From 1fb3fbe55da05fc62bf7cd3b946717b19b3bfd98 Mon Sep 17 00:00:00 2001 From: Alexander Fenster Date: Tue, 31 Mar 2020 15:28:17 -0700 Subject: [PATCH] feat!: drop node8 support, support for async iterators (#396) BREAKING CHANGE: The library now supports Node.js v10+. The last version to support Node.js v8 is tagged legacy-8 on NPM. New feature: methods with pagination now support async iteration. --- .../google-cloud-monitoring/.eslintrc.json | 3 + .../google-cloud-monitoring/.eslintrc.yml | 15 - packages/google-cloud-monitoring/.jsdoc.js | 2 +- packages/google-cloud-monitoring/.prettierrc | 8 - .../google-cloud-monitoring/.prettierrc.js | 17 + packages/google-cloud-monitoring/package.json | 10 +- .../samples/quickstart.js | 2 +- .../src/v3/alert_policy_service_client.ts | 601 +-- .../src/v3/group_service_client.ts | 720 ++-- .../google-cloud-monitoring/src/v3/index.ts | 2 +- .../src/v3/metric_service_client.ts | 974 +++-- .../v3/notification_channel_service_client.ts | 966 +++-- .../v3/service_monitoring_service_client.ts | 905 +++-- .../src/v3/uptime_check_service_client.ts | 732 ++-- .../google-cloud-monitoring/synth.metadata | 19 +- .../system-test/fixtures/sample/src/index.js | 3 +- .../system-test/fixtures/sample/src/index.ts | 23 +- .../system-test/install.ts | 2 +- .../system-test/metrics_service_smoke_test.ts | 3 + .../test/gapic-alert_policy_service-v3.ts | 375 -- .../test/gapic-group_service-v3.ts | 436 -- .../test/gapic-metric_service-v3.ts | 558 --- .../gapic-notification_channel_service-v3.ts | 731 ---- .../gapic-service_monitoring_service-v3.ts | 712 ---- .../test/gapic-uptime_check_service-v3.ts | 445 --- .../test/gapic_alert_policy_service_v3.ts | 2457 ++++++++++++ .../test/gapic_group_service_v3.ts | 2732 +++++++++++++ .../test/gapic_metric_service_v3.ts | 3551 +++++++++++++++++ .../gapic_notification_channel_service_v3.ts | 3442 ++++++++++++++++ .../gapic_service_monitoring_service_v3.ts | 3379 ++++++++++++++++ .../test/gapic_uptime_check_service_v3.ts | 2729 +++++++++++++ .../google-cloud-monitoring/webpack.config.js | 14 +- 32 files changed, 21360 insertions(+), 5208 deletions(-) create mode 100644 packages/google-cloud-monitoring/.eslintrc.json delete mode 100644 packages/google-cloud-monitoring/.eslintrc.yml delete mode 100644 packages/google-cloud-monitoring/.prettierrc create mode 100644 packages/google-cloud-monitoring/.prettierrc.js delete mode 100644 packages/google-cloud-monitoring/test/gapic-alert_policy_service-v3.ts delete mode 100644 packages/google-cloud-monitoring/test/gapic-group_service-v3.ts delete mode 100644 packages/google-cloud-monitoring/test/gapic-metric_service-v3.ts delete mode 100644 packages/google-cloud-monitoring/test/gapic-notification_channel_service-v3.ts delete mode 100644 packages/google-cloud-monitoring/test/gapic-service_monitoring_service-v3.ts delete mode 100644 packages/google-cloud-monitoring/test/gapic-uptime_check_service-v3.ts create mode 100644 packages/google-cloud-monitoring/test/gapic_alert_policy_service_v3.ts create mode 100644 packages/google-cloud-monitoring/test/gapic_group_service_v3.ts create mode 100644 packages/google-cloud-monitoring/test/gapic_metric_service_v3.ts create mode 100644 packages/google-cloud-monitoring/test/gapic_notification_channel_service_v3.ts create mode 100644 packages/google-cloud-monitoring/test/gapic_service_monitoring_service_v3.ts create mode 100644 packages/google-cloud-monitoring/test/gapic_uptime_check_service_v3.ts diff --git a/packages/google-cloud-monitoring/.eslintrc.json b/packages/google-cloud-monitoring/.eslintrc.json new file mode 100644 index 00000000000..78215349546 --- /dev/null +++ b/packages/google-cloud-monitoring/.eslintrc.json @@ -0,0 +1,3 @@ +{ + "extends": "./node_modules/gts" +} diff --git a/packages/google-cloud-monitoring/.eslintrc.yml b/packages/google-cloud-monitoring/.eslintrc.yml deleted file mode 100644 index 73eeec27612..00000000000 --- a/packages/google-cloud-monitoring/.eslintrc.yml +++ /dev/null @@ -1,15 +0,0 @@ ---- -extends: - - 'eslint:recommended' - - 'plugin:node/recommended' - - prettier -plugins: - - node - - prettier -rules: - prettier/prettier: error - block-scoped-var: error - eqeqeq: error - no-warning-comments: warn - no-var: error - prefer-const: error diff --git a/packages/google-cloud-monitoring/.jsdoc.js b/packages/google-cloud-monitoring/.jsdoc.js index bb0edf20f0a..43fd3e0d540 100644 --- a/packages/google-cloud-monitoring/.jsdoc.js +++ b/packages/google-cloud-monitoring/.jsdoc.js @@ -1,4 +1,4 @@ -// Copyright 2019 Google LLC +// Copyright 2020 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/packages/google-cloud-monitoring/.prettierrc b/packages/google-cloud-monitoring/.prettierrc deleted file mode 100644 index df6eac07446..00000000000 --- a/packages/google-cloud-monitoring/.prettierrc +++ /dev/null @@ -1,8 +0,0 @@ ---- -bracketSpacing: false -printWidth: 80 -semi: true -singleQuote: true -tabWidth: 2 -trailingComma: es5 -useTabs: false diff --git a/packages/google-cloud-monitoring/.prettierrc.js b/packages/google-cloud-monitoring/.prettierrc.js new file mode 100644 index 00000000000..08cba3775be --- /dev/null +++ b/packages/google-cloud-monitoring/.prettierrc.js @@ -0,0 +1,17 @@ +// Copyright 2020 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +module.exports = { + ...require('gts/.prettierrc.json') +} diff --git a/packages/google-cloud-monitoring/package.json b/packages/google-cloud-monitoring/package.json index d1819cfa6dc..d5f79fb8a83 100644 --- a/packages/google-cloud-monitoring/package.json +++ b/packages/google-cloud-monitoring/package.json @@ -5,7 +5,7 @@ "license": "Apache-2.0", "author": "Google Inc", "engines": { - "node": ">=8.10.0" + "node": ">=10" }, "repository": "googleapis/nodejs-monitoring", "main": "build/src/index.js", @@ -42,18 +42,19 @@ "prepare": "npm run compile" }, "dependencies": { - "google-gax": "^1.14.1" + "google-gax": "^2.0.1" }, "devDependencies": { "@types/mocha": "^7.0.0", "@types/node": "^12.12.27", + "@types/sinon": "^7.5.2", "c8": "^7.1.0", "codecov": "^3.6.5", "eslint": "^6.0.0", "eslint-config-prettier": "^6.0.0", "eslint-plugin-node": "^11.0.0", "eslint-plugin-prettier": "^3.0.0", - "gts": "^1.0.0", + "gts": "2.0.0-alpha.9", "jsdoc": "^3.5.5", "jsdoc-fresh": "^1.0.1", "jsdoc-region-tag": "^1.0.2", @@ -62,8 +63,9 @@ "null-loader": "^3.0.0", "pack-n-play": "^1.0.0-2", "prettier": "^1.13.7", + "sinon": "^9.0.1", "ts-loader": "^6.2.1", - "typescript": "^3.7.0", + "typescript": "^3.8.3", "webpack": "^4.41.6", "webpack-cli": "^3.3.11" } diff --git a/packages/google-cloud-monitoring/samples/quickstart.js b/packages/google-cloud-monitoring/samples/quickstart.js index 54d132476f4..1be7d2e1822 100644 --- a/packages/google-cloud-monitoring/samples/quickstart.js +++ b/packages/google-cloud-monitoring/samples/quickstart.js @@ -63,7 +63,7 @@ async function quickstart() { // Writes time series data const [result] = await client.createTimeSeries(request); - console.log(`Done writing time series data.`, result); + console.log('Done writing time series data.', result); } // [END monitoring_quickstart] diff --git a/packages/google-cloud-monitoring/src/v3/alert_policy_service_client.ts b/packages/google-cloud-monitoring/src/v3/alert_policy_service_client.ts index 3d45295d634..20c6d51dd9d 100644 --- a/packages/google-cloud-monitoring/src/v3/alert_policy_service_client.ts +++ b/packages/google-cloud-monitoring/src/v3/alert_policy_service_client.ts @@ -1,4 +1,4 @@ -// Copyright 2019 Google LLC +// Copyright 2020 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -18,18 +18,18 @@ import * as gax from 'google-gax'; import { - APICallback, Callback, CallOptions, Descriptors, ClientOptions, PaginationCallback, - PaginationResponse, + GaxCall, } from 'google-gax'; import * as path from 'path'; import {Transform} from 'stream'; -import * as protosTypes from '../../protos/protos'; +import {RequestType} from 'google-gax/build/src/apitypes'; +import * as protos from '../../protos/protos'; import * as gapicConfig from './alert_policy_service_client_config.json'; const version = require('../../../package.json').version; @@ -48,9 +48,6 @@ const version = require('../../../package.json').version; * @memberof v3 */ export class AlertPolicyServiceClient { - private _descriptors: Descriptors = {page: {}, stream: {}, longrunning: {}}; - private _innerApiCalls: {[name: string]: Function}; - private _pathTemplates: {[name: string]: gax.PathTemplate}; private _terminated = false; private _opts: ClientOptions; private _gaxModule: typeof gax | typeof gax.fallback; @@ -58,6 +55,14 @@ export class AlertPolicyServiceClient { private _protos: {}; private _defaults: {[method: string]: gax.CallSettings}; auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + innerApiCalls: {[name: string]: Function}; + pathTemplates: {[name: string]: gax.PathTemplate}; alertPolicyServiceStub?: Promise<{[name: string]: Function}>; /** @@ -149,13 +154,16 @@ export class AlertPolicyServiceClient { 'protos.json' ); this._protos = this._gaxGrpc.loadProto( - opts.fallback ? 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 // identifiers to uniquely identify resources within the API. // Create useful helper objects for these. - this._pathTemplates = { + this.pathTemplates = { folderAlertPolicyPathTemplate: new this._gaxModule.PathTemplate( 'folders/{folder}/alertPolicies/{alert_policy}' ), @@ -236,7 +244,7 @@ export class AlertPolicyServiceClient { // Some of the methods on this service return "paged" results, // (e.g. 50 results at a time, with tokens to get subsequent // pages). Denote the keys used for pagination and results. - this._descriptors.page = { + this.descriptors.page = { listAlertPolicies: new this._gaxModule.PageDescriptor( 'pageToken', 'nextPageToken', @@ -255,7 +263,7 @@ export class AlertPolicyServiceClient { // Set up a dictionary of "inner API calls"; the core implementation // of calling the API is handled in `google-gax`, with this code // merely providing the destination and request information. - this._innerApiCalls = {}; + this.innerApiCalls = {}; } /** @@ -282,7 +290,7 @@ export class AlertPolicyServiceClient { ? (this._protos as protobuf.Root).lookupService( 'google.monitoring.v3.AlertPolicyService' ) - : // tslint:disable-next-line no-any + : // eslint-disable-next-line @typescript-eslint/no-explicit-any (this._protos as any).google.monitoring.v3.AlertPolicyService, this._opts ) as Promise<{[method: string]: Function}>; @@ -296,14 +304,14 @@ export class AlertPolicyServiceClient { 'deleteAlertPolicy', 'updateAlertPolicy', ]; - for (const methodName of alertPolicyServiceStubMethods) { - const innerCallPromise = this.alertPolicyServiceStub.then( + const callPromise = this.alertPolicyServiceStub.then( stub => (...args: Array<{}>) => { if (this._terminated) { return Promise.reject('The client has already been closed.'); } - return stub[methodName].apply(stub, args); + const func = stub[methodName]; + return func.apply(stub, args); }, (err: Error | null | undefined) => () => { throw err; @@ -311,20 +319,14 @@ export class AlertPolicyServiceClient { ); const apiCall = this._gaxModule.createApiCall( - innerCallPromise, + callPromise, this._defaults[methodName], - this._descriptors.page[methodName] || - this._descriptors.stream[methodName] || - this._descriptors.longrunning[methodName] + this.descriptors.page[methodName] || + this.descriptors.stream[methodName] || + this.descriptors.longrunning[methodName] ); - this._innerApiCalls[methodName] = ( - argument: {}, - callOptions?: CallOptions, - callback?: APICallback - ) => { - return apiCall(argument, callOptions, callback); - }; + this.innerApiCalls[methodName] = apiCall; } return this.alertPolicyServiceStub; @@ -385,22 +387,30 @@ export class AlertPolicyServiceClient { // -- Service calls -- // ------------------- getAlertPolicy( - request: protosTypes.google.monitoring.v3.IGetAlertPolicyRequest, + request: protos.google.monitoring.v3.IGetAlertPolicyRequest, options?: gax.CallOptions ): Promise< [ - protosTypes.google.monitoring.v3.IAlertPolicy, - protosTypes.google.monitoring.v3.IGetAlertPolicyRequest | undefined, + protos.google.monitoring.v3.IAlertPolicy, + protos.google.monitoring.v3.IGetAlertPolicyRequest | undefined, {} | undefined ] >; getAlertPolicy( - request: protosTypes.google.monitoring.v3.IGetAlertPolicyRequest, + request: protos.google.monitoring.v3.IGetAlertPolicyRequest, options: gax.CallOptions, callback: Callback< - protosTypes.google.monitoring.v3.IAlertPolicy, - protosTypes.google.monitoring.v3.IGetAlertPolicyRequest | undefined, - {} | undefined + protos.google.monitoring.v3.IAlertPolicy, + protos.google.monitoring.v3.IGetAlertPolicyRequest | null | undefined, + {} | null | undefined + > + ): void; + getAlertPolicy( + request: protos.google.monitoring.v3.IGetAlertPolicyRequest, + callback: Callback< + protos.google.monitoring.v3.IAlertPolicy, + protos.google.monitoring.v3.IGetAlertPolicyRequest | null | undefined, + {} | null | undefined > ): void; /** @@ -419,23 +429,23 @@ export class AlertPolicyServiceClient { * The promise has a method named "cancel" which cancels the ongoing API call. */ getAlertPolicy( - request: protosTypes.google.monitoring.v3.IGetAlertPolicyRequest, + request: protos.google.monitoring.v3.IGetAlertPolicyRequest, optionsOrCallback?: | gax.CallOptions | Callback< - protosTypes.google.monitoring.v3.IAlertPolicy, - protosTypes.google.monitoring.v3.IGetAlertPolicyRequest | undefined, - {} | undefined + protos.google.monitoring.v3.IAlertPolicy, + protos.google.monitoring.v3.IGetAlertPolicyRequest | null | undefined, + {} | null | undefined >, callback?: Callback< - protosTypes.google.monitoring.v3.IAlertPolicy, - protosTypes.google.monitoring.v3.IGetAlertPolicyRequest | undefined, - {} | undefined + protos.google.monitoring.v3.IAlertPolicy, + protos.google.monitoring.v3.IGetAlertPolicyRequest | null | undefined, + {} | null | undefined > ): Promise< [ - protosTypes.google.monitoring.v3.IAlertPolicy, - protosTypes.google.monitoring.v3.IGetAlertPolicyRequest | undefined, + protos.google.monitoring.v3.IAlertPolicy, + protos.google.monitoring.v3.IGetAlertPolicyRequest | undefined, {} | undefined ] > | void { @@ -456,25 +466,33 @@ export class AlertPolicyServiceClient { name: request.name || '', }); this.initialize(); - return this._innerApiCalls.getAlertPolicy(request, options, callback); + return this.innerApiCalls.getAlertPolicy(request, options, callback); } createAlertPolicy( - request: protosTypes.google.monitoring.v3.ICreateAlertPolicyRequest, + request: protos.google.monitoring.v3.ICreateAlertPolicyRequest, options?: gax.CallOptions ): Promise< [ - protosTypes.google.monitoring.v3.IAlertPolicy, - protosTypes.google.monitoring.v3.ICreateAlertPolicyRequest | undefined, + protos.google.monitoring.v3.IAlertPolicy, + protos.google.monitoring.v3.ICreateAlertPolicyRequest | undefined, {} | undefined ] >; createAlertPolicy( - request: protosTypes.google.monitoring.v3.ICreateAlertPolicyRequest, + request: protos.google.monitoring.v3.ICreateAlertPolicyRequest, options: gax.CallOptions, callback: Callback< - protosTypes.google.monitoring.v3.IAlertPolicy, - protosTypes.google.monitoring.v3.ICreateAlertPolicyRequest | undefined, - {} | undefined + protos.google.monitoring.v3.IAlertPolicy, + protos.google.monitoring.v3.ICreateAlertPolicyRequest | null | undefined, + {} | null | undefined + > + ): void; + createAlertPolicy( + request: protos.google.monitoring.v3.ICreateAlertPolicyRequest, + callback: Callback< + protos.google.monitoring.v3.IAlertPolicy, + protos.google.monitoring.v3.ICreateAlertPolicyRequest | null | undefined, + {} | null | undefined > ): void; /** @@ -504,24 +522,25 @@ export class AlertPolicyServiceClient { * The promise has a method named "cancel" which cancels the ongoing API call. */ createAlertPolicy( - request: protosTypes.google.monitoring.v3.ICreateAlertPolicyRequest, + request: protos.google.monitoring.v3.ICreateAlertPolicyRequest, optionsOrCallback?: | gax.CallOptions | Callback< - protosTypes.google.monitoring.v3.IAlertPolicy, - | protosTypes.google.monitoring.v3.ICreateAlertPolicyRequest + protos.google.monitoring.v3.IAlertPolicy, + | protos.google.monitoring.v3.ICreateAlertPolicyRequest + | null | undefined, - {} | undefined + {} | null | undefined >, callback?: Callback< - protosTypes.google.monitoring.v3.IAlertPolicy, - protosTypes.google.monitoring.v3.ICreateAlertPolicyRequest | undefined, - {} | undefined + protos.google.monitoring.v3.IAlertPolicy, + protos.google.monitoring.v3.ICreateAlertPolicyRequest | null | undefined, + {} | null | undefined > ): Promise< [ - protosTypes.google.monitoring.v3.IAlertPolicy, - protosTypes.google.monitoring.v3.ICreateAlertPolicyRequest | undefined, + protos.google.monitoring.v3.IAlertPolicy, + protos.google.monitoring.v3.ICreateAlertPolicyRequest | undefined, {} | undefined ] > | void { @@ -542,25 +561,33 @@ export class AlertPolicyServiceClient { name: request.name || '', }); this.initialize(); - return this._innerApiCalls.createAlertPolicy(request, options, callback); + return this.innerApiCalls.createAlertPolicy(request, options, callback); } deleteAlertPolicy( - request: protosTypes.google.monitoring.v3.IDeleteAlertPolicyRequest, + request: protos.google.monitoring.v3.IDeleteAlertPolicyRequest, options?: gax.CallOptions ): Promise< [ - protosTypes.google.protobuf.IEmpty, - protosTypes.google.monitoring.v3.IDeleteAlertPolicyRequest | undefined, + protos.google.protobuf.IEmpty, + protos.google.monitoring.v3.IDeleteAlertPolicyRequest | undefined, {} | undefined ] >; deleteAlertPolicy( - request: protosTypes.google.monitoring.v3.IDeleteAlertPolicyRequest, + request: protos.google.monitoring.v3.IDeleteAlertPolicyRequest, options: gax.CallOptions, callback: Callback< - protosTypes.google.protobuf.IEmpty, - protosTypes.google.monitoring.v3.IDeleteAlertPolicyRequest | undefined, - {} | undefined + protos.google.protobuf.IEmpty, + protos.google.monitoring.v3.IDeleteAlertPolicyRequest | null | undefined, + {} | null | undefined + > + ): void; + deleteAlertPolicy( + request: protos.google.monitoring.v3.IDeleteAlertPolicyRequest, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.monitoring.v3.IDeleteAlertPolicyRequest | null | undefined, + {} | null | undefined > ): void; /** @@ -581,24 +608,25 @@ export class AlertPolicyServiceClient { * The promise has a method named "cancel" which cancels the ongoing API call. */ deleteAlertPolicy( - request: protosTypes.google.monitoring.v3.IDeleteAlertPolicyRequest, + request: protos.google.monitoring.v3.IDeleteAlertPolicyRequest, optionsOrCallback?: | gax.CallOptions | Callback< - protosTypes.google.protobuf.IEmpty, - | protosTypes.google.monitoring.v3.IDeleteAlertPolicyRequest + protos.google.protobuf.IEmpty, + | protos.google.monitoring.v3.IDeleteAlertPolicyRequest + | null | undefined, - {} | undefined + {} | null | undefined >, callback?: Callback< - protosTypes.google.protobuf.IEmpty, - protosTypes.google.monitoring.v3.IDeleteAlertPolicyRequest | undefined, - {} | undefined + protos.google.protobuf.IEmpty, + protos.google.monitoring.v3.IDeleteAlertPolicyRequest | null | undefined, + {} | null | undefined > ): Promise< [ - protosTypes.google.protobuf.IEmpty, - protosTypes.google.monitoring.v3.IDeleteAlertPolicyRequest | undefined, + protos.google.protobuf.IEmpty, + protos.google.monitoring.v3.IDeleteAlertPolicyRequest | undefined, {} | undefined ] > | void { @@ -619,25 +647,33 @@ export class AlertPolicyServiceClient { name: request.name || '', }); this.initialize(); - return this._innerApiCalls.deleteAlertPolicy(request, options, callback); + return this.innerApiCalls.deleteAlertPolicy(request, options, callback); } updateAlertPolicy( - request: protosTypes.google.monitoring.v3.IUpdateAlertPolicyRequest, + request: protos.google.monitoring.v3.IUpdateAlertPolicyRequest, options?: gax.CallOptions ): Promise< [ - protosTypes.google.monitoring.v3.IAlertPolicy, - protosTypes.google.monitoring.v3.IUpdateAlertPolicyRequest | undefined, + protos.google.monitoring.v3.IAlertPolicy, + protos.google.monitoring.v3.IUpdateAlertPolicyRequest | undefined, {} | undefined ] >; updateAlertPolicy( - request: protosTypes.google.monitoring.v3.IUpdateAlertPolicyRequest, + request: protos.google.monitoring.v3.IUpdateAlertPolicyRequest, options: gax.CallOptions, callback: Callback< - protosTypes.google.monitoring.v3.IAlertPolicy, - protosTypes.google.monitoring.v3.IUpdateAlertPolicyRequest | undefined, - {} | undefined + protos.google.monitoring.v3.IAlertPolicy, + protos.google.monitoring.v3.IUpdateAlertPolicyRequest | null | undefined, + {} | null | undefined + > + ): void; + updateAlertPolicy( + request: protos.google.monitoring.v3.IUpdateAlertPolicyRequest, + callback: Callback< + protos.google.monitoring.v3.IAlertPolicy, + protos.google.monitoring.v3.IUpdateAlertPolicyRequest | null | undefined, + {} | null | undefined > ): void; /** @@ -682,24 +718,25 @@ export class AlertPolicyServiceClient { * The promise has a method named "cancel" which cancels the ongoing API call. */ updateAlertPolicy( - request: protosTypes.google.monitoring.v3.IUpdateAlertPolicyRequest, + request: protos.google.monitoring.v3.IUpdateAlertPolicyRequest, optionsOrCallback?: | gax.CallOptions | Callback< - protosTypes.google.monitoring.v3.IAlertPolicy, - | protosTypes.google.monitoring.v3.IUpdateAlertPolicyRequest + protos.google.monitoring.v3.IAlertPolicy, + | protos.google.monitoring.v3.IUpdateAlertPolicyRequest + | null | undefined, - {} | undefined + {} | null | undefined >, callback?: Callback< - protosTypes.google.monitoring.v3.IAlertPolicy, - protosTypes.google.monitoring.v3.IUpdateAlertPolicyRequest | undefined, - {} | undefined + protos.google.monitoring.v3.IAlertPolicy, + protos.google.monitoring.v3.IUpdateAlertPolicyRequest | null | undefined, + {} | null | undefined > ): Promise< [ - protosTypes.google.monitoring.v3.IAlertPolicy, - protosTypes.google.monitoring.v3.IUpdateAlertPolicyRequest | undefined, + protos.google.monitoring.v3.IAlertPolicy, + protos.google.monitoring.v3.IUpdateAlertPolicyRequest | undefined, {} | undefined ] > | void { @@ -720,26 +757,34 @@ export class AlertPolicyServiceClient { 'alert_policy.name': request.alertPolicy!.name || '', }); this.initialize(); - return this._innerApiCalls.updateAlertPolicy(request, options, callback); + return this.innerApiCalls.updateAlertPolicy(request, options, callback); } listAlertPolicies( - request: protosTypes.google.monitoring.v3.IListAlertPoliciesRequest, + request: protos.google.monitoring.v3.IListAlertPoliciesRequest, options?: gax.CallOptions ): Promise< [ - protosTypes.google.monitoring.v3.IAlertPolicy[], - protosTypes.google.monitoring.v3.IListAlertPoliciesRequest | null, - protosTypes.google.monitoring.v3.IListAlertPoliciesResponse + protos.google.monitoring.v3.IAlertPolicy[], + protos.google.monitoring.v3.IListAlertPoliciesRequest | null, + protos.google.monitoring.v3.IListAlertPoliciesResponse ] >; listAlertPolicies( - request: protosTypes.google.monitoring.v3.IListAlertPoliciesRequest, + request: protos.google.monitoring.v3.IListAlertPoliciesRequest, options: gax.CallOptions, - callback: Callback< - protosTypes.google.monitoring.v3.IAlertPolicy[], - protosTypes.google.monitoring.v3.IListAlertPoliciesRequest | null, - protosTypes.google.monitoring.v3.IListAlertPoliciesResponse + callback: PaginationCallback< + protos.google.monitoring.v3.IListAlertPoliciesRequest, + protos.google.monitoring.v3.IListAlertPoliciesResponse | null | undefined, + protos.google.monitoring.v3.IAlertPolicy + > + ): void; + listAlertPolicies( + request: protos.google.monitoring.v3.IListAlertPoliciesRequest, + callback: PaginationCallback< + protos.google.monitoring.v3.IListAlertPoliciesRequest, + protos.google.monitoring.v3.IListAlertPoliciesResponse | null | undefined, + protos.google.monitoring.v3.IAlertPolicy > ): void; /** @@ -795,24 +840,26 @@ export class AlertPolicyServiceClient { * The promise has a method named "cancel" which cancels the ongoing API call. */ listAlertPolicies( - request: protosTypes.google.monitoring.v3.IListAlertPoliciesRequest, + request: protos.google.monitoring.v3.IListAlertPoliciesRequest, optionsOrCallback?: | gax.CallOptions - | Callback< - protosTypes.google.monitoring.v3.IAlertPolicy[], - protosTypes.google.monitoring.v3.IListAlertPoliciesRequest | null, - protosTypes.google.monitoring.v3.IListAlertPoliciesResponse + | PaginationCallback< + protos.google.monitoring.v3.IListAlertPoliciesRequest, + | protos.google.monitoring.v3.IListAlertPoliciesResponse + | null + | undefined, + protos.google.monitoring.v3.IAlertPolicy >, - callback?: Callback< - protosTypes.google.monitoring.v3.IAlertPolicy[], - protosTypes.google.monitoring.v3.IListAlertPoliciesRequest | null, - protosTypes.google.monitoring.v3.IListAlertPoliciesResponse + callback?: PaginationCallback< + protos.google.monitoring.v3.IListAlertPoliciesRequest, + protos.google.monitoring.v3.IListAlertPoliciesResponse | null | undefined, + protos.google.monitoring.v3.IAlertPolicy > ): Promise< [ - protosTypes.google.monitoring.v3.IAlertPolicy[], - protosTypes.google.monitoring.v3.IListAlertPoliciesRequest | null, - protosTypes.google.monitoring.v3.IListAlertPoliciesResponse + protos.google.monitoring.v3.IAlertPolicy[], + protos.google.monitoring.v3.IListAlertPoliciesRequest | null, + protos.google.monitoring.v3.IListAlertPoliciesResponse ] > | void { request = request || {}; @@ -832,7 +879,7 @@ export class AlertPolicyServiceClient { name: request.name || '', }); this.initialize(); - return this._innerApiCalls.listAlertPolicies(request, options, callback); + return this.innerApiCalls.listAlertPolicies(request, options, callback); } /** @@ -885,7 +932,7 @@ export class AlertPolicyServiceClient { * An object stream which emits an object representing [AlertPolicy]{@link google.monitoring.v3.AlertPolicy} on 'data' event. */ listAlertPoliciesStream( - request?: protosTypes.google.monitoring.v3.IListAlertPoliciesRequest, + request?: protos.google.monitoring.v3.IListAlertPoliciesRequest, options?: gax.CallOptions ): Transform { request = request || {}; @@ -899,12 +946,76 @@ export class AlertPolicyServiceClient { }); const callSettings = new gax.CallSettings(options); this.initialize(); - return this._descriptors.page.listAlertPolicies.createStream( - this._innerApiCalls.listAlertPolicies as gax.GaxCall, + return this.descriptors.page.listAlertPolicies.createStream( + this.innerApiCalls.listAlertPolicies as gax.GaxCall, request, callSettings ); } + + /** + * Equivalent to {@link listAlertPolicies}, 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.name + * Required. The project whose alert policies are to be listed. The format is: + * + * projects/[PROJECT_ID_OR_NUMBER] + * + * Note that this field names the parent container in which the alerting + * policies to be listed are stored. To retrieve a single alerting policy + * by name, use the + * {@link google.monitoring.v3.AlertPolicyService.GetAlertPolicy|GetAlertPolicy} + * operation, instead. + * @param {string} request.filter + * If provided, this field specifies the criteria that must be met by + * alert policies to be included in the response. + * + * For more details, see [sorting and + * filtering](https://cloud.google.com/monitoring/api/v3/sorting-and-filtering). + * @param {string} request.orderBy + * A comma-separated list of fields by which to sort the result. Supports + * the same set of field references as the `filter` field. Entries can be + * prefixed with a minus sign to sort by the field in descending order. + * + * For more details, see [sorting and + * filtering](https://cloud.google.com/monitoring/api/v3/sorting-and-filtering). + * @param {number} request.pageSize + * The maximum number of results to return in a single response. + * @param {string} request.pageToken + * If this field is not empty then it must contain the `nextPageToken` value + * returned by a previous call to this method. Using this field causes the + * method to return more results from the previous method call. + * @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. + */ + listAlertPoliciesAsync( + request?: protos.google.monitoring.v3.IListAlertPoliciesRequest, + options?: gax.CallOptions + ): AsyncIterable { + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + name: request.name || '', + }); + options = options || {}; + const callSettings = new gax.CallSettings(options); + this.initialize(); + return this.descriptors.page.listAlertPolicies.asyncIterate( + this.innerApiCalls['listAlertPolicies'] as GaxCall, + (request as unknown) as RequestType, + callSettings + ) as AsyncIterable; + } // -------------------- // -- Path templates -- // -------------------- @@ -917,8 +1028,8 @@ export class AlertPolicyServiceClient { * @returns {string} Resource name string. */ folderAlertPolicyPath(folder: string, alertPolicy: string) { - return this._pathTemplates.folderAlertPolicyPathTemplate.render({ - folder, + return this.pathTemplates.folderAlertPolicyPathTemplate.render({ + folder: folder, alert_policy: alertPolicy, }); } @@ -931,7 +1042,7 @@ export class AlertPolicyServiceClient { * @returns {string} A string representing the folder. */ matchFolderFromFolderAlertPolicyName(folderAlertPolicyName: string) { - return this._pathTemplates.folderAlertPolicyPathTemplate.match( + return this.pathTemplates.folderAlertPolicyPathTemplate.match( folderAlertPolicyName ).folder; } @@ -944,7 +1055,7 @@ export class AlertPolicyServiceClient { * @returns {string} A string representing the alert_policy. */ matchAlertPolicyFromFolderAlertPolicyName(folderAlertPolicyName: string) { - return this._pathTemplates.folderAlertPolicyPathTemplate.match( + return this.pathTemplates.folderAlertPolicyPathTemplate.match( folderAlertPolicyName ).alert_policy; } @@ -962,10 +1073,10 @@ export class AlertPolicyServiceClient { alertPolicy: string, condition: string ) { - return this._pathTemplates.folderAlertPolicyConditionPathTemplate.render({ - folder, + return this.pathTemplates.folderAlertPolicyConditionPathTemplate.render({ + folder: folder, alert_policy: alertPolicy, - condition, + condition: condition, }); } @@ -979,7 +1090,7 @@ export class AlertPolicyServiceClient { matchFolderFromFolderAlertPolicyConditionName( folderAlertPolicyConditionName: string ) { - return this._pathTemplates.folderAlertPolicyConditionPathTemplate.match( + return this.pathTemplates.folderAlertPolicyConditionPathTemplate.match( folderAlertPolicyConditionName ).folder; } @@ -994,7 +1105,7 @@ export class AlertPolicyServiceClient { matchAlertPolicyFromFolderAlertPolicyConditionName( folderAlertPolicyConditionName: string ) { - return this._pathTemplates.folderAlertPolicyConditionPathTemplate.match( + return this.pathTemplates.folderAlertPolicyConditionPathTemplate.match( folderAlertPolicyConditionName ).alert_policy; } @@ -1009,7 +1120,7 @@ export class AlertPolicyServiceClient { matchConditionFromFolderAlertPolicyConditionName( folderAlertPolicyConditionName: string ) { - return this._pathTemplates.folderAlertPolicyConditionPathTemplate.match( + return this.pathTemplates.folderAlertPolicyConditionPathTemplate.match( folderAlertPolicyConditionName ).condition; } @@ -1022,8 +1133,8 @@ export class AlertPolicyServiceClient { * @returns {string} Resource name string. */ folderChannelDescriptorPath(folder: string, channelDescriptor: string) { - return this._pathTemplates.folderChannelDescriptorPathTemplate.render({ - folder, + return this.pathTemplates.folderChannelDescriptorPathTemplate.render({ + folder: folder, channel_descriptor: channelDescriptor, }); } @@ -1038,7 +1149,7 @@ export class AlertPolicyServiceClient { matchFolderFromFolderChannelDescriptorName( folderChannelDescriptorName: string ) { - return this._pathTemplates.folderChannelDescriptorPathTemplate.match( + return this.pathTemplates.folderChannelDescriptorPathTemplate.match( folderChannelDescriptorName ).folder; } @@ -1053,7 +1164,7 @@ export class AlertPolicyServiceClient { matchChannelDescriptorFromFolderChannelDescriptorName( folderChannelDescriptorName: string ) { - return this._pathTemplates.folderChannelDescriptorPathTemplate.match( + return this.pathTemplates.folderChannelDescriptorPathTemplate.match( folderChannelDescriptorName ).channel_descriptor; } @@ -1066,9 +1177,9 @@ export class AlertPolicyServiceClient { * @returns {string} Resource name string. */ folderGroupPath(folder: string, group: string) { - return this._pathTemplates.folderGroupPathTemplate.render({ - folder, - group, + return this.pathTemplates.folderGroupPathTemplate.render({ + folder: folder, + group: group, }); } @@ -1080,7 +1191,7 @@ export class AlertPolicyServiceClient { * @returns {string} A string representing the folder. */ matchFolderFromFolderGroupName(folderGroupName: string) { - return this._pathTemplates.folderGroupPathTemplate.match(folderGroupName) + return this.pathTemplates.folderGroupPathTemplate.match(folderGroupName) .folder; } @@ -1092,7 +1203,7 @@ export class AlertPolicyServiceClient { * @returns {string} A string representing the group. */ matchGroupFromFolderGroupName(folderGroupName: string) { - return this._pathTemplates.folderGroupPathTemplate.match(folderGroupName) + return this.pathTemplates.folderGroupPathTemplate.match(folderGroupName) .group; } @@ -1104,8 +1215,8 @@ export class AlertPolicyServiceClient { * @returns {string} Resource name string. */ folderNotificationChannelPath(folder: string, notificationChannel: string) { - return this._pathTemplates.folderNotificationChannelPathTemplate.render({ - folder, + return this.pathTemplates.folderNotificationChannelPathTemplate.render({ + folder: folder, notification_channel: notificationChannel, }); } @@ -1120,7 +1231,7 @@ export class AlertPolicyServiceClient { matchFolderFromFolderNotificationChannelName( folderNotificationChannelName: string ) { - return this._pathTemplates.folderNotificationChannelPathTemplate.match( + return this.pathTemplates.folderNotificationChannelPathTemplate.match( folderNotificationChannelName ).folder; } @@ -1135,7 +1246,7 @@ export class AlertPolicyServiceClient { matchNotificationChannelFromFolderNotificationChannelName( folderNotificationChannelName: string ) { - return this._pathTemplates.folderNotificationChannelPathTemplate.match( + return this.pathTemplates.folderNotificationChannelPathTemplate.match( folderNotificationChannelName ).notification_channel; } @@ -1148,9 +1259,9 @@ export class AlertPolicyServiceClient { * @returns {string} Resource name string. */ folderServicePath(folder: string, service: string) { - return this._pathTemplates.folderServicePathTemplate.render({ - folder, - service, + return this.pathTemplates.folderServicePathTemplate.render({ + folder: folder, + service: service, }); } @@ -1162,9 +1273,8 @@ export class AlertPolicyServiceClient { * @returns {string} A string representing the folder. */ matchFolderFromFolderServiceName(folderServiceName: string) { - return this._pathTemplates.folderServicePathTemplate.match( - folderServiceName - ).folder; + return this.pathTemplates.folderServicePathTemplate.match(folderServiceName) + .folder; } /** @@ -1175,9 +1285,8 @@ export class AlertPolicyServiceClient { * @returns {string} A string representing the service. */ matchServiceFromFolderServiceName(folderServiceName: string) { - return this._pathTemplates.folderServicePathTemplate.match( - folderServiceName - ).service; + return this.pathTemplates.folderServicePathTemplate.match(folderServiceName) + .service; } /** @@ -1193,10 +1302,10 @@ export class AlertPolicyServiceClient { service: string, serviceLevelObjective: string ) { - return this._pathTemplates.folderServiceServiceLevelObjectivePathTemplate.render( + return this.pathTemplates.folderServiceServiceLevelObjectivePathTemplate.render( { - folder, - service, + folder: folder, + service: service, service_level_objective: serviceLevelObjective, } ); @@ -1212,7 +1321,7 @@ export class AlertPolicyServiceClient { matchFolderFromFolderServiceServiceLevelObjectiveName( folderServiceServiceLevelObjectiveName: string ) { - return this._pathTemplates.folderServiceServiceLevelObjectivePathTemplate.match( + return this.pathTemplates.folderServiceServiceLevelObjectivePathTemplate.match( folderServiceServiceLevelObjectiveName ).folder; } @@ -1227,7 +1336,7 @@ export class AlertPolicyServiceClient { matchServiceFromFolderServiceServiceLevelObjectiveName( folderServiceServiceLevelObjectiveName: string ) { - return this._pathTemplates.folderServiceServiceLevelObjectivePathTemplate.match( + return this.pathTemplates.folderServiceServiceLevelObjectivePathTemplate.match( folderServiceServiceLevelObjectiveName ).service; } @@ -1242,7 +1351,7 @@ export class AlertPolicyServiceClient { matchServiceLevelObjectiveFromFolderServiceServiceLevelObjectiveName( folderServiceServiceLevelObjectiveName: string ) { - return this._pathTemplates.folderServiceServiceLevelObjectivePathTemplate.match( + return this.pathTemplates.folderServiceServiceLevelObjectivePathTemplate.match( folderServiceServiceLevelObjectiveName ).service_level_objective; } @@ -1255,8 +1364,8 @@ export class AlertPolicyServiceClient { * @returns {string} Resource name string. */ folderUptimeCheckConfigPath(folder: string, uptimeCheckConfig: string) { - return this._pathTemplates.folderUptimeCheckConfigPathTemplate.render({ - folder, + return this.pathTemplates.folderUptimeCheckConfigPathTemplate.render({ + folder: folder, uptime_check_config: uptimeCheckConfig, }); } @@ -1271,7 +1380,7 @@ export class AlertPolicyServiceClient { matchFolderFromFolderUptimeCheckConfigName( folderUptimeCheckConfigName: string ) { - return this._pathTemplates.folderUptimeCheckConfigPathTemplate.match( + return this.pathTemplates.folderUptimeCheckConfigPathTemplate.match( folderUptimeCheckConfigName ).folder; } @@ -1286,7 +1395,7 @@ export class AlertPolicyServiceClient { matchUptimeCheckConfigFromFolderUptimeCheckConfigName( folderUptimeCheckConfigName: string ) { - return this._pathTemplates.folderUptimeCheckConfigPathTemplate.match( + return this.pathTemplates.folderUptimeCheckConfigPathTemplate.match( folderUptimeCheckConfigName ).uptime_check_config; } @@ -1299,8 +1408,8 @@ export class AlertPolicyServiceClient { * @returns {string} Resource name string. */ organizationAlertPolicyPath(organization: string, alertPolicy: string) { - return this._pathTemplates.organizationAlertPolicyPathTemplate.render({ - organization, + return this.pathTemplates.organizationAlertPolicyPathTemplate.render({ + organization: organization, alert_policy: alertPolicy, }); } @@ -1315,7 +1424,7 @@ export class AlertPolicyServiceClient { matchOrganizationFromOrganizationAlertPolicyName( organizationAlertPolicyName: string ) { - return this._pathTemplates.organizationAlertPolicyPathTemplate.match( + return this.pathTemplates.organizationAlertPolicyPathTemplate.match( organizationAlertPolicyName ).organization; } @@ -1330,7 +1439,7 @@ export class AlertPolicyServiceClient { matchAlertPolicyFromOrganizationAlertPolicyName( organizationAlertPolicyName: string ) { - return this._pathTemplates.organizationAlertPolicyPathTemplate.match( + return this.pathTemplates.organizationAlertPolicyPathTemplate.match( organizationAlertPolicyName ).alert_policy; } @@ -1348,11 +1457,11 @@ export class AlertPolicyServiceClient { alertPolicy: string, condition: string ) { - return this._pathTemplates.organizationAlertPolicyConditionPathTemplate.render( + return this.pathTemplates.organizationAlertPolicyConditionPathTemplate.render( { - organization, + organization: organization, alert_policy: alertPolicy, - condition, + condition: condition, } ); } @@ -1367,7 +1476,7 @@ export class AlertPolicyServiceClient { matchOrganizationFromOrganizationAlertPolicyConditionName( organizationAlertPolicyConditionName: string ) { - return this._pathTemplates.organizationAlertPolicyConditionPathTemplate.match( + return this.pathTemplates.organizationAlertPolicyConditionPathTemplate.match( organizationAlertPolicyConditionName ).organization; } @@ -1382,7 +1491,7 @@ export class AlertPolicyServiceClient { matchAlertPolicyFromOrganizationAlertPolicyConditionName( organizationAlertPolicyConditionName: string ) { - return this._pathTemplates.organizationAlertPolicyConditionPathTemplate.match( + return this.pathTemplates.organizationAlertPolicyConditionPathTemplate.match( organizationAlertPolicyConditionName ).alert_policy; } @@ -1397,7 +1506,7 @@ export class AlertPolicyServiceClient { matchConditionFromOrganizationAlertPolicyConditionName( organizationAlertPolicyConditionName: string ) { - return this._pathTemplates.organizationAlertPolicyConditionPathTemplate.match( + return this.pathTemplates.organizationAlertPolicyConditionPathTemplate.match( organizationAlertPolicyConditionName ).condition; } @@ -1413,12 +1522,10 @@ export class AlertPolicyServiceClient { organization: string, channelDescriptor: string ) { - return this._pathTemplates.organizationChannelDescriptorPathTemplate.render( - { - organization, - channel_descriptor: channelDescriptor, - } - ); + return this.pathTemplates.organizationChannelDescriptorPathTemplate.render({ + organization: organization, + channel_descriptor: channelDescriptor, + }); } /** @@ -1431,7 +1538,7 @@ export class AlertPolicyServiceClient { matchOrganizationFromOrganizationChannelDescriptorName( organizationChannelDescriptorName: string ) { - return this._pathTemplates.organizationChannelDescriptorPathTemplate.match( + return this.pathTemplates.organizationChannelDescriptorPathTemplate.match( organizationChannelDescriptorName ).organization; } @@ -1446,7 +1553,7 @@ export class AlertPolicyServiceClient { matchChannelDescriptorFromOrganizationChannelDescriptorName( organizationChannelDescriptorName: string ) { - return this._pathTemplates.organizationChannelDescriptorPathTemplate.match( + return this.pathTemplates.organizationChannelDescriptorPathTemplate.match( organizationChannelDescriptorName ).channel_descriptor; } @@ -1459,9 +1566,9 @@ export class AlertPolicyServiceClient { * @returns {string} Resource name string. */ organizationGroupPath(organization: string, group: string) { - return this._pathTemplates.organizationGroupPathTemplate.render({ - organization, - group, + return this.pathTemplates.organizationGroupPathTemplate.render({ + organization: organization, + group: group, }); } @@ -1473,7 +1580,7 @@ export class AlertPolicyServiceClient { * @returns {string} A string representing the organization. */ matchOrganizationFromOrganizationGroupName(organizationGroupName: string) { - return this._pathTemplates.organizationGroupPathTemplate.match( + return this.pathTemplates.organizationGroupPathTemplate.match( organizationGroupName ).organization; } @@ -1486,7 +1593,7 @@ export class AlertPolicyServiceClient { * @returns {string} A string representing the group. */ matchGroupFromOrganizationGroupName(organizationGroupName: string) { - return this._pathTemplates.organizationGroupPathTemplate.match( + return this.pathTemplates.organizationGroupPathTemplate.match( organizationGroupName ).group; } @@ -1502,9 +1609,9 @@ export class AlertPolicyServiceClient { organization: string, notificationChannel: string ) { - return this._pathTemplates.organizationNotificationChannelPathTemplate.render( + return this.pathTemplates.organizationNotificationChannelPathTemplate.render( { - organization, + organization: organization, notification_channel: notificationChannel, } ); @@ -1520,7 +1627,7 @@ export class AlertPolicyServiceClient { matchOrganizationFromOrganizationNotificationChannelName( organizationNotificationChannelName: string ) { - return this._pathTemplates.organizationNotificationChannelPathTemplate.match( + return this.pathTemplates.organizationNotificationChannelPathTemplate.match( organizationNotificationChannelName ).organization; } @@ -1535,7 +1642,7 @@ export class AlertPolicyServiceClient { matchNotificationChannelFromOrganizationNotificationChannelName( organizationNotificationChannelName: string ) { - return this._pathTemplates.organizationNotificationChannelPathTemplate.match( + return this.pathTemplates.organizationNotificationChannelPathTemplate.match( organizationNotificationChannelName ).notification_channel; } @@ -1548,9 +1655,9 @@ export class AlertPolicyServiceClient { * @returns {string} Resource name string. */ organizationServicePath(organization: string, service: string) { - return this._pathTemplates.organizationServicePathTemplate.render({ - organization, - service, + return this.pathTemplates.organizationServicePathTemplate.render({ + organization: organization, + service: service, }); } @@ -1564,7 +1671,7 @@ export class AlertPolicyServiceClient { matchOrganizationFromOrganizationServiceName( organizationServiceName: string ) { - return this._pathTemplates.organizationServicePathTemplate.match( + return this.pathTemplates.organizationServicePathTemplate.match( organizationServiceName ).organization; } @@ -1577,7 +1684,7 @@ export class AlertPolicyServiceClient { * @returns {string} A string representing the service. */ matchServiceFromOrganizationServiceName(organizationServiceName: string) { - return this._pathTemplates.organizationServicePathTemplate.match( + return this.pathTemplates.organizationServicePathTemplate.match( organizationServiceName ).service; } @@ -1595,10 +1702,10 @@ export class AlertPolicyServiceClient { service: string, serviceLevelObjective: string ) { - return this._pathTemplates.organizationServiceServiceLevelObjectivePathTemplate.render( + return this.pathTemplates.organizationServiceServiceLevelObjectivePathTemplate.render( { - organization, - service, + organization: organization, + service: service, service_level_objective: serviceLevelObjective, } ); @@ -1614,7 +1721,7 @@ export class AlertPolicyServiceClient { matchOrganizationFromOrganizationServiceServiceLevelObjectiveName( organizationServiceServiceLevelObjectiveName: string ) { - return this._pathTemplates.organizationServiceServiceLevelObjectivePathTemplate.match( + return this.pathTemplates.organizationServiceServiceLevelObjectivePathTemplate.match( organizationServiceServiceLevelObjectiveName ).organization; } @@ -1629,7 +1736,7 @@ export class AlertPolicyServiceClient { matchServiceFromOrganizationServiceServiceLevelObjectiveName( organizationServiceServiceLevelObjectiveName: string ) { - return this._pathTemplates.organizationServiceServiceLevelObjectivePathTemplate.match( + return this.pathTemplates.organizationServiceServiceLevelObjectivePathTemplate.match( organizationServiceServiceLevelObjectiveName ).service; } @@ -1644,7 +1751,7 @@ export class AlertPolicyServiceClient { matchServiceLevelObjectiveFromOrganizationServiceServiceLevelObjectiveName( organizationServiceServiceLevelObjectiveName: string ) { - return this._pathTemplates.organizationServiceServiceLevelObjectivePathTemplate.match( + return this.pathTemplates.organizationServiceServiceLevelObjectivePathTemplate.match( organizationServiceServiceLevelObjectiveName ).service_level_objective; } @@ -1660,12 +1767,10 @@ export class AlertPolicyServiceClient { organization: string, uptimeCheckConfig: string ) { - return this._pathTemplates.organizationUptimeCheckConfigPathTemplate.render( - { - organization, - uptime_check_config: uptimeCheckConfig, - } - ); + return this.pathTemplates.organizationUptimeCheckConfigPathTemplate.render({ + organization: organization, + uptime_check_config: uptimeCheckConfig, + }); } /** @@ -1678,7 +1783,7 @@ export class AlertPolicyServiceClient { matchOrganizationFromOrganizationUptimeCheckConfigName( organizationUptimeCheckConfigName: string ) { - return this._pathTemplates.organizationUptimeCheckConfigPathTemplate.match( + return this.pathTemplates.organizationUptimeCheckConfigPathTemplate.match( organizationUptimeCheckConfigName ).organization; } @@ -1693,7 +1798,7 @@ export class AlertPolicyServiceClient { matchUptimeCheckConfigFromOrganizationUptimeCheckConfigName( organizationUptimeCheckConfigName: string ) { - return this._pathTemplates.organizationUptimeCheckConfigPathTemplate.match( + return this.pathTemplates.organizationUptimeCheckConfigPathTemplate.match( organizationUptimeCheckConfigName ).uptime_check_config; } @@ -1705,8 +1810,8 @@ export class AlertPolicyServiceClient { * @returns {string} Resource name string. */ projectPath(project: string) { - return this._pathTemplates.projectPathTemplate.render({ - project, + return this.pathTemplates.projectPathTemplate.render({ + project: project, }); } @@ -1718,7 +1823,7 @@ export class AlertPolicyServiceClient { * @returns {string} A string representing the project. */ matchProjectFromProjectName(projectName: string) { - return this._pathTemplates.projectPathTemplate.match(projectName).project; + return this.pathTemplates.projectPathTemplate.match(projectName).project; } /** @@ -1729,8 +1834,8 @@ export class AlertPolicyServiceClient { * @returns {string} Resource name string. */ projectAlertPolicyPath(project: string, alertPolicy: string) { - return this._pathTemplates.projectAlertPolicyPathTemplate.render({ - project, + return this.pathTemplates.projectAlertPolicyPathTemplate.render({ + project: project, alert_policy: alertPolicy, }); } @@ -1743,7 +1848,7 @@ export class AlertPolicyServiceClient { * @returns {string} A string representing the project. */ matchProjectFromProjectAlertPolicyName(projectAlertPolicyName: string) { - return this._pathTemplates.projectAlertPolicyPathTemplate.match( + return this.pathTemplates.projectAlertPolicyPathTemplate.match( projectAlertPolicyName ).project; } @@ -1756,7 +1861,7 @@ export class AlertPolicyServiceClient { * @returns {string} A string representing the alert_policy. */ matchAlertPolicyFromProjectAlertPolicyName(projectAlertPolicyName: string) { - return this._pathTemplates.projectAlertPolicyPathTemplate.match( + return this.pathTemplates.projectAlertPolicyPathTemplate.match( projectAlertPolicyName ).alert_policy; } @@ -1774,10 +1879,10 @@ export class AlertPolicyServiceClient { alertPolicy: string, condition: string ) { - return this._pathTemplates.projectAlertPolicyConditionPathTemplate.render({ - project, + return this.pathTemplates.projectAlertPolicyConditionPathTemplate.render({ + project: project, alert_policy: alertPolicy, - condition, + condition: condition, }); } @@ -1791,7 +1896,7 @@ export class AlertPolicyServiceClient { matchProjectFromProjectAlertPolicyConditionName( projectAlertPolicyConditionName: string ) { - return this._pathTemplates.projectAlertPolicyConditionPathTemplate.match( + return this.pathTemplates.projectAlertPolicyConditionPathTemplate.match( projectAlertPolicyConditionName ).project; } @@ -1806,7 +1911,7 @@ export class AlertPolicyServiceClient { matchAlertPolicyFromProjectAlertPolicyConditionName( projectAlertPolicyConditionName: string ) { - return this._pathTemplates.projectAlertPolicyConditionPathTemplate.match( + return this.pathTemplates.projectAlertPolicyConditionPathTemplate.match( projectAlertPolicyConditionName ).alert_policy; } @@ -1821,7 +1926,7 @@ export class AlertPolicyServiceClient { matchConditionFromProjectAlertPolicyConditionName( projectAlertPolicyConditionName: string ) { - return this._pathTemplates.projectAlertPolicyConditionPathTemplate.match( + return this.pathTemplates.projectAlertPolicyConditionPathTemplate.match( projectAlertPolicyConditionName ).condition; } @@ -1834,8 +1939,8 @@ export class AlertPolicyServiceClient { * @returns {string} Resource name string. */ projectChannelDescriptorPath(project: string, channelDescriptor: string) { - return this._pathTemplates.projectChannelDescriptorPathTemplate.render({ - project, + return this.pathTemplates.projectChannelDescriptorPathTemplate.render({ + project: project, channel_descriptor: channelDescriptor, }); } @@ -1850,7 +1955,7 @@ export class AlertPolicyServiceClient { matchProjectFromProjectChannelDescriptorName( projectChannelDescriptorName: string ) { - return this._pathTemplates.projectChannelDescriptorPathTemplate.match( + return this.pathTemplates.projectChannelDescriptorPathTemplate.match( projectChannelDescriptorName ).project; } @@ -1865,7 +1970,7 @@ export class AlertPolicyServiceClient { matchChannelDescriptorFromProjectChannelDescriptorName( projectChannelDescriptorName: string ) { - return this._pathTemplates.projectChannelDescriptorPathTemplate.match( + return this.pathTemplates.projectChannelDescriptorPathTemplate.match( projectChannelDescriptorName ).channel_descriptor; } @@ -1878,9 +1983,9 @@ export class AlertPolicyServiceClient { * @returns {string} Resource name string. */ projectGroupPath(project: string, group: string) { - return this._pathTemplates.projectGroupPathTemplate.render({ - project, - group, + return this.pathTemplates.projectGroupPathTemplate.render({ + project: project, + group: group, }); } @@ -1892,7 +1997,7 @@ export class AlertPolicyServiceClient { * @returns {string} A string representing the project. */ matchProjectFromProjectGroupName(projectGroupName: string) { - return this._pathTemplates.projectGroupPathTemplate.match(projectGroupName) + return this.pathTemplates.projectGroupPathTemplate.match(projectGroupName) .project; } @@ -1904,7 +2009,7 @@ export class AlertPolicyServiceClient { * @returns {string} A string representing the group. */ matchGroupFromProjectGroupName(projectGroupName: string) { - return this._pathTemplates.projectGroupPathTemplate.match(projectGroupName) + return this.pathTemplates.projectGroupPathTemplate.match(projectGroupName) .group; } @@ -1916,8 +2021,8 @@ export class AlertPolicyServiceClient { * @returns {string} Resource name string. */ projectNotificationChannelPath(project: string, notificationChannel: string) { - return this._pathTemplates.projectNotificationChannelPathTemplate.render({ - project, + return this.pathTemplates.projectNotificationChannelPathTemplate.render({ + project: project, notification_channel: notificationChannel, }); } @@ -1932,7 +2037,7 @@ export class AlertPolicyServiceClient { matchProjectFromProjectNotificationChannelName( projectNotificationChannelName: string ) { - return this._pathTemplates.projectNotificationChannelPathTemplate.match( + return this.pathTemplates.projectNotificationChannelPathTemplate.match( projectNotificationChannelName ).project; } @@ -1947,7 +2052,7 @@ export class AlertPolicyServiceClient { matchNotificationChannelFromProjectNotificationChannelName( projectNotificationChannelName: string ) { - return this._pathTemplates.projectNotificationChannelPathTemplate.match( + return this.pathTemplates.projectNotificationChannelPathTemplate.match( projectNotificationChannelName ).notification_channel; } @@ -1960,9 +2065,9 @@ export class AlertPolicyServiceClient { * @returns {string} Resource name string. */ projectServicePath(project: string, service: string) { - return this._pathTemplates.projectServicePathTemplate.render({ - project, - service, + return this.pathTemplates.projectServicePathTemplate.render({ + project: project, + service: service, }); } @@ -1974,7 +2079,7 @@ export class AlertPolicyServiceClient { * @returns {string} A string representing the project. */ matchProjectFromProjectServiceName(projectServiceName: string) { - return this._pathTemplates.projectServicePathTemplate.match( + return this.pathTemplates.projectServicePathTemplate.match( projectServiceName ).project; } @@ -1987,7 +2092,7 @@ export class AlertPolicyServiceClient { * @returns {string} A string representing the service. */ matchServiceFromProjectServiceName(projectServiceName: string) { - return this._pathTemplates.projectServicePathTemplate.match( + return this.pathTemplates.projectServicePathTemplate.match( projectServiceName ).service; } @@ -2005,10 +2110,10 @@ export class AlertPolicyServiceClient { service: string, serviceLevelObjective: string ) { - return this._pathTemplates.projectServiceServiceLevelObjectivePathTemplate.render( + return this.pathTemplates.projectServiceServiceLevelObjectivePathTemplate.render( { - project, - service, + project: project, + service: service, service_level_objective: serviceLevelObjective, } ); @@ -2024,7 +2129,7 @@ export class AlertPolicyServiceClient { matchProjectFromProjectServiceServiceLevelObjectiveName( projectServiceServiceLevelObjectiveName: string ) { - return this._pathTemplates.projectServiceServiceLevelObjectivePathTemplate.match( + return this.pathTemplates.projectServiceServiceLevelObjectivePathTemplate.match( projectServiceServiceLevelObjectiveName ).project; } @@ -2039,7 +2144,7 @@ export class AlertPolicyServiceClient { matchServiceFromProjectServiceServiceLevelObjectiveName( projectServiceServiceLevelObjectiveName: string ) { - return this._pathTemplates.projectServiceServiceLevelObjectivePathTemplate.match( + return this.pathTemplates.projectServiceServiceLevelObjectivePathTemplate.match( projectServiceServiceLevelObjectiveName ).service; } @@ -2054,7 +2159,7 @@ export class AlertPolicyServiceClient { matchServiceLevelObjectiveFromProjectServiceServiceLevelObjectiveName( projectServiceServiceLevelObjectiveName: string ) { - return this._pathTemplates.projectServiceServiceLevelObjectivePathTemplate.match( + return this.pathTemplates.projectServiceServiceLevelObjectivePathTemplate.match( projectServiceServiceLevelObjectiveName ).service_level_objective; } @@ -2067,8 +2172,8 @@ export class AlertPolicyServiceClient { * @returns {string} Resource name string. */ projectUptimeCheckConfigPath(project: string, uptimeCheckConfig: string) { - return this._pathTemplates.projectUptimeCheckConfigPathTemplate.render({ - project, + return this.pathTemplates.projectUptimeCheckConfigPathTemplate.render({ + project: project, uptime_check_config: uptimeCheckConfig, }); } @@ -2083,7 +2188,7 @@ export class AlertPolicyServiceClient { matchProjectFromProjectUptimeCheckConfigName( projectUptimeCheckConfigName: string ) { - return this._pathTemplates.projectUptimeCheckConfigPathTemplate.match( + return this.pathTemplates.projectUptimeCheckConfigPathTemplate.match( projectUptimeCheckConfigName ).project; } @@ -2098,7 +2203,7 @@ export class AlertPolicyServiceClient { matchUptimeCheckConfigFromProjectUptimeCheckConfigName( projectUptimeCheckConfigName: string ) { - return this._pathTemplates.projectUptimeCheckConfigPathTemplate.match( + return this.pathTemplates.projectUptimeCheckConfigPathTemplate.match( projectUptimeCheckConfigName ).uptime_check_config; } diff --git a/packages/google-cloud-monitoring/src/v3/group_service_client.ts b/packages/google-cloud-monitoring/src/v3/group_service_client.ts index 80bfc5063d2..605c5c110df 100644 --- a/packages/google-cloud-monitoring/src/v3/group_service_client.ts +++ b/packages/google-cloud-monitoring/src/v3/group_service_client.ts @@ -1,4 +1,4 @@ -// Copyright 2019 Google LLC +// Copyright 2020 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -18,18 +18,18 @@ import * as gax from 'google-gax'; import { - APICallback, Callback, CallOptions, Descriptors, ClientOptions, PaginationCallback, - PaginationResponse, + GaxCall, } from 'google-gax'; import * as path from 'path'; import {Transform} from 'stream'; -import * as protosTypes from '../../protos/protos'; +import {RequestType} from 'google-gax/build/src/apitypes'; +import * as protos from '../../protos/protos'; import * as gapicConfig from './group_service_client_config.json'; const version = require('../../../package.json').version; @@ -51,9 +51,6 @@ const version = require('../../../package.json').version; * @memberof v3 */ export class GroupServiceClient { - private _descriptors: Descriptors = {page: {}, stream: {}, longrunning: {}}; - private _innerApiCalls: {[name: string]: Function}; - private _pathTemplates: {[name: string]: gax.PathTemplate}; private _terminated = false; private _opts: ClientOptions; private _gaxModule: typeof gax | typeof gax.fallback; @@ -61,6 +58,14 @@ export class GroupServiceClient { private _protos: {}; private _defaults: {[method: string]: gax.CallSettings}; auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + innerApiCalls: {[name: string]: Function}; + pathTemplates: {[name: string]: gax.PathTemplate}; groupServiceStub?: Promise<{[name: string]: Function}>; /** @@ -152,13 +157,16 @@ export class GroupServiceClient { 'protos.json' ); this._protos = this._gaxGrpc.loadProto( - opts.fallback ? 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 // identifiers to uniquely identify resources within the API. // Create useful helper objects for these. - this._pathTemplates = { + this.pathTemplates = { folderAlertPolicyPathTemplate: new this._gaxModule.PathTemplate( 'folders/{folder}/alertPolicies/{alert_policy}' ), @@ -239,7 +247,7 @@ export class GroupServiceClient { // Some of the methods on this service return "paged" results, // (e.g. 50 results at a time, with tokens to get subsequent // pages). Denote the keys used for pagination and results. - this._descriptors.page = { + this.descriptors.page = { listGroups: new this._gaxModule.PageDescriptor( 'pageToken', 'nextPageToken', @@ -263,7 +271,7 @@ export class GroupServiceClient { // Set up a dictionary of "inner API calls"; the core implementation // of calling the API is handled in `google-gax`, with this code // merely providing the destination and request information. - this._innerApiCalls = {}; + this.innerApiCalls = {}; } /** @@ -290,7 +298,7 @@ export class GroupServiceClient { ? (this._protos as protobuf.Root).lookupService( 'google.monitoring.v3.GroupService' ) - : // tslint:disable-next-line no-any + : // eslint-disable-next-line @typescript-eslint/no-explicit-any (this._protos as any).google.monitoring.v3.GroupService, this._opts ) as Promise<{[method: string]: Function}>; @@ -305,14 +313,14 @@ export class GroupServiceClient { 'deleteGroup', 'listGroupMembers', ]; - for (const methodName of groupServiceStubMethods) { - const innerCallPromise = this.groupServiceStub.then( + const callPromise = this.groupServiceStub.then( stub => (...args: Array<{}>) => { if (this._terminated) { return Promise.reject('The client has already been closed.'); } - return stub[methodName].apply(stub, args); + const func = stub[methodName]; + return func.apply(stub, args); }, (err: Error | null | undefined) => () => { throw err; @@ -320,20 +328,14 @@ export class GroupServiceClient { ); const apiCall = this._gaxModule.createApiCall( - innerCallPromise, + callPromise, this._defaults[methodName], - this._descriptors.page[methodName] || - this._descriptors.stream[methodName] || - this._descriptors.longrunning[methodName] + this.descriptors.page[methodName] || + this.descriptors.stream[methodName] || + this.descriptors.longrunning[methodName] ); - this._innerApiCalls[methodName] = ( - argument: {}, - callOptions?: CallOptions, - callback?: APICallback - ) => { - return apiCall(argument, callOptions, callback); - }; + this.innerApiCalls[methodName] = apiCall; } return this.groupServiceStub; @@ -394,22 +396,30 @@ export class GroupServiceClient { // -- Service calls -- // ------------------- getGroup( - request: protosTypes.google.monitoring.v3.IGetGroupRequest, + request: protos.google.monitoring.v3.IGetGroupRequest, options?: gax.CallOptions ): Promise< [ - protosTypes.google.monitoring.v3.IGroup, - protosTypes.google.monitoring.v3.IGetGroupRequest | undefined, + protos.google.monitoring.v3.IGroup, + protos.google.monitoring.v3.IGetGroupRequest | undefined, {} | undefined ] >; getGroup( - request: protosTypes.google.monitoring.v3.IGetGroupRequest, + request: protos.google.monitoring.v3.IGetGroupRequest, options: gax.CallOptions, callback: Callback< - protosTypes.google.monitoring.v3.IGroup, - protosTypes.google.monitoring.v3.IGetGroupRequest | undefined, - {} | undefined + protos.google.monitoring.v3.IGroup, + protos.google.monitoring.v3.IGetGroupRequest | null | undefined, + {} | null | undefined + > + ): void; + getGroup( + request: protos.google.monitoring.v3.IGetGroupRequest, + callback: Callback< + protos.google.monitoring.v3.IGroup, + protos.google.monitoring.v3.IGetGroupRequest | null | undefined, + {} | null | undefined > ): void; /** @@ -428,23 +438,23 @@ export class GroupServiceClient { * The promise has a method named "cancel" which cancels the ongoing API call. */ getGroup( - request: protosTypes.google.monitoring.v3.IGetGroupRequest, + request: protos.google.monitoring.v3.IGetGroupRequest, optionsOrCallback?: | gax.CallOptions | Callback< - protosTypes.google.monitoring.v3.IGroup, - protosTypes.google.monitoring.v3.IGetGroupRequest | undefined, - {} | undefined + protos.google.monitoring.v3.IGroup, + protos.google.monitoring.v3.IGetGroupRequest | null | undefined, + {} | null | undefined >, callback?: Callback< - protosTypes.google.monitoring.v3.IGroup, - protosTypes.google.monitoring.v3.IGetGroupRequest | undefined, - {} | undefined + protos.google.monitoring.v3.IGroup, + protos.google.monitoring.v3.IGetGroupRequest | null | undefined, + {} | null | undefined > ): Promise< [ - protosTypes.google.monitoring.v3.IGroup, - protosTypes.google.monitoring.v3.IGetGroupRequest | undefined, + protos.google.monitoring.v3.IGroup, + protos.google.monitoring.v3.IGetGroupRequest | undefined, {} | undefined ] > | void { @@ -465,25 +475,33 @@ export class GroupServiceClient { name: request.name || '', }); this.initialize(); - return this._innerApiCalls.getGroup(request, options, callback); + return this.innerApiCalls.getGroup(request, options, callback); } createGroup( - request: protosTypes.google.monitoring.v3.ICreateGroupRequest, + request: protos.google.monitoring.v3.ICreateGroupRequest, options?: gax.CallOptions ): Promise< [ - protosTypes.google.monitoring.v3.IGroup, - protosTypes.google.monitoring.v3.ICreateGroupRequest | undefined, + protos.google.monitoring.v3.IGroup, + protos.google.monitoring.v3.ICreateGroupRequest | undefined, {} | undefined ] >; createGroup( - request: protosTypes.google.monitoring.v3.ICreateGroupRequest, + request: protos.google.monitoring.v3.ICreateGroupRequest, options: gax.CallOptions, callback: Callback< - protosTypes.google.monitoring.v3.IGroup, - protosTypes.google.monitoring.v3.ICreateGroupRequest | undefined, - {} | undefined + protos.google.monitoring.v3.IGroup, + protos.google.monitoring.v3.ICreateGroupRequest | null | undefined, + {} | null | undefined + > + ): void; + createGroup( + request: protos.google.monitoring.v3.ICreateGroupRequest, + callback: Callback< + protos.google.monitoring.v3.IGroup, + protos.google.monitoring.v3.ICreateGroupRequest | null | undefined, + {} | null | undefined > ): void; /** @@ -507,23 +525,23 @@ export class GroupServiceClient { * The promise has a method named "cancel" which cancels the ongoing API call. */ createGroup( - request: protosTypes.google.monitoring.v3.ICreateGroupRequest, + request: protos.google.monitoring.v3.ICreateGroupRequest, optionsOrCallback?: | gax.CallOptions | Callback< - protosTypes.google.monitoring.v3.IGroup, - protosTypes.google.monitoring.v3.ICreateGroupRequest | undefined, - {} | undefined + protos.google.monitoring.v3.IGroup, + protos.google.monitoring.v3.ICreateGroupRequest | null | undefined, + {} | null | undefined >, callback?: Callback< - protosTypes.google.monitoring.v3.IGroup, - protosTypes.google.monitoring.v3.ICreateGroupRequest | undefined, - {} | undefined + protos.google.monitoring.v3.IGroup, + protos.google.monitoring.v3.ICreateGroupRequest | null | undefined, + {} | null | undefined > ): Promise< [ - protosTypes.google.monitoring.v3.IGroup, - protosTypes.google.monitoring.v3.ICreateGroupRequest | undefined, + protos.google.monitoring.v3.IGroup, + protos.google.monitoring.v3.ICreateGroupRequest | undefined, {} | undefined ] > | void { @@ -544,25 +562,33 @@ export class GroupServiceClient { name: request.name || '', }); this.initialize(); - return this._innerApiCalls.createGroup(request, options, callback); + return this.innerApiCalls.createGroup(request, options, callback); } updateGroup( - request: protosTypes.google.monitoring.v3.IUpdateGroupRequest, + request: protos.google.monitoring.v3.IUpdateGroupRequest, options?: gax.CallOptions ): Promise< [ - protosTypes.google.monitoring.v3.IGroup, - protosTypes.google.monitoring.v3.IUpdateGroupRequest | undefined, + protos.google.monitoring.v3.IGroup, + protos.google.monitoring.v3.IUpdateGroupRequest | undefined, {} | undefined ] >; updateGroup( - request: protosTypes.google.monitoring.v3.IUpdateGroupRequest, + request: protos.google.monitoring.v3.IUpdateGroupRequest, options: gax.CallOptions, callback: Callback< - protosTypes.google.monitoring.v3.IGroup, - protosTypes.google.monitoring.v3.IUpdateGroupRequest | undefined, - {} | undefined + protos.google.monitoring.v3.IGroup, + protos.google.monitoring.v3.IUpdateGroupRequest | null | undefined, + {} | null | undefined + > + ): void; + updateGroup( + request: protos.google.monitoring.v3.IUpdateGroupRequest, + callback: Callback< + protos.google.monitoring.v3.IGroup, + protos.google.monitoring.v3.IUpdateGroupRequest | null | undefined, + {} | null | undefined > ): void; /** @@ -583,23 +609,23 @@ export class GroupServiceClient { * The promise has a method named "cancel" which cancels the ongoing API call. */ updateGroup( - request: protosTypes.google.monitoring.v3.IUpdateGroupRequest, + request: protos.google.monitoring.v3.IUpdateGroupRequest, optionsOrCallback?: | gax.CallOptions | Callback< - protosTypes.google.monitoring.v3.IGroup, - protosTypes.google.monitoring.v3.IUpdateGroupRequest | undefined, - {} | undefined + protos.google.monitoring.v3.IGroup, + protos.google.monitoring.v3.IUpdateGroupRequest | null | undefined, + {} | null | undefined >, callback?: Callback< - protosTypes.google.monitoring.v3.IGroup, - protosTypes.google.monitoring.v3.IUpdateGroupRequest | undefined, - {} | undefined + protos.google.monitoring.v3.IGroup, + protos.google.monitoring.v3.IUpdateGroupRequest | null | undefined, + {} | null | undefined > ): Promise< [ - protosTypes.google.monitoring.v3.IGroup, - protosTypes.google.monitoring.v3.IUpdateGroupRequest | undefined, + protos.google.monitoring.v3.IGroup, + protos.google.monitoring.v3.IUpdateGroupRequest | undefined, {} | undefined ] > | void { @@ -620,25 +646,33 @@ export class GroupServiceClient { 'group.name': request.group!.name || '', }); this.initialize(); - return this._innerApiCalls.updateGroup(request, options, callback); + return this.innerApiCalls.updateGroup(request, options, callback); } deleteGroup( - request: protosTypes.google.monitoring.v3.IDeleteGroupRequest, + request: protos.google.monitoring.v3.IDeleteGroupRequest, options?: gax.CallOptions ): Promise< [ - protosTypes.google.protobuf.IEmpty, - protosTypes.google.monitoring.v3.IDeleteGroupRequest | undefined, + protos.google.protobuf.IEmpty, + protos.google.monitoring.v3.IDeleteGroupRequest | undefined, {} | undefined ] >; deleteGroup( - request: protosTypes.google.monitoring.v3.IDeleteGroupRequest, + request: protos.google.monitoring.v3.IDeleteGroupRequest, options: gax.CallOptions, callback: Callback< - protosTypes.google.protobuf.IEmpty, - protosTypes.google.monitoring.v3.IDeleteGroupRequest | undefined, - {} | undefined + protos.google.protobuf.IEmpty, + protos.google.monitoring.v3.IDeleteGroupRequest | null | undefined, + {} | null | undefined + > + ): void; + deleteGroup( + request: protos.google.monitoring.v3.IDeleteGroupRequest, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.monitoring.v3.IDeleteGroupRequest | null | undefined, + {} | null | undefined > ): void; /** @@ -661,23 +695,23 @@ export class GroupServiceClient { * The promise has a method named "cancel" which cancels the ongoing API call. */ deleteGroup( - request: protosTypes.google.monitoring.v3.IDeleteGroupRequest, + request: protos.google.monitoring.v3.IDeleteGroupRequest, optionsOrCallback?: | gax.CallOptions | Callback< - protosTypes.google.protobuf.IEmpty, - protosTypes.google.monitoring.v3.IDeleteGroupRequest | undefined, - {} | undefined + protos.google.protobuf.IEmpty, + protos.google.monitoring.v3.IDeleteGroupRequest | null | undefined, + {} | null | undefined >, callback?: Callback< - protosTypes.google.protobuf.IEmpty, - protosTypes.google.monitoring.v3.IDeleteGroupRequest | undefined, - {} | undefined + protos.google.protobuf.IEmpty, + protos.google.monitoring.v3.IDeleteGroupRequest | null | undefined, + {} | null | undefined > ): Promise< [ - protosTypes.google.protobuf.IEmpty, - protosTypes.google.monitoring.v3.IDeleteGroupRequest | undefined, + protos.google.protobuf.IEmpty, + protos.google.monitoring.v3.IDeleteGroupRequest | undefined, {} | undefined ] > | void { @@ -698,26 +732,34 @@ export class GroupServiceClient { name: request.name || '', }); this.initialize(); - return this._innerApiCalls.deleteGroup(request, options, callback); + return this.innerApiCalls.deleteGroup(request, options, callback); } listGroups( - request: protosTypes.google.monitoring.v3.IListGroupsRequest, + request: protos.google.monitoring.v3.IListGroupsRequest, options?: gax.CallOptions ): Promise< [ - protosTypes.google.monitoring.v3.IGroup[], - protosTypes.google.monitoring.v3.IListGroupsRequest | null, - protosTypes.google.monitoring.v3.IListGroupsResponse + protos.google.monitoring.v3.IGroup[], + protos.google.monitoring.v3.IListGroupsRequest | null, + protos.google.monitoring.v3.IListGroupsResponse ] >; listGroups( - request: protosTypes.google.monitoring.v3.IListGroupsRequest, + request: protos.google.monitoring.v3.IListGroupsRequest, options: gax.CallOptions, - callback: Callback< - protosTypes.google.monitoring.v3.IGroup[], - protosTypes.google.monitoring.v3.IListGroupsRequest | null, - protosTypes.google.monitoring.v3.IListGroupsResponse + callback: PaginationCallback< + protos.google.monitoring.v3.IListGroupsRequest, + protos.google.monitoring.v3.IListGroupsResponse | null | undefined, + protos.google.monitoring.v3.IGroup + > + ): void; + listGroups( + request: protos.google.monitoring.v3.IListGroupsRequest, + callback: PaginationCallback< + protos.google.monitoring.v3.IListGroupsRequest, + protos.google.monitoring.v3.IListGroupsResponse | null | undefined, + protos.google.monitoring.v3.IGroup > ): void; /** @@ -778,24 +820,24 @@ export class GroupServiceClient { * The promise has a method named "cancel" which cancels the ongoing API call. */ listGroups( - request: protosTypes.google.monitoring.v3.IListGroupsRequest, + request: protos.google.monitoring.v3.IListGroupsRequest, optionsOrCallback?: | gax.CallOptions - | Callback< - protosTypes.google.monitoring.v3.IGroup[], - protosTypes.google.monitoring.v3.IListGroupsRequest | null, - protosTypes.google.monitoring.v3.IListGroupsResponse + | PaginationCallback< + protos.google.monitoring.v3.IListGroupsRequest, + protos.google.monitoring.v3.IListGroupsResponse | null | undefined, + protos.google.monitoring.v3.IGroup >, - callback?: Callback< - protosTypes.google.monitoring.v3.IGroup[], - protosTypes.google.monitoring.v3.IListGroupsRequest | null, - protosTypes.google.monitoring.v3.IListGroupsResponse + callback?: PaginationCallback< + protos.google.monitoring.v3.IListGroupsRequest, + protos.google.monitoring.v3.IListGroupsResponse | null | undefined, + protos.google.monitoring.v3.IGroup > ): Promise< [ - protosTypes.google.monitoring.v3.IGroup[], - protosTypes.google.monitoring.v3.IListGroupsRequest | null, - protosTypes.google.monitoring.v3.IListGroupsResponse + protos.google.monitoring.v3.IGroup[], + protos.google.monitoring.v3.IListGroupsRequest | null, + protos.google.monitoring.v3.IListGroupsResponse ] > | void { request = request || {}; @@ -815,7 +857,7 @@ export class GroupServiceClient { name: request.name || '', }); this.initialize(); - return this._innerApiCalls.listGroups(request, options, callback); + return this.innerApiCalls.listGroups(request, options, callback); } /** @@ -873,7 +915,7 @@ export class GroupServiceClient { * An object stream which emits an object representing [Group]{@link google.monitoring.v3.Group} on 'data' event. */ listGroupsStream( - request?: protosTypes.google.monitoring.v3.IListGroupsRequest, + request?: protos.google.monitoring.v3.IListGroupsRequest, options?: gax.CallOptions ): Transform { request = request || {}; @@ -887,29 +929,106 @@ export class GroupServiceClient { }); const callSettings = new gax.CallSettings(options); this.initialize(); - return this._descriptors.page.listGroups.createStream( - this._innerApiCalls.listGroups as gax.GaxCall, + return this.descriptors.page.listGroups.createStream( + this.innerApiCalls.listGroups as gax.GaxCall, request, callSettings ); } + + /** + * Equivalent to {@link listGroups}, 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.name + * Required. The project whose groups are to be listed. The format is: + * + * projects/[PROJECT_ID_OR_NUMBER] + * @param {string} request.childrenOfGroup + * A group name. The format is: + * + * projects/[PROJECT_ID_OR_NUMBER]/groups/[GROUP_ID] + * + * Returns groups whose `parent_name` field contains the group + * name. If no groups have this parent, the results are empty. + * @param {string} request.ancestorsOfGroup + * A group name. The format is: + * + * projects/[PROJECT_ID_OR_NUMBER]/groups/[GROUP_ID] + * + * Returns groups that are ancestors of the specified group. + * The groups are returned in order, starting with the immediate parent and + * ending with the most distant ancestor. If the specified group has no + * immediate parent, the results are empty. + * @param {string} request.descendantsOfGroup + * A group name. The format is: + * + * projects/[PROJECT_ID_OR_NUMBER]/groups/[GROUP_ID] + * + * Returns the descendants of the specified group. This is a superset of + * the results returned by the `children_of_group` filter, and includes + * children-of-children, and so forth. + * @param {number} request.pageSize + * A positive number that is the maximum number of results to return. + * @param {string} request.pageToken + * If this field is not empty then it must contain the `next_page_token` value + * returned by a previous call to this method. Using this field causes the + * method to return additional results from the previous method call. + * @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. + */ + listGroupsAsync( + request?: protos.google.monitoring.v3.IListGroupsRequest, + options?: gax.CallOptions + ): AsyncIterable { + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + name: request.name || '', + }); + options = options || {}; + const callSettings = new gax.CallSettings(options); + this.initialize(); + return this.descriptors.page.listGroups.asyncIterate( + this.innerApiCalls['listGroups'] as GaxCall, + (request as unknown) as RequestType, + callSettings + ) as AsyncIterable; + } listGroupMembers( - request: protosTypes.google.monitoring.v3.IListGroupMembersRequest, + request: protos.google.monitoring.v3.IListGroupMembersRequest, options?: gax.CallOptions ): Promise< [ - protosTypes.google.api.IMonitoredResource[], - protosTypes.google.monitoring.v3.IListGroupMembersRequest | null, - protosTypes.google.monitoring.v3.IListGroupMembersResponse + protos.google.api.IMonitoredResource[], + protos.google.monitoring.v3.IListGroupMembersRequest | null, + protos.google.monitoring.v3.IListGroupMembersResponse ] >; listGroupMembers( - request: protosTypes.google.monitoring.v3.IListGroupMembersRequest, + request: protos.google.monitoring.v3.IListGroupMembersRequest, options: gax.CallOptions, - callback: Callback< - protosTypes.google.api.IMonitoredResource[], - protosTypes.google.monitoring.v3.IListGroupMembersRequest | null, - protosTypes.google.monitoring.v3.IListGroupMembersResponse + callback: PaginationCallback< + protos.google.monitoring.v3.IListGroupMembersRequest, + protos.google.monitoring.v3.IListGroupMembersResponse | null | undefined, + protos.google.api.IMonitoredResource + > + ): void; + listGroupMembers( + request: protos.google.monitoring.v3.IListGroupMembersRequest, + callback: PaginationCallback< + protos.google.monitoring.v3.IListGroupMembersRequest, + protos.google.monitoring.v3.IListGroupMembersResponse | null | undefined, + protos.google.api.IMonitoredResource > ): void; /** @@ -960,24 +1079,26 @@ export class GroupServiceClient { * The promise has a method named "cancel" which cancels the ongoing API call. */ listGroupMembers( - request: protosTypes.google.monitoring.v3.IListGroupMembersRequest, + request: protos.google.monitoring.v3.IListGroupMembersRequest, optionsOrCallback?: | gax.CallOptions - | Callback< - protosTypes.google.api.IMonitoredResource[], - protosTypes.google.monitoring.v3.IListGroupMembersRequest | null, - protosTypes.google.monitoring.v3.IListGroupMembersResponse + | PaginationCallback< + protos.google.monitoring.v3.IListGroupMembersRequest, + | protos.google.monitoring.v3.IListGroupMembersResponse + | null + | undefined, + protos.google.api.IMonitoredResource >, - callback?: Callback< - protosTypes.google.api.IMonitoredResource[], - protosTypes.google.monitoring.v3.IListGroupMembersRequest | null, - protosTypes.google.monitoring.v3.IListGroupMembersResponse + callback?: PaginationCallback< + protos.google.monitoring.v3.IListGroupMembersRequest, + protos.google.monitoring.v3.IListGroupMembersResponse | null | undefined, + protos.google.api.IMonitoredResource > ): Promise< [ - protosTypes.google.api.IMonitoredResource[], - protosTypes.google.monitoring.v3.IListGroupMembersRequest | null, - protosTypes.google.monitoring.v3.IListGroupMembersResponse + protos.google.api.IMonitoredResource[], + protos.google.monitoring.v3.IListGroupMembersRequest | null, + protos.google.monitoring.v3.IListGroupMembersResponse ] > | void { request = request || {}; @@ -997,7 +1118,7 @@ export class GroupServiceClient { name: request.name || '', }); this.initialize(); - return this._innerApiCalls.listGroupMembers(request, options, callback); + return this.innerApiCalls.listGroupMembers(request, options, callback); } /** @@ -1045,7 +1166,7 @@ export class GroupServiceClient { * An object stream which emits an object representing [MonitoredResource]{@link google.api.MonitoredResource} on 'data' event. */ listGroupMembersStream( - request?: protosTypes.google.monitoring.v3.IListGroupMembersRequest, + request?: protos.google.monitoring.v3.IListGroupMembersRequest, options?: gax.CallOptions ): Transform { request = request || {}; @@ -1059,12 +1180,71 @@ export class GroupServiceClient { }); const callSettings = new gax.CallSettings(options); this.initialize(); - return this._descriptors.page.listGroupMembers.createStream( - this._innerApiCalls.listGroupMembers as gax.GaxCall, + return this.descriptors.page.listGroupMembers.createStream( + this.innerApiCalls.listGroupMembers as gax.GaxCall, request, callSettings ); } + + /** + * Equivalent to {@link listGroupMembers}, 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.name + * Required. The group whose members are listed. The format is: + * + * projects/[PROJECT_ID_OR_NUMBER]/groups/[GROUP_ID] + * @param {number} request.pageSize + * A positive number that is the maximum number of results to return. + * @param {string} request.pageToken + * If this field is not empty then it must contain the `next_page_token` value + * returned by a previous call to this method. Using this field causes the + * method to return additional results from the previous method call. + * @param {string} request.filter + * An optional [list + * filter](https://cloud.google.com/monitoring/api/learn_more#filtering) + * describing the members to be returned. The filter may reference the type, + * labels, and metadata of monitored resources that comprise the group. For + * example, to return only resources representing Compute Engine VM instances, + * use this filter: + * + * `resource.type = "gce_instance"` + * @param {google.monitoring.v3.TimeInterval} request.interval + * An optional time interval for which results should be returned. Only + * members that were part of the group during the specified interval are + * included in the response. If no interval is provided then the group + * membership over the last minute is returned. + * @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. + */ + listGroupMembersAsync( + request?: protos.google.monitoring.v3.IListGroupMembersRequest, + options?: gax.CallOptions + ): AsyncIterable { + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + name: request.name || '', + }); + options = options || {}; + const callSettings = new gax.CallSettings(options); + this.initialize(); + return this.descriptors.page.listGroupMembers.asyncIterate( + this.innerApiCalls['listGroupMembers'] as GaxCall, + (request as unknown) as RequestType, + callSettings + ) as AsyncIterable; + } // -------------------- // -- Path templates -- // -------------------- @@ -1077,8 +1257,8 @@ export class GroupServiceClient { * @returns {string} Resource name string. */ folderAlertPolicyPath(folder: string, alertPolicy: string) { - return this._pathTemplates.folderAlertPolicyPathTemplate.render({ - folder, + return this.pathTemplates.folderAlertPolicyPathTemplate.render({ + folder: folder, alert_policy: alertPolicy, }); } @@ -1091,7 +1271,7 @@ export class GroupServiceClient { * @returns {string} A string representing the folder. */ matchFolderFromFolderAlertPolicyName(folderAlertPolicyName: string) { - return this._pathTemplates.folderAlertPolicyPathTemplate.match( + return this.pathTemplates.folderAlertPolicyPathTemplate.match( folderAlertPolicyName ).folder; } @@ -1104,7 +1284,7 @@ export class GroupServiceClient { * @returns {string} A string representing the alert_policy. */ matchAlertPolicyFromFolderAlertPolicyName(folderAlertPolicyName: string) { - return this._pathTemplates.folderAlertPolicyPathTemplate.match( + return this.pathTemplates.folderAlertPolicyPathTemplate.match( folderAlertPolicyName ).alert_policy; } @@ -1122,10 +1302,10 @@ export class GroupServiceClient { alertPolicy: string, condition: string ) { - return this._pathTemplates.folderAlertPolicyConditionPathTemplate.render({ - folder, + return this.pathTemplates.folderAlertPolicyConditionPathTemplate.render({ + folder: folder, alert_policy: alertPolicy, - condition, + condition: condition, }); } @@ -1139,7 +1319,7 @@ export class GroupServiceClient { matchFolderFromFolderAlertPolicyConditionName( folderAlertPolicyConditionName: string ) { - return this._pathTemplates.folderAlertPolicyConditionPathTemplate.match( + return this.pathTemplates.folderAlertPolicyConditionPathTemplate.match( folderAlertPolicyConditionName ).folder; } @@ -1154,7 +1334,7 @@ export class GroupServiceClient { matchAlertPolicyFromFolderAlertPolicyConditionName( folderAlertPolicyConditionName: string ) { - return this._pathTemplates.folderAlertPolicyConditionPathTemplate.match( + return this.pathTemplates.folderAlertPolicyConditionPathTemplate.match( folderAlertPolicyConditionName ).alert_policy; } @@ -1169,7 +1349,7 @@ export class GroupServiceClient { matchConditionFromFolderAlertPolicyConditionName( folderAlertPolicyConditionName: string ) { - return this._pathTemplates.folderAlertPolicyConditionPathTemplate.match( + return this.pathTemplates.folderAlertPolicyConditionPathTemplate.match( folderAlertPolicyConditionName ).condition; } @@ -1182,8 +1362,8 @@ export class GroupServiceClient { * @returns {string} Resource name string. */ folderChannelDescriptorPath(folder: string, channelDescriptor: string) { - return this._pathTemplates.folderChannelDescriptorPathTemplate.render({ - folder, + return this.pathTemplates.folderChannelDescriptorPathTemplate.render({ + folder: folder, channel_descriptor: channelDescriptor, }); } @@ -1198,7 +1378,7 @@ export class GroupServiceClient { matchFolderFromFolderChannelDescriptorName( folderChannelDescriptorName: string ) { - return this._pathTemplates.folderChannelDescriptorPathTemplate.match( + return this.pathTemplates.folderChannelDescriptorPathTemplate.match( folderChannelDescriptorName ).folder; } @@ -1213,7 +1393,7 @@ export class GroupServiceClient { matchChannelDescriptorFromFolderChannelDescriptorName( folderChannelDescriptorName: string ) { - return this._pathTemplates.folderChannelDescriptorPathTemplate.match( + return this.pathTemplates.folderChannelDescriptorPathTemplate.match( folderChannelDescriptorName ).channel_descriptor; } @@ -1226,9 +1406,9 @@ export class GroupServiceClient { * @returns {string} Resource name string. */ folderGroupPath(folder: string, group: string) { - return this._pathTemplates.folderGroupPathTemplate.render({ - folder, - group, + return this.pathTemplates.folderGroupPathTemplate.render({ + folder: folder, + group: group, }); } @@ -1240,7 +1420,7 @@ export class GroupServiceClient { * @returns {string} A string representing the folder. */ matchFolderFromFolderGroupName(folderGroupName: string) { - return this._pathTemplates.folderGroupPathTemplate.match(folderGroupName) + return this.pathTemplates.folderGroupPathTemplate.match(folderGroupName) .folder; } @@ -1252,7 +1432,7 @@ export class GroupServiceClient { * @returns {string} A string representing the group. */ matchGroupFromFolderGroupName(folderGroupName: string) { - return this._pathTemplates.folderGroupPathTemplate.match(folderGroupName) + return this.pathTemplates.folderGroupPathTemplate.match(folderGroupName) .group; } @@ -1264,8 +1444,8 @@ export class GroupServiceClient { * @returns {string} Resource name string. */ folderNotificationChannelPath(folder: string, notificationChannel: string) { - return this._pathTemplates.folderNotificationChannelPathTemplate.render({ - folder, + return this.pathTemplates.folderNotificationChannelPathTemplate.render({ + folder: folder, notification_channel: notificationChannel, }); } @@ -1280,7 +1460,7 @@ export class GroupServiceClient { matchFolderFromFolderNotificationChannelName( folderNotificationChannelName: string ) { - return this._pathTemplates.folderNotificationChannelPathTemplate.match( + return this.pathTemplates.folderNotificationChannelPathTemplate.match( folderNotificationChannelName ).folder; } @@ -1295,7 +1475,7 @@ export class GroupServiceClient { matchNotificationChannelFromFolderNotificationChannelName( folderNotificationChannelName: string ) { - return this._pathTemplates.folderNotificationChannelPathTemplate.match( + return this.pathTemplates.folderNotificationChannelPathTemplate.match( folderNotificationChannelName ).notification_channel; } @@ -1308,9 +1488,9 @@ export class GroupServiceClient { * @returns {string} Resource name string. */ folderServicePath(folder: string, service: string) { - return this._pathTemplates.folderServicePathTemplate.render({ - folder, - service, + return this.pathTemplates.folderServicePathTemplate.render({ + folder: folder, + service: service, }); } @@ -1322,9 +1502,8 @@ export class GroupServiceClient { * @returns {string} A string representing the folder. */ matchFolderFromFolderServiceName(folderServiceName: string) { - return this._pathTemplates.folderServicePathTemplate.match( - folderServiceName - ).folder; + return this.pathTemplates.folderServicePathTemplate.match(folderServiceName) + .folder; } /** @@ -1335,9 +1514,8 @@ export class GroupServiceClient { * @returns {string} A string representing the service. */ matchServiceFromFolderServiceName(folderServiceName: string) { - return this._pathTemplates.folderServicePathTemplate.match( - folderServiceName - ).service; + return this.pathTemplates.folderServicePathTemplate.match(folderServiceName) + .service; } /** @@ -1353,10 +1531,10 @@ export class GroupServiceClient { service: string, serviceLevelObjective: string ) { - return this._pathTemplates.folderServiceServiceLevelObjectivePathTemplate.render( + return this.pathTemplates.folderServiceServiceLevelObjectivePathTemplate.render( { - folder, - service, + folder: folder, + service: service, service_level_objective: serviceLevelObjective, } ); @@ -1372,7 +1550,7 @@ export class GroupServiceClient { matchFolderFromFolderServiceServiceLevelObjectiveName( folderServiceServiceLevelObjectiveName: string ) { - return this._pathTemplates.folderServiceServiceLevelObjectivePathTemplate.match( + return this.pathTemplates.folderServiceServiceLevelObjectivePathTemplate.match( folderServiceServiceLevelObjectiveName ).folder; } @@ -1387,7 +1565,7 @@ export class GroupServiceClient { matchServiceFromFolderServiceServiceLevelObjectiveName( folderServiceServiceLevelObjectiveName: string ) { - return this._pathTemplates.folderServiceServiceLevelObjectivePathTemplate.match( + return this.pathTemplates.folderServiceServiceLevelObjectivePathTemplate.match( folderServiceServiceLevelObjectiveName ).service; } @@ -1402,7 +1580,7 @@ export class GroupServiceClient { matchServiceLevelObjectiveFromFolderServiceServiceLevelObjectiveName( folderServiceServiceLevelObjectiveName: string ) { - return this._pathTemplates.folderServiceServiceLevelObjectivePathTemplate.match( + return this.pathTemplates.folderServiceServiceLevelObjectivePathTemplate.match( folderServiceServiceLevelObjectiveName ).service_level_objective; } @@ -1415,8 +1593,8 @@ export class GroupServiceClient { * @returns {string} Resource name string. */ folderUptimeCheckConfigPath(folder: string, uptimeCheckConfig: string) { - return this._pathTemplates.folderUptimeCheckConfigPathTemplate.render({ - folder, + return this.pathTemplates.folderUptimeCheckConfigPathTemplate.render({ + folder: folder, uptime_check_config: uptimeCheckConfig, }); } @@ -1431,7 +1609,7 @@ export class GroupServiceClient { matchFolderFromFolderUptimeCheckConfigName( folderUptimeCheckConfigName: string ) { - return this._pathTemplates.folderUptimeCheckConfigPathTemplate.match( + return this.pathTemplates.folderUptimeCheckConfigPathTemplate.match( folderUptimeCheckConfigName ).folder; } @@ -1446,7 +1624,7 @@ export class GroupServiceClient { matchUptimeCheckConfigFromFolderUptimeCheckConfigName( folderUptimeCheckConfigName: string ) { - return this._pathTemplates.folderUptimeCheckConfigPathTemplate.match( + return this.pathTemplates.folderUptimeCheckConfigPathTemplate.match( folderUptimeCheckConfigName ).uptime_check_config; } @@ -1459,8 +1637,8 @@ export class GroupServiceClient { * @returns {string} Resource name string. */ organizationAlertPolicyPath(organization: string, alertPolicy: string) { - return this._pathTemplates.organizationAlertPolicyPathTemplate.render({ - organization, + return this.pathTemplates.organizationAlertPolicyPathTemplate.render({ + organization: organization, alert_policy: alertPolicy, }); } @@ -1475,7 +1653,7 @@ export class GroupServiceClient { matchOrganizationFromOrganizationAlertPolicyName( organizationAlertPolicyName: string ) { - return this._pathTemplates.organizationAlertPolicyPathTemplate.match( + return this.pathTemplates.organizationAlertPolicyPathTemplate.match( organizationAlertPolicyName ).organization; } @@ -1490,7 +1668,7 @@ export class GroupServiceClient { matchAlertPolicyFromOrganizationAlertPolicyName( organizationAlertPolicyName: string ) { - return this._pathTemplates.organizationAlertPolicyPathTemplate.match( + return this.pathTemplates.organizationAlertPolicyPathTemplate.match( organizationAlertPolicyName ).alert_policy; } @@ -1508,11 +1686,11 @@ export class GroupServiceClient { alertPolicy: string, condition: string ) { - return this._pathTemplates.organizationAlertPolicyConditionPathTemplate.render( + return this.pathTemplates.organizationAlertPolicyConditionPathTemplate.render( { - organization, + organization: organization, alert_policy: alertPolicy, - condition, + condition: condition, } ); } @@ -1527,7 +1705,7 @@ export class GroupServiceClient { matchOrganizationFromOrganizationAlertPolicyConditionName( organizationAlertPolicyConditionName: string ) { - return this._pathTemplates.organizationAlertPolicyConditionPathTemplate.match( + return this.pathTemplates.organizationAlertPolicyConditionPathTemplate.match( organizationAlertPolicyConditionName ).organization; } @@ -1542,7 +1720,7 @@ export class GroupServiceClient { matchAlertPolicyFromOrganizationAlertPolicyConditionName( organizationAlertPolicyConditionName: string ) { - return this._pathTemplates.organizationAlertPolicyConditionPathTemplate.match( + return this.pathTemplates.organizationAlertPolicyConditionPathTemplate.match( organizationAlertPolicyConditionName ).alert_policy; } @@ -1557,7 +1735,7 @@ export class GroupServiceClient { matchConditionFromOrganizationAlertPolicyConditionName( organizationAlertPolicyConditionName: string ) { - return this._pathTemplates.organizationAlertPolicyConditionPathTemplate.match( + return this.pathTemplates.organizationAlertPolicyConditionPathTemplate.match( organizationAlertPolicyConditionName ).condition; } @@ -1573,12 +1751,10 @@ export class GroupServiceClient { organization: string, channelDescriptor: string ) { - return this._pathTemplates.organizationChannelDescriptorPathTemplate.render( - { - organization, - channel_descriptor: channelDescriptor, - } - ); + return this.pathTemplates.organizationChannelDescriptorPathTemplate.render({ + organization: organization, + channel_descriptor: channelDescriptor, + }); } /** @@ -1591,7 +1767,7 @@ export class GroupServiceClient { matchOrganizationFromOrganizationChannelDescriptorName( organizationChannelDescriptorName: string ) { - return this._pathTemplates.organizationChannelDescriptorPathTemplate.match( + return this.pathTemplates.organizationChannelDescriptorPathTemplate.match( organizationChannelDescriptorName ).organization; } @@ -1606,7 +1782,7 @@ export class GroupServiceClient { matchChannelDescriptorFromOrganizationChannelDescriptorName( organizationChannelDescriptorName: string ) { - return this._pathTemplates.organizationChannelDescriptorPathTemplate.match( + return this.pathTemplates.organizationChannelDescriptorPathTemplate.match( organizationChannelDescriptorName ).channel_descriptor; } @@ -1619,9 +1795,9 @@ export class GroupServiceClient { * @returns {string} Resource name string. */ organizationGroupPath(organization: string, group: string) { - return this._pathTemplates.organizationGroupPathTemplate.render({ - organization, - group, + return this.pathTemplates.organizationGroupPathTemplate.render({ + organization: organization, + group: group, }); } @@ -1633,7 +1809,7 @@ export class GroupServiceClient { * @returns {string} A string representing the organization. */ matchOrganizationFromOrganizationGroupName(organizationGroupName: string) { - return this._pathTemplates.organizationGroupPathTemplate.match( + return this.pathTemplates.organizationGroupPathTemplate.match( organizationGroupName ).organization; } @@ -1646,7 +1822,7 @@ export class GroupServiceClient { * @returns {string} A string representing the group. */ matchGroupFromOrganizationGroupName(organizationGroupName: string) { - return this._pathTemplates.organizationGroupPathTemplate.match( + return this.pathTemplates.organizationGroupPathTemplate.match( organizationGroupName ).group; } @@ -1662,9 +1838,9 @@ export class GroupServiceClient { organization: string, notificationChannel: string ) { - return this._pathTemplates.organizationNotificationChannelPathTemplate.render( + return this.pathTemplates.organizationNotificationChannelPathTemplate.render( { - organization, + organization: organization, notification_channel: notificationChannel, } ); @@ -1680,7 +1856,7 @@ export class GroupServiceClient { matchOrganizationFromOrganizationNotificationChannelName( organizationNotificationChannelName: string ) { - return this._pathTemplates.organizationNotificationChannelPathTemplate.match( + return this.pathTemplates.organizationNotificationChannelPathTemplate.match( organizationNotificationChannelName ).organization; } @@ -1695,7 +1871,7 @@ export class GroupServiceClient { matchNotificationChannelFromOrganizationNotificationChannelName( organizationNotificationChannelName: string ) { - return this._pathTemplates.organizationNotificationChannelPathTemplate.match( + return this.pathTemplates.organizationNotificationChannelPathTemplate.match( organizationNotificationChannelName ).notification_channel; } @@ -1708,9 +1884,9 @@ export class GroupServiceClient { * @returns {string} Resource name string. */ organizationServicePath(organization: string, service: string) { - return this._pathTemplates.organizationServicePathTemplate.render({ - organization, - service, + return this.pathTemplates.organizationServicePathTemplate.render({ + organization: organization, + service: service, }); } @@ -1724,7 +1900,7 @@ export class GroupServiceClient { matchOrganizationFromOrganizationServiceName( organizationServiceName: string ) { - return this._pathTemplates.organizationServicePathTemplate.match( + return this.pathTemplates.organizationServicePathTemplate.match( organizationServiceName ).organization; } @@ -1737,7 +1913,7 @@ export class GroupServiceClient { * @returns {string} A string representing the service. */ matchServiceFromOrganizationServiceName(organizationServiceName: string) { - return this._pathTemplates.organizationServicePathTemplate.match( + return this.pathTemplates.organizationServicePathTemplate.match( organizationServiceName ).service; } @@ -1755,10 +1931,10 @@ export class GroupServiceClient { service: string, serviceLevelObjective: string ) { - return this._pathTemplates.organizationServiceServiceLevelObjectivePathTemplate.render( + return this.pathTemplates.organizationServiceServiceLevelObjectivePathTemplate.render( { - organization, - service, + organization: organization, + service: service, service_level_objective: serviceLevelObjective, } ); @@ -1774,7 +1950,7 @@ export class GroupServiceClient { matchOrganizationFromOrganizationServiceServiceLevelObjectiveName( organizationServiceServiceLevelObjectiveName: string ) { - return this._pathTemplates.organizationServiceServiceLevelObjectivePathTemplate.match( + return this.pathTemplates.organizationServiceServiceLevelObjectivePathTemplate.match( organizationServiceServiceLevelObjectiveName ).organization; } @@ -1789,7 +1965,7 @@ export class GroupServiceClient { matchServiceFromOrganizationServiceServiceLevelObjectiveName( organizationServiceServiceLevelObjectiveName: string ) { - return this._pathTemplates.organizationServiceServiceLevelObjectivePathTemplate.match( + return this.pathTemplates.organizationServiceServiceLevelObjectivePathTemplate.match( organizationServiceServiceLevelObjectiveName ).service; } @@ -1804,7 +1980,7 @@ export class GroupServiceClient { matchServiceLevelObjectiveFromOrganizationServiceServiceLevelObjectiveName( organizationServiceServiceLevelObjectiveName: string ) { - return this._pathTemplates.organizationServiceServiceLevelObjectivePathTemplate.match( + return this.pathTemplates.organizationServiceServiceLevelObjectivePathTemplate.match( organizationServiceServiceLevelObjectiveName ).service_level_objective; } @@ -1820,12 +1996,10 @@ export class GroupServiceClient { organization: string, uptimeCheckConfig: string ) { - return this._pathTemplates.organizationUptimeCheckConfigPathTemplate.render( - { - organization, - uptime_check_config: uptimeCheckConfig, - } - ); + return this.pathTemplates.organizationUptimeCheckConfigPathTemplate.render({ + organization: organization, + uptime_check_config: uptimeCheckConfig, + }); } /** @@ -1838,7 +2012,7 @@ export class GroupServiceClient { matchOrganizationFromOrganizationUptimeCheckConfigName( organizationUptimeCheckConfigName: string ) { - return this._pathTemplates.organizationUptimeCheckConfigPathTemplate.match( + return this.pathTemplates.organizationUptimeCheckConfigPathTemplate.match( organizationUptimeCheckConfigName ).organization; } @@ -1853,7 +2027,7 @@ export class GroupServiceClient { matchUptimeCheckConfigFromOrganizationUptimeCheckConfigName( organizationUptimeCheckConfigName: string ) { - return this._pathTemplates.organizationUptimeCheckConfigPathTemplate.match( + return this.pathTemplates.organizationUptimeCheckConfigPathTemplate.match( organizationUptimeCheckConfigName ).uptime_check_config; } @@ -1865,8 +2039,8 @@ export class GroupServiceClient { * @returns {string} Resource name string. */ projectPath(project: string) { - return this._pathTemplates.projectPathTemplate.render({ - project, + return this.pathTemplates.projectPathTemplate.render({ + project: project, }); } @@ -1878,7 +2052,7 @@ export class GroupServiceClient { * @returns {string} A string representing the project. */ matchProjectFromProjectName(projectName: string) { - return this._pathTemplates.projectPathTemplate.match(projectName).project; + return this.pathTemplates.projectPathTemplate.match(projectName).project; } /** @@ -1889,8 +2063,8 @@ export class GroupServiceClient { * @returns {string} Resource name string. */ projectAlertPolicyPath(project: string, alertPolicy: string) { - return this._pathTemplates.projectAlertPolicyPathTemplate.render({ - project, + return this.pathTemplates.projectAlertPolicyPathTemplate.render({ + project: project, alert_policy: alertPolicy, }); } @@ -1903,7 +2077,7 @@ export class GroupServiceClient { * @returns {string} A string representing the project. */ matchProjectFromProjectAlertPolicyName(projectAlertPolicyName: string) { - return this._pathTemplates.projectAlertPolicyPathTemplate.match( + return this.pathTemplates.projectAlertPolicyPathTemplate.match( projectAlertPolicyName ).project; } @@ -1916,7 +2090,7 @@ export class GroupServiceClient { * @returns {string} A string representing the alert_policy. */ matchAlertPolicyFromProjectAlertPolicyName(projectAlertPolicyName: string) { - return this._pathTemplates.projectAlertPolicyPathTemplate.match( + return this.pathTemplates.projectAlertPolicyPathTemplate.match( projectAlertPolicyName ).alert_policy; } @@ -1934,10 +2108,10 @@ export class GroupServiceClient { alertPolicy: string, condition: string ) { - return this._pathTemplates.projectAlertPolicyConditionPathTemplate.render({ - project, + return this.pathTemplates.projectAlertPolicyConditionPathTemplate.render({ + project: project, alert_policy: alertPolicy, - condition, + condition: condition, }); } @@ -1951,7 +2125,7 @@ export class GroupServiceClient { matchProjectFromProjectAlertPolicyConditionName( projectAlertPolicyConditionName: string ) { - return this._pathTemplates.projectAlertPolicyConditionPathTemplate.match( + return this.pathTemplates.projectAlertPolicyConditionPathTemplate.match( projectAlertPolicyConditionName ).project; } @@ -1966,7 +2140,7 @@ export class GroupServiceClient { matchAlertPolicyFromProjectAlertPolicyConditionName( projectAlertPolicyConditionName: string ) { - return this._pathTemplates.projectAlertPolicyConditionPathTemplate.match( + return this.pathTemplates.projectAlertPolicyConditionPathTemplate.match( projectAlertPolicyConditionName ).alert_policy; } @@ -1981,7 +2155,7 @@ export class GroupServiceClient { matchConditionFromProjectAlertPolicyConditionName( projectAlertPolicyConditionName: string ) { - return this._pathTemplates.projectAlertPolicyConditionPathTemplate.match( + return this.pathTemplates.projectAlertPolicyConditionPathTemplate.match( projectAlertPolicyConditionName ).condition; } @@ -1994,8 +2168,8 @@ export class GroupServiceClient { * @returns {string} Resource name string. */ projectChannelDescriptorPath(project: string, channelDescriptor: string) { - return this._pathTemplates.projectChannelDescriptorPathTemplate.render({ - project, + return this.pathTemplates.projectChannelDescriptorPathTemplate.render({ + project: project, channel_descriptor: channelDescriptor, }); } @@ -2010,7 +2184,7 @@ export class GroupServiceClient { matchProjectFromProjectChannelDescriptorName( projectChannelDescriptorName: string ) { - return this._pathTemplates.projectChannelDescriptorPathTemplate.match( + return this.pathTemplates.projectChannelDescriptorPathTemplate.match( projectChannelDescriptorName ).project; } @@ -2025,7 +2199,7 @@ export class GroupServiceClient { matchChannelDescriptorFromProjectChannelDescriptorName( projectChannelDescriptorName: string ) { - return this._pathTemplates.projectChannelDescriptorPathTemplate.match( + return this.pathTemplates.projectChannelDescriptorPathTemplate.match( projectChannelDescriptorName ).channel_descriptor; } @@ -2038,9 +2212,9 @@ export class GroupServiceClient { * @returns {string} Resource name string. */ projectGroupPath(project: string, group: string) { - return this._pathTemplates.projectGroupPathTemplate.render({ - project, - group, + return this.pathTemplates.projectGroupPathTemplate.render({ + project: project, + group: group, }); } @@ -2052,7 +2226,7 @@ export class GroupServiceClient { * @returns {string} A string representing the project. */ matchProjectFromProjectGroupName(projectGroupName: string) { - return this._pathTemplates.projectGroupPathTemplate.match(projectGroupName) + return this.pathTemplates.projectGroupPathTemplate.match(projectGroupName) .project; } @@ -2064,7 +2238,7 @@ export class GroupServiceClient { * @returns {string} A string representing the group. */ matchGroupFromProjectGroupName(projectGroupName: string) { - return this._pathTemplates.projectGroupPathTemplate.match(projectGroupName) + return this.pathTemplates.projectGroupPathTemplate.match(projectGroupName) .group; } @@ -2076,8 +2250,8 @@ export class GroupServiceClient { * @returns {string} Resource name string. */ projectNotificationChannelPath(project: string, notificationChannel: string) { - return this._pathTemplates.projectNotificationChannelPathTemplate.render({ - project, + return this.pathTemplates.projectNotificationChannelPathTemplate.render({ + project: project, notification_channel: notificationChannel, }); } @@ -2092,7 +2266,7 @@ export class GroupServiceClient { matchProjectFromProjectNotificationChannelName( projectNotificationChannelName: string ) { - return this._pathTemplates.projectNotificationChannelPathTemplate.match( + return this.pathTemplates.projectNotificationChannelPathTemplate.match( projectNotificationChannelName ).project; } @@ -2107,7 +2281,7 @@ export class GroupServiceClient { matchNotificationChannelFromProjectNotificationChannelName( projectNotificationChannelName: string ) { - return this._pathTemplates.projectNotificationChannelPathTemplate.match( + return this.pathTemplates.projectNotificationChannelPathTemplate.match( projectNotificationChannelName ).notification_channel; } @@ -2120,9 +2294,9 @@ export class GroupServiceClient { * @returns {string} Resource name string. */ projectServicePath(project: string, service: string) { - return this._pathTemplates.projectServicePathTemplate.render({ - project, - service, + return this.pathTemplates.projectServicePathTemplate.render({ + project: project, + service: service, }); } @@ -2134,7 +2308,7 @@ export class GroupServiceClient { * @returns {string} A string representing the project. */ matchProjectFromProjectServiceName(projectServiceName: string) { - return this._pathTemplates.projectServicePathTemplate.match( + return this.pathTemplates.projectServicePathTemplate.match( projectServiceName ).project; } @@ -2147,7 +2321,7 @@ export class GroupServiceClient { * @returns {string} A string representing the service. */ matchServiceFromProjectServiceName(projectServiceName: string) { - return this._pathTemplates.projectServicePathTemplate.match( + return this.pathTemplates.projectServicePathTemplate.match( projectServiceName ).service; } @@ -2165,10 +2339,10 @@ export class GroupServiceClient { service: string, serviceLevelObjective: string ) { - return this._pathTemplates.projectServiceServiceLevelObjectivePathTemplate.render( + return this.pathTemplates.projectServiceServiceLevelObjectivePathTemplate.render( { - project, - service, + project: project, + service: service, service_level_objective: serviceLevelObjective, } ); @@ -2184,7 +2358,7 @@ export class GroupServiceClient { matchProjectFromProjectServiceServiceLevelObjectiveName( projectServiceServiceLevelObjectiveName: string ) { - return this._pathTemplates.projectServiceServiceLevelObjectivePathTemplate.match( + return this.pathTemplates.projectServiceServiceLevelObjectivePathTemplate.match( projectServiceServiceLevelObjectiveName ).project; } @@ -2199,7 +2373,7 @@ export class GroupServiceClient { matchServiceFromProjectServiceServiceLevelObjectiveName( projectServiceServiceLevelObjectiveName: string ) { - return this._pathTemplates.projectServiceServiceLevelObjectivePathTemplate.match( + return this.pathTemplates.projectServiceServiceLevelObjectivePathTemplate.match( projectServiceServiceLevelObjectiveName ).service; } @@ -2214,7 +2388,7 @@ export class GroupServiceClient { matchServiceLevelObjectiveFromProjectServiceServiceLevelObjectiveName( projectServiceServiceLevelObjectiveName: string ) { - return this._pathTemplates.projectServiceServiceLevelObjectivePathTemplate.match( + return this.pathTemplates.projectServiceServiceLevelObjectivePathTemplate.match( projectServiceServiceLevelObjectiveName ).service_level_objective; } @@ -2227,8 +2401,8 @@ export class GroupServiceClient { * @returns {string} Resource name string. */ projectUptimeCheckConfigPath(project: string, uptimeCheckConfig: string) { - return this._pathTemplates.projectUptimeCheckConfigPathTemplate.render({ - project, + return this.pathTemplates.projectUptimeCheckConfigPathTemplate.render({ + project: project, uptime_check_config: uptimeCheckConfig, }); } @@ -2243,7 +2417,7 @@ export class GroupServiceClient { matchProjectFromProjectUptimeCheckConfigName( projectUptimeCheckConfigName: string ) { - return this._pathTemplates.projectUptimeCheckConfigPathTemplate.match( + return this.pathTemplates.projectUptimeCheckConfigPathTemplate.match( projectUptimeCheckConfigName ).project; } @@ -2258,7 +2432,7 @@ export class GroupServiceClient { matchUptimeCheckConfigFromProjectUptimeCheckConfigName( projectUptimeCheckConfigName: string ) { - return this._pathTemplates.projectUptimeCheckConfigPathTemplate.match( + return this.pathTemplates.projectUptimeCheckConfigPathTemplate.match( projectUptimeCheckConfigName ).uptime_check_config; } diff --git a/packages/google-cloud-monitoring/src/v3/index.ts b/packages/google-cloud-monitoring/src/v3/index.ts index 137839b9018..fe58a3d3a4a 100644 --- a/packages/google-cloud-monitoring/src/v3/index.ts +++ b/packages/google-cloud-monitoring/src/v3/index.ts @@ -1,4 +1,4 @@ -// Copyright 2019 Google LLC +// Copyright 2020 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/packages/google-cloud-monitoring/src/v3/metric_service_client.ts b/packages/google-cloud-monitoring/src/v3/metric_service_client.ts index 44d265baa6e..9f161a1bffb 100644 --- a/packages/google-cloud-monitoring/src/v3/metric_service_client.ts +++ b/packages/google-cloud-monitoring/src/v3/metric_service_client.ts @@ -1,4 +1,4 @@ -// Copyright 2019 Google LLC +// Copyright 2020 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -18,18 +18,18 @@ import * as gax from 'google-gax'; import { - APICallback, Callback, CallOptions, Descriptors, ClientOptions, PaginationCallback, - PaginationResponse, + GaxCall, } from 'google-gax'; import * as path from 'path'; import {Transform} from 'stream'; -import * as protosTypes from '../../protos/protos'; +import {RequestType} from 'google-gax/build/src/apitypes'; +import * as protos from '../../protos/protos'; import * as gapicConfig from './metric_service_client_config.json'; const version = require('../../../package.json').version; @@ -41,9 +41,6 @@ const version = require('../../../package.json').version; * @memberof v3 */ export class MetricServiceClient { - private _descriptors: Descriptors = {page: {}, stream: {}, longrunning: {}}; - private _innerApiCalls: {[name: string]: Function}; - private _pathTemplates: {[name: string]: gax.PathTemplate}; private _terminated = false; private _opts: ClientOptions; private _gaxModule: typeof gax | typeof gax.fallback; @@ -51,6 +48,14 @@ export class MetricServiceClient { private _protos: {}; private _defaults: {[method: string]: gax.CallSettings}; auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + innerApiCalls: {[name: string]: Function}; + pathTemplates: {[name: string]: gax.PathTemplate}; metricServiceStub?: Promise<{[name: string]: Function}>; /** @@ -142,13 +147,16 @@ export class MetricServiceClient { 'protos.json' ); this._protos = this._gaxGrpc.loadProto( - opts.fallback ? 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 // identifiers to uniquely identify resources within the API. // Create useful helper objects for these. - this._pathTemplates = { + this.pathTemplates = { folderAlertPolicyPathTemplate: new this._gaxModule.PathTemplate( 'folders/{folder}/alertPolicies/{alert_policy}' ), @@ -247,7 +255,7 @@ export class MetricServiceClient { // Some of the methods on this service return "paged" results, // (e.g. 50 results at a time, with tokens to get subsequent // pages). Denote the keys used for pagination and results. - this._descriptors.page = { + this.descriptors.page = { listMonitoredResourceDescriptors: new this._gaxModule.PageDescriptor( 'pageToken', 'nextPageToken', @@ -276,7 +284,7 @@ export class MetricServiceClient { // Set up a dictionary of "inner API calls"; the core implementation // of calling the API is handled in `google-gax`, with this code // merely providing the destination and request information. - this._innerApiCalls = {}; + this.innerApiCalls = {}; } /** @@ -303,7 +311,7 @@ export class MetricServiceClient { ? (this._protos as protobuf.Root).lookupService( 'google.monitoring.v3.MetricService' ) - : // tslint:disable-next-line no-any + : // eslint-disable-next-line @typescript-eslint/no-explicit-any (this._protos as any).google.monitoring.v3.MetricService, this._opts ) as Promise<{[method: string]: Function}>; @@ -320,14 +328,14 @@ export class MetricServiceClient { 'listTimeSeries', 'createTimeSeries', ]; - for (const methodName of metricServiceStubMethods) { - const innerCallPromise = this.metricServiceStub.then( + const callPromise = this.metricServiceStub.then( stub => (...args: Array<{}>) => { if (this._terminated) { return Promise.reject('The client has already been closed.'); } - return stub[methodName].apply(stub, args); + const func = stub[methodName]; + return func.apply(stub, args); }, (err: Error | null | undefined) => () => { throw err; @@ -335,20 +343,14 @@ export class MetricServiceClient { ); const apiCall = this._gaxModule.createApiCall( - innerCallPromise, + callPromise, this._defaults[methodName], - this._descriptors.page[methodName] || - this._descriptors.stream[methodName] || - this._descriptors.longrunning[methodName] + this.descriptors.page[methodName] || + this.descriptors.stream[methodName] || + this.descriptors.longrunning[methodName] ); - this._innerApiCalls[methodName] = ( - argument: {}, - callOptions?: CallOptions, - callback?: APICallback - ) => { - return apiCall(argument, callOptions, callback); - }; + this.innerApiCalls[methodName] = apiCall; } return this.metricServiceStub; @@ -410,26 +412,37 @@ export class MetricServiceClient { // -- Service calls -- // ------------------- getMonitoredResourceDescriptor( - request: protosTypes.google.monitoring.v3.IGetMonitoredResourceDescriptorRequest, + request: protos.google.monitoring.v3.IGetMonitoredResourceDescriptorRequest, options?: gax.CallOptions ): Promise< [ - protosTypes.google.api.IMonitoredResourceDescriptor, + protos.google.api.IMonitoredResourceDescriptor, ( - | protosTypes.google.monitoring.v3.IGetMonitoredResourceDescriptorRequest + | protos.google.monitoring.v3.IGetMonitoredResourceDescriptorRequest | undefined ), {} | undefined ] >; getMonitoredResourceDescriptor( - request: protosTypes.google.monitoring.v3.IGetMonitoredResourceDescriptorRequest, + request: protos.google.monitoring.v3.IGetMonitoredResourceDescriptorRequest, options: gax.CallOptions, callback: Callback< - protosTypes.google.api.IMonitoredResourceDescriptor, - | protosTypes.google.monitoring.v3.IGetMonitoredResourceDescriptorRequest + protos.google.api.IMonitoredResourceDescriptor, + | protos.google.monitoring.v3.IGetMonitoredResourceDescriptorRequest + | null | undefined, - {} | undefined + {} | null | undefined + > + ): void; + getMonitoredResourceDescriptor( + request: protos.google.monitoring.v3.IGetMonitoredResourceDescriptorRequest, + callback: Callback< + protos.google.api.IMonitoredResourceDescriptor, + | protos.google.monitoring.v3.IGetMonitoredResourceDescriptorRequest + | null + | undefined, + {} | null | undefined > ): void; /** @@ -451,26 +464,28 @@ export class MetricServiceClient { * The promise has a method named "cancel" which cancels the ongoing API call. */ getMonitoredResourceDescriptor( - request: protosTypes.google.monitoring.v3.IGetMonitoredResourceDescriptorRequest, + request: protos.google.monitoring.v3.IGetMonitoredResourceDescriptorRequest, optionsOrCallback?: | gax.CallOptions | Callback< - protosTypes.google.api.IMonitoredResourceDescriptor, - | protosTypes.google.monitoring.v3.IGetMonitoredResourceDescriptorRequest + protos.google.api.IMonitoredResourceDescriptor, + | protos.google.monitoring.v3.IGetMonitoredResourceDescriptorRequest + | null | undefined, - {} | undefined + {} | null | undefined >, callback?: Callback< - protosTypes.google.api.IMonitoredResourceDescriptor, - | protosTypes.google.monitoring.v3.IGetMonitoredResourceDescriptorRequest + protos.google.api.IMonitoredResourceDescriptor, + | protos.google.monitoring.v3.IGetMonitoredResourceDescriptorRequest + | null | undefined, - {} | undefined + {} | null | undefined > ): Promise< [ - protosTypes.google.api.IMonitoredResourceDescriptor, + protos.google.api.IMonitoredResourceDescriptor, ( - | protosTypes.google.monitoring.v3.IGetMonitoredResourceDescriptorRequest + | protos.google.monitoring.v3.IGetMonitoredResourceDescriptorRequest | undefined ), {} | undefined @@ -493,29 +508,41 @@ export class MetricServiceClient { name: request.name || '', }); this.initialize(); - return this._innerApiCalls.getMonitoredResourceDescriptor( + return this.innerApiCalls.getMonitoredResourceDescriptor( request, options, callback ); } getMetricDescriptor( - request: protosTypes.google.monitoring.v3.IGetMetricDescriptorRequest, + request: protos.google.monitoring.v3.IGetMetricDescriptorRequest, options?: gax.CallOptions ): Promise< [ - protosTypes.google.api.IMetricDescriptor, - protosTypes.google.monitoring.v3.IGetMetricDescriptorRequest | undefined, + protos.google.api.IMetricDescriptor, + protos.google.monitoring.v3.IGetMetricDescriptorRequest | undefined, {} | undefined ] >; getMetricDescriptor( - request: protosTypes.google.monitoring.v3.IGetMetricDescriptorRequest, + request: protos.google.monitoring.v3.IGetMetricDescriptorRequest, options: gax.CallOptions, callback: Callback< - protosTypes.google.api.IMetricDescriptor, - protosTypes.google.monitoring.v3.IGetMetricDescriptorRequest | undefined, - {} | undefined + protos.google.api.IMetricDescriptor, + | protos.google.monitoring.v3.IGetMetricDescriptorRequest + | null + | undefined, + {} | null | undefined + > + ): void; + getMetricDescriptor( + request: protos.google.monitoring.v3.IGetMetricDescriptorRequest, + callback: Callback< + protos.google.api.IMetricDescriptor, + | protos.google.monitoring.v3.IGetMetricDescriptorRequest + | null + | undefined, + {} | null | undefined > ): void; /** @@ -537,24 +564,27 @@ export class MetricServiceClient { * The promise has a method named "cancel" which cancels the ongoing API call. */ getMetricDescriptor( - request: protosTypes.google.monitoring.v3.IGetMetricDescriptorRequest, + request: protos.google.monitoring.v3.IGetMetricDescriptorRequest, optionsOrCallback?: | gax.CallOptions | Callback< - protosTypes.google.api.IMetricDescriptor, - | protosTypes.google.monitoring.v3.IGetMetricDescriptorRequest + protos.google.api.IMetricDescriptor, + | protos.google.monitoring.v3.IGetMetricDescriptorRequest + | null | undefined, - {} | undefined + {} | null | undefined >, callback?: Callback< - protosTypes.google.api.IMetricDescriptor, - protosTypes.google.monitoring.v3.IGetMetricDescriptorRequest | undefined, - {} | undefined + protos.google.api.IMetricDescriptor, + | protos.google.monitoring.v3.IGetMetricDescriptorRequest + | null + | undefined, + {} | null | undefined > ): Promise< [ - protosTypes.google.api.IMetricDescriptor, - protosTypes.google.monitoring.v3.IGetMetricDescriptorRequest | undefined, + protos.google.api.IMetricDescriptor, + protos.google.monitoring.v3.IGetMetricDescriptorRequest | undefined, {} | undefined ] > | void { @@ -575,29 +605,37 @@ export class MetricServiceClient { name: request.name || '', }); this.initialize(); - return this._innerApiCalls.getMetricDescriptor(request, options, callback); + return this.innerApiCalls.getMetricDescriptor(request, options, callback); } createMetricDescriptor( - request: protosTypes.google.monitoring.v3.ICreateMetricDescriptorRequest, + request: protos.google.monitoring.v3.ICreateMetricDescriptorRequest, options?: gax.CallOptions ): Promise< [ - protosTypes.google.api.IMetricDescriptor, - ( - | protosTypes.google.monitoring.v3.ICreateMetricDescriptorRequest - | undefined - ), + protos.google.api.IMetricDescriptor, + protos.google.monitoring.v3.ICreateMetricDescriptorRequest | undefined, {} | undefined ] >; createMetricDescriptor( - request: protosTypes.google.monitoring.v3.ICreateMetricDescriptorRequest, + request: protos.google.monitoring.v3.ICreateMetricDescriptorRequest, options: gax.CallOptions, callback: Callback< - protosTypes.google.api.IMetricDescriptor, - | protosTypes.google.monitoring.v3.ICreateMetricDescriptorRequest + protos.google.api.IMetricDescriptor, + | protos.google.monitoring.v3.ICreateMetricDescriptorRequest + | null | undefined, - {} | undefined + {} | null | undefined + > + ): void; + createMetricDescriptor( + request: protos.google.monitoring.v3.ICreateMetricDescriptorRequest, + callback: Callback< + protos.google.api.IMetricDescriptor, + | protos.google.monitoring.v3.ICreateMetricDescriptorRequest + | null + | undefined, + {} | null | undefined > ): void; /** @@ -621,28 +659,27 @@ export class MetricServiceClient { * The promise has a method named "cancel" which cancels the ongoing API call. */ createMetricDescriptor( - request: protosTypes.google.monitoring.v3.ICreateMetricDescriptorRequest, + request: protos.google.monitoring.v3.ICreateMetricDescriptorRequest, optionsOrCallback?: | gax.CallOptions | Callback< - protosTypes.google.api.IMetricDescriptor, - | protosTypes.google.monitoring.v3.ICreateMetricDescriptorRequest + protos.google.api.IMetricDescriptor, + | protos.google.monitoring.v3.ICreateMetricDescriptorRequest + | null | undefined, - {} | undefined + {} | null | undefined >, callback?: Callback< - protosTypes.google.api.IMetricDescriptor, - | protosTypes.google.monitoring.v3.ICreateMetricDescriptorRequest + protos.google.api.IMetricDescriptor, + | protos.google.monitoring.v3.ICreateMetricDescriptorRequest + | null | undefined, - {} | undefined + {} | null | undefined > ): Promise< [ - protosTypes.google.api.IMetricDescriptor, - ( - | protosTypes.google.monitoring.v3.ICreateMetricDescriptorRequest - | undefined - ), + protos.google.api.IMetricDescriptor, + protos.google.monitoring.v3.ICreateMetricDescriptorRequest | undefined, {} | undefined ] > | void { @@ -663,33 +700,41 @@ export class MetricServiceClient { name: request.name || '', }); this.initialize(); - return this._innerApiCalls.createMetricDescriptor( + return this.innerApiCalls.createMetricDescriptor( request, options, callback ); } deleteMetricDescriptor( - request: protosTypes.google.monitoring.v3.IDeleteMetricDescriptorRequest, + request: protos.google.monitoring.v3.IDeleteMetricDescriptorRequest, options?: gax.CallOptions ): Promise< [ - protosTypes.google.protobuf.IEmpty, - ( - | protosTypes.google.monitoring.v3.IDeleteMetricDescriptorRequest - | undefined - ), + protos.google.protobuf.IEmpty, + protos.google.monitoring.v3.IDeleteMetricDescriptorRequest | undefined, {} | undefined ] >; deleteMetricDescriptor( - request: protosTypes.google.monitoring.v3.IDeleteMetricDescriptorRequest, + request: protos.google.monitoring.v3.IDeleteMetricDescriptorRequest, options: gax.CallOptions, callback: Callback< - protosTypes.google.protobuf.IEmpty, - | protosTypes.google.monitoring.v3.IDeleteMetricDescriptorRequest + protos.google.protobuf.IEmpty, + | protos.google.monitoring.v3.IDeleteMetricDescriptorRequest + | null | undefined, - {} | undefined + {} | null | undefined + > + ): void; + deleteMetricDescriptor( + request: protos.google.monitoring.v3.IDeleteMetricDescriptorRequest, + callback: Callback< + protos.google.protobuf.IEmpty, + | protos.google.monitoring.v3.IDeleteMetricDescriptorRequest + | null + | undefined, + {} | null | undefined > ): void; /** @@ -713,28 +758,27 @@ export class MetricServiceClient { * The promise has a method named "cancel" which cancels the ongoing API call. */ deleteMetricDescriptor( - request: protosTypes.google.monitoring.v3.IDeleteMetricDescriptorRequest, + request: protos.google.monitoring.v3.IDeleteMetricDescriptorRequest, optionsOrCallback?: | gax.CallOptions | Callback< - protosTypes.google.protobuf.IEmpty, - | protosTypes.google.monitoring.v3.IDeleteMetricDescriptorRequest + protos.google.protobuf.IEmpty, + | protos.google.monitoring.v3.IDeleteMetricDescriptorRequest + | null | undefined, - {} | undefined + {} | null | undefined >, callback?: Callback< - protosTypes.google.protobuf.IEmpty, - | protosTypes.google.monitoring.v3.IDeleteMetricDescriptorRequest + protos.google.protobuf.IEmpty, + | protos.google.monitoring.v3.IDeleteMetricDescriptorRequest + | null | undefined, - {} | undefined + {} | null | undefined > ): Promise< [ - protosTypes.google.protobuf.IEmpty, - ( - | protosTypes.google.monitoring.v3.IDeleteMetricDescriptorRequest - | undefined - ), + protos.google.protobuf.IEmpty, + protos.google.monitoring.v3.IDeleteMetricDescriptorRequest | undefined, {} | undefined ] > | void { @@ -755,29 +799,37 @@ export class MetricServiceClient { name: request.name || '', }); this.initialize(); - return this._innerApiCalls.deleteMetricDescriptor( + return this.innerApiCalls.deleteMetricDescriptor( request, options, callback ); } createTimeSeries( - request: protosTypes.google.monitoring.v3.ICreateTimeSeriesRequest, + request: protos.google.monitoring.v3.ICreateTimeSeriesRequest, options?: gax.CallOptions ): Promise< [ - protosTypes.google.protobuf.IEmpty, - protosTypes.google.monitoring.v3.ICreateTimeSeriesRequest | undefined, + protos.google.protobuf.IEmpty, + protos.google.monitoring.v3.ICreateTimeSeriesRequest | undefined, {} | undefined ] >; createTimeSeries( - request: protosTypes.google.monitoring.v3.ICreateTimeSeriesRequest, + request: protos.google.monitoring.v3.ICreateTimeSeriesRequest, options: gax.CallOptions, callback: Callback< - protosTypes.google.protobuf.IEmpty, - protosTypes.google.monitoring.v3.ICreateTimeSeriesRequest | undefined, - {} | undefined + protos.google.protobuf.IEmpty, + protos.google.monitoring.v3.ICreateTimeSeriesRequest | null | undefined, + {} | null | undefined + > + ): void; + createTimeSeries( + request: protos.google.monitoring.v3.ICreateTimeSeriesRequest, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.monitoring.v3.ICreateTimeSeriesRequest | null | undefined, + {} | null | undefined > ): void; /** @@ -807,23 +859,25 @@ export class MetricServiceClient { * The promise has a method named "cancel" which cancels the ongoing API call. */ createTimeSeries( - request: protosTypes.google.monitoring.v3.ICreateTimeSeriesRequest, + request: protos.google.monitoring.v3.ICreateTimeSeriesRequest, optionsOrCallback?: | gax.CallOptions | Callback< - protosTypes.google.protobuf.IEmpty, - protosTypes.google.monitoring.v3.ICreateTimeSeriesRequest | undefined, - {} | undefined + protos.google.protobuf.IEmpty, + | protos.google.monitoring.v3.ICreateTimeSeriesRequest + | null + | undefined, + {} | null | undefined >, callback?: Callback< - protosTypes.google.protobuf.IEmpty, - protosTypes.google.monitoring.v3.ICreateTimeSeriesRequest | undefined, - {} | undefined + protos.google.protobuf.IEmpty, + protos.google.monitoring.v3.ICreateTimeSeriesRequest | null | undefined, + {} | null | undefined > ): Promise< [ - protosTypes.google.protobuf.IEmpty, - protosTypes.google.monitoring.v3.ICreateTimeSeriesRequest | undefined, + protos.google.protobuf.IEmpty, + protos.google.monitoring.v3.ICreateTimeSeriesRequest | undefined, {} | undefined ] > | void { @@ -844,26 +898,38 @@ export class MetricServiceClient { name: request.name || '', }); this.initialize(); - return this._innerApiCalls.createTimeSeries(request, options, callback); + return this.innerApiCalls.createTimeSeries(request, options, callback); } listMonitoredResourceDescriptors( - request: protosTypes.google.monitoring.v3.IListMonitoredResourceDescriptorsRequest, + request: protos.google.monitoring.v3.IListMonitoredResourceDescriptorsRequest, options?: gax.CallOptions ): Promise< [ - protosTypes.google.api.IMonitoredResourceDescriptor[], - protosTypes.google.monitoring.v3.IListMonitoredResourceDescriptorsRequest | null, - protosTypes.google.monitoring.v3.IListMonitoredResourceDescriptorsResponse + protos.google.api.IMonitoredResourceDescriptor[], + protos.google.monitoring.v3.IListMonitoredResourceDescriptorsRequest | null, + protos.google.monitoring.v3.IListMonitoredResourceDescriptorsResponse ] >; listMonitoredResourceDescriptors( - request: protosTypes.google.monitoring.v3.IListMonitoredResourceDescriptorsRequest, + request: protos.google.monitoring.v3.IListMonitoredResourceDescriptorsRequest, options: gax.CallOptions, - callback: Callback< - protosTypes.google.api.IMonitoredResourceDescriptor[], - protosTypes.google.monitoring.v3.IListMonitoredResourceDescriptorsRequest | null, - protosTypes.google.monitoring.v3.IListMonitoredResourceDescriptorsResponse + callback: PaginationCallback< + protos.google.monitoring.v3.IListMonitoredResourceDescriptorsRequest, + | protos.google.monitoring.v3.IListMonitoredResourceDescriptorsResponse + | null + | undefined, + protos.google.api.IMonitoredResourceDescriptor + > + ): void; + listMonitoredResourceDescriptors( + request: protos.google.monitoring.v3.IListMonitoredResourceDescriptorsRequest, + callback: PaginationCallback< + protos.google.monitoring.v3.IListMonitoredResourceDescriptorsRequest, + | protos.google.monitoring.v3.IListMonitoredResourceDescriptorsResponse + | null + | undefined, + protos.google.api.IMonitoredResourceDescriptor > ): void; /** @@ -907,24 +973,28 @@ export class MetricServiceClient { * The promise has a method named "cancel" which cancels the ongoing API call. */ listMonitoredResourceDescriptors( - request: protosTypes.google.monitoring.v3.IListMonitoredResourceDescriptorsRequest, + request: protos.google.monitoring.v3.IListMonitoredResourceDescriptorsRequest, optionsOrCallback?: | gax.CallOptions - | Callback< - protosTypes.google.api.IMonitoredResourceDescriptor[], - protosTypes.google.monitoring.v3.IListMonitoredResourceDescriptorsRequest | null, - protosTypes.google.monitoring.v3.IListMonitoredResourceDescriptorsResponse + | PaginationCallback< + protos.google.monitoring.v3.IListMonitoredResourceDescriptorsRequest, + | protos.google.monitoring.v3.IListMonitoredResourceDescriptorsResponse + | null + | undefined, + protos.google.api.IMonitoredResourceDescriptor >, - callback?: Callback< - protosTypes.google.api.IMonitoredResourceDescriptor[], - protosTypes.google.monitoring.v3.IListMonitoredResourceDescriptorsRequest | null, - protosTypes.google.monitoring.v3.IListMonitoredResourceDescriptorsResponse + callback?: PaginationCallback< + protos.google.monitoring.v3.IListMonitoredResourceDescriptorsRequest, + | protos.google.monitoring.v3.IListMonitoredResourceDescriptorsResponse + | null + | undefined, + protos.google.api.IMonitoredResourceDescriptor > ): Promise< [ - protosTypes.google.api.IMonitoredResourceDescriptor[], - protosTypes.google.monitoring.v3.IListMonitoredResourceDescriptorsRequest | null, - protosTypes.google.monitoring.v3.IListMonitoredResourceDescriptorsResponse + protos.google.api.IMonitoredResourceDescriptor[], + protos.google.monitoring.v3.IListMonitoredResourceDescriptorsRequest | null, + protos.google.monitoring.v3.IListMonitoredResourceDescriptorsResponse ] > | void { request = request || {}; @@ -944,7 +1014,7 @@ export class MetricServiceClient { name: request.name || '', }); this.initialize(); - return this._innerApiCalls.listMonitoredResourceDescriptors( + return this.innerApiCalls.listMonitoredResourceDescriptors( request, options, callback @@ -989,7 +1059,7 @@ export class MetricServiceClient { * An object stream which emits an object representing [MonitoredResourceDescriptor]{@link google.api.MonitoredResourceDescriptor} on 'data' event. */ listMonitoredResourceDescriptorsStream( - request?: protosTypes.google.monitoring.v3.IListMonitoredResourceDescriptorsRequest, + request?: protos.google.monitoring.v3.IListMonitoredResourceDescriptorsRequest, options?: gax.CallOptions ): Transform { request = request || {}; @@ -1003,29 +1073,93 @@ export class MetricServiceClient { }); const callSettings = new gax.CallSettings(options); this.initialize(); - return this._descriptors.page.listMonitoredResourceDescriptors.createStream( - this._innerApiCalls.listMonitoredResourceDescriptors as gax.GaxCall, + return this.descriptors.page.listMonitoredResourceDescriptors.createStream( + this.innerApiCalls.listMonitoredResourceDescriptors as gax.GaxCall, request, callSettings ); } + + /** + * Equivalent to {@link listMonitoredResourceDescriptors}, 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.name + * Required. The project on which to execute the request. The format is: + * + * projects/[PROJECT_ID_OR_NUMBER] + * @param {string} request.filter + * An optional [filter](https://cloud.google.com/monitoring/api/v3/filters) + * describing the descriptors to be returned. The filter can reference the + * descriptor's type and labels. For example, the following filter returns + * only Google Compute Engine descriptors that have an `id` label: + * + * resource.type = starts_with("gce_") AND resource.label:id + * @param {number} request.pageSize + * A positive number that is the maximum number of results to return. + * @param {string} request.pageToken + * If this field is not empty then it must contain the `nextPageToken` value + * returned by a previous call to this method. Using this field causes the + * method to return additional results from the previous method call. + * @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. + */ + listMonitoredResourceDescriptorsAsync( + request?: protos.google.monitoring.v3.IListMonitoredResourceDescriptorsRequest, + options?: gax.CallOptions + ): AsyncIterable { + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + name: request.name || '', + }); + options = options || {}; + const callSettings = new gax.CallSettings(options); + this.initialize(); + return this.descriptors.page.listMonitoredResourceDescriptors.asyncIterate( + this.innerApiCalls['listMonitoredResourceDescriptors'] as GaxCall, + (request as unknown) as RequestType, + callSettings + ) as AsyncIterable; + } listMetricDescriptors( - request: protosTypes.google.monitoring.v3.IListMetricDescriptorsRequest, + request: protos.google.monitoring.v3.IListMetricDescriptorsRequest, options?: gax.CallOptions ): Promise< [ - protosTypes.google.api.IMetricDescriptor[], - protosTypes.google.monitoring.v3.IListMetricDescriptorsRequest | null, - protosTypes.google.monitoring.v3.IListMetricDescriptorsResponse + protos.google.api.IMetricDescriptor[], + protos.google.monitoring.v3.IListMetricDescriptorsRequest | null, + protos.google.monitoring.v3.IListMetricDescriptorsResponse ] >; listMetricDescriptors( - request: protosTypes.google.monitoring.v3.IListMetricDescriptorsRequest, + request: protos.google.monitoring.v3.IListMetricDescriptorsRequest, options: gax.CallOptions, - callback: Callback< - protosTypes.google.api.IMetricDescriptor[], - protosTypes.google.monitoring.v3.IListMetricDescriptorsRequest | null, - protosTypes.google.monitoring.v3.IListMetricDescriptorsResponse + callback: PaginationCallback< + protos.google.monitoring.v3.IListMetricDescriptorsRequest, + | protos.google.monitoring.v3.IListMetricDescriptorsResponse + | null + | undefined, + protos.google.api.IMetricDescriptor + > + ): void; + listMetricDescriptors( + request: protos.google.monitoring.v3.IListMetricDescriptorsRequest, + callback: PaginationCallback< + protos.google.monitoring.v3.IListMetricDescriptorsRequest, + | protos.google.monitoring.v3.IListMetricDescriptorsResponse + | null + | undefined, + protos.google.api.IMetricDescriptor > ): void; /** @@ -1071,24 +1205,28 @@ export class MetricServiceClient { * The promise has a method named "cancel" which cancels the ongoing API call. */ listMetricDescriptors( - request: protosTypes.google.monitoring.v3.IListMetricDescriptorsRequest, + request: protos.google.monitoring.v3.IListMetricDescriptorsRequest, optionsOrCallback?: | gax.CallOptions - | Callback< - protosTypes.google.api.IMetricDescriptor[], - protosTypes.google.monitoring.v3.IListMetricDescriptorsRequest | null, - protosTypes.google.monitoring.v3.IListMetricDescriptorsResponse + | PaginationCallback< + protos.google.monitoring.v3.IListMetricDescriptorsRequest, + | protos.google.monitoring.v3.IListMetricDescriptorsResponse + | null + | undefined, + protos.google.api.IMetricDescriptor >, - callback?: Callback< - protosTypes.google.api.IMetricDescriptor[], - protosTypes.google.monitoring.v3.IListMetricDescriptorsRequest | null, - protosTypes.google.monitoring.v3.IListMetricDescriptorsResponse + callback?: PaginationCallback< + protos.google.monitoring.v3.IListMetricDescriptorsRequest, + | protos.google.monitoring.v3.IListMetricDescriptorsResponse + | null + | undefined, + protos.google.api.IMetricDescriptor > ): Promise< [ - protosTypes.google.api.IMetricDescriptor[], - protosTypes.google.monitoring.v3.IListMetricDescriptorsRequest | null, - protosTypes.google.monitoring.v3.IListMetricDescriptorsResponse + protos.google.api.IMetricDescriptor[], + protos.google.monitoring.v3.IListMetricDescriptorsRequest | null, + protos.google.monitoring.v3.IListMetricDescriptorsResponse ] > | void { request = request || {}; @@ -1108,11 +1246,7 @@ export class MetricServiceClient { name: request.name || '', }); this.initialize(); - return this._innerApiCalls.listMetricDescriptors( - request, - options, - callback - ); + return this.innerApiCalls.listMetricDescriptors(request, options, callback); } /** @@ -1155,7 +1289,7 @@ export class MetricServiceClient { * An object stream which emits an object representing [MetricDescriptor]{@link google.api.MetricDescriptor} on 'data' event. */ listMetricDescriptorsStream( - request?: protosTypes.google.monitoring.v3.IListMetricDescriptorsRequest, + request?: protos.google.monitoring.v3.IListMetricDescriptorsRequest, options?: gax.CallOptions ): Transform { request = request || {}; @@ -1169,29 +1303,91 @@ export class MetricServiceClient { }); const callSettings = new gax.CallSettings(options); this.initialize(); - return this._descriptors.page.listMetricDescriptors.createStream( - this._innerApiCalls.listMetricDescriptors as gax.GaxCall, + return this.descriptors.page.listMetricDescriptors.createStream( + this.innerApiCalls.listMetricDescriptors as gax.GaxCall, request, callSettings ); } + + /** + * Equivalent to {@link listMetricDescriptors}, 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.name + * Required. The project on which to execute the request. The format is: + * + * projects/[PROJECT_ID_OR_NUMBER] + * @param {string} request.filter + * If this field is empty, all custom and + * system-defined metric descriptors are returned. + * Otherwise, the [filter](https://cloud.google.com/monitoring/api/v3/filters) + * specifies which metric descriptors are to be + * returned. For example, the following filter matches all + * [custom metrics](https://cloud.google.com/monitoring/custom-metrics): + * + * metric.type = starts_with("custom.googleapis.com/") + * @param {number} request.pageSize + * A positive number that is the maximum number of results to return. + * @param {string} request.pageToken + * If this field is not empty then it must contain the `nextPageToken` value + * returned by a previous call to this method. Using this field causes the + * method to return additional results from the previous method call. + * @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. + */ + listMetricDescriptorsAsync( + request?: protos.google.monitoring.v3.IListMetricDescriptorsRequest, + options?: gax.CallOptions + ): AsyncIterable { + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + name: request.name || '', + }); + options = options || {}; + const callSettings = new gax.CallSettings(options); + this.initialize(); + return this.descriptors.page.listMetricDescriptors.asyncIterate( + this.innerApiCalls['listMetricDescriptors'] as GaxCall, + (request as unknown) as RequestType, + callSettings + ) as AsyncIterable; + } listTimeSeries( - request: protosTypes.google.monitoring.v3.IListTimeSeriesRequest, + request: protos.google.monitoring.v3.IListTimeSeriesRequest, options?: gax.CallOptions ): Promise< [ - protosTypes.google.monitoring.v3.ITimeSeries[], - protosTypes.google.monitoring.v3.IListTimeSeriesRequest | null, - protosTypes.google.monitoring.v3.IListTimeSeriesResponse + protos.google.monitoring.v3.ITimeSeries[], + protos.google.monitoring.v3.IListTimeSeriesRequest | null, + protos.google.monitoring.v3.IListTimeSeriesResponse ] >; listTimeSeries( - request: protosTypes.google.monitoring.v3.IListTimeSeriesRequest, + request: protos.google.monitoring.v3.IListTimeSeriesRequest, options: gax.CallOptions, - callback: Callback< - protosTypes.google.monitoring.v3.ITimeSeries[], - protosTypes.google.monitoring.v3.IListTimeSeriesRequest | null, - protosTypes.google.monitoring.v3.IListTimeSeriesResponse + callback: PaginationCallback< + protos.google.monitoring.v3.IListTimeSeriesRequest, + protos.google.monitoring.v3.IListTimeSeriesResponse | null | undefined, + protos.google.monitoring.v3.ITimeSeries + > + ): void; + listTimeSeries( + request: protos.google.monitoring.v3.IListTimeSeriesRequest, + callback: PaginationCallback< + protos.google.monitoring.v3.IListTimeSeriesRequest, + protos.google.monitoring.v3.IListTimeSeriesResponse | null | undefined, + protos.google.monitoring.v3.ITimeSeries > ): void; /** @@ -1255,24 +1451,26 @@ export class MetricServiceClient { * The promise has a method named "cancel" which cancels the ongoing API call. */ listTimeSeries( - request: protosTypes.google.monitoring.v3.IListTimeSeriesRequest, + request: protos.google.monitoring.v3.IListTimeSeriesRequest, optionsOrCallback?: | gax.CallOptions - | Callback< - protosTypes.google.monitoring.v3.ITimeSeries[], - protosTypes.google.monitoring.v3.IListTimeSeriesRequest | null, - protosTypes.google.monitoring.v3.IListTimeSeriesResponse + | PaginationCallback< + protos.google.monitoring.v3.IListTimeSeriesRequest, + | protos.google.monitoring.v3.IListTimeSeriesResponse + | null + | undefined, + protos.google.monitoring.v3.ITimeSeries >, - callback?: Callback< - protosTypes.google.monitoring.v3.ITimeSeries[], - protosTypes.google.monitoring.v3.IListTimeSeriesRequest | null, - protosTypes.google.monitoring.v3.IListTimeSeriesResponse + callback?: PaginationCallback< + protos.google.monitoring.v3.IListTimeSeriesRequest, + protos.google.monitoring.v3.IListTimeSeriesResponse | null | undefined, + protos.google.monitoring.v3.ITimeSeries > ): Promise< [ - protosTypes.google.monitoring.v3.ITimeSeries[], - protosTypes.google.monitoring.v3.IListTimeSeriesRequest | null, - protosTypes.google.monitoring.v3.IListTimeSeriesResponse + protos.google.monitoring.v3.ITimeSeries[], + protos.google.monitoring.v3.IListTimeSeriesRequest | null, + protos.google.monitoring.v3.IListTimeSeriesResponse ] > | void { request = request || {}; @@ -1292,7 +1490,7 @@ export class MetricServiceClient { name: request.name || '', }); this.initialize(); - return this._innerApiCalls.listTimeSeries(request, options, callback); + return this.innerApiCalls.listTimeSeries(request, options, callback); } /** @@ -1353,7 +1551,7 @@ export class MetricServiceClient { * An object stream which emits an object representing [TimeSeries]{@link google.monitoring.v3.TimeSeries} on 'data' event. */ listTimeSeriesStream( - request?: protosTypes.google.monitoring.v3.IListTimeSeriesRequest, + request?: protos.google.monitoring.v3.IListTimeSeriesRequest, options?: gax.CallOptions ): Transform { request = request || {}; @@ -1367,12 +1565,84 @@ export class MetricServiceClient { }); const callSettings = new gax.CallSettings(options); this.initialize(); - return this._descriptors.page.listTimeSeries.createStream( - this._innerApiCalls.listTimeSeries as gax.GaxCall, + return this.descriptors.page.listTimeSeries.createStream( + this.innerApiCalls.listTimeSeries as gax.GaxCall, request, callSettings ); } + + /** + * Equivalent to {@link listTimeSeries}, 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.name + * Required. The project on which to execute the request. The format is: + * + * projects/[PROJECT_ID_OR_NUMBER] + * @param {string} request.filter + * Required. A [monitoring filter](https://cloud.google.com/monitoring/api/v3/filters) + * that specifies which time series should be returned. The filter must + * specify a single metric type, and can additionally specify metric labels + * and other information. For example: + * + * metric.type = "compute.googleapis.com/instance/cpu/usage_time" AND + * metric.labels.instance_name = "my-instance-name" + * @param {google.monitoring.v3.TimeInterval} request.interval + * Required. The time interval for which results should be returned. Only time series + * that contain data points in the specified interval are included + * in the response. + * @param {google.monitoring.v3.Aggregation} request.aggregation + * Specifies the alignment of data points in individual time series as + * well as how to combine the retrieved time series across specified labels. + * + * By default (if no `aggregation` is explicitly specified), the raw time + * series data is returned. + * @param {string} request.orderBy + * Unsupported: must be left blank. The points in each time series are + * currently returned in reverse time order (most recent to oldest). + * @param {google.monitoring.v3.ListTimeSeriesRequest.TimeSeriesView} request.view + * Required. Specifies which information is returned about the time series. + * @param {number} request.pageSize + * A positive number that is the maximum number of results to return. If + * `page_size` is empty or more than 100,000 results, the effective + * `page_size` is 100,000 results. If `view` is set to `FULL`, this is the + * maximum number of `Points` returned. If `view` is set to `HEADERS`, this is + * the maximum number of `TimeSeries` returned. + * @param {string} request.pageToken + * If this field is not empty then it must contain the `nextPageToken` value + * returned by a previous call to this method. Using this field causes the + * method to return additional results from the previous method call. + * @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. + */ + listTimeSeriesAsync( + request?: protos.google.monitoring.v3.IListTimeSeriesRequest, + options?: gax.CallOptions + ): AsyncIterable { + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + name: request.name || '', + }); + options = options || {}; + const callSettings = new gax.CallSettings(options); + this.initialize(); + return this.descriptors.page.listTimeSeries.asyncIterate( + this.innerApiCalls['listTimeSeries'] as GaxCall, + (request as unknown) as RequestType, + callSettings + ) as AsyncIterable; + } // -------------------- // -- Path templates -- // -------------------- @@ -1385,8 +1655,8 @@ export class MetricServiceClient { * @returns {string} Resource name string. */ folderAlertPolicyPath(folder: string, alertPolicy: string) { - return this._pathTemplates.folderAlertPolicyPathTemplate.render({ - folder, + return this.pathTemplates.folderAlertPolicyPathTemplate.render({ + folder: folder, alert_policy: alertPolicy, }); } @@ -1399,7 +1669,7 @@ export class MetricServiceClient { * @returns {string} A string representing the folder. */ matchFolderFromFolderAlertPolicyName(folderAlertPolicyName: string) { - return this._pathTemplates.folderAlertPolicyPathTemplate.match( + return this.pathTemplates.folderAlertPolicyPathTemplate.match( folderAlertPolicyName ).folder; } @@ -1412,7 +1682,7 @@ export class MetricServiceClient { * @returns {string} A string representing the alert_policy. */ matchAlertPolicyFromFolderAlertPolicyName(folderAlertPolicyName: string) { - return this._pathTemplates.folderAlertPolicyPathTemplate.match( + return this.pathTemplates.folderAlertPolicyPathTemplate.match( folderAlertPolicyName ).alert_policy; } @@ -1430,10 +1700,10 @@ export class MetricServiceClient { alertPolicy: string, condition: string ) { - return this._pathTemplates.folderAlertPolicyConditionPathTemplate.render({ - folder, + return this.pathTemplates.folderAlertPolicyConditionPathTemplate.render({ + folder: folder, alert_policy: alertPolicy, - condition, + condition: condition, }); } @@ -1447,7 +1717,7 @@ export class MetricServiceClient { matchFolderFromFolderAlertPolicyConditionName( folderAlertPolicyConditionName: string ) { - return this._pathTemplates.folderAlertPolicyConditionPathTemplate.match( + return this.pathTemplates.folderAlertPolicyConditionPathTemplate.match( folderAlertPolicyConditionName ).folder; } @@ -1462,7 +1732,7 @@ export class MetricServiceClient { matchAlertPolicyFromFolderAlertPolicyConditionName( folderAlertPolicyConditionName: string ) { - return this._pathTemplates.folderAlertPolicyConditionPathTemplate.match( + return this.pathTemplates.folderAlertPolicyConditionPathTemplate.match( folderAlertPolicyConditionName ).alert_policy; } @@ -1477,7 +1747,7 @@ export class MetricServiceClient { matchConditionFromFolderAlertPolicyConditionName( folderAlertPolicyConditionName: string ) { - return this._pathTemplates.folderAlertPolicyConditionPathTemplate.match( + return this.pathTemplates.folderAlertPolicyConditionPathTemplate.match( folderAlertPolicyConditionName ).condition; } @@ -1490,8 +1760,8 @@ export class MetricServiceClient { * @returns {string} Resource name string. */ folderChannelDescriptorPath(folder: string, channelDescriptor: string) { - return this._pathTemplates.folderChannelDescriptorPathTemplate.render({ - folder, + return this.pathTemplates.folderChannelDescriptorPathTemplate.render({ + folder: folder, channel_descriptor: channelDescriptor, }); } @@ -1506,7 +1776,7 @@ export class MetricServiceClient { matchFolderFromFolderChannelDescriptorName( folderChannelDescriptorName: string ) { - return this._pathTemplates.folderChannelDescriptorPathTemplate.match( + return this.pathTemplates.folderChannelDescriptorPathTemplate.match( folderChannelDescriptorName ).folder; } @@ -1521,7 +1791,7 @@ export class MetricServiceClient { matchChannelDescriptorFromFolderChannelDescriptorName( folderChannelDescriptorName: string ) { - return this._pathTemplates.folderChannelDescriptorPathTemplate.match( + return this.pathTemplates.folderChannelDescriptorPathTemplate.match( folderChannelDescriptorName ).channel_descriptor; } @@ -1534,9 +1804,9 @@ export class MetricServiceClient { * @returns {string} Resource name string. */ folderGroupPath(folder: string, group: string) { - return this._pathTemplates.folderGroupPathTemplate.render({ - folder, - group, + return this.pathTemplates.folderGroupPathTemplate.render({ + folder: folder, + group: group, }); } @@ -1548,7 +1818,7 @@ export class MetricServiceClient { * @returns {string} A string representing the folder. */ matchFolderFromFolderGroupName(folderGroupName: string) { - return this._pathTemplates.folderGroupPathTemplate.match(folderGroupName) + return this.pathTemplates.folderGroupPathTemplate.match(folderGroupName) .folder; } @@ -1560,7 +1830,7 @@ export class MetricServiceClient { * @returns {string} A string representing the group. */ matchGroupFromFolderGroupName(folderGroupName: string) { - return this._pathTemplates.folderGroupPathTemplate.match(folderGroupName) + return this.pathTemplates.folderGroupPathTemplate.match(folderGroupName) .group; } @@ -1572,8 +1842,8 @@ export class MetricServiceClient { * @returns {string} Resource name string. */ folderMetricDescriptorPath(folder: string, metricDescriptor: string) { - return this._pathTemplates.folderMetricDescriptorPathTemplate.render({ - folder, + return this.pathTemplates.folderMetricDescriptorPathTemplate.render({ + folder: folder, metric_descriptor: metricDescriptor, }); } @@ -1588,7 +1858,7 @@ export class MetricServiceClient { matchFolderFromFolderMetricDescriptorName( folderMetricDescriptorName: string ) { - return this._pathTemplates.folderMetricDescriptorPathTemplate.match( + return this.pathTemplates.folderMetricDescriptorPathTemplate.match( folderMetricDescriptorName ).folder; } @@ -1603,7 +1873,7 @@ export class MetricServiceClient { matchMetricDescriptorFromFolderMetricDescriptorName( folderMetricDescriptorName: string ) { - return this._pathTemplates.folderMetricDescriptorPathTemplate.match( + return this.pathTemplates.folderMetricDescriptorPathTemplate.match( folderMetricDescriptorName ).metric_descriptor; } @@ -1619,9 +1889,9 @@ export class MetricServiceClient { folder: string, monitoredResourceDescriptor: string ) { - return this._pathTemplates.folderMonitoredResourceDescriptorPathTemplate.render( + return this.pathTemplates.folderMonitoredResourceDescriptorPathTemplate.render( { - folder, + folder: folder, monitored_resource_descriptor: monitoredResourceDescriptor, } ); @@ -1637,7 +1907,7 @@ export class MetricServiceClient { matchFolderFromFolderMonitoredResourceDescriptorName( folderMonitoredResourceDescriptorName: string ) { - return this._pathTemplates.folderMonitoredResourceDescriptorPathTemplate.match( + return this.pathTemplates.folderMonitoredResourceDescriptorPathTemplate.match( folderMonitoredResourceDescriptorName ).folder; } @@ -1652,7 +1922,7 @@ export class MetricServiceClient { matchMonitoredResourceDescriptorFromFolderMonitoredResourceDescriptorName( folderMonitoredResourceDescriptorName: string ) { - return this._pathTemplates.folderMonitoredResourceDescriptorPathTemplate.match( + return this.pathTemplates.folderMonitoredResourceDescriptorPathTemplate.match( folderMonitoredResourceDescriptorName ).monitored_resource_descriptor; } @@ -1665,8 +1935,8 @@ export class MetricServiceClient { * @returns {string} Resource name string. */ folderNotificationChannelPath(folder: string, notificationChannel: string) { - return this._pathTemplates.folderNotificationChannelPathTemplate.render({ - folder, + return this.pathTemplates.folderNotificationChannelPathTemplate.render({ + folder: folder, notification_channel: notificationChannel, }); } @@ -1681,7 +1951,7 @@ export class MetricServiceClient { matchFolderFromFolderNotificationChannelName( folderNotificationChannelName: string ) { - return this._pathTemplates.folderNotificationChannelPathTemplate.match( + return this.pathTemplates.folderNotificationChannelPathTemplate.match( folderNotificationChannelName ).folder; } @@ -1696,7 +1966,7 @@ export class MetricServiceClient { matchNotificationChannelFromFolderNotificationChannelName( folderNotificationChannelName: string ) { - return this._pathTemplates.folderNotificationChannelPathTemplate.match( + return this.pathTemplates.folderNotificationChannelPathTemplate.match( folderNotificationChannelName ).notification_channel; } @@ -1709,9 +1979,9 @@ export class MetricServiceClient { * @returns {string} Resource name string. */ folderServicePath(folder: string, service: string) { - return this._pathTemplates.folderServicePathTemplate.render({ - folder, - service, + return this.pathTemplates.folderServicePathTemplate.render({ + folder: folder, + service: service, }); } @@ -1723,9 +1993,8 @@ export class MetricServiceClient { * @returns {string} A string representing the folder. */ matchFolderFromFolderServiceName(folderServiceName: string) { - return this._pathTemplates.folderServicePathTemplate.match( - folderServiceName - ).folder; + return this.pathTemplates.folderServicePathTemplate.match(folderServiceName) + .folder; } /** @@ -1736,9 +2005,8 @@ export class MetricServiceClient { * @returns {string} A string representing the service. */ matchServiceFromFolderServiceName(folderServiceName: string) { - return this._pathTemplates.folderServicePathTemplate.match( - folderServiceName - ).service; + return this.pathTemplates.folderServicePathTemplate.match(folderServiceName) + .service; } /** @@ -1754,10 +2022,10 @@ export class MetricServiceClient { service: string, serviceLevelObjective: string ) { - return this._pathTemplates.folderServiceServiceLevelObjectivePathTemplate.render( + return this.pathTemplates.folderServiceServiceLevelObjectivePathTemplate.render( { - folder, - service, + folder: folder, + service: service, service_level_objective: serviceLevelObjective, } ); @@ -1773,7 +2041,7 @@ export class MetricServiceClient { matchFolderFromFolderServiceServiceLevelObjectiveName( folderServiceServiceLevelObjectiveName: string ) { - return this._pathTemplates.folderServiceServiceLevelObjectivePathTemplate.match( + return this.pathTemplates.folderServiceServiceLevelObjectivePathTemplate.match( folderServiceServiceLevelObjectiveName ).folder; } @@ -1788,7 +2056,7 @@ export class MetricServiceClient { matchServiceFromFolderServiceServiceLevelObjectiveName( folderServiceServiceLevelObjectiveName: string ) { - return this._pathTemplates.folderServiceServiceLevelObjectivePathTemplate.match( + return this.pathTemplates.folderServiceServiceLevelObjectivePathTemplate.match( folderServiceServiceLevelObjectiveName ).service; } @@ -1803,7 +2071,7 @@ export class MetricServiceClient { matchServiceLevelObjectiveFromFolderServiceServiceLevelObjectiveName( folderServiceServiceLevelObjectiveName: string ) { - return this._pathTemplates.folderServiceServiceLevelObjectivePathTemplate.match( + return this.pathTemplates.folderServiceServiceLevelObjectivePathTemplate.match( folderServiceServiceLevelObjectiveName ).service_level_objective; } @@ -1816,8 +2084,8 @@ export class MetricServiceClient { * @returns {string} Resource name string. */ folderUptimeCheckConfigPath(folder: string, uptimeCheckConfig: string) { - return this._pathTemplates.folderUptimeCheckConfigPathTemplate.render({ - folder, + return this.pathTemplates.folderUptimeCheckConfigPathTemplate.render({ + folder: folder, uptime_check_config: uptimeCheckConfig, }); } @@ -1832,7 +2100,7 @@ export class MetricServiceClient { matchFolderFromFolderUptimeCheckConfigName( folderUptimeCheckConfigName: string ) { - return this._pathTemplates.folderUptimeCheckConfigPathTemplate.match( + return this.pathTemplates.folderUptimeCheckConfigPathTemplate.match( folderUptimeCheckConfigName ).folder; } @@ -1847,7 +2115,7 @@ export class MetricServiceClient { matchUptimeCheckConfigFromFolderUptimeCheckConfigName( folderUptimeCheckConfigName: string ) { - return this._pathTemplates.folderUptimeCheckConfigPathTemplate.match( + return this.pathTemplates.folderUptimeCheckConfigPathTemplate.match( folderUptimeCheckConfigName ).uptime_check_config; } @@ -1860,8 +2128,8 @@ export class MetricServiceClient { * @returns {string} Resource name string. */ organizationAlertPolicyPath(organization: string, alertPolicy: string) { - return this._pathTemplates.organizationAlertPolicyPathTemplate.render({ - organization, + return this.pathTemplates.organizationAlertPolicyPathTemplate.render({ + organization: organization, alert_policy: alertPolicy, }); } @@ -1876,7 +2144,7 @@ export class MetricServiceClient { matchOrganizationFromOrganizationAlertPolicyName( organizationAlertPolicyName: string ) { - return this._pathTemplates.organizationAlertPolicyPathTemplate.match( + return this.pathTemplates.organizationAlertPolicyPathTemplate.match( organizationAlertPolicyName ).organization; } @@ -1891,7 +2159,7 @@ export class MetricServiceClient { matchAlertPolicyFromOrganizationAlertPolicyName( organizationAlertPolicyName: string ) { - return this._pathTemplates.organizationAlertPolicyPathTemplate.match( + return this.pathTemplates.organizationAlertPolicyPathTemplate.match( organizationAlertPolicyName ).alert_policy; } @@ -1909,11 +2177,11 @@ export class MetricServiceClient { alertPolicy: string, condition: string ) { - return this._pathTemplates.organizationAlertPolicyConditionPathTemplate.render( + return this.pathTemplates.organizationAlertPolicyConditionPathTemplate.render( { - organization, + organization: organization, alert_policy: alertPolicy, - condition, + condition: condition, } ); } @@ -1928,7 +2196,7 @@ export class MetricServiceClient { matchOrganizationFromOrganizationAlertPolicyConditionName( organizationAlertPolicyConditionName: string ) { - return this._pathTemplates.organizationAlertPolicyConditionPathTemplate.match( + return this.pathTemplates.organizationAlertPolicyConditionPathTemplate.match( organizationAlertPolicyConditionName ).organization; } @@ -1943,7 +2211,7 @@ export class MetricServiceClient { matchAlertPolicyFromOrganizationAlertPolicyConditionName( organizationAlertPolicyConditionName: string ) { - return this._pathTemplates.organizationAlertPolicyConditionPathTemplate.match( + return this.pathTemplates.organizationAlertPolicyConditionPathTemplate.match( organizationAlertPolicyConditionName ).alert_policy; } @@ -1958,7 +2226,7 @@ export class MetricServiceClient { matchConditionFromOrganizationAlertPolicyConditionName( organizationAlertPolicyConditionName: string ) { - return this._pathTemplates.organizationAlertPolicyConditionPathTemplate.match( + return this.pathTemplates.organizationAlertPolicyConditionPathTemplate.match( organizationAlertPolicyConditionName ).condition; } @@ -1974,12 +2242,10 @@ export class MetricServiceClient { organization: string, channelDescriptor: string ) { - return this._pathTemplates.organizationChannelDescriptorPathTemplate.render( - { - organization, - channel_descriptor: channelDescriptor, - } - ); + return this.pathTemplates.organizationChannelDescriptorPathTemplate.render({ + organization: organization, + channel_descriptor: channelDescriptor, + }); } /** @@ -1992,7 +2258,7 @@ export class MetricServiceClient { matchOrganizationFromOrganizationChannelDescriptorName( organizationChannelDescriptorName: string ) { - return this._pathTemplates.organizationChannelDescriptorPathTemplate.match( + return this.pathTemplates.organizationChannelDescriptorPathTemplate.match( organizationChannelDescriptorName ).organization; } @@ -2007,7 +2273,7 @@ export class MetricServiceClient { matchChannelDescriptorFromOrganizationChannelDescriptorName( organizationChannelDescriptorName: string ) { - return this._pathTemplates.organizationChannelDescriptorPathTemplate.match( + return this.pathTemplates.organizationChannelDescriptorPathTemplate.match( organizationChannelDescriptorName ).channel_descriptor; } @@ -2020,9 +2286,9 @@ export class MetricServiceClient { * @returns {string} Resource name string. */ organizationGroupPath(organization: string, group: string) { - return this._pathTemplates.organizationGroupPathTemplate.render({ - organization, - group, + return this.pathTemplates.organizationGroupPathTemplate.render({ + organization: organization, + group: group, }); } @@ -2034,7 +2300,7 @@ export class MetricServiceClient { * @returns {string} A string representing the organization. */ matchOrganizationFromOrganizationGroupName(organizationGroupName: string) { - return this._pathTemplates.organizationGroupPathTemplate.match( + return this.pathTemplates.organizationGroupPathTemplate.match( organizationGroupName ).organization; } @@ -2047,7 +2313,7 @@ export class MetricServiceClient { * @returns {string} A string representing the group. */ matchGroupFromOrganizationGroupName(organizationGroupName: string) { - return this._pathTemplates.organizationGroupPathTemplate.match( + return this.pathTemplates.organizationGroupPathTemplate.match( organizationGroupName ).group; } @@ -2063,8 +2329,8 @@ export class MetricServiceClient { organization: string, metricDescriptor: string ) { - return this._pathTemplates.organizationMetricDescriptorPathTemplate.render({ - organization, + return this.pathTemplates.organizationMetricDescriptorPathTemplate.render({ + organization: organization, metric_descriptor: metricDescriptor, }); } @@ -2079,7 +2345,7 @@ export class MetricServiceClient { matchOrganizationFromOrganizationMetricDescriptorName( organizationMetricDescriptorName: string ) { - return this._pathTemplates.organizationMetricDescriptorPathTemplate.match( + return this.pathTemplates.organizationMetricDescriptorPathTemplate.match( organizationMetricDescriptorName ).organization; } @@ -2094,7 +2360,7 @@ export class MetricServiceClient { matchMetricDescriptorFromOrganizationMetricDescriptorName( organizationMetricDescriptorName: string ) { - return this._pathTemplates.organizationMetricDescriptorPathTemplate.match( + return this.pathTemplates.organizationMetricDescriptorPathTemplate.match( organizationMetricDescriptorName ).metric_descriptor; } @@ -2110,9 +2376,9 @@ export class MetricServiceClient { organization: string, monitoredResourceDescriptor: string ) { - return this._pathTemplates.organizationMonitoredResourceDescriptorPathTemplate.render( + return this.pathTemplates.organizationMonitoredResourceDescriptorPathTemplate.render( { - organization, + organization: organization, monitored_resource_descriptor: monitoredResourceDescriptor, } ); @@ -2128,7 +2394,7 @@ export class MetricServiceClient { matchOrganizationFromOrganizationMonitoredResourceDescriptorName( organizationMonitoredResourceDescriptorName: string ) { - return this._pathTemplates.organizationMonitoredResourceDescriptorPathTemplate.match( + return this.pathTemplates.organizationMonitoredResourceDescriptorPathTemplate.match( organizationMonitoredResourceDescriptorName ).organization; } @@ -2143,7 +2409,7 @@ export class MetricServiceClient { matchMonitoredResourceDescriptorFromOrganizationMonitoredResourceDescriptorName( organizationMonitoredResourceDescriptorName: string ) { - return this._pathTemplates.organizationMonitoredResourceDescriptorPathTemplate.match( + return this.pathTemplates.organizationMonitoredResourceDescriptorPathTemplate.match( organizationMonitoredResourceDescriptorName ).monitored_resource_descriptor; } @@ -2159,9 +2425,9 @@ export class MetricServiceClient { organization: string, notificationChannel: string ) { - return this._pathTemplates.organizationNotificationChannelPathTemplate.render( + return this.pathTemplates.organizationNotificationChannelPathTemplate.render( { - organization, + organization: organization, notification_channel: notificationChannel, } ); @@ -2177,7 +2443,7 @@ export class MetricServiceClient { matchOrganizationFromOrganizationNotificationChannelName( organizationNotificationChannelName: string ) { - return this._pathTemplates.organizationNotificationChannelPathTemplate.match( + return this.pathTemplates.organizationNotificationChannelPathTemplate.match( organizationNotificationChannelName ).organization; } @@ -2192,7 +2458,7 @@ export class MetricServiceClient { matchNotificationChannelFromOrganizationNotificationChannelName( organizationNotificationChannelName: string ) { - return this._pathTemplates.organizationNotificationChannelPathTemplate.match( + return this.pathTemplates.organizationNotificationChannelPathTemplate.match( organizationNotificationChannelName ).notification_channel; } @@ -2205,9 +2471,9 @@ export class MetricServiceClient { * @returns {string} Resource name string. */ organizationServicePath(organization: string, service: string) { - return this._pathTemplates.organizationServicePathTemplate.render({ - organization, - service, + return this.pathTemplates.organizationServicePathTemplate.render({ + organization: organization, + service: service, }); } @@ -2221,7 +2487,7 @@ export class MetricServiceClient { matchOrganizationFromOrganizationServiceName( organizationServiceName: string ) { - return this._pathTemplates.organizationServicePathTemplate.match( + return this.pathTemplates.organizationServicePathTemplate.match( organizationServiceName ).organization; } @@ -2234,7 +2500,7 @@ export class MetricServiceClient { * @returns {string} A string representing the service. */ matchServiceFromOrganizationServiceName(organizationServiceName: string) { - return this._pathTemplates.organizationServicePathTemplate.match( + return this.pathTemplates.organizationServicePathTemplate.match( organizationServiceName ).service; } @@ -2252,10 +2518,10 @@ export class MetricServiceClient { service: string, serviceLevelObjective: string ) { - return this._pathTemplates.organizationServiceServiceLevelObjectivePathTemplate.render( + return this.pathTemplates.organizationServiceServiceLevelObjectivePathTemplate.render( { - organization, - service, + organization: organization, + service: service, service_level_objective: serviceLevelObjective, } ); @@ -2271,7 +2537,7 @@ export class MetricServiceClient { matchOrganizationFromOrganizationServiceServiceLevelObjectiveName( organizationServiceServiceLevelObjectiveName: string ) { - return this._pathTemplates.organizationServiceServiceLevelObjectivePathTemplate.match( + return this.pathTemplates.organizationServiceServiceLevelObjectivePathTemplate.match( organizationServiceServiceLevelObjectiveName ).organization; } @@ -2286,7 +2552,7 @@ export class MetricServiceClient { matchServiceFromOrganizationServiceServiceLevelObjectiveName( organizationServiceServiceLevelObjectiveName: string ) { - return this._pathTemplates.organizationServiceServiceLevelObjectivePathTemplate.match( + return this.pathTemplates.organizationServiceServiceLevelObjectivePathTemplate.match( organizationServiceServiceLevelObjectiveName ).service; } @@ -2301,7 +2567,7 @@ export class MetricServiceClient { matchServiceLevelObjectiveFromOrganizationServiceServiceLevelObjectiveName( organizationServiceServiceLevelObjectiveName: string ) { - return this._pathTemplates.organizationServiceServiceLevelObjectivePathTemplate.match( + return this.pathTemplates.organizationServiceServiceLevelObjectivePathTemplate.match( organizationServiceServiceLevelObjectiveName ).service_level_objective; } @@ -2317,12 +2583,10 @@ export class MetricServiceClient { organization: string, uptimeCheckConfig: string ) { - return this._pathTemplates.organizationUptimeCheckConfigPathTemplate.render( - { - organization, - uptime_check_config: uptimeCheckConfig, - } - ); + return this.pathTemplates.organizationUptimeCheckConfigPathTemplate.render({ + organization: organization, + uptime_check_config: uptimeCheckConfig, + }); } /** @@ -2335,7 +2599,7 @@ export class MetricServiceClient { matchOrganizationFromOrganizationUptimeCheckConfigName( organizationUptimeCheckConfigName: string ) { - return this._pathTemplates.organizationUptimeCheckConfigPathTemplate.match( + return this.pathTemplates.organizationUptimeCheckConfigPathTemplate.match( organizationUptimeCheckConfigName ).organization; } @@ -2350,7 +2614,7 @@ export class MetricServiceClient { matchUptimeCheckConfigFromOrganizationUptimeCheckConfigName( organizationUptimeCheckConfigName: string ) { - return this._pathTemplates.organizationUptimeCheckConfigPathTemplate.match( + return this.pathTemplates.organizationUptimeCheckConfigPathTemplate.match( organizationUptimeCheckConfigName ).uptime_check_config; } @@ -2362,8 +2626,8 @@ export class MetricServiceClient { * @returns {string} Resource name string. */ projectPath(project: string) { - return this._pathTemplates.projectPathTemplate.render({ - project, + return this.pathTemplates.projectPathTemplate.render({ + project: project, }); } @@ -2375,7 +2639,7 @@ export class MetricServiceClient { * @returns {string} A string representing the project. */ matchProjectFromProjectName(projectName: string) { - return this._pathTemplates.projectPathTemplate.match(projectName).project; + return this.pathTemplates.projectPathTemplate.match(projectName).project; } /** @@ -2386,8 +2650,8 @@ export class MetricServiceClient { * @returns {string} Resource name string. */ projectAlertPolicyPath(project: string, alertPolicy: string) { - return this._pathTemplates.projectAlertPolicyPathTemplate.render({ - project, + return this.pathTemplates.projectAlertPolicyPathTemplate.render({ + project: project, alert_policy: alertPolicy, }); } @@ -2400,7 +2664,7 @@ export class MetricServiceClient { * @returns {string} A string representing the project. */ matchProjectFromProjectAlertPolicyName(projectAlertPolicyName: string) { - return this._pathTemplates.projectAlertPolicyPathTemplate.match( + return this.pathTemplates.projectAlertPolicyPathTemplate.match( projectAlertPolicyName ).project; } @@ -2413,7 +2677,7 @@ export class MetricServiceClient { * @returns {string} A string representing the alert_policy. */ matchAlertPolicyFromProjectAlertPolicyName(projectAlertPolicyName: string) { - return this._pathTemplates.projectAlertPolicyPathTemplate.match( + return this.pathTemplates.projectAlertPolicyPathTemplate.match( projectAlertPolicyName ).alert_policy; } @@ -2431,10 +2695,10 @@ export class MetricServiceClient { alertPolicy: string, condition: string ) { - return this._pathTemplates.projectAlertPolicyConditionPathTemplate.render({ - project, + return this.pathTemplates.projectAlertPolicyConditionPathTemplate.render({ + project: project, alert_policy: alertPolicy, - condition, + condition: condition, }); } @@ -2448,7 +2712,7 @@ export class MetricServiceClient { matchProjectFromProjectAlertPolicyConditionName( projectAlertPolicyConditionName: string ) { - return this._pathTemplates.projectAlertPolicyConditionPathTemplate.match( + return this.pathTemplates.projectAlertPolicyConditionPathTemplate.match( projectAlertPolicyConditionName ).project; } @@ -2463,7 +2727,7 @@ export class MetricServiceClient { matchAlertPolicyFromProjectAlertPolicyConditionName( projectAlertPolicyConditionName: string ) { - return this._pathTemplates.projectAlertPolicyConditionPathTemplate.match( + return this.pathTemplates.projectAlertPolicyConditionPathTemplate.match( projectAlertPolicyConditionName ).alert_policy; } @@ -2478,7 +2742,7 @@ export class MetricServiceClient { matchConditionFromProjectAlertPolicyConditionName( projectAlertPolicyConditionName: string ) { - return this._pathTemplates.projectAlertPolicyConditionPathTemplate.match( + return this.pathTemplates.projectAlertPolicyConditionPathTemplate.match( projectAlertPolicyConditionName ).condition; } @@ -2491,8 +2755,8 @@ export class MetricServiceClient { * @returns {string} Resource name string. */ projectChannelDescriptorPath(project: string, channelDescriptor: string) { - return this._pathTemplates.projectChannelDescriptorPathTemplate.render({ - project, + return this.pathTemplates.projectChannelDescriptorPathTemplate.render({ + project: project, channel_descriptor: channelDescriptor, }); } @@ -2507,7 +2771,7 @@ export class MetricServiceClient { matchProjectFromProjectChannelDescriptorName( projectChannelDescriptorName: string ) { - return this._pathTemplates.projectChannelDescriptorPathTemplate.match( + return this.pathTemplates.projectChannelDescriptorPathTemplate.match( projectChannelDescriptorName ).project; } @@ -2522,7 +2786,7 @@ export class MetricServiceClient { matchChannelDescriptorFromProjectChannelDescriptorName( projectChannelDescriptorName: string ) { - return this._pathTemplates.projectChannelDescriptorPathTemplate.match( + return this.pathTemplates.projectChannelDescriptorPathTemplate.match( projectChannelDescriptorName ).channel_descriptor; } @@ -2535,9 +2799,9 @@ export class MetricServiceClient { * @returns {string} Resource name string. */ projectGroupPath(project: string, group: string) { - return this._pathTemplates.projectGroupPathTemplate.render({ - project, - group, + return this.pathTemplates.projectGroupPathTemplate.render({ + project: project, + group: group, }); } @@ -2549,7 +2813,7 @@ export class MetricServiceClient { * @returns {string} A string representing the project. */ matchProjectFromProjectGroupName(projectGroupName: string) { - return this._pathTemplates.projectGroupPathTemplate.match(projectGroupName) + return this.pathTemplates.projectGroupPathTemplate.match(projectGroupName) .project; } @@ -2561,7 +2825,7 @@ export class MetricServiceClient { * @returns {string} A string representing the group. */ matchGroupFromProjectGroupName(projectGroupName: string) { - return this._pathTemplates.projectGroupPathTemplate.match(projectGroupName) + return this.pathTemplates.projectGroupPathTemplate.match(projectGroupName) .group; } @@ -2573,8 +2837,8 @@ export class MetricServiceClient { * @returns {string} Resource name string. */ projectMetricDescriptorPath(project: string, metricDescriptor: string) { - return this._pathTemplates.projectMetricDescriptorPathTemplate.render({ - project, + return this.pathTemplates.projectMetricDescriptorPathTemplate.render({ + project: project, metric_descriptor: metricDescriptor, }); } @@ -2589,7 +2853,7 @@ export class MetricServiceClient { matchProjectFromProjectMetricDescriptorName( projectMetricDescriptorName: string ) { - return this._pathTemplates.projectMetricDescriptorPathTemplate.match( + return this.pathTemplates.projectMetricDescriptorPathTemplate.match( projectMetricDescriptorName ).project; } @@ -2604,7 +2868,7 @@ export class MetricServiceClient { matchMetricDescriptorFromProjectMetricDescriptorName( projectMetricDescriptorName: string ) { - return this._pathTemplates.projectMetricDescriptorPathTemplate.match( + return this.pathTemplates.projectMetricDescriptorPathTemplate.match( projectMetricDescriptorName ).metric_descriptor; } @@ -2620,9 +2884,9 @@ export class MetricServiceClient { project: string, monitoredResourceDescriptor: string ) { - return this._pathTemplates.projectMonitoredResourceDescriptorPathTemplate.render( + return this.pathTemplates.projectMonitoredResourceDescriptorPathTemplate.render( { - project, + project: project, monitored_resource_descriptor: monitoredResourceDescriptor, } ); @@ -2638,7 +2902,7 @@ export class MetricServiceClient { matchProjectFromProjectMonitoredResourceDescriptorName( projectMonitoredResourceDescriptorName: string ) { - return this._pathTemplates.projectMonitoredResourceDescriptorPathTemplate.match( + return this.pathTemplates.projectMonitoredResourceDescriptorPathTemplate.match( projectMonitoredResourceDescriptorName ).project; } @@ -2653,7 +2917,7 @@ export class MetricServiceClient { matchMonitoredResourceDescriptorFromProjectMonitoredResourceDescriptorName( projectMonitoredResourceDescriptorName: string ) { - return this._pathTemplates.projectMonitoredResourceDescriptorPathTemplate.match( + return this.pathTemplates.projectMonitoredResourceDescriptorPathTemplate.match( projectMonitoredResourceDescriptorName ).monitored_resource_descriptor; } @@ -2666,8 +2930,8 @@ export class MetricServiceClient { * @returns {string} Resource name string. */ projectNotificationChannelPath(project: string, notificationChannel: string) { - return this._pathTemplates.projectNotificationChannelPathTemplate.render({ - project, + return this.pathTemplates.projectNotificationChannelPathTemplate.render({ + project: project, notification_channel: notificationChannel, }); } @@ -2682,7 +2946,7 @@ export class MetricServiceClient { matchProjectFromProjectNotificationChannelName( projectNotificationChannelName: string ) { - return this._pathTemplates.projectNotificationChannelPathTemplate.match( + return this.pathTemplates.projectNotificationChannelPathTemplate.match( projectNotificationChannelName ).project; } @@ -2697,7 +2961,7 @@ export class MetricServiceClient { matchNotificationChannelFromProjectNotificationChannelName( projectNotificationChannelName: string ) { - return this._pathTemplates.projectNotificationChannelPathTemplate.match( + return this.pathTemplates.projectNotificationChannelPathTemplate.match( projectNotificationChannelName ).notification_channel; } @@ -2710,9 +2974,9 @@ export class MetricServiceClient { * @returns {string} Resource name string. */ projectServicePath(project: string, service: string) { - return this._pathTemplates.projectServicePathTemplate.render({ - project, - service, + return this.pathTemplates.projectServicePathTemplate.render({ + project: project, + service: service, }); } @@ -2724,7 +2988,7 @@ export class MetricServiceClient { * @returns {string} A string representing the project. */ matchProjectFromProjectServiceName(projectServiceName: string) { - return this._pathTemplates.projectServicePathTemplate.match( + return this.pathTemplates.projectServicePathTemplate.match( projectServiceName ).project; } @@ -2737,7 +3001,7 @@ export class MetricServiceClient { * @returns {string} A string representing the service. */ matchServiceFromProjectServiceName(projectServiceName: string) { - return this._pathTemplates.projectServicePathTemplate.match( + return this.pathTemplates.projectServicePathTemplate.match( projectServiceName ).service; } @@ -2755,10 +3019,10 @@ export class MetricServiceClient { service: string, serviceLevelObjective: string ) { - return this._pathTemplates.projectServiceServiceLevelObjectivePathTemplate.render( + return this.pathTemplates.projectServiceServiceLevelObjectivePathTemplate.render( { - project, - service, + project: project, + service: service, service_level_objective: serviceLevelObjective, } ); @@ -2774,7 +3038,7 @@ export class MetricServiceClient { matchProjectFromProjectServiceServiceLevelObjectiveName( projectServiceServiceLevelObjectiveName: string ) { - return this._pathTemplates.projectServiceServiceLevelObjectivePathTemplate.match( + return this.pathTemplates.projectServiceServiceLevelObjectivePathTemplate.match( projectServiceServiceLevelObjectiveName ).project; } @@ -2789,7 +3053,7 @@ export class MetricServiceClient { matchServiceFromProjectServiceServiceLevelObjectiveName( projectServiceServiceLevelObjectiveName: string ) { - return this._pathTemplates.projectServiceServiceLevelObjectivePathTemplate.match( + return this.pathTemplates.projectServiceServiceLevelObjectivePathTemplate.match( projectServiceServiceLevelObjectiveName ).service; } @@ -2804,7 +3068,7 @@ export class MetricServiceClient { matchServiceLevelObjectiveFromProjectServiceServiceLevelObjectiveName( projectServiceServiceLevelObjectiveName: string ) { - return this._pathTemplates.projectServiceServiceLevelObjectivePathTemplate.match( + return this.pathTemplates.projectServiceServiceLevelObjectivePathTemplate.match( projectServiceServiceLevelObjectiveName ).service_level_objective; } @@ -2817,8 +3081,8 @@ export class MetricServiceClient { * @returns {string} Resource name string. */ projectUptimeCheckConfigPath(project: string, uptimeCheckConfig: string) { - return this._pathTemplates.projectUptimeCheckConfigPathTemplate.render({ - project, + return this.pathTemplates.projectUptimeCheckConfigPathTemplate.render({ + project: project, uptime_check_config: uptimeCheckConfig, }); } @@ -2833,7 +3097,7 @@ export class MetricServiceClient { matchProjectFromProjectUptimeCheckConfigName( projectUptimeCheckConfigName: string ) { - return this._pathTemplates.projectUptimeCheckConfigPathTemplate.match( + return this.pathTemplates.projectUptimeCheckConfigPathTemplate.match( projectUptimeCheckConfigName ).project; } @@ -2848,7 +3112,7 @@ export class MetricServiceClient { matchUptimeCheckConfigFromProjectUptimeCheckConfigName( projectUptimeCheckConfigName: string ) { - return this._pathTemplates.projectUptimeCheckConfigPathTemplate.match( + return this.pathTemplates.projectUptimeCheckConfigPathTemplate.match( projectUptimeCheckConfigName ).uptime_check_config; } diff --git a/packages/google-cloud-monitoring/src/v3/notification_channel_service_client.ts b/packages/google-cloud-monitoring/src/v3/notification_channel_service_client.ts index 5716c3f5b03..52ec8bc9f21 100644 --- a/packages/google-cloud-monitoring/src/v3/notification_channel_service_client.ts +++ b/packages/google-cloud-monitoring/src/v3/notification_channel_service_client.ts @@ -1,4 +1,4 @@ -// Copyright 2019 Google LLC +// Copyright 2020 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -18,18 +18,18 @@ import * as gax from 'google-gax'; import { - APICallback, Callback, CallOptions, Descriptors, ClientOptions, PaginationCallback, - PaginationResponse, + GaxCall, } from 'google-gax'; import * as path from 'path'; import {Transform} from 'stream'; -import * as protosTypes from '../../protos/protos'; +import {RequestType} from 'google-gax/build/src/apitypes'; +import * as protos from '../../protos/protos'; import * as gapicConfig from './notification_channel_service_client_config.json'; const version = require('../../../package.json').version; @@ -41,9 +41,6 @@ const version = require('../../../package.json').version; * @memberof v3 */ export class NotificationChannelServiceClient { - private _descriptors: Descriptors = {page: {}, stream: {}, longrunning: {}}; - private _innerApiCalls: {[name: string]: Function}; - private _pathTemplates: {[name: string]: gax.PathTemplate}; private _terminated = false; private _opts: ClientOptions; private _gaxModule: typeof gax | typeof gax.fallback; @@ -51,6 +48,14 @@ export class NotificationChannelServiceClient { private _protos: {}; private _defaults: {[method: string]: gax.CallSettings}; auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + innerApiCalls: {[name: string]: Function}; + pathTemplates: {[name: string]: gax.PathTemplate}; notificationChannelServiceStub?: Promise<{[name: string]: Function}>; /** @@ -144,13 +149,16 @@ export class NotificationChannelServiceClient { 'protos.json' ); this._protos = this._gaxGrpc.loadProto( - opts.fallback ? 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 // identifiers to uniquely identify resources within the API. // Create useful helper objects for these. - this._pathTemplates = { + this.pathTemplates = { folderAlertPolicyPathTemplate: new this._gaxModule.PathTemplate( 'folders/{folder}/alertPolicies/{alert_policy}' ), @@ -231,7 +239,7 @@ export class NotificationChannelServiceClient { // Some of the methods on this service return "paged" results, // (e.g. 50 results at a time, with tokens to get subsequent // pages). Denote the keys used for pagination and results. - this._descriptors.page = { + this.descriptors.page = { listNotificationChannelDescriptors: new this._gaxModule.PageDescriptor( 'pageToken', 'nextPageToken', @@ -255,7 +263,7 @@ export class NotificationChannelServiceClient { // Set up a dictionary of "inner API calls"; the core implementation // of calling the API is handled in `google-gax`, with this code // merely providing the destination and request information. - this._innerApiCalls = {}; + this.innerApiCalls = {}; } /** @@ -282,7 +290,7 @@ export class NotificationChannelServiceClient { ? (this._protos as protobuf.Root).lookupService( 'google.monitoring.v3.NotificationChannelService' ) - : // tslint:disable-next-line no-any + : // eslint-disable-next-line @typescript-eslint/no-explicit-any (this._protos as any).google.monitoring.v3.NotificationChannelService, this._opts ) as Promise<{[method: string]: Function}>; @@ -301,14 +309,14 @@ export class NotificationChannelServiceClient { 'getNotificationChannelVerificationCode', 'verifyNotificationChannel', ]; - for (const methodName of notificationChannelServiceStubMethods) { - const innerCallPromise = this.notificationChannelServiceStub.then( + const callPromise = this.notificationChannelServiceStub.then( stub => (...args: Array<{}>) => { if (this._terminated) { return Promise.reject('The client has already been closed.'); } - return stub[methodName].apply(stub, args); + const func = stub[methodName]; + return func.apply(stub, args); }, (err: Error | null | undefined) => () => { throw err; @@ -316,20 +324,14 @@ export class NotificationChannelServiceClient { ); const apiCall = this._gaxModule.createApiCall( - innerCallPromise, + callPromise, this._defaults[methodName], - this._descriptors.page[methodName] || - this._descriptors.stream[methodName] || - this._descriptors.longrunning[methodName] + this.descriptors.page[methodName] || + this.descriptors.stream[methodName] || + this.descriptors.longrunning[methodName] ); - this._innerApiCalls[methodName] = ( - argument: {}, - callOptions?: CallOptions, - callback?: APICallback - ) => { - return apiCall(argument, callOptions, callback); - }; + this.innerApiCalls[methodName] = apiCall; } return this.notificationChannelServiceStub; @@ -390,26 +392,37 @@ export class NotificationChannelServiceClient { // -- Service calls -- // ------------------- getNotificationChannelDescriptor( - request: protosTypes.google.monitoring.v3.IGetNotificationChannelDescriptorRequest, + request: protos.google.monitoring.v3.IGetNotificationChannelDescriptorRequest, options?: gax.CallOptions ): Promise< [ - protosTypes.google.monitoring.v3.INotificationChannelDescriptor, + protos.google.monitoring.v3.INotificationChannelDescriptor, ( - | protosTypes.google.monitoring.v3.IGetNotificationChannelDescriptorRequest + | protos.google.monitoring.v3.IGetNotificationChannelDescriptorRequest | undefined ), {} | undefined ] >; getNotificationChannelDescriptor( - request: protosTypes.google.monitoring.v3.IGetNotificationChannelDescriptorRequest, + request: protos.google.monitoring.v3.IGetNotificationChannelDescriptorRequest, options: gax.CallOptions, callback: Callback< - protosTypes.google.monitoring.v3.INotificationChannelDescriptor, - | protosTypes.google.monitoring.v3.IGetNotificationChannelDescriptorRequest + protos.google.monitoring.v3.INotificationChannelDescriptor, + | protos.google.monitoring.v3.IGetNotificationChannelDescriptorRequest + | null | undefined, - {} | undefined + {} | null | undefined + > + ): void; + getNotificationChannelDescriptor( + request: protos.google.monitoring.v3.IGetNotificationChannelDescriptorRequest, + callback: Callback< + protos.google.monitoring.v3.INotificationChannelDescriptor, + | protos.google.monitoring.v3.IGetNotificationChannelDescriptorRequest + | null + | undefined, + {} | null | undefined > ): void; /** @@ -429,26 +442,28 @@ export class NotificationChannelServiceClient { * The promise has a method named "cancel" which cancels the ongoing API call. */ getNotificationChannelDescriptor( - request: protosTypes.google.monitoring.v3.IGetNotificationChannelDescriptorRequest, + request: protos.google.monitoring.v3.IGetNotificationChannelDescriptorRequest, optionsOrCallback?: | gax.CallOptions | Callback< - protosTypes.google.monitoring.v3.INotificationChannelDescriptor, - | protosTypes.google.monitoring.v3.IGetNotificationChannelDescriptorRequest + protos.google.monitoring.v3.INotificationChannelDescriptor, + | protos.google.monitoring.v3.IGetNotificationChannelDescriptorRequest + | null | undefined, - {} | undefined + {} | null | undefined >, callback?: Callback< - protosTypes.google.monitoring.v3.INotificationChannelDescriptor, - | protosTypes.google.monitoring.v3.IGetNotificationChannelDescriptorRequest + protos.google.monitoring.v3.INotificationChannelDescriptor, + | protos.google.monitoring.v3.IGetNotificationChannelDescriptorRequest + | null | undefined, - {} | undefined + {} | null | undefined > ): Promise< [ - protosTypes.google.monitoring.v3.INotificationChannelDescriptor, + protos.google.monitoring.v3.INotificationChannelDescriptor, ( - | protosTypes.google.monitoring.v3.IGetNotificationChannelDescriptorRequest + | protos.google.monitoring.v3.IGetNotificationChannelDescriptorRequest | undefined ), {} | undefined @@ -471,33 +486,41 @@ export class NotificationChannelServiceClient { name: request.name || '', }); this.initialize(); - return this._innerApiCalls.getNotificationChannelDescriptor( + return this.innerApiCalls.getNotificationChannelDescriptor( request, options, callback ); } getNotificationChannel( - request: protosTypes.google.monitoring.v3.IGetNotificationChannelRequest, + request: protos.google.monitoring.v3.IGetNotificationChannelRequest, options?: gax.CallOptions ): Promise< [ - protosTypes.google.monitoring.v3.INotificationChannel, - ( - | protosTypes.google.monitoring.v3.IGetNotificationChannelRequest - | undefined - ), + protos.google.monitoring.v3.INotificationChannel, + protos.google.monitoring.v3.IGetNotificationChannelRequest | undefined, {} | undefined ] >; getNotificationChannel( - request: protosTypes.google.monitoring.v3.IGetNotificationChannelRequest, + request: protos.google.monitoring.v3.IGetNotificationChannelRequest, options: gax.CallOptions, callback: Callback< - protosTypes.google.monitoring.v3.INotificationChannel, - | protosTypes.google.monitoring.v3.IGetNotificationChannelRequest + protos.google.monitoring.v3.INotificationChannel, + | protos.google.monitoring.v3.IGetNotificationChannelRequest + | null | undefined, - {} | undefined + {} | null | undefined + > + ): void; + getNotificationChannel( + request: protos.google.monitoring.v3.IGetNotificationChannelRequest, + callback: Callback< + protos.google.monitoring.v3.INotificationChannel, + | protos.google.monitoring.v3.IGetNotificationChannelRequest + | null + | undefined, + {} | null | undefined > ): void; /** @@ -520,28 +543,27 @@ export class NotificationChannelServiceClient { * The promise has a method named "cancel" which cancels the ongoing API call. */ getNotificationChannel( - request: protosTypes.google.monitoring.v3.IGetNotificationChannelRequest, + request: protos.google.monitoring.v3.IGetNotificationChannelRequest, optionsOrCallback?: | gax.CallOptions | Callback< - protosTypes.google.monitoring.v3.INotificationChannel, - | protosTypes.google.monitoring.v3.IGetNotificationChannelRequest + protos.google.monitoring.v3.INotificationChannel, + | protos.google.monitoring.v3.IGetNotificationChannelRequest + | null | undefined, - {} | undefined + {} | null | undefined >, callback?: Callback< - protosTypes.google.monitoring.v3.INotificationChannel, - | protosTypes.google.monitoring.v3.IGetNotificationChannelRequest + protos.google.monitoring.v3.INotificationChannel, + | protos.google.monitoring.v3.IGetNotificationChannelRequest + | null | undefined, - {} | undefined + {} | null | undefined > ): Promise< [ - protosTypes.google.monitoring.v3.INotificationChannel, - ( - | protosTypes.google.monitoring.v3.IGetNotificationChannelRequest - | undefined - ), + protos.google.monitoring.v3.INotificationChannel, + protos.google.monitoring.v3.IGetNotificationChannelRequest | undefined, {} | undefined ] > | void { @@ -562,33 +584,41 @@ export class NotificationChannelServiceClient { name: request.name || '', }); this.initialize(); - return this._innerApiCalls.getNotificationChannel( + return this.innerApiCalls.getNotificationChannel( request, options, callback ); } createNotificationChannel( - request: protosTypes.google.monitoring.v3.ICreateNotificationChannelRequest, + request: protos.google.monitoring.v3.ICreateNotificationChannelRequest, options?: gax.CallOptions ): Promise< [ - protosTypes.google.monitoring.v3.INotificationChannel, - ( - | protosTypes.google.monitoring.v3.ICreateNotificationChannelRequest - | undefined - ), + protos.google.monitoring.v3.INotificationChannel, + protos.google.monitoring.v3.ICreateNotificationChannelRequest | undefined, {} | undefined ] >; createNotificationChannel( - request: protosTypes.google.monitoring.v3.ICreateNotificationChannelRequest, + request: protos.google.monitoring.v3.ICreateNotificationChannelRequest, options: gax.CallOptions, callback: Callback< - protosTypes.google.monitoring.v3.INotificationChannel, - | protosTypes.google.monitoring.v3.ICreateNotificationChannelRequest + protos.google.monitoring.v3.INotificationChannel, + | protos.google.monitoring.v3.ICreateNotificationChannelRequest + | null | undefined, - {} | undefined + {} | null | undefined + > + ): void; + createNotificationChannel( + request: protos.google.monitoring.v3.ICreateNotificationChannelRequest, + callback: Callback< + protos.google.monitoring.v3.INotificationChannel, + | protos.google.monitoring.v3.ICreateNotificationChannelRequest + | null + | undefined, + {} | null | undefined > ): void; /** @@ -615,28 +645,27 @@ export class NotificationChannelServiceClient { * The promise has a method named "cancel" which cancels the ongoing API call. */ createNotificationChannel( - request: protosTypes.google.monitoring.v3.ICreateNotificationChannelRequest, + request: protos.google.monitoring.v3.ICreateNotificationChannelRequest, optionsOrCallback?: | gax.CallOptions | Callback< - protosTypes.google.monitoring.v3.INotificationChannel, - | protosTypes.google.monitoring.v3.ICreateNotificationChannelRequest + protos.google.monitoring.v3.INotificationChannel, + | protos.google.monitoring.v3.ICreateNotificationChannelRequest + | null | undefined, - {} | undefined + {} | null | undefined >, callback?: Callback< - protosTypes.google.monitoring.v3.INotificationChannel, - | protosTypes.google.monitoring.v3.ICreateNotificationChannelRequest + protos.google.monitoring.v3.INotificationChannel, + | protos.google.monitoring.v3.ICreateNotificationChannelRequest + | null | undefined, - {} | undefined + {} | null | undefined > ): Promise< [ - protosTypes.google.monitoring.v3.INotificationChannel, - ( - | protosTypes.google.monitoring.v3.ICreateNotificationChannelRequest - | undefined - ), + protos.google.monitoring.v3.INotificationChannel, + protos.google.monitoring.v3.ICreateNotificationChannelRequest | undefined, {} | undefined ] > | void { @@ -657,33 +686,41 @@ export class NotificationChannelServiceClient { name: request.name || '', }); this.initialize(); - return this._innerApiCalls.createNotificationChannel( + return this.innerApiCalls.createNotificationChannel( request, options, callback ); } updateNotificationChannel( - request: protosTypes.google.monitoring.v3.IUpdateNotificationChannelRequest, + request: protos.google.monitoring.v3.IUpdateNotificationChannelRequest, options?: gax.CallOptions ): Promise< [ - protosTypes.google.monitoring.v3.INotificationChannel, - ( - | protosTypes.google.monitoring.v3.IUpdateNotificationChannelRequest - | undefined - ), + protos.google.monitoring.v3.INotificationChannel, + protos.google.monitoring.v3.IUpdateNotificationChannelRequest | undefined, {} | undefined ] >; updateNotificationChannel( - request: protosTypes.google.monitoring.v3.IUpdateNotificationChannelRequest, + request: protos.google.monitoring.v3.IUpdateNotificationChannelRequest, options: gax.CallOptions, callback: Callback< - protosTypes.google.monitoring.v3.INotificationChannel, - | protosTypes.google.monitoring.v3.IUpdateNotificationChannelRequest + protos.google.monitoring.v3.INotificationChannel, + | protos.google.monitoring.v3.IUpdateNotificationChannelRequest + | null | undefined, - {} | undefined + {} | null | undefined + > + ): void; + updateNotificationChannel( + request: protos.google.monitoring.v3.IUpdateNotificationChannelRequest, + callback: Callback< + protos.google.monitoring.v3.INotificationChannel, + | protos.google.monitoring.v3.IUpdateNotificationChannelRequest + | null + | undefined, + {} | null | undefined > ): void; /** @@ -706,28 +743,27 @@ export class NotificationChannelServiceClient { * The promise has a method named "cancel" which cancels the ongoing API call. */ updateNotificationChannel( - request: protosTypes.google.monitoring.v3.IUpdateNotificationChannelRequest, + request: protos.google.monitoring.v3.IUpdateNotificationChannelRequest, optionsOrCallback?: | gax.CallOptions | Callback< - protosTypes.google.monitoring.v3.INotificationChannel, - | protosTypes.google.monitoring.v3.IUpdateNotificationChannelRequest + protos.google.monitoring.v3.INotificationChannel, + | protos.google.monitoring.v3.IUpdateNotificationChannelRequest + | null | undefined, - {} | undefined + {} | null | undefined >, callback?: Callback< - protosTypes.google.monitoring.v3.INotificationChannel, - | protosTypes.google.monitoring.v3.IUpdateNotificationChannelRequest + protos.google.monitoring.v3.INotificationChannel, + | protos.google.monitoring.v3.IUpdateNotificationChannelRequest + | null | undefined, - {} | undefined + {} | null | undefined > ): Promise< [ - protosTypes.google.monitoring.v3.INotificationChannel, - ( - | protosTypes.google.monitoring.v3.IUpdateNotificationChannelRequest - | undefined - ), + protos.google.monitoring.v3.INotificationChannel, + protos.google.monitoring.v3.IUpdateNotificationChannelRequest | undefined, {} | undefined ] > | void { @@ -748,33 +784,41 @@ export class NotificationChannelServiceClient { 'notification_channel.name': request.notificationChannel!.name || '', }); this.initialize(); - return this._innerApiCalls.updateNotificationChannel( + return this.innerApiCalls.updateNotificationChannel( request, options, callback ); } deleteNotificationChannel( - request: protosTypes.google.monitoring.v3.IDeleteNotificationChannelRequest, + request: protos.google.monitoring.v3.IDeleteNotificationChannelRequest, options?: gax.CallOptions ): Promise< [ - protosTypes.google.protobuf.IEmpty, - ( - | protosTypes.google.monitoring.v3.IDeleteNotificationChannelRequest - | undefined - ), + protos.google.protobuf.IEmpty, + protos.google.monitoring.v3.IDeleteNotificationChannelRequest | undefined, {} | undefined ] >; deleteNotificationChannel( - request: protosTypes.google.monitoring.v3.IDeleteNotificationChannelRequest, + request: protos.google.monitoring.v3.IDeleteNotificationChannelRequest, options: gax.CallOptions, callback: Callback< - protosTypes.google.protobuf.IEmpty, - | protosTypes.google.monitoring.v3.IDeleteNotificationChannelRequest + protos.google.protobuf.IEmpty, + | protos.google.monitoring.v3.IDeleteNotificationChannelRequest + | null | undefined, - {} | undefined + {} | null | undefined + > + ): void; + deleteNotificationChannel( + request: protos.google.monitoring.v3.IDeleteNotificationChannelRequest, + callback: Callback< + protos.google.protobuf.IEmpty, + | protos.google.monitoring.v3.IDeleteNotificationChannelRequest + | null + | undefined, + {} | null | undefined > ): void; /** @@ -798,28 +842,27 @@ export class NotificationChannelServiceClient { * The promise has a method named "cancel" which cancels the ongoing API call. */ deleteNotificationChannel( - request: protosTypes.google.monitoring.v3.IDeleteNotificationChannelRequest, + request: protos.google.monitoring.v3.IDeleteNotificationChannelRequest, optionsOrCallback?: | gax.CallOptions | Callback< - protosTypes.google.protobuf.IEmpty, - | protosTypes.google.monitoring.v3.IDeleteNotificationChannelRequest + protos.google.protobuf.IEmpty, + | protos.google.monitoring.v3.IDeleteNotificationChannelRequest + | null | undefined, - {} | undefined + {} | null | undefined >, callback?: Callback< - protosTypes.google.protobuf.IEmpty, - | protosTypes.google.monitoring.v3.IDeleteNotificationChannelRequest + protos.google.protobuf.IEmpty, + | protos.google.monitoring.v3.IDeleteNotificationChannelRequest + | null | undefined, - {} | undefined + {} | null | undefined > ): Promise< [ - protosTypes.google.protobuf.IEmpty, - ( - | protosTypes.google.monitoring.v3.IDeleteNotificationChannelRequest - | undefined - ), + protos.google.protobuf.IEmpty, + protos.google.monitoring.v3.IDeleteNotificationChannelRequest | undefined, {} | undefined ] > | void { @@ -840,33 +883,44 @@ export class NotificationChannelServiceClient { name: request.name || '', }); this.initialize(); - return this._innerApiCalls.deleteNotificationChannel( + return this.innerApiCalls.deleteNotificationChannel( request, options, callback ); } sendNotificationChannelVerificationCode( - request: protosTypes.google.monitoring.v3.ISendNotificationChannelVerificationCodeRequest, + request: protos.google.monitoring.v3.ISendNotificationChannelVerificationCodeRequest, options?: gax.CallOptions ): Promise< [ - protosTypes.google.protobuf.IEmpty, + protos.google.protobuf.IEmpty, ( - | protosTypes.google.monitoring.v3.ISendNotificationChannelVerificationCodeRequest + | protos.google.monitoring.v3.ISendNotificationChannelVerificationCodeRequest | undefined ), {} | undefined ] >; sendNotificationChannelVerificationCode( - request: protosTypes.google.monitoring.v3.ISendNotificationChannelVerificationCodeRequest, + request: protos.google.monitoring.v3.ISendNotificationChannelVerificationCodeRequest, options: gax.CallOptions, callback: Callback< - protosTypes.google.protobuf.IEmpty, - | protosTypes.google.monitoring.v3.ISendNotificationChannelVerificationCodeRequest + protos.google.protobuf.IEmpty, + | protos.google.monitoring.v3.ISendNotificationChannelVerificationCodeRequest + | null | undefined, - {} | undefined + {} | null | undefined + > + ): void; + sendNotificationChannelVerificationCode( + request: protos.google.monitoring.v3.ISendNotificationChannelVerificationCodeRequest, + callback: Callback< + protos.google.protobuf.IEmpty, + | protos.google.monitoring.v3.ISendNotificationChannelVerificationCodeRequest + | null + | undefined, + {} | null | undefined > ): void; /** @@ -884,26 +938,28 @@ export class NotificationChannelServiceClient { * The promise has a method named "cancel" which cancels the ongoing API call. */ sendNotificationChannelVerificationCode( - request: protosTypes.google.monitoring.v3.ISendNotificationChannelVerificationCodeRequest, + request: protos.google.monitoring.v3.ISendNotificationChannelVerificationCodeRequest, optionsOrCallback?: | gax.CallOptions | Callback< - protosTypes.google.protobuf.IEmpty, - | protosTypes.google.monitoring.v3.ISendNotificationChannelVerificationCodeRequest + protos.google.protobuf.IEmpty, + | protos.google.monitoring.v3.ISendNotificationChannelVerificationCodeRequest + | null | undefined, - {} | undefined + {} | null | undefined >, callback?: Callback< - protosTypes.google.protobuf.IEmpty, - | protosTypes.google.monitoring.v3.ISendNotificationChannelVerificationCodeRequest + protos.google.protobuf.IEmpty, + | protos.google.monitoring.v3.ISendNotificationChannelVerificationCodeRequest + | null | undefined, - {} | undefined + {} | null | undefined > ): Promise< [ - protosTypes.google.protobuf.IEmpty, + protos.google.protobuf.IEmpty, ( - | protosTypes.google.monitoring.v3.ISendNotificationChannelVerificationCodeRequest + | protos.google.monitoring.v3.ISendNotificationChannelVerificationCodeRequest | undefined ), {} | undefined @@ -926,33 +982,44 @@ export class NotificationChannelServiceClient { name: request.name || '', }); this.initialize(); - return this._innerApiCalls.sendNotificationChannelVerificationCode( + return this.innerApiCalls.sendNotificationChannelVerificationCode( request, options, callback ); } getNotificationChannelVerificationCode( - request: protosTypes.google.monitoring.v3.IGetNotificationChannelVerificationCodeRequest, + request: protos.google.monitoring.v3.IGetNotificationChannelVerificationCodeRequest, options?: gax.CallOptions ): Promise< [ - protosTypes.google.monitoring.v3.IGetNotificationChannelVerificationCodeResponse, + protos.google.monitoring.v3.IGetNotificationChannelVerificationCodeResponse, ( - | protosTypes.google.monitoring.v3.IGetNotificationChannelVerificationCodeRequest + | protos.google.monitoring.v3.IGetNotificationChannelVerificationCodeRequest | undefined ), {} | undefined ] >; getNotificationChannelVerificationCode( - request: protosTypes.google.monitoring.v3.IGetNotificationChannelVerificationCodeRequest, + request: protos.google.monitoring.v3.IGetNotificationChannelVerificationCodeRequest, options: gax.CallOptions, callback: Callback< - protosTypes.google.monitoring.v3.IGetNotificationChannelVerificationCodeResponse, - | protosTypes.google.monitoring.v3.IGetNotificationChannelVerificationCodeRequest + protos.google.monitoring.v3.IGetNotificationChannelVerificationCodeResponse, + | protos.google.monitoring.v3.IGetNotificationChannelVerificationCodeRequest + | null | undefined, - {} | undefined + {} | null | undefined + > + ): void; + getNotificationChannelVerificationCode( + request: protos.google.monitoring.v3.IGetNotificationChannelVerificationCodeRequest, + callback: Callback< + protos.google.monitoring.v3.IGetNotificationChannelVerificationCodeResponse, + | protos.google.monitoring.v3.IGetNotificationChannelVerificationCodeRequest + | null + | undefined, + {} | null | undefined > ): void; /** @@ -1001,26 +1068,28 @@ export class NotificationChannelServiceClient { * The promise has a method named "cancel" which cancels the ongoing API call. */ getNotificationChannelVerificationCode( - request: protosTypes.google.monitoring.v3.IGetNotificationChannelVerificationCodeRequest, + request: protos.google.monitoring.v3.IGetNotificationChannelVerificationCodeRequest, optionsOrCallback?: | gax.CallOptions | Callback< - protosTypes.google.monitoring.v3.IGetNotificationChannelVerificationCodeResponse, - | protosTypes.google.monitoring.v3.IGetNotificationChannelVerificationCodeRequest + protos.google.monitoring.v3.IGetNotificationChannelVerificationCodeResponse, + | protos.google.monitoring.v3.IGetNotificationChannelVerificationCodeRequest + | null | undefined, - {} | undefined + {} | null | undefined >, callback?: Callback< - protosTypes.google.monitoring.v3.IGetNotificationChannelVerificationCodeResponse, - | protosTypes.google.monitoring.v3.IGetNotificationChannelVerificationCodeRequest + protos.google.monitoring.v3.IGetNotificationChannelVerificationCodeResponse, + | protos.google.monitoring.v3.IGetNotificationChannelVerificationCodeRequest + | null | undefined, - {} | undefined + {} | null | undefined > ): Promise< [ - protosTypes.google.monitoring.v3.IGetNotificationChannelVerificationCodeResponse, + protos.google.monitoring.v3.IGetNotificationChannelVerificationCodeResponse, ( - | protosTypes.google.monitoring.v3.IGetNotificationChannelVerificationCodeRequest + | protos.google.monitoring.v3.IGetNotificationChannelVerificationCodeRequest | undefined ), {} | undefined @@ -1043,33 +1112,41 @@ export class NotificationChannelServiceClient { name: request.name || '', }); this.initialize(); - return this._innerApiCalls.getNotificationChannelVerificationCode( + return this.innerApiCalls.getNotificationChannelVerificationCode( request, options, callback ); } verifyNotificationChannel( - request: protosTypes.google.monitoring.v3.IVerifyNotificationChannelRequest, + request: protos.google.monitoring.v3.IVerifyNotificationChannelRequest, options?: gax.CallOptions ): Promise< [ - protosTypes.google.monitoring.v3.INotificationChannel, - ( - | protosTypes.google.monitoring.v3.IVerifyNotificationChannelRequest - | undefined - ), + protos.google.monitoring.v3.INotificationChannel, + protos.google.monitoring.v3.IVerifyNotificationChannelRequest | undefined, {} | undefined ] >; verifyNotificationChannel( - request: protosTypes.google.monitoring.v3.IVerifyNotificationChannelRequest, + request: protos.google.monitoring.v3.IVerifyNotificationChannelRequest, options: gax.CallOptions, callback: Callback< - protosTypes.google.monitoring.v3.INotificationChannel, - | protosTypes.google.monitoring.v3.IVerifyNotificationChannelRequest + protos.google.monitoring.v3.INotificationChannel, + | protos.google.monitoring.v3.IVerifyNotificationChannelRequest + | null | undefined, - {} | undefined + {} | null | undefined + > + ): void; + verifyNotificationChannel( + request: protos.google.monitoring.v3.IVerifyNotificationChannelRequest, + callback: Callback< + protos.google.monitoring.v3.INotificationChannel, + | protos.google.monitoring.v3.IVerifyNotificationChannelRequest + | null + | undefined, + {} | null | undefined > ): void; /** @@ -1096,28 +1173,27 @@ export class NotificationChannelServiceClient { * The promise has a method named "cancel" which cancels the ongoing API call. */ verifyNotificationChannel( - request: protosTypes.google.monitoring.v3.IVerifyNotificationChannelRequest, + request: protos.google.monitoring.v3.IVerifyNotificationChannelRequest, optionsOrCallback?: | gax.CallOptions | Callback< - protosTypes.google.monitoring.v3.INotificationChannel, - | protosTypes.google.monitoring.v3.IVerifyNotificationChannelRequest + protos.google.monitoring.v3.INotificationChannel, + | protos.google.monitoring.v3.IVerifyNotificationChannelRequest + | null | undefined, - {} | undefined + {} | null | undefined >, callback?: Callback< - protosTypes.google.monitoring.v3.INotificationChannel, - | protosTypes.google.monitoring.v3.IVerifyNotificationChannelRequest + protos.google.monitoring.v3.INotificationChannel, + | protos.google.monitoring.v3.IVerifyNotificationChannelRequest + | null | undefined, - {} | undefined + {} | null | undefined > ): Promise< [ - protosTypes.google.monitoring.v3.INotificationChannel, - ( - | protosTypes.google.monitoring.v3.IVerifyNotificationChannelRequest - | undefined - ), + protos.google.monitoring.v3.INotificationChannel, + protos.google.monitoring.v3.IVerifyNotificationChannelRequest | undefined, {} | undefined ] > | void { @@ -1138,7 +1214,7 @@ export class NotificationChannelServiceClient { name: request.name || '', }); this.initialize(); - return this._innerApiCalls.verifyNotificationChannel( + return this.innerApiCalls.verifyNotificationChannel( request, options, callback @@ -1146,22 +1222,34 @@ export class NotificationChannelServiceClient { } listNotificationChannelDescriptors( - request: protosTypes.google.monitoring.v3.IListNotificationChannelDescriptorsRequest, + request: protos.google.monitoring.v3.IListNotificationChannelDescriptorsRequest, options?: gax.CallOptions ): Promise< [ - protosTypes.google.monitoring.v3.INotificationChannelDescriptor[], - protosTypes.google.monitoring.v3.IListNotificationChannelDescriptorsRequest | null, - protosTypes.google.monitoring.v3.IListNotificationChannelDescriptorsResponse + protos.google.monitoring.v3.INotificationChannelDescriptor[], + protos.google.monitoring.v3.IListNotificationChannelDescriptorsRequest | null, + protos.google.monitoring.v3.IListNotificationChannelDescriptorsResponse ] >; listNotificationChannelDescriptors( - request: protosTypes.google.monitoring.v3.IListNotificationChannelDescriptorsRequest, + request: protos.google.monitoring.v3.IListNotificationChannelDescriptorsRequest, options: gax.CallOptions, - callback: Callback< - protosTypes.google.monitoring.v3.INotificationChannelDescriptor[], - protosTypes.google.monitoring.v3.IListNotificationChannelDescriptorsRequest | null, - protosTypes.google.monitoring.v3.IListNotificationChannelDescriptorsResponse + callback: PaginationCallback< + protos.google.monitoring.v3.IListNotificationChannelDescriptorsRequest, + | protos.google.monitoring.v3.IListNotificationChannelDescriptorsResponse + | null + | undefined, + protos.google.monitoring.v3.INotificationChannelDescriptor + > + ): void; + listNotificationChannelDescriptors( + request: protos.google.monitoring.v3.IListNotificationChannelDescriptorsRequest, + callback: PaginationCallback< + protos.google.monitoring.v3.IListNotificationChannelDescriptorsRequest, + | protos.google.monitoring.v3.IListNotificationChannelDescriptorsResponse + | null + | undefined, + protos.google.monitoring.v3.INotificationChannelDescriptor > ): void; /** @@ -1207,24 +1295,28 @@ export class NotificationChannelServiceClient { * The promise has a method named "cancel" which cancels the ongoing API call. */ listNotificationChannelDescriptors( - request: protosTypes.google.monitoring.v3.IListNotificationChannelDescriptorsRequest, + request: protos.google.monitoring.v3.IListNotificationChannelDescriptorsRequest, optionsOrCallback?: | gax.CallOptions - | Callback< - protosTypes.google.monitoring.v3.INotificationChannelDescriptor[], - protosTypes.google.monitoring.v3.IListNotificationChannelDescriptorsRequest | null, - protosTypes.google.monitoring.v3.IListNotificationChannelDescriptorsResponse + | PaginationCallback< + protos.google.monitoring.v3.IListNotificationChannelDescriptorsRequest, + | protos.google.monitoring.v3.IListNotificationChannelDescriptorsResponse + | null + | undefined, + protos.google.monitoring.v3.INotificationChannelDescriptor >, - callback?: Callback< - protosTypes.google.monitoring.v3.INotificationChannelDescriptor[], - protosTypes.google.monitoring.v3.IListNotificationChannelDescriptorsRequest | null, - protosTypes.google.monitoring.v3.IListNotificationChannelDescriptorsResponse + callback?: PaginationCallback< + protos.google.monitoring.v3.IListNotificationChannelDescriptorsRequest, + | protos.google.monitoring.v3.IListNotificationChannelDescriptorsResponse + | null + | undefined, + protos.google.monitoring.v3.INotificationChannelDescriptor > ): Promise< [ - protosTypes.google.monitoring.v3.INotificationChannelDescriptor[], - protosTypes.google.monitoring.v3.IListNotificationChannelDescriptorsRequest | null, - protosTypes.google.monitoring.v3.IListNotificationChannelDescriptorsResponse + protos.google.monitoring.v3.INotificationChannelDescriptor[], + protos.google.monitoring.v3.IListNotificationChannelDescriptorsRequest | null, + protos.google.monitoring.v3.IListNotificationChannelDescriptorsResponse ] > | void { request = request || {}; @@ -1244,7 +1336,7 @@ export class NotificationChannelServiceClient { name: request.name || '', }); this.initialize(); - return this._innerApiCalls.listNotificationChannelDescriptors( + return this.innerApiCalls.listNotificationChannelDescriptors( request, options, callback @@ -1290,7 +1382,7 @@ export class NotificationChannelServiceClient { * An object stream which emits an object representing [NotificationChannelDescriptor]{@link google.monitoring.v3.NotificationChannelDescriptor} on 'data' event. */ listNotificationChannelDescriptorsStream( - request?: protosTypes.google.monitoring.v3.IListNotificationChannelDescriptorsRequest, + request?: protos.google.monitoring.v3.IListNotificationChannelDescriptorsRequest, options?: gax.CallOptions ): Transform { request = request || {}; @@ -1304,29 +1396,96 @@ export class NotificationChannelServiceClient { }); const callSettings = new gax.CallSettings(options); this.initialize(); - return this._descriptors.page.listNotificationChannelDescriptors.createStream( - this._innerApiCalls.listNotificationChannelDescriptors as gax.GaxCall, + return this.descriptors.page.listNotificationChannelDescriptors.createStream( + this.innerApiCalls.listNotificationChannelDescriptors as gax.GaxCall, request, callSettings ); } + + /** + * Equivalent to {@link listNotificationChannelDescriptors}, 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.name + * Required. The REST resource name of the parent from which to retrieve + * the notification channel descriptors. The expected syntax is: + * + * projects/[PROJECT_ID_OR_NUMBER] + * + * Note that this names the parent container in which to look for the + * descriptors; to retrieve a single descriptor by name, use the + * {@link google.monitoring.v3.NotificationChannelService.GetNotificationChannelDescriptor|GetNotificationChannelDescriptor} + * operation, instead. + * @param {number} request.pageSize + * The maximum number of results to return in a single response. If + * not set to a positive number, a reasonable value will be chosen by the + * service. + * @param {string} request.pageToken + * If non-empty, `page_token` must contain a value returned as the + * `next_page_token` in a previous response to request the next set + * of results. + * @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. + */ + listNotificationChannelDescriptorsAsync( + request?: protos.google.monitoring.v3.IListNotificationChannelDescriptorsRequest, + options?: gax.CallOptions + ): AsyncIterable { + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + name: request.name || '', + }); + options = options || {}; + const callSettings = new gax.CallSettings(options); + this.initialize(); + return this.descriptors.page.listNotificationChannelDescriptors.asyncIterate( + this.innerApiCalls['listNotificationChannelDescriptors'] as GaxCall, + (request as unknown) as RequestType, + callSettings + ) as AsyncIterable< + protos.google.monitoring.v3.INotificationChannelDescriptor + >; + } listNotificationChannels( - request: protosTypes.google.monitoring.v3.IListNotificationChannelsRequest, + request: protos.google.monitoring.v3.IListNotificationChannelsRequest, options?: gax.CallOptions ): Promise< [ - protosTypes.google.monitoring.v3.INotificationChannel[], - protosTypes.google.monitoring.v3.IListNotificationChannelsRequest | null, - protosTypes.google.monitoring.v3.IListNotificationChannelsResponse + protos.google.monitoring.v3.INotificationChannel[], + protos.google.monitoring.v3.IListNotificationChannelsRequest | null, + protos.google.monitoring.v3.IListNotificationChannelsResponse ] >; listNotificationChannels( - request: protosTypes.google.monitoring.v3.IListNotificationChannelsRequest, + request: protos.google.monitoring.v3.IListNotificationChannelsRequest, options: gax.CallOptions, - callback: Callback< - protosTypes.google.monitoring.v3.INotificationChannel[], - protosTypes.google.monitoring.v3.IListNotificationChannelsRequest | null, - protosTypes.google.monitoring.v3.IListNotificationChannelsResponse + callback: PaginationCallback< + protos.google.monitoring.v3.IListNotificationChannelsRequest, + | protos.google.monitoring.v3.IListNotificationChannelsResponse + | null + | undefined, + protos.google.monitoring.v3.INotificationChannel + > + ): void; + listNotificationChannels( + request: protos.google.monitoring.v3.IListNotificationChannelsRequest, + callback: PaginationCallback< + protos.google.monitoring.v3.IListNotificationChannelsRequest, + | protos.google.monitoring.v3.IListNotificationChannelsResponse + | null + | undefined, + protos.google.monitoring.v3.INotificationChannel > ): void; /** @@ -1385,24 +1544,28 @@ export class NotificationChannelServiceClient { * The promise has a method named "cancel" which cancels the ongoing API call. */ listNotificationChannels( - request: protosTypes.google.monitoring.v3.IListNotificationChannelsRequest, + request: protos.google.monitoring.v3.IListNotificationChannelsRequest, optionsOrCallback?: | gax.CallOptions - | Callback< - protosTypes.google.monitoring.v3.INotificationChannel[], - protosTypes.google.monitoring.v3.IListNotificationChannelsRequest | null, - protosTypes.google.monitoring.v3.IListNotificationChannelsResponse + | PaginationCallback< + protos.google.monitoring.v3.IListNotificationChannelsRequest, + | protos.google.monitoring.v3.IListNotificationChannelsResponse + | null + | undefined, + protos.google.monitoring.v3.INotificationChannel >, - callback?: Callback< - protosTypes.google.monitoring.v3.INotificationChannel[], - protosTypes.google.monitoring.v3.IListNotificationChannelsRequest | null, - protosTypes.google.monitoring.v3.IListNotificationChannelsResponse + callback?: PaginationCallback< + protos.google.monitoring.v3.IListNotificationChannelsRequest, + | protos.google.monitoring.v3.IListNotificationChannelsResponse + | null + | undefined, + protos.google.monitoring.v3.INotificationChannel > ): Promise< [ - protosTypes.google.monitoring.v3.INotificationChannel[], - protosTypes.google.monitoring.v3.IListNotificationChannelsRequest | null, - protosTypes.google.monitoring.v3.IListNotificationChannelsResponse + protos.google.monitoring.v3.INotificationChannel[], + protos.google.monitoring.v3.IListNotificationChannelsRequest | null, + protos.google.monitoring.v3.IListNotificationChannelsResponse ] > | void { request = request || {}; @@ -1422,7 +1585,7 @@ export class NotificationChannelServiceClient { name: request.name || '', }); this.initialize(); - return this._innerApiCalls.listNotificationChannels( + return this.innerApiCalls.listNotificationChannels( request, options, callback @@ -1482,7 +1645,7 @@ export class NotificationChannelServiceClient { * An object stream which emits an object representing [NotificationChannel]{@link google.monitoring.v3.NotificationChannel} on 'data' event. */ listNotificationChannelsStream( - request?: protosTypes.google.monitoring.v3.IListNotificationChannelsRequest, + request?: protos.google.monitoring.v3.IListNotificationChannelsRequest, options?: gax.CallOptions ): Transform { request = request || {}; @@ -1496,12 +1659,79 @@ export class NotificationChannelServiceClient { }); const callSettings = new gax.CallSettings(options); this.initialize(); - return this._descriptors.page.listNotificationChannels.createStream( - this._innerApiCalls.listNotificationChannels as gax.GaxCall, + return this.descriptors.page.listNotificationChannels.createStream( + this.innerApiCalls.listNotificationChannels as gax.GaxCall, request, callSettings ); } + + /** + * Equivalent to {@link listNotificationChannels}, 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.name + * Required. The project on which to execute the request. The format is: + * + * projects/[PROJECT_ID_OR_NUMBER] + * + * This names the container + * in which to look for the notification channels; it does not name a + * specific channel. To query a specific channel by REST resource name, use + * the + * {@link google.monitoring.v3.NotificationChannelService.GetNotificationChannel|`GetNotificationChannel`} + * operation. + * @param {string} request.filter + * If provided, this field specifies the criteria that must be met by + * notification channels to be included in the response. + * + * For more details, see [sorting and + * filtering](https://cloud.google.com/monitoring/api/v3/sorting-and-filtering). + * @param {string} request.orderBy + * A comma-separated list of fields by which to sort the result. Supports + * the same set of fields as in `filter`. Entries can be prefixed with + * a minus sign to sort in descending rather than ascending order. + * + * For more details, see [sorting and + * filtering](https://cloud.google.com/monitoring/api/v3/sorting-and-filtering). + * @param {number} request.pageSize + * The maximum number of results to return in a single response. If + * not set to a positive number, a reasonable value will be chosen by the + * service. + * @param {string} request.pageToken + * If non-empty, `page_token` must contain a value returned as the + * `next_page_token` in a previous response to request the next set + * of results. + * @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. + */ + listNotificationChannelsAsync( + request?: protos.google.monitoring.v3.IListNotificationChannelsRequest, + options?: gax.CallOptions + ): AsyncIterable { + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + name: request.name || '', + }); + options = options || {}; + const callSettings = new gax.CallSettings(options); + this.initialize(); + return this.descriptors.page.listNotificationChannels.asyncIterate( + this.innerApiCalls['listNotificationChannels'] as GaxCall, + (request as unknown) as RequestType, + callSettings + ) as AsyncIterable; + } // -------------------- // -- Path templates -- // -------------------- @@ -1514,8 +1744,8 @@ export class NotificationChannelServiceClient { * @returns {string} Resource name string. */ folderAlertPolicyPath(folder: string, alertPolicy: string) { - return this._pathTemplates.folderAlertPolicyPathTemplate.render({ - folder, + return this.pathTemplates.folderAlertPolicyPathTemplate.render({ + folder: folder, alert_policy: alertPolicy, }); } @@ -1528,7 +1758,7 @@ export class NotificationChannelServiceClient { * @returns {string} A string representing the folder. */ matchFolderFromFolderAlertPolicyName(folderAlertPolicyName: string) { - return this._pathTemplates.folderAlertPolicyPathTemplate.match( + return this.pathTemplates.folderAlertPolicyPathTemplate.match( folderAlertPolicyName ).folder; } @@ -1541,7 +1771,7 @@ export class NotificationChannelServiceClient { * @returns {string} A string representing the alert_policy. */ matchAlertPolicyFromFolderAlertPolicyName(folderAlertPolicyName: string) { - return this._pathTemplates.folderAlertPolicyPathTemplate.match( + return this.pathTemplates.folderAlertPolicyPathTemplate.match( folderAlertPolicyName ).alert_policy; } @@ -1559,10 +1789,10 @@ export class NotificationChannelServiceClient { alertPolicy: string, condition: string ) { - return this._pathTemplates.folderAlertPolicyConditionPathTemplate.render({ - folder, + return this.pathTemplates.folderAlertPolicyConditionPathTemplate.render({ + folder: folder, alert_policy: alertPolicy, - condition, + condition: condition, }); } @@ -1576,7 +1806,7 @@ export class NotificationChannelServiceClient { matchFolderFromFolderAlertPolicyConditionName( folderAlertPolicyConditionName: string ) { - return this._pathTemplates.folderAlertPolicyConditionPathTemplate.match( + return this.pathTemplates.folderAlertPolicyConditionPathTemplate.match( folderAlertPolicyConditionName ).folder; } @@ -1591,7 +1821,7 @@ export class NotificationChannelServiceClient { matchAlertPolicyFromFolderAlertPolicyConditionName( folderAlertPolicyConditionName: string ) { - return this._pathTemplates.folderAlertPolicyConditionPathTemplate.match( + return this.pathTemplates.folderAlertPolicyConditionPathTemplate.match( folderAlertPolicyConditionName ).alert_policy; } @@ -1606,7 +1836,7 @@ export class NotificationChannelServiceClient { matchConditionFromFolderAlertPolicyConditionName( folderAlertPolicyConditionName: string ) { - return this._pathTemplates.folderAlertPolicyConditionPathTemplate.match( + return this.pathTemplates.folderAlertPolicyConditionPathTemplate.match( folderAlertPolicyConditionName ).condition; } @@ -1619,8 +1849,8 @@ export class NotificationChannelServiceClient { * @returns {string} Resource name string. */ folderChannelDescriptorPath(folder: string, channelDescriptor: string) { - return this._pathTemplates.folderChannelDescriptorPathTemplate.render({ - folder, + return this.pathTemplates.folderChannelDescriptorPathTemplate.render({ + folder: folder, channel_descriptor: channelDescriptor, }); } @@ -1635,7 +1865,7 @@ export class NotificationChannelServiceClient { matchFolderFromFolderChannelDescriptorName( folderChannelDescriptorName: string ) { - return this._pathTemplates.folderChannelDescriptorPathTemplate.match( + return this.pathTemplates.folderChannelDescriptorPathTemplate.match( folderChannelDescriptorName ).folder; } @@ -1650,7 +1880,7 @@ export class NotificationChannelServiceClient { matchChannelDescriptorFromFolderChannelDescriptorName( folderChannelDescriptorName: string ) { - return this._pathTemplates.folderChannelDescriptorPathTemplate.match( + return this.pathTemplates.folderChannelDescriptorPathTemplate.match( folderChannelDescriptorName ).channel_descriptor; } @@ -1663,9 +1893,9 @@ export class NotificationChannelServiceClient { * @returns {string} Resource name string. */ folderGroupPath(folder: string, group: string) { - return this._pathTemplates.folderGroupPathTemplate.render({ - folder, - group, + return this.pathTemplates.folderGroupPathTemplate.render({ + folder: folder, + group: group, }); } @@ -1677,7 +1907,7 @@ export class NotificationChannelServiceClient { * @returns {string} A string representing the folder. */ matchFolderFromFolderGroupName(folderGroupName: string) { - return this._pathTemplates.folderGroupPathTemplate.match(folderGroupName) + return this.pathTemplates.folderGroupPathTemplate.match(folderGroupName) .folder; } @@ -1689,7 +1919,7 @@ export class NotificationChannelServiceClient { * @returns {string} A string representing the group. */ matchGroupFromFolderGroupName(folderGroupName: string) { - return this._pathTemplates.folderGroupPathTemplate.match(folderGroupName) + return this.pathTemplates.folderGroupPathTemplate.match(folderGroupName) .group; } @@ -1701,8 +1931,8 @@ export class NotificationChannelServiceClient { * @returns {string} Resource name string. */ folderNotificationChannelPath(folder: string, notificationChannel: string) { - return this._pathTemplates.folderNotificationChannelPathTemplate.render({ - folder, + return this.pathTemplates.folderNotificationChannelPathTemplate.render({ + folder: folder, notification_channel: notificationChannel, }); } @@ -1717,7 +1947,7 @@ export class NotificationChannelServiceClient { matchFolderFromFolderNotificationChannelName( folderNotificationChannelName: string ) { - return this._pathTemplates.folderNotificationChannelPathTemplate.match( + return this.pathTemplates.folderNotificationChannelPathTemplate.match( folderNotificationChannelName ).folder; } @@ -1732,7 +1962,7 @@ export class NotificationChannelServiceClient { matchNotificationChannelFromFolderNotificationChannelName( folderNotificationChannelName: string ) { - return this._pathTemplates.folderNotificationChannelPathTemplate.match( + return this.pathTemplates.folderNotificationChannelPathTemplate.match( folderNotificationChannelName ).notification_channel; } @@ -1745,9 +1975,9 @@ export class NotificationChannelServiceClient { * @returns {string} Resource name string. */ folderServicePath(folder: string, service: string) { - return this._pathTemplates.folderServicePathTemplate.render({ - folder, - service, + return this.pathTemplates.folderServicePathTemplate.render({ + folder: folder, + service: service, }); } @@ -1759,9 +1989,8 @@ export class NotificationChannelServiceClient { * @returns {string} A string representing the folder. */ matchFolderFromFolderServiceName(folderServiceName: string) { - return this._pathTemplates.folderServicePathTemplate.match( - folderServiceName - ).folder; + return this.pathTemplates.folderServicePathTemplate.match(folderServiceName) + .folder; } /** @@ -1772,9 +2001,8 @@ export class NotificationChannelServiceClient { * @returns {string} A string representing the service. */ matchServiceFromFolderServiceName(folderServiceName: string) { - return this._pathTemplates.folderServicePathTemplate.match( - folderServiceName - ).service; + return this.pathTemplates.folderServicePathTemplate.match(folderServiceName) + .service; } /** @@ -1790,10 +2018,10 @@ export class NotificationChannelServiceClient { service: string, serviceLevelObjective: string ) { - return this._pathTemplates.folderServiceServiceLevelObjectivePathTemplate.render( + return this.pathTemplates.folderServiceServiceLevelObjectivePathTemplate.render( { - folder, - service, + folder: folder, + service: service, service_level_objective: serviceLevelObjective, } ); @@ -1809,7 +2037,7 @@ export class NotificationChannelServiceClient { matchFolderFromFolderServiceServiceLevelObjectiveName( folderServiceServiceLevelObjectiveName: string ) { - return this._pathTemplates.folderServiceServiceLevelObjectivePathTemplate.match( + return this.pathTemplates.folderServiceServiceLevelObjectivePathTemplate.match( folderServiceServiceLevelObjectiveName ).folder; } @@ -1824,7 +2052,7 @@ export class NotificationChannelServiceClient { matchServiceFromFolderServiceServiceLevelObjectiveName( folderServiceServiceLevelObjectiveName: string ) { - return this._pathTemplates.folderServiceServiceLevelObjectivePathTemplate.match( + return this.pathTemplates.folderServiceServiceLevelObjectivePathTemplate.match( folderServiceServiceLevelObjectiveName ).service; } @@ -1839,7 +2067,7 @@ export class NotificationChannelServiceClient { matchServiceLevelObjectiveFromFolderServiceServiceLevelObjectiveName( folderServiceServiceLevelObjectiveName: string ) { - return this._pathTemplates.folderServiceServiceLevelObjectivePathTemplate.match( + return this.pathTemplates.folderServiceServiceLevelObjectivePathTemplate.match( folderServiceServiceLevelObjectiveName ).service_level_objective; } @@ -1852,8 +2080,8 @@ export class NotificationChannelServiceClient { * @returns {string} Resource name string. */ folderUptimeCheckConfigPath(folder: string, uptimeCheckConfig: string) { - return this._pathTemplates.folderUptimeCheckConfigPathTemplate.render({ - folder, + return this.pathTemplates.folderUptimeCheckConfigPathTemplate.render({ + folder: folder, uptime_check_config: uptimeCheckConfig, }); } @@ -1868,7 +2096,7 @@ export class NotificationChannelServiceClient { matchFolderFromFolderUptimeCheckConfigName( folderUptimeCheckConfigName: string ) { - return this._pathTemplates.folderUptimeCheckConfigPathTemplate.match( + return this.pathTemplates.folderUptimeCheckConfigPathTemplate.match( folderUptimeCheckConfigName ).folder; } @@ -1883,7 +2111,7 @@ export class NotificationChannelServiceClient { matchUptimeCheckConfigFromFolderUptimeCheckConfigName( folderUptimeCheckConfigName: string ) { - return this._pathTemplates.folderUptimeCheckConfigPathTemplate.match( + return this.pathTemplates.folderUptimeCheckConfigPathTemplate.match( folderUptimeCheckConfigName ).uptime_check_config; } @@ -1896,8 +2124,8 @@ export class NotificationChannelServiceClient { * @returns {string} Resource name string. */ organizationAlertPolicyPath(organization: string, alertPolicy: string) { - return this._pathTemplates.organizationAlertPolicyPathTemplate.render({ - organization, + return this.pathTemplates.organizationAlertPolicyPathTemplate.render({ + organization: organization, alert_policy: alertPolicy, }); } @@ -1912,7 +2140,7 @@ export class NotificationChannelServiceClient { matchOrganizationFromOrganizationAlertPolicyName( organizationAlertPolicyName: string ) { - return this._pathTemplates.organizationAlertPolicyPathTemplate.match( + return this.pathTemplates.organizationAlertPolicyPathTemplate.match( organizationAlertPolicyName ).organization; } @@ -1927,7 +2155,7 @@ export class NotificationChannelServiceClient { matchAlertPolicyFromOrganizationAlertPolicyName( organizationAlertPolicyName: string ) { - return this._pathTemplates.organizationAlertPolicyPathTemplate.match( + return this.pathTemplates.organizationAlertPolicyPathTemplate.match( organizationAlertPolicyName ).alert_policy; } @@ -1945,11 +2173,11 @@ export class NotificationChannelServiceClient { alertPolicy: string, condition: string ) { - return this._pathTemplates.organizationAlertPolicyConditionPathTemplate.render( + return this.pathTemplates.organizationAlertPolicyConditionPathTemplate.render( { - organization, + organization: organization, alert_policy: alertPolicy, - condition, + condition: condition, } ); } @@ -1964,7 +2192,7 @@ export class NotificationChannelServiceClient { matchOrganizationFromOrganizationAlertPolicyConditionName( organizationAlertPolicyConditionName: string ) { - return this._pathTemplates.organizationAlertPolicyConditionPathTemplate.match( + return this.pathTemplates.organizationAlertPolicyConditionPathTemplate.match( organizationAlertPolicyConditionName ).organization; } @@ -1979,7 +2207,7 @@ export class NotificationChannelServiceClient { matchAlertPolicyFromOrganizationAlertPolicyConditionName( organizationAlertPolicyConditionName: string ) { - return this._pathTemplates.organizationAlertPolicyConditionPathTemplate.match( + return this.pathTemplates.organizationAlertPolicyConditionPathTemplate.match( organizationAlertPolicyConditionName ).alert_policy; } @@ -1994,7 +2222,7 @@ export class NotificationChannelServiceClient { matchConditionFromOrganizationAlertPolicyConditionName( organizationAlertPolicyConditionName: string ) { - return this._pathTemplates.organizationAlertPolicyConditionPathTemplate.match( + return this.pathTemplates.organizationAlertPolicyConditionPathTemplate.match( organizationAlertPolicyConditionName ).condition; } @@ -2010,12 +2238,10 @@ export class NotificationChannelServiceClient { organization: string, channelDescriptor: string ) { - return this._pathTemplates.organizationChannelDescriptorPathTemplate.render( - { - organization, - channel_descriptor: channelDescriptor, - } - ); + return this.pathTemplates.organizationChannelDescriptorPathTemplate.render({ + organization: organization, + channel_descriptor: channelDescriptor, + }); } /** @@ -2028,7 +2254,7 @@ export class NotificationChannelServiceClient { matchOrganizationFromOrganizationChannelDescriptorName( organizationChannelDescriptorName: string ) { - return this._pathTemplates.organizationChannelDescriptorPathTemplate.match( + return this.pathTemplates.organizationChannelDescriptorPathTemplate.match( organizationChannelDescriptorName ).organization; } @@ -2043,7 +2269,7 @@ export class NotificationChannelServiceClient { matchChannelDescriptorFromOrganizationChannelDescriptorName( organizationChannelDescriptorName: string ) { - return this._pathTemplates.organizationChannelDescriptorPathTemplate.match( + return this.pathTemplates.organizationChannelDescriptorPathTemplate.match( organizationChannelDescriptorName ).channel_descriptor; } @@ -2056,9 +2282,9 @@ export class NotificationChannelServiceClient { * @returns {string} Resource name string. */ organizationGroupPath(organization: string, group: string) { - return this._pathTemplates.organizationGroupPathTemplate.render({ - organization, - group, + return this.pathTemplates.organizationGroupPathTemplate.render({ + organization: organization, + group: group, }); } @@ -2070,7 +2296,7 @@ export class NotificationChannelServiceClient { * @returns {string} A string representing the organization. */ matchOrganizationFromOrganizationGroupName(organizationGroupName: string) { - return this._pathTemplates.organizationGroupPathTemplate.match( + return this.pathTemplates.organizationGroupPathTemplate.match( organizationGroupName ).organization; } @@ -2083,7 +2309,7 @@ export class NotificationChannelServiceClient { * @returns {string} A string representing the group. */ matchGroupFromOrganizationGroupName(organizationGroupName: string) { - return this._pathTemplates.organizationGroupPathTemplate.match( + return this.pathTemplates.organizationGroupPathTemplate.match( organizationGroupName ).group; } @@ -2099,9 +2325,9 @@ export class NotificationChannelServiceClient { organization: string, notificationChannel: string ) { - return this._pathTemplates.organizationNotificationChannelPathTemplate.render( + return this.pathTemplates.organizationNotificationChannelPathTemplate.render( { - organization, + organization: organization, notification_channel: notificationChannel, } ); @@ -2117,7 +2343,7 @@ export class NotificationChannelServiceClient { matchOrganizationFromOrganizationNotificationChannelName( organizationNotificationChannelName: string ) { - return this._pathTemplates.organizationNotificationChannelPathTemplate.match( + return this.pathTemplates.organizationNotificationChannelPathTemplate.match( organizationNotificationChannelName ).organization; } @@ -2132,7 +2358,7 @@ export class NotificationChannelServiceClient { matchNotificationChannelFromOrganizationNotificationChannelName( organizationNotificationChannelName: string ) { - return this._pathTemplates.organizationNotificationChannelPathTemplate.match( + return this.pathTemplates.organizationNotificationChannelPathTemplate.match( organizationNotificationChannelName ).notification_channel; } @@ -2145,9 +2371,9 @@ export class NotificationChannelServiceClient { * @returns {string} Resource name string. */ organizationServicePath(organization: string, service: string) { - return this._pathTemplates.organizationServicePathTemplate.render({ - organization, - service, + return this.pathTemplates.organizationServicePathTemplate.render({ + organization: organization, + service: service, }); } @@ -2161,7 +2387,7 @@ export class NotificationChannelServiceClient { matchOrganizationFromOrganizationServiceName( organizationServiceName: string ) { - return this._pathTemplates.organizationServicePathTemplate.match( + return this.pathTemplates.organizationServicePathTemplate.match( organizationServiceName ).organization; } @@ -2174,7 +2400,7 @@ export class NotificationChannelServiceClient { * @returns {string} A string representing the service. */ matchServiceFromOrganizationServiceName(organizationServiceName: string) { - return this._pathTemplates.organizationServicePathTemplate.match( + return this.pathTemplates.organizationServicePathTemplate.match( organizationServiceName ).service; } @@ -2192,10 +2418,10 @@ export class NotificationChannelServiceClient { service: string, serviceLevelObjective: string ) { - return this._pathTemplates.organizationServiceServiceLevelObjectivePathTemplate.render( + return this.pathTemplates.organizationServiceServiceLevelObjectivePathTemplate.render( { - organization, - service, + organization: organization, + service: service, service_level_objective: serviceLevelObjective, } ); @@ -2211,7 +2437,7 @@ export class NotificationChannelServiceClient { matchOrganizationFromOrganizationServiceServiceLevelObjectiveName( organizationServiceServiceLevelObjectiveName: string ) { - return this._pathTemplates.organizationServiceServiceLevelObjectivePathTemplate.match( + return this.pathTemplates.organizationServiceServiceLevelObjectivePathTemplate.match( organizationServiceServiceLevelObjectiveName ).organization; } @@ -2226,7 +2452,7 @@ export class NotificationChannelServiceClient { matchServiceFromOrganizationServiceServiceLevelObjectiveName( organizationServiceServiceLevelObjectiveName: string ) { - return this._pathTemplates.organizationServiceServiceLevelObjectivePathTemplate.match( + return this.pathTemplates.organizationServiceServiceLevelObjectivePathTemplate.match( organizationServiceServiceLevelObjectiveName ).service; } @@ -2241,7 +2467,7 @@ export class NotificationChannelServiceClient { matchServiceLevelObjectiveFromOrganizationServiceServiceLevelObjectiveName( organizationServiceServiceLevelObjectiveName: string ) { - return this._pathTemplates.organizationServiceServiceLevelObjectivePathTemplate.match( + return this.pathTemplates.organizationServiceServiceLevelObjectivePathTemplate.match( organizationServiceServiceLevelObjectiveName ).service_level_objective; } @@ -2257,12 +2483,10 @@ export class NotificationChannelServiceClient { organization: string, uptimeCheckConfig: string ) { - return this._pathTemplates.organizationUptimeCheckConfigPathTemplate.render( - { - organization, - uptime_check_config: uptimeCheckConfig, - } - ); + return this.pathTemplates.organizationUptimeCheckConfigPathTemplate.render({ + organization: organization, + uptime_check_config: uptimeCheckConfig, + }); } /** @@ -2275,7 +2499,7 @@ export class NotificationChannelServiceClient { matchOrganizationFromOrganizationUptimeCheckConfigName( organizationUptimeCheckConfigName: string ) { - return this._pathTemplates.organizationUptimeCheckConfigPathTemplate.match( + return this.pathTemplates.organizationUptimeCheckConfigPathTemplate.match( organizationUptimeCheckConfigName ).organization; } @@ -2290,7 +2514,7 @@ export class NotificationChannelServiceClient { matchUptimeCheckConfigFromOrganizationUptimeCheckConfigName( organizationUptimeCheckConfigName: string ) { - return this._pathTemplates.organizationUptimeCheckConfigPathTemplate.match( + return this.pathTemplates.organizationUptimeCheckConfigPathTemplate.match( organizationUptimeCheckConfigName ).uptime_check_config; } @@ -2302,8 +2526,8 @@ export class NotificationChannelServiceClient { * @returns {string} Resource name string. */ projectPath(project: string) { - return this._pathTemplates.projectPathTemplate.render({ - project, + return this.pathTemplates.projectPathTemplate.render({ + project: project, }); } @@ -2315,7 +2539,7 @@ export class NotificationChannelServiceClient { * @returns {string} A string representing the project. */ matchProjectFromProjectName(projectName: string) { - return this._pathTemplates.projectPathTemplate.match(projectName).project; + return this.pathTemplates.projectPathTemplate.match(projectName).project; } /** @@ -2326,8 +2550,8 @@ export class NotificationChannelServiceClient { * @returns {string} Resource name string. */ projectAlertPolicyPath(project: string, alertPolicy: string) { - return this._pathTemplates.projectAlertPolicyPathTemplate.render({ - project, + return this.pathTemplates.projectAlertPolicyPathTemplate.render({ + project: project, alert_policy: alertPolicy, }); } @@ -2340,7 +2564,7 @@ export class NotificationChannelServiceClient { * @returns {string} A string representing the project. */ matchProjectFromProjectAlertPolicyName(projectAlertPolicyName: string) { - return this._pathTemplates.projectAlertPolicyPathTemplate.match( + return this.pathTemplates.projectAlertPolicyPathTemplate.match( projectAlertPolicyName ).project; } @@ -2353,7 +2577,7 @@ export class NotificationChannelServiceClient { * @returns {string} A string representing the alert_policy. */ matchAlertPolicyFromProjectAlertPolicyName(projectAlertPolicyName: string) { - return this._pathTemplates.projectAlertPolicyPathTemplate.match( + return this.pathTemplates.projectAlertPolicyPathTemplate.match( projectAlertPolicyName ).alert_policy; } @@ -2371,10 +2595,10 @@ export class NotificationChannelServiceClient { alertPolicy: string, condition: string ) { - return this._pathTemplates.projectAlertPolicyConditionPathTemplate.render({ - project, + return this.pathTemplates.projectAlertPolicyConditionPathTemplate.render({ + project: project, alert_policy: alertPolicy, - condition, + condition: condition, }); } @@ -2388,7 +2612,7 @@ export class NotificationChannelServiceClient { matchProjectFromProjectAlertPolicyConditionName( projectAlertPolicyConditionName: string ) { - return this._pathTemplates.projectAlertPolicyConditionPathTemplate.match( + return this.pathTemplates.projectAlertPolicyConditionPathTemplate.match( projectAlertPolicyConditionName ).project; } @@ -2403,7 +2627,7 @@ export class NotificationChannelServiceClient { matchAlertPolicyFromProjectAlertPolicyConditionName( projectAlertPolicyConditionName: string ) { - return this._pathTemplates.projectAlertPolicyConditionPathTemplate.match( + return this.pathTemplates.projectAlertPolicyConditionPathTemplate.match( projectAlertPolicyConditionName ).alert_policy; } @@ -2418,7 +2642,7 @@ export class NotificationChannelServiceClient { matchConditionFromProjectAlertPolicyConditionName( projectAlertPolicyConditionName: string ) { - return this._pathTemplates.projectAlertPolicyConditionPathTemplate.match( + return this.pathTemplates.projectAlertPolicyConditionPathTemplate.match( projectAlertPolicyConditionName ).condition; } @@ -2431,8 +2655,8 @@ export class NotificationChannelServiceClient { * @returns {string} Resource name string. */ projectChannelDescriptorPath(project: string, channelDescriptor: string) { - return this._pathTemplates.projectChannelDescriptorPathTemplate.render({ - project, + return this.pathTemplates.projectChannelDescriptorPathTemplate.render({ + project: project, channel_descriptor: channelDescriptor, }); } @@ -2447,7 +2671,7 @@ export class NotificationChannelServiceClient { matchProjectFromProjectChannelDescriptorName( projectChannelDescriptorName: string ) { - return this._pathTemplates.projectChannelDescriptorPathTemplate.match( + return this.pathTemplates.projectChannelDescriptorPathTemplate.match( projectChannelDescriptorName ).project; } @@ -2462,7 +2686,7 @@ export class NotificationChannelServiceClient { matchChannelDescriptorFromProjectChannelDescriptorName( projectChannelDescriptorName: string ) { - return this._pathTemplates.projectChannelDescriptorPathTemplate.match( + return this.pathTemplates.projectChannelDescriptorPathTemplate.match( projectChannelDescriptorName ).channel_descriptor; } @@ -2475,9 +2699,9 @@ export class NotificationChannelServiceClient { * @returns {string} Resource name string. */ projectGroupPath(project: string, group: string) { - return this._pathTemplates.projectGroupPathTemplate.render({ - project, - group, + return this.pathTemplates.projectGroupPathTemplate.render({ + project: project, + group: group, }); } @@ -2489,7 +2713,7 @@ export class NotificationChannelServiceClient { * @returns {string} A string representing the project. */ matchProjectFromProjectGroupName(projectGroupName: string) { - return this._pathTemplates.projectGroupPathTemplate.match(projectGroupName) + return this.pathTemplates.projectGroupPathTemplate.match(projectGroupName) .project; } @@ -2501,7 +2725,7 @@ export class NotificationChannelServiceClient { * @returns {string} A string representing the group. */ matchGroupFromProjectGroupName(projectGroupName: string) { - return this._pathTemplates.projectGroupPathTemplate.match(projectGroupName) + return this.pathTemplates.projectGroupPathTemplate.match(projectGroupName) .group; } @@ -2513,8 +2737,8 @@ export class NotificationChannelServiceClient { * @returns {string} Resource name string. */ projectNotificationChannelPath(project: string, notificationChannel: string) { - return this._pathTemplates.projectNotificationChannelPathTemplate.render({ - project, + return this.pathTemplates.projectNotificationChannelPathTemplate.render({ + project: project, notification_channel: notificationChannel, }); } @@ -2529,7 +2753,7 @@ export class NotificationChannelServiceClient { matchProjectFromProjectNotificationChannelName( projectNotificationChannelName: string ) { - return this._pathTemplates.projectNotificationChannelPathTemplate.match( + return this.pathTemplates.projectNotificationChannelPathTemplate.match( projectNotificationChannelName ).project; } @@ -2544,7 +2768,7 @@ export class NotificationChannelServiceClient { matchNotificationChannelFromProjectNotificationChannelName( projectNotificationChannelName: string ) { - return this._pathTemplates.projectNotificationChannelPathTemplate.match( + return this.pathTemplates.projectNotificationChannelPathTemplate.match( projectNotificationChannelName ).notification_channel; } @@ -2557,9 +2781,9 @@ export class NotificationChannelServiceClient { * @returns {string} Resource name string. */ projectServicePath(project: string, service: string) { - return this._pathTemplates.projectServicePathTemplate.render({ - project, - service, + return this.pathTemplates.projectServicePathTemplate.render({ + project: project, + service: service, }); } @@ -2571,7 +2795,7 @@ export class NotificationChannelServiceClient { * @returns {string} A string representing the project. */ matchProjectFromProjectServiceName(projectServiceName: string) { - return this._pathTemplates.projectServicePathTemplate.match( + return this.pathTemplates.projectServicePathTemplate.match( projectServiceName ).project; } @@ -2584,7 +2808,7 @@ export class NotificationChannelServiceClient { * @returns {string} A string representing the service. */ matchServiceFromProjectServiceName(projectServiceName: string) { - return this._pathTemplates.projectServicePathTemplate.match( + return this.pathTemplates.projectServicePathTemplate.match( projectServiceName ).service; } @@ -2602,10 +2826,10 @@ export class NotificationChannelServiceClient { service: string, serviceLevelObjective: string ) { - return this._pathTemplates.projectServiceServiceLevelObjectivePathTemplate.render( + return this.pathTemplates.projectServiceServiceLevelObjectivePathTemplate.render( { - project, - service, + project: project, + service: service, service_level_objective: serviceLevelObjective, } ); @@ -2621,7 +2845,7 @@ export class NotificationChannelServiceClient { matchProjectFromProjectServiceServiceLevelObjectiveName( projectServiceServiceLevelObjectiveName: string ) { - return this._pathTemplates.projectServiceServiceLevelObjectivePathTemplate.match( + return this.pathTemplates.projectServiceServiceLevelObjectivePathTemplate.match( projectServiceServiceLevelObjectiveName ).project; } @@ -2636,7 +2860,7 @@ export class NotificationChannelServiceClient { matchServiceFromProjectServiceServiceLevelObjectiveName( projectServiceServiceLevelObjectiveName: string ) { - return this._pathTemplates.projectServiceServiceLevelObjectivePathTemplate.match( + return this.pathTemplates.projectServiceServiceLevelObjectivePathTemplate.match( projectServiceServiceLevelObjectiveName ).service; } @@ -2651,7 +2875,7 @@ export class NotificationChannelServiceClient { matchServiceLevelObjectiveFromProjectServiceServiceLevelObjectiveName( projectServiceServiceLevelObjectiveName: string ) { - return this._pathTemplates.projectServiceServiceLevelObjectivePathTemplate.match( + return this.pathTemplates.projectServiceServiceLevelObjectivePathTemplate.match( projectServiceServiceLevelObjectiveName ).service_level_objective; } @@ -2664,8 +2888,8 @@ export class NotificationChannelServiceClient { * @returns {string} Resource name string. */ projectUptimeCheckConfigPath(project: string, uptimeCheckConfig: string) { - return this._pathTemplates.projectUptimeCheckConfigPathTemplate.render({ - project, + return this.pathTemplates.projectUptimeCheckConfigPathTemplate.render({ + project: project, uptime_check_config: uptimeCheckConfig, }); } @@ -2680,7 +2904,7 @@ export class NotificationChannelServiceClient { matchProjectFromProjectUptimeCheckConfigName( projectUptimeCheckConfigName: string ) { - return this._pathTemplates.projectUptimeCheckConfigPathTemplate.match( + return this.pathTemplates.projectUptimeCheckConfigPathTemplate.match( projectUptimeCheckConfigName ).project; } @@ -2695,7 +2919,7 @@ export class NotificationChannelServiceClient { matchUptimeCheckConfigFromProjectUptimeCheckConfigName( projectUptimeCheckConfigName: string ) { - return this._pathTemplates.projectUptimeCheckConfigPathTemplate.match( + return this.pathTemplates.projectUptimeCheckConfigPathTemplate.match( projectUptimeCheckConfigName ).uptime_check_config; } diff --git a/packages/google-cloud-monitoring/src/v3/service_monitoring_service_client.ts b/packages/google-cloud-monitoring/src/v3/service_monitoring_service_client.ts index ecee7592a36..99b6bb76f32 100644 --- a/packages/google-cloud-monitoring/src/v3/service_monitoring_service_client.ts +++ b/packages/google-cloud-monitoring/src/v3/service_monitoring_service_client.ts @@ -1,4 +1,4 @@ -// Copyright 2019 Google LLC +// Copyright 2020 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -18,18 +18,18 @@ import * as gax from 'google-gax'; import { - APICallback, Callback, CallOptions, Descriptors, ClientOptions, PaginationCallback, - PaginationResponse, + GaxCall, } from 'google-gax'; import * as path from 'path'; import {Transform} from 'stream'; -import * as protosTypes from '../../protos/protos'; +import {RequestType} from 'google-gax/build/src/apitypes'; +import * as protos from '../../protos/protos'; import * as gapicConfig from './service_monitoring_service_client_config.json'; const version = require('../../../package.json').version; @@ -43,9 +43,6 @@ const version = require('../../../package.json').version; * @memberof v3 */ export class ServiceMonitoringServiceClient { - private _descriptors: Descriptors = {page: {}, stream: {}, longrunning: {}}; - private _innerApiCalls: {[name: string]: Function}; - private _pathTemplates: {[name: string]: gax.PathTemplate}; private _terminated = false; private _opts: ClientOptions; private _gaxModule: typeof gax | typeof gax.fallback; @@ -53,6 +50,14 @@ export class ServiceMonitoringServiceClient { private _protos: {}; private _defaults: {[method: string]: gax.CallSettings}; auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + innerApiCalls: {[name: string]: Function}; + pathTemplates: {[name: string]: gax.PathTemplate}; serviceMonitoringServiceStub?: Promise<{[name: string]: Function}>; /** @@ -146,13 +151,16 @@ export class ServiceMonitoringServiceClient { 'protos.json' ); this._protos = this._gaxGrpc.loadProto( - opts.fallback ? 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 // identifiers to uniquely identify resources within the API. // Create useful helper objects for these. - this._pathTemplates = { + this.pathTemplates = { folderAlertPolicyPathTemplate: new this._gaxModule.PathTemplate( 'folders/{folder}/alertPolicies/{alert_policy}' ), @@ -233,7 +241,7 @@ export class ServiceMonitoringServiceClient { // Some of the methods on this service return "paged" results, // (e.g. 50 results at a time, with tokens to get subsequent // pages). Denote the keys used for pagination and results. - this._descriptors.page = { + this.descriptors.page = { listServices: new this._gaxModule.PageDescriptor( 'pageToken', 'nextPageToken', @@ -257,7 +265,7 @@ export class ServiceMonitoringServiceClient { // Set up a dictionary of "inner API calls"; the core implementation // of calling the API is handled in `google-gax`, with this code // merely providing the destination and request information. - this._innerApiCalls = {}; + this.innerApiCalls = {}; } /** @@ -284,7 +292,7 @@ export class ServiceMonitoringServiceClient { ? (this._protos as protobuf.Root).lookupService( 'google.monitoring.v3.ServiceMonitoringService' ) - : // tslint:disable-next-line no-any + : // eslint-disable-next-line @typescript-eslint/no-explicit-any (this._protos as any).google.monitoring.v3.ServiceMonitoringService, this._opts ) as Promise<{[method: string]: Function}>; @@ -303,14 +311,14 @@ export class ServiceMonitoringServiceClient { 'updateServiceLevelObjective', 'deleteServiceLevelObjective', ]; - for (const methodName of serviceMonitoringServiceStubMethods) { - const innerCallPromise = this.serviceMonitoringServiceStub.then( + const callPromise = this.serviceMonitoringServiceStub.then( stub => (...args: Array<{}>) => { if (this._terminated) { return Promise.reject('The client has already been closed.'); } - return stub[methodName].apply(stub, args); + const func = stub[methodName]; + return func.apply(stub, args); }, (err: Error | null | undefined) => () => { throw err; @@ -318,20 +326,14 @@ export class ServiceMonitoringServiceClient { ); const apiCall = this._gaxModule.createApiCall( - innerCallPromise, + callPromise, this._defaults[methodName], - this._descriptors.page[methodName] || - this._descriptors.stream[methodName] || - this._descriptors.longrunning[methodName] + this.descriptors.page[methodName] || + this.descriptors.stream[methodName] || + this.descriptors.longrunning[methodName] ); - this._innerApiCalls[methodName] = ( - argument: {}, - callOptions?: CallOptions, - callback?: APICallback - ) => { - return apiCall(argument, callOptions, callback); - }; + this.innerApiCalls[methodName] = apiCall; } return this.serviceMonitoringServiceStub; @@ -392,22 +394,30 @@ export class ServiceMonitoringServiceClient { // -- Service calls -- // ------------------- createService( - request: protosTypes.google.monitoring.v3.ICreateServiceRequest, + request: protos.google.monitoring.v3.ICreateServiceRequest, options?: gax.CallOptions ): Promise< [ - protosTypes.google.monitoring.v3.IService, - protosTypes.google.monitoring.v3.ICreateServiceRequest | undefined, + protos.google.monitoring.v3.IService, + protos.google.monitoring.v3.ICreateServiceRequest | undefined, {} | undefined ] >; createService( - request: protosTypes.google.monitoring.v3.ICreateServiceRequest, + request: protos.google.monitoring.v3.ICreateServiceRequest, options: gax.CallOptions, callback: Callback< - protosTypes.google.monitoring.v3.IService, - protosTypes.google.monitoring.v3.ICreateServiceRequest | undefined, - {} | undefined + protos.google.monitoring.v3.IService, + protos.google.monitoring.v3.ICreateServiceRequest | null | undefined, + {} | null | undefined + > + ): void; + createService( + request: protos.google.monitoring.v3.ICreateServiceRequest, + callback: Callback< + protos.google.monitoring.v3.IService, + protos.google.monitoring.v3.ICreateServiceRequest | null | undefined, + {} | null | undefined > ): void; /** @@ -430,23 +440,23 @@ export class ServiceMonitoringServiceClient { * The promise has a method named "cancel" which cancels the ongoing API call. */ createService( - request: protosTypes.google.monitoring.v3.ICreateServiceRequest, + request: protos.google.monitoring.v3.ICreateServiceRequest, optionsOrCallback?: | gax.CallOptions | Callback< - protosTypes.google.monitoring.v3.IService, - protosTypes.google.monitoring.v3.ICreateServiceRequest | undefined, - {} | undefined + protos.google.monitoring.v3.IService, + protos.google.monitoring.v3.ICreateServiceRequest | null | undefined, + {} | null | undefined >, callback?: Callback< - protosTypes.google.monitoring.v3.IService, - protosTypes.google.monitoring.v3.ICreateServiceRequest | undefined, - {} | undefined + protos.google.monitoring.v3.IService, + protos.google.monitoring.v3.ICreateServiceRequest | null | undefined, + {} | null | undefined > ): Promise< [ - protosTypes.google.monitoring.v3.IService, - protosTypes.google.monitoring.v3.ICreateServiceRequest | undefined, + protos.google.monitoring.v3.IService, + protos.google.monitoring.v3.ICreateServiceRequest | undefined, {} | undefined ] > | void { @@ -467,25 +477,33 @@ export class ServiceMonitoringServiceClient { parent: request.parent || '', }); this.initialize(); - return this._innerApiCalls.createService(request, options, callback); + return this.innerApiCalls.createService(request, options, callback); } getService( - request: protosTypes.google.monitoring.v3.IGetServiceRequest, + request: protos.google.monitoring.v3.IGetServiceRequest, options?: gax.CallOptions ): Promise< [ - protosTypes.google.monitoring.v3.IService, - protosTypes.google.monitoring.v3.IGetServiceRequest | undefined, + protos.google.monitoring.v3.IService, + protos.google.monitoring.v3.IGetServiceRequest | undefined, {} | undefined ] >; getService( - request: protosTypes.google.monitoring.v3.IGetServiceRequest, + request: protos.google.monitoring.v3.IGetServiceRequest, options: gax.CallOptions, callback: Callback< - protosTypes.google.monitoring.v3.IService, - protosTypes.google.monitoring.v3.IGetServiceRequest | undefined, - {} | undefined + protos.google.monitoring.v3.IService, + protos.google.monitoring.v3.IGetServiceRequest | null | undefined, + {} | null | undefined + > + ): void; + getService( + request: protos.google.monitoring.v3.IGetServiceRequest, + callback: Callback< + protos.google.monitoring.v3.IService, + protos.google.monitoring.v3.IGetServiceRequest | null | undefined, + {} | null | undefined > ): void; /** @@ -503,23 +521,23 @@ export class ServiceMonitoringServiceClient { * The promise has a method named "cancel" which cancels the ongoing API call. */ getService( - request: protosTypes.google.monitoring.v3.IGetServiceRequest, + request: protos.google.monitoring.v3.IGetServiceRequest, optionsOrCallback?: | gax.CallOptions | Callback< - protosTypes.google.monitoring.v3.IService, - protosTypes.google.monitoring.v3.IGetServiceRequest | undefined, - {} | undefined + protos.google.monitoring.v3.IService, + protos.google.monitoring.v3.IGetServiceRequest | null | undefined, + {} | null | undefined >, callback?: Callback< - protosTypes.google.monitoring.v3.IService, - protosTypes.google.monitoring.v3.IGetServiceRequest | undefined, - {} | undefined + protos.google.monitoring.v3.IService, + protos.google.monitoring.v3.IGetServiceRequest | null | undefined, + {} | null | undefined > ): Promise< [ - protosTypes.google.monitoring.v3.IService, - protosTypes.google.monitoring.v3.IGetServiceRequest | undefined, + protos.google.monitoring.v3.IService, + protos.google.monitoring.v3.IGetServiceRequest | undefined, {} | undefined ] > | void { @@ -540,25 +558,33 @@ export class ServiceMonitoringServiceClient { name: request.name || '', }); this.initialize(); - return this._innerApiCalls.getService(request, options, callback); + return this.innerApiCalls.getService(request, options, callback); } updateService( - request: protosTypes.google.monitoring.v3.IUpdateServiceRequest, + request: protos.google.monitoring.v3.IUpdateServiceRequest, options?: gax.CallOptions ): Promise< [ - protosTypes.google.monitoring.v3.IService, - protosTypes.google.monitoring.v3.IUpdateServiceRequest | undefined, + protos.google.monitoring.v3.IService, + protos.google.monitoring.v3.IUpdateServiceRequest | undefined, {} | undefined ] >; updateService( - request: protosTypes.google.monitoring.v3.IUpdateServiceRequest, + request: protos.google.monitoring.v3.IUpdateServiceRequest, options: gax.CallOptions, callback: Callback< - protosTypes.google.monitoring.v3.IService, - protosTypes.google.monitoring.v3.IUpdateServiceRequest | undefined, - {} | undefined + protos.google.monitoring.v3.IService, + protos.google.monitoring.v3.IUpdateServiceRequest | null | undefined, + {} | null | undefined + > + ): void; + updateService( + request: protos.google.monitoring.v3.IUpdateServiceRequest, + callback: Callback< + protos.google.monitoring.v3.IService, + protos.google.monitoring.v3.IUpdateServiceRequest | null | undefined, + {} | null | undefined > ): void; /** @@ -578,23 +604,23 @@ export class ServiceMonitoringServiceClient { * The promise has a method named "cancel" which cancels the ongoing API call. */ updateService( - request: protosTypes.google.monitoring.v3.IUpdateServiceRequest, + request: protos.google.monitoring.v3.IUpdateServiceRequest, optionsOrCallback?: | gax.CallOptions | Callback< - protosTypes.google.monitoring.v3.IService, - protosTypes.google.monitoring.v3.IUpdateServiceRequest | undefined, - {} | undefined + protos.google.monitoring.v3.IService, + protos.google.monitoring.v3.IUpdateServiceRequest | null | undefined, + {} | null | undefined >, callback?: Callback< - protosTypes.google.monitoring.v3.IService, - protosTypes.google.monitoring.v3.IUpdateServiceRequest | undefined, - {} | undefined + protos.google.monitoring.v3.IService, + protos.google.monitoring.v3.IUpdateServiceRequest | null | undefined, + {} | null | undefined > ): Promise< [ - protosTypes.google.monitoring.v3.IService, - protosTypes.google.monitoring.v3.IUpdateServiceRequest | undefined, + protos.google.monitoring.v3.IService, + protos.google.monitoring.v3.IUpdateServiceRequest | undefined, {} | undefined ] > | void { @@ -615,25 +641,33 @@ export class ServiceMonitoringServiceClient { 'service.name': request.service!.name || '', }); this.initialize(); - return this._innerApiCalls.updateService(request, options, callback); + return this.innerApiCalls.updateService(request, options, callback); } deleteService( - request: protosTypes.google.monitoring.v3.IDeleteServiceRequest, + request: protos.google.monitoring.v3.IDeleteServiceRequest, options?: gax.CallOptions ): Promise< [ - protosTypes.google.protobuf.IEmpty, - protosTypes.google.monitoring.v3.IDeleteServiceRequest | undefined, + protos.google.protobuf.IEmpty, + protos.google.monitoring.v3.IDeleteServiceRequest | undefined, {} | undefined ] >; deleteService( - request: protosTypes.google.monitoring.v3.IDeleteServiceRequest, + request: protos.google.monitoring.v3.IDeleteServiceRequest, options: gax.CallOptions, callback: Callback< - protosTypes.google.protobuf.IEmpty, - protosTypes.google.monitoring.v3.IDeleteServiceRequest | undefined, - {} | undefined + protos.google.protobuf.IEmpty, + protos.google.monitoring.v3.IDeleteServiceRequest | null | undefined, + {} | null | undefined + > + ): void; + deleteService( + request: protos.google.monitoring.v3.IDeleteServiceRequest, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.monitoring.v3.IDeleteServiceRequest | null | undefined, + {} | null | undefined > ): void; /** @@ -651,23 +685,23 @@ export class ServiceMonitoringServiceClient { * The promise has a method named "cancel" which cancels the ongoing API call. */ deleteService( - request: protosTypes.google.monitoring.v3.IDeleteServiceRequest, + request: protos.google.monitoring.v3.IDeleteServiceRequest, optionsOrCallback?: | gax.CallOptions | Callback< - protosTypes.google.protobuf.IEmpty, - protosTypes.google.monitoring.v3.IDeleteServiceRequest | undefined, - {} | undefined + protos.google.protobuf.IEmpty, + protos.google.monitoring.v3.IDeleteServiceRequest | null | undefined, + {} | null | undefined >, callback?: Callback< - protosTypes.google.protobuf.IEmpty, - protosTypes.google.monitoring.v3.IDeleteServiceRequest | undefined, - {} | undefined + protos.google.protobuf.IEmpty, + protos.google.monitoring.v3.IDeleteServiceRequest | null | undefined, + {} | null | undefined > ): Promise< [ - protosTypes.google.protobuf.IEmpty, - protosTypes.google.monitoring.v3.IDeleteServiceRequest | undefined, + protos.google.protobuf.IEmpty, + protos.google.monitoring.v3.IDeleteServiceRequest | undefined, {} | undefined ] > | void { @@ -688,29 +722,40 @@ export class ServiceMonitoringServiceClient { name: request.name || '', }); this.initialize(); - return this._innerApiCalls.deleteService(request, options, callback); + return this.innerApiCalls.deleteService(request, options, callback); } createServiceLevelObjective( - request: protosTypes.google.monitoring.v3.ICreateServiceLevelObjectiveRequest, + request: protos.google.monitoring.v3.ICreateServiceLevelObjectiveRequest, options?: gax.CallOptions ): Promise< [ - protosTypes.google.monitoring.v3.IServiceLevelObjective, + protos.google.monitoring.v3.IServiceLevelObjective, ( - | protosTypes.google.monitoring.v3.ICreateServiceLevelObjectiveRequest + | protos.google.monitoring.v3.ICreateServiceLevelObjectiveRequest | undefined ), {} | undefined ] >; createServiceLevelObjective( - request: protosTypes.google.monitoring.v3.ICreateServiceLevelObjectiveRequest, + request: protos.google.monitoring.v3.ICreateServiceLevelObjectiveRequest, options: gax.CallOptions, callback: Callback< - protosTypes.google.monitoring.v3.IServiceLevelObjective, - | protosTypes.google.monitoring.v3.ICreateServiceLevelObjectiveRequest + protos.google.monitoring.v3.IServiceLevelObjective, + | protos.google.monitoring.v3.ICreateServiceLevelObjectiveRequest + | null | undefined, - {} | undefined + {} | null | undefined + > + ): void; + createServiceLevelObjective( + request: protos.google.monitoring.v3.ICreateServiceLevelObjectiveRequest, + callback: Callback< + protos.google.monitoring.v3.IServiceLevelObjective, + | protos.google.monitoring.v3.ICreateServiceLevelObjectiveRequest + | null + | undefined, + {} | null | undefined > ): void; /** @@ -736,26 +781,28 @@ export class ServiceMonitoringServiceClient { * The promise has a method named "cancel" which cancels the ongoing API call. */ createServiceLevelObjective( - request: protosTypes.google.monitoring.v3.ICreateServiceLevelObjectiveRequest, + request: protos.google.monitoring.v3.ICreateServiceLevelObjectiveRequest, optionsOrCallback?: | gax.CallOptions | Callback< - protosTypes.google.monitoring.v3.IServiceLevelObjective, - | protosTypes.google.monitoring.v3.ICreateServiceLevelObjectiveRequest + protos.google.monitoring.v3.IServiceLevelObjective, + | protos.google.monitoring.v3.ICreateServiceLevelObjectiveRequest + | null | undefined, - {} | undefined + {} | null | undefined >, callback?: Callback< - protosTypes.google.monitoring.v3.IServiceLevelObjective, - | protosTypes.google.monitoring.v3.ICreateServiceLevelObjectiveRequest + protos.google.monitoring.v3.IServiceLevelObjective, + | protos.google.monitoring.v3.ICreateServiceLevelObjectiveRequest + | null | undefined, - {} | undefined + {} | null | undefined > ): Promise< [ - protosTypes.google.monitoring.v3.IServiceLevelObjective, + protos.google.monitoring.v3.IServiceLevelObjective, ( - | protosTypes.google.monitoring.v3.ICreateServiceLevelObjectiveRequest + | protos.google.monitoring.v3.ICreateServiceLevelObjectiveRequest | undefined ), {} | undefined @@ -778,33 +825,41 @@ export class ServiceMonitoringServiceClient { parent: request.parent || '', }); this.initialize(); - return this._innerApiCalls.createServiceLevelObjective( + return this.innerApiCalls.createServiceLevelObjective( request, options, callback ); } getServiceLevelObjective( - request: protosTypes.google.monitoring.v3.IGetServiceLevelObjectiveRequest, + request: protos.google.monitoring.v3.IGetServiceLevelObjectiveRequest, options?: gax.CallOptions ): Promise< [ - protosTypes.google.monitoring.v3.IServiceLevelObjective, - ( - | protosTypes.google.monitoring.v3.IGetServiceLevelObjectiveRequest - | undefined - ), + protos.google.monitoring.v3.IServiceLevelObjective, + protos.google.monitoring.v3.IGetServiceLevelObjectiveRequest | undefined, {} | undefined ] >; getServiceLevelObjective( - request: protosTypes.google.monitoring.v3.IGetServiceLevelObjectiveRequest, + request: protos.google.monitoring.v3.IGetServiceLevelObjectiveRequest, options: gax.CallOptions, callback: Callback< - protosTypes.google.monitoring.v3.IServiceLevelObjective, - | protosTypes.google.monitoring.v3.IGetServiceLevelObjectiveRequest + protos.google.monitoring.v3.IServiceLevelObjective, + | protos.google.monitoring.v3.IGetServiceLevelObjectiveRequest + | null | undefined, - {} | undefined + {} | null | undefined + > + ): void; + getServiceLevelObjective( + request: protos.google.monitoring.v3.IGetServiceLevelObjectiveRequest, + callback: Callback< + protos.google.monitoring.v3.IServiceLevelObjective, + | protos.google.monitoring.v3.IGetServiceLevelObjectiveRequest + | null + | undefined, + {} | null | undefined > ): void; /** @@ -828,28 +883,27 @@ export class ServiceMonitoringServiceClient { * The promise has a method named "cancel" which cancels the ongoing API call. */ getServiceLevelObjective( - request: protosTypes.google.monitoring.v3.IGetServiceLevelObjectiveRequest, + request: protos.google.monitoring.v3.IGetServiceLevelObjectiveRequest, optionsOrCallback?: | gax.CallOptions | Callback< - protosTypes.google.monitoring.v3.IServiceLevelObjective, - | protosTypes.google.monitoring.v3.IGetServiceLevelObjectiveRequest + protos.google.monitoring.v3.IServiceLevelObjective, + | protos.google.monitoring.v3.IGetServiceLevelObjectiveRequest + | null | undefined, - {} | undefined + {} | null | undefined >, callback?: Callback< - protosTypes.google.monitoring.v3.IServiceLevelObjective, - | protosTypes.google.monitoring.v3.IGetServiceLevelObjectiveRequest + protos.google.monitoring.v3.IServiceLevelObjective, + | protos.google.monitoring.v3.IGetServiceLevelObjectiveRequest + | null | undefined, - {} | undefined + {} | null | undefined > ): Promise< [ - protosTypes.google.monitoring.v3.IServiceLevelObjective, - ( - | protosTypes.google.monitoring.v3.IGetServiceLevelObjectiveRequest - | undefined - ), + protos.google.monitoring.v3.IServiceLevelObjective, + protos.google.monitoring.v3.IGetServiceLevelObjectiveRequest | undefined, {} | undefined ] > | void { @@ -870,33 +924,44 @@ export class ServiceMonitoringServiceClient { name: request.name || '', }); this.initialize(); - return this._innerApiCalls.getServiceLevelObjective( + return this.innerApiCalls.getServiceLevelObjective( request, options, callback ); } updateServiceLevelObjective( - request: protosTypes.google.monitoring.v3.IUpdateServiceLevelObjectiveRequest, + request: protos.google.monitoring.v3.IUpdateServiceLevelObjectiveRequest, options?: gax.CallOptions ): Promise< [ - protosTypes.google.monitoring.v3.IServiceLevelObjective, + protos.google.monitoring.v3.IServiceLevelObjective, ( - | protosTypes.google.monitoring.v3.IUpdateServiceLevelObjectiveRequest + | protos.google.monitoring.v3.IUpdateServiceLevelObjectiveRequest | undefined ), {} | undefined ] >; updateServiceLevelObjective( - request: protosTypes.google.monitoring.v3.IUpdateServiceLevelObjectiveRequest, + request: protos.google.monitoring.v3.IUpdateServiceLevelObjectiveRequest, options: gax.CallOptions, callback: Callback< - protosTypes.google.monitoring.v3.IServiceLevelObjective, - | protosTypes.google.monitoring.v3.IUpdateServiceLevelObjectiveRequest + protos.google.monitoring.v3.IServiceLevelObjective, + | protos.google.monitoring.v3.IUpdateServiceLevelObjectiveRequest + | null | undefined, - {} | undefined + {} | null | undefined + > + ): void; + updateServiceLevelObjective( + request: protos.google.monitoring.v3.IUpdateServiceLevelObjectiveRequest, + callback: Callback< + protos.google.monitoring.v3.IServiceLevelObjective, + | protos.google.monitoring.v3.IUpdateServiceLevelObjectiveRequest + | null + | undefined, + {} | null | undefined > ): void; /** @@ -916,26 +981,28 @@ export class ServiceMonitoringServiceClient { * The promise has a method named "cancel" which cancels the ongoing API call. */ updateServiceLevelObjective( - request: protosTypes.google.monitoring.v3.IUpdateServiceLevelObjectiveRequest, + request: protos.google.monitoring.v3.IUpdateServiceLevelObjectiveRequest, optionsOrCallback?: | gax.CallOptions | Callback< - protosTypes.google.monitoring.v3.IServiceLevelObjective, - | protosTypes.google.monitoring.v3.IUpdateServiceLevelObjectiveRequest + protos.google.monitoring.v3.IServiceLevelObjective, + | protos.google.monitoring.v3.IUpdateServiceLevelObjectiveRequest + | null | undefined, - {} | undefined + {} | null | undefined >, callback?: Callback< - protosTypes.google.monitoring.v3.IServiceLevelObjective, - | protosTypes.google.monitoring.v3.IUpdateServiceLevelObjectiveRequest + protos.google.monitoring.v3.IServiceLevelObjective, + | protos.google.monitoring.v3.IUpdateServiceLevelObjectiveRequest + | null | undefined, - {} | undefined + {} | null | undefined > ): Promise< [ - protosTypes.google.monitoring.v3.IServiceLevelObjective, + protos.google.monitoring.v3.IServiceLevelObjective, ( - | protosTypes.google.monitoring.v3.IUpdateServiceLevelObjectiveRequest + | protos.google.monitoring.v3.IUpdateServiceLevelObjectiveRequest | undefined ), {} | undefined @@ -958,33 +1025,44 @@ export class ServiceMonitoringServiceClient { 'service_level_objective.name': request.serviceLevelObjective!.name || '', }); this.initialize(); - return this._innerApiCalls.updateServiceLevelObjective( + return this.innerApiCalls.updateServiceLevelObjective( request, options, callback ); } deleteServiceLevelObjective( - request: protosTypes.google.monitoring.v3.IDeleteServiceLevelObjectiveRequest, + request: protos.google.monitoring.v3.IDeleteServiceLevelObjectiveRequest, options?: gax.CallOptions ): Promise< [ - protosTypes.google.protobuf.IEmpty, + protos.google.protobuf.IEmpty, ( - | protosTypes.google.monitoring.v3.IDeleteServiceLevelObjectiveRequest + | protos.google.monitoring.v3.IDeleteServiceLevelObjectiveRequest | undefined ), {} | undefined ] >; deleteServiceLevelObjective( - request: protosTypes.google.monitoring.v3.IDeleteServiceLevelObjectiveRequest, + request: protos.google.monitoring.v3.IDeleteServiceLevelObjectiveRequest, options: gax.CallOptions, callback: Callback< - protosTypes.google.protobuf.IEmpty, - | protosTypes.google.monitoring.v3.IDeleteServiceLevelObjectiveRequest + protos.google.protobuf.IEmpty, + | protos.google.monitoring.v3.IDeleteServiceLevelObjectiveRequest + | null | undefined, - {} | undefined + {} | null | undefined + > + ): void; + deleteServiceLevelObjective( + request: protos.google.monitoring.v3.IDeleteServiceLevelObjectiveRequest, + callback: Callback< + protos.google.protobuf.IEmpty, + | protos.google.monitoring.v3.IDeleteServiceLevelObjectiveRequest + | null + | undefined, + {} | null | undefined > ): void; /** @@ -1003,26 +1081,28 @@ export class ServiceMonitoringServiceClient { * The promise has a method named "cancel" which cancels the ongoing API call. */ deleteServiceLevelObjective( - request: protosTypes.google.monitoring.v3.IDeleteServiceLevelObjectiveRequest, + request: protos.google.monitoring.v3.IDeleteServiceLevelObjectiveRequest, optionsOrCallback?: | gax.CallOptions | Callback< - protosTypes.google.protobuf.IEmpty, - | protosTypes.google.monitoring.v3.IDeleteServiceLevelObjectiveRequest + protos.google.protobuf.IEmpty, + | protos.google.monitoring.v3.IDeleteServiceLevelObjectiveRequest + | null | undefined, - {} | undefined + {} | null | undefined >, callback?: Callback< - protosTypes.google.protobuf.IEmpty, - | protosTypes.google.monitoring.v3.IDeleteServiceLevelObjectiveRequest + protos.google.protobuf.IEmpty, + | protos.google.monitoring.v3.IDeleteServiceLevelObjectiveRequest + | null | undefined, - {} | undefined + {} | null | undefined > ): Promise< [ - protosTypes.google.protobuf.IEmpty, + protos.google.protobuf.IEmpty, ( - | protosTypes.google.monitoring.v3.IDeleteServiceLevelObjectiveRequest + | protos.google.monitoring.v3.IDeleteServiceLevelObjectiveRequest | undefined ), {} | undefined @@ -1045,7 +1125,7 @@ export class ServiceMonitoringServiceClient { name: request.name || '', }); this.initialize(); - return this._innerApiCalls.deleteServiceLevelObjective( + return this.innerApiCalls.deleteServiceLevelObjective( request, options, callback @@ -1053,22 +1133,30 @@ export class ServiceMonitoringServiceClient { } listServices( - request: protosTypes.google.monitoring.v3.IListServicesRequest, + request: protos.google.monitoring.v3.IListServicesRequest, options?: gax.CallOptions ): Promise< [ - protosTypes.google.monitoring.v3.IService[], - protosTypes.google.monitoring.v3.IListServicesRequest | null, - protosTypes.google.monitoring.v3.IListServicesResponse + protos.google.monitoring.v3.IService[], + protos.google.monitoring.v3.IListServicesRequest | null, + protos.google.monitoring.v3.IListServicesResponse ] >; listServices( - request: protosTypes.google.monitoring.v3.IListServicesRequest, + request: protos.google.monitoring.v3.IListServicesRequest, options: gax.CallOptions, - callback: Callback< - protosTypes.google.monitoring.v3.IService[], - protosTypes.google.monitoring.v3.IListServicesRequest | null, - protosTypes.google.monitoring.v3.IListServicesResponse + callback: PaginationCallback< + protos.google.monitoring.v3.IListServicesRequest, + protos.google.monitoring.v3.IListServicesResponse | null | undefined, + protos.google.monitoring.v3.IService + > + ): void; + listServices( + request: protos.google.monitoring.v3.IListServicesRequest, + callback: PaginationCallback< + protos.google.monitoring.v3.IListServicesRequest, + protos.google.monitoring.v3.IListServicesResponse | null | undefined, + protos.google.monitoring.v3.IService > ): void; /** @@ -1121,24 +1209,24 @@ export class ServiceMonitoringServiceClient { * The promise has a method named "cancel" which cancels the ongoing API call. */ listServices( - request: protosTypes.google.monitoring.v3.IListServicesRequest, + request: protos.google.monitoring.v3.IListServicesRequest, optionsOrCallback?: | gax.CallOptions - | Callback< - protosTypes.google.monitoring.v3.IService[], - protosTypes.google.monitoring.v3.IListServicesRequest | null, - protosTypes.google.monitoring.v3.IListServicesResponse + | PaginationCallback< + protos.google.monitoring.v3.IListServicesRequest, + protos.google.monitoring.v3.IListServicesResponse | null | undefined, + protos.google.monitoring.v3.IService >, - callback?: Callback< - protosTypes.google.monitoring.v3.IService[], - protosTypes.google.monitoring.v3.IListServicesRequest | null, - protosTypes.google.monitoring.v3.IListServicesResponse + callback?: PaginationCallback< + protos.google.monitoring.v3.IListServicesRequest, + protos.google.monitoring.v3.IListServicesResponse | null | undefined, + protos.google.monitoring.v3.IService > ): Promise< [ - protosTypes.google.monitoring.v3.IService[], - protosTypes.google.monitoring.v3.IListServicesRequest | null, - protosTypes.google.monitoring.v3.IListServicesResponse + protos.google.monitoring.v3.IService[], + protos.google.monitoring.v3.IListServicesRequest | null, + protos.google.monitoring.v3.IListServicesResponse ] > | void { request = request || {}; @@ -1158,7 +1246,7 @@ export class ServiceMonitoringServiceClient { parent: request.parent || '', }); this.initialize(); - return this._innerApiCalls.listServices(request, options, callback); + return this.innerApiCalls.listServices(request, options, callback); } /** @@ -1208,7 +1296,7 @@ export class ServiceMonitoringServiceClient { * An object stream which emits an object representing [Service]{@link google.monitoring.v3.Service} on 'data' event. */ listServicesStream( - request?: protosTypes.google.monitoring.v3.IListServicesRequest, + request?: protos.google.monitoring.v3.IListServicesRequest, options?: gax.CallOptions ): Transform { request = request || {}; @@ -1222,29 +1310,102 @@ export class ServiceMonitoringServiceClient { }); const callSettings = new gax.CallSettings(options); this.initialize(); - return this._descriptors.page.listServices.createStream( - this._innerApiCalls.listServices as gax.GaxCall, + return this.descriptors.page.listServices.createStream( + this.innerApiCalls.listServices as gax.GaxCall, request, callSettings ); } + + /** + * Equivalent to {@link listServices}, 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. Resource name of the parent `Workspace`. + * Of the form `projects/{project_id}`. + * @param {string} request.filter + * A filter specifying what `Service`s to return. The filter currently + * supports the following fields: + * + * - `identifier_case` + * - `app_engine.module_id` + * - `cloud_endpoints.service` + * - `cluster_istio.location` + * - `cluster_istio.cluster_name` + * - `cluster_istio.service_namespace` + * - `cluster_istio.service_name` + * + * `identifier_case` refers to which option in the identifier oneof is + * populated. For example, the filter `identifier_case = "CUSTOM"` would match + * all services with a value for the `custom` field. Valid options are + * "CUSTOM", "APP_ENGINE", "CLOUD_ENDPOINTS", and "CLUSTER_ISTIO". + * @param {number} request.pageSize + * A non-negative number that is the maximum number of results to return. + * When 0, use default page size. + * @param {string} request.pageToken + * If this field is not empty then it must contain the `nextPageToken` value + * returned by a previous call to this method. Using this field causes the + * method to return additional results from the previous method call. + * @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. + */ + listServicesAsync( + request?: protos.google.monitoring.v3.IListServicesRequest, + options?: gax.CallOptions + ): AsyncIterable { + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + parent: request.parent || '', + }); + options = options || {}; + const callSettings = new gax.CallSettings(options); + this.initialize(); + return this.descriptors.page.listServices.asyncIterate( + this.innerApiCalls['listServices'] as GaxCall, + (request as unknown) as RequestType, + callSettings + ) as AsyncIterable; + } listServiceLevelObjectives( - request: protosTypes.google.monitoring.v3.IListServiceLevelObjectivesRequest, + request: protos.google.monitoring.v3.IListServiceLevelObjectivesRequest, options?: gax.CallOptions ): Promise< [ - protosTypes.google.monitoring.v3.IServiceLevelObjective[], - protosTypes.google.monitoring.v3.IListServiceLevelObjectivesRequest | null, - protosTypes.google.monitoring.v3.IListServiceLevelObjectivesResponse + protos.google.monitoring.v3.IServiceLevelObjective[], + protos.google.monitoring.v3.IListServiceLevelObjectivesRequest | null, + protos.google.monitoring.v3.IListServiceLevelObjectivesResponse ] >; listServiceLevelObjectives( - request: protosTypes.google.monitoring.v3.IListServiceLevelObjectivesRequest, + request: protos.google.monitoring.v3.IListServiceLevelObjectivesRequest, options: gax.CallOptions, - callback: Callback< - protosTypes.google.monitoring.v3.IServiceLevelObjective[], - protosTypes.google.monitoring.v3.IListServiceLevelObjectivesRequest | null, - protosTypes.google.monitoring.v3.IListServiceLevelObjectivesResponse + callback: PaginationCallback< + protos.google.monitoring.v3.IListServiceLevelObjectivesRequest, + | protos.google.monitoring.v3.IListServiceLevelObjectivesResponse + | null + | undefined, + protos.google.monitoring.v3.IServiceLevelObjective + > + ): void; + listServiceLevelObjectives( + request: protos.google.monitoring.v3.IListServiceLevelObjectivesRequest, + callback: PaginationCallback< + protos.google.monitoring.v3.IListServiceLevelObjectivesRequest, + | protos.google.monitoring.v3.IListServiceLevelObjectivesResponse + | null + | undefined, + protos.google.monitoring.v3.IServiceLevelObjective > ): void; /** @@ -1288,24 +1449,28 @@ export class ServiceMonitoringServiceClient { * The promise has a method named "cancel" which cancels the ongoing API call. */ listServiceLevelObjectives( - request: protosTypes.google.monitoring.v3.IListServiceLevelObjectivesRequest, + request: protos.google.monitoring.v3.IListServiceLevelObjectivesRequest, optionsOrCallback?: | gax.CallOptions - | Callback< - protosTypes.google.monitoring.v3.IServiceLevelObjective[], - protosTypes.google.monitoring.v3.IListServiceLevelObjectivesRequest | null, - protosTypes.google.monitoring.v3.IListServiceLevelObjectivesResponse + | PaginationCallback< + protos.google.monitoring.v3.IListServiceLevelObjectivesRequest, + | protos.google.monitoring.v3.IListServiceLevelObjectivesResponse + | null + | undefined, + protos.google.monitoring.v3.IServiceLevelObjective >, - callback?: Callback< - protosTypes.google.monitoring.v3.IServiceLevelObjective[], - protosTypes.google.monitoring.v3.IListServiceLevelObjectivesRequest | null, - protosTypes.google.monitoring.v3.IListServiceLevelObjectivesResponse + callback?: PaginationCallback< + protos.google.monitoring.v3.IListServiceLevelObjectivesRequest, + | protos.google.monitoring.v3.IListServiceLevelObjectivesResponse + | null + | undefined, + protos.google.monitoring.v3.IServiceLevelObjective > ): Promise< [ - protosTypes.google.monitoring.v3.IServiceLevelObjective[], - protosTypes.google.monitoring.v3.IListServiceLevelObjectivesRequest | null, - protosTypes.google.monitoring.v3.IListServiceLevelObjectivesResponse + protos.google.monitoring.v3.IServiceLevelObjective[], + protos.google.monitoring.v3.IListServiceLevelObjectivesRequest | null, + protos.google.monitoring.v3.IListServiceLevelObjectivesResponse ] > | void { request = request || {}; @@ -1325,7 +1490,7 @@ export class ServiceMonitoringServiceClient { parent: request.parent || '', }); this.initialize(); - return this._innerApiCalls.listServiceLevelObjectives( + return this.innerApiCalls.listServiceLevelObjectives( request, options, callback @@ -1370,7 +1535,7 @@ export class ServiceMonitoringServiceClient { * An object stream which emits an object representing [ServiceLevelObjective]{@link google.monitoring.v3.ServiceLevelObjective} on 'data' event. */ listServiceLevelObjectivesStream( - request?: protosTypes.google.monitoring.v3.IListServiceLevelObjectivesRequest, + request?: protos.google.monitoring.v3.IListServiceLevelObjectivesRequest, options?: gax.CallOptions ): Transform { request = request || {}; @@ -1384,12 +1549,64 @@ export class ServiceMonitoringServiceClient { }); const callSettings = new gax.CallSettings(options); this.initialize(); - return this._descriptors.page.listServiceLevelObjectives.createStream( - this._innerApiCalls.listServiceLevelObjectives as gax.GaxCall, + return this.descriptors.page.listServiceLevelObjectives.createStream( + this.innerApiCalls.listServiceLevelObjectives as gax.GaxCall, request, callSettings ); } + + /** + * Equivalent to {@link listServiceLevelObjectives}, 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. Resource name of the parent `Service`. + * Of the form `projects/{project_id}/services/{service_id}`. + * @param {string} request.filter + * A filter specifying what `ServiceLevelObjective`s to return. + * @param {number} request.pageSize + * A non-negative number that is the maximum number of results to return. + * When 0, use default page size. + * @param {string} request.pageToken + * If this field is not empty then it must contain the `nextPageToken` value + * returned by a previous call to this method. Using this field causes the + * method to return additional results from the previous method call. + * @param {google.monitoring.v3.ServiceLevelObjective.View} request.view + * View of the `ServiceLevelObjective`s to return. If `DEFAULT`, return each + * `ServiceLevelObjective` as originally defined. If `EXPLICIT` and the + * `ServiceLevelObjective` is defined in terms of a `BasicSli`, replace the + * `BasicSli` with a `RequestBasedSli` spelling out how the SLI is computed. + * @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. + */ + listServiceLevelObjectivesAsync( + request?: protos.google.monitoring.v3.IListServiceLevelObjectivesRequest, + options?: gax.CallOptions + ): AsyncIterable { + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + parent: request.parent || '', + }); + options = options || {}; + const callSettings = new gax.CallSettings(options); + this.initialize(); + return this.descriptors.page.listServiceLevelObjectives.asyncIterate( + this.innerApiCalls['listServiceLevelObjectives'] as GaxCall, + (request as unknown) as RequestType, + callSettings + ) as AsyncIterable; + } // -------------------- // -- Path templates -- // -------------------- @@ -1402,8 +1619,8 @@ export class ServiceMonitoringServiceClient { * @returns {string} Resource name string. */ folderAlertPolicyPath(folder: string, alertPolicy: string) { - return this._pathTemplates.folderAlertPolicyPathTemplate.render({ - folder, + return this.pathTemplates.folderAlertPolicyPathTemplate.render({ + folder: folder, alert_policy: alertPolicy, }); } @@ -1416,7 +1633,7 @@ export class ServiceMonitoringServiceClient { * @returns {string} A string representing the folder. */ matchFolderFromFolderAlertPolicyName(folderAlertPolicyName: string) { - return this._pathTemplates.folderAlertPolicyPathTemplate.match( + return this.pathTemplates.folderAlertPolicyPathTemplate.match( folderAlertPolicyName ).folder; } @@ -1429,7 +1646,7 @@ export class ServiceMonitoringServiceClient { * @returns {string} A string representing the alert_policy. */ matchAlertPolicyFromFolderAlertPolicyName(folderAlertPolicyName: string) { - return this._pathTemplates.folderAlertPolicyPathTemplate.match( + return this.pathTemplates.folderAlertPolicyPathTemplate.match( folderAlertPolicyName ).alert_policy; } @@ -1447,10 +1664,10 @@ export class ServiceMonitoringServiceClient { alertPolicy: string, condition: string ) { - return this._pathTemplates.folderAlertPolicyConditionPathTemplate.render({ - folder, + return this.pathTemplates.folderAlertPolicyConditionPathTemplate.render({ + folder: folder, alert_policy: alertPolicy, - condition, + condition: condition, }); } @@ -1464,7 +1681,7 @@ export class ServiceMonitoringServiceClient { matchFolderFromFolderAlertPolicyConditionName( folderAlertPolicyConditionName: string ) { - return this._pathTemplates.folderAlertPolicyConditionPathTemplate.match( + return this.pathTemplates.folderAlertPolicyConditionPathTemplate.match( folderAlertPolicyConditionName ).folder; } @@ -1479,7 +1696,7 @@ export class ServiceMonitoringServiceClient { matchAlertPolicyFromFolderAlertPolicyConditionName( folderAlertPolicyConditionName: string ) { - return this._pathTemplates.folderAlertPolicyConditionPathTemplate.match( + return this.pathTemplates.folderAlertPolicyConditionPathTemplate.match( folderAlertPolicyConditionName ).alert_policy; } @@ -1494,7 +1711,7 @@ export class ServiceMonitoringServiceClient { matchConditionFromFolderAlertPolicyConditionName( folderAlertPolicyConditionName: string ) { - return this._pathTemplates.folderAlertPolicyConditionPathTemplate.match( + return this.pathTemplates.folderAlertPolicyConditionPathTemplate.match( folderAlertPolicyConditionName ).condition; } @@ -1507,8 +1724,8 @@ export class ServiceMonitoringServiceClient { * @returns {string} Resource name string. */ folderChannelDescriptorPath(folder: string, channelDescriptor: string) { - return this._pathTemplates.folderChannelDescriptorPathTemplate.render({ - folder, + return this.pathTemplates.folderChannelDescriptorPathTemplate.render({ + folder: folder, channel_descriptor: channelDescriptor, }); } @@ -1523,7 +1740,7 @@ export class ServiceMonitoringServiceClient { matchFolderFromFolderChannelDescriptorName( folderChannelDescriptorName: string ) { - return this._pathTemplates.folderChannelDescriptorPathTemplate.match( + return this.pathTemplates.folderChannelDescriptorPathTemplate.match( folderChannelDescriptorName ).folder; } @@ -1538,7 +1755,7 @@ export class ServiceMonitoringServiceClient { matchChannelDescriptorFromFolderChannelDescriptorName( folderChannelDescriptorName: string ) { - return this._pathTemplates.folderChannelDescriptorPathTemplate.match( + return this.pathTemplates.folderChannelDescriptorPathTemplate.match( folderChannelDescriptorName ).channel_descriptor; } @@ -1551,9 +1768,9 @@ export class ServiceMonitoringServiceClient { * @returns {string} Resource name string. */ folderGroupPath(folder: string, group: string) { - return this._pathTemplates.folderGroupPathTemplate.render({ - folder, - group, + return this.pathTemplates.folderGroupPathTemplate.render({ + folder: folder, + group: group, }); } @@ -1565,7 +1782,7 @@ export class ServiceMonitoringServiceClient { * @returns {string} A string representing the folder. */ matchFolderFromFolderGroupName(folderGroupName: string) { - return this._pathTemplates.folderGroupPathTemplate.match(folderGroupName) + return this.pathTemplates.folderGroupPathTemplate.match(folderGroupName) .folder; } @@ -1577,7 +1794,7 @@ export class ServiceMonitoringServiceClient { * @returns {string} A string representing the group. */ matchGroupFromFolderGroupName(folderGroupName: string) { - return this._pathTemplates.folderGroupPathTemplate.match(folderGroupName) + return this.pathTemplates.folderGroupPathTemplate.match(folderGroupName) .group; } @@ -1589,8 +1806,8 @@ export class ServiceMonitoringServiceClient { * @returns {string} Resource name string. */ folderNotificationChannelPath(folder: string, notificationChannel: string) { - return this._pathTemplates.folderNotificationChannelPathTemplate.render({ - folder, + return this.pathTemplates.folderNotificationChannelPathTemplate.render({ + folder: folder, notification_channel: notificationChannel, }); } @@ -1605,7 +1822,7 @@ export class ServiceMonitoringServiceClient { matchFolderFromFolderNotificationChannelName( folderNotificationChannelName: string ) { - return this._pathTemplates.folderNotificationChannelPathTemplate.match( + return this.pathTemplates.folderNotificationChannelPathTemplate.match( folderNotificationChannelName ).folder; } @@ -1620,7 +1837,7 @@ export class ServiceMonitoringServiceClient { matchNotificationChannelFromFolderNotificationChannelName( folderNotificationChannelName: string ) { - return this._pathTemplates.folderNotificationChannelPathTemplate.match( + return this.pathTemplates.folderNotificationChannelPathTemplate.match( folderNotificationChannelName ).notification_channel; } @@ -1633,9 +1850,9 @@ export class ServiceMonitoringServiceClient { * @returns {string} Resource name string. */ folderServicePath(folder: string, service: string) { - return this._pathTemplates.folderServicePathTemplate.render({ - folder, - service, + return this.pathTemplates.folderServicePathTemplate.render({ + folder: folder, + service: service, }); } @@ -1647,9 +1864,8 @@ export class ServiceMonitoringServiceClient { * @returns {string} A string representing the folder. */ matchFolderFromFolderServiceName(folderServiceName: string) { - return this._pathTemplates.folderServicePathTemplate.match( - folderServiceName - ).folder; + return this.pathTemplates.folderServicePathTemplate.match(folderServiceName) + .folder; } /** @@ -1660,9 +1876,8 @@ export class ServiceMonitoringServiceClient { * @returns {string} A string representing the service. */ matchServiceFromFolderServiceName(folderServiceName: string) { - return this._pathTemplates.folderServicePathTemplate.match( - folderServiceName - ).service; + return this.pathTemplates.folderServicePathTemplate.match(folderServiceName) + .service; } /** @@ -1678,10 +1893,10 @@ export class ServiceMonitoringServiceClient { service: string, serviceLevelObjective: string ) { - return this._pathTemplates.folderServiceServiceLevelObjectivePathTemplate.render( + return this.pathTemplates.folderServiceServiceLevelObjectivePathTemplate.render( { - folder, - service, + folder: folder, + service: service, service_level_objective: serviceLevelObjective, } ); @@ -1697,7 +1912,7 @@ export class ServiceMonitoringServiceClient { matchFolderFromFolderServiceServiceLevelObjectiveName( folderServiceServiceLevelObjectiveName: string ) { - return this._pathTemplates.folderServiceServiceLevelObjectivePathTemplate.match( + return this.pathTemplates.folderServiceServiceLevelObjectivePathTemplate.match( folderServiceServiceLevelObjectiveName ).folder; } @@ -1712,7 +1927,7 @@ export class ServiceMonitoringServiceClient { matchServiceFromFolderServiceServiceLevelObjectiveName( folderServiceServiceLevelObjectiveName: string ) { - return this._pathTemplates.folderServiceServiceLevelObjectivePathTemplate.match( + return this.pathTemplates.folderServiceServiceLevelObjectivePathTemplate.match( folderServiceServiceLevelObjectiveName ).service; } @@ -1727,7 +1942,7 @@ export class ServiceMonitoringServiceClient { matchServiceLevelObjectiveFromFolderServiceServiceLevelObjectiveName( folderServiceServiceLevelObjectiveName: string ) { - return this._pathTemplates.folderServiceServiceLevelObjectivePathTemplate.match( + return this.pathTemplates.folderServiceServiceLevelObjectivePathTemplate.match( folderServiceServiceLevelObjectiveName ).service_level_objective; } @@ -1740,8 +1955,8 @@ export class ServiceMonitoringServiceClient { * @returns {string} Resource name string. */ folderUptimeCheckConfigPath(folder: string, uptimeCheckConfig: string) { - return this._pathTemplates.folderUptimeCheckConfigPathTemplate.render({ - folder, + return this.pathTemplates.folderUptimeCheckConfigPathTemplate.render({ + folder: folder, uptime_check_config: uptimeCheckConfig, }); } @@ -1756,7 +1971,7 @@ export class ServiceMonitoringServiceClient { matchFolderFromFolderUptimeCheckConfigName( folderUptimeCheckConfigName: string ) { - return this._pathTemplates.folderUptimeCheckConfigPathTemplate.match( + return this.pathTemplates.folderUptimeCheckConfigPathTemplate.match( folderUptimeCheckConfigName ).folder; } @@ -1771,7 +1986,7 @@ export class ServiceMonitoringServiceClient { matchUptimeCheckConfigFromFolderUptimeCheckConfigName( folderUptimeCheckConfigName: string ) { - return this._pathTemplates.folderUptimeCheckConfigPathTemplate.match( + return this.pathTemplates.folderUptimeCheckConfigPathTemplate.match( folderUptimeCheckConfigName ).uptime_check_config; } @@ -1784,8 +1999,8 @@ export class ServiceMonitoringServiceClient { * @returns {string} Resource name string. */ organizationAlertPolicyPath(organization: string, alertPolicy: string) { - return this._pathTemplates.organizationAlertPolicyPathTemplate.render({ - organization, + return this.pathTemplates.organizationAlertPolicyPathTemplate.render({ + organization: organization, alert_policy: alertPolicy, }); } @@ -1800,7 +2015,7 @@ export class ServiceMonitoringServiceClient { matchOrganizationFromOrganizationAlertPolicyName( organizationAlertPolicyName: string ) { - return this._pathTemplates.organizationAlertPolicyPathTemplate.match( + return this.pathTemplates.organizationAlertPolicyPathTemplate.match( organizationAlertPolicyName ).organization; } @@ -1815,7 +2030,7 @@ export class ServiceMonitoringServiceClient { matchAlertPolicyFromOrganizationAlertPolicyName( organizationAlertPolicyName: string ) { - return this._pathTemplates.organizationAlertPolicyPathTemplate.match( + return this.pathTemplates.organizationAlertPolicyPathTemplate.match( organizationAlertPolicyName ).alert_policy; } @@ -1833,11 +2048,11 @@ export class ServiceMonitoringServiceClient { alertPolicy: string, condition: string ) { - return this._pathTemplates.organizationAlertPolicyConditionPathTemplate.render( + return this.pathTemplates.organizationAlertPolicyConditionPathTemplate.render( { - organization, + organization: organization, alert_policy: alertPolicy, - condition, + condition: condition, } ); } @@ -1852,7 +2067,7 @@ export class ServiceMonitoringServiceClient { matchOrganizationFromOrganizationAlertPolicyConditionName( organizationAlertPolicyConditionName: string ) { - return this._pathTemplates.organizationAlertPolicyConditionPathTemplate.match( + return this.pathTemplates.organizationAlertPolicyConditionPathTemplate.match( organizationAlertPolicyConditionName ).organization; } @@ -1867,7 +2082,7 @@ export class ServiceMonitoringServiceClient { matchAlertPolicyFromOrganizationAlertPolicyConditionName( organizationAlertPolicyConditionName: string ) { - return this._pathTemplates.organizationAlertPolicyConditionPathTemplate.match( + return this.pathTemplates.organizationAlertPolicyConditionPathTemplate.match( organizationAlertPolicyConditionName ).alert_policy; } @@ -1882,7 +2097,7 @@ export class ServiceMonitoringServiceClient { matchConditionFromOrganizationAlertPolicyConditionName( organizationAlertPolicyConditionName: string ) { - return this._pathTemplates.organizationAlertPolicyConditionPathTemplate.match( + return this.pathTemplates.organizationAlertPolicyConditionPathTemplate.match( organizationAlertPolicyConditionName ).condition; } @@ -1898,12 +2113,10 @@ export class ServiceMonitoringServiceClient { organization: string, channelDescriptor: string ) { - return this._pathTemplates.organizationChannelDescriptorPathTemplate.render( - { - organization, - channel_descriptor: channelDescriptor, - } - ); + return this.pathTemplates.organizationChannelDescriptorPathTemplate.render({ + organization: organization, + channel_descriptor: channelDescriptor, + }); } /** @@ -1916,7 +2129,7 @@ export class ServiceMonitoringServiceClient { matchOrganizationFromOrganizationChannelDescriptorName( organizationChannelDescriptorName: string ) { - return this._pathTemplates.organizationChannelDescriptorPathTemplate.match( + return this.pathTemplates.organizationChannelDescriptorPathTemplate.match( organizationChannelDescriptorName ).organization; } @@ -1931,7 +2144,7 @@ export class ServiceMonitoringServiceClient { matchChannelDescriptorFromOrganizationChannelDescriptorName( organizationChannelDescriptorName: string ) { - return this._pathTemplates.organizationChannelDescriptorPathTemplate.match( + return this.pathTemplates.organizationChannelDescriptorPathTemplate.match( organizationChannelDescriptorName ).channel_descriptor; } @@ -1944,9 +2157,9 @@ export class ServiceMonitoringServiceClient { * @returns {string} Resource name string. */ organizationGroupPath(organization: string, group: string) { - return this._pathTemplates.organizationGroupPathTemplate.render({ - organization, - group, + return this.pathTemplates.organizationGroupPathTemplate.render({ + organization: organization, + group: group, }); } @@ -1958,7 +2171,7 @@ export class ServiceMonitoringServiceClient { * @returns {string} A string representing the organization. */ matchOrganizationFromOrganizationGroupName(organizationGroupName: string) { - return this._pathTemplates.organizationGroupPathTemplate.match( + return this.pathTemplates.organizationGroupPathTemplate.match( organizationGroupName ).organization; } @@ -1971,7 +2184,7 @@ export class ServiceMonitoringServiceClient { * @returns {string} A string representing the group. */ matchGroupFromOrganizationGroupName(organizationGroupName: string) { - return this._pathTemplates.organizationGroupPathTemplate.match( + return this.pathTemplates.organizationGroupPathTemplate.match( organizationGroupName ).group; } @@ -1987,9 +2200,9 @@ export class ServiceMonitoringServiceClient { organization: string, notificationChannel: string ) { - return this._pathTemplates.organizationNotificationChannelPathTemplate.render( + return this.pathTemplates.organizationNotificationChannelPathTemplate.render( { - organization, + organization: organization, notification_channel: notificationChannel, } ); @@ -2005,7 +2218,7 @@ export class ServiceMonitoringServiceClient { matchOrganizationFromOrganizationNotificationChannelName( organizationNotificationChannelName: string ) { - return this._pathTemplates.organizationNotificationChannelPathTemplate.match( + return this.pathTemplates.organizationNotificationChannelPathTemplate.match( organizationNotificationChannelName ).organization; } @@ -2020,7 +2233,7 @@ export class ServiceMonitoringServiceClient { matchNotificationChannelFromOrganizationNotificationChannelName( organizationNotificationChannelName: string ) { - return this._pathTemplates.organizationNotificationChannelPathTemplate.match( + return this.pathTemplates.organizationNotificationChannelPathTemplate.match( organizationNotificationChannelName ).notification_channel; } @@ -2033,9 +2246,9 @@ export class ServiceMonitoringServiceClient { * @returns {string} Resource name string. */ organizationServicePath(organization: string, service: string) { - return this._pathTemplates.organizationServicePathTemplate.render({ - organization, - service, + return this.pathTemplates.organizationServicePathTemplate.render({ + organization: organization, + service: service, }); } @@ -2049,7 +2262,7 @@ export class ServiceMonitoringServiceClient { matchOrganizationFromOrganizationServiceName( organizationServiceName: string ) { - return this._pathTemplates.organizationServicePathTemplate.match( + return this.pathTemplates.organizationServicePathTemplate.match( organizationServiceName ).organization; } @@ -2062,7 +2275,7 @@ export class ServiceMonitoringServiceClient { * @returns {string} A string representing the service. */ matchServiceFromOrganizationServiceName(organizationServiceName: string) { - return this._pathTemplates.organizationServicePathTemplate.match( + return this.pathTemplates.organizationServicePathTemplate.match( organizationServiceName ).service; } @@ -2080,10 +2293,10 @@ export class ServiceMonitoringServiceClient { service: string, serviceLevelObjective: string ) { - return this._pathTemplates.organizationServiceServiceLevelObjectivePathTemplate.render( + return this.pathTemplates.organizationServiceServiceLevelObjectivePathTemplate.render( { - organization, - service, + organization: organization, + service: service, service_level_objective: serviceLevelObjective, } ); @@ -2099,7 +2312,7 @@ export class ServiceMonitoringServiceClient { matchOrganizationFromOrganizationServiceServiceLevelObjectiveName( organizationServiceServiceLevelObjectiveName: string ) { - return this._pathTemplates.organizationServiceServiceLevelObjectivePathTemplate.match( + return this.pathTemplates.organizationServiceServiceLevelObjectivePathTemplate.match( organizationServiceServiceLevelObjectiveName ).organization; } @@ -2114,7 +2327,7 @@ export class ServiceMonitoringServiceClient { matchServiceFromOrganizationServiceServiceLevelObjectiveName( organizationServiceServiceLevelObjectiveName: string ) { - return this._pathTemplates.organizationServiceServiceLevelObjectivePathTemplate.match( + return this.pathTemplates.organizationServiceServiceLevelObjectivePathTemplate.match( organizationServiceServiceLevelObjectiveName ).service; } @@ -2129,7 +2342,7 @@ export class ServiceMonitoringServiceClient { matchServiceLevelObjectiveFromOrganizationServiceServiceLevelObjectiveName( organizationServiceServiceLevelObjectiveName: string ) { - return this._pathTemplates.organizationServiceServiceLevelObjectivePathTemplate.match( + return this.pathTemplates.organizationServiceServiceLevelObjectivePathTemplate.match( organizationServiceServiceLevelObjectiveName ).service_level_objective; } @@ -2145,12 +2358,10 @@ export class ServiceMonitoringServiceClient { organization: string, uptimeCheckConfig: string ) { - return this._pathTemplates.organizationUptimeCheckConfigPathTemplate.render( - { - organization, - uptime_check_config: uptimeCheckConfig, - } - ); + return this.pathTemplates.organizationUptimeCheckConfigPathTemplate.render({ + organization: organization, + uptime_check_config: uptimeCheckConfig, + }); } /** @@ -2163,7 +2374,7 @@ export class ServiceMonitoringServiceClient { matchOrganizationFromOrganizationUptimeCheckConfigName( organizationUptimeCheckConfigName: string ) { - return this._pathTemplates.organizationUptimeCheckConfigPathTemplate.match( + return this.pathTemplates.organizationUptimeCheckConfigPathTemplate.match( organizationUptimeCheckConfigName ).organization; } @@ -2178,7 +2389,7 @@ export class ServiceMonitoringServiceClient { matchUptimeCheckConfigFromOrganizationUptimeCheckConfigName( organizationUptimeCheckConfigName: string ) { - return this._pathTemplates.organizationUptimeCheckConfigPathTemplate.match( + return this.pathTemplates.organizationUptimeCheckConfigPathTemplate.match( organizationUptimeCheckConfigName ).uptime_check_config; } @@ -2190,8 +2401,8 @@ export class ServiceMonitoringServiceClient { * @returns {string} Resource name string. */ projectPath(project: string) { - return this._pathTemplates.projectPathTemplate.render({ - project, + return this.pathTemplates.projectPathTemplate.render({ + project: project, }); } @@ -2203,7 +2414,7 @@ export class ServiceMonitoringServiceClient { * @returns {string} A string representing the project. */ matchProjectFromProjectName(projectName: string) { - return this._pathTemplates.projectPathTemplate.match(projectName).project; + return this.pathTemplates.projectPathTemplate.match(projectName).project; } /** @@ -2214,8 +2425,8 @@ export class ServiceMonitoringServiceClient { * @returns {string} Resource name string. */ projectAlertPolicyPath(project: string, alertPolicy: string) { - return this._pathTemplates.projectAlertPolicyPathTemplate.render({ - project, + return this.pathTemplates.projectAlertPolicyPathTemplate.render({ + project: project, alert_policy: alertPolicy, }); } @@ -2228,7 +2439,7 @@ export class ServiceMonitoringServiceClient { * @returns {string} A string representing the project. */ matchProjectFromProjectAlertPolicyName(projectAlertPolicyName: string) { - return this._pathTemplates.projectAlertPolicyPathTemplate.match( + return this.pathTemplates.projectAlertPolicyPathTemplate.match( projectAlertPolicyName ).project; } @@ -2241,7 +2452,7 @@ export class ServiceMonitoringServiceClient { * @returns {string} A string representing the alert_policy. */ matchAlertPolicyFromProjectAlertPolicyName(projectAlertPolicyName: string) { - return this._pathTemplates.projectAlertPolicyPathTemplate.match( + return this.pathTemplates.projectAlertPolicyPathTemplate.match( projectAlertPolicyName ).alert_policy; } @@ -2259,10 +2470,10 @@ export class ServiceMonitoringServiceClient { alertPolicy: string, condition: string ) { - return this._pathTemplates.projectAlertPolicyConditionPathTemplate.render({ - project, + return this.pathTemplates.projectAlertPolicyConditionPathTemplate.render({ + project: project, alert_policy: alertPolicy, - condition, + condition: condition, }); } @@ -2276,7 +2487,7 @@ export class ServiceMonitoringServiceClient { matchProjectFromProjectAlertPolicyConditionName( projectAlertPolicyConditionName: string ) { - return this._pathTemplates.projectAlertPolicyConditionPathTemplate.match( + return this.pathTemplates.projectAlertPolicyConditionPathTemplate.match( projectAlertPolicyConditionName ).project; } @@ -2291,7 +2502,7 @@ export class ServiceMonitoringServiceClient { matchAlertPolicyFromProjectAlertPolicyConditionName( projectAlertPolicyConditionName: string ) { - return this._pathTemplates.projectAlertPolicyConditionPathTemplate.match( + return this.pathTemplates.projectAlertPolicyConditionPathTemplate.match( projectAlertPolicyConditionName ).alert_policy; } @@ -2306,7 +2517,7 @@ export class ServiceMonitoringServiceClient { matchConditionFromProjectAlertPolicyConditionName( projectAlertPolicyConditionName: string ) { - return this._pathTemplates.projectAlertPolicyConditionPathTemplate.match( + return this.pathTemplates.projectAlertPolicyConditionPathTemplate.match( projectAlertPolicyConditionName ).condition; } @@ -2319,8 +2530,8 @@ export class ServiceMonitoringServiceClient { * @returns {string} Resource name string. */ projectChannelDescriptorPath(project: string, channelDescriptor: string) { - return this._pathTemplates.projectChannelDescriptorPathTemplate.render({ - project, + return this.pathTemplates.projectChannelDescriptorPathTemplate.render({ + project: project, channel_descriptor: channelDescriptor, }); } @@ -2335,7 +2546,7 @@ export class ServiceMonitoringServiceClient { matchProjectFromProjectChannelDescriptorName( projectChannelDescriptorName: string ) { - return this._pathTemplates.projectChannelDescriptorPathTemplate.match( + return this.pathTemplates.projectChannelDescriptorPathTemplate.match( projectChannelDescriptorName ).project; } @@ -2350,7 +2561,7 @@ export class ServiceMonitoringServiceClient { matchChannelDescriptorFromProjectChannelDescriptorName( projectChannelDescriptorName: string ) { - return this._pathTemplates.projectChannelDescriptorPathTemplate.match( + return this.pathTemplates.projectChannelDescriptorPathTemplate.match( projectChannelDescriptorName ).channel_descriptor; } @@ -2363,9 +2574,9 @@ export class ServiceMonitoringServiceClient { * @returns {string} Resource name string. */ projectGroupPath(project: string, group: string) { - return this._pathTemplates.projectGroupPathTemplate.render({ - project, - group, + return this.pathTemplates.projectGroupPathTemplate.render({ + project: project, + group: group, }); } @@ -2377,7 +2588,7 @@ export class ServiceMonitoringServiceClient { * @returns {string} A string representing the project. */ matchProjectFromProjectGroupName(projectGroupName: string) { - return this._pathTemplates.projectGroupPathTemplate.match(projectGroupName) + return this.pathTemplates.projectGroupPathTemplate.match(projectGroupName) .project; } @@ -2389,7 +2600,7 @@ export class ServiceMonitoringServiceClient { * @returns {string} A string representing the group. */ matchGroupFromProjectGroupName(projectGroupName: string) { - return this._pathTemplates.projectGroupPathTemplate.match(projectGroupName) + return this.pathTemplates.projectGroupPathTemplate.match(projectGroupName) .group; } @@ -2401,8 +2612,8 @@ export class ServiceMonitoringServiceClient { * @returns {string} Resource name string. */ projectNotificationChannelPath(project: string, notificationChannel: string) { - return this._pathTemplates.projectNotificationChannelPathTemplate.render({ - project, + return this.pathTemplates.projectNotificationChannelPathTemplate.render({ + project: project, notification_channel: notificationChannel, }); } @@ -2417,7 +2628,7 @@ export class ServiceMonitoringServiceClient { matchProjectFromProjectNotificationChannelName( projectNotificationChannelName: string ) { - return this._pathTemplates.projectNotificationChannelPathTemplate.match( + return this.pathTemplates.projectNotificationChannelPathTemplate.match( projectNotificationChannelName ).project; } @@ -2432,7 +2643,7 @@ export class ServiceMonitoringServiceClient { matchNotificationChannelFromProjectNotificationChannelName( projectNotificationChannelName: string ) { - return this._pathTemplates.projectNotificationChannelPathTemplate.match( + return this.pathTemplates.projectNotificationChannelPathTemplate.match( projectNotificationChannelName ).notification_channel; } @@ -2445,9 +2656,9 @@ export class ServiceMonitoringServiceClient { * @returns {string} Resource name string. */ projectServicePath(project: string, service: string) { - return this._pathTemplates.projectServicePathTemplate.render({ - project, - service, + return this.pathTemplates.projectServicePathTemplate.render({ + project: project, + service: service, }); } @@ -2459,7 +2670,7 @@ export class ServiceMonitoringServiceClient { * @returns {string} A string representing the project. */ matchProjectFromProjectServiceName(projectServiceName: string) { - return this._pathTemplates.projectServicePathTemplate.match( + return this.pathTemplates.projectServicePathTemplate.match( projectServiceName ).project; } @@ -2472,7 +2683,7 @@ export class ServiceMonitoringServiceClient { * @returns {string} A string representing the service. */ matchServiceFromProjectServiceName(projectServiceName: string) { - return this._pathTemplates.projectServicePathTemplate.match( + return this.pathTemplates.projectServicePathTemplate.match( projectServiceName ).service; } @@ -2490,10 +2701,10 @@ export class ServiceMonitoringServiceClient { service: string, serviceLevelObjective: string ) { - return this._pathTemplates.projectServiceServiceLevelObjectivePathTemplate.render( + return this.pathTemplates.projectServiceServiceLevelObjectivePathTemplate.render( { - project, - service, + project: project, + service: service, service_level_objective: serviceLevelObjective, } ); @@ -2509,7 +2720,7 @@ export class ServiceMonitoringServiceClient { matchProjectFromProjectServiceServiceLevelObjectiveName( projectServiceServiceLevelObjectiveName: string ) { - return this._pathTemplates.projectServiceServiceLevelObjectivePathTemplate.match( + return this.pathTemplates.projectServiceServiceLevelObjectivePathTemplate.match( projectServiceServiceLevelObjectiveName ).project; } @@ -2524,7 +2735,7 @@ export class ServiceMonitoringServiceClient { matchServiceFromProjectServiceServiceLevelObjectiveName( projectServiceServiceLevelObjectiveName: string ) { - return this._pathTemplates.projectServiceServiceLevelObjectivePathTemplate.match( + return this.pathTemplates.projectServiceServiceLevelObjectivePathTemplate.match( projectServiceServiceLevelObjectiveName ).service; } @@ -2539,7 +2750,7 @@ export class ServiceMonitoringServiceClient { matchServiceLevelObjectiveFromProjectServiceServiceLevelObjectiveName( projectServiceServiceLevelObjectiveName: string ) { - return this._pathTemplates.projectServiceServiceLevelObjectivePathTemplate.match( + return this.pathTemplates.projectServiceServiceLevelObjectivePathTemplate.match( projectServiceServiceLevelObjectiveName ).service_level_objective; } @@ -2552,8 +2763,8 @@ export class ServiceMonitoringServiceClient { * @returns {string} Resource name string. */ projectUptimeCheckConfigPath(project: string, uptimeCheckConfig: string) { - return this._pathTemplates.projectUptimeCheckConfigPathTemplate.render({ - project, + return this.pathTemplates.projectUptimeCheckConfigPathTemplate.render({ + project: project, uptime_check_config: uptimeCheckConfig, }); } @@ -2568,7 +2779,7 @@ export class ServiceMonitoringServiceClient { matchProjectFromProjectUptimeCheckConfigName( projectUptimeCheckConfigName: string ) { - return this._pathTemplates.projectUptimeCheckConfigPathTemplate.match( + return this.pathTemplates.projectUptimeCheckConfigPathTemplate.match( projectUptimeCheckConfigName ).project; } @@ -2583,7 +2794,7 @@ export class ServiceMonitoringServiceClient { matchUptimeCheckConfigFromProjectUptimeCheckConfigName( projectUptimeCheckConfigName: string ) { - return this._pathTemplates.projectUptimeCheckConfigPathTemplate.match( + return this.pathTemplates.projectUptimeCheckConfigPathTemplate.match( projectUptimeCheckConfigName ).uptime_check_config; } diff --git a/packages/google-cloud-monitoring/src/v3/uptime_check_service_client.ts b/packages/google-cloud-monitoring/src/v3/uptime_check_service_client.ts index d0aa99442a1..0d982a41405 100644 --- a/packages/google-cloud-monitoring/src/v3/uptime_check_service_client.ts +++ b/packages/google-cloud-monitoring/src/v3/uptime_check_service_client.ts @@ -1,4 +1,4 @@ -// Copyright 2019 Google LLC +// Copyright 2020 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -18,18 +18,18 @@ import * as gax from 'google-gax'; import { - APICallback, Callback, CallOptions, Descriptors, ClientOptions, PaginationCallback, - PaginationResponse, + GaxCall, } from 'google-gax'; import * as path from 'path'; import {Transform} from 'stream'; -import * as protosTypes from '../../protos/protos'; +import {RequestType} from 'google-gax/build/src/apitypes'; +import * as protos from '../../protos/protos'; import * as gapicConfig from './uptime_check_service_client_config.json'; const version = require('../../../package.json').version; @@ -47,9 +47,6 @@ const version = require('../../../package.json').version; * @memberof v3 */ export class UptimeCheckServiceClient { - private _descriptors: Descriptors = {page: {}, stream: {}, longrunning: {}}; - private _innerApiCalls: {[name: string]: Function}; - private _pathTemplates: {[name: string]: gax.PathTemplate}; private _terminated = false; private _opts: ClientOptions; private _gaxModule: typeof gax | typeof gax.fallback; @@ -57,6 +54,14 @@ export class UptimeCheckServiceClient { private _protos: {}; private _defaults: {[method: string]: gax.CallSettings}; auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + innerApiCalls: {[name: string]: Function}; + pathTemplates: {[name: string]: gax.PathTemplate}; uptimeCheckServiceStub?: Promise<{[name: string]: Function}>; /** @@ -148,13 +153,16 @@ export class UptimeCheckServiceClient { 'protos.json' ); this._protos = this._gaxGrpc.loadProto( - opts.fallback ? 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 // identifiers to uniquely identify resources within the API. // Create useful helper objects for these. - this._pathTemplates = { + this.pathTemplates = { folderAlertPolicyPathTemplate: new this._gaxModule.PathTemplate( 'folders/{folder}/alertPolicies/{alert_policy}' ), @@ -235,7 +243,7 @@ export class UptimeCheckServiceClient { // Some of the methods on this service return "paged" results, // (e.g. 50 results at a time, with tokens to get subsequent // pages). Denote the keys used for pagination and results. - this._descriptors.page = { + this.descriptors.page = { listUptimeCheckConfigs: new this._gaxModule.PageDescriptor( 'pageToken', 'nextPageToken', @@ -259,7 +267,7 @@ export class UptimeCheckServiceClient { // Set up a dictionary of "inner API calls"; the core implementation // of calling the API is handled in `google-gax`, with this code // merely providing the destination and request information. - this._innerApiCalls = {}; + this.innerApiCalls = {}; } /** @@ -286,7 +294,7 @@ export class UptimeCheckServiceClient { ? (this._protos as protobuf.Root).lookupService( 'google.monitoring.v3.UptimeCheckService' ) - : // tslint:disable-next-line no-any + : // eslint-disable-next-line @typescript-eslint/no-explicit-any (this._protos as any).google.monitoring.v3.UptimeCheckService, this._opts ) as Promise<{[method: string]: Function}>; @@ -301,14 +309,14 @@ export class UptimeCheckServiceClient { 'deleteUptimeCheckConfig', 'listUptimeCheckIps', ]; - for (const methodName of uptimeCheckServiceStubMethods) { - const innerCallPromise = this.uptimeCheckServiceStub.then( + const callPromise = this.uptimeCheckServiceStub.then( stub => (...args: Array<{}>) => { if (this._terminated) { return Promise.reject('The client has already been closed.'); } - return stub[methodName].apply(stub, args); + const func = stub[methodName]; + return func.apply(stub, args); }, (err: Error | null | undefined) => () => { throw err; @@ -316,20 +324,14 @@ export class UptimeCheckServiceClient { ); const apiCall = this._gaxModule.createApiCall( - innerCallPromise, + callPromise, this._defaults[methodName], - this._descriptors.page[methodName] || - this._descriptors.stream[methodName] || - this._descriptors.longrunning[methodName] + this.descriptors.page[methodName] || + this.descriptors.stream[methodName] || + this.descriptors.longrunning[methodName] ); - this._innerApiCalls[methodName] = ( - argument: {}, - callOptions?: CallOptions, - callback?: APICallback - ) => { - return apiCall(argument, callOptions, callback); - }; + this.innerApiCalls[methodName] = apiCall; } return this.uptimeCheckServiceStub; @@ -390,22 +392,34 @@ export class UptimeCheckServiceClient { // -- Service calls -- // ------------------- getUptimeCheckConfig( - request: protosTypes.google.monitoring.v3.IGetUptimeCheckConfigRequest, + request: protos.google.monitoring.v3.IGetUptimeCheckConfigRequest, options?: gax.CallOptions ): Promise< [ - protosTypes.google.monitoring.v3.IUptimeCheckConfig, - protosTypes.google.monitoring.v3.IGetUptimeCheckConfigRequest | undefined, + protos.google.monitoring.v3.IUptimeCheckConfig, + protos.google.monitoring.v3.IGetUptimeCheckConfigRequest | undefined, {} | undefined ] >; getUptimeCheckConfig( - request: protosTypes.google.monitoring.v3.IGetUptimeCheckConfigRequest, + request: protos.google.monitoring.v3.IGetUptimeCheckConfigRequest, options: gax.CallOptions, callback: Callback< - protosTypes.google.monitoring.v3.IUptimeCheckConfig, - protosTypes.google.monitoring.v3.IGetUptimeCheckConfigRequest | undefined, - {} | undefined + protos.google.monitoring.v3.IUptimeCheckConfig, + | protos.google.monitoring.v3.IGetUptimeCheckConfigRequest + | null + | undefined, + {} | null | undefined + > + ): void; + getUptimeCheckConfig( + request: protos.google.monitoring.v3.IGetUptimeCheckConfigRequest, + callback: Callback< + protos.google.monitoring.v3.IUptimeCheckConfig, + | protos.google.monitoring.v3.IGetUptimeCheckConfigRequest + | null + | undefined, + {} | null | undefined > ): void; /** @@ -423,24 +437,27 @@ export class UptimeCheckServiceClient { * The promise has a method named "cancel" which cancels the ongoing API call. */ getUptimeCheckConfig( - request: protosTypes.google.monitoring.v3.IGetUptimeCheckConfigRequest, + request: protos.google.monitoring.v3.IGetUptimeCheckConfigRequest, optionsOrCallback?: | gax.CallOptions | Callback< - protosTypes.google.monitoring.v3.IUptimeCheckConfig, - | protosTypes.google.monitoring.v3.IGetUptimeCheckConfigRequest + protos.google.monitoring.v3.IUptimeCheckConfig, + | protos.google.monitoring.v3.IGetUptimeCheckConfigRequest + | null | undefined, - {} | undefined + {} | null | undefined >, callback?: Callback< - protosTypes.google.monitoring.v3.IUptimeCheckConfig, - protosTypes.google.monitoring.v3.IGetUptimeCheckConfigRequest | undefined, - {} | undefined + protos.google.monitoring.v3.IUptimeCheckConfig, + | protos.google.monitoring.v3.IGetUptimeCheckConfigRequest + | null + | undefined, + {} | null | undefined > ): Promise< [ - protosTypes.google.monitoring.v3.IUptimeCheckConfig, - protosTypes.google.monitoring.v3.IGetUptimeCheckConfigRequest | undefined, + protos.google.monitoring.v3.IUptimeCheckConfig, + protos.google.monitoring.v3.IGetUptimeCheckConfigRequest | undefined, {} | undefined ] > | void { @@ -461,29 +478,37 @@ export class UptimeCheckServiceClient { name: request.name || '', }); this.initialize(); - return this._innerApiCalls.getUptimeCheckConfig(request, options, callback); + return this.innerApiCalls.getUptimeCheckConfig(request, options, callback); } createUptimeCheckConfig( - request: protosTypes.google.monitoring.v3.ICreateUptimeCheckConfigRequest, + request: protos.google.monitoring.v3.ICreateUptimeCheckConfigRequest, options?: gax.CallOptions ): Promise< [ - protosTypes.google.monitoring.v3.IUptimeCheckConfig, - ( - | protosTypes.google.monitoring.v3.ICreateUptimeCheckConfigRequest - | undefined - ), + protos.google.monitoring.v3.IUptimeCheckConfig, + protos.google.monitoring.v3.ICreateUptimeCheckConfigRequest | undefined, {} | undefined ] >; createUptimeCheckConfig( - request: protosTypes.google.monitoring.v3.ICreateUptimeCheckConfigRequest, + request: protos.google.monitoring.v3.ICreateUptimeCheckConfigRequest, options: gax.CallOptions, callback: Callback< - protosTypes.google.monitoring.v3.IUptimeCheckConfig, - | protosTypes.google.monitoring.v3.ICreateUptimeCheckConfigRequest + protos.google.monitoring.v3.IUptimeCheckConfig, + | protos.google.monitoring.v3.ICreateUptimeCheckConfigRequest + | null | undefined, - {} | undefined + {} | null | undefined + > + ): void; + createUptimeCheckConfig( + request: protos.google.monitoring.v3.ICreateUptimeCheckConfigRequest, + callback: Callback< + protos.google.monitoring.v3.IUptimeCheckConfig, + | protos.google.monitoring.v3.ICreateUptimeCheckConfigRequest + | null + | undefined, + {} | null | undefined > ): void; /** @@ -503,28 +528,27 @@ export class UptimeCheckServiceClient { * The promise has a method named "cancel" which cancels the ongoing API call. */ createUptimeCheckConfig( - request: protosTypes.google.monitoring.v3.ICreateUptimeCheckConfigRequest, + request: protos.google.monitoring.v3.ICreateUptimeCheckConfigRequest, optionsOrCallback?: | gax.CallOptions | Callback< - protosTypes.google.monitoring.v3.IUptimeCheckConfig, - | protosTypes.google.monitoring.v3.ICreateUptimeCheckConfigRequest + protos.google.monitoring.v3.IUptimeCheckConfig, + | protos.google.monitoring.v3.ICreateUptimeCheckConfigRequest + | null | undefined, - {} | undefined + {} | null | undefined >, callback?: Callback< - protosTypes.google.monitoring.v3.IUptimeCheckConfig, - | protosTypes.google.monitoring.v3.ICreateUptimeCheckConfigRequest + protos.google.monitoring.v3.IUptimeCheckConfig, + | protos.google.monitoring.v3.ICreateUptimeCheckConfigRequest + | null | undefined, - {} | undefined + {} | null | undefined > ): Promise< [ - protosTypes.google.monitoring.v3.IUptimeCheckConfig, - ( - | protosTypes.google.monitoring.v3.ICreateUptimeCheckConfigRequest - | undefined - ), + protos.google.monitoring.v3.IUptimeCheckConfig, + protos.google.monitoring.v3.ICreateUptimeCheckConfigRequest | undefined, {} | undefined ] > | void { @@ -545,33 +569,41 @@ export class UptimeCheckServiceClient { parent: request.parent || '', }); this.initialize(); - return this._innerApiCalls.createUptimeCheckConfig( + return this.innerApiCalls.createUptimeCheckConfig( request, options, callback ); } updateUptimeCheckConfig( - request: protosTypes.google.monitoring.v3.IUpdateUptimeCheckConfigRequest, + request: protos.google.monitoring.v3.IUpdateUptimeCheckConfigRequest, options?: gax.CallOptions ): Promise< [ - protosTypes.google.monitoring.v3.IUptimeCheckConfig, - ( - | protosTypes.google.monitoring.v3.IUpdateUptimeCheckConfigRequest - | undefined - ), + protos.google.monitoring.v3.IUptimeCheckConfig, + protos.google.monitoring.v3.IUpdateUptimeCheckConfigRequest | undefined, {} | undefined ] >; updateUptimeCheckConfig( - request: protosTypes.google.monitoring.v3.IUpdateUptimeCheckConfigRequest, + request: protos.google.monitoring.v3.IUpdateUptimeCheckConfigRequest, options: gax.CallOptions, callback: Callback< - protosTypes.google.monitoring.v3.IUptimeCheckConfig, - | protosTypes.google.monitoring.v3.IUpdateUptimeCheckConfigRequest + protos.google.monitoring.v3.IUptimeCheckConfig, + | protos.google.monitoring.v3.IUpdateUptimeCheckConfigRequest + | null | undefined, - {} | undefined + {} | null | undefined + > + ): void; + updateUptimeCheckConfig( + request: protos.google.monitoring.v3.IUpdateUptimeCheckConfigRequest, + callback: Callback< + protos.google.monitoring.v3.IUptimeCheckConfig, + | protos.google.monitoring.v3.IUpdateUptimeCheckConfigRequest + | null + | undefined, + {} | null | undefined > ): void; /** @@ -606,28 +638,27 @@ export class UptimeCheckServiceClient { * The promise has a method named "cancel" which cancels the ongoing API call. */ updateUptimeCheckConfig( - request: protosTypes.google.monitoring.v3.IUpdateUptimeCheckConfigRequest, + request: protos.google.monitoring.v3.IUpdateUptimeCheckConfigRequest, optionsOrCallback?: | gax.CallOptions | Callback< - protosTypes.google.monitoring.v3.IUptimeCheckConfig, - | protosTypes.google.monitoring.v3.IUpdateUptimeCheckConfigRequest + protos.google.monitoring.v3.IUptimeCheckConfig, + | protos.google.monitoring.v3.IUpdateUptimeCheckConfigRequest + | null | undefined, - {} | undefined + {} | null | undefined >, callback?: Callback< - protosTypes.google.monitoring.v3.IUptimeCheckConfig, - | protosTypes.google.monitoring.v3.IUpdateUptimeCheckConfigRequest + protos.google.monitoring.v3.IUptimeCheckConfig, + | protos.google.monitoring.v3.IUpdateUptimeCheckConfigRequest + | null | undefined, - {} | undefined + {} | null | undefined > ): Promise< [ - protosTypes.google.monitoring.v3.IUptimeCheckConfig, - ( - | protosTypes.google.monitoring.v3.IUpdateUptimeCheckConfigRequest - | undefined - ), + protos.google.monitoring.v3.IUptimeCheckConfig, + protos.google.monitoring.v3.IUpdateUptimeCheckConfigRequest | undefined, {} | undefined ] > | void { @@ -648,33 +679,41 @@ export class UptimeCheckServiceClient { 'uptime_check_config.name': request.uptimeCheckConfig!.name || '', }); this.initialize(); - return this._innerApiCalls.updateUptimeCheckConfig( + return this.innerApiCalls.updateUptimeCheckConfig( request, options, callback ); } deleteUptimeCheckConfig( - request: protosTypes.google.monitoring.v3.IDeleteUptimeCheckConfigRequest, + request: protos.google.monitoring.v3.IDeleteUptimeCheckConfigRequest, options?: gax.CallOptions ): Promise< [ - protosTypes.google.protobuf.IEmpty, - ( - | protosTypes.google.monitoring.v3.IDeleteUptimeCheckConfigRequest - | undefined - ), + protos.google.protobuf.IEmpty, + protos.google.monitoring.v3.IDeleteUptimeCheckConfigRequest | undefined, {} | undefined ] >; deleteUptimeCheckConfig( - request: protosTypes.google.monitoring.v3.IDeleteUptimeCheckConfigRequest, + request: protos.google.monitoring.v3.IDeleteUptimeCheckConfigRequest, options: gax.CallOptions, callback: Callback< - protosTypes.google.protobuf.IEmpty, - | protosTypes.google.monitoring.v3.IDeleteUptimeCheckConfigRequest + protos.google.protobuf.IEmpty, + | protos.google.monitoring.v3.IDeleteUptimeCheckConfigRequest + | null | undefined, - {} | undefined + {} | null | undefined + > + ): void; + deleteUptimeCheckConfig( + request: protos.google.monitoring.v3.IDeleteUptimeCheckConfigRequest, + callback: Callback< + protos.google.protobuf.IEmpty, + | protos.google.monitoring.v3.IDeleteUptimeCheckConfigRequest + | null + | undefined, + {} | null | undefined > ): void; /** @@ -694,28 +733,27 @@ export class UptimeCheckServiceClient { * The promise has a method named "cancel" which cancels the ongoing API call. */ deleteUptimeCheckConfig( - request: protosTypes.google.monitoring.v3.IDeleteUptimeCheckConfigRequest, + request: protos.google.monitoring.v3.IDeleteUptimeCheckConfigRequest, optionsOrCallback?: | gax.CallOptions | Callback< - protosTypes.google.protobuf.IEmpty, - | protosTypes.google.monitoring.v3.IDeleteUptimeCheckConfigRequest + protos.google.protobuf.IEmpty, + | protos.google.monitoring.v3.IDeleteUptimeCheckConfigRequest + | null | undefined, - {} | undefined + {} | null | undefined >, callback?: Callback< - protosTypes.google.protobuf.IEmpty, - | protosTypes.google.monitoring.v3.IDeleteUptimeCheckConfigRequest + protos.google.protobuf.IEmpty, + | protos.google.monitoring.v3.IDeleteUptimeCheckConfigRequest + | null | undefined, - {} | undefined + {} | null | undefined > ): Promise< [ - protosTypes.google.protobuf.IEmpty, - ( - | protosTypes.google.monitoring.v3.IDeleteUptimeCheckConfigRequest - | undefined - ), + protos.google.protobuf.IEmpty, + protos.google.monitoring.v3.IDeleteUptimeCheckConfigRequest | undefined, {} | undefined ] > | void { @@ -736,7 +774,7 @@ export class UptimeCheckServiceClient { name: request.name || '', }); this.initialize(); - return this._innerApiCalls.deleteUptimeCheckConfig( + return this.innerApiCalls.deleteUptimeCheckConfig( request, options, callback @@ -744,22 +782,34 @@ export class UptimeCheckServiceClient { } listUptimeCheckConfigs( - request: protosTypes.google.monitoring.v3.IListUptimeCheckConfigsRequest, + request: protos.google.monitoring.v3.IListUptimeCheckConfigsRequest, options?: gax.CallOptions ): Promise< [ - protosTypes.google.monitoring.v3.IUptimeCheckConfig[], - protosTypes.google.monitoring.v3.IListUptimeCheckConfigsRequest | null, - protosTypes.google.monitoring.v3.IListUptimeCheckConfigsResponse + protos.google.monitoring.v3.IUptimeCheckConfig[], + protos.google.monitoring.v3.IListUptimeCheckConfigsRequest | null, + protos.google.monitoring.v3.IListUptimeCheckConfigsResponse ] >; listUptimeCheckConfigs( - request: protosTypes.google.monitoring.v3.IListUptimeCheckConfigsRequest, + request: protos.google.monitoring.v3.IListUptimeCheckConfigsRequest, options: gax.CallOptions, - callback: Callback< - protosTypes.google.monitoring.v3.IUptimeCheckConfig[], - protosTypes.google.monitoring.v3.IListUptimeCheckConfigsRequest | null, - protosTypes.google.monitoring.v3.IListUptimeCheckConfigsResponse + callback: PaginationCallback< + protos.google.monitoring.v3.IListUptimeCheckConfigsRequest, + | protos.google.monitoring.v3.IListUptimeCheckConfigsResponse + | null + | undefined, + protos.google.monitoring.v3.IUptimeCheckConfig + > + ): void; + listUptimeCheckConfigs( + request: protos.google.monitoring.v3.IListUptimeCheckConfigsRequest, + callback: PaginationCallback< + protos.google.monitoring.v3.IListUptimeCheckConfigsRequest, + | protos.google.monitoring.v3.IListUptimeCheckConfigsResponse + | null + | undefined, + protos.google.monitoring.v3.IUptimeCheckConfig > ): void; /** @@ -799,24 +849,28 @@ export class UptimeCheckServiceClient { * The promise has a method named "cancel" which cancels the ongoing API call. */ listUptimeCheckConfigs( - request: protosTypes.google.monitoring.v3.IListUptimeCheckConfigsRequest, + request: protos.google.monitoring.v3.IListUptimeCheckConfigsRequest, optionsOrCallback?: | gax.CallOptions - | Callback< - protosTypes.google.monitoring.v3.IUptimeCheckConfig[], - protosTypes.google.monitoring.v3.IListUptimeCheckConfigsRequest | null, - protosTypes.google.monitoring.v3.IListUptimeCheckConfigsResponse + | PaginationCallback< + protos.google.monitoring.v3.IListUptimeCheckConfigsRequest, + | protos.google.monitoring.v3.IListUptimeCheckConfigsResponse + | null + | undefined, + protos.google.monitoring.v3.IUptimeCheckConfig >, - callback?: Callback< - protosTypes.google.monitoring.v3.IUptimeCheckConfig[], - protosTypes.google.monitoring.v3.IListUptimeCheckConfigsRequest | null, - protosTypes.google.monitoring.v3.IListUptimeCheckConfigsResponse + callback?: PaginationCallback< + protos.google.monitoring.v3.IListUptimeCheckConfigsRequest, + | protos.google.monitoring.v3.IListUptimeCheckConfigsResponse + | null + | undefined, + protos.google.monitoring.v3.IUptimeCheckConfig > ): Promise< [ - protosTypes.google.monitoring.v3.IUptimeCheckConfig[], - protosTypes.google.monitoring.v3.IListUptimeCheckConfigsRequest | null, - protosTypes.google.monitoring.v3.IListUptimeCheckConfigsResponse + protos.google.monitoring.v3.IUptimeCheckConfig[], + protos.google.monitoring.v3.IListUptimeCheckConfigsRequest | null, + protos.google.monitoring.v3.IListUptimeCheckConfigsResponse ] > | void { request = request || {}; @@ -836,7 +890,7 @@ export class UptimeCheckServiceClient { parent: request.parent || '', }); this.initialize(); - return this._innerApiCalls.listUptimeCheckConfigs( + return this.innerApiCalls.listUptimeCheckConfigs( request, options, callback @@ -876,7 +930,7 @@ export class UptimeCheckServiceClient { * An object stream which emits an object representing [UptimeCheckConfig]{@link google.monitoring.v3.UptimeCheckConfig} on 'data' event. */ listUptimeCheckConfigsStream( - request?: protosTypes.google.monitoring.v3.IListUptimeCheckConfigsRequest, + request?: protos.google.monitoring.v3.IListUptimeCheckConfigsRequest, options?: gax.CallOptions ): Transform { request = request || {}; @@ -890,29 +944,88 @@ export class UptimeCheckServiceClient { }); const callSettings = new gax.CallSettings(options); this.initialize(); - return this._descriptors.page.listUptimeCheckConfigs.createStream( - this._innerApiCalls.listUptimeCheckConfigs as gax.GaxCall, + return this.descriptors.page.listUptimeCheckConfigs.createStream( + this.innerApiCalls.listUptimeCheckConfigs as gax.GaxCall, request, callSettings ); } + + /** + * Equivalent to {@link listUptimeCheckConfigs}, 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 project whose Uptime check configurations are listed. The format + * is `projects/[PROJECT_ID]`. + * @param {number} request.pageSize + * The maximum number of results to return in a single response. The server + * may further constrain the maximum number of results returned in a single + * page. If the page_size is <=0, the server will decide the number of results + * to be returned. + * @param {string} request.pageToken + * If this field is not empty then it must contain the `nextPageToken` value + * returned by a previous call to this method. Using this field causes the + * method to return more results from the previous method call. + * @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. + */ + listUptimeCheckConfigsAsync( + request?: protos.google.monitoring.v3.IListUptimeCheckConfigsRequest, + options?: gax.CallOptions + ): AsyncIterable { + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + parent: request.parent || '', + }); + options = options || {}; + const callSettings = new gax.CallSettings(options); + this.initialize(); + return this.descriptors.page.listUptimeCheckConfigs.asyncIterate( + this.innerApiCalls['listUptimeCheckConfigs'] as GaxCall, + (request as unknown) as RequestType, + callSettings + ) as AsyncIterable; + } listUptimeCheckIps( - request: protosTypes.google.monitoring.v3.IListUptimeCheckIpsRequest, + request: protos.google.monitoring.v3.IListUptimeCheckIpsRequest, options?: gax.CallOptions ): Promise< [ - protosTypes.google.monitoring.v3.IUptimeCheckIp[], - protosTypes.google.monitoring.v3.IListUptimeCheckIpsRequest | null, - protosTypes.google.monitoring.v3.IListUptimeCheckIpsResponse + protos.google.monitoring.v3.IUptimeCheckIp[], + protos.google.monitoring.v3.IListUptimeCheckIpsRequest | null, + protos.google.monitoring.v3.IListUptimeCheckIpsResponse ] >; listUptimeCheckIps( - request: protosTypes.google.monitoring.v3.IListUptimeCheckIpsRequest, + request: protos.google.monitoring.v3.IListUptimeCheckIpsRequest, options: gax.CallOptions, - callback: Callback< - protosTypes.google.monitoring.v3.IUptimeCheckIp[], - protosTypes.google.monitoring.v3.IListUptimeCheckIpsRequest | null, - protosTypes.google.monitoring.v3.IListUptimeCheckIpsResponse + callback: PaginationCallback< + protos.google.monitoring.v3.IListUptimeCheckIpsRequest, + | protos.google.monitoring.v3.IListUptimeCheckIpsResponse + | null + | undefined, + protos.google.monitoring.v3.IUptimeCheckIp + > + ): void; + listUptimeCheckIps( + request: protos.google.monitoring.v3.IListUptimeCheckIpsRequest, + callback: PaginationCallback< + protos.google.monitoring.v3.IListUptimeCheckIpsRequest, + | protos.google.monitoring.v3.IListUptimeCheckIpsResponse + | null + | undefined, + protos.google.monitoring.v3.IUptimeCheckIp > ): void; /** @@ -950,24 +1063,28 @@ export class UptimeCheckServiceClient { * The promise has a method named "cancel" which cancels the ongoing API call. */ listUptimeCheckIps( - request: protosTypes.google.monitoring.v3.IListUptimeCheckIpsRequest, + request: protos.google.monitoring.v3.IListUptimeCheckIpsRequest, optionsOrCallback?: | gax.CallOptions - | Callback< - protosTypes.google.monitoring.v3.IUptimeCheckIp[], - protosTypes.google.monitoring.v3.IListUptimeCheckIpsRequest | null, - protosTypes.google.monitoring.v3.IListUptimeCheckIpsResponse + | PaginationCallback< + protos.google.monitoring.v3.IListUptimeCheckIpsRequest, + | protos.google.monitoring.v3.IListUptimeCheckIpsResponse + | null + | undefined, + protos.google.monitoring.v3.IUptimeCheckIp >, - callback?: Callback< - protosTypes.google.monitoring.v3.IUptimeCheckIp[], - protosTypes.google.monitoring.v3.IListUptimeCheckIpsRequest | null, - protosTypes.google.monitoring.v3.IListUptimeCheckIpsResponse + callback?: PaginationCallback< + protos.google.monitoring.v3.IListUptimeCheckIpsRequest, + | protos.google.monitoring.v3.IListUptimeCheckIpsResponse + | null + | undefined, + protos.google.monitoring.v3.IUptimeCheckIp > ): Promise< [ - protosTypes.google.monitoring.v3.IUptimeCheckIp[], - protosTypes.google.monitoring.v3.IListUptimeCheckIpsRequest | null, - protosTypes.google.monitoring.v3.IListUptimeCheckIpsResponse + protos.google.monitoring.v3.IUptimeCheckIp[], + protos.google.monitoring.v3.IListUptimeCheckIpsRequest | null, + protos.google.monitoring.v3.IListUptimeCheckIpsResponse ] > | void { request = request || {}; @@ -980,7 +1097,7 @@ export class UptimeCheckServiceClient { } options = options || {}; this.initialize(); - return this._innerApiCalls.listUptimeCheckIps(request, options, callback); + return this.innerApiCalls.listUptimeCheckIps(request, options, callback); } /** @@ -1015,19 +1132,58 @@ export class UptimeCheckServiceClient { * An object stream which emits an object representing [UptimeCheckIp]{@link google.monitoring.v3.UptimeCheckIp} on 'data' event. */ listUptimeCheckIpsStream( - request?: protosTypes.google.monitoring.v3.IListUptimeCheckIpsRequest, + request?: protos.google.monitoring.v3.IListUptimeCheckIpsRequest, options?: gax.CallOptions ): Transform { request = request || {}; options = options || {}; const callSettings = new gax.CallSettings(options); this.initialize(); - return this._descriptors.page.listUptimeCheckIps.createStream( - this._innerApiCalls.listUptimeCheckIps as gax.GaxCall, + return this.descriptors.page.listUptimeCheckIps.createStream( + this.innerApiCalls.listUptimeCheckIps as gax.GaxCall, request, callSettings ); } + + /** + * Equivalent to {@link listUptimeCheckIps}, 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 {number} request.pageSize + * The maximum number of results to return in a single response. The server + * may further constrain the maximum number of results returned in a single + * page. If the page_size is <=0, the server will decide the number of results + * to be returned. + * NOTE: this field is not yet implemented + * @param {string} request.pageToken + * If this field is not empty then it must contain the `nextPageToken` value + * returned by a previous call to this method. Using this field causes the + * method to return more results from the previous method call. + * NOTE: this field is not yet implemented + * @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. + */ + listUptimeCheckIpsAsync( + request?: protos.google.monitoring.v3.IListUptimeCheckIpsRequest, + options?: gax.CallOptions + ): AsyncIterable { + request = request || {}; + options = options || {}; + options = options || {}; + const callSettings = new gax.CallSettings(options); + this.initialize(); + return this.descriptors.page.listUptimeCheckIps.asyncIterate( + this.innerApiCalls['listUptimeCheckIps'] as GaxCall, + (request as unknown) as RequestType, + callSettings + ) as AsyncIterable; + } // -------------------- // -- Path templates -- // -------------------- @@ -1040,8 +1196,8 @@ export class UptimeCheckServiceClient { * @returns {string} Resource name string. */ folderAlertPolicyPath(folder: string, alertPolicy: string) { - return this._pathTemplates.folderAlertPolicyPathTemplate.render({ - folder, + return this.pathTemplates.folderAlertPolicyPathTemplate.render({ + folder: folder, alert_policy: alertPolicy, }); } @@ -1054,7 +1210,7 @@ export class UptimeCheckServiceClient { * @returns {string} A string representing the folder. */ matchFolderFromFolderAlertPolicyName(folderAlertPolicyName: string) { - return this._pathTemplates.folderAlertPolicyPathTemplate.match( + return this.pathTemplates.folderAlertPolicyPathTemplate.match( folderAlertPolicyName ).folder; } @@ -1067,7 +1223,7 @@ export class UptimeCheckServiceClient { * @returns {string} A string representing the alert_policy. */ matchAlertPolicyFromFolderAlertPolicyName(folderAlertPolicyName: string) { - return this._pathTemplates.folderAlertPolicyPathTemplate.match( + return this.pathTemplates.folderAlertPolicyPathTemplate.match( folderAlertPolicyName ).alert_policy; } @@ -1085,10 +1241,10 @@ export class UptimeCheckServiceClient { alertPolicy: string, condition: string ) { - return this._pathTemplates.folderAlertPolicyConditionPathTemplate.render({ - folder, + return this.pathTemplates.folderAlertPolicyConditionPathTemplate.render({ + folder: folder, alert_policy: alertPolicy, - condition, + condition: condition, }); } @@ -1102,7 +1258,7 @@ export class UptimeCheckServiceClient { matchFolderFromFolderAlertPolicyConditionName( folderAlertPolicyConditionName: string ) { - return this._pathTemplates.folderAlertPolicyConditionPathTemplate.match( + return this.pathTemplates.folderAlertPolicyConditionPathTemplate.match( folderAlertPolicyConditionName ).folder; } @@ -1117,7 +1273,7 @@ export class UptimeCheckServiceClient { matchAlertPolicyFromFolderAlertPolicyConditionName( folderAlertPolicyConditionName: string ) { - return this._pathTemplates.folderAlertPolicyConditionPathTemplate.match( + return this.pathTemplates.folderAlertPolicyConditionPathTemplate.match( folderAlertPolicyConditionName ).alert_policy; } @@ -1132,7 +1288,7 @@ export class UptimeCheckServiceClient { matchConditionFromFolderAlertPolicyConditionName( folderAlertPolicyConditionName: string ) { - return this._pathTemplates.folderAlertPolicyConditionPathTemplate.match( + return this.pathTemplates.folderAlertPolicyConditionPathTemplate.match( folderAlertPolicyConditionName ).condition; } @@ -1145,8 +1301,8 @@ export class UptimeCheckServiceClient { * @returns {string} Resource name string. */ folderChannelDescriptorPath(folder: string, channelDescriptor: string) { - return this._pathTemplates.folderChannelDescriptorPathTemplate.render({ - folder, + return this.pathTemplates.folderChannelDescriptorPathTemplate.render({ + folder: folder, channel_descriptor: channelDescriptor, }); } @@ -1161,7 +1317,7 @@ export class UptimeCheckServiceClient { matchFolderFromFolderChannelDescriptorName( folderChannelDescriptorName: string ) { - return this._pathTemplates.folderChannelDescriptorPathTemplate.match( + return this.pathTemplates.folderChannelDescriptorPathTemplate.match( folderChannelDescriptorName ).folder; } @@ -1176,7 +1332,7 @@ export class UptimeCheckServiceClient { matchChannelDescriptorFromFolderChannelDescriptorName( folderChannelDescriptorName: string ) { - return this._pathTemplates.folderChannelDescriptorPathTemplate.match( + return this.pathTemplates.folderChannelDescriptorPathTemplate.match( folderChannelDescriptorName ).channel_descriptor; } @@ -1189,9 +1345,9 @@ export class UptimeCheckServiceClient { * @returns {string} Resource name string. */ folderGroupPath(folder: string, group: string) { - return this._pathTemplates.folderGroupPathTemplate.render({ - folder, - group, + return this.pathTemplates.folderGroupPathTemplate.render({ + folder: folder, + group: group, }); } @@ -1203,7 +1359,7 @@ export class UptimeCheckServiceClient { * @returns {string} A string representing the folder. */ matchFolderFromFolderGroupName(folderGroupName: string) { - return this._pathTemplates.folderGroupPathTemplate.match(folderGroupName) + return this.pathTemplates.folderGroupPathTemplate.match(folderGroupName) .folder; } @@ -1215,7 +1371,7 @@ export class UptimeCheckServiceClient { * @returns {string} A string representing the group. */ matchGroupFromFolderGroupName(folderGroupName: string) { - return this._pathTemplates.folderGroupPathTemplate.match(folderGroupName) + return this.pathTemplates.folderGroupPathTemplate.match(folderGroupName) .group; } @@ -1227,8 +1383,8 @@ export class UptimeCheckServiceClient { * @returns {string} Resource name string. */ folderNotificationChannelPath(folder: string, notificationChannel: string) { - return this._pathTemplates.folderNotificationChannelPathTemplate.render({ - folder, + return this.pathTemplates.folderNotificationChannelPathTemplate.render({ + folder: folder, notification_channel: notificationChannel, }); } @@ -1243,7 +1399,7 @@ export class UptimeCheckServiceClient { matchFolderFromFolderNotificationChannelName( folderNotificationChannelName: string ) { - return this._pathTemplates.folderNotificationChannelPathTemplate.match( + return this.pathTemplates.folderNotificationChannelPathTemplate.match( folderNotificationChannelName ).folder; } @@ -1258,7 +1414,7 @@ export class UptimeCheckServiceClient { matchNotificationChannelFromFolderNotificationChannelName( folderNotificationChannelName: string ) { - return this._pathTemplates.folderNotificationChannelPathTemplate.match( + return this.pathTemplates.folderNotificationChannelPathTemplate.match( folderNotificationChannelName ).notification_channel; } @@ -1271,9 +1427,9 @@ export class UptimeCheckServiceClient { * @returns {string} Resource name string. */ folderServicePath(folder: string, service: string) { - return this._pathTemplates.folderServicePathTemplate.render({ - folder, - service, + return this.pathTemplates.folderServicePathTemplate.render({ + folder: folder, + service: service, }); } @@ -1285,9 +1441,8 @@ export class UptimeCheckServiceClient { * @returns {string} A string representing the folder. */ matchFolderFromFolderServiceName(folderServiceName: string) { - return this._pathTemplates.folderServicePathTemplate.match( - folderServiceName - ).folder; + return this.pathTemplates.folderServicePathTemplate.match(folderServiceName) + .folder; } /** @@ -1298,9 +1453,8 @@ export class UptimeCheckServiceClient { * @returns {string} A string representing the service. */ matchServiceFromFolderServiceName(folderServiceName: string) { - return this._pathTemplates.folderServicePathTemplate.match( - folderServiceName - ).service; + return this.pathTemplates.folderServicePathTemplate.match(folderServiceName) + .service; } /** @@ -1316,10 +1470,10 @@ export class UptimeCheckServiceClient { service: string, serviceLevelObjective: string ) { - return this._pathTemplates.folderServiceServiceLevelObjectivePathTemplate.render( + return this.pathTemplates.folderServiceServiceLevelObjectivePathTemplate.render( { - folder, - service, + folder: folder, + service: service, service_level_objective: serviceLevelObjective, } ); @@ -1335,7 +1489,7 @@ export class UptimeCheckServiceClient { matchFolderFromFolderServiceServiceLevelObjectiveName( folderServiceServiceLevelObjectiveName: string ) { - return this._pathTemplates.folderServiceServiceLevelObjectivePathTemplate.match( + return this.pathTemplates.folderServiceServiceLevelObjectivePathTemplate.match( folderServiceServiceLevelObjectiveName ).folder; } @@ -1350,7 +1504,7 @@ export class UptimeCheckServiceClient { matchServiceFromFolderServiceServiceLevelObjectiveName( folderServiceServiceLevelObjectiveName: string ) { - return this._pathTemplates.folderServiceServiceLevelObjectivePathTemplate.match( + return this.pathTemplates.folderServiceServiceLevelObjectivePathTemplate.match( folderServiceServiceLevelObjectiveName ).service; } @@ -1365,7 +1519,7 @@ export class UptimeCheckServiceClient { matchServiceLevelObjectiveFromFolderServiceServiceLevelObjectiveName( folderServiceServiceLevelObjectiveName: string ) { - return this._pathTemplates.folderServiceServiceLevelObjectivePathTemplate.match( + return this.pathTemplates.folderServiceServiceLevelObjectivePathTemplate.match( folderServiceServiceLevelObjectiveName ).service_level_objective; } @@ -1378,8 +1532,8 @@ export class UptimeCheckServiceClient { * @returns {string} Resource name string. */ folderUptimeCheckConfigPath(folder: string, uptimeCheckConfig: string) { - return this._pathTemplates.folderUptimeCheckConfigPathTemplate.render({ - folder, + return this.pathTemplates.folderUptimeCheckConfigPathTemplate.render({ + folder: folder, uptime_check_config: uptimeCheckConfig, }); } @@ -1394,7 +1548,7 @@ export class UptimeCheckServiceClient { matchFolderFromFolderUptimeCheckConfigName( folderUptimeCheckConfigName: string ) { - return this._pathTemplates.folderUptimeCheckConfigPathTemplate.match( + return this.pathTemplates.folderUptimeCheckConfigPathTemplate.match( folderUptimeCheckConfigName ).folder; } @@ -1409,7 +1563,7 @@ export class UptimeCheckServiceClient { matchUptimeCheckConfigFromFolderUptimeCheckConfigName( folderUptimeCheckConfigName: string ) { - return this._pathTemplates.folderUptimeCheckConfigPathTemplate.match( + return this.pathTemplates.folderUptimeCheckConfigPathTemplate.match( folderUptimeCheckConfigName ).uptime_check_config; } @@ -1422,8 +1576,8 @@ export class UptimeCheckServiceClient { * @returns {string} Resource name string. */ organizationAlertPolicyPath(organization: string, alertPolicy: string) { - return this._pathTemplates.organizationAlertPolicyPathTemplate.render({ - organization, + return this.pathTemplates.organizationAlertPolicyPathTemplate.render({ + organization: organization, alert_policy: alertPolicy, }); } @@ -1438,7 +1592,7 @@ export class UptimeCheckServiceClient { matchOrganizationFromOrganizationAlertPolicyName( organizationAlertPolicyName: string ) { - return this._pathTemplates.organizationAlertPolicyPathTemplate.match( + return this.pathTemplates.organizationAlertPolicyPathTemplate.match( organizationAlertPolicyName ).organization; } @@ -1453,7 +1607,7 @@ export class UptimeCheckServiceClient { matchAlertPolicyFromOrganizationAlertPolicyName( organizationAlertPolicyName: string ) { - return this._pathTemplates.organizationAlertPolicyPathTemplate.match( + return this.pathTemplates.organizationAlertPolicyPathTemplate.match( organizationAlertPolicyName ).alert_policy; } @@ -1471,11 +1625,11 @@ export class UptimeCheckServiceClient { alertPolicy: string, condition: string ) { - return this._pathTemplates.organizationAlertPolicyConditionPathTemplate.render( + return this.pathTemplates.organizationAlertPolicyConditionPathTemplate.render( { - organization, + organization: organization, alert_policy: alertPolicy, - condition, + condition: condition, } ); } @@ -1490,7 +1644,7 @@ export class UptimeCheckServiceClient { matchOrganizationFromOrganizationAlertPolicyConditionName( organizationAlertPolicyConditionName: string ) { - return this._pathTemplates.organizationAlertPolicyConditionPathTemplate.match( + return this.pathTemplates.organizationAlertPolicyConditionPathTemplate.match( organizationAlertPolicyConditionName ).organization; } @@ -1505,7 +1659,7 @@ export class UptimeCheckServiceClient { matchAlertPolicyFromOrganizationAlertPolicyConditionName( organizationAlertPolicyConditionName: string ) { - return this._pathTemplates.organizationAlertPolicyConditionPathTemplate.match( + return this.pathTemplates.organizationAlertPolicyConditionPathTemplate.match( organizationAlertPolicyConditionName ).alert_policy; } @@ -1520,7 +1674,7 @@ export class UptimeCheckServiceClient { matchConditionFromOrganizationAlertPolicyConditionName( organizationAlertPolicyConditionName: string ) { - return this._pathTemplates.organizationAlertPolicyConditionPathTemplate.match( + return this.pathTemplates.organizationAlertPolicyConditionPathTemplate.match( organizationAlertPolicyConditionName ).condition; } @@ -1536,12 +1690,10 @@ export class UptimeCheckServiceClient { organization: string, channelDescriptor: string ) { - return this._pathTemplates.organizationChannelDescriptorPathTemplate.render( - { - organization, - channel_descriptor: channelDescriptor, - } - ); + return this.pathTemplates.organizationChannelDescriptorPathTemplate.render({ + organization: organization, + channel_descriptor: channelDescriptor, + }); } /** @@ -1554,7 +1706,7 @@ export class UptimeCheckServiceClient { matchOrganizationFromOrganizationChannelDescriptorName( organizationChannelDescriptorName: string ) { - return this._pathTemplates.organizationChannelDescriptorPathTemplate.match( + return this.pathTemplates.organizationChannelDescriptorPathTemplate.match( organizationChannelDescriptorName ).organization; } @@ -1569,7 +1721,7 @@ export class UptimeCheckServiceClient { matchChannelDescriptorFromOrganizationChannelDescriptorName( organizationChannelDescriptorName: string ) { - return this._pathTemplates.organizationChannelDescriptorPathTemplate.match( + return this.pathTemplates.organizationChannelDescriptorPathTemplate.match( organizationChannelDescriptorName ).channel_descriptor; } @@ -1582,9 +1734,9 @@ export class UptimeCheckServiceClient { * @returns {string} Resource name string. */ organizationGroupPath(organization: string, group: string) { - return this._pathTemplates.organizationGroupPathTemplate.render({ - organization, - group, + return this.pathTemplates.organizationGroupPathTemplate.render({ + organization: organization, + group: group, }); } @@ -1596,7 +1748,7 @@ export class UptimeCheckServiceClient { * @returns {string} A string representing the organization. */ matchOrganizationFromOrganizationGroupName(organizationGroupName: string) { - return this._pathTemplates.organizationGroupPathTemplate.match( + return this.pathTemplates.organizationGroupPathTemplate.match( organizationGroupName ).organization; } @@ -1609,7 +1761,7 @@ export class UptimeCheckServiceClient { * @returns {string} A string representing the group. */ matchGroupFromOrganizationGroupName(organizationGroupName: string) { - return this._pathTemplates.organizationGroupPathTemplate.match( + return this.pathTemplates.organizationGroupPathTemplate.match( organizationGroupName ).group; } @@ -1625,9 +1777,9 @@ export class UptimeCheckServiceClient { organization: string, notificationChannel: string ) { - return this._pathTemplates.organizationNotificationChannelPathTemplate.render( + return this.pathTemplates.organizationNotificationChannelPathTemplate.render( { - organization, + organization: organization, notification_channel: notificationChannel, } ); @@ -1643,7 +1795,7 @@ export class UptimeCheckServiceClient { matchOrganizationFromOrganizationNotificationChannelName( organizationNotificationChannelName: string ) { - return this._pathTemplates.organizationNotificationChannelPathTemplate.match( + return this.pathTemplates.organizationNotificationChannelPathTemplate.match( organizationNotificationChannelName ).organization; } @@ -1658,7 +1810,7 @@ export class UptimeCheckServiceClient { matchNotificationChannelFromOrganizationNotificationChannelName( organizationNotificationChannelName: string ) { - return this._pathTemplates.organizationNotificationChannelPathTemplate.match( + return this.pathTemplates.organizationNotificationChannelPathTemplate.match( organizationNotificationChannelName ).notification_channel; } @@ -1671,9 +1823,9 @@ export class UptimeCheckServiceClient { * @returns {string} Resource name string. */ organizationServicePath(organization: string, service: string) { - return this._pathTemplates.organizationServicePathTemplate.render({ - organization, - service, + return this.pathTemplates.organizationServicePathTemplate.render({ + organization: organization, + service: service, }); } @@ -1687,7 +1839,7 @@ export class UptimeCheckServiceClient { matchOrganizationFromOrganizationServiceName( organizationServiceName: string ) { - return this._pathTemplates.organizationServicePathTemplate.match( + return this.pathTemplates.organizationServicePathTemplate.match( organizationServiceName ).organization; } @@ -1700,7 +1852,7 @@ export class UptimeCheckServiceClient { * @returns {string} A string representing the service. */ matchServiceFromOrganizationServiceName(organizationServiceName: string) { - return this._pathTemplates.organizationServicePathTemplate.match( + return this.pathTemplates.organizationServicePathTemplate.match( organizationServiceName ).service; } @@ -1718,10 +1870,10 @@ export class UptimeCheckServiceClient { service: string, serviceLevelObjective: string ) { - return this._pathTemplates.organizationServiceServiceLevelObjectivePathTemplate.render( + return this.pathTemplates.organizationServiceServiceLevelObjectivePathTemplate.render( { - organization, - service, + organization: organization, + service: service, service_level_objective: serviceLevelObjective, } ); @@ -1737,7 +1889,7 @@ export class UptimeCheckServiceClient { matchOrganizationFromOrganizationServiceServiceLevelObjectiveName( organizationServiceServiceLevelObjectiveName: string ) { - return this._pathTemplates.organizationServiceServiceLevelObjectivePathTemplate.match( + return this.pathTemplates.organizationServiceServiceLevelObjectivePathTemplate.match( organizationServiceServiceLevelObjectiveName ).organization; } @@ -1752,7 +1904,7 @@ export class UptimeCheckServiceClient { matchServiceFromOrganizationServiceServiceLevelObjectiveName( organizationServiceServiceLevelObjectiveName: string ) { - return this._pathTemplates.organizationServiceServiceLevelObjectivePathTemplate.match( + return this.pathTemplates.organizationServiceServiceLevelObjectivePathTemplate.match( organizationServiceServiceLevelObjectiveName ).service; } @@ -1767,7 +1919,7 @@ export class UptimeCheckServiceClient { matchServiceLevelObjectiveFromOrganizationServiceServiceLevelObjectiveName( organizationServiceServiceLevelObjectiveName: string ) { - return this._pathTemplates.organizationServiceServiceLevelObjectivePathTemplate.match( + return this.pathTemplates.organizationServiceServiceLevelObjectivePathTemplate.match( organizationServiceServiceLevelObjectiveName ).service_level_objective; } @@ -1783,12 +1935,10 @@ export class UptimeCheckServiceClient { organization: string, uptimeCheckConfig: string ) { - return this._pathTemplates.organizationUptimeCheckConfigPathTemplate.render( - { - organization, - uptime_check_config: uptimeCheckConfig, - } - ); + return this.pathTemplates.organizationUptimeCheckConfigPathTemplate.render({ + organization: organization, + uptime_check_config: uptimeCheckConfig, + }); } /** @@ -1801,7 +1951,7 @@ export class UptimeCheckServiceClient { matchOrganizationFromOrganizationUptimeCheckConfigName( organizationUptimeCheckConfigName: string ) { - return this._pathTemplates.organizationUptimeCheckConfigPathTemplate.match( + return this.pathTemplates.organizationUptimeCheckConfigPathTemplate.match( organizationUptimeCheckConfigName ).organization; } @@ -1816,7 +1966,7 @@ export class UptimeCheckServiceClient { matchUptimeCheckConfigFromOrganizationUptimeCheckConfigName( organizationUptimeCheckConfigName: string ) { - return this._pathTemplates.organizationUptimeCheckConfigPathTemplate.match( + return this.pathTemplates.organizationUptimeCheckConfigPathTemplate.match( organizationUptimeCheckConfigName ).uptime_check_config; } @@ -1828,8 +1978,8 @@ export class UptimeCheckServiceClient { * @returns {string} Resource name string. */ projectPath(project: string) { - return this._pathTemplates.projectPathTemplate.render({ - project, + return this.pathTemplates.projectPathTemplate.render({ + project: project, }); } @@ -1841,7 +1991,7 @@ export class UptimeCheckServiceClient { * @returns {string} A string representing the project. */ matchProjectFromProjectName(projectName: string) { - return this._pathTemplates.projectPathTemplate.match(projectName).project; + return this.pathTemplates.projectPathTemplate.match(projectName).project; } /** @@ -1852,8 +2002,8 @@ export class UptimeCheckServiceClient { * @returns {string} Resource name string. */ projectAlertPolicyPath(project: string, alertPolicy: string) { - return this._pathTemplates.projectAlertPolicyPathTemplate.render({ - project, + return this.pathTemplates.projectAlertPolicyPathTemplate.render({ + project: project, alert_policy: alertPolicy, }); } @@ -1866,7 +2016,7 @@ export class UptimeCheckServiceClient { * @returns {string} A string representing the project. */ matchProjectFromProjectAlertPolicyName(projectAlertPolicyName: string) { - return this._pathTemplates.projectAlertPolicyPathTemplate.match( + return this.pathTemplates.projectAlertPolicyPathTemplate.match( projectAlertPolicyName ).project; } @@ -1879,7 +2029,7 @@ export class UptimeCheckServiceClient { * @returns {string} A string representing the alert_policy. */ matchAlertPolicyFromProjectAlertPolicyName(projectAlertPolicyName: string) { - return this._pathTemplates.projectAlertPolicyPathTemplate.match( + return this.pathTemplates.projectAlertPolicyPathTemplate.match( projectAlertPolicyName ).alert_policy; } @@ -1897,10 +2047,10 @@ export class UptimeCheckServiceClient { alertPolicy: string, condition: string ) { - return this._pathTemplates.projectAlertPolicyConditionPathTemplate.render({ - project, + return this.pathTemplates.projectAlertPolicyConditionPathTemplate.render({ + project: project, alert_policy: alertPolicy, - condition, + condition: condition, }); } @@ -1914,7 +2064,7 @@ export class UptimeCheckServiceClient { matchProjectFromProjectAlertPolicyConditionName( projectAlertPolicyConditionName: string ) { - return this._pathTemplates.projectAlertPolicyConditionPathTemplate.match( + return this.pathTemplates.projectAlertPolicyConditionPathTemplate.match( projectAlertPolicyConditionName ).project; } @@ -1929,7 +2079,7 @@ export class UptimeCheckServiceClient { matchAlertPolicyFromProjectAlertPolicyConditionName( projectAlertPolicyConditionName: string ) { - return this._pathTemplates.projectAlertPolicyConditionPathTemplate.match( + return this.pathTemplates.projectAlertPolicyConditionPathTemplate.match( projectAlertPolicyConditionName ).alert_policy; } @@ -1944,7 +2094,7 @@ export class UptimeCheckServiceClient { matchConditionFromProjectAlertPolicyConditionName( projectAlertPolicyConditionName: string ) { - return this._pathTemplates.projectAlertPolicyConditionPathTemplate.match( + return this.pathTemplates.projectAlertPolicyConditionPathTemplate.match( projectAlertPolicyConditionName ).condition; } @@ -1957,8 +2107,8 @@ export class UptimeCheckServiceClient { * @returns {string} Resource name string. */ projectChannelDescriptorPath(project: string, channelDescriptor: string) { - return this._pathTemplates.projectChannelDescriptorPathTemplate.render({ - project, + return this.pathTemplates.projectChannelDescriptorPathTemplate.render({ + project: project, channel_descriptor: channelDescriptor, }); } @@ -1973,7 +2123,7 @@ export class UptimeCheckServiceClient { matchProjectFromProjectChannelDescriptorName( projectChannelDescriptorName: string ) { - return this._pathTemplates.projectChannelDescriptorPathTemplate.match( + return this.pathTemplates.projectChannelDescriptorPathTemplate.match( projectChannelDescriptorName ).project; } @@ -1988,7 +2138,7 @@ export class UptimeCheckServiceClient { matchChannelDescriptorFromProjectChannelDescriptorName( projectChannelDescriptorName: string ) { - return this._pathTemplates.projectChannelDescriptorPathTemplate.match( + return this.pathTemplates.projectChannelDescriptorPathTemplate.match( projectChannelDescriptorName ).channel_descriptor; } @@ -2001,9 +2151,9 @@ export class UptimeCheckServiceClient { * @returns {string} Resource name string. */ projectGroupPath(project: string, group: string) { - return this._pathTemplates.projectGroupPathTemplate.render({ - project, - group, + return this.pathTemplates.projectGroupPathTemplate.render({ + project: project, + group: group, }); } @@ -2015,7 +2165,7 @@ export class UptimeCheckServiceClient { * @returns {string} A string representing the project. */ matchProjectFromProjectGroupName(projectGroupName: string) { - return this._pathTemplates.projectGroupPathTemplate.match(projectGroupName) + return this.pathTemplates.projectGroupPathTemplate.match(projectGroupName) .project; } @@ -2027,7 +2177,7 @@ export class UptimeCheckServiceClient { * @returns {string} A string representing the group. */ matchGroupFromProjectGroupName(projectGroupName: string) { - return this._pathTemplates.projectGroupPathTemplate.match(projectGroupName) + return this.pathTemplates.projectGroupPathTemplate.match(projectGroupName) .group; } @@ -2039,8 +2189,8 @@ export class UptimeCheckServiceClient { * @returns {string} Resource name string. */ projectNotificationChannelPath(project: string, notificationChannel: string) { - return this._pathTemplates.projectNotificationChannelPathTemplate.render({ - project, + return this.pathTemplates.projectNotificationChannelPathTemplate.render({ + project: project, notification_channel: notificationChannel, }); } @@ -2055,7 +2205,7 @@ export class UptimeCheckServiceClient { matchProjectFromProjectNotificationChannelName( projectNotificationChannelName: string ) { - return this._pathTemplates.projectNotificationChannelPathTemplate.match( + return this.pathTemplates.projectNotificationChannelPathTemplate.match( projectNotificationChannelName ).project; } @@ -2070,7 +2220,7 @@ export class UptimeCheckServiceClient { matchNotificationChannelFromProjectNotificationChannelName( projectNotificationChannelName: string ) { - return this._pathTemplates.projectNotificationChannelPathTemplate.match( + return this.pathTemplates.projectNotificationChannelPathTemplate.match( projectNotificationChannelName ).notification_channel; } @@ -2083,9 +2233,9 @@ export class UptimeCheckServiceClient { * @returns {string} Resource name string. */ projectServicePath(project: string, service: string) { - return this._pathTemplates.projectServicePathTemplate.render({ - project, - service, + return this.pathTemplates.projectServicePathTemplate.render({ + project: project, + service: service, }); } @@ -2097,7 +2247,7 @@ export class UptimeCheckServiceClient { * @returns {string} A string representing the project. */ matchProjectFromProjectServiceName(projectServiceName: string) { - return this._pathTemplates.projectServicePathTemplate.match( + return this.pathTemplates.projectServicePathTemplate.match( projectServiceName ).project; } @@ -2110,7 +2260,7 @@ export class UptimeCheckServiceClient { * @returns {string} A string representing the service. */ matchServiceFromProjectServiceName(projectServiceName: string) { - return this._pathTemplates.projectServicePathTemplate.match( + return this.pathTemplates.projectServicePathTemplate.match( projectServiceName ).service; } @@ -2128,10 +2278,10 @@ export class UptimeCheckServiceClient { service: string, serviceLevelObjective: string ) { - return this._pathTemplates.projectServiceServiceLevelObjectivePathTemplate.render( + return this.pathTemplates.projectServiceServiceLevelObjectivePathTemplate.render( { - project, - service, + project: project, + service: service, service_level_objective: serviceLevelObjective, } ); @@ -2147,7 +2297,7 @@ export class UptimeCheckServiceClient { matchProjectFromProjectServiceServiceLevelObjectiveName( projectServiceServiceLevelObjectiveName: string ) { - return this._pathTemplates.projectServiceServiceLevelObjectivePathTemplate.match( + return this.pathTemplates.projectServiceServiceLevelObjectivePathTemplate.match( projectServiceServiceLevelObjectiveName ).project; } @@ -2162,7 +2312,7 @@ export class UptimeCheckServiceClient { matchServiceFromProjectServiceServiceLevelObjectiveName( projectServiceServiceLevelObjectiveName: string ) { - return this._pathTemplates.projectServiceServiceLevelObjectivePathTemplate.match( + return this.pathTemplates.projectServiceServiceLevelObjectivePathTemplate.match( projectServiceServiceLevelObjectiveName ).service; } @@ -2177,7 +2327,7 @@ export class UptimeCheckServiceClient { matchServiceLevelObjectiveFromProjectServiceServiceLevelObjectiveName( projectServiceServiceLevelObjectiveName: string ) { - return this._pathTemplates.projectServiceServiceLevelObjectivePathTemplate.match( + return this.pathTemplates.projectServiceServiceLevelObjectivePathTemplate.match( projectServiceServiceLevelObjectiveName ).service_level_objective; } @@ -2190,8 +2340,8 @@ export class UptimeCheckServiceClient { * @returns {string} Resource name string. */ projectUptimeCheckConfigPath(project: string, uptimeCheckConfig: string) { - return this._pathTemplates.projectUptimeCheckConfigPathTemplate.render({ - project, + return this.pathTemplates.projectUptimeCheckConfigPathTemplate.render({ + project: project, uptime_check_config: uptimeCheckConfig, }); } @@ -2206,7 +2356,7 @@ export class UptimeCheckServiceClient { matchProjectFromProjectUptimeCheckConfigName( projectUptimeCheckConfigName: string ) { - return this._pathTemplates.projectUptimeCheckConfigPathTemplate.match( + return this.pathTemplates.projectUptimeCheckConfigPathTemplate.match( projectUptimeCheckConfigName ).project; } @@ -2221,7 +2371,7 @@ export class UptimeCheckServiceClient { matchUptimeCheckConfigFromProjectUptimeCheckConfigName( projectUptimeCheckConfigName: string ) { - return this._pathTemplates.projectUptimeCheckConfigPathTemplate.match( + return this.pathTemplates.projectUptimeCheckConfigPathTemplate.match( projectUptimeCheckConfigName ).uptime_check_config; } diff --git a/packages/google-cloud-monitoring/synth.metadata b/packages/google-cloud-monitoring/synth.metadata index 69808cbb539..1c1b8835642 100644 --- a/packages/google-cloud-monitoring/synth.metadata +++ b/packages/google-cloud-monitoring/synth.metadata @@ -1,22 +1,5 @@ { - "updateTime": "2020-03-06T12:32:55.468505Z", - "sources": [ - { - "git": { - "name": "googleapis", - "remote": "https://github.com/googleapis/googleapis.git", - "sha": "f0b581b5bdf803e45201ecdb3688b60e381628a8", - "internalRef": "299181282" - } - }, - { - "template": { - "name": "node_library", - "origin": "synthtool.gcp", - "version": "2020.2.4" - } - } - ], + "updateTime": "2020-03-31T19:49:37.802729Z", "destinations": [ { "client": { diff --git a/packages/google-cloud-monitoring/system-test/fixtures/sample/src/index.js b/packages/google-cloud-monitoring/system-test/fixtures/sample/src/index.js index 001f06d484b..1a73cd85938 100644 --- a/packages/google-cloud-monitoring/system-test/fixtures/sample/src/index.js +++ b/packages/google-cloud-monitoring/system-test/fixtures/sample/src/index.js @@ -1,4 +1,4 @@ -// Copyright 2019 Google LLC +// Copyright 2020 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -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 monitoring = require('@google-cloud/monitoring'); diff --git a/packages/google-cloud-monitoring/system-test/fixtures/sample/src/index.ts b/packages/google-cloud-monitoring/system-test/fixtures/sample/src/index.ts index a493300d67f..70b78043268 100644 --- a/packages/google-cloud-monitoring/system-test/fixtures/sample/src/index.ts +++ b/packages/google-cloud-monitoring/system-test/fixtures/sample/src/index.ts @@ -1,4 +1,4 @@ -// Copyright 2019 Google LLC +// Copyright 2020 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -16,15 +16,22 @@ // ** https://github.com/googleapis/gapic-generator-typescript ** // ** All changes to this file may be overwritten. ** -import {AlertPolicyServiceClient, GroupServiceClient, MetricServiceClient, NotificationChannelServiceClient, ServiceMonitoringServiceClient, UptimeCheckServiceClient} from '@google-cloud/monitoring'; +import { + AlertPolicyServiceClient, + GroupServiceClient, + MetricServiceClient, + NotificationChannelServiceClient, + ServiceMonitoringServiceClient, + UptimeCheckServiceClient, +} from '@google-cloud/monitoring'; function main() { - const alertPolicyServiceClient = new AlertPolicyServiceClient(); - const groupServiceClient = new GroupServiceClient(); - const metricServiceClient = new MetricServiceClient(); - const notificationChannelServiceClient = new NotificationChannelServiceClient(); - const serviceMonitoringServiceClient = new ServiceMonitoringServiceClient(); - const uptimeCheckServiceClient = new UptimeCheckServiceClient(); + new AlertPolicyServiceClient(); + new GroupServiceClient(); + new MetricServiceClient(); + new NotificationChannelServiceClient(); + new ServiceMonitoringServiceClient(); + new UptimeCheckServiceClient(); } main(); diff --git a/packages/google-cloud-monitoring/system-test/install.ts b/packages/google-cloud-monitoring/system-test/install.ts index c9aa74ec221..c4d80e9c0c8 100644 --- a/packages/google-cloud-monitoring/system-test/install.ts +++ b/packages/google-cloud-monitoring/system-test/install.ts @@ -1,4 +1,4 @@ -// Copyright 2019 Google LLC +// Copyright 2020 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/packages/google-cloud-monitoring/system-test/metrics_service_smoke_test.ts b/packages/google-cloud-monitoring/system-test/metrics_service_smoke_test.ts index efd9be651eb..4923de6f4f8 100644 --- a/packages/google-cloud-monitoring/system-test/metrics_service_smoke_test.ts +++ b/packages/google-cloud-monitoring/system-test/metrics_service_smoke_test.ts @@ -21,6 +21,7 @@ describe('MetricServiceSmokeTest', () => { const projectId = process.env.GCLOUD_PROJECT; it('successfully makes a call to the service using promises', done => { + // eslint-disable-next-line @typescript-eslint/no-var-requires const monitoring = require('../src'); const client = new monitoring.v3.MetricServiceClient({ @@ -43,6 +44,7 @@ describe('MetricServiceSmokeTest', () => { }); it('successfully makes a call to the service using callbacks', done => { + // eslint-disable-next-line @typescript-eslint/no-var-requires const monitoring = require('../src'); const client = new monitoring.v3.MetricServiceClient({ @@ -78,6 +80,7 @@ describe('MetricServiceSmokeTest', () => { }); it('successfully makes a call to the service using streaming', done => { + // eslint-disable-next-line @typescript-eslint/no-var-requires const monitoring = require('../src'); const client = new monitoring.v3.MetricServiceClient({ diff --git a/packages/google-cloud-monitoring/test/gapic-alert_policy_service-v3.ts b/packages/google-cloud-monitoring/test/gapic-alert_policy_service-v3.ts deleted file mode 100644 index bc7b80f2d37..00000000000 --- a/packages/google-cloud-monitoring/test/gapic-alert_policy_service-v3.ts +++ /dev/null @@ -1,375 +0,0 @@ -// Copyright 2019 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -import * as protosTypes from '../protos/protos'; -import * as assert from 'assert'; -import {describe, it} from 'mocha'; -const alertpolicyserviceModule = require('../src'); - -const FAKE_STATUS_CODE = 1; -class FakeError { - name: string; - message: string; - code: number; - constructor(n: number) { - this.name = 'fakeName'; - this.message = 'fake message'; - this.code = n; - } -} -const error = new FakeError(FAKE_STATUS_CODE); -export interface Callback { - (err: FakeError | null, response?: {} | null): void; -} - -export class Operation { - constructor() {} - promise() {} -} -function mockSimpleGrpcMethod( - expectedRequest: {}, - response: {} | null, - error: FakeError | null -) { - return (actualRequest: {}, options: {}, callback: Callback) => { - assert.deepStrictEqual(actualRequest, expectedRequest); - if (error) { - callback(error); - } else if (response) { - callback(null, response); - } else { - callback(null); - } - }; -} -describe('v3.AlertPolicyServiceClient', () => { - it('has servicePath', () => { - const servicePath = - alertpolicyserviceModule.v3.AlertPolicyServiceClient.servicePath; - assert(servicePath); - }); - it('has apiEndpoint', () => { - const apiEndpoint = - alertpolicyserviceModule.v3.AlertPolicyServiceClient.apiEndpoint; - assert(apiEndpoint); - }); - it('has port', () => { - const port = alertpolicyserviceModule.v3.AlertPolicyServiceClient.port; - assert(port); - assert(typeof port === 'number'); - }); - it('should create a client with no option', () => { - const client = new alertpolicyserviceModule.v3.AlertPolicyServiceClient(); - assert(client); - }); - it('should create a client with gRPC fallback', () => { - const client = new alertpolicyserviceModule.v3.AlertPolicyServiceClient({ - fallback: true, - }); - assert(client); - }); - it('has initialize method and supports deferred initialization', async () => { - const client = new alertpolicyserviceModule.v3.AlertPolicyServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.alertPolicyServiceStub, undefined); - await client.initialize(); - assert(client.alertPolicyServiceStub); - }); - it('has close method', () => { - const client = new alertpolicyserviceModule.v3.AlertPolicyServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.close(); - }); - describe('getAlertPolicy', () => { - it('invokes getAlertPolicy without error', done => { - const client = new alertpolicyserviceModule.v3.AlertPolicyServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - // Initialize client before mocking - client.initialize(); - // Mock request - const request: protosTypes.google.monitoring.v3.IGetAlertPolicyRequest = {}; - request.name = ''; - // Mock response - const expectedResponse = {}; - // Mock gRPC layer - client._innerApiCalls.getAlertPolicy = mockSimpleGrpcMethod( - request, - expectedResponse, - null - ); - client.getAlertPolicy(request, (err: {}, response: {}) => { - assert.ifError(err); - assert.deepStrictEqual(response, expectedResponse); - done(); - }); - }); - - it('invokes getAlertPolicy with error', done => { - const client = new alertpolicyserviceModule.v3.AlertPolicyServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - // Initialize client before mocking - client.initialize(); - // Mock request - const request: protosTypes.google.monitoring.v3.IGetAlertPolicyRequest = {}; - request.name = ''; - // Mock response - const expectedResponse = {}; - // Mock gRPC layer - client._innerApiCalls.getAlertPolicy = mockSimpleGrpcMethod( - request, - null, - error - ); - client.getAlertPolicy(request, (err: FakeError, response: {}) => { - assert(err instanceof FakeError); - assert.strictEqual(err.code, FAKE_STATUS_CODE); - assert(typeof response === 'undefined'); - done(); - }); - }); - }); - describe('createAlertPolicy', () => { - it('invokes createAlertPolicy without error', done => { - const client = new alertpolicyserviceModule.v3.AlertPolicyServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - // Initialize client before mocking - client.initialize(); - // Mock request - const request: protosTypes.google.monitoring.v3.ICreateAlertPolicyRequest = {}; - request.name = ''; - // Mock response - const expectedResponse = {}; - // Mock gRPC layer - client._innerApiCalls.createAlertPolicy = mockSimpleGrpcMethod( - request, - expectedResponse, - null - ); - client.createAlertPolicy(request, (err: {}, response: {}) => { - assert.ifError(err); - assert.deepStrictEqual(response, expectedResponse); - done(); - }); - }); - - it('invokes createAlertPolicy with error', done => { - const client = new alertpolicyserviceModule.v3.AlertPolicyServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - // Initialize client before mocking - client.initialize(); - // Mock request - const request: protosTypes.google.monitoring.v3.ICreateAlertPolicyRequest = {}; - request.name = ''; - // Mock response - const expectedResponse = {}; - // Mock gRPC layer - client._innerApiCalls.createAlertPolicy = mockSimpleGrpcMethod( - request, - null, - error - ); - client.createAlertPolicy(request, (err: FakeError, response: {}) => { - assert(err instanceof FakeError); - assert.strictEqual(err.code, FAKE_STATUS_CODE); - assert(typeof response === 'undefined'); - done(); - }); - }); - }); - describe('deleteAlertPolicy', () => { - it('invokes deleteAlertPolicy without error', done => { - const client = new alertpolicyserviceModule.v3.AlertPolicyServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - // Initialize client before mocking - client.initialize(); - // Mock request - const request: protosTypes.google.monitoring.v3.IDeleteAlertPolicyRequest = {}; - request.name = ''; - // Mock response - const expectedResponse = {}; - // Mock gRPC layer - client._innerApiCalls.deleteAlertPolicy = mockSimpleGrpcMethod( - request, - expectedResponse, - null - ); - client.deleteAlertPolicy(request, (err: {}, response: {}) => { - assert.ifError(err); - assert.deepStrictEqual(response, expectedResponse); - done(); - }); - }); - - it('invokes deleteAlertPolicy with error', done => { - const client = new alertpolicyserviceModule.v3.AlertPolicyServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - // Initialize client before mocking - client.initialize(); - // Mock request - const request: protosTypes.google.monitoring.v3.IDeleteAlertPolicyRequest = {}; - request.name = ''; - // Mock response - const expectedResponse = {}; - // Mock gRPC layer - client._innerApiCalls.deleteAlertPolicy = mockSimpleGrpcMethod( - request, - null, - error - ); - client.deleteAlertPolicy(request, (err: FakeError, response: {}) => { - assert(err instanceof FakeError); - assert.strictEqual(err.code, FAKE_STATUS_CODE); - assert(typeof response === 'undefined'); - done(); - }); - }); - }); - describe('updateAlertPolicy', () => { - it('invokes updateAlertPolicy without error', done => { - const client = new alertpolicyserviceModule.v3.AlertPolicyServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - // Initialize client before mocking - client.initialize(); - // Mock request - const request: protosTypes.google.monitoring.v3.IUpdateAlertPolicyRequest = {}; - request.alertPolicy = {}; - request.alertPolicy.name = ''; - // Mock response - const expectedResponse = {}; - // Mock gRPC layer - client._innerApiCalls.updateAlertPolicy = mockSimpleGrpcMethod( - request, - expectedResponse, - null - ); - client.updateAlertPolicy(request, (err: {}, response: {}) => { - assert.ifError(err); - assert.deepStrictEqual(response, expectedResponse); - done(); - }); - }); - - it('invokes updateAlertPolicy with error', done => { - const client = new alertpolicyserviceModule.v3.AlertPolicyServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - // Initialize client before mocking - client.initialize(); - // Mock request - const request: protosTypes.google.monitoring.v3.IUpdateAlertPolicyRequest = {}; - request.alertPolicy = {}; - request.alertPolicy.name = ''; - // Mock response - const expectedResponse = {}; - // Mock gRPC layer - client._innerApiCalls.updateAlertPolicy = mockSimpleGrpcMethod( - request, - null, - error - ); - client.updateAlertPolicy(request, (err: FakeError, response: {}) => { - assert(err instanceof FakeError); - assert.strictEqual(err.code, FAKE_STATUS_CODE); - assert(typeof response === 'undefined'); - done(); - }); - }); - }); - describe('listAlertPolicies', () => { - it('invokes listAlertPolicies without error', done => { - const client = new alertpolicyserviceModule.v3.AlertPolicyServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - // Initialize client before mocking - client.initialize(); - // Mock request - const request: protosTypes.google.monitoring.v3.IListAlertPoliciesRequest = {}; - request.name = ''; - // Mock response - const expectedResponse = {}; - // Mock Grpc layer - client._innerApiCalls.listAlertPolicies = ( - actualRequest: {}, - options: {}, - callback: Callback - ) => { - assert.deepStrictEqual(actualRequest, request); - callback(null, expectedResponse); - }; - client.listAlertPolicies(request, (err: FakeError, response: {}) => { - assert.ifError(err); - assert.deepStrictEqual(response, expectedResponse); - done(); - }); - }); - }); - describe('listAlertPoliciesStream', () => { - it('invokes listAlertPoliciesStream without error', done => { - const client = new alertpolicyserviceModule.v3.AlertPolicyServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - // Initialize client before mocking - client.initialize(); - // Mock request - const request: protosTypes.google.monitoring.v3.IListAlertPoliciesRequest = {}; - request.name = ''; - // Mock response - const expectedResponse = {response: 'data'}; - // Mock Grpc layer - client._innerApiCalls.listAlertPolicies = ( - actualRequest: {}, - options: {}, - callback: Callback - ) => { - assert.deepStrictEqual(actualRequest, request); - callback(null, expectedResponse); - }; - const stream = client - .listAlertPoliciesStream(request, {}) - .on('data', (response: {}) => { - assert.deepStrictEqual(response, expectedResponse); - done(); - }) - .on('error', (err: FakeError) => { - done(err); - }); - stream.write(expectedResponse); - }); - }); -}); diff --git a/packages/google-cloud-monitoring/test/gapic-group_service-v3.ts b/packages/google-cloud-monitoring/test/gapic-group_service-v3.ts deleted file mode 100644 index 941a1a75376..00000000000 --- a/packages/google-cloud-monitoring/test/gapic-group_service-v3.ts +++ /dev/null @@ -1,436 +0,0 @@ -// Copyright 2019 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -import * as protosTypes from '../protos/protos'; -import * as assert from 'assert'; -import {describe, it} from 'mocha'; -const groupserviceModule = require('../src'); - -const FAKE_STATUS_CODE = 1; -class FakeError { - name: string; - message: string; - code: number; - constructor(n: number) { - this.name = 'fakeName'; - this.message = 'fake message'; - this.code = n; - } -} -const error = new FakeError(FAKE_STATUS_CODE); -export interface Callback { - (err: FakeError | null, response?: {} | null): void; -} - -export class Operation { - constructor() {} - promise() {} -} -function mockSimpleGrpcMethod( - expectedRequest: {}, - response: {} | null, - error: FakeError | null -) { - return (actualRequest: {}, options: {}, callback: Callback) => { - assert.deepStrictEqual(actualRequest, expectedRequest); - if (error) { - callback(error); - } else if (response) { - callback(null, response); - } else { - callback(null); - } - }; -} -describe('v3.GroupServiceClient', () => { - it('has servicePath', () => { - const servicePath = groupserviceModule.v3.GroupServiceClient.servicePath; - assert(servicePath); - }); - it('has apiEndpoint', () => { - const apiEndpoint = groupserviceModule.v3.GroupServiceClient.apiEndpoint; - assert(apiEndpoint); - }); - it('has port', () => { - const port = groupserviceModule.v3.GroupServiceClient.port; - assert(port); - assert(typeof port === 'number'); - }); - it('should create a client with no option', () => { - const client = new groupserviceModule.v3.GroupServiceClient(); - assert(client); - }); - it('should create a client with gRPC fallback', () => { - const client = new groupserviceModule.v3.GroupServiceClient({ - fallback: true, - }); - assert(client); - }); - it('has initialize method and supports deferred initialization', async () => { - const client = new groupserviceModule.v3.GroupServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.groupServiceStub, undefined); - await client.initialize(); - assert(client.groupServiceStub); - }); - it('has close method', () => { - const client = new groupserviceModule.v3.GroupServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.close(); - }); - describe('getGroup', () => { - it('invokes getGroup without error', done => { - const client = new groupserviceModule.v3.GroupServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - // Initialize client before mocking - client.initialize(); - // Mock request - const request: protosTypes.google.monitoring.v3.IGetGroupRequest = {}; - request.name = ''; - // Mock response - const expectedResponse = {}; - // Mock gRPC layer - client._innerApiCalls.getGroup = mockSimpleGrpcMethod( - request, - expectedResponse, - null - ); - client.getGroup(request, (err: {}, response: {}) => { - assert.ifError(err); - assert.deepStrictEqual(response, expectedResponse); - done(); - }); - }); - - it('invokes getGroup with error', done => { - const client = new groupserviceModule.v3.GroupServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - // Initialize client before mocking - client.initialize(); - // Mock request - const request: protosTypes.google.monitoring.v3.IGetGroupRequest = {}; - request.name = ''; - // Mock response - const expectedResponse = {}; - // Mock gRPC layer - client._innerApiCalls.getGroup = mockSimpleGrpcMethod( - request, - null, - error - ); - client.getGroup(request, (err: FakeError, response: {}) => { - assert(err instanceof FakeError); - assert.strictEqual(err.code, FAKE_STATUS_CODE); - assert(typeof response === 'undefined'); - done(); - }); - }); - }); - describe('createGroup', () => { - it('invokes createGroup without error', done => { - const client = new groupserviceModule.v3.GroupServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - // Initialize client before mocking - client.initialize(); - // Mock request - const request: protosTypes.google.monitoring.v3.ICreateGroupRequest = {}; - request.name = ''; - // Mock response - const expectedResponse = {}; - // Mock gRPC layer - client._innerApiCalls.createGroup = mockSimpleGrpcMethod( - request, - expectedResponse, - null - ); - client.createGroup(request, (err: {}, response: {}) => { - assert.ifError(err); - assert.deepStrictEqual(response, expectedResponse); - done(); - }); - }); - - it('invokes createGroup with error', done => { - const client = new groupserviceModule.v3.GroupServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - // Initialize client before mocking - client.initialize(); - // Mock request - const request: protosTypes.google.monitoring.v3.ICreateGroupRequest = {}; - request.name = ''; - // Mock response - const expectedResponse = {}; - // Mock gRPC layer - client._innerApiCalls.createGroup = mockSimpleGrpcMethod( - request, - null, - error - ); - client.createGroup(request, (err: FakeError, response: {}) => { - assert(err instanceof FakeError); - assert.strictEqual(err.code, FAKE_STATUS_CODE); - assert(typeof response === 'undefined'); - done(); - }); - }); - }); - describe('updateGroup', () => { - it('invokes updateGroup without error', done => { - const client = new groupserviceModule.v3.GroupServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - // Initialize client before mocking - client.initialize(); - // Mock request - const request: protosTypes.google.monitoring.v3.IUpdateGroupRequest = {}; - request.group = {}; - request.group.name = ''; - // Mock response - const expectedResponse = {}; - // Mock gRPC layer - client._innerApiCalls.updateGroup = mockSimpleGrpcMethod( - request, - expectedResponse, - null - ); - client.updateGroup(request, (err: {}, response: {}) => { - assert.ifError(err); - assert.deepStrictEqual(response, expectedResponse); - done(); - }); - }); - - it('invokes updateGroup with error', done => { - const client = new groupserviceModule.v3.GroupServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - // Initialize client before mocking - client.initialize(); - // Mock request - const request: protosTypes.google.monitoring.v3.IUpdateGroupRequest = {}; - request.group = {}; - request.group.name = ''; - // Mock response - const expectedResponse = {}; - // Mock gRPC layer - client._innerApiCalls.updateGroup = mockSimpleGrpcMethod( - request, - null, - error - ); - client.updateGroup(request, (err: FakeError, response: {}) => { - assert(err instanceof FakeError); - assert.strictEqual(err.code, FAKE_STATUS_CODE); - assert(typeof response === 'undefined'); - done(); - }); - }); - }); - describe('deleteGroup', () => { - it('invokes deleteGroup without error', done => { - const client = new groupserviceModule.v3.GroupServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - // Initialize client before mocking - client.initialize(); - // Mock request - const request: protosTypes.google.monitoring.v3.IDeleteGroupRequest = {}; - request.name = ''; - // Mock response - const expectedResponse = {}; - // Mock gRPC layer - client._innerApiCalls.deleteGroup = mockSimpleGrpcMethod( - request, - expectedResponse, - null - ); - client.deleteGroup(request, (err: {}, response: {}) => { - assert.ifError(err); - assert.deepStrictEqual(response, expectedResponse); - done(); - }); - }); - - it('invokes deleteGroup with error', done => { - const client = new groupserviceModule.v3.GroupServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - // Initialize client before mocking - client.initialize(); - // Mock request - const request: protosTypes.google.monitoring.v3.IDeleteGroupRequest = {}; - request.name = ''; - // Mock response - const expectedResponse = {}; - // Mock gRPC layer - client._innerApiCalls.deleteGroup = mockSimpleGrpcMethod( - request, - null, - error - ); - client.deleteGroup(request, (err: FakeError, response: {}) => { - assert(err instanceof FakeError); - assert.strictEqual(err.code, FAKE_STATUS_CODE); - assert(typeof response === 'undefined'); - done(); - }); - }); - }); - describe('listGroups', () => { - it('invokes listGroups without error', done => { - const client = new groupserviceModule.v3.GroupServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - // Initialize client before mocking - client.initialize(); - // Mock request - const request: protosTypes.google.monitoring.v3.IListGroupsRequest = {}; - request.name = ''; - // Mock response - const expectedResponse = {}; - // Mock Grpc layer - client._innerApiCalls.listGroups = ( - actualRequest: {}, - options: {}, - callback: Callback - ) => { - assert.deepStrictEqual(actualRequest, request); - callback(null, expectedResponse); - }; - client.listGroups(request, (err: FakeError, response: {}) => { - assert.ifError(err); - assert.deepStrictEqual(response, expectedResponse); - done(); - }); - }); - }); - describe('listGroupsStream', () => { - it('invokes listGroupsStream without error', done => { - const client = new groupserviceModule.v3.GroupServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - // Initialize client before mocking - client.initialize(); - // Mock request - const request: protosTypes.google.monitoring.v3.IListGroupsRequest = {}; - request.name = ''; - // Mock response - const expectedResponse = {response: 'data'}; - // Mock Grpc layer - client._innerApiCalls.listGroups = ( - actualRequest: {}, - options: {}, - callback: Callback - ) => { - assert.deepStrictEqual(actualRequest, request); - callback(null, expectedResponse); - }; - const stream = client - .listGroupsStream(request, {}) - .on('data', (response: {}) => { - assert.deepStrictEqual(response, expectedResponse); - done(); - }) - .on('error', (err: FakeError) => { - done(err); - }); - stream.write(expectedResponse); - }); - }); - describe('listGroupMembers', () => { - it('invokes listGroupMembers without error', done => { - const client = new groupserviceModule.v3.GroupServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - // Initialize client before mocking - client.initialize(); - // Mock request - const request: protosTypes.google.monitoring.v3.IListGroupMembersRequest = {}; - request.name = ''; - // Mock response - const expectedResponse = {}; - // Mock Grpc layer - client._innerApiCalls.listGroupMembers = ( - actualRequest: {}, - options: {}, - callback: Callback - ) => { - assert.deepStrictEqual(actualRequest, request); - callback(null, expectedResponse); - }; - client.listGroupMembers(request, (err: FakeError, response: {}) => { - assert.ifError(err); - assert.deepStrictEqual(response, expectedResponse); - done(); - }); - }); - }); - describe('listGroupMembersStream', () => { - it('invokes listGroupMembersStream without error', done => { - const client = new groupserviceModule.v3.GroupServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - // Initialize client before mocking - client.initialize(); - // Mock request - const request: protosTypes.google.monitoring.v3.IListGroupMembersRequest = {}; - request.name = ''; - // Mock response - const expectedResponse = {response: 'data'}; - // Mock Grpc layer - client._innerApiCalls.listGroupMembers = ( - actualRequest: {}, - options: {}, - callback: Callback - ) => { - assert.deepStrictEqual(actualRequest, request); - callback(null, expectedResponse); - }; - const stream = client - .listGroupMembersStream(request, {}) - .on('data', (response: {}) => { - assert.deepStrictEqual(response, expectedResponse); - done(); - }) - .on('error', (err: FakeError) => { - done(err); - }); - stream.write(expectedResponse); - }); - }); -}); diff --git a/packages/google-cloud-monitoring/test/gapic-metric_service-v3.ts b/packages/google-cloud-monitoring/test/gapic-metric_service-v3.ts deleted file mode 100644 index 6490176488a..00000000000 --- a/packages/google-cloud-monitoring/test/gapic-metric_service-v3.ts +++ /dev/null @@ -1,558 +0,0 @@ -// Copyright 2019 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -import * as protosTypes from '../protos/protos'; -import * as assert from 'assert'; -import {describe, it} from 'mocha'; -const metricserviceModule = require('../src'); - -const FAKE_STATUS_CODE = 1; -class FakeError { - name: string; - message: string; - code: number; - constructor(n: number) { - this.name = 'fakeName'; - this.message = 'fake message'; - this.code = n; - } -} -const error = new FakeError(FAKE_STATUS_CODE); -export interface Callback { - (err: FakeError | null, response?: {} | null): void; -} - -export class Operation { - constructor() {} - promise() {} -} -function mockSimpleGrpcMethod( - expectedRequest: {}, - response: {} | null, - error: FakeError | null -) { - return (actualRequest: {}, options: {}, callback: Callback) => { - assert.deepStrictEqual(actualRequest, expectedRequest); - if (error) { - callback(error); - } else if (response) { - callback(null, response); - } else { - callback(null); - } - }; -} -describe('v3.MetricServiceClient', () => { - it('has servicePath', () => { - const servicePath = metricserviceModule.v3.MetricServiceClient.servicePath; - assert(servicePath); - }); - it('has apiEndpoint', () => { - const apiEndpoint = metricserviceModule.v3.MetricServiceClient.apiEndpoint; - assert(apiEndpoint); - }); - it('has port', () => { - const port = metricserviceModule.v3.MetricServiceClient.port; - assert(port); - assert(typeof port === 'number'); - }); - it('should create a client with no option', () => { - const client = new metricserviceModule.v3.MetricServiceClient(); - assert(client); - }); - it('should create a client with gRPC fallback', () => { - const client = new metricserviceModule.v3.MetricServiceClient({ - fallback: true, - }); - assert(client); - }); - it('has initialize method and supports deferred initialization', async () => { - const client = new metricserviceModule.v3.MetricServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.metricServiceStub, undefined); - await client.initialize(); - assert(client.metricServiceStub); - }); - it('has close method', () => { - const client = new metricserviceModule.v3.MetricServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.close(); - }); - describe('getMonitoredResourceDescriptor', () => { - it('invokes getMonitoredResourceDescriptor without error', done => { - const client = new metricserviceModule.v3.MetricServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - // Initialize client before mocking - client.initialize(); - // Mock request - const request: protosTypes.google.monitoring.v3.IGetMonitoredResourceDescriptorRequest = {}; - request.name = ''; - // Mock response - const expectedResponse = {}; - // Mock gRPC layer - client._innerApiCalls.getMonitoredResourceDescriptor = mockSimpleGrpcMethod( - request, - expectedResponse, - null - ); - client.getMonitoredResourceDescriptor( - request, - (err: {}, response: {}) => { - assert.ifError(err); - assert.deepStrictEqual(response, expectedResponse); - done(); - } - ); - }); - - it('invokes getMonitoredResourceDescriptor with error', done => { - const client = new metricserviceModule.v3.MetricServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - // Initialize client before mocking - client.initialize(); - // Mock request - const request: protosTypes.google.monitoring.v3.IGetMonitoredResourceDescriptorRequest = {}; - request.name = ''; - // Mock response - const expectedResponse = {}; - // Mock gRPC layer - client._innerApiCalls.getMonitoredResourceDescriptor = mockSimpleGrpcMethod( - request, - null, - error - ); - client.getMonitoredResourceDescriptor( - request, - (err: FakeError, response: {}) => { - assert(err instanceof FakeError); - assert.strictEqual(err.code, FAKE_STATUS_CODE); - assert(typeof response === 'undefined'); - done(); - } - ); - }); - }); - describe('getMetricDescriptor', () => { - it('invokes getMetricDescriptor without error', done => { - const client = new metricserviceModule.v3.MetricServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - // Initialize client before mocking - client.initialize(); - // Mock request - const request: protosTypes.google.monitoring.v3.IGetMetricDescriptorRequest = {}; - request.name = ''; - // Mock response - const expectedResponse = {}; - // Mock gRPC layer - client._innerApiCalls.getMetricDescriptor = mockSimpleGrpcMethod( - request, - expectedResponse, - null - ); - client.getMetricDescriptor(request, (err: {}, response: {}) => { - assert.ifError(err); - assert.deepStrictEqual(response, expectedResponse); - done(); - }); - }); - - it('invokes getMetricDescriptor with error', done => { - const client = new metricserviceModule.v3.MetricServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - // Initialize client before mocking - client.initialize(); - // Mock request - const request: protosTypes.google.monitoring.v3.IGetMetricDescriptorRequest = {}; - request.name = ''; - // Mock response - const expectedResponse = {}; - // Mock gRPC layer - client._innerApiCalls.getMetricDescriptor = mockSimpleGrpcMethod( - request, - null, - error - ); - client.getMetricDescriptor(request, (err: FakeError, response: {}) => { - assert(err instanceof FakeError); - assert.strictEqual(err.code, FAKE_STATUS_CODE); - assert(typeof response === 'undefined'); - done(); - }); - }); - }); - describe('createMetricDescriptor', () => { - it('invokes createMetricDescriptor without error', done => { - const client = new metricserviceModule.v3.MetricServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - // Initialize client before mocking - client.initialize(); - // Mock request - const request: protosTypes.google.monitoring.v3.ICreateMetricDescriptorRequest = {}; - request.name = ''; - // Mock response - const expectedResponse = {}; - // Mock gRPC layer - client._innerApiCalls.createMetricDescriptor = mockSimpleGrpcMethod( - request, - expectedResponse, - null - ); - client.createMetricDescriptor(request, (err: {}, response: {}) => { - assert.ifError(err); - assert.deepStrictEqual(response, expectedResponse); - done(); - }); - }); - - it('invokes createMetricDescriptor with error', done => { - const client = new metricserviceModule.v3.MetricServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - // Initialize client before mocking - client.initialize(); - // Mock request - const request: protosTypes.google.monitoring.v3.ICreateMetricDescriptorRequest = {}; - request.name = ''; - // Mock response - const expectedResponse = {}; - // Mock gRPC layer - client._innerApiCalls.createMetricDescriptor = mockSimpleGrpcMethod( - request, - null, - error - ); - client.createMetricDescriptor(request, (err: FakeError, response: {}) => { - assert(err instanceof FakeError); - assert.strictEqual(err.code, FAKE_STATUS_CODE); - assert(typeof response === 'undefined'); - done(); - }); - }); - }); - describe('deleteMetricDescriptor', () => { - it('invokes deleteMetricDescriptor without error', done => { - const client = new metricserviceModule.v3.MetricServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - // Initialize client before mocking - client.initialize(); - // Mock request - const request: protosTypes.google.monitoring.v3.IDeleteMetricDescriptorRequest = {}; - request.name = ''; - // Mock response - const expectedResponse = {}; - // Mock gRPC layer - client._innerApiCalls.deleteMetricDescriptor = mockSimpleGrpcMethod( - request, - expectedResponse, - null - ); - client.deleteMetricDescriptor(request, (err: {}, response: {}) => { - assert.ifError(err); - assert.deepStrictEqual(response, expectedResponse); - done(); - }); - }); - - it('invokes deleteMetricDescriptor with error', done => { - const client = new metricserviceModule.v3.MetricServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - // Initialize client before mocking - client.initialize(); - // Mock request - const request: protosTypes.google.monitoring.v3.IDeleteMetricDescriptorRequest = {}; - request.name = ''; - // Mock response - const expectedResponse = {}; - // Mock gRPC layer - client._innerApiCalls.deleteMetricDescriptor = mockSimpleGrpcMethod( - request, - null, - error - ); - client.deleteMetricDescriptor(request, (err: FakeError, response: {}) => { - assert(err instanceof FakeError); - assert.strictEqual(err.code, FAKE_STATUS_CODE); - assert(typeof response === 'undefined'); - done(); - }); - }); - }); - describe('createTimeSeries', () => { - it('invokes createTimeSeries without error', done => { - const client = new metricserviceModule.v3.MetricServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - // Initialize client before mocking - client.initialize(); - // Mock request - const request: protosTypes.google.monitoring.v3.ICreateTimeSeriesRequest = {}; - request.name = ''; - // Mock response - const expectedResponse = {}; - // Mock gRPC layer - client._innerApiCalls.createTimeSeries = mockSimpleGrpcMethod( - request, - expectedResponse, - null - ); - client.createTimeSeries(request, (err: {}, response: {}) => { - assert.ifError(err); - assert.deepStrictEqual(response, expectedResponse); - done(); - }); - }); - - it('invokes createTimeSeries with error', done => { - const client = new metricserviceModule.v3.MetricServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - // Initialize client before mocking - client.initialize(); - // Mock request - const request: protosTypes.google.monitoring.v3.ICreateTimeSeriesRequest = {}; - request.name = ''; - // Mock response - const expectedResponse = {}; - // Mock gRPC layer - client._innerApiCalls.createTimeSeries = mockSimpleGrpcMethod( - request, - null, - error - ); - client.createTimeSeries(request, (err: FakeError, response: {}) => { - assert(err instanceof FakeError); - assert.strictEqual(err.code, FAKE_STATUS_CODE); - assert(typeof response === 'undefined'); - done(); - }); - }); - }); - describe('listMonitoredResourceDescriptors', () => { - it('invokes listMonitoredResourceDescriptors without error', done => { - const client = new metricserviceModule.v3.MetricServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - // Initialize client before mocking - client.initialize(); - // Mock request - const request: protosTypes.google.monitoring.v3.IListMonitoredResourceDescriptorsRequest = {}; - request.name = ''; - // Mock response - const expectedResponse = {}; - // Mock Grpc layer - client._innerApiCalls.listMonitoredResourceDescriptors = ( - actualRequest: {}, - options: {}, - callback: Callback - ) => { - assert.deepStrictEqual(actualRequest, request); - callback(null, expectedResponse); - }; - client.listMonitoredResourceDescriptors( - request, - (err: FakeError, response: {}) => { - assert.ifError(err); - assert.deepStrictEqual(response, expectedResponse); - done(); - } - ); - }); - }); - describe('listMonitoredResourceDescriptorsStream', () => { - it('invokes listMonitoredResourceDescriptorsStream without error', done => { - const client = new metricserviceModule.v3.MetricServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - // Initialize client before mocking - client.initialize(); - // Mock request - const request: protosTypes.google.monitoring.v3.IListMonitoredResourceDescriptorsRequest = {}; - request.name = ''; - // Mock response - const expectedResponse = {response: 'data'}; - // Mock Grpc layer - client._innerApiCalls.listMonitoredResourceDescriptors = ( - actualRequest: {}, - options: {}, - callback: Callback - ) => { - assert.deepStrictEqual(actualRequest, request); - callback(null, expectedResponse); - }; - const stream = client - .listMonitoredResourceDescriptorsStream(request, {}) - .on('data', (response: {}) => { - assert.deepStrictEqual(response, expectedResponse); - done(); - }) - .on('error', (err: FakeError) => { - done(err); - }); - stream.write(expectedResponse); - }); - }); - describe('listMetricDescriptors', () => { - it('invokes listMetricDescriptors without error', done => { - const client = new metricserviceModule.v3.MetricServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - // Initialize client before mocking - client.initialize(); - // Mock request - const request: protosTypes.google.monitoring.v3.IListMetricDescriptorsRequest = {}; - request.name = ''; - // Mock response - const expectedResponse = {}; - // Mock Grpc layer - client._innerApiCalls.listMetricDescriptors = ( - actualRequest: {}, - options: {}, - callback: Callback - ) => { - assert.deepStrictEqual(actualRequest, request); - callback(null, expectedResponse); - }; - client.listMetricDescriptors(request, (err: FakeError, response: {}) => { - assert.ifError(err); - assert.deepStrictEqual(response, expectedResponse); - done(); - }); - }); - }); - describe('listMetricDescriptorsStream', () => { - it('invokes listMetricDescriptorsStream without error', done => { - const client = new metricserviceModule.v3.MetricServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - // Initialize client before mocking - client.initialize(); - // Mock request - const request: protosTypes.google.monitoring.v3.IListMetricDescriptorsRequest = {}; - request.name = ''; - // Mock response - const expectedResponse = {response: 'data'}; - // Mock Grpc layer - client._innerApiCalls.listMetricDescriptors = ( - actualRequest: {}, - options: {}, - callback: Callback - ) => { - assert.deepStrictEqual(actualRequest, request); - callback(null, expectedResponse); - }; - const stream = client - .listMetricDescriptorsStream(request, {}) - .on('data', (response: {}) => { - assert.deepStrictEqual(response, expectedResponse); - done(); - }) - .on('error', (err: FakeError) => { - done(err); - }); - stream.write(expectedResponse); - }); - }); - describe('listTimeSeries', () => { - it('invokes listTimeSeries without error', done => { - const client = new metricserviceModule.v3.MetricServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - // Initialize client before mocking - client.initialize(); - // Mock request - const request: protosTypes.google.monitoring.v3.IListTimeSeriesRequest = {}; - request.name = ''; - // Mock response - const expectedResponse = {}; - // Mock Grpc layer - client._innerApiCalls.listTimeSeries = ( - actualRequest: {}, - options: {}, - callback: Callback - ) => { - assert.deepStrictEqual(actualRequest, request); - callback(null, expectedResponse); - }; - client.listTimeSeries(request, (err: FakeError, response: {}) => { - assert.ifError(err); - assert.deepStrictEqual(response, expectedResponse); - done(); - }); - }); - }); - describe('listTimeSeriesStream', () => { - it('invokes listTimeSeriesStream without error', done => { - const client = new metricserviceModule.v3.MetricServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - // Initialize client before mocking - client.initialize(); - // Mock request - const request: protosTypes.google.monitoring.v3.IListTimeSeriesRequest = {}; - request.name = ''; - // Mock response - const expectedResponse = {response: 'data'}; - // Mock Grpc layer - client._innerApiCalls.listTimeSeries = ( - actualRequest: {}, - options: {}, - callback: Callback - ) => { - assert.deepStrictEqual(actualRequest, request); - callback(null, expectedResponse); - }; - const stream = client - .listTimeSeriesStream(request, {}) - .on('data', (response: {}) => { - assert.deepStrictEqual(response, expectedResponse); - done(); - }) - .on('error', (err: FakeError) => { - done(err); - }); - stream.write(expectedResponse); - }); - }); -}); diff --git a/packages/google-cloud-monitoring/test/gapic-notification_channel_service-v3.ts b/packages/google-cloud-monitoring/test/gapic-notification_channel_service-v3.ts deleted file mode 100644 index 85398175164..00000000000 --- a/packages/google-cloud-monitoring/test/gapic-notification_channel_service-v3.ts +++ /dev/null @@ -1,731 +0,0 @@ -// Copyright 2019 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -import * as protosTypes from '../protos/protos'; -import * as assert from 'assert'; -import {describe, it} from 'mocha'; -const notificationchannelserviceModule = require('../src'); - -const FAKE_STATUS_CODE = 1; -class FakeError { - name: string; - message: string; - code: number; - constructor(n: number) { - this.name = 'fakeName'; - this.message = 'fake message'; - this.code = n; - } -} -const error = new FakeError(FAKE_STATUS_CODE); -export interface Callback { - (err: FakeError | null, response?: {} | null): void; -} - -export class Operation { - constructor() {} - promise() {} -} -function mockSimpleGrpcMethod( - expectedRequest: {}, - response: {} | null, - error: FakeError | null -) { - return (actualRequest: {}, options: {}, callback: Callback) => { - assert.deepStrictEqual(actualRequest, expectedRequest); - if (error) { - callback(error); - } else if (response) { - callback(null, response); - } else { - callback(null); - } - }; -} -describe('v3.NotificationChannelServiceClient', () => { - it('has servicePath', () => { - const servicePath = - notificationchannelserviceModule.v3.NotificationChannelServiceClient - .servicePath; - assert(servicePath); - }); - it('has apiEndpoint', () => { - const apiEndpoint = - notificationchannelserviceModule.v3.NotificationChannelServiceClient - .apiEndpoint; - assert(apiEndpoint); - }); - it('has port', () => { - const port = - notificationchannelserviceModule.v3.NotificationChannelServiceClient.port; - assert(port); - assert(typeof port === 'number'); - }); - it('should create a client with no option', () => { - const client = new notificationchannelserviceModule.v3.NotificationChannelServiceClient(); - assert(client); - }); - it('should create a client with gRPC fallback', () => { - const client = new notificationchannelserviceModule.v3.NotificationChannelServiceClient( - { - fallback: true, - } - ); - assert(client); - }); - it('has initialize method and supports deferred initialization', async () => { - const client = new notificationchannelserviceModule.v3.NotificationChannelServiceClient( - { - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - } - ); - assert.strictEqual(client.notificationChannelServiceStub, undefined); - await client.initialize(); - assert(client.notificationChannelServiceStub); - }); - it('has close method', () => { - const client = new notificationchannelserviceModule.v3.NotificationChannelServiceClient( - { - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - } - ); - client.close(); - }); - describe('getNotificationChannelDescriptor', () => { - it('invokes getNotificationChannelDescriptor without error', done => { - const client = new notificationchannelserviceModule.v3.NotificationChannelServiceClient( - { - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - } - ); - // Initialize client before mocking - client.initialize(); - // Mock request - const request: protosTypes.google.monitoring.v3.IGetNotificationChannelDescriptorRequest = {}; - request.name = ''; - // Mock response - const expectedResponse = {}; - // Mock gRPC layer - client._innerApiCalls.getNotificationChannelDescriptor = mockSimpleGrpcMethod( - request, - expectedResponse, - null - ); - client.getNotificationChannelDescriptor( - request, - (err: {}, response: {}) => { - assert.ifError(err); - assert.deepStrictEqual(response, expectedResponse); - done(); - } - ); - }); - - it('invokes getNotificationChannelDescriptor with error', done => { - const client = new notificationchannelserviceModule.v3.NotificationChannelServiceClient( - { - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - } - ); - // Initialize client before mocking - client.initialize(); - // Mock request - const request: protosTypes.google.monitoring.v3.IGetNotificationChannelDescriptorRequest = {}; - request.name = ''; - // Mock response - const expectedResponse = {}; - // Mock gRPC layer - client._innerApiCalls.getNotificationChannelDescriptor = mockSimpleGrpcMethod( - request, - null, - error - ); - client.getNotificationChannelDescriptor( - request, - (err: FakeError, response: {}) => { - assert(err instanceof FakeError); - assert.strictEqual(err.code, FAKE_STATUS_CODE); - assert(typeof response === 'undefined'); - done(); - } - ); - }); - }); - describe('getNotificationChannel', () => { - it('invokes getNotificationChannel without error', done => { - const client = new notificationchannelserviceModule.v3.NotificationChannelServiceClient( - { - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - } - ); - // Initialize client before mocking - client.initialize(); - // Mock request - const request: protosTypes.google.monitoring.v3.IGetNotificationChannelRequest = {}; - request.name = ''; - // Mock response - const expectedResponse = {}; - // Mock gRPC layer - client._innerApiCalls.getNotificationChannel = mockSimpleGrpcMethod( - request, - expectedResponse, - null - ); - client.getNotificationChannel(request, (err: {}, response: {}) => { - assert.ifError(err); - assert.deepStrictEqual(response, expectedResponse); - done(); - }); - }); - - it('invokes getNotificationChannel with error', done => { - const client = new notificationchannelserviceModule.v3.NotificationChannelServiceClient( - { - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - } - ); - // Initialize client before mocking - client.initialize(); - // Mock request - const request: protosTypes.google.monitoring.v3.IGetNotificationChannelRequest = {}; - request.name = ''; - // Mock response - const expectedResponse = {}; - // Mock gRPC layer - client._innerApiCalls.getNotificationChannel = mockSimpleGrpcMethod( - request, - null, - error - ); - client.getNotificationChannel(request, (err: FakeError, response: {}) => { - assert(err instanceof FakeError); - assert.strictEqual(err.code, FAKE_STATUS_CODE); - assert(typeof response === 'undefined'); - done(); - }); - }); - }); - describe('createNotificationChannel', () => { - it('invokes createNotificationChannel without error', done => { - const client = new notificationchannelserviceModule.v3.NotificationChannelServiceClient( - { - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - } - ); - // Initialize client before mocking - client.initialize(); - // Mock request - const request: protosTypes.google.monitoring.v3.ICreateNotificationChannelRequest = {}; - request.name = ''; - // Mock response - const expectedResponse = {}; - // Mock gRPC layer - client._innerApiCalls.createNotificationChannel = mockSimpleGrpcMethod( - request, - expectedResponse, - null - ); - client.createNotificationChannel(request, (err: {}, response: {}) => { - assert.ifError(err); - assert.deepStrictEqual(response, expectedResponse); - done(); - }); - }); - - it('invokes createNotificationChannel with error', done => { - const client = new notificationchannelserviceModule.v3.NotificationChannelServiceClient( - { - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - } - ); - // Initialize client before mocking - client.initialize(); - // Mock request - const request: protosTypes.google.monitoring.v3.ICreateNotificationChannelRequest = {}; - request.name = ''; - // Mock response - const expectedResponse = {}; - // Mock gRPC layer - client._innerApiCalls.createNotificationChannel = mockSimpleGrpcMethod( - request, - null, - error - ); - client.createNotificationChannel( - request, - (err: FakeError, response: {}) => { - assert(err instanceof FakeError); - assert.strictEqual(err.code, FAKE_STATUS_CODE); - assert(typeof response === 'undefined'); - done(); - } - ); - }); - }); - describe('updateNotificationChannel', () => { - it('invokes updateNotificationChannel without error', done => { - const client = new notificationchannelserviceModule.v3.NotificationChannelServiceClient( - { - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - } - ); - // Initialize client before mocking - client.initialize(); - // Mock request - const request: protosTypes.google.monitoring.v3.IUpdateNotificationChannelRequest = {}; - request.notificationChannel = {}; - request.notificationChannel.name = ''; - // Mock response - const expectedResponse = {}; - // Mock gRPC layer - client._innerApiCalls.updateNotificationChannel = mockSimpleGrpcMethod( - request, - expectedResponse, - null - ); - client.updateNotificationChannel(request, (err: {}, response: {}) => { - assert.ifError(err); - assert.deepStrictEqual(response, expectedResponse); - done(); - }); - }); - - it('invokes updateNotificationChannel with error', done => { - const client = new notificationchannelserviceModule.v3.NotificationChannelServiceClient( - { - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - } - ); - // Initialize client before mocking - client.initialize(); - // Mock request - const request: protosTypes.google.monitoring.v3.IUpdateNotificationChannelRequest = {}; - request.notificationChannel = {}; - request.notificationChannel.name = ''; - // Mock response - const expectedResponse = {}; - // Mock gRPC layer - client._innerApiCalls.updateNotificationChannel = mockSimpleGrpcMethod( - request, - null, - error - ); - client.updateNotificationChannel( - request, - (err: FakeError, response: {}) => { - assert(err instanceof FakeError); - assert.strictEqual(err.code, FAKE_STATUS_CODE); - assert(typeof response === 'undefined'); - done(); - } - ); - }); - }); - describe('deleteNotificationChannel', () => { - it('invokes deleteNotificationChannel without error', done => { - const client = new notificationchannelserviceModule.v3.NotificationChannelServiceClient( - { - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - } - ); - // Initialize client before mocking - client.initialize(); - // Mock request - const request: protosTypes.google.monitoring.v3.IDeleteNotificationChannelRequest = {}; - request.name = ''; - // Mock response - const expectedResponse = {}; - // Mock gRPC layer - client._innerApiCalls.deleteNotificationChannel = mockSimpleGrpcMethod( - request, - expectedResponse, - null - ); - client.deleteNotificationChannel(request, (err: {}, response: {}) => { - assert.ifError(err); - assert.deepStrictEqual(response, expectedResponse); - done(); - }); - }); - - it('invokes deleteNotificationChannel with error', done => { - const client = new notificationchannelserviceModule.v3.NotificationChannelServiceClient( - { - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - } - ); - // Initialize client before mocking - client.initialize(); - // Mock request - const request: protosTypes.google.monitoring.v3.IDeleteNotificationChannelRequest = {}; - request.name = ''; - // Mock response - const expectedResponse = {}; - // Mock gRPC layer - client._innerApiCalls.deleteNotificationChannel = mockSimpleGrpcMethod( - request, - null, - error - ); - client.deleteNotificationChannel( - request, - (err: FakeError, response: {}) => { - assert(err instanceof FakeError); - assert.strictEqual(err.code, FAKE_STATUS_CODE); - assert(typeof response === 'undefined'); - done(); - } - ); - }); - }); - describe('sendNotificationChannelVerificationCode', () => { - it('invokes sendNotificationChannelVerificationCode without error', done => { - const client = new notificationchannelserviceModule.v3.NotificationChannelServiceClient( - { - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - } - ); - // Initialize client before mocking - client.initialize(); - // Mock request - const request: protosTypes.google.monitoring.v3.ISendNotificationChannelVerificationCodeRequest = {}; - request.name = ''; - // Mock response - const expectedResponse = {}; - // Mock gRPC layer - client._innerApiCalls.sendNotificationChannelVerificationCode = mockSimpleGrpcMethod( - request, - expectedResponse, - null - ); - client.sendNotificationChannelVerificationCode( - request, - (err: {}, response: {}) => { - assert.ifError(err); - assert.deepStrictEqual(response, expectedResponse); - done(); - } - ); - }); - - it('invokes sendNotificationChannelVerificationCode with error', done => { - const client = new notificationchannelserviceModule.v3.NotificationChannelServiceClient( - { - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - } - ); - // Initialize client before mocking - client.initialize(); - // Mock request - const request: protosTypes.google.monitoring.v3.ISendNotificationChannelVerificationCodeRequest = {}; - request.name = ''; - // Mock response - const expectedResponse = {}; - // Mock gRPC layer - client._innerApiCalls.sendNotificationChannelVerificationCode = mockSimpleGrpcMethod( - request, - null, - error - ); - client.sendNotificationChannelVerificationCode( - request, - (err: FakeError, response: {}) => { - assert(err instanceof FakeError); - assert.strictEqual(err.code, FAKE_STATUS_CODE); - assert(typeof response === 'undefined'); - done(); - } - ); - }); - }); - describe('getNotificationChannelVerificationCode', () => { - it('invokes getNotificationChannelVerificationCode without error', done => { - const client = new notificationchannelserviceModule.v3.NotificationChannelServiceClient( - { - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - } - ); - // Initialize client before mocking - client.initialize(); - // Mock request - const request: protosTypes.google.monitoring.v3.IGetNotificationChannelVerificationCodeRequest = {}; - request.name = ''; - // Mock response - const expectedResponse = {}; - // Mock gRPC layer - client._innerApiCalls.getNotificationChannelVerificationCode = mockSimpleGrpcMethod( - request, - expectedResponse, - null - ); - client.getNotificationChannelVerificationCode( - request, - (err: {}, response: {}) => { - assert.ifError(err); - assert.deepStrictEqual(response, expectedResponse); - done(); - } - ); - }); - - it('invokes getNotificationChannelVerificationCode with error', done => { - const client = new notificationchannelserviceModule.v3.NotificationChannelServiceClient( - { - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - } - ); - // Initialize client before mocking - client.initialize(); - // Mock request - const request: protosTypes.google.monitoring.v3.IGetNotificationChannelVerificationCodeRequest = {}; - request.name = ''; - // Mock response - const expectedResponse = {}; - // Mock gRPC layer - client._innerApiCalls.getNotificationChannelVerificationCode = mockSimpleGrpcMethod( - request, - null, - error - ); - client.getNotificationChannelVerificationCode( - request, - (err: FakeError, response: {}) => { - assert(err instanceof FakeError); - assert.strictEqual(err.code, FAKE_STATUS_CODE); - assert(typeof response === 'undefined'); - done(); - } - ); - }); - }); - describe('verifyNotificationChannel', () => { - it('invokes verifyNotificationChannel without error', done => { - const client = new notificationchannelserviceModule.v3.NotificationChannelServiceClient( - { - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - } - ); - // Initialize client before mocking - client.initialize(); - // Mock request - const request: protosTypes.google.monitoring.v3.IVerifyNotificationChannelRequest = {}; - request.name = ''; - // Mock response - const expectedResponse = {}; - // Mock gRPC layer - client._innerApiCalls.verifyNotificationChannel = mockSimpleGrpcMethod( - request, - expectedResponse, - null - ); - client.verifyNotificationChannel(request, (err: {}, response: {}) => { - assert.ifError(err); - assert.deepStrictEqual(response, expectedResponse); - done(); - }); - }); - - it('invokes verifyNotificationChannel with error', done => { - const client = new notificationchannelserviceModule.v3.NotificationChannelServiceClient( - { - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - } - ); - // Initialize client before mocking - client.initialize(); - // Mock request - const request: protosTypes.google.monitoring.v3.IVerifyNotificationChannelRequest = {}; - request.name = ''; - // Mock response - const expectedResponse = {}; - // Mock gRPC layer - client._innerApiCalls.verifyNotificationChannel = mockSimpleGrpcMethod( - request, - null, - error - ); - client.verifyNotificationChannel( - request, - (err: FakeError, response: {}) => { - assert(err instanceof FakeError); - assert.strictEqual(err.code, FAKE_STATUS_CODE); - assert(typeof response === 'undefined'); - done(); - } - ); - }); - }); - describe('listNotificationChannelDescriptors', () => { - it('invokes listNotificationChannelDescriptors without error', done => { - const client = new notificationchannelserviceModule.v3.NotificationChannelServiceClient( - { - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - } - ); - // Initialize client before mocking - client.initialize(); - // Mock request - const request: protosTypes.google.monitoring.v3.IListNotificationChannelDescriptorsRequest = {}; - request.name = ''; - // Mock response - const expectedResponse = {}; - // Mock Grpc layer - client._innerApiCalls.listNotificationChannelDescriptors = ( - actualRequest: {}, - options: {}, - callback: Callback - ) => { - assert.deepStrictEqual(actualRequest, request); - callback(null, expectedResponse); - }; - client.listNotificationChannelDescriptors( - request, - (err: FakeError, response: {}) => { - assert.ifError(err); - assert.deepStrictEqual(response, expectedResponse); - done(); - } - ); - }); - }); - describe('listNotificationChannelDescriptorsStream', () => { - it('invokes listNotificationChannelDescriptorsStream without error', done => { - const client = new notificationchannelserviceModule.v3.NotificationChannelServiceClient( - { - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - } - ); - // Initialize client before mocking - client.initialize(); - // Mock request - const request: protosTypes.google.monitoring.v3.IListNotificationChannelDescriptorsRequest = {}; - request.name = ''; - // Mock response - const expectedResponse = {response: 'data'}; - // Mock Grpc layer - client._innerApiCalls.listNotificationChannelDescriptors = ( - actualRequest: {}, - options: {}, - callback: Callback - ) => { - assert.deepStrictEqual(actualRequest, request); - callback(null, expectedResponse); - }; - const stream = client - .listNotificationChannelDescriptorsStream(request, {}) - .on('data', (response: {}) => { - assert.deepStrictEqual(response, expectedResponse); - done(); - }) - .on('error', (err: FakeError) => { - done(err); - }); - stream.write(expectedResponse); - }); - }); - describe('listNotificationChannels', () => { - it('invokes listNotificationChannels without error', done => { - const client = new notificationchannelserviceModule.v3.NotificationChannelServiceClient( - { - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - } - ); - // Initialize client before mocking - client.initialize(); - // Mock request - const request: protosTypes.google.monitoring.v3.IListNotificationChannelsRequest = {}; - request.name = ''; - // Mock response - const expectedResponse = {}; - // Mock Grpc layer - client._innerApiCalls.listNotificationChannels = ( - actualRequest: {}, - options: {}, - callback: Callback - ) => { - assert.deepStrictEqual(actualRequest, request); - callback(null, expectedResponse); - }; - client.listNotificationChannels( - request, - (err: FakeError, response: {}) => { - assert.ifError(err); - assert.deepStrictEqual(response, expectedResponse); - done(); - } - ); - }); - }); - describe('listNotificationChannelsStream', () => { - it('invokes listNotificationChannelsStream without error', done => { - const client = new notificationchannelserviceModule.v3.NotificationChannelServiceClient( - { - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - } - ); - // Initialize client before mocking - client.initialize(); - // Mock request - const request: protosTypes.google.monitoring.v3.IListNotificationChannelsRequest = {}; - request.name = ''; - // Mock response - const expectedResponse = {response: 'data'}; - // Mock Grpc layer - client._innerApiCalls.listNotificationChannels = ( - actualRequest: {}, - options: {}, - callback: Callback - ) => { - assert.deepStrictEqual(actualRequest, request); - callback(null, expectedResponse); - }; - const stream = client - .listNotificationChannelsStream(request, {}) - .on('data', (response: {}) => { - assert.deepStrictEqual(response, expectedResponse); - done(); - }) - .on('error', (err: FakeError) => { - done(err); - }); - stream.write(expectedResponse); - }); - }); -}); diff --git a/packages/google-cloud-monitoring/test/gapic-service_monitoring_service-v3.ts b/packages/google-cloud-monitoring/test/gapic-service_monitoring_service-v3.ts deleted file mode 100644 index f72b50dbf60..00000000000 --- a/packages/google-cloud-monitoring/test/gapic-service_monitoring_service-v3.ts +++ /dev/null @@ -1,712 +0,0 @@ -// Copyright 2019 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -import * as protosTypes from '../protos/protos'; -import * as assert from 'assert'; -import {describe, it} from 'mocha'; -const servicemonitoringserviceModule = require('../src'); - -const FAKE_STATUS_CODE = 1; -class FakeError { - name: string; - message: string; - code: number; - constructor(n: number) { - this.name = 'fakeName'; - this.message = 'fake message'; - this.code = n; - } -} -const error = new FakeError(FAKE_STATUS_CODE); -export interface Callback { - (err: FakeError | null, response?: {} | null): void; -} - -export class Operation { - constructor() {} - promise() {} -} -function mockSimpleGrpcMethod( - expectedRequest: {}, - response: {} | null, - error: FakeError | null -) { - return (actualRequest: {}, options: {}, callback: Callback) => { - assert.deepStrictEqual(actualRequest, expectedRequest); - if (error) { - callback(error); - } else if (response) { - callback(null, response); - } else { - callback(null); - } - }; -} -describe('v3.ServiceMonitoringServiceClient', () => { - it('has servicePath', () => { - const servicePath = - servicemonitoringserviceModule.v3.ServiceMonitoringServiceClient - .servicePath; - assert(servicePath); - }); - it('has apiEndpoint', () => { - const apiEndpoint = - servicemonitoringserviceModule.v3.ServiceMonitoringServiceClient - .apiEndpoint; - assert(apiEndpoint); - }); - it('has port', () => { - const port = - servicemonitoringserviceModule.v3.ServiceMonitoringServiceClient.port; - assert(port); - assert(typeof port === 'number'); - }); - it('should create a client with no option', () => { - const client = new servicemonitoringserviceModule.v3.ServiceMonitoringServiceClient(); - assert(client); - }); - it('should create a client with gRPC fallback', () => { - const client = new servicemonitoringserviceModule.v3.ServiceMonitoringServiceClient( - { - fallback: true, - } - ); - assert(client); - }); - it('has initialize method and supports deferred initialization', async () => { - const client = new servicemonitoringserviceModule.v3.ServiceMonitoringServiceClient( - { - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - } - ); - assert.strictEqual(client.serviceMonitoringServiceStub, undefined); - await client.initialize(); - assert(client.serviceMonitoringServiceStub); - }); - it('has close method', () => { - const client = new servicemonitoringserviceModule.v3.ServiceMonitoringServiceClient( - { - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - } - ); - client.close(); - }); - describe('createService', () => { - it('invokes createService without error', done => { - const client = new servicemonitoringserviceModule.v3.ServiceMonitoringServiceClient( - { - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - } - ); - // Initialize client before mocking - client.initialize(); - // Mock request - const request: protosTypes.google.monitoring.v3.ICreateServiceRequest = {}; - request.parent = ''; - // Mock response - const expectedResponse = {}; - // Mock gRPC layer - client._innerApiCalls.createService = mockSimpleGrpcMethod( - request, - expectedResponse, - null - ); - client.createService(request, (err: {}, response: {}) => { - assert.ifError(err); - assert.deepStrictEqual(response, expectedResponse); - done(); - }); - }); - - it('invokes createService with error', done => { - const client = new servicemonitoringserviceModule.v3.ServiceMonitoringServiceClient( - { - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - } - ); - // Initialize client before mocking - client.initialize(); - // Mock request - const request: protosTypes.google.monitoring.v3.ICreateServiceRequest = {}; - request.parent = ''; - // Mock response - const expectedResponse = {}; - // Mock gRPC layer - client._innerApiCalls.createService = mockSimpleGrpcMethod( - request, - null, - error - ); - client.createService(request, (err: FakeError, response: {}) => { - assert(err instanceof FakeError); - assert.strictEqual(err.code, FAKE_STATUS_CODE); - assert(typeof response === 'undefined'); - done(); - }); - }); - }); - describe('getService', () => { - it('invokes getService without error', done => { - const client = new servicemonitoringserviceModule.v3.ServiceMonitoringServiceClient( - { - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - } - ); - // Initialize client before mocking - client.initialize(); - // Mock request - const request: protosTypes.google.monitoring.v3.IGetServiceRequest = {}; - request.name = ''; - // Mock response - const expectedResponse = {}; - // Mock gRPC layer - client._innerApiCalls.getService = mockSimpleGrpcMethod( - request, - expectedResponse, - null - ); - client.getService(request, (err: {}, response: {}) => { - assert.ifError(err); - assert.deepStrictEqual(response, expectedResponse); - done(); - }); - }); - - it('invokes getService with error', done => { - const client = new servicemonitoringserviceModule.v3.ServiceMonitoringServiceClient( - { - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - } - ); - // Initialize client before mocking - client.initialize(); - // Mock request - const request: protosTypes.google.monitoring.v3.IGetServiceRequest = {}; - request.name = ''; - // Mock response - const expectedResponse = {}; - // Mock gRPC layer - client._innerApiCalls.getService = mockSimpleGrpcMethod( - request, - null, - error - ); - client.getService(request, (err: FakeError, response: {}) => { - assert(err instanceof FakeError); - assert.strictEqual(err.code, FAKE_STATUS_CODE); - assert(typeof response === 'undefined'); - done(); - }); - }); - }); - describe('updateService', () => { - it('invokes updateService without error', done => { - const client = new servicemonitoringserviceModule.v3.ServiceMonitoringServiceClient( - { - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - } - ); - // Initialize client before mocking - client.initialize(); - // Mock request - const request: protosTypes.google.monitoring.v3.IUpdateServiceRequest = {}; - request.service = {}; - request.service.name = ''; - // Mock response - const expectedResponse = {}; - // Mock gRPC layer - client._innerApiCalls.updateService = mockSimpleGrpcMethod( - request, - expectedResponse, - null - ); - client.updateService(request, (err: {}, response: {}) => { - assert.ifError(err); - assert.deepStrictEqual(response, expectedResponse); - done(); - }); - }); - - it('invokes updateService with error', done => { - const client = new servicemonitoringserviceModule.v3.ServiceMonitoringServiceClient( - { - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - } - ); - // Initialize client before mocking - client.initialize(); - // Mock request - const request: protosTypes.google.monitoring.v3.IUpdateServiceRequest = {}; - request.service = {}; - request.service.name = ''; - // Mock response - const expectedResponse = {}; - // Mock gRPC layer - client._innerApiCalls.updateService = mockSimpleGrpcMethod( - request, - null, - error - ); - client.updateService(request, (err: FakeError, response: {}) => { - assert(err instanceof FakeError); - assert.strictEqual(err.code, FAKE_STATUS_CODE); - assert(typeof response === 'undefined'); - done(); - }); - }); - }); - describe('deleteService', () => { - it('invokes deleteService without error', done => { - const client = new servicemonitoringserviceModule.v3.ServiceMonitoringServiceClient( - { - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - } - ); - // Initialize client before mocking - client.initialize(); - // Mock request - const request: protosTypes.google.monitoring.v3.IDeleteServiceRequest = {}; - request.name = ''; - // Mock response - const expectedResponse = {}; - // Mock gRPC layer - client._innerApiCalls.deleteService = mockSimpleGrpcMethod( - request, - expectedResponse, - null - ); - client.deleteService(request, (err: {}, response: {}) => { - assert.ifError(err); - assert.deepStrictEqual(response, expectedResponse); - done(); - }); - }); - - it('invokes deleteService with error', done => { - const client = new servicemonitoringserviceModule.v3.ServiceMonitoringServiceClient( - { - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - } - ); - // Initialize client before mocking - client.initialize(); - // Mock request - const request: protosTypes.google.monitoring.v3.IDeleteServiceRequest = {}; - request.name = ''; - // Mock response - const expectedResponse = {}; - // Mock gRPC layer - client._innerApiCalls.deleteService = mockSimpleGrpcMethod( - request, - null, - error - ); - client.deleteService(request, (err: FakeError, response: {}) => { - assert(err instanceof FakeError); - assert.strictEqual(err.code, FAKE_STATUS_CODE); - assert(typeof response === 'undefined'); - done(); - }); - }); - }); - describe('createServiceLevelObjective', () => { - it('invokes createServiceLevelObjective without error', done => { - const client = new servicemonitoringserviceModule.v3.ServiceMonitoringServiceClient( - { - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - } - ); - // Initialize client before mocking - client.initialize(); - // Mock request - const request: protosTypes.google.monitoring.v3.ICreateServiceLevelObjectiveRequest = {}; - request.parent = ''; - // Mock response - const expectedResponse = {}; - // Mock gRPC layer - client._innerApiCalls.createServiceLevelObjective = mockSimpleGrpcMethod( - request, - expectedResponse, - null - ); - client.createServiceLevelObjective(request, (err: {}, response: {}) => { - assert.ifError(err); - assert.deepStrictEqual(response, expectedResponse); - done(); - }); - }); - - it('invokes createServiceLevelObjective with error', done => { - const client = new servicemonitoringserviceModule.v3.ServiceMonitoringServiceClient( - { - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - } - ); - // Initialize client before mocking - client.initialize(); - // Mock request - const request: protosTypes.google.monitoring.v3.ICreateServiceLevelObjectiveRequest = {}; - request.parent = ''; - // Mock response - const expectedResponse = {}; - // Mock gRPC layer - client._innerApiCalls.createServiceLevelObjective = mockSimpleGrpcMethod( - request, - null, - error - ); - client.createServiceLevelObjective( - request, - (err: FakeError, response: {}) => { - assert(err instanceof FakeError); - assert.strictEqual(err.code, FAKE_STATUS_CODE); - assert(typeof response === 'undefined'); - done(); - } - ); - }); - }); - describe('getServiceLevelObjective', () => { - it('invokes getServiceLevelObjective without error', done => { - const client = new servicemonitoringserviceModule.v3.ServiceMonitoringServiceClient( - { - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - } - ); - // Initialize client before mocking - client.initialize(); - // Mock request - const request: protosTypes.google.monitoring.v3.IGetServiceLevelObjectiveRequest = {}; - request.name = ''; - // Mock response - const expectedResponse = {}; - // Mock gRPC layer - client._innerApiCalls.getServiceLevelObjective = mockSimpleGrpcMethod( - request, - expectedResponse, - null - ); - client.getServiceLevelObjective(request, (err: {}, response: {}) => { - assert.ifError(err); - assert.deepStrictEqual(response, expectedResponse); - done(); - }); - }); - - it('invokes getServiceLevelObjective with error', done => { - const client = new servicemonitoringserviceModule.v3.ServiceMonitoringServiceClient( - { - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - } - ); - // Initialize client before mocking - client.initialize(); - // Mock request - const request: protosTypes.google.monitoring.v3.IGetServiceLevelObjectiveRequest = {}; - request.name = ''; - // Mock response - const expectedResponse = {}; - // Mock gRPC layer - client._innerApiCalls.getServiceLevelObjective = mockSimpleGrpcMethod( - request, - null, - error - ); - client.getServiceLevelObjective( - request, - (err: FakeError, response: {}) => { - assert(err instanceof FakeError); - assert.strictEqual(err.code, FAKE_STATUS_CODE); - assert(typeof response === 'undefined'); - done(); - } - ); - }); - }); - describe('updateServiceLevelObjective', () => { - it('invokes updateServiceLevelObjective without error', done => { - const client = new servicemonitoringserviceModule.v3.ServiceMonitoringServiceClient( - { - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - } - ); - // Initialize client before mocking - client.initialize(); - // Mock request - const request: protosTypes.google.monitoring.v3.IUpdateServiceLevelObjectiveRequest = {}; - request.serviceLevelObjective = {}; - request.serviceLevelObjective.name = ''; - // Mock response - const expectedResponse = {}; - // Mock gRPC layer - client._innerApiCalls.updateServiceLevelObjective = mockSimpleGrpcMethod( - request, - expectedResponse, - null - ); - client.updateServiceLevelObjective(request, (err: {}, response: {}) => { - assert.ifError(err); - assert.deepStrictEqual(response, expectedResponse); - done(); - }); - }); - - it('invokes updateServiceLevelObjective with error', done => { - const client = new servicemonitoringserviceModule.v3.ServiceMonitoringServiceClient( - { - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - } - ); - // Initialize client before mocking - client.initialize(); - // Mock request - const request: protosTypes.google.monitoring.v3.IUpdateServiceLevelObjectiveRequest = {}; - request.serviceLevelObjective = {}; - request.serviceLevelObjective.name = ''; - // Mock response - const expectedResponse = {}; - // Mock gRPC layer - client._innerApiCalls.updateServiceLevelObjective = mockSimpleGrpcMethod( - request, - null, - error - ); - client.updateServiceLevelObjective( - request, - (err: FakeError, response: {}) => { - assert(err instanceof FakeError); - assert.strictEqual(err.code, FAKE_STATUS_CODE); - assert(typeof response === 'undefined'); - done(); - } - ); - }); - }); - describe('deleteServiceLevelObjective', () => { - it('invokes deleteServiceLevelObjective without error', done => { - const client = new servicemonitoringserviceModule.v3.ServiceMonitoringServiceClient( - { - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - } - ); - // Initialize client before mocking - client.initialize(); - // Mock request - const request: protosTypes.google.monitoring.v3.IDeleteServiceLevelObjectiveRequest = {}; - request.name = ''; - // Mock response - const expectedResponse = {}; - // Mock gRPC layer - client._innerApiCalls.deleteServiceLevelObjective = mockSimpleGrpcMethod( - request, - expectedResponse, - null - ); - client.deleteServiceLevelObjective(request, (err: {}, response: {}) => { - assert.ifError(err); - assert.deepStrictEqual(response, expectedResponse); - done(); - }); - }); - - it('invokes deleteServiceLevelObjective with error', done => { - const client = new servicemonitoringserviceModule.v3.ServiceMonitoringServiceClient( - { - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - } - ); - // Initialize client before mocking - client.initialize(); - // Mock request - const request: protosTypes.google.monitoring.v3.IDeleteServiceLevelObjectiveRequest = {}; - request.name = ''; - // Mock response - const expectedResponse = {}; - // Mock gRPC layer - client._innerApiCalls.deleteServiceLevelObjective = mockSimpleGrpcMethod( - request, - null, - error - ); - client.deleteServiceLevelObjective( - request, - (err: FakeError, response: {}) => { - assert(err instanceof FakeError); - assert.strictEqual(err.code, FAKE_STATUS_CODE); - assert(typeof response === 'undefined'); - done(); - } - ); - }); - }); - describe('listServices', () => { - it('invokes listServices without error', done => { - const client = new servicemonitoringserviceModule.v3.ServiceMonitoringServiceClient( - { - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - } - ); - // Initialize client before mocking - client.initialize(); - // Mock request - const request: protosTypes.google.monitoring.v3.IListServicesRequest = {}; - request.parent = ''; - // Mock response - const expectedResponse = {}; - // Mock Grpc layer - client._innerApiCalls.listServices = ( - actualRequest: {}, - options: {}, - callback: Callback - ) => { - assert.deepStrictEqual(actualRequest, request); - callback(null, expectedResponse); - }; - client.listServices(request, (err: FakeError, response: {}) => { - assert.ifError(err); - assert.deepStrictEqual(response, expectedResponse); - done(); - }); - }); - }); - describe('listServicesStream', () => { - it('invokes listServicesStream without error', done => { - const client = new servicemonitoringserviceModule.v3.ServiceMonitoringServiceClient( - { - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - } - ); - // Initialize client before mocking - client.initialize(); - // Mock request - const request: protosTypes.google.monitoring.v3.IListServicesRequest = {}; - request.parent = ''; - // Mock response - const expectedResponse = {response: 'data'}; - // Mock Grpc layer - client._innerApiCalls.listServices = ( - actualRequest: {}, - options: {}, - callback: Callback - ) => { - assert.deepStrictEqual(actualRequest, request); - callback(null, expectedResponse); - }; - const stream = client - .listServicesStream(request, {}) - .on('data', (response: {}) => { - assert.deepStrictEqual(response, expectedResponse); - done(); - }) - .on('error', (err: FakeError) => { - done(err); - }); - stream.write(expectedResponse); - }); - }); - describe('listServiceLevelObjectives', () => { - it('invokes listServiceLevelObjectives without error', done => { - const client = new servicemonitoringserviceModule.v3.ServiceMonitoringServiceClient( - { - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - } - ); - // Initialize client before mocking - client.initialize(); - // Mock request - const request: protosTypes.google.monitoring.v3.IListServiceLevelObjectivesRequest = {}; - request.parent = ''; - // Mock response - const expectedResponse = {}; - // Mock Grpc layer - client._innerApiCalls.listServiceLevelObjectives = ( - actualRequest: {}, - options: {}, - callback: Callback - ) => { - assert.deepStrictEqual(actualRequest, request); - callback(null, expectedResponse); - }; - client.listServiceLevelObjectives( - request, - (err: FakeError, response: {}) => { - assert.ifError(err); - assert.deepStrictEqual(response, expectedResponse); - done(); - } - ); - }); - }); - describe('listServiceLevelObjectivesStream', () => { - it('invokes listServiceLevelObjectivesStream without error', done => { - const client = new servicemonitoringserviceModule.v3.ServiceMonitoringServiceClient( - { - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - } - ); - // Initialize client before mocking - client.initialize(); - // Mock request - const request: protosTypes.google.monitoring.v3.IListServiceLevelObjectivesRequest = {}; - request.parent = ''; - // Mock response - const expectedResponse = {response: 'data'}; - // Mock Grpc layer - client._innerApiCalls.listServiceLevelObjectives = ( - actualRequest: {}, - options: {}, - callback: Callback - ) => { - assert.deepStrictEqual(actualRequest, request); - callback(null, expectedResponse); - }; - const stream = client - .listServiceLevelObjectivesStream(request, {}) - .on('data', (response: {}) => { - assert.deepStrictEqual(response, expectedResponse); - done(); - }) - .on('error', (err: FakeError) => { - done(err); - }); - stream.write(expectedResponse); - }); - }); -}); diff --git a/packages/google-cloud-monitoring/test/gapic-uptime_check_service-v3.ts b/packages/google-cloud-monitoring/test/gapic-uptime_check_service-v3.ts deleted file mode 100644 index ae479840769..00000000000 --- a/packages/google-cloud-monitoring/test/gapic-uptime_check_service-v3.ts +++ /dev/null @@ -1,445 +0,0 @@ -// Copyright 2019 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -import * as protosTypes from '../protos/protos'; -import * as assert from 'assert'; -import {describe, it} from 'mocha'; -const uptimecheckserviceModule = require('../src'); - -const FAKE_STATUS_CODE = 1; -class FakeError { - name: string; - message: string; - code: number; - constructor(n: number) { - this.name = 'fakeName'; - this.message = 'fake message'; - this.code = n; - } -} -const error = new FakeError(FAKE_STATUS_CODE); -export interface Callback { - (err: FakeError | null, response?: {} | null): void; -} - -export class Operation { - constructor() {} - promise() {} -} -function mockSimpleGrpcMethod( - expectedRequest: {}, - response: {} | null, - error: FakeError | null -) { - return (actualRequest: {}, options: {}, callback: Callback) => { - assert.deepStrictEqual(actualRequest, expectedRequest); - if (error) { - callback(error); - } else if (response) { - callback(null, response); - } else { - callback(null); - } - }; -} -describe('v3.UptimeCheckServiceClient', () => { - it('has servicePath', () => { - const servicePath = - uptimecheckserviceModule.v3.UptimeCheckServiceClient.servicePath; - assert(servicePath); - }); - it('has apiEndpoint', () => { - const apiEndpoint = - uptimecheckserviceModule.v3.UptimeCheckServiceClient.apiEndpoint; - assert(apiEndpoint); - }); - it('has port', () => { - const port = uptimecheckserviceModule.v3.UptimeCheckServiceClient.port; - assert(port); - assert(typeof port === 'number'); - }); - it('should create a client with no option', () => { - const client = new uptimecheckserviceModule.v3.UptimeCheckServiceClient(); - assert(client); - }); - it('should create a client with gRPC fallback', () => { - const client = new uptimecheckserviceModule.v3.UptimeCheckServiceClient({ - fallback: true, - }); - assert(client); - }); - it('has initialize method and supports deferred initialization', async () => { - const client = new uptimecheckserviceModule.v3.UptimeCheckServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.uptimeCheckServiceStub, undefined); - await client.initialize(); - assert(client.uptimeCheckServiceStub); - }); - it('has close method', () => { - const client = new uptimecheckserviceModule.v3.UptimeCheckServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.close(); - }); - describe('getUptimeCheckConfig', () => { - it('invokes getUptimeCheckConfig without error', done => { - const client = new uptimecheckserviceModule.v3.UptimeCheckServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - // Initialize client before mocking - client.initialize(); - // Mock request - const request: protosTypes.google.monitoring.v3.IGetUptimeCheckConfigRequest = {}; - request.name = ''; - // Mock response - const expectedResponse = {}; - // Mock gRPC layer - client._innerApiCalls.getUptimeCheckConfig = mockSimpleGrpcMethod( - request, - expectedResponse, - null - ); - client.getUptimeCheckConfig(request, (err: {}, response: {}) => { - assert.ifError(err); - assert.deepStrictEqual(response, expectedResponse); - done(); - }); - }); - - it('invokes getUptimeCheckConfig with error', done => { - const client = new uptimecheckserviceModule.v3.UptimeCheckServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - // Initialize client before mocking - client.initialize(); - // Mock request - const request: protosTypes.google.monitoring.v3.IGetUptimeCheckConfigRequest = {}; - request.name = ''; - // Mock response - const expectedResponse = {}; - // Mock gRPC layer - client._innerApiCalls.getUptimeCheckConfig = mockSimpleGrpcMethod( - request, - null, - error - ); - client.getUptimeCheckConfig(request, (err: FakeError, response: {}) => { - assert(err instanceof FakeError); - assert.strictEqual(err.code, FAKE_STATUS_CODE); - assert(typeof response === 'undefined'); - done(); - }); - }); - }); - describe('createUptimeCheckConfig', () => { - it('invokes createUptimeCheckConfig without error', done => { - const client = new uptimecheckserviceModule.v3.UptimeCheckServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - // Initialize client before mocking - client.initialize(); - // Mock request - const request: protosTypes.google.monitoring.v3.ICreateUptimeCheckConfigRequest = {}; - request.parent = ''; - // Mock response - const expectedResponse = {}; - // Mock gRPC layer - client._innerApiCalls.createUptimeCheckConfig = mockSimpleGrpcMethod( - request, - expectedResponse, - null - ); - client.createUptimeCheckConfig(request, (err: {}, response: {}) => { - assert.ifError(err); - assert.deepStrictEqual(response, expectedResponse); - done(); - }); - }); - - it('invokes createUptimeCheckConfig with error', done => { - const client = new uptimecheckserviceModule.v3.UptimeCheckServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - // Initialize client before mocking - client.initialize(); - // Mock request - const request: protosTypes.google.monitoring.v3.ICreateUptimeCheckConfigRequest = {}; - request.parent = ''; - // Mock response - const expectedResponse = {}; - // Mock gRPC layer - client._innerApiCalls.createUptimeCheckConfig = mockSimpleGrpcMethod( - request, - null, - error - ); - client.createUptimeCheckConfig( - request, - (err: FakeError, response: {}) => { - assert(err instanceof FakeError); - assert.strictEqual(err.code, FAKE_STATUS_CODE); - assert(typeof response === 'undefined'); - done(); - } - ); - }); - }); - describe('updateUptimeCheckConfig', () => { - it('invokes updateUptimeCheckConfig without error', done => { - const client = new uptimecheckserviceModule.v3.UptimeCheckServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - // Initialize client before mocking - client.initialize(); - // Mock request - const request: protosTypes.google.monitoring.v3.IUpdateUptimeCheckConfigRequest = {}; - request.uptimeCheckConfig = {}; - request.uptimeCheckConfig.name = ''; - // Mock response - const expectedResponse = {}; - // Mock gRPC layer - client._innerApiCalls.updateUptimeCheckConfig = mockSimpleGrpcMethod( - request, - expectedResponse, - null - ); - client.updateUptimeCheckConfig(request, (err: {}, response: {}) => { - assert.ifError(err); - assert.deepStrictEqual(response, expectedResponse); - done(); - }); - }); - - it('invokes updateUptimeCheckConfig with error', done => { - const client = new uptimecheckserviceModule.v3.UptimeCheckServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - // Initialize client before mocking - client.initialize(); - // Mock request - const request: protosTypes.google.monitoring.v3.IUpdateUptimeCheckConfigRequest = {}; - request.uptimeCheckConfig = {}; - request.uptimeCheckConfig.name = ''; - // Mock response - const expectedResponse = {}; - // Mock gRPC layer - client._innerApiCalls.updateUptimeCheckConfig = mockSimpleGrpcMethod( - request, - null, - error - ); - client.updateUptimeCheckConfig( - request, - (err: FakeError, response: {}) => { - assert(err instanceof FakeError); - assert.strictEqual(err.code, FAKE_STATUS_CODE); - assert(typeof response === 'undefined'); - done(); - } - ); - }); - }); - describe('deleteUptimeCheckConfig', () => { - it('invokes deleteUptimeCheckConfig without error', done => { - const client = new uptimecheckserviceModule.v3.UptimeCheckServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - // Initialize client before mocking - client.initialize(); - // Mock request - const request: protosTypes.google.monitoring.v3.IDeleteUptimeCheckConfigRequest = {}; - request.name = ''; - // Mock response - const expectedResponse = {}; - // Mock gRPC layer - client._innerApiCalls.deleteUptimeCheckConfig = mockSimpleGrpcMethod( - request, - expectedResponse, - null - ); - client.deleteUptimeCheckConfig(request, (err: {}, response: {}) => { - assert.ifError(err); - assert.deepStrictEqual(response, expectedResponse); - done(); - }); - }); - - it('invokes deleteUptimeCheckConfig with error', done => { - const client = new uptimecheckserviceModule.v3.UptimeCheckServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - // Initialize client before mocking - client.initialize(); - // Mock request - const request: protosTypes.google.monitoring.v3.IDeleteUptimeCheckConfigRequest = {}; - request.name = ''; - // Mock response - const expectedResponse = {}; - // Mock gRPC layer - client._innerApiCalls.deleteUptimeCheckConfig = mockSimpleGrpcMethod( - request, - null, - error - ); - client.deleteUptimeCheckConfig( - request, - (err: FakeError, response: {}) => { - assert(err instanceof FakeError); - assert.strictEqual(err.code, FAKE_STATUS_CODE); - assert(typeof response === 'undefined'); - done(); - } - ); - }); - }); - describe('listUptimeCheckConfigs', () => { - it('invokes listUptimeCheckConfigs without error', done => { - const client = new uptimecheckserviceModule.v3.UptimeCheckServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - // Initialize client before mocking - client.initialize(); - // Mock request - const request: protosTypes.google.monitoring.v3.IListUptimeCheckConfigsRequest = {}; - request.parent = ''; - // Mock response - const expectedResponse = {}; - // Mock Grpc layer - client._innerApiCalls.listUptimeCheckConfigs = ( - actualRequest: {}, - options: {}, - callback: Callback - ) => { - assert.deepStrictEqual(actualRequest, request); - callback(null, expectedResponse); - }; - client.listUptimeCheckConfigs(request, (err: FakeError, response: {}) => { - assert.ifError(err); - assert.deepStrictEqual(response, expectedResponse); - done(); - }); - }); - }); - describe('listUptimeCheckConfigsStream', () => { - it('invokes listUptimeCheckConfigsStream without error', done => { - const client = new uptimecheckserviceModule.v3.UptimeCheckServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - // Initialize client before mocking - client.initialize(); - // Mock request - const request: protosTypes.google.monitoring.v3.IListUptimeCheckConfigsRequest = {}; - request.parent = ''; - // Mock response - const expectedResponse = {response: 'data'}; - // Mock Grpc layer - client._innerApiCalls.listUptimeCheckConfigs = ( - actualRequest: {}, - options: {}, - callback: Callback - ) => { - assert.deepStrictEqual(actualRequest, request); - callback(null, expectedResponse); - }; - const stream = client - .listUptimeCheckConfigsStream(request, {}) - .on('data', (response: {}) => { - assert.deepStrictEqual(response, expectedResponse); - done(); - }) - .on('error', (err: FakeError) => { - done(err); - }); - stream.write(expectedResponse); - }); - }); - describe('listUptimeCheckIps', () => { - it('invokes listUptimeCheckIps without error', done => { - const client = new uptimecheckserviceModule.v3.UptimeCheckServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - // Initialize client before mocking - client.initialize(); - // Mock request - const request: protosTypes.google.monitoring.v3.IListUptimeCheckIpsRequest = {}; - // Mock response - const expectedResponse = {}; - // Mock Grpc layer - client._innerApiCalls.listUptimeCheckIps = ( - actualRequest: {}, - options: {}, - callback: Callback - ) => { - assert.deepStrictEqual(actualRequest, request); - callback(null, expectedResponse); - }; - client.listUptimeCheckIps(request, (err: FakeError, response: {}) => { - assert.ifError(err); - assert.deepStrictEqual(response, expectedResponse); - done(); - }); - }); - }); - describe('listUptimeCheckIpsStream', () => { - it('invokes listUptimeCheckIpsStream without error', done => { - const client = new uptimecheckserviceModule.v3.UptimeCheckServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - // Initialize client before mocking - client.initialize(); - // Mock request - const request: protosTypes.google.monitoring.v3.IListUptimeCheckIpsRequest = {}; - // Mock response - const expectedResponse = {response: 'data'}; - // Mock Grpc layer - client._innerApiCalls.listUptimeCheckIps = ( - actualRequest: {}, - options: {}, - callback: Callback - ) => { - assert.deepStrictEqual(actualRequest, request); - callback(null, expectedResponse); - }; - const stream = client - .listUptimeCheckIpsStream(request, {}) - .on('data', (response: {}) => { - assert.deepStrictEqual(response, expectedResponse); - done(); - }) - .on('error', (err: FakeError) => { - done(err); - }); - stream.write(expectedResponse); - }); - }); -}); diff --git a/packages/google-cloud-monitoring/test/gapic_alert_policy_service_v3.ts b/packages/google-cloud-monitoring/test/gapic_alert_policy_service_v3.ts new file mode 100644 index 00000000000..16017316657 --- /dev/null +++ b/packages/google-cloud-monitoring/test/gapic_alert_policy_service_v3.ts @@ -0,0 +1,2457 @@ +// Copyright 2020 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +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 * as alertpolicyserviceModule from '../src'; + +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; +} + +function stubSimpleCall(response?: ResponseType, error?: Error) { + 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 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(); + }); + } + 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); +} + +describe('v3.AlertPolicyServiceClient', () => { + it('has servicePath', () => { + const servicePath = + alertpolicyserviceModule.v3.AlertPolicyServiceClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = + alertpolicyserviceModule.v3.AlertPolicyServiceClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = alertpolicyserviceModule.v3.AlertPolicyServiceClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new alertpolicyserviceModule.v3.AlertPolicyServiceClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new alertpolicyserviceModule.v3.AlertPolicyServiceClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new alertpolicyserviceModule.v3.AlertPolicyServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.alertPolicyServiceStub, undefined); + await client.initialize(); + assert(client.alertPolicyServiceStub); + }); + + it('has close method', () => { + const client = new alertpolicyserviceModule.v3.AlertPolicyServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.close(); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new alertpolicyserviceModule.v3.AlertPolicyServiceClient({ + 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 alertpolicyserviceModule.v3.AlertPolicyServiceClient({ + 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('getAlertPolicy', () => { + it('invokes getAlertPolicy without error', async () => { + const client = new alertpolicyserviceModule.v3.AlertPolicyServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.monitoring.v3.GetAlertPolicyRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.monitoring.v3.AlertPolicy() + ); + client.innerApiCalls.getAlertPolicy = stubSimpleCall(expectedResponse); + const [response] = await client.getAlertPolicy(request); + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.getAlertPolicy as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + + it('invokes getAlertPolicy without error using callback', async () => { + const client = new alertpolicyserviceModule.v3.AlertPolicyServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.monitoring.v3.GetAlertPolicyRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.monitoring.v3.AlertPolicy() + ); + client.innerApiCalls.getAlertPolicy = stubSimpleCallWithCallback( + expectedResponse + ); + const promise = new Promise((resolve, reject) => { + client.getAlertPolicy( + request, + ( + err?: Error | null, + result?: protos.google.monitoring.v3.IAlertPolicy | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.getAlertPolicy as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions /*, callback defined above */) + ); + }); + + it('invokes getAlertPolicy with error', async () => { + const client = new alertpolicyserviceModule.v3.AlertPolicyServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.monitoring.v3.GetAlertPolicyRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.getAlertPolicy = stubSimpleCall( + undefined, + expectedError + ); + assert.rejects(async () => { + await client.getAlertPolicy(request); + }, expectedError); + assert( + (client.innerApiCalls.getAlertPolicy as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + }); + + describe('createAlertPolicy', () => { + it('invokes createAlertPolicy without error', async () => { + const client = new alertpolicyserviceModule.v3.AlertPolicyServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.monitoring.v3.CreateAlertPolicyRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.monitoring.v3.AlertPolicy() + ); + client.innerApiCalls.createAlertPolicy = stubSimpleCall(expectedResponse); + const [response] = await client.createAlertPolicy(request); + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.createAlertPolicy as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + + it('invokes createAlertPolicy without error using callback', async () => { + const client = new alertpolicyserviceModule.v3.AlertPolicyServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.monitoring.v3.CreateAlertPolicyRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.monitoring.v3.AlertPolicy() + ); + client.innerApiCalls.createAlertPolicy = stubSimpleCallWithCallback( + expectedResponse + ); + const promise = new Promise((resolve, reject) => { + client.createAlertPolicy( + request, + ( + err?: Error | null, + result?: protos.google.monitoring.v3.IAlertPolicy | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.createAlertPolicy as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions /*, callback defined above */) + ); + }); + + it('invokes createAlertPolicy with error', async () => { + const client = new alertpolicyserviceModule.v3.AlertPolicyServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.monitoring.v3.CreateAlertPolicyRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.createAlertPolicy = stubSimpleCall( + undefined, + expectedError + ); + assert.rejects(async () => { + await client.createAlertPolicy(request); + }, expectedError); + assert( + (client.innerApiCalls.createAlertPolicy as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + }); + + describe('deleteAlertPolicy', () => { + it('invokes deleteAlertPolicy without error', async () => { + const client = new alertpolicyserviceModule.v3.AlertPolicyServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.monitoring.v3.DeleteAlertPolicyRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.deleteAlertPolicy = stubSimpleCall(expectedResponse); + const [response] = await client.deleteAlertPolicy(request); + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.deleteAlertPolicy as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + + it('invokes deleteAlertPolicy without error using callback', async () => { + const client = new alertpolicyserviceModule.v3.AlertPolicyServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.monitoring.v3.DeleteAlertPolicyRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.deleteAlertPolicy = stubSimpleCallWithCallback( + expectedResponse + ); + const promise = new Promise((resolve, reject) => { + client.deleteAlertPolicy( + 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.deleteAlertPolicy as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions /*, callback defined above */) + ); + }); + + it('invokes deleteAlertPolicy with error', async () => { + const client = new alertpolicyserviceModule.v3.AlertPolicyServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.monitoring.v3.DeleteAlertPolicyRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteAlertPolicy = stubSimpleCall( + undefined, + expectedError + ); + assert.rejects(async () => { + await client.deleteAlertPolicy(request); + }, expectedError); + assert( + (client.innerApiCalls.deleteAlertPolicy as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + }); + + describe('updateAlertPolicy', () => { + it('invokes updateAlertPolicy without error', async () => { + const client = new alertpolicyserviceModule.v3.AlertPolicyServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.monitoring.v3.UpdateAlertPolicyRequest() + ); + request.alertPolicy = {}; + request.alertPolicy.name = ''; + const expectedHeaderRequestParams = 'alert_policy.name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.monitoring.v3.AlertPolicy() + ); + client.innerApiCalls.updateAlertPolicy = stubSimpleCall(expectedResponse); + const [response] = await client.updateAlertPolicy(request); + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.updateAlertPolicy as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + + it('invokes updateAlertPolicy without error using callback', async () => { + const client = new alertpolicyserviceModule.v3.AlertPolicyServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.monitoring.v3.UpdateAlertPolicyRequest() + ); + request.alertPolicy = {}; + request.alertPolicy.name = ''; + const expectedHeaderRequestParams = 'alert_policy.name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.monitoring.v3.AlertPolicy() + ); + client.innerApiCalls.updateAlertPolicy = stubSimpleCallWithCallback( + expectedResponse + ); + const promise = new Promise((resolve, reject) => { + client.updateAlertPolicy( + request, + ( + err?: Error | null, + result?: protos.google.monitoring.v3.IAlertPolicy | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.updateAlertPolicy as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions /*, callback defined above */) + ); + }); + + it('invokes updateAlertPolicy with error', async () => { + const client = new alertpolicyserviceModule.v3.AlertPolicyServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.monitoring.v3.UpdateAlertPolicyRequest() + ); + request.alertPolicy = {}; + request.alertPolicy.name = ''; + const expectedHeaderRequestParams = 'alert_policy.name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.updateAlertPolicy = stubSimpleCall( + undefined, + expectedError + ); + assert.rejects(async () => { + await client.updateAlertPolicy(request); + }, expectedError); + assert( + (client.innerApiCalls.updateAlertPolicy as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + }); + + describe('listAlertPolicies', () => { + it('invokes listAlertPolicies without error', async () => { + const client = new alertpolicyserviceModule.v3.AlertPolicyServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.monitoring.v3.ListAlertPoliciesRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage(new protos.google.monitoring.v3.AlertPolicy()), + generateSampleMessage(new protos.google.monitoring.v3.AlertPolicy()), + generateSampleMessage(new protos.google.monitoring.v3.AlertPolicy()), + ]; + client.innerApiCalls.listAlertPolicies = stubSimpleCall(expectedResponse); + const [response] = await client.listAlertPolicies(request); + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.listAlertPolicies as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + + it('invokes listAlertPolicies without error using callback', async () => { + const client = new alertpolicyserviceModule.v3.AlertPolicyServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.monitoring.v3.ListAlertPoliciesRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage(new protos.google.monitoring.v3.AlertPolicy()), + generateSampleMessage(new protos.google.monitoring.v3.AlertPolicy()), + generateSampleMessage(new protos.google.monitoring.v3.AlertPolicy()), + ]; + client.innerApiCalls.listAlertPolicies = stubSimpleCallWithCallback( + expectedResponse + ); + const promise = new Promise((resolve, reject) => { + client.listAlertPolicies( + request, + ( + err?: Error | null, + result?: protos.google.monitoring.v3.IAlertPolicy[] | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.listAlertPolicies as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions /*, callback defined above */) + ); + }); + + it('invokes listAlertPolicies with error', async () => { + const client = new alertpolicyserviceModule.v3.AlertPolicyServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.monitoring.v3.ListAlertPoliciesRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.listAlertPolicies = stubSimpleCall( + undefined, + expectedError + ); + assert.rejects(async () => { + await client.listAlertPolicies(request); + }, expectedError); + assert( + (client.innerApiCalls.listAlertPolicies as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + + it('invokes listAlertPoliciesStream without error', async () => { + const client = new alertpolicyserviceModule.v3.AlertPolicyServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.monitoring.v3.ListAlertPoliciesRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedResponse = [ + generateSampleMessage(new protos.google.monitoring.v3.AlertPolicy()), + generateSampleMessage(new protos.google.monitoring.v3.AlertPolicy()), + generateSampleMessage(new protos.google.monitoring.v3.AlertPolicy()), + ]; + client.descriptors.page.listAlertPolicies.createStream = stubPageStreamingCall( + expectedResponse + ); + const stream = client.listAlertPoliciesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.monitoring.v3.AlertPolicy[] = []; + stream.on( + 'data', + (response: protos.google.monitoring.v3.AlertPolicy) => { + 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.listAlertPolicies.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listAlertPolicies, request) + ); + assert.strictEqual( + (client.descriptors.page.listAlertPolicies + .createStream as SinonStub).getCall(0).args[2].otherArgs.headers[ + 'x-goog-request-params' + ], + expectedHeaderRequestParams + ); + }); + + it('invokes listAlertPoliciesStream with error', async () => { + const client = new alertpolicyserviceModule.v3.AlertPolicyServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.monitoring.v3.ListAlertPoliciesRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedError = new Error('expected'); + client.descriptors.page.listAlertPolicies.createStream = stubPageStreamingCall( + undefined, + expectedError + ); + const stream = client.listAlertPoliciesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.monitoring.v3.AlertPolicy[] = []; + stream.on( + 'data', + (response: protos.google.monitoring.v3.AlertPolicy) => { + responses.push(response); + } + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + assert.rejects(async () => { + await promise; + }, expectedError); + assert( + (client.descriptors.page.listAlertPolicies.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listAlertPolicies, request) + ); + assert.strictEqual( + (client.descriptors.page.listAlertPolicies + .createStream as SinonStub).getCall(0).args[2].otherArgs.headers[ + 'x-goog-request-params' + ], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listAlertPolicies without error', async () => { + const client = new alertpolicyserviceModule.v3.AlertPolicyServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.monitoring.v3.ListAlertPoliciesRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedResponse = [ + generateSampleMessage(new protos.google.monitoring.v3.AlertPolicy()), + generateSampleMessage(new protos.google.monitoring.v3.AlertPolicy()), + generateSampleMessage(new protos.google.monitoring.v3.AlertPolicy()), + ]; + client.descriptors.page.listAlertPolicies.asyncIterate = stubAsyncIterationCall( + expectedResponse + ); + const responses: protos.google.monitoring.v3.IAlertPolicy[] = []; + const iterable = client.listAlertPoliciesAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listAlertPolicies + .asyncIterate as SinonStub).getCall(0).args[1], + request + ); + assert.strictEqual( + (client.descriptors.page.listAlertPolicies + .asyncIterate as SinonStub).getCall(0).args[2].otherArgs.headers[ + 'x-goog-request-params' + ], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listAlertPolicies with error', async () => { + const client = new alertpolicyserviceModule.v3.AlertPolicyServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.monitoring.v3.ListAlertPoliciesRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedError = new Error('expected'); + client.descriptors.page.listAlertPolicies.asyncIterate = stubAsyncIterationCall( + undefined, + expectedError + ); + const iterable = client.listAlertPoliciesAsync(request); + assert.rejects(async () => { + const responses: protos.google.monitoring.v3.IAlertPolicy[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listAlertPolicies + .asyncIterate as SinonStub).getCall(0).args[1], + request + ); + assert.strictEqual( + (client.descriptors.page.listAlertPolicies + .asyncIterate as SinonStub).getCall(0).args[2].otherArgs.headers[ + 'x-goog-request-params' + ], + expectedHeaderRequestParams + ); + }); + }); + + describe('Path templates', () => { + describe('folderAlertPolicy', () => { + const fakePath = '/rendered/path/folderAlertPolicy'; + const expectedParameters = { + folder: 'folderValue', + alert_policy: 'alertPolicyValue', + }; + const client = new alertpolicyserviceModule.v3.AlertPolicyServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.folderAlertPolicyPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.folderAlertPolicyPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('folderAlertPolicyPath', () => { + const result = client.folderAlertPolicyPath( + 'folderValue', + 'alertPolicyValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.folderAlertPolicyPathTemplate + .render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchFolderFromFolderAlertPolicyName', () => { + const result = client.matchFolderFromFolderAlertPolicyName(fakePath); + assert.strictEqual(result, 'folderValue'); + assert( + (client.pathTemplates.folderAlertPolicyPathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchAlertPolicyFromFolderAlertPolicyName', () => { + const result = client.matchAlertPolicyFromFolderAlertPolicyName( + fakePath + ); + assert.strictEqual(result, 'alertPolicyValue'); + assert( + (client.pathTemplates.folderAlertPolicyPathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('folderAlertPolicyCondition', () => { + const fakePath = '/rendered/path/folderAlertPolicyCondition'; + const expectedParameters = { + folder: 'folderValue', + alert_policy: 'alertPolicyValue', + condition: 'conditionValue', + }; + const client = new alertpolicyserviceModule.v3.AlertPolicyServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.folderAlertPolicyConditionPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.folderAlertPolicyConditionPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('folderAlertPolicyConditionPath', () => { + const result = client.folderAlertPolicyConditionPath( + 'folderValue', + 'alertPolicyValue', + 'conditionValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.folderAlertPolicyConditionPathTemplate + .render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchFolderFromFolderAlertPolicyConditionName', () => { + const result = client.matchFolderFromFolderAlertPolicyConditionName( + fakePath + ); + assert.strictEqual(result, 'folderValue'); + assert( + (client.pathTemplates.folderAlertPolicyConditionPathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchAlertPolicyFromFolderAlertPolicyConditionName', () => { + const result = client.matchAlertPolicyFromFolderAlertPolicyConditionName( + fakePath + ); + assert.strictEqual(result, 'alertPolicyValue'); + assert( + (client.pathTemplates.folderAlertPolicyConditionPathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchConditionFromFolderAlertPolicyConditionName', () => { + const result = client.matchConditionFromFolderAlertPolicyConditionName( + fakePath + ); + assert.strictEqual(result, 'conditionValue'); + assert( + (client.pathTemplates.folderAlertPolicyConditionPathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('folderChannelDescriptor', () => { + const fakePath = '/rendered/path/folderChannelDescriptor'; + const expectedParameters = { + folder: 'folderValue', + channel_descriptor: 'channelDescriptorValue', + }; + const client = new alertpolicyserviceModule.v3.AlertPolicyServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.folderChannelDescriptorPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.folderChannelDescriptorPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('folderChannelDescriptorPath', () => { + const result = client.folderChannelDescriptorPath( + 'folderValue', + 'channelDescriptorValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.folderChannelDescriptorPathTemplate + .render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchFolderFromFolderChannelDescriptorName', () => { + const result = client.matchFolderFromFolderChannelDescriptorName( + fakePath + ); + assert.strictEqual(result, 'folderValue'); + assert( + (client.pathTemplates.folderChannelDescriptorPathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchChannelDescriptorFromFolderChannelDescriptorName', () => { + const result = client.matchChannelDescriptorFromFolderChannelDescriptorName( + fakePath + ); + assert.strictEqual(result, 'channelDescriptorValue'); + assert( + (client.pathTemplates.folderChannelDescriptorPathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('folderGroup', () => { + const fakePath = '/rendered/path/folderGroup'; + const expectedParameters = { + folder: 'folderValue', + group: 'groupValue', + }; + const client = new alertpolicyserviceModule.v3.AlertPolicyServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.folderGroupPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.folderGroupPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('folderGroupPath', () => { + const result = client.folderGroupPath('folderValue', 'groupValue'); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.folderGroupPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchFolderFromFolderGroupName', () => { + const result = client.matchFolderFromFolderGroupName(fakePath); + assert.strictEqual(result, 'folderValue'); + assert( + (client.pathTemplates.folderGroupPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchGroupFromFolderGroupName', () => { + const result = client.matchGroupFromFolderGroupName(fakePath); + assert.strictEqual(result, 'groupValue'); + assert( + (client.pathTemplates.folderGroupPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('folderNotificationChannel', () => { + const fakePath = '/rendered/path/folderNotificationChannel'; + const expectedParameters = { + folder: 'folderValue', + notification_channel: 'notificationChannelValue', + }; + const client = new alertpolicyserviceModule.v3.AlertPolicyServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.folderNotificationChannelPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.folderNotificationChannelPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('folderNotificationChannelPath', () => { + const result = client.folderNotificationChannelPath( + 'folderValue', + 'notificationChannelValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.folderNotificationChannelPathTemplate + .render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchFolderFromFolderNotificationChannelName', () => { + const result = client.matchFolderFromFolderNotificationChannelName( + fakePath + ); + assert.strictEqual(result, 'folderValue'); + assert( + (client.pathTemplates.folderNotificationChannelPathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchNotificationChannelFromFolderNotificationChannelName', () => { + const result = client.matchNotificationChannelFromFolderNotificationChannelName( + fakePath + ); + assert.strictEqual(result, 'notificationChannelValue'); + assert( + (client.pathTemplates.folderNotificationChannelPathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('folderService', () => { + const fakePath = '/rendered/path/folderService'; + const expectedParameters = { + folder: 'folderValue', + service: 'serviceValue', + }; + const client = new alertpolicyserviceModule.v3.AlertPolicyServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.folderServicePathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.folderServicePathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('folderServicePath', () => { + const result = client.folderServicePath('folderValue', 'serviceValue'); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.folderServicePathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchFolderFromFolderServiceName', () => { + const result = client.matchFolderFromFolderServiceName(fakePath); + assert.strictEqual(result, 'folderValue'); + assert( + (client.pathTemplates.folderServicePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchServiceFromFolderServiceName', () => { + const result = client.matchServiceFromFolderServiceName(fakePath); + assert.strictEqual(result, 'serviceValue'); + assert( + (client.pathTemplates.folderServicePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('folderServiceServiceLevelObjective', () => { + const fakePath = '/rendered/path/folderServiceServiceLevelObjective'; + const expectedParameters = { + folder: 'folderValue', + service: 'serviceValue', + service_level_objective: 'serviceLevelObjectiveValue', + }; + const client = new alertpolicyserviceModule.v3.AlertPolicyServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.folderServiceServiceLevelObjectivePathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.folderServiceServiceLevelObjectivePathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('folderServiceServiceLevelObjectivePath', () => { + const result = client.folderServiceServiceLevelObjectivePath( + 'folderValue', + 'serviceValue', + 'serviceLevelObjectiveValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.folderServiceServiceLevelObjectivePathTemplate + .render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchFolderFromFolderServiceServiceLevelObjectiveName', () => { + const result = client.matchFolderFromFolderServiceServiceLevelObjectiveName( + fakePath + ); + assert.strictEqual(result, 'folderValue'); + assert( + (client.pathTemplates.folderServiceServiceLevelObjectivePathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchServiceFromFolderServiceServiceLevelObjectiveName', () => { + const result = client.matchServiceFromFolderServiceServiceLevelObjectiveName( + fakePath + ); + assert.strictEqual(result, 'serviceValue'); + assert( + (client.pathTemplates.folderServiceServiceLevelObjectivePathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchServiceLevelObjectiveFromFolderServiceServiceLevelObjectiveName', () => { + const result = client.matchServiceLevelObjectiveFromFolderServiceServiceLevelObjectiveName( + fakePath + ); + assert.strictEqual(result, 'serviceLevelObjectiveValue'); + assert( + (client.pathTemplates.folderServiceServiceLevelObjectivePathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('folderUptimeCheckConfig', () => { + const fakePath = '/rendered/path/folderUptimeCheckConfig'; + const expectedParameters = { + folder: 'folderValue', + uptime_check_config: 'uptimeCheckConfigValue', + }; + const client = new alertpolicyserviceModule.v3.AlertPolicyServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.folderUptimeCheckConfigPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.folderUptimeCheckConfigPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('folderUptimeCheckConfigPath', () => { + const result = client.folderUptimeCheckConfigPath( + 'folderValue', + 'uptimeCheckConfigValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.folderUptimeCheckConfigPathTemplate + .render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchFolderFromFolderUptimeCheckConfigName', () => { + const result = client.matchFolderFromFolderUptimeCheckConfigName( + fakePath + ); + assert.strictEqual(result, 'folderValue'); + assert( + (client.pathTemplates.folderUptimeCheckConfigPathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchUptimeCheckConfigFromFolderUptimeCheckConfigName', () => { + const result = client.matchUptimeCheckConfigFromFolderUptimeCheckConfigName( + fakePath + ); + assert.strictEqual(result, 'uptimeCheckConfigValue'); + assert( + (client.pathTemplates.folderUptimeCheckConfigPathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('organizationAlertPolicy', () => { + const fakePath = '/rendered/path/organizationAlertPolicy'; + const expectedParameters = { + organization: 'organizationValue', + alert_policy: 'alertPolicyValue', + }; + const client = new alertpolicyserviceModule.v3.AlertPolicyServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.organizationAlertPolicyPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.organizationAlertPolicyPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('organizationAlertPolicyPath', () => { + const result = client.organizationAlertPolicyPath( + 'organizationValue', + 'alertPolicyValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.organizationAlertPolicyPathTemplate + .render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchOrganizationFromOrganizationAlertPolicyName', () => { + const result = client.matchOrganizationFromOrganizationAlertPolicyName( + fakePath + ); + assert.strictEqual(result, 'organizationValue'); + assert( + (client.pathTemplates.organizationAlertPolicyPathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchAlertPolicyFromOrganizationAlertPolicyName', () => { + const result = client.matchAlertPolicyFromOrganizationAlertPolicyName( + fakePath + ); + assert.strictEqual(result, 'alertPolicyValue'); + assert( + (client.pathTemplates.organizationAlertPolicyPathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('organizationAlertPolicyCondition', () => { + const fakePath = '/rendered/path/organizationAlertPolicyCondition'; + const expectedParameters = { + organization: 'organizationValue', + alert_policy: 'alertPolicyValue', + condition: 'conditionValue', + }; + const client = new alertpolicyserviceModule.v3.AlertPolicyServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.organizationAlertPolicyConditionPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.organizationAlertPolicyConditionPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('organizationAlertPolicyConditionPath', () => { + const result = client.organizationAlertPolicyConditionPath( + 'organizationValue', + 'alertPolicyValue', + 'conditionValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.organizationAlertPolicyConditionPathTemplate + .render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchOrganizationFromOrganizationAlertPolicyConditionName', () => { + const result = client.matchOrganizationFromOrganizationAlertPolicyConditionName( + fakePath + ); + assert.strictEqual(result, 'organizationValue'); + assert( + (client.pathTemplates.organizationAlertPolicyConditionPathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchAlertPolicyFromOrganizationAlertPolicyConditionName', () => { + const result = client.matchAlertPolicyFromOrganizationAlertPolicyConditionName( + fakePath + ); + assert.strictEqual(result, 'alertPolicyValue'); + assert( + (client.pathTemplates.organizationAlertPolicyConditionPathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchConditionFromOrganizationAlertPolicyConditionName', () => { + const result = client.matchConditionFromOrganizationAlertPolicyConditionName( + fakePath + ); + assert.strictEqual(result, 'conditionValue'); + assert( + (client.pathTemplates.organizationAlertPolicyConditionPathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('organizationChannelDescriptor', () => { + const fakePath = '/rendered/path/organizationChannelDescriptor'; + const expectedParameters = { + organization: 'organizationValue', + channel_descriptor: 'channelDescriptorValue', + }; + const client = new alertpolicyserviceModule.v3.AlertPolicyServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.organizationChannelDescriptorPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.organizationChannelDescriptorPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('organizationChannelDescriptorPath', () => { + const result = client.organizationChannelDescriptorPath( + 'organizationValue', + 'channelDescriptorValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.organizationChannelDescriptorPathTemplate + .render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchOrganizationFromOrganizationChannelDescriptorName', () => { + const result = client.matchOrganizationFromOrganizationChannelDescriptorName( + fakePath + ); + assert.strictEqual(result, 'organizationValue'); + assert( + (client.pathTemplates.organizationChannelDescriptorPathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchChannelDescriptorFromOrganizationChannelDescriptorName', () => { + const result = client.matchChannelDescriptorFromOrganizationChannelDescriptorName( + fakePath + ); + assert.strictEqual(result, 'channelDescriptorValue'); + assert( + (client.pathTemplates.organizationChannelDescriptorPathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('organizationGroup', () => { + const fakePath = '/rendered/path/organizationGroup'; + const expectedParameters = { + organization: 'organizationValue', + group: 'groupValue', + }; + const client = new alertpolicyserviceModule.v3.AlertPolicyServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.organizationGroupPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.organizationGroupPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('organizationGroupPath', () => { + const result = client.organizationGroupPath( + 'organizationValue', + 'groupValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.organizationGroupPathTemplate + .render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchOrganizationFromOrganizationGroupName', () => { + const result = client.matchOrganizationFromOrganizationGroupName( + fakePath + ); + assert.strictEqual(result, 'organizationValue'); + assert( + (client.pathTemplates.organizationGroupPathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchGroupFromOrganizationGroupName', () => { + const result = client.matchGroupFromOrganizationGroupName(fakePath); + assert.strictEqual(result, 'groupValue'); + assert( + (client.pathTemplates.organizationGroupPathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('organizationNotificationChannel', () => { + const fakePath = '/rendered/path/organizationNotificationChannel'; + const expectedParameters = { + organization: 'organizationValue', + notification_channel: 'notificationChannelValue', + }; + const client = new alertpolicyserviceModule.v3.AlertPolicyServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.organizationNotificationChannelPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.organizationNotificationChannelPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('organizationNotificationChannelPath', () => { + const result = client.organizationNotificationChannelPath( + 'organizationValue', + 'notificationChannelValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.organizationNotificationChannelPathTemplate + .render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchOrganizationFromOrganizationNotificationChannelName', () => { + const result = client.matchOrganizationFromOrganizationNotificationChannelName( + fakePath + ); + assert.strictEqual(result, 'organizationValue'); + assert( + (client.pathTemplates.organizationNotificationChannelPathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchNotificationChannelFromOrganizationNotificationChannelName', () => { + const result = client.matchNotificationChannelFromOrganizationNotificationChannelName( + fakePath + ); + assert.strictEqual(result, 'notificationChannelValue'); + assert( + (client.pathTemplates.organizationNotificationChannelPathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('organizationService', () => { + const fakePath = '/rendered/path/organizationService'; + const expectedParameters = { + organization: 'organizationValue', + service: 'serviceValue', + }; + const client = new alertpolicyserviceModule.v3.AlertPolicyServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.organizationServicePathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.organizationServicePathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('organizationServicePath', () => { + const result = client.organizationServicePath( + 'organizationValue', + 'serviceValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.organizationServicePathTemplate + .render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchOrganizationFromOrganizationServiceName', () => { + const result = client.matchOrganizationFromOrganizationServiceName( + fakePath + ); + assert.strictEqual(result, 'organizationValue'); + assert( + (client.pathTemplates.organizationServicePathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchServiceFromOrganizationServiceName', () => { + const result = client.matchServiceFromOrganizationServiceName(fakePath); + assert.strictEqual(result, 'serviceValue'); + assert( + (client.pathTemplates.organizationServicePathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('organizationServiceServiceLevelObjective', () => { + const fakePath = + '/rendered/path/organizationServiceServiceLevelObjective'; + const expectedParameters = { + organization: 'organizationValue', + service: 'serviceValue', + service_level_objective: 'serviceLevelObjectiveValue', + }; + const client = new alertpolicyserviceModule.v3.AlertPolicyServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.organizationServiceServiceLevelObjectivePathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.organizationServiceServiceLevelObjectivePathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('organizationServiceServiceLevelObjectivePath', () => { + const result = client.organizationServiceServiceLevelObjectivePath( + 'organizationValue', + 'serviceValue', + 'serviceLevelObjectiveValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates + .organizationServiceServiceLevelObjectivePathTemplate + .render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchOrganizationFromOrganizationServiceServiceLevelObjectiveName', () => { + const result = client.matchOrganizationFromOrganizationServiceServiceLevelObjectiveName( + fakePath + ); + assert.strictEqual(result, 'organizationValue'); + assert( + (client.pathTemplates + .organizationServiceServiceLevelObjectivePathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchServiceFromOrganizationServiceServiceLevelObjectiveName', () => { + const result = client.matchServiceFromOrganizationServiceServiceLevelObjectiveName( + fakePath + ); + assert.strictEqual(result, 'serviceValue'); + assert( + (client.pathTemplates + .organizationServiceServiceLevelObjectivePathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchServiceLevelObjectiveFromOrganizationServiceServiceLevelObjectiveName', () => { + const result = client.matchServiceLevelObjectiveFromOrganizationServiceServiceLevelObjectiveName( + fakePath + ); + assert.strictEqual(result, 'serviceLevelObjectiveValue'); + assert( + (client.pathTemplates + .organizationServiceServiceLevelObjectivePathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('organizationUptimeCheckConfig', () => { + const fakePath = '/rendered/path/organizationUptimeCheckConfig'; + const expectedParameters = { + organization: 'organizationValue', + uptime_check_config: 'uptimeCheckConfigValue', + }; + const client = new alertpolicyserviceModule.v3.AlertPolicyServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.organizationUptimeCheckConfigPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.organizationUptimeCheckConfigPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('organizationUptimeCheckConfigPath', () => { + const result = client.organizationUptimeCheckConfigPath( + 'organizationValue', + 'uptimeCheckConfigValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.organizationUptimeCheckConfigPathTemplate + .render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchOrganizationFromOrganizationUptimeCheckConfigName', () => { + const result = client.matchOrganizationFromOrganizationUptimeCheckConfigName( + fakePath + ); + assert.strictEqual(result, 'organizationValue'); + assert( + (client.pathTemplates.organizationUptimeCheckConfigPathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchUptimeCheckConfigFromOrganizationUptimeCheckConfigName', () => { + const result = client.matchUptimeCheckConfigFromOrganizationUptimeCheckConfigName( + fakePath + ); + assert.strictEqual(result, 'uptimeCheckConfigValue'); + assert( + (client.pathTemplates.organizationUptimeCheckConfigPathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('project', () => { + const fakePath = '/rendered/path/project'; + const expectedParameters = { + project: 'projectValue', + }; + const client = new alertpolicyserviceModule.v3.AlertPolicyServiceClient({ + 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('matchProjectFromProjectName', () => { + const result = client.matchProjectFromProjectName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.projectPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('projectAlertPolicy', () => { + const fakePath = '/rendered/path/projectAlertPolicy'; + const expectedParameters = { + project: 'projectValue', + alert_policy: 'alertPolicyValue', + }; + const client = new alertpolicyserviceModule.v3.AlertPolicyServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.projectAlertPolicyPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.projectAlertPolicyPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('projectAlertPolicyPath', () => { + const result = client.projectAlertPolicyPath( + 'projectValue', + 'alertPolicyValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.projectAlertPolicyPathTemplate + .render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromProjectAlertPolicyName', () => { + const result = client.matchProjectFromProjectAlertPolicyName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.projectAlertPolicyPathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchAlertPolicyFromProjectAlertPolicyName', () => { + const result = client.matchAlertPolicyFromProjectAlertPolicyName( + fakePath + ); + assert.strictEqual(result, 'alertPolicyValue'); + assert( + (client.pathTemplates.projectAlertPolicyPathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('projectAlertPolicyCondition', () => { + const fakePath = '/rendered/path/projectAlertPolicyCondition'; + const expectedParameters = { + project: 'projectValue', + alert_policy: 'alertPolicyValue', + condition: 'conditionValue', + }; + const client = new alertpolicyserviceModule.v3.AlertPolicyServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.projectAlertPolicyConditionPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.projectAlertPolicyConditionPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('projectAlertPolicyConditionPath', () => { + const result = client.projectAlertPolicyConditionPath( + 'projectValue', + 'alertPolicyValue', + 'conditionValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.projectAlertPolicyConditionPathTemplate + .render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromProjectAlertPolicyConditionName', () => { + const result = client.matchProjectFromProjectAlertPolicyConditionName( + fakePath + ); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.projectAlertPolicyConditionPathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchAlertPolicyFromProjectAlertPolicyConditionName', () => { + const result = client.matchAlertPolicyFromProjectAlertPolicyConditionName( + fakePath + ); + assert.strictEqual(result, 'alertPolicyValue'); + assert( + (client.pathTemplates.projectAlertPolicyConditionPathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchConditionFromProjectAlertPolicyConditionName', () => { + const result = client.matchConditionFromProjectAlertPolicyConditionName( + fakePath + ); + assert.strictEqual(result, 'conditionValue'); + assert( + (client.pathTemplates.projectAlertPolicyConditionPathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('projectChannelDescriptor', () => { + const fakePath = '/rendered/path/projectChannelDescriptor'; + const expectedParameters = { + project: 'projectValue', + channel_descriptor: 'channelDescriptorValue', + }; + const client = new alertpolicyserviceModule.v3.AlertPolicyServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.projectChannelDescriptorPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.projectChannelDescriptorPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('projectChannelDescriptorPath', () => { + const result = client.projectChannelDescriptorPath( + 'projectValue', + 'channelDescriptorValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.projectChannelDescriptorPathTemplate + .render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromProjectChannelDescriptorName', () => { + const result = client.matchProjectFromProjectChannelDescriptorName( + fakePath + ); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.projectChannelDescriptorPathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchChannelDescriptorFromProjectChannelDescriptorName', () => { + const result = client.matchChannelDescriptorFromProjectChannelDescriptorName( + fakePath + ); + assert.strictEqual(result, 'channelDescriptorValue'); + assert( + (client.pathTemplates.projectChannelDescriptorPathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('projectGroup', () => { + const fakePath = '/rendered/path/projectGroup'; + const expectedParameters = { + project: 'projectValue', + group: 'groupValue', + }; + const client = new alertpolicyserviceModule.v3.AlertPolicyServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.projectGroupPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.projectGroupPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('projectGroupPath', () => { + const result = client.projectGroupPath('projectValue', 'groupValue'); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.projectGroupPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromProjectGroupName', () => { + const result = client.matchProjectFromProjectGroupName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.projectGroupPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchGroupFromProjectGroupName', () => { + const result = client.matchGroupFromProjectGroupName(fakePath); + assert.strictEqual(result, 'groupValue'); + assert( + (client.pathTemplates.projectGroupPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('projectNotificationChannel', () => { + const fakePath = '/rendered/path/projectNotificationChannel'; + const expectedParameters = { + project: 'projectValue', + notification_channel: 'notificationChannelValue', + }; + const client = new alertpolicyserviceModule.v3.AlertPolicyServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.projectNotificationChannelPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.projectNotificationChannelPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('projectNotificationChannelPath', () => { + const result = client.projectNotificationChannelPath( + 'projectValue', + 'notificationChannelValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.projectNotificationChannelPathTemplate + .render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromProjectNotificationChannelName', () => { + const result = client.matchProjectFromProjectNotificationChannelName( + fakePath + ); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.projectNotificationChannelPathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchNotificationChannelFromProjectNotificationChannelName', () => { + const result = client.matchNotificationChannelFromProjectNotificationChannelName( + fakePath + ); + assert.strictEqual(result, 'notificationChannelValue'); + assert( + (client.pathTemplates.projectNotificationChannelPathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('projectService', () => { + const fakePath = '/rendered/path/projectService'; + const expectedParameters = { + project: 'projectValue', + service: 'serviceValue', + }; + const client = new alertpolicyserviceModule.v3.AlertPolicyServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.projectServicePathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.projectServicePathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('projectServicePath', () => { + const result = client.projectServicePath( + 'projectValue', + 'serviceValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.projectServicePathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromProjectServiceName', () => { + const result = client.matchProjectFromProjectServiceName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.projectServicePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchServiceFromProjectServiceName', () => { + const result = client.matchServiceFromProjectServiceName(fakePath); + assert.strictEqual(result, 'serviceValue'); + assert( + (client.pathTemplates.projectServicePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('projectServiceServiceLevelObjective', () => { + const fakePath = '/rendered/path/projectServiceServiceLevelObjective'; + const expectedParameters = { + project: 'projectValue', + service: 'serviceValue', + service_level_objective: 'serviceLevelObjectiveValue', + }; + const client = new alertpolicyserviceModule.v3.AlertPolicyServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.projectServiceServiceLevelObjectivePathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.projectServiceServiceLevelObjectivePathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('projectServiceServiceLevelObjectivePath', () => { + const result = client.projectServiceServiceLevelObjectivePath( + 'projectValue', + 'serviceValue', + 'serviceLevelObjectiveValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.projectServiceServiceLevelObjectivePathTemplate + .render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromProjectServiceServiceLevelObjectiveName', () => { + const result = client.matchProjectFromProjectServiceServiceLevelObjectiveName( + fakePath + ); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.projectServiceServiceLevelObjectivePathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchServiceFromProjectServiceServiceLevelObjectiveName', () => { + const result = client.matchServiceFromProjectServiceServiceLevelObjectiveName( + fakePath + ); + assert.strictEqual(result, 'serviceValue'); + assert( + (client.pathTemplates.projectServiceServiceLevelObjectivePathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchServiceLevelObjectiveFromProjectServiceServiceLevelObjectiveName', () => { + const result = client.matchServiceLevelObjectiveFromProjectServiceServiceLevelObjectiveName( + fakePath + ); + assert.strictEqual(result, 'serviceLevelObjectiveValue'); + assert( + (client.pathTemplates.projectServiceServiceLevelObjectivePathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('projectUptimeCheckConfig', () => { + const fakePath = '/rendered/path/projectUptimeCheckConfig'; + const expectedParameters = { + project: 'projectValue', + uptime_check_config: 'uptimeCheckConfigValue', + }; + const client = new alertpolicyserviceModule.v3.AlertPolicyServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.projectUptimeCheckConfigPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.projectUptimeCheckConfigPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('projectUptimeCheckConfigPath', () => { + const result = client.projectUptimeCheckConfigPath( + 'projectValue', + 'uptimeCheckConfigValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.projectUptimeCheckConfigPathTemplate + .render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromProjectUptimeCheckConfigName', () => { + const result = client.matchProjectFromProjectUptimeCheckConfigName( + fakePath + ); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.projectUptimeCheckConfigPathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchUptimeCheckConfigFromProjectUptimeCheckConfigName', () => { + const result = client.matchUptimeCheckConfigFromProjectUptimeCheckConfigName( + fakePath + ); + assert.strictEqual(result, 'uptimeCheckConfigValue'); + assert( + (client.pathTemplates.projectUptimeCheckConfigPathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + }); +}); diff --git a/packages/google-cloud-monitoring/test/gapic_group_service_v3.ts b/packages/google-cloud-monitoring/test/gapic_group_service_v3.ts new file mode 100644 index 00000000000..5ba251ff679 --- /dev/null +++ b/packages/google-cloud-monitoring/test/gapic_group_service_v3.ts @@ -0,0 +1,2732 @@ +// Copyright 2020 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +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 * as groupserviceModule from '../src'; + +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; +} + +function stubSimpleCall(response?: ResponseType, error?: Error) { + 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 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(); + }); + } + 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); +} + +describe('v3.GroupServiceClient', () => { + it('has servicePath', () => { + const servicePath = groupserviceModule.v3.GroupServiceClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = groupserviceModule.v3.GroupServiceClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = groupserviceModule.v3.GroupServiceClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new groupserviceModule.v3.GroupServiceClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new groupserviceModule.v3.GroupServiceClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new groupserviceModule.v3.GroupServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.groupServiceStub, undefined); + await client.initialize(); + assert(client.groupServiceStub); + }); + + it('has close method', () => { + const client = new groupserviceModule.v3.GroupServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.close(); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new groupserviceModule.v3.GroupServiceClient({ + 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 groupserviceModule.v3.GroupServiceClient({ + 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('getGroup', () => { + it('invokes getGroup without error', async () => { + const client = new groupserviceModule.v3.GroupServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.monitoring.v3.GetGroupRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.monitoring.v3.Group() + ); + client.innerApiCalls.getGroup = stubSimpleCall(expectedResponse); + const [response] = await client.getGroup(request); + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.getGroup as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + + it('invokes getGroup without error using callback', async () => { + const client = new groupserviceModule.v3.GroupServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.monitoring.v3.GetGroupRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.monitoring.v3.Group() + ); + client.innerApiCalls.getGroup = stubSimpleCallWithCallback( + expectedResponse + ); + const promise = new Promise((resolve, reject) => { + client.getGroup( + request, + ( + err?: Error | null, + result?: protos.google.monitoring.v3.IGroup | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.getGroup as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions /*, callback defined above */) + ); + }); + + it('invokes getGroup with error', async () => { + const client = new groupserviceModule.v3.GroupServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.monitoring.v3.GetGroupRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.getGroup = stubSimpleCall(undefined, expectedError); + assert.rejects(async () => { + await client.getGroup(request); + }, expectedError); + assert( + (client.innerApiCalls.getGroup as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + }); + + describe('createGroup', () => { + it('invokes createGroup without error', async () => { + const client = new groupserviceModule.v3.GroupServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.monitoring.v3.CreateGroupRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.monitoring.v3.Group() + ); + client.innerApiCalls.createGroup = stubSimpleCall(expectedResponse); + const [response] = await client.createGroup(request); + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.createGroup as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + + it('invokes createGroup without error using callback', async () => { + const client = new groupserviceModule.v3.GroupServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.monitoring.v3.CreateGroupRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.monitoring.v3.Group() + ); + client.innerApiCalls.createGroup = stubSimpleCallWithCallback( + expectedResponse + ); + const promise = new Promise((resolve, reject) => { + client.createGroup( + request, + ( + err?: Error | null, + result?: protos.google.monitoring.v3.IGroup | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.createGroup as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions /*, callback defined above */) + ); + }); + + it('invokes createGroup with error', async () => { + const client = new groupserviceModule.v3.GroupServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.monitoring.v3.CreateGroupRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.createGroup = stubSimpleCall( + undefined, + expectedError + ); + assert.rejects(async () => { + await client.createGroup(request); + }, expectedError); + assert( + (client.innerApiCalls.createGroup as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + }); + + describe('updateGroup', () => { + it('invokes updateGroup without error', async () => { + const client = new groupserviceModule.v3.GroupServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.monitoring.v3.UpdateGroupRequest() + ); + request.group = {}; + request.group.name = ''; + const expectedHeaderRequestParams = 'group.name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.monitoring.v3.Group() + ); + client.innerApiCalls.updateGroup = stubSimpleCall(expectedResponse); + const [response] = await client.updateGroup(request); + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.updateGroup as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + + it('invokes updateGroup without error using callback', async () => { + const client = new groupserviceModule.v3.GroupServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.monitoring.v3.UpdateGroupRequest() + ); + request.group = {}; + request.group.name = ''; + const expectedHeaderRequestParams = 'group.name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.monitoring.v3.Group() + ); + client.innerApiCalls.updateGroup = stubSimpleCallWithCallback( + expectedResponse + ); + const promise = new Promise((resolve, reject) => { + client.updateGroup( + request, + ( + err?: Error | null, + result?: protos.google.monitoring.v3.IGroup | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.updateGroup as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions /*, callback defined above */) + ); + }); + + it('invokes updateGroup with error', async () => { + const client = new groupserviceModule.v3.GroupServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.monitoring.v3.UpdateGroupRequest() + ); + request.group = {}; + request.group.name = ''; + const expectedHeaderRequestParams = 'group.name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.updateGroup = stubSimpleCall( + undefined, + expectedError + ); + assert.rejects(async () => { + await client.updateGroup(request); + }, expectedError); + assert( + (client.innerApiCalls.updateGroup as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + }); + + describe('deleteGroup', () => { + it('invokes deleteGroup without error', async () => { + const client = new groupserviceModule.v3.GroupServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.monitoring.v3.DeleteGroupRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.deleteGroup = stubSimpleCall(expectedResponse); + const [response] = await client.deleteGroup(request); + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.deleteGroup as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + + it('invokes deleteGroup without error using callback', async () => { + const client = new groupserviceModule.v3.GroupServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.monitoring.v3.DeleteGroupRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.deleteGroup = stubSimpleCallWithCallback( + expectedResponse + ); + const promise = new Promise((resolve, reject) => { + client.deleteGroup( + 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.deleteGroup as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions /*, callback defined above */) + ); + }); + + it('invokes deleteGroup with error', async () => { + const client = new groupserviceModule.v3.GroupServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.monitoring.v3.DeleteGroupRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteGroup = stubSimpleCall( + undefined, + expectedError + ); + assert.rejects(async () => { + await client.deleteGroup(request); + }, expectedError); + assert( + (client.innerApiCalls.deleteGroup as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + }); + + describe('listGroups', () => { + it('invokes listGroups without error', async () => { + const client = new groupserviceModule.v3.GroupServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.monitoring.v3.ListGroupsRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage(new protos.google.monitoring.v3.Group()), + generateSampleMessage(new protos.google.monitoring.v3.Group()), + generateSampleMessage(new protos.google.monitoring.v3.Group()), + ]; + client.innerApiCalls.listGroups = stubSimpleCall(expectedResponse); + const [response] = await client.listGroups(request); + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.listGroups as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + + it('invokes listGroups without error using callback', async () => { + const client = new groupserviceModule.v3.GroupServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.monitoring.v3.ListGroupsRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage(new protos.google.monitoring.v3.Group()), + generateSampleMessage(new protos.google.monitoring.v3.Group()), + generateSampleMessage(new protos.google.monitoring.v3.Group()), + ]; + client.innerApiCalls.listGroups = stubSimpleCallWithCallback( + expectedResponse + ); + const promise = new Promise((resolve, reject) => { + client.listGroups( + request, + ( + err?: Error | null, + result?: protos.google.monitoring.v3.IGroup[] | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.listGroups as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions /*, callback defined above */) + ); + }); + + it('invokes listGroups with error', async () => { + const client = new groupserviceModule.v3.GroupServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.monitoring.v3.ListGroupsRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.listGroups = stubSimpleCall( + undefined, + expectedError + ); + assert.rejects(async () => { + await client.listGroups(request); + }, expectedError); + assert( + (client.innerApiCalls.listGroups as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + + it('invokes listGroupsStream without error', async () => { + const client = new groupserviceModule.v3.GroupServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.monitoring.v3.ListGroupsRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedResponse = [ + generateSampleMessage(new protos.google.monitoring.v3.Group()), + generateSampleMessage(new protos.google.monitoring.v3.Group()), + generateSampleMessage(new protos.google.monitoring.v3.Group()), + ]; + client.descriptors.page.listGroups.createStream = stubPageStreamingCall( + expectedResponse + ); + const stream = client.listGroupsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.monitoring.v3.Group[] = []; + stream.on('data', (response: protos.google.monitoring.v3.Group) => { + 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.listGroups.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listGroups, request) + ); + assert.strictEqual( + (client.descriptors.page.listGroups.createStream as SinonStub).getCall( + 0 + ).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('invokes listGroupsStream with error', async () => { + const client = new groupserviceModule.v3.GroupServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.monitoring.v3.ListGroupsRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedError = new Error('expected'); + client.descriptors.page.listGroups.createStream = stubPageStreamingCall( + undefined, + expectedError + ); + const stream = client.listGroupsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.monitoring.v3.Group[] = []; + stream.on('data', (response: protos.google.monitoring.v3.Group) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + assert.rejects(async () => { + await promise; + }, expectedError); + assert( + (client.descriptors.page.listGroups.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listGroups, request) + ); + assert.strictEqual( + (client.descriptors.page.listGroups.createStream as SinonStub).getCall( + 0 + ).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listGroups without error', async () => { + const client = new groupserviceModule.v3.GroupServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.monitoring.v3.ListGroupsRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedResponse = [ + generateSampleMessage(new protos.google.monitoring.v3.Group()), + generateSampleMessage(new protos.google.monitoring.v3.Group()), + generateSampleMessage(new protos.google.monitoring.v3.Group()), + ]; + client.descriptors.page.listGroups.asyncIterate = stubAsyncIterationCall( + expectedResponse + ); + const responses: protos.google.monitoring.v3.IGroup[] = []; + const iterable = client.listGroupsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listGroups.asyncIterate as SinonStub).getCall( + 0 + ).args[1], + request + ); + assert.strictEqual( + (client.descriptors.page.listGroups.asyncIterate as SinonStub).getCall( + 0 + ).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listGroups with error', async () => { + const client = new groupserviceModule.v3.GroupServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.monitoring.v3.ListGroupsRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedError = new Error('expected'); + client.descriptors.page.listGroups.asyncIterate = stubAsyncIterationCall( + undefined, + expectedError + ); + const iterable = client.listGroupsAsync(request); + assert.rejects(async () => { + const responses: protos.google.monitoring.v3.IGroup[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listGroups.asyncIterate as SinonStub).getCall( + 0 + ).args[1], + request + ); + assert.strictEqual( + (client.descriptors.page.listGroups.asyncIterate as SinonStub).getCall( + 0 + ).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + }); + + describe('listGroupMembers', () => { + it('invokes listGroupMembers without error', async () => { + const client = new groupserviceModule.v3.GroupServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.monitoring.v3.ListGroupMembersRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage(new protos.google.api.MonitoredResource()), + generateSampleMessage(new protos.google.api.MonitoredResource()), + generateSampleMessage(new protos.google.api.MonitoredResource()), + ]; + client.innerApiCalls.listGroupMembers = stubSimpleCall(expectedResponse); + const [response] = await client.listGroupMembers(request); + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.listGroupMembers as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + + it('invokes listGroupMembers without error using callback', async () => { + const client = new groupserviceModule.v3.GroupServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.monitoring.v3.ListGroupMembersRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage(new protos.google.api.MonitoredResource()), + generateSampleMessage(new protos.google.api.MonitoredResource()), + generateSampleMessage(new protos.google.api.MonitoredResource()), + ]; + client.innerApiCalls.listGroupMembers = stubSimpleCallWithCallback( + expectedResponse + ); + const promise = new Promise((resolve, reject) => { + client.listGroupMembers( + request, + ( + err?: Error | null, + result?: protos.google.api.IMonitoredResource[] | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.listGroupMembers as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions /*, callback defined above */) + ); + }); + + it('invokes listGroupMembers with error', async () => { + const client = new groupserviceModule.v3.GroupServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.monitoring.v3.ListGroupMembersRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.listGroupMembers = stubSimpleCall( + undefined, + expectedError + ); + assert.rejects(async () => { + await client.listGroupMembers(request); + }, expectedError); + assert( + (client.innerApiCalls.listGroupMembers as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + + it('invokes listGroupMembersStream without error', async () => { + const client = new groupserviceModule.v3.GroupServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.monitoring.v3.ListGroupMembersRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedResponse = [ + generateSampleMessage(new protos.google.api.MonitoredResource()), + generateSampleMessage(new protos.google.api.MonitoredResource()), + generateSampleMessage(new protos.google.api.MonitoredResource()), + ]; + client.descriptors.page.listGroupMembers.createStream = stubPageStreamingCall( + expectedResponse + ); + const stream = client.listGroupMembersStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.api.MonitoredResource[] = []; + stream.on('data', (response: protos.google.api.MonitoredResource) => { + 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.listGroupMembers.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listGroupMembers, request) + ); + assert.strictEqual( + (client.descriptors.page.listGroupMembers + .createStream as SinonStub).getCall(0).args[2].otherArgs.headers[ + 'x-goog-request-params' + ], + expectedHeaderRequestParams + ); + }); + + it('invokes listGroupMembersStream with error', async () => { + const client = new groupserviceModule.v3.GroupServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.monitoring.v3.ListGroupMembersRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedError = new Error('expected'); + client.descriptors.page.listGroupMembers.createStream = stubPageStreamingCall( + undefined, + expectedError + ); + const stream = client.listGroupMembersStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.api.MonitoredResource[] = []; + stream.on('data', (response: protos.google.api.MonitoredResource) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + assert.rejects(async () => { + await promise; + }, expectedError); + assert( + (client.descriptors.page.listGroupMembers.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listGroupMembers, request) + ); + assert.strictEqual( + (client.descriptors.page.listGroupMembers + .createStream as SinonStub).getCall(0).args[2].otherArgs.headers[ + 'x-goog-request-params' + ], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listGroupMembers without error', async () => { + const client = new groupserviceModule.v3.GroupServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.monitoring.v3.ListGroupMembersRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedResponse = [ + generateSampleMessage(new protos.google.api.MonitoredResource()), + generateSampleMessage(new protos.google.api.MonitoredResource()), + generateSampleMessage(new protos.google.api.MonitoredResource()), + ]; + client.descriptors.page.listGroupMembers.asyncIterate = stubAsyncIterationCall( + expectedResponse + ); + const responses: protos.google.api.IMonitoredResource[] = []; + const iterable = client.listGroupMembersAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listGroupMembers + .asyncIterate as SinonStub).getCall(0).args[1], + request + ); + assert.strictEqual( + (client.descriptors.page.listGroupMembers + .asyncIterate as SinonStub).getCall(0).args[2].otherArgs.headers[ + 'x-goog-request-params' + ], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listGroupMembers with error', async () => { + const client = new groupserviceModule.v3.GroupServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.monitoring.v3.ListGroupMembersRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedError = new Error('expected'); + client.descriptors.page.listGroupMembers.asyncIterate = stubAsyncIterationCall( + undefined, + expectedError + ); + const iterable = client.listGroupMembersAsync(request); + assert.rejects(async () => { + const responses: protos.google.api.IMonitoredResource[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listGroupMembers + .asyncIterate as SinonStub).getCall(0).args[1], + request + ); + assert.strictEqual( + (client.descriptors.page.listGroupMembers + .asyncIterate as SinonStub).getCall(0).args[2].otherArgs.headers[ + 'x-goog-request-params' + ], + expectedHeaderRequestParams + ); + }); + }); + + describe('Path templates', () => { + describe('folderAlertPolicy', () => { + const fakePath = '/rendered/path/folderAlertPolicy'; + const expectedParameters = { + folder: 'folderValue', + alert_policy: 'alertPolicyValue', + }; + const client = new groupserviceModule.v3.GroupServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.folderAlertPolicyPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.folderAlertPolicyPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('folderAlertPolicyPath', () => { + const result = client.folderAlertPolicyPath( + 'folderValue', + 'alertPolicyValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.folderAlertPolicyPathTemplate + .render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchFolderFromFolderAlertPolicyName', () => { + const result = client.matchFolderFromFolderAlertPolicyName(fakePath); + assert.strictEqual(result, 'folderValue'); + assert( + (client.pathTemplates.folderAlertPolicyPathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchAlertPolicyFromFolderAlertPolicyName', () => { + const result = client.matchAlertPolicyFromFolderAlertPolicyName( + fakePath + ); + assert.strictEqual(result, 'alertPolicyValue'); + assert( + (client.pathTemplates.folderAlertPolicyPathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('folderAlertPolicyCondition', () => { + const fakePath = '/rendered/path/folderAlertPolicyCondition'; + const expectedParameters = { + folder: 'folderValue', + alert_policy: 'alertPolicyValue', + condition: 'conditionValue', + }; + const client = new groupserviceModule.v3.GroupServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.folderAlertPolicyConditionPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.folderAlertPolicyConditionPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('folderAlertPolicyConditionPath', () => { + const result = client.folderAlertPolicyConditionPath( + 'folderValue', + 'alertPolicyValue', + 'conditionValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.folderAlertPolicyConditionPathTemplate + .render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchFolderFromFolderAlertPolicyConditionName', () => { + const result = client.matchFolderFromFolderAlertPolicyConditionName( + fakePath + ); + assert.strictEqual(result, 'folderValue'); + assert( + (client.pathTemplates.folderAlertPolicyConditionPathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchAlertPolicyFromFolderAlertPolicyConditionName', () => { + const result = client.matchAlertPolicyFromFolderAlertPolicyConditionName( + fakePath + ); + assert.strictEqual(result, 'alertPolicyValue'); + assert( + (client.pathTemplates.folderAlertPolicyConditionPathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchConditionFromFolderAlertPolicyConditionName', () => { + const result = client.matchConditionFromFolderAlertPolicyConditionName( + fakePath + ); + assert.strictEqual(result, 'conditionValue'); + assert( + (client.pathTemplates.folderAlertPolicyConditionPathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('folderChannelDescriptor', () => { + const fakePath = '/rendered/path/folderChannelDescriptor'; + const expectedParameters = { + folder: 'folderValue', + channel_descriptor: 'channelDescriptorValue', + }; + const client = new groupserviceModule.v3.GroupServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.folderChannelDescriptorPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.folderChannelDescriptorPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('folderChannelDescriptorPath', () => { + const result = client.folderChannelDescriptorPath( + 'folderValue', + 'channelDescriptorValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.folderChannelDescriptorPathTemplate + .render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchFolderFromFolderChannelDescriptorName', () => { + const result = client.matchFolderFromFolderChannelDescriptorName( + fakePath + ); + assert.strictEqual(result, 'folderValue'); + assert( + (client.pathTemplates.folderChannelDescriptorPathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchChannelDescriptorFromFolderChannelDescriptorName', () => { + const result = client.matchChannelDescriptorFromFolderChannelDescriptorName( + fakePath + ); + assert.strictEqual(result, 'channelDescriptorValue'); + assert( + (client.pathTemplates.folderChannelDescriptorPathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('folderGroup', () => { + const fakePath = '/rendered/path/folderGroup'; + const expectedParameters = { + folder: 'folderValue', + group: 'groupValue', + }; + const client = new groupserviceModule.v3.GroupServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.folderGroupPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.folderGroupPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('folderGroupPath', () => { + const result = client.folderGroupPath('folderValue', 'groupValue'); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.folderGroupPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchFolderFromFolderGroupName', () => { + const result = client.matchFolderFromFolderGroupName(fakePath); + assert.strictEqual(result, 'folderValue'); + assert( + (client.pathTemplates.folderGroupPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchGroupFromFolderGroupName', () => { + const result = client.matchGroupFromFolderGroupName(fakePath); + assert.strictEqual(result, 'groupValue'); + assert( + (client.pathTemplates.folderGroupPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('folderNotificationChannel', () => { + const fakePath = '/rendered/path/folderNotificationChannel'; + const expectedParameters = { + folder: 'folderValue', + notification_channel: 'notificationChannelValue', + }; + const client = new groupserviceModule.v3.GroupServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.folderNotificationChannelPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.folderNotificationChannelPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('folderNotificationChannelPath', () => { + const result = client.folderNotificationChannelPath( + 'folderValue', + 'notificationChannelValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.folderNotificationChannelPathTemplate + .render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchFolderFromFolderNotificationChannelName', () => { + const result = client.matchFolderFromFolderNotificationChannelName( + fakePath + ); + assert.strictEqual(result, 'folderValue'); + assert( + (client.pathTemplates.folderNotificationChannelPathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchNotificationChannelFromFolderNotificationChannelName', () => { + const result = client.matchNotificationChannelFromFolderNotificationChannelName( + fakePath + ); + assert.strictEqual(result, 'notificationChannelValue'); + assert( + (client.pathTemplates.folderNotificationChannelPathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('folderService', () => { + const fakePath = '/rendered/path/folderService'; + const expectedParameters = { + folder: 'folderValue', + service: 'serviceValue', + }; + const client = new groupserviceModule.v3.GroupServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.folderServicePathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.folderServicePathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('folderServicePath', () => { + const result = client.folderServicePath('folderValue', 'serviceValue'); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.folderServicePathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchFolderFromFolderServiceName', () => { + const result = client.matchFolderFromFolderServiceName(fakePath); + assert.strictEqual(result, 'folderValue'); + assert( + (client.pathTemplates.folderServicePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchServiceFromFolderServiceName', () => { + const result = client.matchServiceFromFolderServiceName(fakePath); + assert.strictEqual(result, 'serviceValue'); + assert( + (client.pathTemplates.folderServicePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('folderServiceServiceLevelObjective', () => { + const fakePath = '/rendered/path/folderServiceServiceLevelObjective'; + const expectedParameters = { + folder: 'folderValue', + service: 'serviceValue', + service_level_objective: 'serviceLevelObjectiveValue', + }; + const client = new groupserviceModule.v3.GroupServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.folderServiceServiceLevelObjectivePathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.folderServiceServiceLevelObjectivePathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('folderServiceServiceLevelObjectivePath', () => { + const result = client.folderServiceServiceLevelObjectivePath( + 'folderValue', + 'serviceValue', + 'serviceLevelObjectiveValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.folderServiceServiceLevelObjectivePathTemplate + .render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchFolderFromFolderServiceServiceLevelObjectiveName', () => { + const result = client.matchFolderFromFolderServiceServiceLevelObjectiveName( + fakePath + ); + assert.strictEqual(result, 'folderValue'); + assert( + (client.pathTemplates.folderServiceServiceLevelObjectivePathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchServiceFromFolderServiceServiceLevelObjectiveName', () => { + const result = client.matchServiceFromFolderServiceServiceLevelObjectiveName( + fakePath + ); + assert.strictEqual(result, 'serviceValue'); + assert( + (client.pathTemplates.folderServiceServiceLevelObjectivePathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchServiceLevelObjectiveFromFolderServiceServiceLevelObjectiveName', () => { + const result = client.matchServiceLevelObjectiveFromFolderServiceServiceLevelObjectiveName( + fakePath + ); + assert.strictEqual(result, 'serviceLevelObjectiveValue'); + assert( + (client.pathTemplates.folderServiceServiceLevelObjectivePathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('folderUptimeCheckConfig', () => { + const fakePath = '/rendered/path/folderUptimeCheckConfig'; + const expectedParameters = { + folder: 'folderValue', + uptime_check_config: 'uptimeCheckConfigValue', + }; + const client = new groupserviceModule.v3.GroupServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.folderUptimeCheckConfigPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.folderUptimeCheckConfigPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('folderUptimeCheckConfigPath', () => { + const result = client.folderUptimeCheckConfigPath( + 'folderValue', + 'uptimeCheckConfigValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.folderUptimeCheckConfigPathTemplate + .render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchFolderFromFolderUptimeCheckConfigName', () => { + const result = client.matchFolderFromFolderUptimeCheckConfigName( + fakePath + ); + assert.strictEqual(result, 'folderValue'); + assert( + (client.pathTemplates.folderUptimeCheckConfigPathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchUptimeCheckConfigFromFolderUptimeCheckConfigName', () => { + const result = client.matchUptimeCheckConfigFromFolderUptimeCheckConfigName( + fakePath + ); + assert.strictEqual(result, 'uptimeCheckConfigValue'); + assert( + (client.pathTemplates.folderUptimeCheckConfigPathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('organizationAlertPolicy', () => { + const fakePath = '/rendered/path/organizationAlertPolicy'; + const expectedParameters = { + organization: 'organizationValue', + alert_policy: 'alertPolicyValue', + }; + const client = new groupserviceModule.v3.GroupServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.organizationAlertPolicyPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.organizationAlertPolicyPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('organizationAlertPolicyPath', () => { + const result = client.organizationAlertPolicyPath( + 'organizationValue', + 'alertPolicyValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.organizationAlertPolicyPathTemplate + .render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchOrganizationFromOrganizationAlertPolicyName', () => { + const result = client.matchOrganizationFromOrganizationAlertPolicyName( + fakePath + ); + assert.strictEqual(result, 'organizationValue'); + assert( + (client.pathTemplates.organizationAlertPolicyPathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchAlertPolicyFromOrganizationAlertPolicyName', () => { + const result = client.matchAlertPolicyFromOrganizationAlertPolicyName( + fakePath + ); + assert.strictEqual(result, 'alertPolicyValue'); + assert( + (client.pathTemplates.organizationAlertPolicyPathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('organizationAlertPolicyCondition', () => { + const fakePath = '/rendered/path/organizationAlertPolicyCondition'; + const expectedParameters = { + organization: 'organizationValue', + alert_policy: 'alertPolicyValue', + condition: 'conditionValue', + }; + const client = new groupserviceModule.v3.GroupServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.organizationAlertPolicyConditionPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.organizationAlertPolicyConditionPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('organizationAlertPolicyConditionPath', () => { + const result = client.organizationAlertPolicyConditionPath( + 'organizationValue', + 'alertPolicyValue', + 'conditionValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.organizationAlertPolicyConditionPathTemplate + .render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchOrganizationFromOrganizationAlertPolicyConditionName', () => { + const result = client.matchOrganizationFromOrganizationAlertPolicyConditionName( + fakePath + ); + assert.strictEqual(result, 'organizationValue'); + assert( + (client.pathTemplates.organizationAlertPolicyConditionPathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchAlertPolicyFromOrganizationAlertPolicyConditionName', () => { + const result = client.matchAlertPolicyFromOrganizationAlertPolicyConditionName( + fakePath + ); + assert.strictEqual(result, 'alertPolicyValue'); + assert( + (client.pathTemplates.organizationAlertPolicyConditionPathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchConditionFromOrganizationAlertPolicyConditionName', () => { + const result = client.matchConditionFromOrganizationAlertPolicyConditionName( + fakePath + ); + assert.strictEqual(result, 'conditionValue'); + assert( + (client.pathTemplates.organizationAlertPolicyConditionPathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('organizationChannelDescriptor', () => { + const fakePath = '/rendered/path/organizationChannelDescriptor'; + const expectedParameters = { + organization: 'organizationValue', + channel_descriptor: 'channelDescriptorValue', + }; + const client = new groupserviceModule.v3.GroupServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.organizationChannelDescriptorPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.organizationChannelDescriptorPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('organizationChannelDescriptorPath', () => { + const result = client.organizationChannelDescriptorPath( + 'organizationValue', + 'channelDescriptorValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.organizationChannelDescriptorPathTemplate + .render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchOrganizationFromOrganizationChannelDescriptorName', () => { + const result = client.matchOrganizationFromOrganizationChannelDescriptorName( + fakePath + ); + assert.strictEqual(result, 'organizationValue'); + assert( + (client.pathTemplates.organizationChannelDescriptorPathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchChannelDescriptorFromOrganizationChannelDescriptorName', () => { + const result = client.matchChannelDescriptorFromOrganizationChannelDescriptorName( + fakePath + ); + assert.strictEqual(result, 'channelDescriptorValue'); + assert( + (client.pathTemplates.organizationChannelDescriptorPathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('organizationGroup', () => { + const fakePath = '/rendered/path/organizationGroup'; + const expectedParameters = { + organization: 'organizationValue', + group: 'groupValue', + }; + const client = new groupserviceModule.v3.GroupServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.organizationGroupPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.organizationGroupPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('organizationGroupPath', () => { + const result = client.organizationGroupPath( + 'organizationValue', + 'groupValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.organizationGroupPathTemplate + .render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchOrganizationFromOrganizationGroupName', () => { + const result = client.matchOrganizationFromOrganizationGroupName( + fakePath + ); + assert.strictEqual(result, 'organizationValue'); + assert( + (client.pathTemplates.organizationGroupPathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchGroupFromOrganizationGroupName', () => { + const result = client.matchGroupFromOrganizationGroupName(fakePath); + assert.strictEqual(result, 'groupValue'); + assert( + (client.pathTemplates.organizationGroupPathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('organizationNotificationChannel', () => { + const fakePath = '/rendered/path/organizationNotificationChannel'; + const expectedParameters = { + organization: 'organizationValue', + notification_channel: 'notificationChannelValue', + }; + const client = new groupserviceModule.v3.GroupServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.organizationNotificationChannelPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.organizationNotificationChannelPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('organizationNotificationChannelPath', () => { + const result = client.organizationNotificationChannelPath( + 'organizationValue', + 'notificationChannelValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.organizationNotificationChannelPathTemplate + .render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchOrganizationFromOrganizationNotificationChannelName', () => { + const result = client.matchOrganizationFromOrganizationNotificationChannelName( + fakePath + ); + assert.strictEqual(result, 'organizationValue'); + assert( + (client.pathTemplates.organizationNotificationChannelPathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchNotificationChannelFromOrganizationNotificationChannelName', () => { + const result = client.matchNotificationChannelFromOrganizationNotificationChannelName( + fakePath + ); + assert.strictEqual(result, 'notificationChannelValue'); + assert( + (client.pathTemplates.organizationNotificationChannelPathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('organizationService', () => { + const fakePath = '/rendered/path/organizationService'; + const expectedParameters = { + organization: 'organizationValue', + service: 'serviceValue', + }; + const client = new groupserviceModule.v3.GroupServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.organizationServicePathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.organizationServicePathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('organizationServicePath', () => { + const result = client.organizationServicePath( + 'organizationValue', + 'serviceValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.organizationServicePathTemplate + .render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchOrganizationFromOrganizationServiceName', () => { + const result = client.matchOrganizationFromOrganizationServiceName( + fakePath + ); + assert.strictEqual(result, 'organizationValue'); + assert( + (client.pathTemplates.organizationServicePathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchServiceFromOrganizationServiceName', () => { + const result = client.matchServiceFromOrganizationServiceName(fakePath); + assert.strictEqual(result, 'serviceValue'); + assert( + (client.pathTemplates.organizationServicePathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('organizationServiceServiceLevelObjective', () => { + const fakePath = + '/rendered/path/organizationServiceServiceLevelObjective'; + const expectedParameters = { + organization: 'organizationValue', + service: 'serviceValue', + service_level_objective: 'serviceLevelObjectiveValue', + }; + const client = new groupserviceModule.v3.GroupServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.organizationServiceServiceLevelObjectivePathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.organizationServiceServiceLevelObjectivePathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('organizationServiceServiceLevelObjectivePath', () => { + const result = client.organizationServiceServiceLevelObjectivePath( + 'organizationValue', + 'serviceValue', + 'serviceLevelObjectiveValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates + .organizationServiceServiceLevelObjectivePathTemplate + .render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchOrganizationFromOrganizationServiceServiceLevelObjectiveName', () => { + const result = client.matchOrganizationFromOrganizationServiceServiceLevelObjectiveName( + fakePath + ); + assert.strictEqual(result, 'organizationValue'); + assert( + (client.pathTemplates + .organizationServiceServiceLevelObjectivePathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchServiceFromOrganizationServiceServiceLevelObjectiveName', () => { + const result = client.matchServiceFromOrganizationServiceServiceLevelObjectiveName( + fakePath + ); + assert.strictEqual(result, 'serviceValue'); + assert( + (client.pathTemplates + .organizationServiceServiceLevelObjectivePathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchServiceLevelObjectiveFromOrganizationServiceServiceLevelObjectiveName', () => { + const result = client.matchServiceLevelObjectiveFromOrganizationServiceServiceLevelObjectiveName( + fakePath + ); + assert.strictEqual(result, 'serviceLevelObjectiveValue'); + assert( + (client.pathTemplates + .organizationServiceServiceLevelObjectivePathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('organizationUptimeCheckConfig', () => { + const fakePath = '/rendered/path/organizationUptimeCheckConfig'; + const expectedParameters = { + organization: 'organizationValue', + uptime_check_config: 'uptimeCheckConfigValue', + }; + const client = new groupserviceModule.v3.GroupServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.organizationUptimeCheckConfigPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.organizationUptimeCheckConfigPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('organizationUptimeCheckConfigPath', () => { + const result = client.organizationUptimeCheckConfigPath( + 'organizationValue', + 'uptimeCheckConfigValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.organizationUptimeCheckConfigPathTemplate + .render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchOrganizationFromOrganizationUptimeCheckConfigName', () => { + const result = client.matchOrganizationFromOrganizationUptimeCheckConfigName( + fakePath + ); + assert.strictEqual(result, 'organizationValue'); + assert( + (client.pathTemplates.organizationUptimeCheckConfigPathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchUptimeCheckConfigFromOrganizationUptimeCheckConfigName', () => { + const result = client.matchUptimeCheckConfigFromOrganizationUptimeCheckConfigName( + fakePath + ); + assert.strictEqual(result, 'uptimeCheckConfigValue'); + assert( + (client.pathTemplates.organizationUptimeCheckConfigPathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('project', () => { + const fakePath = '/rendered/path/project'; + const expectedParameters = { + project: 'projectValue', + }; + const client = new groupserviceModule.v3.GroupServiceClient({ + 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('matchProjectFromProjectName', () => { + const result = client.matchProjectFromProjectName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.projectPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('projectAlertPolicy', () => { + const fakePath = '/rendered/path/projectAlertPolicy'; + const expectedParameters = { + project: 'projectValue', + alert_policy: 'alertPolicyValue', + }; + const client = new groupserviceModule.v3.GroupServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.projectAlertPolicyPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.projectAlertPolicyPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('projectAlertPolicyPath', () => { + const result = client.projectAlertPolicyPath( + 'projectValue', + 'alertPolicyValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.projectAlertPolicyPathTemplate + .render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromProjectAlertPolicyName', () => { + const result = client.matchProjectFromProjectAlertPolicyName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.projectAlertPolicyPathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchAlertPolicyFromProjectAlertPolicyName', () => { + const result = client.matchAlertPolicyFromProjectAlertPolicyName( + fakePath + ); + assert.strictEqual(result, 'alertPolicyValue'); + assert( + (client.pathTemplates.projectAlertPolicyPathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('projectAlertPolicyCondition', () => { + const fakePath = '/rendered/path/projectAlertPolicyCondition'; + const expectedParameters = { + project: 'projectValue', + alert_policy: 'alertPolicyValue', + condition: 'conditionValue', + }; + const client = new groupserviceModule.v3.GroupServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.projectAlertPolicyConditionPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.projectAlertPolicyConditionPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('projectAlertPolicyConditionPath', () => { + const result = client.projectAlertPolicyConditionPath( + 'projectValue', + 'alertPolicyValue', + 'conditionValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.projectAlertPolicyConditionPathTemplate + .render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromProjectAlertPolicyConditionName', () => { + const result = client.matchProjectFromProjectAlertPolicyConditionName( + fakePath + ); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.projectAlertPolicyConditionPathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchAlertPolicyFromProjectAlertPolicyConditionName', () => { + const result = client.matchAlertPolicyFromProjectAlertPolicyConditionName( + fakePath + ); + assert.strictEqual(result, 'alertPolicyValue'); + assert( + (client.pathTemplates.projectAlertPolicyConditionPathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchConditionFromProjectAlertPolicyConditionName', () => { + const result = client.matchConditionFromProjectAlertPolicyConditionName( + fakePath + ); + assert.strictEqual(result, 'conditionValue'); + assert( + (client.pathTemplates.projectAlertPolicyConditionPathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('projectChannelDescriptor', () => { + const fakePath = '/rendered/path/projectChannelDescriptor'; + const expectedParameters = { + project: 'projectValue', + channel_descriptor: 'channelDescriptorValue', + }; + const client = new groupserviceModule.v3.GroupServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.projectChannelDescriptorPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.projectChannelDescriptorPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('projectChannelDescriptorPath', () => { + const result = client.projectChannelDescriptorPath( + 'projectValue', + 'channelDescriptorValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.projectChannelDescriptorPathTemplate + .render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromProjectChannelDescriptorName', () => { + const result = client.matchProjectFromProjectChannelDescriptorName( + fakePath + ); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.projectChannelDescriptorPathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchChannelDescriptorFromProjectChannelDescriptorName', () => { + const result = client.matchChannelDescriptorFromProjectChannelDescriptorName( + fakePath + ); + assert.strictEqual(result, 'channelDescriptorValue'); + assert( + (client.pathTemplates.projectChannelDescriptorPathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('projectGroup', () => { + const fakePath = '/rendered/path/projectGroup'; + const expectedParameters = { + project: 'projectValue', + group: 'groupValue', + }; + const client = new groupserviceModule.v3.GroupServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.projectGroupPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.projectGroupPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('projectGroupPath', () => { + const result = client.projectGroupPath('projectValue', 'groupValue'); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.projectGroupPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromProjectGroupName', () => { + const result = client.matchProjectFromProjectGroupName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.projectGroupPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchGroupFromProjectGroupName', () => { + const result = client.matchGroupFromProjectGroupName(fakePath); + assert.strictEqual(result, 'groupValue'); + assert( + (client.pathTemplates.projectGroupPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('projectNotificationChannel', () => { + const fakePath = '/rendered/path/projectNotificationChannel'; + const expectedParameters = { + project: 'projectValue', + notification_channel: 'notificationChannelValue', + }; + const client = new groupserviceModule.v3.GroupServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.projectNotificationChannelPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.projectNotificationChannelPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('projectNotificationChannelPath', () => { + const result = client.projectNotificationChannelPath( + 'projectValue', + 'notificationChannelValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.projectNotificationChannelPathTemplate + .render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromProjectNotificationChannelName', () => { + const result = client.matchProjectFromProjectNotificationChannelName( + fakePath + ); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.projectNotificationChannelPathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchNotificationChannelFromProjectNotificationChannelName', () => { + const result = client.matchNotificationChannelFromProjectNotificationChannelName( + fakePath + ); + assert.strictEqual(result, 'notificationChannelValue'); + assert( + (client.pathTemplates.projectNotificationChannelPathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('projectService', () => { + const fakePath = '/rendered/path/projectService'; + const expectedParameters = { + project: 'projectValue', + service: 'serviceValue', + }; + const client = new groupserviceModule.v3.GroupServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.projectServicePathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.projectServicePathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('projectServicePath', () => { + const result = client.projectServicePath( + 'projectValue', + 'serviceValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.projectServicePathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromProjectServiceName', () => { + const result = client.matchProjectFromProjectServiceName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.projectServicePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchServiceFromProjectServiceName', () => { + const result = client.matchServiceFromProjectServiceName(fakePath); + assert.strictEqual(result, 'serviceValue'); + assert( + (client.pathTemplates.projectServicePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('projectServiceServiceLevelObjective', () => { + const fakePath = '/rendered/path/projectServiceServiceLevelObjective'; + const expectedParameters = { + project: 'projectValue', + service: 'serviceValue', + service_level_objective: 'serviceLevelObjectiveValue', + }; + const client = new groupserviceModule.v3.GroupServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.projectServiceServiceLevelObjectivePathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.projectServiceServiceLevelObjectivePathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('projectServiceServiceLevelObjectivePath', () => { + const result = client.projectServiceServiceLevelObjectivePath( + 'projectValue', + 'serviceValue', + 'serviceLevelObjectiveValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.projectServiceServiceLevelObjectivePathTemplate + .render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromProjectServiceServiceLevelObjectiveName', () => { + const result = client.matchProjectFromProjectServiceServiceLevelObjectiveName( + fakePath + ); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.projectServiceServiceLevelObjectivePathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchServiceFromProjectServiceServiceLevelObjectiveName', () => { + const result = client.matchServiceFromProjectServiceServiceLevelObjectiveName( + fakePath + ); + assert.strictEqual(result, 'serviceValue'); + assert( + (client.pathTemplates.projectServiceServiceLevelObjectivePathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchServiceLevelObjectiveFromProjectServiceServiceLevelObjectiveName', () => { + const result = client.matchServiceLevelObjectiveFromProjectServiceServiceLevelObjectiveName( + fakePath + ); + assert.strictEqual(result, 'serviceLevelObjectiveValue'); + assert( + (client.pathTemplates.projectServiceServiceLevelObjectivePathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('projectUptimeCheckConfig', () => { + const fakePath = '/rendered/path/projectUptimeCheckConfig'; + const expectedParameters = { + project: 'projectValue', + uptime_check_config: 'uptimeCheckConfigValue', + }; + const client = new groupserviceModule.v3.GroupServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.projectUptimeCheckConfigPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.projectUptimeCheckConfigPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('projectUptimeCheckConfigPath', () => { + const result = client.projectUptimeCheckConfigPath( + 'projectValue', + 'uptimeCheckConfigValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.projectUptimeCheckConfigPathTemplate + .render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromProjectUptimeCheckConfigName', () => { + const result = client.matchProjectFromProjectUptimeCheckConfigName( + fakePath + ); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.projectUptimeCheckConfigPathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchUptimeCheckConfigFromProjectUptimeCheckConfigName', () => { + const result = client.matchUptimeCheckConfigFromProjectUptimeCheckConfigName( + fakePath + ); + assert.strictEqual(result, 'uptimeCheckConfigValue'); + assert( + (client.pathTemplates.projectUptimeCheckConfigPathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + }); +}); diff --git a/packages/google-cloud-monitoring/test/gapic_metric_service_v3.ts b/packages/google-cloud-monitoring/test/gapic_metric_service_v3.ts new file mode 100644 index 00000000000..142d8e0ec7f --- /dev/null +++ b/packages/google-cloud-monitoring/test/gapic_metric_service_v3.ts @@ -0,0 +1,3551 @@ +// Copyright 2020 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +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 * as metricserviceModule from '../src'; + +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; +} + +function stubSimpleCall(response?: ResponseType, error?: Error) { + 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 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(); + }); + } + 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); +} + +describe('v3.MetricServiceClient', () => { + it('has servicePath', () => { + const servicePath = metricserviceModule.v3.MetricServiceClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = metricserviceModule.v3.MetricServiceClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = metricserviceModule.v3.MetricServiceClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new metricserviceModule.v3.MetricServiceClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new metricserviceModule.v3.MetricServiceClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new metricserviceModule.v3.MetricServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.metricServiceStub, undefined); + await client.initialize(); + assert(client.metricServiceStub); + }); + + it('has close method', () => { + const client = new metricserviceModule.v3.MetricServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.close(); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new metricserviceModule.v3.MetricServiceClient({ + 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 metricserviceModule.v3.MetricServiceClient({ + 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('getMonitoredResourceDescriptor', () => { + it('invokes getMonitoredResourceDescriptor without error', async () => { + const client = new metricserviceModule.v3.MetricServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.monitoring.v3.GetMonitoredResourceDescriptorRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.api.MonitoredResourceDescriptor() + ); + client.innerApiCalls.getMonitoredResourceDescriptor = stubSimpleCall( + expectedResponse + ); + const [response] = await client.getMonitoredResourceDescriptor(request); + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.getMonitoredResourceDescriptor as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + + it('invokes getMonitoredResourceDescriptor without error using callback', async () => { + const client = new metricserviceModule.v3.MetricServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.monitoring.v3.GetMonitoredResourceDescriptorRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.api.MonitoredResourceDescriptor() + ); + client.innerApiCalls.getMonitoredResourceDescriptor = stubSimpleCallWithCallback( + expectedResponse + ); + const promise = new Promise((resolve, reject) => { + client.getMonitoredResourceDescriptor( + request, + ( + err?: Error | null, + result?: protos.google.api.IMonitoredResourceDescriptor | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.getMonitoredResourceDescriptor as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions /*, callback defined above */) + ); + }); + + it('invokes getMonitoredResourceDescriptor with error', async () => { + const client = new metricserviceModule.v3.MetricServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.monitoring.v3.GetMonitoredResourceDescriptorRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.getMonitoredResourceDescriptor = stubSimpleCall( + undefined, + expectedError + ); + assert.rejects(async () => { + await client.getMonitoredResourceDescriptor(request); + }, expectedError); + assert( + (client.innerApiCalls.getMonitoredResourceDescriptor as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + }); + + describe('getMetricDescriptor', () => { + it('invokes getMetricDescriptor without error', async () => { + const client = new metricserviceModule.v3.MetricServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.monitoring.v3.GetMetricDescriptorRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.api.MetricDescriptor() + ); + client.innerApiCalls.getMetricDescriptor = stubSimpleCall( + expectedResponse + ); + const [response] = await client.getMetricDescriptor(request); + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.getMetricDescriptor as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + + it('invokes getMetricDescriptor without error using callback', async () => { + const client = new metricserviceModule.v3.MetricServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.monitoring.v3.GetMetricDescriptorRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.api.MetricDescriptor() + ); + client.innerApiCalls.getMetricDescriptor = stubSimpleCallWithCallback( + expectedResponse + ); + const promise = new Promise((resolve, reject) => { + client.getMetricDescriptor( + request, + ( + err?: Error | null, + result?: protos.google.api.IMetricDescriptor | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.getMetricDescriptor as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions /*, callback defined above */) + ); + }); + + it('invokes getMetricDescriptor with error', async () => { + const client = new metricserviceModule.v3.MetricServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.monitoring.v3.GetMetricDescriptorRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.getMetricDescriptor = stubSimpleCall( + undefined, + expectedError + ); + assert.rejects(async () => { + await client.getMetricDescriptor(request); + }, expectedError); + assert( + (client.innerApiCalls.getMetricDescriptor as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + }); + + describe('createMetricDescriptor', () => { + it('invokes createMetricDescriptor without error', async () => { + const client = new metricserviceModule.v3.MetricServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.monitoring.v3.CreateMetricDescriptorRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.api.MetricDescriptor() + ); + client.innerApiCalls.createMetricDescriptor = stubSimpleCall( + expectedResponse + ); + const [response] = await client.createMetricDescriptor(request); + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.createMetricDescriptor as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + + it('invokes createMetricDescriptor without error using callback', async () => { + const client = new metricserviceModule.v3.MetricServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.monitoring.v3.CreateMetricDescriptorRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.api.MetricDescriptor() + ); + client.innerApiCalls.createMetricDescriptor = stubSimpleCallWithCallback( + expectedResponse + ); + const promise = new Promise((resolve, reject) => { + client.createMetricDescriptor( + request, + ( + err?: Error | null, + result?: protos.google.api.IMetricDescriptor | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.createMetricDescriptor as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions /*, callback defined above */) + ); + }); + + it('invokes createMetricDescriptor with error', async () => { + const client = new metricserviceModule.v3.MetricServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.monitoring.v3.CreateMetricDescriptorRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.createMetricDescriptor = stubSimpleCall( + undefined, + expectedError + ); + assert.rejects(async () => { + await client.createMetricDescriptor(request); + }, expectedError); + assert( + (client.innerApiCalls.createMetricDescriptor as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + }); + + describe('deleteMetricDescriptor', () => { + it('invokes deleteMetricDescriptor without error', async () => { + const client = new metricserviceModule.v3.MetricServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.monitoring.v3.DeleteMetricDescriptorRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.deleteMetricDescriptor = stubSimpleCall( + expectedResponse + ); + const [response] = await client.deleteMetricDescriptor(request); + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.deleteMetricDescriptor as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + + it('invokes deleteMetricDescriptor without error using callback', async () => { + const client = new metricserviceModule.v3.MetricServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.monitoring.v3.DeleteMetricDescriptorRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.deleteMetricDescriptor = stubSimpleCallWithCallback( + expectedResponse + ); + const promise = new Promise((resolve, reject) => { + client.deleteMetricDescriptor( + 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.deleteMetricDescriptor as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions /*, callback defined above */) + ); + }); + + it('invokes deleteMetricDescriptor with error', async () => { + const client = new metricserviceModule.v3.MetricServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.monitoring.v3.DeleteMetricDescriptorRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteMetricDescriptor = stubSimpleCall( + undefined, + expectedError + ); + assert.rejects(async () => { + await client.deleteMetricDescriptor(request); + }, expectedError); + assert( + (client.innerApiCalls.deleteMetricDescriptor as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + }); + + describe('createTimeSeries', () => { + it('invokes createTimeSeries without error', async () => { + const client = new metricserviceModule.v3.MetricServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.monitoring.v3.CreateTimeSeriesRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.createTimeSeries = stubSimpleCall(expectedResponse); + const [response] = await client.createTimeSeries(request); + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.createTimeSeries as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + + it('invokes createTimeSeries without error using callback', async () => { + const client = new metricserviceModule.v3.MetricServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.monitoring.v3.CreateTimeSeriesRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.createTimeSeries = stubSimpleCallWithCallback( + expectedResponse + ); + const promise = new Promise((resolve, reject) => { + client.createTimeSeries( + 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.createTimeSeries as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions /*, callback defined above */) + ); + }); + + it('invokes createTimeSeries with error', async () => { + const client = new metricserviceModule.v3.MetricServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.monitoring.v3.CreateTimeSeriesRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.createTimeSeries = stubSimpleCall( + undefined, + expectedError + ); + assert.rejects(async () => { + await client.createTimeSeries(request); + }, expectedError); + assert( + (client.innerApiCalls.createTimeSeries as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + }); + + describe('listMonitoredResourceDescriptors', () => { + it('invokes listMonitoredResourceDescriptors without error', async () => { + const client = new metricserviceModule.v3.MetricServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.monitoring.v3.ListMonitoredResourceDescriptorsRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage( + new protos.google.api.MonitoredResourceDescriptor() + ), + generateSampleMessage( + new protos.google.api.MonitoredResourceDescriptor() + ), + generateSampleMessage( + new protos.google.api.MonitoredResourceDescriptor() + ), + ]; + client.innerApiCalls.listMonitoredResourceDescriptors = stubSimpleCall( + expectedResponse + ); + const [response] = await client.listMonitoredResourceDescriptors(request); + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.listMonitoredResourceDescriptors as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + + it('invokes listMonitoredResourceDescriptors without error using callback', async () => { + const client = new metricserviceModule.v3.MetricServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.monitoring.v3.ListMonitoredResourceDescriptorsRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage( + new protos.google.api.MonitoredResourceDescriptor() + ), + generateSampleMessage( + new protos.google.api.MonitoredResourceDescriptor() + ), + generateSampleMessage( + new protos.google.api.MonitoredResourceDescriptor() + ), + ]; + client.innerApiCalls.listMonitoredResourceDescriptors = stubSimpleCallWithCallback( + expectedResponse + ); + const promise = new Promise((resolve, reject) => { + client.listMonitoredResourceDescriptors( + request, + ( + err?: Error | null, + result?: protos.google.api.IMonitoredResourceDescriptor[] | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.listMonitoredResourceDescriptors as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions /*, callback defined above */) + ); + }); + + it('invokes listMonitoredResourceDescriptors with error', async () => { + const client = new metricserviceModule.v3.MetricServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.monitoring.v3.ListMonitoredResourceDescriptorsRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.listMonitoredResourceDescriptors = stubSimpleCall( + undefined, + expectedError + ); + assert.rejects(async () => { + await client.listMonitoredResourceDescriptors(request); + }, expectedError); + assert( + (client.innerApiCalls.listMonitoredResourceDescriptors as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + + it('invokes listMonitoredResourceDescriptorsStream without error', async () => { + const client = new metricserviceModule.v3.MetricServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.monitoring.v3.ListMonitoredResourceDescriptorsRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedResponse = [ + generateSampleMessage( + new protos.google.api.MonitoredResourceDescriptor() + ), + generateSampleMessage( + new protos.google.api.MonitoredResourceDescriptor() + ), + generateSampleMessage( + new protos.google.api.MonitoredResourceDescriptor() + ), + ]; + client.descriptors.page.listMonitoredResourceDescriptors.createStream = stubPageStreamingCall( + expectedResponse + ); + const stream = client.listMonitoredResourceDescriptorsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.api.MonitoredResourceDescriptor[] = []; + stream.on( + 'data', + (response: protos.google.api.MonitoredResourceDescriptor) => { + 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.listMonitoredResourceDescriptors + .createStream as SinonStub) + .getCall(0) + .calledWith( + client.innerApiCalls.listMonitoredResourceDescriptors, + request + ) + ); + assert.strictEqual( + (client.descriptors.page.listMonitoredResourceDescriptors + .createStream as SinonStub).getCall(0).args[2].otherArgs.headers[ + 'x-goog-request-params' + ], + expectedHeaderRequestParams + ); + }); + + it('invokes listMonitoredResourceDescriptorsStream with error', async () => { + const client = new metricserviceModule.v3.MetricServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.monitoring.v3.ListMonitoredResourceDescriptorsRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedError = new Error('expected'); + client.descriptors.page.listMonitoredResourceDescriptors.createStream = stubPageStreamingCall( + undefined, + expectedError + ); + const stream = client.listMonitoredResourceDescriptorsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.api.MonitoredResourceDescriptor[] = []; + stream.on( + 'data', + (response: protos.google.api.MonitoredResourceDescriptor) => { + responses.push(response); + } + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + assert.rejects(async () => { + await promise; + }, expectedError); + assert( + (client.descriptors.page.listMonitoredResourceDescriptors + .createStream as SinonStub) + .getCall(0) + .calledWith( + client.innerApiCalls.listMonitoredResourceDescriptors, + request + ) + ); + assert.strictEqual( + (client.descriptors.page.listMonitoredResourceDescriptors + .createStream as SinonStub).getCall(0).args[2].otherArgs.headers[ + 'x-goog-request-params' + ], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listMonitoredResourceDescriptors without error', async () => { + const client = new metricserviceModule.v3.MetricServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.monitoring.v3.ListMonitoredResourceDescriptorsRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedResponse = [ + generateSampleMessage( + new protos.google.api.MonitoredResourceDescriptor() + ), + generateSampleMessage( + new protos.google.api.MonitoredResourceDescriptor() + ), + generateSampleMessage( + new protos.google.api.MonitoredResourceDescriptor() + ), + ]; + client.descriptors.page.listMonitoredResourceDescriptors.asyncIterate = stubAsyncIterationCall( + expectedResponse + ); + const responses: protos.google.api.IMonitoredResourceDescriptor[] = []; + const iterable = client.listMonitoredResourceDescriptorsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listMonitoredResourceDescriptors + .asyncIterate as SinonStub).getCall(0).args[1], + request + ); + assert.strictEqual( + (client.descriptors.page.listMonitoredResourceDescriptors + .asyncIterate as SinonStub).getCall(0).args[2].otherArgs.headers[ + 'x-goog-request-params' + ], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listMonitoredResourceDescriptors with error', async () => { + const client = new metricserviceModule.v3.MetricServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.monitoring.v3.ListMonitoredResourceDescriptorsRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedError = new Error('expected'); + client.descriptors.page.listMonitoredResourceDescriptors.asyncIterate = stubAsyncIterationCall( + undefined, + expectedError + ); + const iterable = client.listMonitoredResourceDescriptorsAsync(request); + assert.rejects(async () => { + const responses: protos.google.api.IMonitoredResourceDescriptor[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listMonitoredResourceDescriptors + .asyncIterate as SinonStub).getCall(0).args[1], + request + ); + assert.strictEqual( + (client.descriptors.page.listMonitoredResourceDescriptors + .asyncIterate as SinonStub).getCall(0).args[2].otherArgs.headers[ + 'x-goog-request-params' + ], + expectedHeaderRequestParams + ); + }); + }); + + describe('listMetricDescriptors', () => { + it('invokes listMetricDescriptors without error', async () => { + const client = new metricserviceModule.v3.MetricServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.monitoring.v3.ListMetricDescriptorsRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage(new protos.google.api.MetricDescriptor()), + generateSampleMessage(new protos.google.api.MetricDescriptor()), + generateSampleMessage(new protos.google.api.MetricDescriptor()), + ]; + client.innerApiCalls.listMetricDescriptors = stubSimpleCall( + expectedResponse + ); + const [response] = await client.listMetricDescriptors(request); + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.listMetricDescriptors as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + + it('invokes listMetricDescriptors without error using callback', async () => { + const client = new metricserviceModule.v3.MetricServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.monitoring.v3.ListMetricDescriptorsRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage(new protos.google.api.MetricDescriptor()), + generateSampleMessage(new protos.google.api.MetricDescriptor()), + generateSampleMessage(new protos.google.api.MetricDescriptor()), + ]; + client.innerApiCalls.listMetricDescriptors = stubSimpleCallWithCallback( + expectedResponse + ); + const promise = new Promise((resolve, reject) => { + client.listMetricDescriptors( + request, + ( + err?: Error | null, + result?: protos.google.api.IMetricDescriptor[] | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.listMetricDescriptors as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions /*, callback defined above */) + ); + }); + + it('invokes listMetricDescriptors with error', async () => { + const client = new metricserviceModule.v3.MetricServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.monitoring.v3.ListMetricDescriptorsRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.listMetricDescriptors = stubSimpleCall( + undefined, + expectedError + ); + assert.rejects(async () => { + await client.listMetricDescriptors(request); + }, expectedError); + assert( + (client.innerApiCalls.listMetricDescriptors as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + + it('invokes listMetricDescriptorsStream without error', async () => { + const client = new metricserviceModule.v3.MetricServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.monitoring.v3.ListMetricDescriptorsRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedResponse = [ + generateSampleMessage(new protos.google.api.MetricDescriptor()), + generateSampleMessage(new protos.google.api.MetricDescriptor()), + generateSampleMessage(new protos.google.api.MetricDescriptor()), + ]; + client.descriptors.page.listMetricDescriptors.createStream = stubPageStreamingCall( + expectedResponse + ); + const stream = client.listMetricDescriptorsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.api.MetricDescriptor[] = []; + stream.on('data', (response: protos.google.api.MetricDescriptor) => { + 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.listMetricDescriptors + .createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listMetricDescriptors, request) + ); + assert.strictEqual( + (client.descriptors.page.listMetricDescriptors + .createStream as SinonStub).getCall(0).args[2].otherArgs.headers[ + 'x-goog-request-params' + ], + expectedHeaderRequestParams + ); + }); + + it('invokes listMetricDescriptorsStream with error', async () => { + const client = new metricserviceModule.v3.MetricServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.monitoring.v3.ListMetricDescriptorsRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedError = new Error('expected'); + client.descriptors.page.listMetricDescriptors.createStream = stubPageStreamingCall( + undefined, + expectedError + ); + const stream = client.listMetricDescriptorsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.api.MetricDescriptor[] = []; + stream.on('data', (response: protos.google.api.MetricDescriptor) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + assert.rejects(async () => { + await promise; + }, expectedError); + assert( + (client.descriptors.page.listMetricDescriptors + .createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listMetricDescriptors, request) + ); + assert.strictEqual( + (client.descriptors.page.listMetricDescriptors + .createStream as SinonStub).getCall(0).args[2].otherArgs.headers[ + 'x-goog-request-params' + ], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listMetricDescriptors without error', async () => { + const client = new metricserviceModule.v3.MetricServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.monitoring.v3.ListMetricDescriptorsRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedResponse = [ + generateSampleMessage(new protos.google.api.MetricDescriptor()), + generateSampleMessage(new protos.google.api.MetricDescriptor()), + generateSampleMessage(new protos.google.api.MetricDescriptor()), + ]; + client.descriptors.page.listMetricDescriptors.asyncIterate = stubAsyncIterationCall( + expectedResponse + ); + const responses: protos.google.api.IMetricDescriptor[] = []; + const iterable = client.listMetricDescriptorsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listMetricDescriptors + .asyncIterate as SinonStub).getCall(0).args[1], + request + ); + assert.strictEqual( + (client.descriptors.page.listMetricDescriptors + .asyncIterate as SinonStub).getCall(0).args[2].otherArgs.headers[ + 'x-goog-request-params' + ], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listMetricDescriptors with error', async () => { + const client = new metricserviceModule.v3.MetricServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.monitoring.v3.ListMetricDescriptorsRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedError = new Error('expected'); + client.descriptors.page.listMetricDescriptors.asyncIterate = stubAsyncIterationCall( + undefined, + expectedError + ); + const iterable = client.listMetricDescriptorsAsync(request); + assert.rejects(async () => { + const responses: protos.google.api.IMetricDescriptor[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listMetricDescriptors + .asyncIterate as SinonStub).getCall(0).args[1], + request + ); + assert.strictEqual( + (client.descriptors.page.listMetricDescriptors + .asyncIterate as SinonStub).getCall(0).args[2].otherArgs.headers[ + 'x-goog-request-params' + ], + expectedHeaderRequestParams + ); + }); + }); + + describe('listTimeSeries', () => { + it('invokes listTimeSeries without error', async () => { + const client = new metricserviceModule.v3.MetricServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.monitoring.v3.ListTimeSeriesRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage(new protos.google.monitoring.v3.TimeSeries()), + generateSampleMessage(new protos.google.monitoring.v3.TimeSeries()), + generateSampleMessage(new protos.google.monitoring.v3.TimeSeries()), + ]; + client.innerApiCalls.listTimeSeries = stubSimpleCall(expectedResponse); + const [response] = await client.listTimeSeries(request); + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.listTimeSeries as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + + it('invokes listTimeSeries without error using callback', async () => { + const client = new metricserviceModule.v3.MetricServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.monitoring.v3.ListTimeSeriesRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage(new protos.google.monitoring.v3.TimeSeries()), + generateSampleMessage(new protos.google.monitoring.v3.TimeSeries()), + generateSampleMessage(new protos.google.monitoring.v3.TimeSeries()), + ]; + client.innerApiCalls.listTimeSeries = stubSimpleCallWithCallback( + expectedResponse + ); + const promise = new Promise((resolve, reject) => { + client.listTimeSeries( + request, + ( + err?: Error | null, + result?: protos.google.monitoring.v3.ITimeSeries[] | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.listTimeSeries as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions /*, callback defined above */) + ); + }); + + it('invokes listTimeSeries with error', async () => { + const client = new metricserviceModule.v3.MetricServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.monitoring.v3.ListTimeSeriesRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.listTimeSeries = stubSimpleCall( + undefined, + expectedError + ); + assert.rejects(async () => { + await client.listTimeSeries(request); + }, expectedError); + assert( + (client.innerApiCalls.listTimeSeries as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + + it('invokes listTimeSeriesStream without error', async () => { + const client = new metricserviceModule.v3.MetricServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.monitoring.v3.ListTimeSeriesRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedResponse = [ + generateSampleMessage(new protos.google.monitoring.v3.TimeSeries()), + generateSampleMessage(new protos.google.monitoring.v3.TimeSeries()), + generateSampleMessage(new protos.google.monitoring.v3.TimeSeries()), + ]; + client.descriptors.page.listTimeSeries.createStream = stubPageStreamingCall( + expectedResponse + ); + const stream = client.listTimeSeriesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.monitoring.v3.TimeSeries[] = []; + stream.on( + 'data', + (response: protos.google.monitoring.v3.TimeSeries) => { + 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.listTimeSeries.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listTimeSeries, request) + ); + assert.strictEqual( + (client.descriptors.page.listTimeSeries + .createStream as SinonStub).getCall(0).args[2].otherArgs.headers[ + 'x-goog-request-params' + ], + expectedHeaderRequestParams + ); + }); + + it('invokes listTimeSeriesStream with error', async () => { + const client = new metricserviceModule.v3.MetricServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.monitoring.v3.ListTimeSeriesRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedError = new Error('expected'); + client.descriptors.page.listTimeSeries.createStream = stubPageStreamingCall( + undefined, + expectedError + ); + const stream = client.listTimeSeriesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.monitoring.v3.TimeSeries[] = []; + stream.on( + 'data', + (response: protos.google.monitoring.v3.TimeSeries) => { + responses.push(response); + } + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + assert.rejects(async () => { + await promise; + }, expectedError); + assert( + (client.descriptors.page.listTimeSeries.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listTimeSeries, request) + ); + assert.strictEqual( + (client.descriptors.page.listTimeSeries + .createStream as SinonStub).getCall(0).args[2].otherArgs.headers[ + 'x-goog-request-params' + ], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listTimeSeries without error', async () => { + const client = new metricserviceModule.v3.MetricServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.monitoring.v3.ListTimeSeriesRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedResponse = [ + generateSampleMessage(new protos.google.monitoring.v3.TimeSeries()), + generateSampleMessage(new protos.google.monitoring.v3.TimeSeries()), + generateSampleMessage(new protos.google.monitoring.v3.TimeSeries()), + ]; + client.descriptors.page.listTimeSeries.asyncIterate = stubAsyncIterationCall( + expectedResponse + ); + const responses: protos.google.monitoring.v3.ITimeSeries[] = []; + const iterable = client.listTimeSeriesAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listTimeSeries + .asyncIterate as SinonStub).getCall(0).args[1], + request + ); + assert.strictEqual( + (client.descriptors.page.listTimeSeries + .asyncIterate as SinonStub).getCall(0).args[2].otherArgs.headers[ + 'x-goog-request-params' + ], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listTimeSeries with error', async () => { + const client = new metricserviceModule.v3.MetricServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.monitoring.v3.ListTimeSeriesRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedError = new Error('expected'); + client.descriptors.page.listTimeSeries.asyncIterate = stubAsyncIterationCall( + undefined, + expectedError + ); + const iterable = client.listTimeSeriesAsync(request); + assert.rejects(async () => { + const responses: protos.google.monitoring.v3.ITimeSeries[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listTimeSeries + .asyncIterate as SinonStub).getCall(0).args[1], + request + ); + assert.strictEqual( + (client.descriptors.page.listTimeSeries + .asyncIterate as SinonStub).getCall(0).args[2].otherArgs.headers[ + 'x-goog-request-params' + ], + expectedHeaderRequestParams + ); + }); + }); + + describe('Path templates', () => { + describe('folderAlertPolicy', () => { + const fakePath = '/rendered/path/folderAlertPolicy'; + const expectedParameters = { + folder: 'folderValue', + alert_policy: 'alertPolicyValue', + }; + const client = new metricserviceModule.v3.MetricServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.folderAlertPolicyPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.folderAlertPolicyPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('folderAlertPolicyPath', () => { + const result = client.folderAlertPolicyPath( + 'folderValue', + 'alertPolicyValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.folderAlertPolicyPathTemplate + .render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchFolderFromFolderAlertPolicyName', () => { + const result = client.matchFolderFromFolderAlertPolicyName(fakePath); + assert.strictEqual(result, 'folderValue'); + assert( + (client.pathTemplates.folderAlertPolicyPathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchAlertPolicyFromFolderAlertPolicyName', () => { + const result = client.matchAlertPolicyFromFolderAlertPolicyName( + fakePath + ); + assert.strictEqual(result, 'alertPolicyValue'); + assert( + (client.pathTemplates.folderAlertPolicyPathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('folderAlertPolicyCondition', () => { + const fakePath = '/rendered/path/folderAlertPolicyCondition'; + const expectedParameters = { + folder: 'folderValue', + alert_policy: 'alertPolicyValue', + condition: 'conditionValue', + }; + const client = new metricserviceModule.v3.MetricServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.folderAlertPolicyConditionPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.folderAlertPolicyConditionPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('folderAlertPolicyConditionPath', () => { + const result = client.folderAlertPolicyConditionPath( + 'folderValue', + 'alertPolicyValue', + 'conditionValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.folderAlertPolicyConditionPathTemplate + .render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchFolderFromFolderAlertPolicyConditionName', () => { + const result = client.matchFolderFromFolderAlertPolicyConditionName( + fakePath + ); + assert.strictEqual(result, 'folderValue'); + assert( + (client.pathTemplates.folderAlertPolicyConditionPathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchAlertPolicyFromFolderAlertPolicyConditionName', () => { + const result = client.matchAlertPolicyFromFolderAlertPolicyConditionName( + fakePath + ); + assert.strictEqual(result, 'alertPolicyValue'); + assert( + (client.pathTemplates.folderAlertPolicyConditionPathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchConditionFromFolderAlertPolicyConditionName', () => { + const result = client.matchConditionFromFolderAlertPolicyConditionName( + fakePath + ); + assert.strictEqual(result, 'conditionValue'); + assert( + (client.pathTemplates.folderAlertPolicyConditionPathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('folderChannelDescriptor', () => { + const fakePath = '/rendered/path/folderChannelDescriptor'; + const expectedParameters = { + folder: 'folderValue', + channel_descriptor: 'channelDescriptorValue', + }; + const client = new metricserviceModule.v3.MetricServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.folderChannelDescriptorPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.folderChannelDescriptorPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('folderChannelDescriptorPath', () => { + const result = client.folderChannelDescriptorPath( + 'folderValue', + 'channelDescriptorValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.folderChannelDescriptorPathTemplate + .render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchFolderFromFolderChannelDescriptorName', () => { + const result = client.matchFolderFromFolderChannelDescriptorName( + fakePath + ); + assert.strictEqual(result, 'folderValue'); + assert( + (client.pathTemplates.folderChannelDescriptorPathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchChannelDescriptorFromFolderChannelDescriptorName', () => { + const result = client.matchChannelDescriptorFromFolderChannelDescriptorName( + fakePath + ); + assert.strictEqual(result, 'channelDescriptorValue'); + assert( + (client.pathTemplates.folderChannelDescriptorPathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('folderGroup', () => { + const fakePath = '/rendered/path/folderGroup'; + const expectedParameters = { + folder: 'folderValue', + group: 'groupValue', + }; + const client = new metricserviceModule.v3.MetricServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.folderGroupPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.folderGroupPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('folderGroupPath', () => { + const result = client.folderGroupPath('folderValue', 'groupValue'); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.folderGroupPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchFolderFromFolderGroupName', () => { + const result = client.matchFolderFromFolderGroupName(fakePath); + assert.strictEqual(result, 'folderValue'); + assert( + (client.pathTemplates.folderGroupPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchGroupFromFolderGroupName', () => { + const result = client.matchGroupFromFolderGroupName(fakePath); + assert.strictEqual(result, 'groupValue'); + assert( + (client.pathTemplates.folderGroupPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('folderMetricDescriptor', () => { + const fakePath = '/rendered/path/folderMetricDescriptor'; + const expectedParameters = { + folder: 'folderValue', + metric_descriptor: 'metricDescriptorValue', + }; + const client = new metricserviceModule.v3.MetricServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.folderMetricDescriptorPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.folderMetricDescriptorPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('folderMetricDescriptorPath', () => { + const result = client.folderMetricDescriptorPath( + 'folderValue', + 'metricDescriptorValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.folderMetricDescriptorPathTemplate + .render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchFolderFromFolderMetricDescriptorName', () => { + const result = client.matchFolderFromFolderMetricDescriptorName( + fakePath + ); + assert.strictEqual(result, 'folderValue'); + assert( + (client.pathTemplates.folderMetricDescriptorPathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchMetricDescriptorFromFolderMetricDescriptorName', () => { + const result = client.matchMetricDescriptorFromFolderMetricDescriptorName( + fakePath + ); + assert.strictEqual(result, 'metricDescriptorValue'); + assert( + (client.pathTemplates.folderMetricDescriptorPathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('folderMonitoredResourceDescriptor', () => { + const fakePath = '/rendered/path/folderMonitoredResourceDescriptor'; + const expectedParameters = { + folder: 'folderValue', + monitored_resource_descriptor: 'monitoredResourceDescriptorValue', + }; + const client = new metricserviceModule.v3.MetricServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.folderMonitoredResourceDescriptorPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.folderMonitoredResourceDescriptorPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('folderMonitoredResourceDescriptorPath', () => { + const result = client.folderMonitoredResourceDescriptorPath( + 'folderValue', + 'monitoredResourceDescriptorValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.folderMonitoredResourceDescriptorPathTemplate + .render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchFolderFromFolderMonitoredResourceDescriptorName', () => { + const result = client.matchFolderFromFolderMonitoredResourceDescriptorName( + fakePath + ); + assert.strictEqual(result, 'folderValue'); + assert( + (client.pathTemplates.folderMonitoredResourceDescriptorPathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchMonitoredResourceDescriptorFromFolderMonitoredResourceDescriptorName', () => { + const result = client.matchMonitoredResourceDescriptorFromFolderMonitoredResourceDescriptorName( + fakePath + ); + assert.strictEqual(result, 'monitoredResourceDescriptorValue'); + assert( + (client.pathTemplates.folderMonitoredResourceDescriptorPathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('folderNotificationChannel', () => { + const fakePath = '/rendered/path/folderNotificationChannel'; + const expectedParameters = { + folder: 'folderValue', + notification_channel: 'notificationChannelValue', + }; + const client = new metricserviceModule.v3.MetricServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.folderNotificationChannelPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.folderNotificationChannelPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('folderNotificationChannelPath', () => { + const result = client.folderNotificationChannelPath( + 'folderValue', + 'notificationChannelValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.folderNotificationChannelPathTemplate + .render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchFolderFromFolderNotificationChannelName', () => { + const result = client.matchFolderFromFolderNotificationChannelName( + fakePath + ); + assert.strictEqual(result, 'folderValue'); + assert( + (client.pathTemplates.folderNotificationChannelPathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchNotificationChannelFromFolderNotificationChannelName', () => { + const result = client.matchNotificationChannelFromFolderNotificationChannelName( + fakePath + ); + assert.strictEqual(result, 'notificationChannelValue'); + assert( + (client.pathTemplates.folderNotificationChannelPathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('folderService', () => { + const fakePath = '/rendered/path/folderService'; + const expectedParameters = { + folder: 'folderValue', + service: 'serviceValue', + }; + const client = new metricserviceModule.v3.MetricServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.folderServicePathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.folderServicePathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('folderServicePath', () => { + const result = client.folderServicePath('folderValue', 'serviceValue'); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.folderServicePathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchFolderFromFolderServiceName', () => { + const result = client.matchFolderFromFolderServiceName(fakePath); + assert.strictEqual(result, 'folderValue'); + assert( + (client.pathTemplates.folderServicePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchServiceFromFolderServiceName', () => { + const result = client.matchServiceFromFolderServiceName(fakePath); + assert.strictEqual(result, 'serviceValue'); + assert( + (client.pathTemplates.folderServicePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('folderServiceServiceLevelObjective', () => { + const fakePath = '/rendered/path/folderServiceServiceLevelObjective'; + const expectedParameters = { + folder: 'folderValue', + service: 'serviceValue', + service_level_objective: 'serviceLevelObjectiveValue', + }; + const client = new metricserviceModule.v3.MetricServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.folderServiceServiceLevelObjectivePathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.folderServiceServiceLevelObjectivePathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('folderServiceServiceLevelObjectivePath', () => { + const result = client.folderServiceServiceLevelObjectivePath( + 'folderValue', + 'serviceValue', + 'serviceLevelObjectiveValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.folderServiceServiceLevelObjectivePathTemplate + .render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchFolderFromFolderServiceServiceLevelObjectiveName', () => { + const result = client.matchFolderFromFolderServiceServiceLevelObjectiveName( + fakePath + ); + assert.strictEqual(result, 'folderValue'); + assert( + (client.pathTemplates.folderServiceServiceLevelObjectivePathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchServiceFromFolderServiceServiceLevelObjectiveName', () => { + const result = client.matchServiceFromFolderServiceServiceLevelObjectiveName( + fakePath + ); + assert.strictEqual(result, 'serviceValue'); + assert( + (client.pathTemplates.folderServiceServiceLevelObjectivePathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchServiceLevelObjectiveFromFolderServiceServiceLevelObjectiveName', () => { + const result = client.matchServiceLevelObjectiveFromFolderServiceServiceLevelObjectiveName( + fakePath + ); + assert.strictEqual(result, 'serviceLevelObjectiveValue'); + assert( + (client.pathTemplates.folderServiceServiceLevelObjectivePathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('folderUptimeCheckConfig', () => { + const fakePath = '/rendered/path/folderUptimeCheckConfig'; + const expectedParameters = { + folder: 'folderValue', + uptime_check_config: 'uptimeCheckConfigValue', + }; + const client = new metricserviceModule.v3.MetricServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.folderUptimeCheckConfigPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.folderUptimeCheckConfigPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('folderUptimeCheckConfigPath', () => { + const result = client.folderUptimeCheckConfigPath( + 'folderValue', + 'uptimeCheckConfigValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.folderUptimeCheckConfigPathTemplate + .render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchFolderFromFolderUptimeCheckConfigName', () => { + const result = client.matchFolderFromFolderUptimeCheckConfigName( + fakePath + ); + assert.strictEqual(result, 'folderValue'); + assert( + (client.pathTemplates.folderUptimeCheckConfigPathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchUptimeCheckConfigFromFolderUptimeCheckConfigName', () => { + const result = client.matchUptimeCheckConfigFromFolderUptimeCheckConfigName( + fakePath + ); + assert.strictEqual(result, 'uptimeCheckConfigValue'); + assert( + (client.pathTemplates.folderUptimeCheckConfigPathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('organizationAlertPolicy', () => { + const fakePath = '/rendered/path/organizationAlertPolicy'; + const expectedParameters = { + organization: 'organizationValue', + alert_policy: 'alertPolicyValue', + }; + const client = new metricserviceModule.v3.MetricServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.organizationAlertPolicyPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.organizationAlertPolicyPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('organizationAlertPolicyPath', () => { + const result = client.organizationAlertPolicyPath( + 'organizationValue', + 'alertPolicyValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.organizationAlertPolicyPathTemplate + .render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchOrganizationFromOrganizationAlertPolicyName', () => { + const result = client.matchOrganizationFromOrganizationAlertPolicyName( + fakePath + ); + assert.strictEqual(result, 'organizationValue'); + assert( + (client.pathTemplates.organizationAlertPolicyPathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchAlertPolicyFromOrganizationAlertPolicyName', () => { + const result = client.matchAlertPolicyFromOrganizationAlertPolicyName( + fakePath + ); + assert.strictEqual(result, 'alertPolicyValue'); + assert( + (client.pathTemplates.organizationAlertPolicyPathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('organizationAlertPolicyCondition', () => { + const fakePath = '/rendered/path/organizationAlertPolicyCondition'; + const expectedParameters = { + organization: 'organizationValue', + alert_policy: 'alertPolicyValue', + condition: 'conditionValue', + }; + const client = new metricserviceModule.v3.MetricServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.organizationAlertPolicyConditionPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.organizationAlertPolicyConditionPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('organizationAlertPolicyConditionPath', () => { + const result = client.organizationAlertPolicyConditionPath( + 'organizationValue', + 'alertPolicyValue', + 'conditionValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.organizationAlertPolicyConditionPathTemplate + .render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchOrganizationFromOrganizationAlertPolicyConditionName', () => { + const result = client.matchOrganizationFromOrganizationAlertPolicyConditionName( + fakePath + ); + assert.strictEqual(result, 'organizationValue'); + assert( + (client.pathTemplates.organizationAlertPolicyConditionPathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchAlertPolicyFromOrganizationAlertPolicyConditionName', () => { + const result = client.matchAlertPolicyFromOrganizationAlertPolicyConditionName( + fakePath + ); + assert.strictEqual(result, 'alertPolicyValue'); + assert( + (client.pathTemplates.organizationAlertPolicyConditionPathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchConditionFromOrganizationAlertPolicyConditionName', () => { + const result = client.matchConditionFromOrganizationAlertPolicyConditionName( + fakePath + ); + assert.strictEqual(result, 'conditionValue'); + assert( + (client.pathTemplates.organizationAlertPolicyConditionPathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('organizationChannelDescriptor', () => { + const fakePath = '/rendered/path/organizationChannelDescriptor'; + const expectedParameters = { + organization: 'organizationValue', + channel_descriptor: 'channelDescriptorValue', + }; + const client = new metricserviceModule.v3.MetricServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.organizationChannelDescriptorPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.organizationChannelDescriptorPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('organizationChannelDescriptorPath', () => { + const result = client.organizationChannelDescriptorPath( + 'organizationValue', + 'channelDescriptorValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.organizationChannelDescriptorPathTemplate + .render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchOrganizationFromOrganizationChannelDescriptorName', () => { + const result = client.matchOrganizationFromOrganizationChannelDescriptorName( + fakePath + ); + assert.strictEqual(result, 'organizationValue'); + assert( + (client.pathTemplates.organizationChannelDescriptorPathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchChannelDescriptorFromOrganizationChannelDescriptorName', () => { + const result = client.matchChannelDescriptorFromOrganizationChannelDescriptorName( + fakePath + ); + assert.strictEqual(result, 'channelDescriptorValue'); + assert( + (client.pathTemplates.organizationChannelDescriptorPathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('organizationGroup', () => { + const fakePath = '/rendered/path/organizationGroup'; + const expectedParameters = { + organization: 'organizationValue', + group: 'groupValue', + }; + const client = new metricserviceModule.v3.MetricServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.organizationGroupPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.organizationGroupPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('organizationGroupPath', () => { + const result = client.organizationGroupPath( + 'organizationValue', + 'groupValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.organizationGroupPathTemplate + .render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchOrganizationFromOrganizationGroupName', () => { + const result = client.matchOrganizationFromOrganizationGroupName( + fakePath + ); + assert.strictEqual(result, 'organizationValue'); + assert( + (client.pathTemplates.organizationGroupPathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchGroupFromOrganizationGroupName', () => { + const result = client.matchGroupFromOrganizationGroupName(fakePath); + assert.strictEqual(result, 'groupValue'); + assert( + (client.pathTemplates.organizationGroupPathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('organizationMetricDescriptor', () => { + const fakePath = '/rendered/path/organizationMetricDescriptor'; + const expectedParameters = { + organization: 'organizationValue', + metric_descriptor: 'metricDescriptorValue', + }; + const client = new metricserviceModule.v3.MetricServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.organizationMetricDescriptorPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.organizationMetricDescriptorPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('organizationMetricDescriptorPath', () => { + const result = client.organizationMetricDescriptorPath( + 'organizationValue', + 'metricDescriptorValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.organizationMetricDescriptorPathTemplate + .render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchOrganizationFromOrganizationMetricDescriptorName', () => { + const result = client.matchOrganizationFromOrganizationMetricDescriptorName( + fakePath + ); + assert.strictEqual(result, 'organizationValue'); + assert( + (client.pathTemplates.organizationMetricDescriptorPathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchMetricDescriptorFromOrganizationMetricDescriptorName', () => { + const result = client.matchMetricDescriptorFromOrganizationMetricDescriptorName( + fakePath + ); + assert.strictEqual(result, 'metricDescriptorValue'); + assert( + (client.pathTemplates.organizationMetricDescriptorPathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('organizationMonitoredResourceDescriptor', () => { + const fakePath = '/rendered/path/organizationMonitoredResourceDescriptor'; + const expectedParameters = { + organization: 'organizationValue', + monitored_resource_descriptor: 'monitoredResourceDescriptorValue', + }; + const client = new metricserviceModule.v3.MetricServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.organizationMonitoredResourceDescriptorPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.organizationMonitoredResourceDescriptorPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('organizationMonitoredResourceDescriptorPath', () => { + const result = client.organizationMonitoredResourceDescriptorPath( + 'organizationValue', + 'monitoredResourceDescriptorValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates + .organizationMonitoredResourceDescriptorPathTemplate + .render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchOrganizationFromOrganizationMonitoredResourceDescriptorName', () => { + const result = client.matchOrganizationFromOrganizationMonitoredResourceDescriptorName( + fakePath + ); + assert.strictEqual(result, 'organizationValue'); + assert( + (client.pathTemplates + .organizationMonitoredResourceDescriptorPathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchMonitoredResourceDescriptorFromOrganizationMonitoredResourceDescriptorName', () => { + const result = client.matchMonitoredResourceDescriptorFromOrganizationMonitoredResourceDescriptorName( + fakePath + ); + assert.strictEqual(result, 'monitoredResourceDescriptorValue'); + assert( + (client.pathTemplates + .organizationMonitoredResourceDescriptorPathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('organizationNotificationChannel', () => { + const fakePath = '/rendered/path/organizationNotificationChannel'; + const expectedParameters = { + organization: 'organizationValue', + notification_channel: 'notificationChannelValue', + }; + const client = new metricserviceModule.v3.MetricServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.organizationNotificationChannelPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.organizationNotificationChannelPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('organizationNotificationChannelPath', () => { + const result = client.organizationNotificationChannelPath( + 'organizationValue', + 'notificationChannelValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.organizationNotificationChannelPathTemplate + .render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchOrganizationFromOrganizationNotificationChannelName', () => { + const result = client.matchOrganizationFromOrganizationNotificationChannelName( + fakePath + ); + assert.strictEqual(result, 'organizationValue'); + assert( + (client.pathTemplates.organizationNotificationChannelPathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchNotificationChannelFromOrganizationNotificationChannelName', () => { + const result = client.matchNotificationChannelFromOrganizationNotificationChannelName( + fakePath + ); + assert.strictEqual(result, 'notificationChannelValue'); + assert( + (client.pathTemplates.organizationNotificationChannelPathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('organizationService', () => { + const fakePath = '/rendered/path/organizationService'; + const expectedParameters = { + organization: 'organizationValue', + service: 'serviceValue', + }; + const client = new metricserviceModule.v3.MetricServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.organizationServicePathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.organizationServicePathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('organizationServicePath', () => { + const result = client.organizationServicePath( + 'organizationValue', + 'serviceValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.organizationServicePathTemplate + .render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchOrganizationFromOrganizationServiceName', () => { + const result = client.matchOrganizationFromOrganizationServiceName( + fakePath + ); + assert.strictEqual(result, 'organizationValue'); + assert( + (client.pathTemplates.organizationServicePathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchServiceFromOrganizationServiceName', () => { + const result = client.matchServiceFromOrganizationServiceName(fakePath); + assert.strictEqual(result, 'serviceValue'); + assert( + (client.pathTemplates.organizationServicePathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('organizationServiceServiceLevelObjective', () => { + const fakePath = + '/rendered/path/organizationServiceServiceLevelObjective'; + const expectedParameters = { + organization: 'organizationValue', + service: 'serviceValue', + service_level_objective: 'serviceLevelObjectiveValue', + }; + const client = new metricserviceModule.v3.MetricServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.organizationServiceServiceLevelObjectivePathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.organizationServiceServiceLevelObjectivePathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('organizationServiceServiceLevelObjectivePath', () => { + const result = client.organizationServiceServiceLevelObjectivePath( + 'organizationValue', + 'serviceValue', + 'serviceLevelObjectiveValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates + .organizationServiceServiceLevelObjectivePathTemplate + .render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchOrganizationFromOrganizationServiceServiceLevelObjectiveName', () => { + const result = client.matchOrganizationFromOrganizationServiceServiceLevelObjectiveName( + fakePath + ); + assert.strictEqual(result, 'organizationValue'); + assert( + (client.pathTemplates + .organizationServiceServiceLevelObjectivePathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchServiceFromOrganizationServiceServiceLevelObjectiveName', () => { + const result = client.matchServiceFromOrganizationServiceServiceLevelObjectiveName( + fakePath + ); + assert.strictEqual(result, 'serviceValue'); + assert( + (client.pathTemplates + .organizationServiceServiceLevelObjectivePathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchServiceLevelObjectiveFromOrganizationServiceServiceLevelObjectiveName', () => { + const result = client.matchServiceLevelObjectiveFromOrganizationServiceServiceLevelObjectiveName( + fakePath + ); + assert.strictEqual(result, 'serviceLevelObjectiveValue'); + assert( + (client.pathTemplates + .organizationServiceServiceLevelObjectivePathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('organizationUptimeCheckConfig', () => { + const fakePath = '/rendered/path/organizationUptimeCheckConfig'; + const expectedParameters = { + organization: 'organizationValue', + uptime_check_config: 'uptimeCheckConfigValue', + }; + const client = new metricserviceModule.v3.MetricServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.organizationUptimeCheckConfigPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.organizationUptimeCheckConfigPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('organizationUptimeCheckConfigPath', () => { + const result = client.organizationUptimeCheckConfigPath( + 'organizationValue', + 'uptimeCheckConfigValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.organizationUptimeCheckConfigPathTemplate + .render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchOrganizationFromOrganizationUptimeCheckConfigName', () => { + const result = client.matchOrganizationFromOrganizationUptimeCheckConfigName( + fakePath + ); + assert.strictEqual(result, 'organizationValue'); + assert( + (client.pathTemplates.organizationUptimeCheckConfigPathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchUptimeCheckConfigFromOrganizationUptimeCheckConfigName', () => { + const result = client.matchUptimeCheckConfigFromOrganizationUptimeCheckConfigName( + fakePath + ); + assert.strictEqual(result, 'uptimeCheckConfigValue'); + assert( + (client.pathTemplates.organizationUptimeCheckConfigPathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('project', () => { + const fakePath = '/rendered/path/project'; + const expectedParameters = { + project: 'projectValue', + }; + const client = new metricserviceModule.v3.MetricServiceClient({ + 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('matchProjectFromProjectName', () => { + const result = client.matchProjectFromProjectName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.projectPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('projectAlertPolicy', () => { + const fakePath = '/rendered/path/projectAlertPolicy'; + const expectedParameters = { + project: 'projectValue', + alert_policy: 'alertPolicyValue', + }; + const client = new metricserviceModule.v3.MetricServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.projectAlertPolicyPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.projectAlertPolicyPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('projectAlertPolicyPath', () => { + const result = client.projectAlertPolicyPath( + 'projectValue', + 'alertPolicyValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.projectAlertPolicyPathTemplate + .render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromProjectAlertPolicyName', () => { + const result = client.matchProjectFromProjectAlertPolicyName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.projectAlertPolicyPathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchAlertPolicyFromProjectAlertPolicyName', () => { + const result = client.matchAlertPolicyFromProjectAlertPolicyName( + fakePath + ); + assert.strictEqual(result, 'alertPolicyValue'); + assert( + (client.pathTemplates.projectAlertPolicyPathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('projectAlertPolicyCondition', () => { + const fakePath = '/rendered/path/projectAlertPolicyCondition'; + const expectedParameters = { + project: 'projectValue', + alert_policy: 'alertPolicyValue', + condition: 'conditionValue', + }; + const client = new metricserviceModule.v3.MetricServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.projectAlertPolicyConditionPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.projectAlertPolicyConditionPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('projectAlertPolicyConditionPath', () => { + const result = client.projectAlertPolicyConditionPath( + 'projectValue', + 'alertPolicyValue', + 'conditionValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.projectAlertPolicyConditionPathTemplate + .render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromProjectAlertPolicyConditionName', () => { + const result = client.matchProjectFromProjectAlertPolicyConditionName( + fakePath + ); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.projectAlertPolicyConditionPathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchAlertPolicyFromProjectAlertPolicyConditionName', () => { + const result = client.matchAlertPolicyFromProjectAlertPolicyConditionName( + fakePath + ); + assert.strictEqual(result, 'alertPolicyValue'); + assert( + (client.pathTemplates.projectAlertPolicyConditionPathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchConditionFromProjectAlertPolicyConditionName', () => { + const result = client.matchConditionFromProjectAlertPolicyConditionName( + fakePath + ); + assert.strictEqual(result, 'conditionValue'); + assert( + (client.pathTemplates.projectAlertPolicyConditionPathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('projectChannelDescriptor', () => { + const fakePath = '/rendered/path/projectChannelDescriptor'; + const expectedParameters = { + project: 'projectValue', + channel_descriptor: 'channelDescriptorValue', + }; + const client = new metricserviceModule.v3.MetricServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.projectChannelDescriptorPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.projectChannelDescriptorPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('projectChannelDescriptorPath', () => { + const result = client.projectChannelDescriptorPath( + 'projectValue', + 'channelDescriptorValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.projectChannelDescriptorPathTemplate + .render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromProjectChannelDescriptorName', () => { + const result = client.matchProjectFromProjectChannelDescriptorName( + fakePath + ); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.projectChannelDescriptorPathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchChannelDescriptorFromProjectChannelDescriptorName', () => { + const result = client.matchChannelDescriptorFromProjectChannelDescriptorName( + fakePath + ); + assert.strictEqual(result, 'channelDescriptorValue'); + assert( + (client.pathTemplates.projectChannelDescriptorPathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('projectGroup', () => { + const fakePath = '/rendered/path/projectGroup'; + const expectedParameters = { + project: 'projectValue', + group: 'groupValue', + }; + const client = new metricserviceModule.v3.MetricServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.projectGroupPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.projectGroupPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('projectGroupPath', () => { + const result = client.projectGroupPath('projectValue', 'groupValue'); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.projectGroupPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromProjectGroupName', () => { + const result = client.matchProjectFromProjectGroupName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.projectGroupPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchGroupFromProjectGroupName', () => { + const result = client.matchGroupFromProjectGroupName(fakePath); + assert.strictEqual(result, 'groupValue'); + assert( + (client.pathTemplates.projectGroupPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('projectMetricDescriptor', () => { + const fakePath = '/rendered/path/projectMetricDescriptor'; + const expectedParameters = { + project: 'projectValue', + metric_descriptor: 'metricDescriptorValue', + }; + const client = new metricserviceModule.v3.MetricServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.projectMetricDescriptorPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.projectMetricDescriptorPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('projectMetricDescriptorPath', () => { + const result = client.projectMetricDescriptorPath( + 'projectValue', + 'metricDescriptorValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.projectMetricDescriptorPathTemplate + .render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromProjectMetricDescriptorName', () => { + const result = client.matchProjectFromProjectMetricDescriptorName( + fakePath + ); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.projectMetricDescriptorPathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchMetricDescriptorFromProjectMetricDescriptorName', () => { + const result = client.matchMetricDescriptorFromProjectMetricDescriptorName( + fakePath + ); + assert.strictEqual(result, 'metricDescriptorValue'); + assert( + (client.pathTemplates.projectMetricDescriptorPathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('projectMonitoredResourceDescriptor', () => { + const fakePath = '/rendered/path/projectMonitoredResourceDescriptor'; + const expectedParameters = { + project: 'projectValue', + monitored_resource_descriptor: 'monitoredResourceDescriptorValue', + }; + const client = new metricserviceModule.v3.MetricServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.projectMonitoredResourceDescriptorPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.projectMonitoredResourceDescriptorPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('projectMonitoredResourceDescriptorPath', () => { + const result = client.projectMonitoredResourceDescriptorPath( + 'projectValue', + 'monitoredResourceDescriptorValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.projectMonitoredResourceDescriptorPathTemplate + .render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromProjectMonitoredResourceDescriptorName', () => { + const result = client.matchProjectFromProjectMonitoredResourceDescriptorName( + fakePath + ); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.projectMonitoredResourceDescriptorPathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchMonitoredResourceDescriptorFromProjectMonitoredResourceDescriptorName', () => { + const result = client.matchMonitoredResourceDescriptorFromProjectMonitoredResourceDescriptorName( + fakePath + ); + assert.strictEqual(result, 'monitoredResourceDescriptorValue'); + assert( + (client.pathTemplates.projectMonitoredResourceDescriptorPathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('projectNotificationChannel', () => { + const fakePath = '/rendered/path/projectNotificationChannel'; + const expectedParameters = { + project: 'projectValue', + notification_channel: 'notificationChannelValue', + }; + const client = new metricserviceModule.v3.MetricServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.projectNotificationChannelPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.projectNotificationChannelPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('projectNotificationChannelPath', () => { + const result = client.projectNotificationChannelPath( + 'projectValue', + 'notificationChannelValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.projectNotificationChannelPathTemplate + .render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromProjectNotificationChannelName', () => { + const result = client.matchProjectFromProjectNotificationChannelName( + fakePath + ); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.projectNotificationChannelPathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchNotificationChannelFromProjectNotificationChannelName', () => { + const result = client.matchNotificationChannelFromProjectNotificationChannelName( + fakePath + ); + assert.strictEqual(result, 'notificationChannelValue'); + assert( + (client.pathTemplates.projectNotificationChannelPathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('projectService', () => { + const fakePath = '/rendered/path/projectService'; + const expectedParameters = { + project: 'projectValue', + service: 'serviceValue', + }; + const client = new metricserviceModule.v3.MetricServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.projectServicePathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.projectServicePathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('projectServicePath', () => { + const result = client.projectServicePath( + 'projectValue', + 'serviceValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.projectServicePathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromProjectServiceName', () => { + const result = client.matchProjectFromProjectServiceName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.projectServicePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchServiceFromProjectServiceName', () => { + const result = client.matchServiceFromProjectServiceName(fakePath); + assert.strictEqual(result, 'serviceValue'); + assert( + (client.pathTemplates.projectServicePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('projectServiceServiceLevelObjective', () => { + const fakePath = '/rendered/path/projectServiceServiceLevelObjective'; + const expectedParameters = { + project: 'projectValue', + service: 'serviceValue', + service_level_objective: 'serviceLevelObjectiveValue', + }; + const client = new metricserviceModule.v3.MetricServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.projectServiceServiceLevelObjectivePathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.projectServiceServiceLevelObjectivePathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('projectServiceServiceLevelObjectivePath', () => { + const result = client.projectServiceServiceLevelObjectivePath( + 'projectValue', + 'serviceValue', + 'serviceLevelObjectiveValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.projectServiceServiceLevelObjectivePathTemplate + .render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromProjectServiceServiceLevelObjectiveName', () => { + const result = client.matchProjectFromProjectServiceServiceLevelObjectiveName( + fakePath + ); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.projectServiceServiceLevelObjectivePathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchServiceFromProjectServiceServiceLevelObjectiveName', () => { + const result = client.matchServiceFromProjectServiceServiceLevelObjectiveName( + fakePath + ); + assert.strictEqual(result, 'serviceValue'); + assert( + (client.pathTemplates.projectServiceServiceLevelObjectivePathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchServiceLevelObjectiveFromProjectServiceServiceLevelObjectiveName', () => { + const result = client.matchServiceLevelObjectiveFromProjectServiceServiceLevelObjectiveName( + fakePath + ); + assert.strictEqual(result, 'serviceLevelObjectiveValue'); + assert( + (client.pathTemplates.projectServiceServiceLevelObjectivePathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('projectUptimeCheckConfig', () => { + const fakePath = '/rendered/path/projectUptimeCheckConfig'; + const expectedParameters = { + project: 'projectValue', + uptime_check_config: 'uptimeCheckConfigValue', + }; + const client = new metricserviceModule.v3.MetricServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.projectUptimeCheckConfigPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.projectUptimeCheckConfigPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('projectUptimeCheckConfigPath', () => { + const result = client.projectUptimeCheckConfigPath( + 'projectValue', + 'uptimeCheckConfigValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.projectUptimeCheckConfigPathTemplate + .render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromProjectUptimeCheckConfigName', () => { + const result = client.matchProjectFromProjectUptimeCheckConfigName( + fakePath + ); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.projectUptimeCheckConfigPathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchUptimeCheckConfigFromProjectUptimeCheckConfigName', () => { + const result = client.matchUptimeCheckConfigFromProjectUptimeCheckConfigName( + fakePath + ); + assert.strictEqual(result, 'uptimeCheckConfigValue'); + assert( + (client.pathTemplates.projectUptimeCheckConfigPathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + }); +}); diff --git a/packages/google-cloud-monitoring/test/gapic_notification_channel_service_v3.ts b/packages/google-cloud-monitoring/test/gapic_notification_channel_service_v3.ts new file mode 100644 index 00000000000..863d9437538 --- /dev/null +++ b/packages/google-cloud-monitoring/test/gapic_notification_channel_service_v3.ts @@ -0,0 +1,3442 @@ +// Copyright 2020 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +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 * as notificationchannelserviceModule from '../src'; + +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; +} + +function stubSimpleCall(response?: ResponseType, error?: Error) { + 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 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(); + }); + } + 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); +} + +describe('v3.NotificationChannelServiceClient', () => { + it('has servicePath', () => { + const servicePath = + notificationchannelserviceModule.v3.NotificationChannelServiceClient + .servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = + notificationchannelserviceModule.v3.NotificationChannelServiceClient + .apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = + notificationchannelserviceModule.v3.NotificationChannelServiceClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new notificationchannelserviceModule.v3.NotificationChannelServiceClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new notificationchannelserviceModule.v3.NotificationChannelServiceClient( + { + fallback: true, + } + ); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new notificationchannelserviceModule.v3.NotificationChannelServiceClient( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + assert.strictEqual(client.notificationChannelServiceStub, undefined); + await client.initialize(); + assert(client.notificationChannelServiceStub); + }); + + it('has close method', () => { + const client = new notificationchannelserviceModule.v3.NotificationChannelServiceClient( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.close(); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new notificationchannelserviceModule.v3.NotificationChannelServiceClient( + { + 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 notificationchannelserviceModule.v3.NotificationChannelServiceClient( + { + 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('getNotificationChannelDescriptor', () => { + it('invokes getNotificationChannelDescriptor without error', async () => { + const client = new notificationchannelserviceModule.v3.NotificationChannelServiceClient( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + const request = generateSampleMessage( + new protos.google.monitoring.v3.GetNotificationChannelDescriptorRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.monitoring.v3.NotificationChannelDescriptor() + ); + client.innerApiCalls.getNotificationChannelDescriptor = stubSimpleCall( + expectedResponse + ); + const [response] = await client.getNotificationChannelDescriptor(request); + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.getNotificationChannelDescriptor as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + + it('invokes getNotificationChannelDescriptor without error using callback', async () => { + const client = new notificationchannelserviceModule.v3.NotificationChannelServiceClient( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + const request = generateSampleMessage( + new protos.google.monitoring.v3.GetNotificationChannelDescriptorRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.monitoring.v3.NotificationChannelDescriptor() + ); + client.innerApiCalls.getNotificationChannelDescriptor = stubSimpleCallWithCallback( + expectedResponse + ); + const promise = new Promise((resolve, reject) => { + client.getNotificationChannelDescriptor( + request, + ( + err?: Error | null, + result?: protos.google.monitoring.v3.INotificationChannelDescriptor | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.getNotificationChannelDescriptor as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions /*, callback defined above */) + ); + }); + + it('invokes getNotificationChannelDescriptor with error', async () => { + const client = new notificationchannelserviceModule.v3.NotificationChannelServiceClient( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + const request = generateSampleMessage( + new protos.google.monitoring.v3.GetNotificationChannelDescriptorRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.getNotificationChannelDescriptor = stubSimpleCall( + undefined, + expectedError + ); + assert.rejects(async () => { + await client.getNotificationChannelDescriptor(request); + }, expectedError); + assert( + (client.innerApiCalls.getNotificationChannelDescriptor as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + }); + + describe('getNotificationChannel', () => { + it('invokes getNotificationChannel without error', async () => { + const client = new notificationchannelserviceModule.v3.NotificationChannelServiceClient( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + const request = generateSampleMessage( + new protos.google.monitoring.v3.GetNotificationChannelRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.monitoring.v3.NotificationChannel() + ); + client.innerApiCalls.getNotificationChannel = stubSimpleCall( + expectedResponse + ); + const [response] = await client.getNotificationChannel(request); + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.getNotificationChannel as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + + it('invokes getNotificationChannel without error using callback', async () => { + const client = new notificationchannelserviceModule.v3.NotificationChannelServiceClient( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + const request = generateSampleMessage( + new protos.google.monitoring.v3.GetNotificationChannelRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.monitoring.v3.NotificationChannel() + ); + client.innerApiCalls.getNotificationChannel = stubSimpleCallWithCallback( + expectedResponse + ); + const promise = new Promise((resolve, reject) => { + client.getNotificationChannel( + request, + ( + err?: Error | null, + result?: protos.google.monitoring.v3.INotificationChannel | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.getNotificationChannel as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions /*, callback defined above */) + ); + }); + + it('invokes getNotificationChannel with error', async () => { + const client = new notificationchannelserviceModule.v3.NotificationChannelServiceClient( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + const request = generateSampleMessage( + new protos.google.monitoring.v3.GetNotificationChannelRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.getNotificationChannel = stubSimpleCall( + undefined, + expectedError + ); + assert.rejects(async () => { + await client.getNotificationChannel(request); + }, expectedError); + assert( + (client.innerApiCalls.getNotificationChannel as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + }); + + describe('createNotificationChannel', () => { + it('invokes createNotificationChannel without error', async () => { + const client = new notificationchannelserviceModule.v3.NotificationChannelServiceClient( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + const request = generateSampleMessage( + new protos.google.monitoring.v3.CreateNotificationChannelRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.monitoring.v3.NotificationChannel() + ); + client.innerApiCalls.createNotificationChannel = stubSimpleCall( + expectedResponse + ); + const [response] = await client.createNotificationChannel(request); + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.createNotificationChannel as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + + it('invokes createNotificationChannel without error using callback', async () => { + const client = new notificationchannelserviceModule.v3.NotificationChannelServiceClient( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + const request = generateSampleMessage( + new protos.google.monitoring.v3.CreateNotificationChannelRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.monitoring.v3.NotificationChannel() + ); + client.innerApiCalls.createNotificationChannel = stubSimpleCallWithCallback( + expectedResponse + ); + const promise = new Promise((resolve, reject) => { + client.createNotificationChannel( + request, + ( + err?: Error | null, + result?: protos.google.monitoring.v3.INotificationChannel | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.createNotificationChannel as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions /*, callback defined above */) + ); + }); + + it('invokes createNotificationChannel with error', async () => { + const client = new notificationchannelserviceModule.v3.NotificationChannelServiceClient( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + const request = generateSampleMessage( + new protos.google.monitoring.v3.CreateNotificationChannelRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.createNotificationChannel = stubSimpleCall( + undefined, + expectedError + ); + assert.rejects(async () => { + await client.createNotificationChannel(request); + }, expectedError); + assert( + (client.innerApiCalls.createNotificationChannel as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + }); + + describe('updateNotificationChannel', () => { + it('invokes updateNotificationChannel without error', async () => { + const client = new notificationchannelserviceModule.v3.NotificationChannelServiceClient( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + const request = generateSampleMessage( + new protos.google.monitoring.v3.UpdateNotificationChannelRequest() + ); + request.notificationChannel = {}; + request.notificationChannel.name = ''; + const expectedHeaderRequestParams = 'notification_channel.name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.monitoring.v3.NotificationChannel() + ); + client.innerApiCalls.updateNotificationChannel = stubSimpleCall( + expectedResponse + ); + const [response] = await client.updateNotificationChannel(request); + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.updateNotificationChannel as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + + it('invokes updateNotificationChannel without error using callback', async () => { + const client = new notificationchannelserviceModule.v3.NotificationChannelServiceClient( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + const request = generateSampleMessage( + new protos.google.monitoring.v3.UpdateNotificationChannelRequest() + ); + request.notificationChannel = {}; + request.notificationChannel.name = ''; + const expectedHeaderRequestParams = 'notification_channel.name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.monitoring.v3.NotificationChannel() + ); + client.innerApiCalls.updateNotificationChannel = stubSimpleCallWithCallback( + expectedResponse + ); + const promise = new Promise((resolve, reject) => { + client.updateNotificationChannel( + request, + ( + err?: Error | null, + result?: protos.google.monitoring.v3.INotificationChannel | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.updateNotificationChannel as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions /*, callback defined above */) + ); + }); + + it('invokes updateNotificationChannel with error', async () => { + const client = new notificationchannelserviceModule.v3.NotificationChannelServiceClient( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + const request = generateSampleMessage( + new protos.google.monitoring.v3.UpdateNotificationChannelRequest() + ); + request.notificationChannel = {}; + request.notificationChannel.name = ''; + const expectedHeaderRequestParams = 'notification_channel.name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.updateNotificationChannel = stubSimpleCall( + undefined, + expectedError + ); + assert.rejects(async () => { + await client.updateNotificationChannel(request); + }, expectedError); + assert( + (client.innerApiCalls.updateNotificationChannel as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + }); + + describe('deleteNotificationChannel', () => { + it('invokes deleteNotificationChannel without error', async () => { + const client = new notificationchannelserviceModule.v3.NotificationChannelServiceClient( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + const request = generateSampleMessage( + new protos.google.monitoring.v3.DeleteNotificationChannelRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.deleteNotificationChannel = stubSimpleCall( + expectedResponse + ); + const [response] = await client.deleteNotificationChannel(request); + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.deleteNotificationChannel as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + + it('invokes deleteNotificationChannel without error using callback', async () => { + const client = new notificationchannelserviceModule.v3.NotificationChannelServiceClient( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + const request = generateSampleMessage( + new protos.google.monitoring.v3.DeleteNotificationChannelRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.deleteNotificationChannel = stubSimpleCallWithCallback( + expectedResponse + ); + const promise = new Promise((resolve, reject) => { + client.deleteNotificationChannel( + 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.deleteNotificationChannel as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions /*, callback defined above */) + ); + }); + + it('invokes deleteNotificationChannel with error', async () => { + const client = new notificationchannelserviceModule.v3.NotificationChannelServiceClient( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + const request = generateSampleMessage( + new protos.google.monitoring.v3.DeleteNotificationChannelRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteNotificationChannel = stubSimpleCall( + undefined, + expectedError + ); + assert.rejects(async () => { + await client.deleteNotificationChannel(request); + }, expectedError); + assert( + (client.innerApiCalls.deleteNotificationChannel as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + }); + + describe('sendNotificationChannelVerificationCode', () => { + it('invokes sendNotificationChannelVerificationCode without error', async () => { + const client = new notificationchannelserviceModule.v3.NotificationChannelServiceClient( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + const request = generateSampleMessage( + new protos.google.monitoring.v3.SendNotificationChannelVerificationCodeRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.sendNotificationChannelVerificationCode = stubSimpleCall( + expectedResponse + ); + const [response] = await client.sendNotificationChannelVerificationCode( + request + ); + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls + .sendNotificationChannelVerificationCode as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + + it('invokes sendNotificationChannelVerificationCode without error using callback', async () => { + const client = new notificationchannelserviceModule.v3.NotificationChannelServiceClient( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + const request = generateSampleMessage( + new protos.google.monitoring.v3.SendNotificationChannelVerificationCodeRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.sendNotificationChannelVerificationCode = stubSimpleCallWithCallback( + expectedResponse + ); + const promise = new Promise((resolve, reject) => { + client.sendNotificationChannelVerificationCode( + 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 + .sendNotificationChannelVerificationCode as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions /*, callback defined above */) + ); + }); + + it('invokes sendNotificationChannelVerificationCode with error', async () => { + const client = new notificationchannelserviceModule.v3.NotificationChannelServiceClient( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + const request = generateSampleMessage( + new protos.google.monitoring.v3.SendNotificationChannelVerificationCodeRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.sendNotificationChannelVerificationCode = stubSimpleCall( + undefined, + expectedError + ); + assert.rejects(async () => { + await client.sendNotificationChannelVerificationCode(request); + }, expectedError); + assert( + (client.innerApiCalls + .sendNotificationChannelVerificationCode as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + }); + + describe('getNotificationChannelVerificationCode', () => { + it('invokes getNotificationChannelVerificationCode without error', async () => { + const client = new notificationchannelserviceModule.v3.NotificationChannelServiceClient( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + const request = generateSampleMessage( + new protos.google.monitoring.v3.GetNotificationChannelVerificationCodeRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.monitoring.v3.GetNotificationChannelVerificationCodeResponse() + ); + client.innerApiCalls.getNotificationChannelVerificationCode = stubSimpleCall( + expectedResponse + ); + const [response] = await client.getNotificationChannelVerificationCode( + request + ); + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls + .getNotificationChannelVerificationCode as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + + it('invokes getNotificationChannelVerificationCode without error using callback', async () => { + const client = new notificationchannelserviceModule.v3.NotificationChannelServiceClient( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + const request = generateSampleMessage( + new protos.google.monitoring.v3.GetNotificationChannelVerificationCodeRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.monitoring.v3.GetNotificationChannelVerificationCodeResponse() + ); + client.innerApiCalls.getNotificationChannelVerificationCode = stubSimpleCallWithCallback( + expectedResponse + ); + const promise = new Promise((resolve, reject) => { + client.getNotificationChannelVerificationCode( + request, + ( + err?: Error | null, + result?: protos.google.monitoring.v3.IGetNotificationChannelVerificationCodeResponse | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls + .getNotificationChannelVerificationCode as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions /*, callback defined above */) + ); + }); + + it('invokes getNotificationChannelVerificationCode with error', async () => { + const client = new notificationchannelserviceModule.v3.NotificationChannelServiceClient( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + const request = generateSampleMessage( + new protos.google.monitoring.v3.GetNotificationChannelVerificationCodeRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.getNotificationChannelVerificationCode = stubSimpleCall( + undefined, + expectedError + ); + assert.rejects(async () => { + await client.getNotificationChannelVerificationCode(request); + }, expectedError); + assert( + (client.innerApiCalls + .getNotificationChannelVerificationCode as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + }); + + describe('verifyNotificationChannel', () => { + it('invokes verifyNotificationChannel without error', async () => { + const client = new notificationchannelserviceModule.v3.NotificationChannelServiceClient( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + const request = generateSampleMessage( + new protos.google.monitoring.v3.VerifyNotificationChannelRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.monitoring.v3.NotificationChannel() + ); + client.innerApiCalls.verifyNotificationChannel = stubSimpleCall( + expectedResponse + ); + const [response] = await client.verifyNotificationChannel(request); + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.verifyNotificationChannel as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + + it('invokes verifyNotificationChannel without error using callback', async () => { + const client = new notificationchannelserviceModule.v3.NotificationChannelServiceClient( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + const request = generateSampleMessage( + new protos.google.monitoring.v3.VerifyNotificationChannelRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.monitoring.v3.NotificationChannel() + ); + client.innerApiCalls.verifyNotificationChannel = stubSimpleCallWithCallback( + expectedResponse + ); + const promise = new Promise((resolve, reject) => { + client.verifyNotificationChannel( + request, + ( + err?: Error | null, + result?: protos.google.monitoring.v3.INotificationChannel | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.verifyNotificationChannel as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions /*, callback defined above */) + ); + }); + + it('invokes verifyNotificationChannel with error', async () => { + const client = new notificationchannelserviceModule.v3.NotificationChannelServiceClient( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + const request = generateSampleMessage( + new protos.google.monitoring.v3.VerifyNotificationChannelRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.verifyNotificationChannel = stubSimpleCall( + undefined, + expectedError + ); + assert.rejects(async () => { + await client.verifyNotificationChannel(request); + }, expectedError); + assert( + (client.innerApiCalls.verifyNotificationChannel as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + }); + + describe('listNotificationChannelDescriptors', () => { + it('invokes listNotificationChannelDescriptors without error', async () => { + const client = new notificationchannelserviceModule.v3.NotificationChannelServiceClient( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + const request = generateSampleMessage( + new protos.google.monitoring.v3.ListNotificationChannelDescriptorsRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage( + new protos.google.monitoring.v3.NotificationChannelDescriptor() + ), + generateSampleMessage( + new protos.google.monitoring.v3.NotificationChannelDescriptor() + ), + generateSampleMessage( + new protos.google.monitoring.v3.NotificationChannelDescriptor() + ), + ]; + client.innerApiCalls.listNotificationChannelDescriptors = stubSimpleCall( + expectedResponse + ); + const [response] = await client.listNotificationChannelDescriptors( + request + ); + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.listNotificationChannelDescriptors as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + + it('invokes listNotificationChannelDescriptors without error using callback', async () => { + const client = new notificationchannelserviceModule.v3.NotificationChannelServiceClient( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + const request = generateSampleMessage( + new protos.google.monitoring.v3.ListNotificationChannelDescriptorsRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage( + new protos.google.monitoring.v3.NotificationChannelDescriptor() + ), + generateSampleMessage( + new protos.google.monitoring.v3.NotificationChannelDescriptor() + ), + generateSampleMessage( + new protos.google.monitoring.v3.NotificationChannelDescriptor() + ), + ]; + client.innerApiCalls.listNotificationChannelDescriptors = stubSimpleCallWithCallback( + expectedResponse + ); + const promise = new Promise((resolve, reject) => { + client.listNotificationChannelDescriptors( + request, + ( + err?: Error | null, + result?: + | protos.google.monitoring.v3.INotificationChannelDescriptor[] + | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.listNotificationChannelDescriptors as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions /*, callback defined above */) + ); + }); + + it('invokes listNotificationChannelDescriptors with error', async () => { + const client = new notificationchannelserviceModule.v3.NotificationChannelServiceClient( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + const request = generateSampleMessage( + new protos.google.monitoring.v3.ListNotificationChannelDescriptorsRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.listNotificationChannelDescriptors = stubSimpleCall( + undefined, + expectedError + ); + assert.rejects(async () => { + await client.listNotificationChannelDescriptors(request); + }, expectedError); + assert( + (client.innerApiCalls.listNotificationChannelDescriptors as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + + it('invokes listNotificationChannelDescriptorsStream without error', async () => { + const client = new notificationchannelserviceModule.v3.NotificationChannelServiceClient( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + const request = generateSampleMessage( + new protos.google.monitoring.v3.ListNotificationChannelDescriptorsRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedResponse = [ + generateSampleMessage( + new protos.google.monitoring.v3.NotificationChannelDescriptor() + ), + generateSampleMessage( + new protos.google.monitoring.v3.NotificationChannelDescriptor() + ), + generateSampleMessage( + new protos.google.monitoring.v3.NotificationChannelDescriptor() + ), + ]; + client.descriptors.page.listNotificationChannelDescriptors.createStream = stubPageStreamingCall( + expectedResponse + ); + const stream = client.listNotificationChannelDescriptorsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.monitoring.v3.NotificationChannelDescriptor[] = []; + stream.on( + 'data', + ( + response: protos.google.monitoring.v3.NotificationChannelDescriptor + ) => { + 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.listNotificationChannelDescriptors + .createStream as SinonStub) + .getCall(0) + .calledWith( + client.innerApiCalls.listNotificationChannelDescriptors, + request + ) + ); + assert.strictEqual( + (client.descriptors.page.listNotificationChannelDescriptors + .createStream as SinonStub).getCall(0).args[2].otherArgs.headers[ + 'x-goog-request-params' + ], + expectedHeaderRequestParams + ); + }); + + it('invokes listNotificationChannelDescriptorsStream with error', async () => { + const client = new notificationchannelserviceModule.v3.NotificationChannelServiceClient( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + const request = generateSampleMessage( + new protos.google.monitoring.v3.ListNotificationChannelDescriptorsRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedError = new Error('expected'); + client.descriptors.page.listNotificationChannelDescriptors.createStream = stubPageStreamingCall( + undefined, + expectedError + ); + const stream = client.listNotificationChannelDescriptorsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.monitoring.v3.NotificationChannelDescriptor[] = []; + stream.on( + 'data', + ( + response: protos.google.monitoring.v3.NotificationChannelDescriptor + ) => { + responses.push(response); + } + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + assert.rejects(async () => { + await promise; + }, expectedError); + assert( + (client.descriptors.page.listNotificationChannelDescriptors + .createStream as SinonStub) + .getCall(0) + .calledWith( + client.innerApiCalls.listNotificationChannelDescriptors, + request + ) + ); + assert.strictEqual( + (client.descriptors.page.listNotificationChannelDescriptors + .createStream as SinonStub).getCall(0).args[2].otherArgs.headers[ + 'x-goog-request-params' + ], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listNotificationChannelDescriptors without error', async () => { + const client = new notificationchannelserviceModule.v3.NotificationChannelServiceClient( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + const request = generateSampleMessage( + new protos.google.monitoring.v3.ListNotificationChannelDescriptorsRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedResponse = [ + generateSampleMessage( + new protos.google.monitoring.v3.NotificationChannelDescriptor() + ), + generateSampleMessage( + new protos.google.monitoring.v3.NotificationChannelDescriptor() + ), + generateSampleMessage( + new protos.google.monitoring.v3.NotificationChannelDescriptor() + ), + ]; + client.descriptors.page.listNotificationChannelDescriptors.asyncIterate = stubAsyncIterationCall( + expectedResponse + ); + const responses: protos.google.monitoring.v3.INotificationChannelDescriptor[] = []; + const iterable = client.listNotificationChannelDescriptorsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listNotificationChannelDescriptors + .asyncIterate as SinonStub).getCall(0).args[1], + request + ); + assert.strictEqual( + (client.descriptors.page.listNotificationChannelDescriptors + .asyncIterate as SinonStub).getCall(0).args[2].otherArgs.headers[ + 'x-goog-request-params' + ], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listNotificationChannelDescriptors with error', async () => { + const client = new notificationchannelserviceModule.v3.NotificationChannelServiceClient( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + const request = generateSampleMessage( + new protos.google.monitoring.v3.ListNotificationChannelDescriptorsRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedError = new Error('expected'); + client.descriptors.page.listNotificationChannelDescriptors.asyncIterate = stubAsyncIterationCall( + undefined, + expectedError + ); + const iterable = client.listNotificationChannelDescriptorsAsync(request); + assert.rejects(async () => { + const responses: protos.google.monitoring.v3.INotificationChannelDescriptor[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listNotificationChannelDescriptors + .asyncIterate as SinonStub).getCall(0).args[1], + request + ); + assert.strictEqual( + (client.descriptors.page.listNotificationChannelDescriptors + .asyncIterate as SinonStub).getCall(0).args[2].otherArgs.headers[ + 'x-goog-request-params' + ], + expectedHeaderRequestParams + ); + }); + }); + + describe('listNotificationChannels', () => { + it('invokes listNotificationChannels without error', async () => { + const client = new notificationchannelserviceModule.v3.NotificationChannelServiceClient( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + const request = generateSampleMessage( + new protos.google.monitoring.v3.ListNotificationChannelsRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage( + new protos.google.monitoring.v3.NotificationChannel() + ), + generateSampleMessage( + new protos.google.monitoring.v3.NotificationChannel() + ), + generateSampleMessage( + new protos.google.monitoring.v3.NotificationChannel() + ), + ]; + client.innerApiCalls.listNotificationChannels = stubSimpleCall( + expectedResponse + ); + const [response] = await client.listNotificationChannels(request); + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.listNotificationChannels as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + + it('invokes listNotificationChannels without error using callback', async () => { + const client = new notificationchannelserviceModule.v3.NotificationChannelServiceClient( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + const request = generateSampleMessage( + new protos.google.monitoring.v3.ListNotificationChannelsRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage( + new protos.google.monitoring.v3.NotificationChannel() + ), + generateSampleMessage( + new protos.google.monitoring.v3.NotificationChannel() + ), + generateSampleMessage( + new protos.google.monitoring.v3.NotificationChannel() + ), + ]; + client.innerApiCalls.listNotificationChannels = stubSimpleCallWithCallback( + expectedResponse + ); + const promise = new Promise((resolve, reject) => { + client.listNotificationChannels( + request, + ( + err?: Error | null, + result?: protos.google.monitoring.v3.INotificationChannel[] | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.listNotificationChannels as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions /*, callback defined above */) + ); + }); + + it('invokes listNotificationChannels with error', async () => { + const client = new notificationchannelserviceModule.v3.NotificationChannelServiceClient( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + const request = generateSampleMessage( + new protos.google.monitoring.v3.ListNotificationChannelsRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.listNotificationChannels = stubSimpleCall( + undefined, + expectedError + ); + assert.rejects(async () => { + await client.listNotificationChannels(request); + }, expectedError); + assert( + (client.innerApiCalls.listNotificationChannels as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + + it('invokes listNotificationChannelsStream without error', async () => { + const client = new notificationchannelserviceModule.v3.NotificationChannelServiceClient( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + const request = generateSampleMessage( + new protos.google.monitoring.v3.ListNotificationChannelsRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedResponse = [ + generateSampleMessage( + new protos.google.monitoring.v3.NotificationChannel() + ), + generateSampleMessage( + new protos.google.monitoring.v3.NotificationChannel() + ), + generateSampleMessage( + new protos.google.monitoring.v3.NotificationChannel() + ), + ]; + client.descriptors.page.listNotificationChannels.createStream = stubPageStreamingCall( + expectedResponse + ); + const stream = client.listNotificationChannelsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.monitoring.v3.NotificationChannel[] = []; + stream.on( + 'data', + (response: protos.google.monitoring.v3.NotificationChannel) => { + 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.listNotificationChannels + .createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listNotificationChannels, request) + ); + assert.strictEqual( + (client.descriptors.page.listNotificationChannels + .createStream as SinonStub).getCall(0).args[2].otherArgs.headers[ + 'x-goog-request-params' + ], + expectedHeaderRequestParams + ); + }); + + it('invokes listNotificationChannelsStream with error', async () => { + const client = new notificationchannelserviceModule.v3.NotificationChannelServiceClient( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + const request = generateSampleMessage( + new protos.google.monitoring.v3.ListNotificationChannelsRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedError = new Error('expected'); + client.descriptors.page.listNotificationChannels.createStream = stubPageStreamingCall( + undefined, + expectedError + ); + const stream = client.listNotificationChannelsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.monitoring.v3.NotificationChannel[] = []; + stream.on( + 'data', + (response: protos.google.monitoring.v3.NotificationChannel) => { + responses.push(response); + } + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + assert.rejects(async () => { + await promise; + }, expectedError); + assert( + (client.descriptors.page.listNotificationChannels + .createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listNotificationChannels, request) + ); + assert.strictEqual( + (client.descriptors.page.listNotificationChannels + .createStream as SinonStub).getCall(0).args[2].otherArgs.headers[ + 'x-goog-request-params' + ], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listNotificationChannels without error', async () => { + const client = new notificationchannelserviceModule.v3.NotificationChannelServiceClient( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + const request = generateSampleMessage( + new protos.google.monitoring.v3.ListNotificationChannelsRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedResponse = [ + generateSampleMessage( + new protos.google.monitoring.v3.NotificationChannel() + ), + generateSampleMessage( + new protos.google.monitoring.v3.NotificationChannel() + ), + generateSampleMessage( + new protos.google.monitoring.v3.NotificationChannel() + ), + ]; + client.descriptors.page.listNotificationChannels.asyncIterate = stubAsyncIterationCall( + expectedResponse + ); + const responses: protos.google.monitoring.v3.INotificationChannel[] = []; + const iterable = client.listNotificationChannelsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listNotificationChannels + .asyncIterate as SinonStub).getCall(0).args[1], + request + ); + assert.strictEqual( + (client.descriptors.page.listNotificationChannels + .asyncIterate as SinonStub).getCall(0).args[2].otherArgs.headers[ + 'x-goog-request-params' + ], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listNotificationChannels with error', async () => { + const client = new notificationchannelserviceModule.v3.NotificationChannelServiceClient( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + const request = generateSampleMessage( + new protos.google.monitoring.v3.ListNotificationChannelsRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedError = new Error('expected'); + client.descriptors.page.listNotificationChannels.asyncIterate = stubAsyncIterationCall( + undefined, + expectedError + ); + const iterable = client.listNotificationChannelsAsync(request); + assert.rejects(async () => { + const responses: protos.google.monitoring.v3.INotificationChannel[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listNotificationChannels + .asyncIterate as SinonStub).getCall(0).args[1], + request + ); + assert.strictEqual( + (client.descriptors.page.listNotificationChannels + .asyncIterate as SinonStub).getCall(0).args[2].otherArgs.headers[ + 'x-goog-request-params' + ], + expectedHeaderRequestParams + ); + }); + }); + + describe('Path templates', () => { + describe('folderAlertPolicy', () => { + const fakePath = '/rendered/path/folderAlertPolicy'; + const expectedParameters = { + folder: 'folderValue', + alert_policy: 'alertPolicyValue', + }; + const client = new notificationchannelserviceModule.v3.NotificationChannelServiceClient( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + client.pathTemplates.folderAlertPolicyPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.folderAlertPolicyPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('folderAlertPolicyPath', () => { + const result = client.folderAlertPolicyPath( + 'folderValue', + 'alertPolicyValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.folderAlertPolicyPathTemplate + .render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchFolderFromFolderAlertPolicyName', () => { + const result = client.matchFolderFromFolderAlertPolicyName(fakePath); + assert.strictEqual(result, 'folderValue'); + assert( + (client.pathTemplates.folderAlertPolicyPathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchAlertPolicyFromFolderAlertPolicyName', () => { + const result = client.matchAlertPolicyFromFolderAlertPolicyName( + fakePath + ); + assert.strictEqual(result, 'alertPolicyValue'); + assert( + (client.pathTemplates.folderAlertPolicyPathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('folderAlertPolicyCondition', () => { + const fakePath = '/rendered/path/folderAlertPolicyCondition'; + const expectedParameters = { + folder: 'folderValue', + alert_policy: 'alertPolicyValue', + condition: 'conditionValue', + }; + const client = new notificationchannelserviceModule.v3.NotificationChannelServiceClient( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + client.pathTemplates.folderAlertPolicyConditionPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.folderAlertPolicyConditionPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('folderAlertPolicyConditionPath', () => { + const result = client.folderAlertPolicyConditionPath( + 'folderValue', + 'alertPolicyValue', + 'conditionValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.folderAlertPolicyConditionPathTemplate + .render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchFolderFromFolderAlertPolicyConditionName', () => { + const result = client.matchFolderFromFolderAlertPolicyConditionName( + fakePath + ); + assert.strictEqual(result, 'folderValue'); + assert( + (client.pathTemplates.folderAlertPolicyConditionPathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchAlertPolicyFromFolderAlertPolicyConditionName', () => { + const result = client.matchAlertPolicyFromFolderAlertPolicyConditionName( + fakePath + ); + assert.strictEqual(result, 'alertPolicyValue'); + assert( + (client.pathTemplates.folderAlertPolicyConditionPathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchConditionFromFolderAlertPolicyConditionName', () => { + const result = client.matchConditionFromFolderAlertPolicyConditionName( + fakePath + ); + assert.strictEqual(result, 'conditionValue'); + assert( + (client.pathTemplates.folderAlertPolicyConditionPathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('folderChannelDescriptor', () => { + const fakePath = '/rendered/path/folderChannelDescriptor'; + const expectedParameters = { + folder: 'folderValue', + channel_descriptor: 'channelDescriptorValue', + }; + const client = new notificationchannelserviceModule.v3.NotificationChannelServiceClient( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + client.pathTemplates.folderChannelDescriptorPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.folderChannelDescriptorPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('folderChannelDescriptorPath', () => { + const result = client.folderChannelDescriptorPath( + 'folderValue', + 'channelDescriptorValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.folderChannelDescriptorPathTemplate + .render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchFolderFromFolderChannelDescriptorName', () => { + const result = client.matchFolderFromFolderChannelDescriptorName( + fakePath + ); + assert.strictEqual(result, 'folderValue'); + assert( + (client.pathTemplates.folderChannelDescriptorPathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchChannelDescriptorFromFolderChannelDescriptorName', () => { + const result = client.matchChannelDescriptorFromFolderChannelDescriptorName( + fakePath + ); + assert.strictEqual(result, 'channelDescriptorValue'); + assert( + (client.pathTemplates.folderChannelDescriptorPathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('folderGroup', () => { + const fakePath = '/rendered/path/folderGroup'; + const expectedParameters = { + folder: 'folderValue', + group: 'groupValue', + }; + const client = new notificationchannelserviceModule.v3.NotificationChannelServiceClient( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + client.pathTemplates.folderGroupPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.folderGroupPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('folderGroupPath', () => { + const result = client.folderGroupPath('folderValue', 'groupValue'); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.folderGroupPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchFolderFromFolderGroupName', () => { + const result = client.matchFolderFromFolderGroupName(fakePath); + assert.strictEqual(result, 'folderValue'); + assert( + (client.pathTemplates.folderGroupPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchGroupFromFolderGroupName', () => { + const result = client.matchGroupFromFolderGroupName(fakePath); + assert.strictEqual(result, 'groupValue'); + assert( + (client.pathTemplates.folderGroupPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('folderNotificationChannel', () => { + const fakePath = '/rendered/path/folderNotificationChannel'; + const expectedParameters = { + folder: 'folderValue', + notification_channel: 'notificationChannelValue', + }; + const client = new notificationchannelserviceModule.v3.NotificationChannelServiceClient( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + client.pathTemplates.folderNotificationChannelPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.folderNotificationChannelPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('folderNotificationChannelPath', () => { + const result = client.folderNotificationChannelPath( + 'folderValue', + 'notificationChannelValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.folderNotificationChannelPathTemplate + .render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchFolderFromFolderNotificationChannelName', () => { + const result = client.matchFolderFromFolderNotificationChannelName( + fakePath + ); + assert.strictEqual(result, 'folderValue'); + assert( + (client.pathTemplates.folderNotificationChannelPathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchNotificationChannelFromFolderNotificationChannelName', () => { + const result = client.matchNotificationChannelFromFolderNotificationChannelName( + fakePath + ); + assert.strictEqual(result, 'notificationChannelValue'); + assert( + (client.pathTemplates.folderNotificationChannelPathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('folderService', () => { + const fakePath = '/rendered/path/folderService'; + const expectedParameters = { + folder: 'folderValue', + service: 'serviceValue', + }; + const client = new notificationchannelserviceModule.v3.NotificationChannelServiceClient( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + client.pathTemplates.folderServicePathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.folderServicePathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('folderServicePath', () => { + const result = client.folderServicePath('folderValue', 'serviceValue'); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.folderServicePathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchFolderFromFolderServiceName', () => { + const result = client.matchFolderFromFolderServiceName(fakePath); + assert.strictEqual(result, 'folderValue'); + assert( + (client.pathTemplates.folderServicePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchServiceFromFolderServiceName', () => { + const result = client.matchServiceFromFolderServiceName(fakePath); + assert.strictEqual(result, 'serviceValue'); + assert( + (client.pathTemplates.folderServicePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('folderServiceServiceLevelObjective', () => { + const fakePath = '/rendered/path/folderServiceServiceLevelObjective'; + const expectedParameters = { + folder: 'folderValue', + service: 'serviceValue', + service_level_objective: 'serviceLevelObjectiveValue', + }; + const client = new notificationchannelserviceModule.v3.NotificationChannelServiceClient( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + client.pathTemplates.folderServiceServiceLevelObjectivePathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.folderServiceServiceLevelObjectivePathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('folderServiceServiceLevelObjectivePath', () => { + const result = client.folderServiceServiceLevelObjectivePath( + 'folderValue', + 'serviceValue', + 'serviceLevelObjectiveValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.folderServiceServiceLevelObjectivePathTemplate + .render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchFolderFromFolderServiceServiceLevelObjectiveName', () => { + const result = client.matchFolderFromFolderServiceServiceLevelObjectiveName( + fakePath + ); + assert.strictEqual(result, 'folderValue'); + assert( + (client.pathTemplates.folderServiceServiceLevelObjectivePathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchServiceFromFolderServiceServiceLevelObjectiveName', () => { + const result = client.matchServiceFromFolderServiceServiceLevelObjectiveName( + fakePath + ); + assert.strictEqual(result, 'serviceValue'); + assert( + (client.pathTemplates.folderServiceServiceLevelObjectivePathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchServiceLevelObjectiveFromFolderServiceServiceLevelObjectiveName', () => { + const result = client.matchServiceLevelObjectiveFromFolderServiceServiceLevelObjectiveName( + fakePath + ); + assert.strictEqual(result, 'serviceLevelObjectiveValue'); + assert( + (client.pathTemplates.folderServiceServiceLevelObjectivePathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('folderUptimeCheckConfig', () => { + const fakePath = '/rendered/path/folderUptimeCheckConfig'; + const expectedParameters = { + folder: 'folderValue', + uptime_check_config: 'uptimeCheckConfigValue', + }; + const client = new notificationchannelserviceModule.v3.NotificationChannelServiceClient( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + client.pathTemplates.folderUptimeCheckConfigPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.folderUptimeCheckConfigPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('folderUptimeCheckConfigPath', () => { + const result = client.folderUptimeCheckConfigPath( + 'folderValue', + 'uptimeCheckConfigValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.folderUptimeCheckConfigPathTemplate + .render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchFolderFromFolderUptimeCheckConfigName', () => { + const result = client.matchFolderFromFolderUptimeCheckConfigName( + fakePath + ); + assert.strictEqual(result, 'folderValue'); + assert( + (client.pathTemplates.folderUptimeCheckConfigPathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchUptimeCheckConfigFromFolderUptimeCheckConfigName', () => { + const result = client.matchUptimeCheckConfigFromFolderUptimeCheckConfigName( + fakePath + ); + assert.strictEqual(result, 'uptimeCheckConfigValue'); + assert( + (client.pathTemplates.folderUptimeCheckConfigPathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('organizationAlertPolicy', () => { + const fakePath = '/rendered/path/organizationAlertPolicy'; + const expectedParameters = { + organization: 'organizationValue', + alert_policy: 'alertPolicyValue', + }; + const client = new notificationchannelserviceModule.v3.NotificationChannelServiceClient( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + client.pathTemplates.organizationAlertPolicyPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.organizationAlertPolicyPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('organizationAlertPolicyPath', () => { + const result = client.organizationAlertPolicyPath( + 'organizationValue', + 'alertPolicyValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.organizationAlertPolicyPathTemplate + .render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchOrganizationFromOrganizationAlertPolicyName', () => { + const result = client.matchOrganizationFromOrganizationAlertPolicyName( + fakePath + ); + assert.strictEqual(result, 'organizationValue'); + assert( + (client.pathTemplates.organizationAlertPolicyPathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchAlertPolicyFromOrganizationAlertPolicyName', () => { + const result = client.matchAlertPolicyFromOrganizationAlertPolicyName( + fakePath + ); + assert.strictEqual(result, 'alertPolicyValue'); + assert( + (client.pathTemplates.organizationAlertPolicyPathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('organizationAlertPolicyCondition', () => { + const fakePath = '/rendered/path/organizationAlertPolicyCondition'; + const expectedParameters = { + organization: 'organizationValue', + alert_policy: 'alertPolicyValue', + condition: 'conditionValue', + }; + const client = new notificationchannelserviceModule.v3.NotificationChannelServiceClient( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + client.pathTemplates.organizationAlertPolicyConditionPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.organizationAlertPolicyConditionPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('organizationAlertPolicyConditionPath', () => { + const result = client.organizationAlertPolicyConditionPath( + 'organizationValue', + 'alertPolicyValue', + 'conditionValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.organizationAlertPolicyConditionPathTemplate + .render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchOrganizationFromOrganizationAlertPolicyConditionName', () => { + const result = client.matchOrganizationFromOrganizationAlertPolicyConditionName( + fakePath + ); + assert.strictEqual(result, 'organizationValue'); + assert( + (client.pathTemplates.organizationAlertPolicyConditionPathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchAlertPolicyFromOrganizationAlertPolicyConditionName', () => { + const result = client.matchAlertPolicyFromOrganizationAlertPolicyConditionName( + fakePath + ); + assert.strictEqual(result, 'alertPolicyValue'); + assert( + (client.pathTemplates.organizationAlertPolicyConditionPathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchConditionFromOrganizationAlertPolicyConditionName', () => { + const result = client.matchConditionFromOrganizationAlertPolicyConditionName( + fakePath + ); + assert.strictEqual(result, 'conditionValue'); + assert( + (client.pathTemplates.organizationAlertPolicyConditionPathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('organizationChannelDescriptor', () => { + const fakePath = '/rendered/path/organizationChannelDescriptor'; + const expectedParameters = { + organization: 'organizationValue', + channel_descriptor: 'channelDescriptorValue', + }; + const client = new notificationchannelserviceModule.v3.NotificationChannelServiceClient( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + client.pathTemplates.organizationChannelDescriptorPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.organizationChannelDescriptorPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('organizationChannelDescriptorPath', () => { + const result = client.organizationChannelDescriptorPath( + 'organizationValue', + 'channelDescriptorValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.organizationChannelDescriptorPathTemplate + .render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchOrganizationFromOrganizationChannelDescriptorName', () => { + const result = client.matchOrganizationFromOrganizationChannelDescriptorName( + fakePath + ); + assert.strictEqual(result, 'organizationValue'); + assert( + (client.pathTemplates.organizationChannelDescriptorPathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchChannelDescriptorFromOrganizationChannelDescriptorName', () => { + const result = client.matchChannelDescriptorFromOrganizationChannelDescriptorName( + fakePath + ); + assert.strictEqual(result, 'channelDescriptorValue'); + assert( + (client.pathTemplates.organizationChannelDescriptorPathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('organizationGroup', () => { + const fakePath = '/rendered/path/organizationGroup'; + const expectedParameters = { + organization: 'organizationValue', + group: 'groupValue', + }; + const client = new notificationchannelserviceModule.v3.NotificationChannelServiceClient( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + client.pathTemplates.organizationGroupPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.organizationGroupPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('organizationGroupPath', () => { + const result = client.organizationGroupPath( + 'organizationValue', + 'groupValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.organizationGroupPathTemplate + .render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchOrganizationFromOrganizationGroupName', () => { + const result = client.matchOrganizationFromOrganizationGroupName( + fakePath + ); + assert.strictEqual(result, 'organizationValue'); + assert( + (client.pathTemplates.organizationGroupPathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchGroupFromOrganizationGroupName', () => { + const result = client.matchGroupFromOrganizationGroupName(fakePath); + assert.strictEqual(result, 'groupValue'); + assert( + (client.pathTemplates.organizationGroupPathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('organizationNotificationChannel', () => { + const fakePath = '/rendered/path/organizationNotificationChannel'; + const expectedParameters = { + organization: 'organizationValue', + notification_channel: 'notificationChannelValue', + }; + const client = new notificationchannelserviceModule.v3.NotificationChannelServiceClient( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + client.pathTemplates.organizationNotificationChannelPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.organizationNotificationChannelPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('organizationNotificationChannelPath', () => { + const result = client.organizationNotificationChannelPath( + 'organizationValue', + 'notificationChannelValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.organizationNotificationChannelPathTemplate + .render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchOrganizationFromOrganizationNotificationChannelName', () => { + const result = client.matchOrganizationFromOrganizationNotificationChannelName( + fakePath + ); + assert.strictEqual(result, 'organizationValue'); + assert( + (client.pathTemplates.organizationNotificationChannelPathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchNotificationChannelFromOrganizationNotificationChannelName', () => { + const result = client.matchNotificationChannelFromOrganizationNotificationChannelName( + fakePath + ); + assert.strictEqual(result, 'notificationChannelValue'); + assert( + (client.pathTemplates.organizationNotificationChannelPathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('organizationService', () => { + const fakePath = '/rendered/path/organizationService'; + const expectedParameters = { + organization: 'organizationValue', + service: 'serviceValue', + }; + const client = new notificationchannelserviceModule.v3.NotificationChannelServiceClient( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + client.pathTemplates.organizationServicePathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.organizationServicePathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('organizationServicePath', () => { + const result = client.organizationServicePath( + 'organizationValue', + 'serviceValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.organizationServicePathTemplate + .render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchOrganizationFromOrganizationServiceName', () => { + const result = client.matchOrganizationFromOrganizationServiceName( + fakePath + ); + assert.strictEqual(result, 'organizationValue'); + assert( + (client.pathTemplates.organizationServicePathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchServiceFromOrganizationServiceName', () => { + const result = client.matchServiceFromOrganizationServiceName(fakePath); + assert.strictEqual(result, 'serviceValue'); + assert( + (client.pathTemplates.organizationServicePathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('organizationServiceServiceLevelObjective', () => { + const fakePath = + '/rendered/path/organizationServiceServiceLevelObjective'; + const expectedParameters = { + organization: 'organizationValue', + service: 'serviceValue', + service_level_objective: 'serviceLevelObjectiveValue', + }; + const client = new notificationchannelserviceModule.v3.NotificationChannelServiceClient( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + client.pathTemplates.organizationServiceServiceLevelObjectivePathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.organizationServiceServiceLevelObjectivePathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('organizationServiceServiceLevelObjectivePath', () => { + const result = client.organizationServiceServiceLevelObjectivePath( + 'organizationValue', + 'serviceValue', + 'serviceLevelObjectiveValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates + .organizationServiceServiceLevelObjectivePathTemplate + .render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchOrganizationFromOrganizationServiceServiceLevelObjectiveName', () => { + const result = client.matchOrganizationFromOrganizationServiceServiceLevelObjectiveName( + fakePath + ); + assert.strictEqual(result, 'organizationValue'); + assert( + (client.pathTemplates + .organizationServiceServiceLevelObjectivePathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchServiceFromOrganizationServiceServiceLevelObjectiveName', () => { + const result = client.matchServiceFromOrganizationServiceServiceLevelObjectiveName( + fakePath + ); + assert.strictEqual(result, 'serviceValue'); + assert( + (client.pathTemplates + .organizationServiceServiceLevelObjectivePathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchServiceLevelObjectiveFromOrganizationServiceServiceLevelObjectiveName', () => { + const result = client.matchServiceLevelObjectiveFromOrganizationServiceServiceLevelObjectiveName( + fakePath + ); + assert.strictEqual(result, 'serviceLevelObjectiveValue'); + assert( + (client.pathTemplates + .organizationServiceServiceLevelObjectivePathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('organizationUptimeCheckConfig', () => { + const fakePath = '/rendered/path/organizationUptimeCheckConfig'; + const expectedParameters = { + organization: 'organizationValue', + uptime_check_config: 'uptimeCheckConfigValue', + }; + const client = new notificationchannelserviceModule.v3.NotificationChannelServiceClient( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + client.pathTemplates.organizationUptimeCheckConfigPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.organizationUptimeCheckConfigPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('organizationUptimeCheckConfigPath', () => { + const result = client.organizationUptimeCheckConfigPath( + 'organizationValue', + 'uptimeCheckConfigValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.organizationUptimeCheckConfigPathTemplate + .render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchOrganizationFromOrganizationUptimeCheckConfigName', () => { + const result = client.matchOrganizationFromOrganizationUptimeCheckConfigName( + fakePath + ); + assert.strictEqual(result, 'organizationValue'); + assert( + (client.pathTemplates.organizationUptimeCheckConfigPathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchUptimeCheckConfigFromOrganizationUptimeCheckConfigName', () => { + const result = client.matchUptimeCheckConfigFromOrganizationUptimeCheckConfigName( + fakePath + ); + assert.strictEqual(result, 'uptimeCheckConfigValue'); + assert( + (client.pathTemplates.organizationUptimeCheckConfigPathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('project', () => { + const fakePath = '/rendered/path/project'; + const expectedParameters = { + project: 'projectValue', + }; + const client = new notificationchannelserviceModule.v3.NotificationChannelServiceClient( + { + 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('matchProjectFromProjectName', () => { + const result = client.matchProjectFromProjectName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.projectPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('projectAlertPolicy', () => { + const fakePath = '/rendered/path/projectAlertPolicy'; + const expectedParameters = { + project: 'projectValue', + alert_policy: 'alertPolicyValue', + }; + const client = new notificationchannelserviceModule.v3.NotificationChannelServiceClient( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + client.pathTemplates.projectAlertPolicyPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.projectAlertPolicyPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('projectAlertPolicyPath', () => { + const result = client.projectAlertPolicyPath( + 'projectValue', + 'alertPolicyValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.projectAlertPolicyPathTemplate + .render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromProjectAlertPolicyName', () => { + const result = client.matchProjectFromProjectAlertPolicyName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.projectAlertPolicyPathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchAlertPolicyFromProjectAlertPolicyName', () => { + const result = client.matchAlertPolicyFromProjectAlertPolicyName( + fakePath + ); + assert.strictEqual(result, 'alertPolicyValue'); + assert( + (client.pathTemplates.projectAlertPolicyPathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('projectAlertPolicyCondition', () => { + const fakePath = '/rendered/path/projectAlertPolicyCondition'; + const expectedParameters = { + project: 'projectValue', + alert_policy: 'alertPolicyValue', + condition: 'conditionValue', + }; + const client = new notificationchannelserviceModule.v3.NotificationChannelServiceClient( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + client.pathTemplates.projectAlertPolicyConditionPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.projectAlertPolicyConditionPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('projectAlertPolicyConditionPath', () => { + const result = client.projectAlertPolicyConditionPath( + 'projectValue', + 'alertPolicyValue', + 'conditionValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.projectAlertPolicyConditionPathTemplate + .render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromProjectAlertPolicyConditionName', () => { + const result = client.matchProjectFromProjectAlertPolicyConditionName( + fakePath + ); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.projectAlertPolicyConditionPathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchAlertPolicyFromProjectAlertPolicyConditionName', () => { + const result = client.matchAlertPolicyFromProjectAlertPolicyConditionName( + fakePath + ); + assert.strictEqual(result, 'alertPolicyValue'); + assert( + (client.pathTemplates.projectAlertPolicyConditionPathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchConditionFromProjectAlertPolicyConditionName', () => { + const result = client.matchConditionFromProjectAlertPolicyConditionName( + fakePath + ); + assert.strictEqual(result, 'conditionValue'); + assert( + (client.pathTemplates.projectAlertPolicyConditionPathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('projectChannelDescriptor', () => { + const fakePath = '/rendered/path/projectChannelDescriptor'; + const expectedParameters = { + project: 'projectValue', + channel_descriptor: 'channelDescriptorValue', + }; + const client = new notificationchannelserviceModule.v3.NotificationChannelServiceClient( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + client.pathTemplates.projectChannelDescriptorPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.projectChannelDescriptorPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('projectChannelDescriptorPath', () => { + const result = client.projectChannelDescriptorPath( + 'projectValue', + 'channelDescriptorValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.projectChannelDescriptorPathTemplate + .render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromProjectChannelDescriptorName', () => { + const result = client.matchProjectFromProjectChannelDescriptorName( + fakePath + ); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.projectChannelDescriptorPathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchChannelDescriptorFromProjectChannelDescriptorName', () => { + const result = client.matchChannelDescriptorFromProjectChannelDescriptorName( + fakePath + ); + assert.strictEqual(result, 'channelDescriptorValue'); + assert( + (client.pathTemplates.projectChannelDescriptorPathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('projectGroup', () => { + const fakePath = '/rendered/path/projectGroup'; + const expectedParameters = { + project: 'projectValue', + group: 'groupValue', + }; + const client = new notificationchannelserviceModule.v3.NotificationChannelServiceClient( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + client.pathTemplates.projectGroupPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.projectGroupPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('projectGroupPath', () => { + const result = client.projectGroupPath('projectValue', 'groupValue'); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.projectGroupPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromProjectGroupName', () => { + const result = client.matchProjectFromProjectGroupName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.projectGroupPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchGroupFromProjectGroupName', () => { + const result = client.matchGroupFromProjectGroupName(fakePath); + assert.strictEqual(result, 'groupValue'); + assert( + (client.pathTemplates.projectGroupPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('projectNotificationChannel', () => { + const fakePath = '/rendered/path/projectNotificationChannel'; + const expectedParameters = { + project: 'projectValue', + notification_channel: 'notificationChannelValue', + }; + const client = new notificationchannelserviceModule.v3.NotificationChannelServiceClient( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + client.pathTemplates.projectNotificationChannelPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.projectNotificationChannelPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('projectNotificationChannelPath', () => { + const result = client.projectNotificationChannelPath( + 'projectValue', + 'notificationChannelValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.projectNotificationChannelPathTemplate + .render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromProjectNotificationChannelName', () => { + const result = client.matchProjectFromProjectNotificationChannelName( + fakePath + ); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.projectNotificationChannelPathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchNotificationChannelFromProjectNotificationChannelName', () => { + const result = client.matchNotificationChannelFromProjectNotificationChannelName( + fakePath + ); + assert.strictEqual(result, 'notificationChannelValue'); + assert( + (client.pathTemplates.projectNotificationChannelPathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('projectService', () => { + const fakePath = '/rendered/path/projectService'; + const expectedParameters = { + project: 'projectValue', + service: 'serviceValue', + }; + const client = new notificationchannelserviceModule.v3.NotificationChannelServiceClient( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + client.pathTemplates.projectServicePathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.projectServicePathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('projectServicePath', () => { + const result = client.projectServicePath( + 'projectValue', + 'serviceValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.projectServicePathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromProjectServiceName', () => { + const result = client.matchProjectFromProjectServiceName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.projectServicePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchServiceFromProjectServiceName', () => { + const result = client.matchServiceFromProjectServiceName(fakePath); + assert.strictEqual(result, 'serviceValue'); + assert( + (client.pathTemplates.projectServicePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('projectServiceServiceLevelObjective', () => { + const fakePath = '/rendered/path/projectServiceServiceLevelObjective'; + const expectedParameters = { + project: 'projectValue', + service: 'serviceValue', + service_level_objective: 'serviceLevelObjectiveValue', + }; + const client = new notificationchannelserviceModule.v3.NotificationChannelServiceClient( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + client.pathTemplates.projectServiceServiceLevelObjectivePathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.projectServiceServiceLevelObjectivePathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('projectServiceServiceLevelObjectivePath', () => { + const result = client.projectServiceServiceLevelObjectivePath( + 'projectValue', + 'serviceValue', + 'serviceLevelObjectiveValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.projectServiceServiceLevelObjectivePathTemplate + .render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromProjectServiceServiceLevelObjectiveName', () => { + const result = client.matchProjectFromProjectServiceServiceLevelObjectiveName( + fakePath + ); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.projectServiceServiceLevelObjectivePathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchServiceFromProjectServiceServiceLevelObjectiveName', () => { + const result = client.matchServiceFromProjectServiceServiceLevelObjectiveName( + fakePath + ); + assert.strictEqual(result, 'serviceValue'); + assert( + (client.pathTemplates.projectServiceServiceLevelObjectivePathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchServiceLevelObjectiveFromProjectServiceServiceLevelObjectiveName', () => { + const result = client.matchServiceLevelObjectiveFromProjectServiceServiceLevelObjectiveName( + fakePath + ); + assert.strictEqual(result, 'serviceLevelObjectiveValue'); + assert( + (client.pathTemplates.projectServiceServiceLevelObjectivePathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('projectUptimeCheckConfig', () => { + const fakePath = '/rendered/path/projectUptimeCheckConfig'; + const expectedParameters = { + project: 'projectValue', + uptime_check_config: 'uptimeCheckConfigValue', + }; + const client = new notificationchannelserviceModule.v3.NotificationChannelServiceClient( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + client.pathTemplates.projectUptimeCheckConfigPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.projectUptimeCheckConfigPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('projectUptimeCheckConfigPath', () => { + const result = client.projectUptimeCheckConfigPath( + 'projectValue', + 'uptimeCheckConfigValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.projectUptimeCheckConfigPathTemplate + .render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromProjectUptimeCheckConfigName', () => { + const result = client.matchProjectFromProjectUptimeCheckConfigName( + fakePath + ); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.projectUptimeCheckConfigPathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchUptimeCheckConfigFromProjectUptimeCheckConfigName', () => { + const result = client.matchUptimeCheckConfigFromProjectUptimeCheckConfigName( + fakePath + ); + assert.strictEqual(result, 'uptimeCheckConfigValue'); + assert( + (client.pathTemplates.projectUptimeCheckConfigPathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + }); +}); diff --git a/packages/google-cloud-monitoring/test/gapic_service_monitoring_service_v3.ts b/packages/google-cloud-monitoring/test/gapic_service_monitoring_service_v3.ts new file mode 100644 index 00000000000..ab41526c84d --- /dev/null +++ b/packages/google-cloud-monitoring/test/gapic_service_monitoring_service_v3.ts @@ -0,0 +1,3379 @@ +// Copyright 2020 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +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 * as servicemonitoringserviceModule from '../src'; + +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; +} + +function stubSimpleCall(response?: ResponseType, error?: Error) { + 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 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(); + }); + } + 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); +} + +describe('v3.ServiceMonitoringServiceClient', () => { + it('has servicePath', () => { + const servicePath = + servicemonitoringserviceModule.v3.ServiceMonitoringServiceClient + .servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = + servicemonitoringserviceModule.v3.ServiceMonitoringServiceClient + .apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = + servicemonitoringserviceModule.v3.ServiceMonitoringServiceClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new servicemonitoringserviceModule.v3.ServiceMonitoringServiceClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new servicemonitoringserviceModule.v3.ServiceMonitoringServiceClient( + { + fallback: true, + } + ); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new servicemonitoringserviceModule.v3.ServiceMonitoringServiceClient( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + assert.strictEqual(client.serviceMonitoringServiceStub, undefined); + await client.initialize(); + assert(client.serviceMonitoringServiceStub); + }); + + it('has close method', () => { + const client = new servicemonitoringserviceModule.v3.ServiceMonitoringServiceClient( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.close(); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new servicemonitoringserviceModule.v3.ServiceMonitoringServiceClient( + { + 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 servicemonitoringserviceModule.v3.ServiceMonitoringServiceClient( + { + 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('createService', () => { + it('invokes createService without error', async () => { + const client = new servicemonitoringserviceModule.v3.ServiceMonitoringServiceClient( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + const request = generateSampleMessage( + new protos.google.monitoring.v3.CreateServiceRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.monitoring.v3.Service() + ); + client.innerApiCalls.createService = stubSimpleCall(expectedResponse); + const [response] = await client.createService(request); + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.createService as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + + it('invokes createService without error using callback', async () => { + const client = new servicemonitoringserviceModule.v3.ServiceMonitoringServiceClient( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + const request = generateSampleMessage( + new protos.google.monitoring.v3.CreateServiceRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.monitoring.v3.Service() + ); + client.innerApiCalls.createService = stubSimpleCallWithCallback( + expectedResponse + ); + const promise = new Promise((resolve, reject) => { + client.createService( + request, + ( + err?: Error | null, + result?: protos.google.monitoring.v3.IService | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.createService as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions /*, callback defined above */) + ); + }); + + it('invokes createService with error', async () => { + const client = new servicemonitoringserviceModule.v3.ServiceMonitoringServiceClient( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + const request = generateSampleMessage( + new protos.google.monitoring.v3.CreateServiceRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.createService = stubSimpleCall( + undefined, + expectedError + ); + assert.rejects(async () => { + await client.createService(request); + }, expectedError); + assert( + (client.innerApiCalls.createService as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + }); + + describe('getService', () => { + it('invokes getService without error', async () => { + const client = new servicemonitoringserviceModule.v3.ServiceMonitoringServiceClient( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + const request = generateSampleMessage( + new protos.google.monitoring.v3.GetServiceRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.monitoring.v3.Service() + ); + client.innerApiCalls.getService = stubSimpleCall(expectedResponse); + const [response] = await client.getService(request); + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.getService as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + + it('invokes getService without error using callback', async () => { + const client = new servicemonitoringserviceModule.v3.ServiceMonitoringServiceClient( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + const request = generateSampleMessage( + new protos.google.monitoring.v3.GetServiceRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.monitoring.v3.Service() + ); + client.innerApiCalls.getService = stubSimpleCallWithCallback( + expectedResponse + ); + const promise = new Promise((resolve, reject) => { + client.getService( + request, + ( + err?: Error | null, + result?: protos.google.monitoring.v3.IService | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.getService as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions /*, callback defined above */) + ); + }); + + it('invokes getService with error', async () => { + const client = new servicemonitoringserviceModule.v3.ServiceMonitoringServiceClient( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + const request = generateSampleMessage( + new protos.google.monitoring.v3.GetServiceRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.getService = stubSimpleCall( + undefined, + expectedError + ); + assert.rejects(async () => { + await client.getService(request); + }, expectedError); + assert( + (client.innerApiCalls.getService as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + }); + + describe('updateService', () => { + it('invokes updateService without error', async () => { + const client = new servicemonitoringserviceModule.v3.ServiceMonitoringServiceClient( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + const request = generateSampleMessage( + new protos.google.monitoring.v3.UpdateServiceRequest() + ); + request.service = {}; + request.service.name = ''; + const expectedHeaderRequestParams = 'service.name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.monitoring.v3.Service() + ); + client.innerApiCalls.updateService = stubSimpleCall(expectedResponse); + const [response] = await client.updateService(request); + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.updateService as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + + it('invokes updateService without error using callback', async () => { + const client = new servicemonitoringserviceModule.v3.ServiceMonitoringServiceClient( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + const request = generateSampleMessage( + new protos.google.monitoring.v3.UpdateServiceRequest() + ); + request.service = {}; + request.service.name = ''; + const expectedHeaderRequestParams = 'service.name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.monitoring.v3.Service() + ); + client.innerApiCalls.updateService = stubSimpleCallWithCallback( + expectedResponse + ); + const promise = new Promise((resolve, reject) => { + client.updateService( + request, + ( + err?: Error | null, + result?: protos.google.monitoring.v3.IService | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.updateService as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions /*, callback defined above */) + ); + }); + + it('invokes updateService with error', async () => { + const client = new servicemonitoringserviceModule.v3.ServiceMonitoringServiceClient( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + const request = generateSampleMessage( + new protos.google.monitoring.v3.UpdateServiceRequest() + ); + request.service = {}; + request.service.name = ''; + const expectedHeaderRequestParams = 'service.name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.updateService = stubSimpleCall( + undefined, + expectedError + ); + assert.rejects(async () => { + await client.updateService(request); + }, expectedError); + assert( + (client.innerApiCalls.updateService as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + }); + + describe('deleteService', () => { + it('invokes deleteService without error', async () => { + const client = new servicemonitoringserviceModule.v3.ServiceMonitoringServiceClient( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + const request = generateSampleMessage( + new protos.google.monitoring.v3.DeleteServiceRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.deleteService = stubSimpleCall(expectedResponse); + const [response] = await client.deleteService(request); + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.deleteService as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + + it('invokes deleteService without error using callback', async () => { + const client = new servicemonitoringserviceModule.v3.ServiceMonitoringServiceClient( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + const request = generateSampleMessage( + new protos.google.monitoring.v3.DeleteServiceRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.deleteService = stubSimpleCallWithCallback( + expectedResponse + ); + const promise = new Promise((resolve, reject) => { + client.deleteService( + 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.deleteService as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions /*, callback defined above */) + ); + }); + + it('invokes deleteService with error', async () => { + const client = new servicemonitoringserviceModule.v3.ServiceMonitoringServiceClient( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + const request = generateSampleMessage( + new protos.google.monitoring.v3.DeleteServiceRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteService = stubSimpleCall( + undefined, + expectedError + ); + assert.rejects(async () => { + await client.deleteService(request); + }, expectedError); + assert( + (client.innerApiCalls.deleteService as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + }); + + describe('createServiceLevelObjective', () => { + it('invokes createServiceLevelObjective without error', async () => { + const client = new servicemonitoringserviceModule.v3.ServiceMonitoringServiceClient( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + const request = generateSampleMessage( + new protos.google.monitoring.v3.CreateServiceLevelObjectiveRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.monitoring.v3.ServiceLevelObjective() + ); + client.innerApiCalls.createServiceLevelObjective = stubSimpleCall( + expectedResponse + ); + const [response] = await client.createServiceLevelObjective(request); + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.createServiceLevelObjective as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + + it('invokes createServiceLevelObjective without error using callback', async () => { + const client = new servicemonitoringserviceModule.v3.ServiceMonitoringServiceClient( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + const request = generateSampleMessage( + new protos.google.monitoring.v3.CreateServiceLevelObjectiveRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.monitoring.v3.ServiceLevelObjective() + ); + client.innerApiCalls.createServiceLevelObjective = stubSimpleCallWithCallback( + expectedResponse + ); + const promise = new Promise((resolve, reject) => { + client.createServiceLevelObjective( + request, + ( + err?: Error | null, + result?: protos.google.monitoring.v3.IServiceLevelObjective | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.createServiceLevelObjective as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions /*, callback defined above */) + ); + }); + + it('invokes createServiceLevelObjective with error', async () => { + const client = new servicemonitoringserviceModule.v3.ServiceMonitoringServiceClient( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + const request = generateSampleMessage( + new protos.google.monitoring.v3.CreateServiceLevelObjectiveRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.createServiceLevelObjective = stubSimpleCall( + undefined, + expectedError + ); + assert.rejects(async () => { + await client.createServiceLevelObjective(request); + }, expectedError); + assert( + (client.innerApiCalls.createServiceLevelObjective as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + }); + + describe('getServiceLevelObjective', () => { + it('invokes getServiceLevelObjective without error', async () => { + const client = new servicemonitoringserviceModule.v3.ServiceMonitoringServiceClient( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + const request = generateSampleMessage( + new protos.google.monitoring.v3.GetServiceLevelObjectiveRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.monitoring.v3.ServiceLevelObjective() + ); + client.innerApiCalls.getServiceLevelObjective = stubSimpleCall( + expectedResponse + ); + const [response] = await client.getServiceLevelObjective(request); + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.getServiceLevelObjective as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + + it('invokes getServiceLevelObjective without error using callback', async () => { + const client = new servicemonitoringserviceModule.v3.ServiceMonitoringServiceClient( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + const request = generateSampleMessage( + new protos.google.monitoring.v3.GetServiceLevelObjectiveRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.monitoring.v3.ServiceLevelObjective() + ); + client.innerApiCalls.getServiceLevelObjective = stubSimpleCallWithCallback( + expectedResponse + ); + const promise = new Promise((resolve, reject) => { + client.getServiceLevelObjective( + request, + ( + err?: Error | null, + result?: protos.google.monitoring.v3.IServiceLevelObjective | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.getServiceLevelObjective as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions /*, callback defined above */) + ); + }); + + it('invokes getServiceLevelObjective with error', async () => { + const client = new servicemonitoringserviceModule.v3.ServiceMonitoringServiceClient( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + const request = generateSampleMessage( + new protos.google.monitoring.v3.GetServiceLevelObjectiveRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.getServiceLevelObjective = stubSimpleCall( + undefined, + expectedError + ); + assert.rejects(async () => { + await client.getServiceLevelObjective(request); + }, expectedError); + assert( + (client.innerApiCalls.getServiceLevelObjective as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + }); + + describe('updateServiceLevelObjective', () => { + it('invokes updateServiceLevelObjective without error', async () => { + const client = new servicemonitoringserviceModule.v3.ServiceMonitoringServiceClient( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + const request = generateSampleMessage( + new protos.google.monitoring.v3.UpdateServiceLevelObjectiveRequest() + ); + request.serviceLevelObjective = {}; + request.serviceLevelObjective.name = ''; + const expectedHeaderRequestParams = 'service_level_objective.name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.monitoring.v3.ServiceLevelObjective() + ); + client.innerApiCalls.updateServiceLevelObjective = stubSimpleCall( + expectedResponse + ); + const [response] = await client.updateServiceLevelObjective(request); + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.updateServiceLevelObjective as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + + it('invokes updateServiceLevelObjective without error using callback', async () => { + const client = new servicemonitoringserviceModule.v3.ServiceMonitoringServiceClient( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + const request = generateSampleMessage( + new protos.google.monitoring.v3.UpdateServiceLevelObjectiveRequest() + ); + request.serviceLevelObjective = {}; + request.serviceLevelObjective.name = ''; + const expectedHeaderRequestParams = 'service_level_objective.name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.monitoring.v3.ServiceLevelObjective() + ); + client.innerApiCalls.updateServiceLevelObjective = stubSimpleCallWithCallback( + expectedResponse + ); + const promise = new Promise((resolve, reject) => { + client.updateServiceLevelObjective( + request, + ( + err?: Error | null, + result?: protos.google.monitoring.v3.IServiceLevelObjective | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.updateServiceLevelObjective as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions /*, callback defined above */) + ); + }); + + it('invokes updateServiceLevelObjective with error', async () => { + const client = new servicemonitoringserviceModule.v3.ServiceMonitoringServiceClient( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + const request = generateSampleMessage( + new protos.google.monitoring.v3.UpdateServiceLevelObjectiveRequest() + ); + request.serviceLevelObjective = {}; + request.serviceLevelObjective.name = ''; + const expectedHeaderRequestParams = 'service_level_objective.name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.updateServiceLevelObjective = stubSimpleCall( + undefined, + expectedError + ); + assert.rejects(async () => { + await client.updateServiceLevelObjective(request); + }, expectedError); + assert( + (client.innerApiCalls.updateServiceLevelObjective as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + }); + + describe('deleteServiceLevelObjective', () => { + it('invokes deleteServiceLevelObjective without error', async () => { + const client = new servicemonitoringserviceModule.v3.ServiceMonitoringServiceClient( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + const request = generateSampleMessage( + new protos.google.monitoring.v3.DeleteServiceLevelObjectiveRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.deleteServiceLevelObjective = stubSimpleCall( + expectedResponse + ); + const [response] = await client.deleteServiceLevelObjective(request); + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.deleteServiceLevelObjective as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + + it('invokes deleteServiceLevelObjective without error using callback', async () => { + const client = new servicemonitoringserviceModule.v3.ServiceMonitoringServiceClient( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + const request = generateSampleMessage( + new protos.google.monitoring.v3.DeleteServiceLevelObjectiveRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.deleteServiceLevelObjective = stubSimpleCallWithCallback( + expectedResponse + ); + const promise = new Promise((resolve, reject) => { + client.deleteServiceLevelObjective( + 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.deleteServiceLevelObjective as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions /*, callback defined above */) + ); + }); + + it('invokes deleteServiceLevelObjective with error', async () => { + const client = new servicemonitoringserviceModule.v3.ServiceMonitoringServiceClient( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + const request = generateSampleMessage( + new protos.google.monitoring.v3.DeleteServiceLevelObjectiveRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteServiceLevelObjective = stubSimpleCall( + undefined, + expectedError + ); + assert.rejects(async () => { + await client.deleteServiceLevelObjective(request); + }, expectedError); + assert( + (client.innerApiCalls.deleteServiceLevelObjective as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + }); + + describe('listServices', () => { + it('invokes listServices without error', async () => { + const client = new servicemonitoringserviceModule.v3.ServiceMonitoringServiceClient( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + const request = generateSampleMessage( + new protos.google.monitoring.v3.ListServicesRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage(new protos.google.monitoring.v3.Service()), + generateSampleMessage(new protos.google.monitoring.v3.Service()), + generateSampleMessage(new protos.google.monitoring.v3.Service()), + ]; + client.innerApiCalls.listServices = stubSimpleCall(expectedResponse); + const [response] = await client.listServices(request); + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.listServices as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + + it('invokes listServices without error using callback', async () => { + const client = new servicemonitoringserviceModule.v3.ServiceMonitoringServiceClient( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + const request = generateSampleMessage( + new protos.google.monitoring.v3.ListServicesRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage(new protos.google.monitoring.v3.Service()), + generateSampleMessage(new protos.google.monitoring.v3.Service()), + generateSampleMessage(new protos.google.monitoring.v3.Service()), + ]; + client.innerApiCalls.listServices = stubSimpleCallWithCallback( + expectedResponse + ); + const promise = new Promise((resolve, reject) => { + client.listServices( + request, + ( + err?: Error | null, + result?: protos.google.monitoring.v3.IService[] | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.listServices as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions /*, callback defined above */) + ); + }); + + it('invokes listServices with error', async () => { + const client = new servicemonitoringserviceModule.v3.ServiceMonitoringServiceClient( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + const request = generateSampleMessage( + new protos.google.monitoring.v3.ListServicesRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.listServices = stubSimpleCall( + undefined, + expectedError + ); + assert.rejects(async () => { + await client.listServices(request); + }, expectedError); + assert( + (client.innerApiCalls.listServices as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + + it('invokes listServicesStream without error', async () => { + const client = new servicemonitoringserviceModule.v3.ServiceMonitoringServiceClient( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + const request = generateSampleMessage( + new protos.google.monitoring.v3.ListServicesRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedResponse = [ + generateSampleMessage(new protos.google.monitoring.v3.Service()), + generateSampleMessage(new protos.google.monitoring.v3.Service()), + generateSampleMessage(new protos.google.monitoring.v3.Service()), + ]; + client.descriptors.page.listServices.createStream = stubPageStreamingCall( + expectedResponse + ); + const stream = client.listServicesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.monitoring.v3.Service[] = []; + stream.on('data', (response: protos.google.monitoring.v3.Service) => { + 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.listServices.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listServices, request) + ); + assert.strictEqual( + (client.descriptors.page.listServices + .createStream as SinonStub).getCall(0).args[2].otherArgs.headers[ + 'x-goog-request-params' + ], + expectedHeaderRequestParams + ); + }); + + it('invokes listServicesStream with error', async () => { + const client = new servicemonitoringserviceModule.v3.ServiceMonitoringServiceClient( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + const request = generateSampleMessage( + new protos.google.monitoring.v3.ListServicesRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedError = new Error('expected'); + client.descriptors.page.listServices.createStream = stubPageStreamingCall( + undefined, + expectedError + ); + const stream = client.listServicesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.monitoring.v3.Service[] = []; + stream.on('data', (response: protos.google.monitoring.v3.Service) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + assert.rejects(async () => { + await promise; + }, expectedError); + assert( + (client.descriptors.page.listServices.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listServices, request) + ); + assert.strictEqual( + (client.descriptors.page.listServices + .createStream as SinonStub).getCall(0).args[2].otherArgs.headers[ + 'x-goog-request-params' + ], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listServices without error', async () => { + const client = new servicemonitoringserviceModule.v3.ServiceMonitoringServiceClient( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + const request = generateSampleMessage( + new protos.google.monitoring.v3.ListServicesRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedResponse = [ + generateSampleMessage(new protos.google.monitoring.v3.Service()), + generateSampleMessage(new protos.google.monitoring.v3.Service()), + generateSampleMessage(new protos.google.monitoring.v3.Service()), + ]; + client.descriptors.page.listServices.asyncIterate = stubAsyncIterationCall( + expectedResponse + ); + const responses: protos.google.monitoring.v3.IService[] = []; + const iterable = client.listServicesAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listServices + .asyncIterate as SinonStub).getCall(0).args[1], + request + ); + assert.strictEqual( + (client.descriptors.page.listServices + .asyncIterate as SinonStub).getCall(0).args[2].otherArgs.headers[ + 'x-goog-request-params' + ], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listServices with error', async () => { + const client = new servicemonitoringserviceModule.v3.ServiceMonitoringServiceClient( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + const request = generateSampleMessage( + new protos.google.monitoring.v3.ListServicesRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedError = new Error('expected'); + client.descriptors.page.listServices.asyncIterate = stubAsyncIterationCall( + undefined, + expectedError + ); + const iterable = client.listServicesAsync(request); + assert.rejects(async () => { + const responses: protos.google.monitoring.v3.IService[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listServices + .asyncIterate as SinonStub).getCall(0).args[1], + request + ); + assert.strictEqual( + (client.descriptors.page.listServices + .asyncIterate as SinonStub).getCall(0).args[2].otherArgs.headers[ + 'x-goog-request-params' + ], + expectedHeaderRequestParams + ); + }); + }); + + describe('listServiceLevelObjectives', () => { + it('invokes listServiceLevelObjectives without error', async () => { + const client = new servicemonitoringserviceModule.v3.ServiceMonitoringServiceClient( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + const request = generateSampleMessage( + new protos.google.monitoring.v3.ListServiceLevelObjectivesRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage( + new protos.google.monitoring.v3.ServiceLevelObjective() + ), + generateSampleMessage( + new protos.google.monitoring.v3.ServiceLevelObjective() + ), + generateSampleMessage( + new protos.google.monitoring.v3.ServiceLevelObjective() + ), + ]; + client.innerApiCalls.listServiceLevelObjectives = stubSimpleCall( + expectedResponse + ); + const [response] = await client.listServiceLevelObjectives(request); + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.listServiceLevelObjectives as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + + it('invokes listServiceLevelObjectives without error using callback', async () => { + const client = new servicemonitoringserviceModule.v3.ServiceMonitoringServiceClient( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + const request = generateSampleMessage( + new protos.google.monitoring.v3.ListServiceLevelObjectivesRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage( + new protos.google.monitoring.v3.ServiceLevelObjective() + ), + generateSampleMessage( + new protos.google.monitoring.v3.ServiceLevelObjective() + ), + generateSampleMessage( + new protos.google.monitoring.v3.ServiceLevelObjective() + ), + ]; + client.innerApiCalls.listServiceLevelObjectives = stubSimpleCallWithCallback( + expectedResponse + ); + const promise = new Promise((resolve, reject) => { + client.listServiceLevelObjectives( + request, + ( + err?: Error | null, + result?: protos.google.monitoring.v3.IServiceLevelObjective[] | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.listServiceLevelObjectives as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions /*, callback defined above */) + ); + }); + + it('invokes listServiceLevelObjectives with error', async () => { + const client = new servicemonitoringserviceModule.v3.ServiceMonitoringServiceClient( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + const request = generateSampleMessage( + new protos.google.monitoring.v3.ListServiceLevelObjectivesRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.listServiceLevelObjectives = stubSimpleCall( + undefined, + expectedError + ); + assert.rejects(async () => { + await client.listServiceLevelObjectives(request); + }, expectedError); + assert( + (client.innerApiCalls.listServiceLevelObjectives as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + + it('invokes listServiceLevelObjectivesStream without error', async () => { + const client = new servicemonitoringserviceModule.v3.ServiceMonitoringServiceClient( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + const request = generateSampleMessage( + new protos.google.monitoring.v3.ListServiceLevelObjectivesRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedResponse = [ + generateSampleMessage( + new protos.google.monitoring.v3.ServiceLevelObjective() + ), + generateSampleMessage( + new protos.google.monitoring.v3.ServiceLevelObjective() + ), + generateSampleMessage( + new protos.google.monitoring.v3.ServiceLevelObjective() + ), + ]; + client.descriptors.page.listServiceLevelObjectives.createStream = stubPageStreamingCall( + expectedResponse + ); + const stream = client.listServiceLevelObjectivesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.monitoring.v3.ServiceLevelObjective[] = []; + stream.on( + 'data', + (response: protos.google.monitoring.v3.ServiceLevelObjective) => { + 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.listServiceLevelObjectives + .createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listServiceLevelObjectives, request) + ); + assert.strictEqual( + (client.descriptors.page.listServiceLevelObjectives + .createStream as SinonStub).getCall(0).args[2].otherArgs.headers[ + 'x-goog-request-params' + ], + expectedHeaderRequestParams + ); + }); + + it('invokes listServiceLevelObjectivesStream with error', async () => { + const client = new servicemonitoringserviceModule.v3.ServiceMonitoringServiceClient( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + const request = generateSampleMessage( + new protos.google.monitoring.v3.ListServiceLevelObjectivesRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedError = new Error('expected'); + client.descriptors.page.listServiceLevelObjectives.createStream = stubPageStreamingCall( + undefined, + expectedError + ); + const stream = client.listServiceLevelObjectivesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.monitoring.v3.ServiceLevelObjective[] = []; + stream.on( + 'data', + (response: protos.google.monitoring.v3.ServiceLevelObjective) => { + responses.push(response); + } + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + assert.rejects(async () => { + await promise; + }, expectedError); + assert( + (client.descriptors.page.listServiceLevelObjectives + .createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listServiceLevelObjectives, request) + ); + assert.strictEqual( + (client.descriptors.page.listServiceLevelObjectives + .createStream as SinonStub).getCall(0).args[2].otherArgs.headers[ + 'x-goog-request-params' + ], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listServiceLevelObjectives without error', async () => { + const client = new servicemonitoringserviceModule.v3.ServiceMonitoringServiceClient( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + const request = generateSampleMessage( + new protos.google.monitoring.v3.ListServiceLevelObjectivesRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedResponse = [ + generateSampleMessage( + new protos.google.monitoring.v3.ServiceLevelObjective() + ), + generateSampleMessage( + new protos.google.monitoring.v3.ServiceLevelObjective() + ), + generateSampleMessage( + new protos.google.monitoring.v3.ServiceLevelObjective() + ), + ]; + client.descriptors.page.listServiceLevelObjectives.asyncIterate = stubAsyncIterationCall( + expectedResponse + ); + const responses: protos.google.monitoring.v3.IServiceLevelObjective[] = []; + const iterable = client.listServiceLevelObjectivesAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listServiceLevelObjectives + .asyncIterate as SinonStub).getCall(0).args[1], + request + ); + assert.strictEqual( + (client.descriptors.page.listServiceLevelObjectives + .asyncIterate as SinonStub).getCall(0).args[2].otherArgs.headers[ + 'x-goog-request-params' + ], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listServiceLevelObjectives with error', async () => { + const client = new servicemonitoringserviceModule.v3.ServiceMonitoringServiceClient( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + const request = generateSampleMessage( + new protos.google.monitoring.v3.ListServiceLevelObjectivesRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedError = new Error('expected'); + client.descriptors.page.listServiceLevelObjectives.asyncIterate = stubAsyncIterationCall( + undefined, + expectedError + ); + const iterable = client.listServiceLevelObjectivesAsync(request); + assert.rejects(async () => { + const responses: protos.google.monitoring.v3.IServiceLevelObjective[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listServiceLevelObjectives + .asyncIterate as SinonStub).getCall(0).args[1], + request + ); + assert.strictEqual( + (client.descriptors.page.listServiceLevelObjectives + .asyncIterate as SinonStub).getCall(0).args[2].otherArgs.headers[ + 'x-goog-request-params' + ], + expectedHeaderRequestParams + ); + }); + }); + + describe('Path templates', () => { + describe('folderAlertPolicy', () => { + const fakePath = '/rendered/path/folderAlertPolicy'; + const expectedParameters = { + folder: 'folderValue', + alert_policy: 'alertPolicyValue', + }; + const client = new servicemonitoringserviceModule.v3.ServiceMonitoringServiceClient( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + client.pathTemplates.folderAlertPolicyPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.folderAlertPolicyPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('folderAlertPolicyPath', () => { + const result = client.folderAlertPolicyPath( + 'folderValue', + 'alertPolicyValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.folderAlertPolicyPathTemplate + .render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchFolderFromFolderAlertPolicyName', () => { + const result = client.matchFolderFromFolderAlertPolicyName(fakePath); + assert.strictEqual(result, 'folderValue'); + assert( + (client.pathTemplates.folderAlertPolicyPathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchAlertPolicyFromFolderAlertPolicyName', () => { + const result = client.matchAlertPolicyFromFolderAlertPolicyName( + fakePath + ); + assert.strictEqual(result, 'alertPolicyValue'); + assert( + (client.pathTemplates.folderAlertPolicyPathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('folderAlertPolicyCondition', () => { + const fakePath = '/rendered/path/folderAlertPolicyCondition'; + const expectedParameters = { + folder: 'folderValue', + alert_policy: 'alertPolicyValue', + condition: 'conditionValue', + }; + const client = new servicemonitoringserviceModule.v3.ServiceMonitoringServiceClient( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + client.pathTemplates.folderAlertPolicyConditionPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.folderAlertPolicyConditionPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('folderAlertPolicyConditionPath', () => { + const result = client.folderAlertPolicyConditionPath( + 'folderValue', + 'alertPolicyValue', + 'conditionValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.folderAlertPolicyConditionPathTemplate + .render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchFolderFromFolderAlertPolicyConditionName', () => { + const result = client.matchFolderFromFolderAlertPolicyConditionName( + fakePath + ); + assert.strictEqual(result, 'folderValue'); + assert( + (client.pathTemplates.folderAlertPolicyConditionPathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchAlertPolicyFromFolderAlertPolicyConditionName', () => { + const result = client.matchAlertPolicyFromFolderAlertPolicyConditionName( + fakePath + ); + assert.strictEqual(result, 'alertPolicyValue'); + assert( + (client.pathTemplates.folderAlertPolicyConditionPathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchConditionFromFolderAlertPolicyConditionName', () => { + const result = client.matchConditionFromFolderAlertPolicyConditionName( + fakePath + ); + assert.strictEqual(result, 'conditionValue'); + assert( + (client.pathTemplates.folderAlertPolicyConditionPathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('folderChannelDescriptor', () => { + const fakePath = '/rendered/path/folderChannelDescriptor'; + const expectedParameters = { + folder: 'folderValue', + channel_descriptor: 'channelDescriptorValue', + }; + const client = new servicemonitoringserviceModule.v3.ServiceMonitoringServiceClient( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + client.pathTemplates.folderChannelDescriptorPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.folderChannelDescriptorPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('folderChannelDescriptorPath', () => { + const result = client.folderChannelDescriptorPath( + 'folderValue', + 'channelDescriptorValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.folderChannelDescriptorPathTemplate + .render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchFolderFromFolderChannelDescriptorName', () => { + const result = client.matchFolderFromFolderChannelDescriptorName( + fakePath + ); + assert.strictEqual(result, 'folderValue'); + assert( + (client.pathTemplates.folderChannelDescriptorPathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchChannelDescriptorFromFolderChannelDescriptorName', () => { + const result = client.matchChannelDescriptorFromFolderChannelDescriptorName( + fakePath + ); + assert.strictEqual(result, 'channelDescriptorValue'); + assert( + (client.pathTemplates.folderChannelDescriptorPathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('folderGroup', () => { + const fakePath = '/rendered/path/folderGroup'; + const expectedParameters = { + folder: 'folderValue', + group: 'groupValue', + }; + const client = new servicemonitoringserviceModule.v3.ServiceMonitoringServiceClient( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + client.pathTemplates.folderGroupPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.folderGroupPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('folderGroupPath', () => { + const result = client.folderGroupPath('folderValue', 'groupValue'); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.folderGroupPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchFolderFromFolderGroupName', () => { + const result = client.matchFolderFromFolderGroupName(fakePath); + assert.strictEqual(result, 'folderValue'); + assert( + (client.pathTemplates.folderGroupPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchGroupFromFolderGroupName', () => { + const result = client.matchGroupFromFolderGroupName(fakePath); + assert.strictEqual(result, 'groupValue'); + assert( + (client.pathTemplates.folderGroupPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('folderNotificationChannel', () => { + const fakePath = '/rendered/path/folderNotificationChannel'; + const expectedParameters = { + folder: 'folderValue', + notification_channel: 'notificationChannelValue', + }; + const client = new servicemonitoringserviceModule.v3.ServiceMonitoringServiceClient( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + client.pathTemplates.folderNotificationChannelPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.folderNotificationChannelPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('folderNotificationChannelPath', () => { + const result = client.folderNotificationChannelPath( + 'folderValue', + 'notificationChannelValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.folderNotificationChannelPathTemplate + .render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchFolderFromFolderNotificationChannelName', () => { + const result = client.matchFolderFromFolderNotificationChannelName( + fakePath + ); + assert.strictEqual(result, 'folderValue'); + assert( + (client.pathTemplates.folderNotificationChannelPathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchNotificationChannelFromFolderNotificationChannelName', () => { + const result = client.matchNotificationChannelFromFolderNotificationChannelName( + fakePath + ); + assert.strictEqual(result, 'notificationChannelValue'); + assert( + (client.pathTemplates.folderNotificationChannelPathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('folderService', () => { + const fakePath = '/rendered/path/folderService'; + const expectedParameters = { + folder: 'folderValue', + service: 'serviceValue', + }; + const client = new servicemonitoringserviceModule.v3.ServiceMonitoringServiceClient( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + client.pathTemplates.folderServicePathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.folderServicePathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('folderServicePath', () => { + const result = client.folderServicePath('folderValue', 'serviceValue'); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.folderServicePathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchFolderFromFolderServiceName', () => { + const result = client.matchFolderFromFolderServiceName(fakePath); + assert.strictEqual(result, 'folderValue'); + assert( + (client.pathTemplates.folderServicePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchServiceFromFolderServiceName', () => { + const result = client.matchServiceFromFolderServiceName(fakePath); + assert.strictEqual(result, 'serviceValue'); + assert( + (client.pathTemplates.folderServicePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('folderServiceServiceLevelObjective', () => { + const fakePath = '/rendered/path/folderServiceServiceLevelObjective'; + const expectedParameters = { + folder: 'folderValue', + service: 'serviceValue', + service_level_objective: 'serviceLevelObjectiveValue', + }; + const client = new servicemonitoringserviceModule.v3.ServiceMonitoringServiceClient( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + client.pathTemplates.folderServiceServiceLevelObjectivePathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.folderServiceServiceLevelObjectivePathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('folderServiceServiceLevelObjectivePath', () => { + const result = client.folderServiceServiceLevelObjectivePath( + 'folderValue', + 'serviceValue', + 'serviceLevelObjectiveValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.folderServiceServiceLevelObjectivePathTemplate + .render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchFolderFromFolderServiceServiceLevelObjectiveName', () => { + const result = client.matchFolderFromFolderServiceServiceLevelObjectiveName( + fakePath + ); + assert.strictEqual(result, 'folderValue'); + assert( + (client.pathTemplates.folderServiceServiceLevelObjectivePathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchServiceFromFolderServiceServiceLevelObjectiveName', () => { + const result = client.matchServiceFromFolderServiceServiceLevelObjectiveName( + fakePath + ); + assert.strictEqual(result, 'serviceValue'); + assert( + (client.pathTemplates.folderServiceServiceLevelObjectivePathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchServiceLevelObjectiveFromFolderServiceServiceLevelObjectiveName', () => { + const result = client.matchServiceLevelObjectiveFromFolderServiceServiceLevelObjectiveName( + fakePath + ); + assert.strictEqual(result, 'serviceLevelObjectiveValue'); + assert( + (client.pathTemplates.folderServiceServiceLevelObjectivePathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('folderUptimeCheckConfig', () => { + const fakePath = '/rendered/path/folderUptimeCheckConfig'; + const expectedParameters = { + folder: 'folderValue', + uptime_check_config: 'uptimeCheckConfigValue', + }; + const client = new servicemonitoringserviceModule.v3.ServiceMonitoringServiceClient( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + client.pathTemplates.folderUptimeCheckConfigPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.folderUptimeCheckConfigPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('folderUptimeCheckConfigPath', () => { + const result = client.folderUptimeCheckConfigPath( + 'folderValue', + 'uptimeCheckConfigValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.folderUptimeCheckConfigPathTemplate + .render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchFolderFromFolderUptimeCheckConfigName', () => { + const result = client.matchFolderFromFolderUptimeCheckConfigName( + fakePath + ); + assert.strictEqual(result, 'folderValue'); + assert( + (client.pathTemplates.folderUptimeCheckConfigPathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchUptimeCheckConfigFromFolderUptimeCheckConfigName', () => { + const result = client.matchUptimeCheckConfigFromFolderUptimeCheckConfigName( + fakePath + ); + assert.strictEqual(result, 'uptimeCheckConfigValue'); + assert( + (client.pathTemplates.folderUptimeCheckConfigPathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('organizationAlertPolicy', () => { + const fakePath = '/rendered/path/organizationAlertPolicy'; + const expectedParameters = { + organization: 'organizationValue', + alert_policy: 'alertPolicyValue', + }; + const client = new servicemonitoringserviceModule.v3.ServiceMonitoringServiceClient( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + client.pathTemplates.organizationAlertPolicyPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.organizationAlertPolicyPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('organizationAlertPolicyPath', () => { + const result = client.organizationAlertPolicyPath( + 'organizationValue', + 'alertPolicyValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.organizationAlertPolicyPathTemplate + .render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchOrganizationFromOrganizationAlertPolicyName', () => { + const result = client.matchOrganizationFromOrganizationAlertPolicyName( + fakePath + ); + assert.strictEqual(result, 'organizationValue'); + assert( + (client.pathTemplates.organizationAlertPolicyPathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchAlertPolicyFromOrganizationAlertPolicyName', () => { + const result = client.matchAlertPolicyFromOrganizationAlertPolicyName( + fakePath + ); + assert.strictEqual(result, 'alertPolicyValue'); + assert( + (client.pathTemplates.organizationAlertPolicyPathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('organizationAlertPolicyCondition', () => { + const fakePath = '/rendered/path/organizationAlertPolicyCondition'; + const expectedParameters = { + organization: 'organizationValue', + alert_policy: 'alertPolicyValue', + condition: 'conditionValue', + }; + const client = new servicemonitoringserviceModule.v3.ServiceMonitoringServiceClient( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + client.pathTemplates.organizationAlertPolicyConditionPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.organizationAlertPolicyConditionPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('organizationAlertPolicyConditionPath', () => { + const result = client.organizationAlertPolicyConditionPath( + 'organizationValue', + 'alertPolicyValue', + 'conditionValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.organizationAlertPolicyConditionPathTemplate + .render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchOrganizationFromOrganizationAlertPolicyConditionName', () => { + const result = client.matchOrganizationFromOrganizationAlertPolicyConditionName( + fakePath + ); + assert.strictEqual(result, 'organizationValue'); + assert( + (client.pathTemplates.organizationAlertPolicyConditionPathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchAlertPolicyFromOrganizationAlertPolicyConditionName', () => { + const result = client.matchAlertPolicyFromOrganizationAlertPolicyConditionName( + fakePath + ); + assert.strictEqual(result, 'alertPolicyValue'); + assert( + (client.pathTemplates.organizationAlertPolicyConditionPathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchConditionFromOrganizationAlertPolicyConditionName', () => { + const result = client.matchConditionFromOrganizationAlertPolicyConditionName( + fakePath + ); + assert.strictEqual(result, 'conditionValue'); + assert( + (client.pathTemplates.organizationAlertPolicyConditionPathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('organizationChannelDescriptor', () => { + const fakePath = '/rendered/path/organizationChannelDescriptor'; + const expectedParameters = { + organization: 'organizationValue', + channel_descriptor: 'channelDescriptorValue', + }; + const client = new servicemonitoringserviceModule.v3.ServiceMonitoringServiceClient( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + client.pathTemplates.organizationChannelDescriptorPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.organizationChannelDescriptorPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('organizationChannelDescriptorPath', () => { + const result = client.organizationChannelDescriptorPath( + 'organizationValue', + 'channelDescriptorValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.organizationChannelDescriptorPathTemplate + .render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchOrganizationFromOrganizationChannelDescriptorName', () => { + const result = client.matchOrganizationFromOrganizationChannelDescriptorName( + fakePath + ); + assert.strictEqual(result, 'organizationValue'); + assert( + (client.pathTemplates.organizationChannelDescriptorPathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchChannelDescriptorFromOrganizationChannelDescriptorName', () => { + const result = client.matchChannelDescriptorFromOrganizationChannelDescriptorName( + fakePath + ); + assert.strictEqual(result, 'channelDescriptorValue'); + assert( + (client.pathTemplates.organizationChannelDescriptorPathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('organizationGroup', () => { + const fakePath = '/rendered/path/organizationGroup'; + const expectedParameters = { + organization: 'organizationValue', + group: 'groupValue', + }; + const client = new servicemonitoringserviceModule.v3.ServiceMonitoringServiceClient( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + client.pathTemplates.organizationGroupPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.organizationGroupPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('organizationGroupPath', () => { + const result = client.organizationGroupPath( + 'organizationValue', + 'groupValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.organizationGroupPathTemplate + .render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchOrganizationFromOrganizationGroupName', () => { + const result = client.matchOrganizationFromOrganizationGroupName( + fakePath + ); + assert.strictEqual(result, 'organizationValue'); + assert( + (client.pathTemplates.organizationGroupPathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchGroupFromOrganizationGroupName', () => { + const result = client.matchGroupFromOrganizationGroupName(fakePath); + assert.strictEqual(result, 'groupValue'); + assert( + (client.pathTemplates.organizationGroupPathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('organizationNotificationChannel', () => { + const fakePath = '/rendered/path/organizationNotificationChannel'; + const expectedParameters = { + organization: 'organizationValue', + notification_channel: 'notificationChannelValue', + }; + const client = new servicemonitoringserviceModule.v3.ServiceMonitoringServiceClient( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + client.pathTemplates.organizationNotificationChannelPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.organizationNotificationChannelPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('organizationNotificationChannelPath', () => { + const result = client.organizationNotificationChannelPath( + 'organizationValue', + 'notificationChannelValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.organizationNotificationChannelPathTemplate + .render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchOrganizationFromOrganizationNotificationChannelName', () => { + const result = client.matchOrganizationFromOrganizationNotificationChannelName( + fakePath + ); + assert.strictEqual(result, 'organizationValue'); + assert( + (client.pathTemplates.organizationNotificationChannelPathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchNotificationChannelFromOrganizationNotificationChannelName', () => { + const result = client.matchNotificationChannelFromOrganizationNotificationChannelName( + fakePath + ); + assert.strictEqual(result, 'notificationChannelValue'); + assert( + (client.pathTemplates.organizationNotificationChannelPathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('organizationService', () => { + const fakePath = '/rendered/path/organizationService'; + const expectedParameters = { + organization: 'organizationValue', + service: 'serviceValue', + }; + const client = new servicemonitoringserviceModule.v3.ServiceMonitoringServiceClient( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + client.pathTemplates.organizationServicePathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.organizationServicePathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('organizationServicePath', () => { + const result = client.organizationServicePath( + 'organizationValue', + 'serviceValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.organizationServicePathTemplate + .render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchOrganizationFromOrganizationServiceName', () => { + const result = client.matchOrganizationFromOrganizationServiceName( + fakePath + ); + assert.strictEqual(result, 'organizationValue'); + assert( + (client.pathTemplates.organizationServicePathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchServiceFromOrganizationServiceName', () => { + const result = client.matchServiceFromOrganizationServiceName(fakePath); + assert.strictEqual(result, 'serviceValue'); + assert( + (client.pathTemplates.organizationServicePathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('organizationServiceServiceLevelObjective', () => { + const fakePath = + '/rendered/path/organizationServiceServiceLevelObjective'; + const expectedParameters = { + organization: 'organizationValue', + service: 'serviceValue', + service_level_objective: 'serviceLevelObjectiveValue', + }; + const client = new servicemonitoringserviceModule.v3.ServiceMonitoringServiceClient( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + client.pathTemplates.organizationServiceServiceLevelObjectivePathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.organizationServiceServiceLevelObjectivePathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('organizationServiceServiceLevelObjectivePath', () => { + const result = client.organizationServiceServiceLevelObjectivePath( + 'organizationValue', + 'serviceValue', + 'serviceLevelObjectiveValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates + .organizationServiceServiceLevelObjectivePathTemplate + .render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchOrganizationFromOrganizationServiceServiceLevelObjectiveName', () => { + const result = client.matchOrganizationFromOrganizationServiceServiceLevelObjectiveName( + fakePath + ); + assert.strictEqual(result, 'organizationValue'); + assert( + (client.pathTemplates + .organizationServiceServiceLevelObjectivePathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchServiceFromOrganizationServiceServiceLevelObjectiveName', () => { + const result = client.matchServiceFromOrganizationServiceServiceLevelObjectiveName( + fakePath + ); + assert.strictEqual(result, 'serviceValue'); + assert( + (client.pathTemplates + .organizationServiceServiceLevelObjectivePathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchServiceLevelObjectiveFromOrganizationServiceServiceLevelObjectiveName', () => { + const result = client.matchServiceLevelObjectiveFromOrganizationServiceServiceLevelObjectiveName( + fakePath + ); + assert.strictEqual(result, 'serviceLevelObjectiveValue'); + assert( + (client.pathTemplates + .organizationServiceServiceLevelObjectivePathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('organizationUptimeCheckConfig', () => { + const fakePath = '/rendered/path/organizationUptimeCheckConfig'; + const expectedParameters = { + organization: 'organizationValue', + uptime_check_config: 'uptimeCheckConfigValue', + }; + const client = new servicemonitoringserviceModule.v3.ServiceMonitoringServiceClient( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + client.pathTemplates.organizationUptimeCheckConfigPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.organizationUptimeCheckConfigPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('organizationUptimeCheckConfigPath', () => { + const result = client.organizationUptimeCheckConfigPath( + 'organizationValue', + 'uptimeCheckConfigValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.organizationUptimeCheckConfigPathTemplate + .render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchOrganizationFromOrganizationUptimeCheckConfigName', () => { + const result = client.matchOrganizationFromOrganizationUptimeCheckConfigName( + fakePath + ); + assert.strictEqual(result, 'organizationValue'); + assert( + (client.pathTemplates.organizationUptimeCheckConfigPathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchUptimeCheckConfigFromOrganizationUptimeCheckConfigName', () => { + const result = client.matchUptimeCheckConfigFromOrganizationUptimeCheckConfigName( + fakePath + ); + assert.strictEqual(result, 'uptimeCheckConfigValue'); + assert( + (client.pathTemplates.organizationUptimeCheckConfigPathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('project', () => { + const fakePath = '/rendered/path/project'; + const expectedParameters = { + project: 'projectValue', + }; + const client = new servicemonitoringserviceModule.v3.ServiceMonitoringServiceClient( + { + 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('matchProjectFromProjectName', () => { + const result = client.matchProjectFromProjectName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.projectPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('projectAlertPolicy', () => { + const fakePath = '/rendered/path/projectAlertPolicy'; + const expectedParameters = { + project: 'projectValue', + alert_policy: 'alertPolicyValue', + }; + const client = new servicemonitoringserviceModule.v3.ServiceMonitoringServiceClient( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + client.pathTemplates.projectAlertPolicyPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.projectAlertPolicyPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('projectAlertPolicyPath', () => { + const result = client.projectAlertPolicyPath( + 'projectValue', + 'alertPolicyValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.projectAlertPolicyPathTemplate + .render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromProjectAlertPolicyName', () => { + const result = client.matchProjectFromProjectAlertPolicyName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.projectAlertPolicyPathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchAlertPolicyFromProjectAlertPolicyName', () => { + const result = client.matchAlertPolicyFromProjectAlertPolicyName( + fakePath + ); + assert.strictEqual(result, 'alertPolicyValue'); + assert( + (client.pathTemplates.projectAlertPolicyPathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('projectAlertPolicyCondition', () => { + const fakePath = '/rendered/path/projectAlertPolicyCondition'; + const expectedParameters = { + project: 'projectValue', + alert_policy: 'alertPolicyValue', + condition: 'conditionValue', + }; + const client = new servicemonitoringserviceModule.v3.ServiceMonitoringServiceClient( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + client.pathTemplates.projectAlertPolicyConditionPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.projectAlertPolicyConditionPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('projectAlertPolicyConditionPath', () => { + const result = client.projectAlertPolicyConditionPath( + 'projectValue', + 'alertPolicyValue', + 'conditionValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.projectAlertPolicyConditionPathTemplate + .render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromProjectAlertPolicyConditionName', () => { + const result = client.matchProjectFromProjectAlertPolicyConditionName( + fakePath + ); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.projectAlertPolicyConditionPathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchAlertPolicyFromProjectAlertPolicyConditionName', () => { + const result = client.matchAlertPolicyFromProjectAlertPolicyConditionName( + fakePath + ); + assert.strictEqual(result, 'alertPolicyValue'); + assert( + (client.pathTemplates.projectAlertPolicyConditionPathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchConditionFromProjectAlertPolicyConditionName', () => { + const result = client.matchConditionFromProjectAlertPolicyConditionName( + fakePath + ); + assert.strictEqual(result, 'conditionValue'); + assert( + (client.pathTemplates.projectAlertPolicyConditionPathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('projectChannelDescriptor', () => { + const fakePath = '/rendered/path/projectChannelDescriptor'; + const expectedParameters = { + project: 'projectValue', + channel_descriptor: 'channelDescriptorValue', + }; + const client = new servicemonitoringserviceModule.v3.ServiceMonitoringServiceClient( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + client.pathTemplates.projectChannelDescriptorPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.projectChannelDescriptorPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('projectChannelDescriptorPath', () => { + const result = client.projectChannelDescriptorPath( + 'projectValue', + 'channelDescriptorValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.projectChannelDescriptorPathTemplate + .render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromProjectChannelDescriptorName', () => { + const result = client.matchProjectFromProjectChannelDescriptorName( + fakePath + ); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.projectChannelDescriptorPathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchChannelDescriptorFromProjectChannelDescriptorName', () => { + const result = client.matchChannelDescriptorFromProjectChannelDescriptorName( + fakePath + ); + assert.strictEqual(result, 'channelDescriptorValue'); + assert( + (client.pathTemplates.projectChannelDescriptorPathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('projectGroup', () => { + const fakePath = '/rendered/path/projectGroup'; + const expectedParameters = { + project: 'projectValue', + group: 'groupValue', + }; + const client = new servicemonitoringserviceModule.v3.ServiceMonitoringServiceClient( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + client.pathTemplates.projectGroupPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.projectGroupPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('projectGroupPath', () => { + const result = client.projectGroupPath('projectValue', 'groupValue'); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.projectGroupPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromProjectGroupName', () => { + const result = client.matchProjectFromProjectGroupName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.projectGroupPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchGroupFromProjectGroupName', () => { + const result = client.matchGroupFromProjectGroupName(fakePath); + assert.strictEqual(result, 'groupValue'); + assert( + (client.pathTemplates.projectGroupPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('projectNotificationChannel', () => { + const fakePath = '/rendered/path/projectNotificationChannel'; + const expectedParameters = { + project: 'projectValue', + notification_channel: 'notificationChannelValue', + }; + const client = new servicemonitoringserviceModule.v3.ServiceMonitoringServiceClient( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + client.pathTemplates.projectNotificationChannelPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.projectNotificationChannelPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('projectNotificationChannelPath', () => { + const result = client.projectNotificationChannelPath( + 'projectValue', + 'notificationChannelValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.projectNotificationChannelPathTemplate + .render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromProjectNotificationChannelName', () => { + const result = client.matchProjectFromProjectNotificationChannelName( + fakePath + ); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.projectNotificationChannelPathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchNotificationChannelFromProjectNotificationChannelName', () => { + const result = client.matchNotificationChannelFromProjectNotificationChannelName( + fakePath + ); + assert.strictEqual(result, 'notificationChannelValue'); + assert( + (client.pathTemplates.projectNotificationChannelPathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('projectService', () => { + const fakePath = '/rendered/path/projectService'; + const expectedParameters = { + project: 'projectValue', + service: 'serviceValue', + }; + const client = new servicemonitoringserviceModule.v3.ServiceMonitoringServiceClient( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + client.pathTemplates.projectServicePathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.projectServicePathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('projectServicePath', () => { + const result = client.projectServicePath( + 'projectValue', + 'serviceValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.projectServicePathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromProjectServiceName', () => { + const result = client.matchProjectFromProjectServiceName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.projectServicePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchServiceFromProjectServiceName', () => { + const result = client.matchServiceFromProjectServiceName(fakePath); + assert.strictEqual(result, 'serviceValue'); + assert( + (client.pathTemplates.projectServicePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('projectServiceServiceLevelObjective', () => { + const fakePath = '/rendered/path/projectServiceServiceLevelObjective'; + const expectedParameters = { + project: 'projectValue', + service: 'serviceValue', + service_level_objective: 'serviceLevelObjectiveValue', + }; + const client = new servicemonitoringserviceModule.v3.ServiceMonitoringServiceClient( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + client.pathTemplates.projectServiceServiceLevelObjectivePathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.projectServiceServiceLevelObjectivePathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('projectServiceServiceLevelObjectivePath', () => { + const result = client.projectServiceServiceLevelObjectivePath( + 'projectValue', + 'serviceValue', + 'serviceLevelObjectiveValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.projectServiceServiceLevelObjectivePathTemplate + .render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromProjectServiceServiceLevelObjectiveName', () => { + const result = client.matchProjectFromProjectServiceServiceLevelObjectiveName( + fakePath + ); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.projectServiceServiceLevelObjectivePathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchServiceFromProjectServiceServiceLevelObjectiveName', () => { + const result = client.matchServiceFromProjectServiceServiceLevelObjectiveName( + fakePath + ); + assert.strictEqual(result, 'serviceValue'); + assert( + (client.pathTemplates.projectServiceServiceLevelObjectivePathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchServiceLevelObjectiveFromProjectServiceServiceLevelObjectiveName', () => { + const result = client.matchServiceLevelObjectiveFromProjectServiceServiceLevelObjectiveName( + fakePath + ); + assert.strictEqual(result, 'serviceLevelObjectiveValue'); + assert( + (client.pathTemplates.projectServiceServiceLevelObjectivePathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('projectUptimeCheckConfig', () => { + const fakePath = '/rendered/path/projectUptimeCheckConfig'; + const expectedParameters = { + project: 'projectValue', + uptime_check_config: 'uptimeCheckConfigValue', + }; + const client = new servicemonitoringserviceModule.v3.ServiceMonitoringServiceClient( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + client.pathTemplates.projectUptimeCheckConfigPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.projectUptimeCheckConfigPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('projectUptimeCheckConfigPath', () => { + const result = client.projectUptimeCheckConfigPath( + 'projectValue', + 'uptimeCheckConfigValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.projectUptimeCheckConfigPathTemplate + .render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromProjectUptimeCheckConfigName', () => { + const result = client.matchProjectFromProjectUptimeCheckConfigName( + fakePath + ); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.projectUptimeCheckConfigPathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchUptimeCheckConfigFromProjectUptimeCheckConfigName', () => { + const result = client.matchUptimeCheckConfigFromProjectUptimeCheckConfigName( + fakePath + ); + assert.strictEqual(result, 'uptimeCheckConfigValue'); + assert( + (client.pathTemplates.projectUptimeCheckConfigPathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + }); +}); diff --git a/packages/google-cloud-monitoring/test/gapic_uptime_check_service_v3.ts b/packages/google-cloud-monitoring/test/gapic_uptime_check_service_v3.ts new file mode 100644 index 00000000000..494d1d134cc --- /dev/null +++ b/packages/google-cloud-monitoring/test/gapic_uptime_check_service_v3.ts @@ -0,0 +1,2729 @@ +// Copyright 2020 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +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 * as uptimecheckserviceModule from '../src'; + +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; +} + +function stubSimpleCall(response?: ResponseType, error?: Error) { + 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 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(); + }); + } + 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); +} + +describe('v3.UptimeCheckServiceClient', () => { + it('has servicePath', () => { + const servicePath = + uptimecheckserviceModule.v3.UptimeCheckServiceClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = + uptimecheckserviceModule.v3.UptimeCheckServiceClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = uptimecheckserviceModule.v3.UptimeCheckServiceClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new uptimecheckserviceModule.v3.UptimeCheckServiceClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new uptimecheckserviceModule.v3.UptimeCheckServiceClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new uptimecheckserviceModule.v3.UptimeCheckServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.uptimeCheckServiceStub, undefined); + await client.initialize(); + assert(client.uptimeCheckServiceStub); + }); + + it('has close method', () => { + const client = new uptimecheckserviceModule.v3.UptimeCheckServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.close(); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new uptimecheckserviceModule.v3.UptimeCheckServiceClient({ + 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 uptimecheckserviceModule.v3.UptimeCheckServiceClient({ + 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('getUptimeCheckConfig', () => { + it('invokes getUptimeCheckConfig without error', async () => { + const client = new uptimecheckserviceModule.v3.UptimeCheckServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.monitoring.v3.GetUptimeCheckConfigRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.monitoring.v3.UptimeCheckConfig() + ); + client.innerApiCalls.getUptimeCheckConfig = stubSimpleCall( + expectedResponse + ); + const [response] = await client.getUptimeCheckConfig(request); + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.getUptimeCheckConfig as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + + it('invokes getUptimeCheckConfig without error using callback', async () => { + const client = new uptimecheckserviceModule.v3.UptimeCheckServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.monitoring.v3.GetUptimeCheckConfigRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.monitoring.v3.UptimeCheckConfig() + ); + client.innerApiCalls.getUptimeCheckConfig = stubSimpleCallWithCallback( + expectedResponse + ); + const promise = new Promise((resolve, reject) => { + client.getUptimeCheckConfig( + request, + ( + err?: Error | null, + result?: protos.google.monitoring.v3.IUptimeCheckConfig | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.getUptimeCheckConfig as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions /*, callback defined above */) + ); + }); + + it('invokes getUptimeCheckConfig with error', async () => { + const client = new uptimecheckserviceModule.v3.UptimeCheckServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.monitoring.v3.GetUptimeCheckConfigRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.getUptimeCheckConfig = stubSimpleCall( + undefined, + expectedError + ); + assert.rejects(async () => { + await client.getUptimeCheckConfig(request); + }, expectedError); + assert( + (client.innerApiCalls.getUptimeCheckConfig as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + }); + + describe('createUptimeCheckConfig', () => { + it('invokes createUptimeCheckConfig without error', async () => { + const client = new uptimecheckserviceModule.v3.UptimeCheckServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.monitoring.v3.CreateUptimeCheckConfigRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.monitoring.v3.UptimeCheckConfig() + ); + client.innerApiCalls.createUptimeCheckConfig = stubSimpleCall( + expectedResponse + ); + const [response] = await client.createUptimeCheckConfig(request); + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.createUptimeCheckConfig as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + + it('invokes createUptimeCheckConfig without error using callback', async () => { + const client = new uptimecheckserviceModule.v3.UptimeCheckServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.monitoring.v3.CreateUptimeCheckConfigRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.monitoring.v3.UptimeCheckConfig() + ); + client.innerApiCalls.createUptimeCheckConfig = stubSimpleCallWithCallback( + expectedResponse + ); + const promise = new Promise((resolve, reject) => { + client.createUptimeCheckConfig( + request, + ( + err?: Error | null, + result?: protos.google.monitoring.v3.IUptimeCheckConfig | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.createUptimeCheckConfig as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions /*, callback defined above */) + ); + }); + + it('invokes createUptimeCheckConfig with error', async () => { + const client = new uptimecheckserviceModule.v3.UptimeCheckServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.monitoring.v3.CreateUptimeCheckConfigRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.createUptimeCheckConfig = stubSimpleCall( + undefined, + expectedError + ); + assert.rejects(async () => { + await client.createUptimeCheckConfig(request); + }, expectedError); + assert( + (client.innerApiCalls.createUptimeCheckConfig as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + }); + + describe('updateUptimeCheckConfig', () => { + it('invokes updateUptimeCheckConfig without error', async () => { + const client = new uptimecheckserviceModule.v3.UptimeCheckServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.monitoring.v3.UpdateUptimeCheckConfigRequest() + ); + request.uptimeCheckConfig = {}; + request.uptimeCheckConfig.name = ''; + const expectedHeaderRequestParams = 'uptime_check_config.name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.monitoring.v3.UptimeCheckConfig() + ); + client.innerApiCalls.updateUptimeCheckConfig = stubSimpleCall( + expectedResponse + ); + const [response] = await client.updateUptimeCheckConfig(request); + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.updateUptimeCheckConfig as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + + it('invokes updateUptimeCheckConfig without error using callback', async () => { + const client = new uptimecheckserviceModule.v3.UptimeCheckServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.monitoring.v3.UpdateUptimeCheckConfigRequest() + ); + request.uptimeCheckConfig = {}; + request.uptimeCheckConfig.name = ''; + const expectedHeaderRequestParams = 'uptime_check_config.name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.monitoring.v3.UptimeCheckConfig() + ); + client.innerApiCalls.updateUptimeCheckConfig = stubSimpleCallWithCallback( + expectedResponse + ); + const promise = new Promise((resolve, reject) => { + client.updateUptimeCheckConfig( + request, + ( + err?: Error | null, + result?: protos.google.monitoring.v3.IUptimeCheckConfig | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.updateUptimeCheckConfig as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions /*, callback defined above */) + ); + }); + + it('invokes updateUptimeCheckConfig with error', async () => { + const client = new uptimecheckserviceModule.v3.UptimeCheckServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.monitoring.v3.UpdateUptimeCheckConfigRequest() + ); + request.uptimeCheckConfig = {}; + request.uptimeCheckConfig.name = ''; + const expectedHeaderRequestParams = 'uptime_check_config.name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.updateUptimeCheckConfig = stubSimpleCall( + undefined, + expectedError + ); + assert.rejects(async () => { + await client.updateUptimeCheckConfig(request); + }, expectedError); + assert( + (client.innerApiCalls.updateUptimeCheckConfig as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + }); + + describe('deleteUptimeCheckConfig', () => { + it('invokes deleteUptimeCheckConfig without error', async () => { + const client = new uptimecheckserviceModule.v3.UptimeCheckServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.monitoring.v3.DeleteUptimeCheckConfigRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.deleteUptimeCheckConfig = stubSimpleCall( + expectedResponse + ); + const [response] = await client.deleteUptimeCheckConfig(request); + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.deleteUptimeCheckConfig as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + + it('invokes deleteUptimeCheckConfig without error using callback', async () => { + const client = new uptimecheckserviceModule.v3.UptimeCheckServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.monitoring.v3.DeleteUptimeCheckConfigRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.deleteUptimeCheckConfig = stubSimpleCallWithCallback( + expectedResponse + ); + const promise = new Promise((resolve, reject) => { + client.deleteUptimeCheckConfig( + 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.deleteUptimeCheckConfig as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions /*, callback defined above */) + ); + }); + + it('invokes deleteUptimeCheckConfig with error', async () => { + const client = new uptimecheckserviceModule.v3.UptimeCheckServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.monitoring.v3.DeleteUptimeCheckConfigRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteUptimeCheckConfig = stubSimpleCall( + undefined, + expectedError + ); + assert.rejects(async () => { + await client.deleteUptimeCheckConfig(request); + }, expectedError); + assert( + (client.innerApiCalls.deleteUptimeCheckConfig as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + }); + + describe('listUptimeCheckConfigs', () => { + it('invokes listUptimeCheckConfigs without error', async () => { + const client = new uptimecheckserviceModule.v3.UptimeCheckServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.monitoring.v3.ListUptimeCheckConfigsRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage( + new protos.google.monitoring.v3.UptimeCheckConfig() + ), + generateSampleMessage( + new protos.google.monitoring.v3.UptimeCheckConfig() + ), + generateSampleMessage( + new protos.google.monitoring.v3.UptimeCheckConfig() + ), + ]; + client.innerApiCalls.listUptimeCheckConfigs = stubSimpleCall( + expectedResponse + ); + const [response] = await client.listUptimeCheckConfigs(request); + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.listUptimeCheckConfigs as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + + it('invokes listUptimeCheckConfigs without error using callback', async () => { + const client = new uptimecheckserviceModule.v3.UptimeCheckServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.monitoring.v3.ListUptimeCheckConfigsRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage( + new protos.google.monitoring.v3.UptimeCheckConfig() + ), + generateSampleMessage( + new protos.google.monitoring.v3.UptimeCheckConfig() + ), + generateSampleMessage( + new protos.google.monitoring.v3.UptimeCheckConfig() + ), + ]; + client.innerApiCalls.listUptimeCheckConfigs = stubSimpleCallWithCallback( + expectedResponse + ); + const promise = new Promise((resolve, reject) => { + client.listUptimeCheckConfigs( + request, + ( + err?: Error | null, + result?: protos.google.monitoring.v3.IUptimeCheckConfig[] | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.listUptimeCheckConfigs as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions /*, callback defined above */) + ); + }); + + it('invokes listUptimeCheckConfigs with error', async () => { + const client = new uptimecheckserviceModule.v3.UptimeCheckServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.monitoring.v3.ListUptimeCheckConfigsRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.listUptimeCheckConfigs = stubSimpleCall( + undefined, + expectedError + ); + assert.rejects(async () => { + await client.listUptimeCheckConfigs(request); + }, expectedError); + assert( + (client.innerApiCalls.listUptimeCheckConfigs as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + + it('invokes listUptimeCheckConfigsStream without error', async () => { + const client = new uptimecheckserviceModule.v3.UptimeCheckServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.monitoring.v3.ListUptimeCheckConfigsRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedResponse = [ + generateSampleMessage( + new protos.google.monitoring.v3.UptimeCheckConfig() + ), + generateSampleMessage( + new protos.google.monitoring.v3.UptimeCheckConfig() + ), + generateSampleMessage( + new protos.google.monitoring.v3.UptimeCheckConfig() + ), + ]; + client.descriptors.page.listUptimeCheckConfigs.createStream = stubPageStreamingCall( + expectedResponse + ); + const stream = client.listUptimeCheckConfigsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.monitoring.v3.UptimeCheckConfig[] = []; + stream.on( + 'data', + (response: protos.google.monitoring.v3.UptimeCheckConfig) => { + 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.listUptimeCheckConfigs + .createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listUptimeCheckConfigs, request) + ); + assert.strictEqual( + (client.descriptors.page.listUptimeCheckConfigs + .createStream as SinonStub).getCall(0).args[2].otherArgs.headers[ + 'x-goog-request-params' + ], + expectedHeaderRequestParams + ); + }); + + it('invokes listUptimeCheckConfigsStream with error', async () => { + const client = new uptimecheckserviceModule.v3.UptimeCheckServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.monitoring.v3.ListUptimeCheckConfigsRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedError = new Error('expected'); + client.descriptors.page.listUptimeCheckConfigs.createStream = stubPageStreamingCall( + undefined, + expectedError + ); + const stream = client.listUptimeCheckConfigsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.monitoring.v3.UptimeCheckConfig[] = []; + stream.on( + 'data', + (response: protos.google.monitoring.v3.UptimeCheckConfig) => { + responses.push(response); + } + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + assert.rejects(async () => { + await promise; + }, expectedError); + assert( + (client.descriptors.page.listUptimeCheckConfigs + .createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listUptimeCheckConfigs, request) + ); + assert.strictEqual( + (client.descriptors.page.listUptimeCheckConfigs + .createStream as SinonStub).getCall(0).args[2].otherArgs.headers[ + 'x-goog-request-params' + ], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listUptimeCheckConfigs without error', async () => { + const client = new uptimecheckserviceModule.v3.UptimeCheckServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.monitoring.v3.ListUptimeCheckConfigsRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedResponse = [ + generateSampleMessage( + new protos.google.monitoring.v3.UptimeCheckConfig() + ), + generateSampleMessage( + new protos.google.monitoring.v3.UptimeCheckConfig() + ), + generateSampleMessage( + new protos.google.monitoring.v3.UptimeCheckConfig() + ), + ]; + client.descriptors.page.listUptimeCheckConfigs.asyncIterate = stubAsyncIterationCall( + expectedResponse + ); + const responses: protos.google.monitoring.v3.IUptimeCheckConfig[] = []; + const iterable = client.listUptimeCheckConfigsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listUptimeCheckConfigs + .asyncIterate as SinonStub).getCall(0).args[1], + request + ); + assert.strictEqual( + (client.descriptors.page.listUptimeCheckConfigs + .asyncIterate as SinonStub).getCall(0).args[2].otherArgs.headers[ + 'x-goog-request-params' + ], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listUptimeCheckConfigs with error', async () => { + const client = new uptimecheckserviceModule.v3.UptimeCheckServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.monitoring.v3.ListUptimeCheckConfigsRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedError = new Error('expected'); + client.descriptors.page.listUptimeCheckConfigs.asyncIterate = stubAsyncIterationCall( + undefined, + expectedError + ); + const iterable = client.listUptimeCheckConfigsAsync(request); + assert.rejects(async () => { + const responses: protos.google.monitoring.v3.IUptimeCheckConfig[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listUptimeCheckConfigs + .asyncIterate as SinonStub).getCall(0).args[1], + request + ); + assert.strictEqual( + (client.descriptors.page.listUptimeCheckConfigs + .asyncIterate as SinonStub).getCall(0).args[2].otherArgs.headers[ + 'x-goog-request-params' + ], + expectedHeaderRequestParams + ); + }); + }); + + describe('listUptimeCheckIps', () => { + it('invokes listUptimeCheckIps without error', async () => { + const client = new uptimecheckserviceModule.v3.UptimeCheckServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.monitoring.v3.ListUptimeCheckIpsRequest() + ); + const expectedOptions = {}; + const expectedResponse = [ + generateSampleMessage(new protos.google.monitoring.v3.UptimeCheckIp()), + generateSampleMessage(new protos.google.monitoring.v3.UptimeCheckIp()), + generateSampleMessage(new protos.google.monitoring.v3.UptimeCheckIp()), + ]; + client.innerApiCalls.listUptimeCheckIps = stubSimpleCall( + expectedResponse + ); + const [response] = await client.listUptimeCheckIps(request); + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.listUptimeCheckIps as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + + it('invokes listUptimeCheckIps without error using callback', async () => { + const client = new uptimecheckserviceModule.v3.UptimeCheckServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.monitoring.v3.ListUptimeCheckIpsRequest() + ); + const expectedOptions = {}; + const expectedResponse = [ + generateSampleMessage(new protos.google.monitoring.v3.UptimeCheckIp()), + generateSampleMessage(new protos.google.monitoring.v3.UptimeCheckIp()), + generateSampleMessage(new protos.google.monitoring.v3.UptimeCheckIp()), + ]; + client.innerApiCalls.listUptimeCheckIps = stubSimpleCallWithCallback( + expectedResponse + ); + const promise = new Promise((resolve, reject) => { + client.listUptimeCheckIps( + request, + ( + err?: Error | null, + result?: protos.google.monitoring.v3.IUptimeCheckIp[] | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.listUptimeCheckIps as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions /*, callback defined above */) + ); + }); + + it('invokes listUptimeCheckIps with error', async () => { + const client = new uptimecheckserviceModule.v3.UptimeCheckServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.monitoring.v3.ListUptimeCheckIpsRequest() + ); + const expectedOptions = {}; + const expectedError = new Error('expected'); + client.innerApiCalls.listUptimeCheckIps = stubSimpleCall( + undefined, + expectedError + ); + assert.rejects(async () => { + await client.listUptimeCheckIps(request); + }, expectedError); + assert( + (client.innerApiCalls.listUptimeCheckIps as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + + it('invokes listUptimeCheckIpsStream without error', async () => { + const client = new uptimecheckserviceModule.v3.UptimeCheckServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.monitoring.v3.ListUptimeCheckIpsRequest() + ); + const expectedResponse = [ + generateSampleMessage(new protos.google.monitoring.v3.UptimeCheckIp()), + generateSampleMessage(new protos.google.monitoring.v3.UptimeCheckIp()), + generateSampleMessage(new protos.google.monitoring.v3.UptimeCheckIp()), + ]; + client.descriptors.page.listUptimeCheckIps.createStream = stubPageStreamingCall( + expectedResponse + ); + const stream = client.listUptimeCheckIpsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.monitoring.v3.UptimeCheckIp[] = []; + stream.on( + 'data', + (response: protos.google.monitoring.v3.UptimeCheckIp) => { + 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.listUptimeCheckIps.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listUptimeCheckIps, request) + ); + }); + + it('invokes listUptimeCheckIpsStream with error', async () => { + const client = new uptimecheckserviceModule.v3.UptimeCheckServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.monitoring.v3.ListUptimeCheckIpsRequest() + ); + const expectedError = new Error('expected'); + client.descriptors.page.listUptimeCheckIps.createStream = stubPageStreamingCall( + undefined, + expectedError + ); + const stream = client.listUptimeCheckIpsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.monitoring.v3.UptimeCheckIp[] = []; + stream.on( + 'data', + (response: protos.google.monitoring.v3.UptimeCheckIp) => { + responses.push(response); + } + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + assert.rejects(async () => { + await promise; + }, expectedError); + assert( + (client.descriptors.page.listUptimeCheckIps.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listUptimeCheckIps, request) + ); + }); + + it('uses async iteration with listUptimeCheckIps without error', async () => { + const client = new uptimecheckserviceModule.v3.UptimeCheckServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.monitoring.v3.ListUptimeCheckIpsRequest() + ); + const expectedResponse = [ + generateSampleMessage(new protos.google.monitoring.v3.UptimeCheckIp()), + generateSampleMessage(new protos.google.monitoring.v3.UptimeCheckIp()), + generateSampleMessage(new protos.google.monitoring.v3.UptimeCheckIp()), + ]; + client.descriptors.page.listUptimeCheckIps.asyncIterate = stubAsyncIterationCall( + expectedResponse + ); + const responses: protos.google.monitoring.v3.IUptimeCheckIp[] = []; + const iterable = client.listUptimeCheckIpsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listUptimeCheckIps + .asyncIterate as SinonStub).getCall(0).args[1], + request + ); + }); + + it('uses async iteration with listUptimeCheckIps with error', async () => { + const client = new uptimecheckserviceModule.v3.UptimeCheckServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.monitoring.v3.ListUptimeCheckIpsRequest() + ); + const expectedError = new Error('expected'); + client.descriptors.page.listUptimeCheckIps.asyncIterate = stubAsyncIterationCall( + undefined, + expectedError + ); + const iterable = client.listUptimeCheckIpsAsync(request); + assert.rejects(async () => { + const responses: protos.google.monitoring.v3.IUptimeCheckIp[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listUptimeCheckIps + .asyncIterate as SinonStub).getCall(0).args[1], + request + ); + }); + }); + + describe('Path templates', () => { + describe('folderAlertPolicy', () => { + const fakePath = '/rendered/path/folderAlertPolicy'; + const expectedParameters = { + folder: 'folderValue', + alert_policy: 'alertPolicyValue', + }; + const client = new uptimecheckserviceModule.v3.UptimeCheckServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.folderAlertPolicyPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.folderAlertPolicyPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('folderAlertPolicyPath', () => { + const result = client.folderAlertPolicyPath( + 'folderValue', + 'alertPolicyValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.folderAlertPolicyPathTemplate + .render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchFolderFromFolderAlertPolicyName', () => { + const result = client.matchFolderFromFolderAlertPolicyName(fakePath); + assert.strictEqual(result, 'folderValue'); + assert( + (client.pathTemplates.folderAlertPolicyPathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchAlertPolicyFromFolderAlertPolicyName', () => { + const result = client.matchAlertPolicyFromFolderAlertPolicyName( + fakePath + ); + assert.strictEqual(result, 'alertPolicyValue'); + assert( + (client.pathTemplates.folderAlertPolicyPathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('folderAlertPolicyCondition', () => { + const fakePath = '/rendered/path/folderAlertPolicyCondition'; + const expectedParameters = { + folder: 'folderValue', + alert_policy: 'alertPolicyValue', + condition: 'conditionValue', + }; + const client = new uptimecheckserviceModule.v3.UptimeCheckServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.folderAlertPolicyConditionPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.folderAlertPolicyConditionPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('folderAlertPolicyConditionPath', () => { + const result = client.folderAlertPolicyConditionPath( + 'folderValue', + 'alertPolicyValue', + 'conditionValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.folderAlertPolicyConditionPathTemplate + .render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchFolderFromFolderAlertPolicyConditionName', () => { + const result = client.matchFolderFromFolderAlertPolicyConditionName( + fakePath + ); + assert.strictEqual(result, 'folderValue'); + assert( + (client.pathTemplates.folderAlertPolicyConditionPathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchAlertPolicyFromFolderAlertPolicyConditionName', () => { + const result = client.matchAlertPolicyFromFolderAlertPolicyConditionName( + fakePath + ); + assert.strictEqual(result, 'alertPolicyValue'); + assert( + (client.pathTemplates.folderAlertPolicyConditionPathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchConditionFromFolderAlertPolicyConditionName', () => { + const result = client.matchConditionFromFolderAlertPolicyConditionName( + fakePath + ); + assert.strictEqual(result, 'conditionValue'); + assert( + (client.pathTemplates.folderAlertPolicyConditionPathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('folderChannelDescriptor', () => { + const fakePath = '/rendered/path/folderChannelDescriptor'; + const expectedParameters = { + folder: 'folderValue', + channel_descriptor: 'channelDescriptorValue', + }; + const client = new uptimecheckserviceModule.v3.UptimeCheckServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.folderChannelDescriptorPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.folderChannelDescriptorPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('folderChannelDescriptorPath', () => { + const result = client.folderChannelDescriptorPath( + 'folderValue', + 'channelDescriptorValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.folderChannelDescriptorPathTemplate + .render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchFolderFromFolderChannelDescriptorName', () => { + const result = client.matchFolderFromFolderChannelDescriptorName( + fakePath + ); + assert.strictEqual(result, 'folderValue'); + assert( + (client.pathTemplates.folderChannelDescriptorPathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchChannelDescriptorFromFolderChannelDescriptorName', () => { + const result = client.matchChannelDescriptorFromFolderChannelDescriptorName( + fakePath + ); + assert.strictEqual(result, 'channelDescriptorValue'); + assert( + (client.pathTemplates.folderChannelDescriptorPathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('folderGroup', () => { + const fakePath = '/rendered/path/folderGroup'; + const expectedParameters = { + folder: 'folderValue', + group: 'groupValue', + }; + const client = new uptimecheckserviceModule.v3.UptimeCheckServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.folderGroupPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.folderGroupPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('folderGroupPath', () => { + const result = client.folderGroupPath('folderValue', 'groupValue'); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.folderGroupPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchFolderFromFolderGroupName', () => { + const result = client.matchFolderFromFolderGroupName(fakePath); + assert.strictEqual(result, 'folderValue'); + assert( + (client.pathTemplates.folderGroupPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchGroupFromFolderGroupName', () => { + const result = client.matchGroupFromFolderGroupName(fakePath); + assert.strictEqual(result, 'groupValue'); + assert( + (client.pathTemplates.folderGroupPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('folderNotificationChannel', () => { + const fakePath = '/rendered/path/folderNotificationChannel'; + const expectedParameters = { + folder: 'folderValue', + notification_channel: 'notificationChannelValue', + }; + const client = new uptimecheckserviceModule.v3.UptimeCheckServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.folderNotificationChannelPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.folderNotificationChannelPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('folderNotificationChannelPath', () => { + const result = client.folderNotificationChannelPath( + 'folderValue', + 'notificationChannelValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.folderNotificationChannelPathTemplate + .render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchFolderFromFolderNotificationChannelName', () => { + const result = client.matchFolderFromFolderNotificationChannelName( + fakePath + ); + assert.strictEqual(result, 'folderValue'); + assert( + (client.pathTemplates.folderNotificationChannelPathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchNotificationChannelFromFolderNotificationChannelName', () => { + const result = client.matchNotificationChannelFromFolderNotificationChannelName( + fakePath + ); + assert.strictEqual(result, 'notificationChannelValue'); + assert( + (client.pathTemplates.folderNotificationChannelPathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('folderService', () => { + const fakePath = '/rendered/path/folderService'; + const expectedParameters = { + folder: 'folderValue', + service: 'serviceValue', + }; + const client = new uptimecheckserviceModule.v3.UptimeCheckServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.folderServicePathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.folderServicePathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('folderServicePath', () => { + const result = client.folderServicePath('folderValue', 'serviceValue'); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.folderServicePathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchFolderFromFolderServiceName', () => { + const result = client.matchFolderFromFolderServiceName(fakePath); + assert.strictEqual(result, 'folderValue'); + assert( + (client.pathTemplates.folderServicePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchServiceFromFolderServiceName', () => { + const result = client.matchServiceFromFolderServiceName(fakePath); + assert.strictEqual(result, 'serviceValue'); + assert( + (client.pathTemplates.folderServicePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('folderServiceServiceLevelObjective', () => { + const fakePath = '/rendered/path/folderServiceServiceLevelObjective'; + const expectedParameters = { + folder: 'folderValue', + service: 'serviceValue', + service_level_objective: 'serviceLevelObjectiveValue', + }; + const client = new uptimecheckserviceModule.v3.UptimeCheckServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.folderServiceServiceLevelObjectivePathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.folderServiceServiceLevelObjectivePathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('folderServiceServiceLevelObjectivePath', () => { + const result = client.folderServiceServiceLevelObjectivePath( + 'folderValue', + 'serviceValue', + 'serviceLevelObjectiveValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.folderServiceServiceLevelObjectivePathTemplate + .render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchFolderFromFolderServiceServiceLevelObjectiveName', () => { + const result = client.matchFolderFromFolderServiceServiceLevelObjectiveName( + fakePath + ); + assert.strictEqual(result, 'folderValue'); + assert( + (client.pathTemplates.folderServiceServiceLevelObjectivePathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchServiceFromFolderServiceServiceLevelObjectiveName', () => { + const result = client.matchServiceFromFolderServiceServiceLevelObjectiveName( + fakePath + ); + assert.strictEqual(result, 'serviceValue'); + assert( + (client.pathTemplates.folderServiceServiceLevelObjectivePathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchServiceLevelObjectiveFromFolderServiceServiceLevelObjectiveName', () => { + const result = client.matchServiceLevelObjectiveFromFolderServiceServiceLevelObjectiveName( + fakePath + ); + assert.strictEqual(result, 'serviceLevelObjectiveValue'); + assert( + (client.pathTemplates.folderServiceServiceLevelObjectivePathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('folderUptimeCheckConfig', () => { + const fakePath = '/rendered/path/folderUptimeCheckConfig'; + const expectedParameters = { + folder: 'folderValue', + uptime_check_config: 'uptimeCheckConfigValue', + }; + const client = new uptimecheckserviceModule.v3.UptimeCheckServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.folderUptimeCheckConfigPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.folderUptimeCheckConfigPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('folderUptimeCheckConfigPath', () => { + const result = client.folderUptimeCheckConfigPath( + 'folderValue', + 'uptimeCheckConfigValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.folderUptimeCheckConfigPathTemplate + .render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchFolderFromFolderUptimeCheckConfigName', () => { + const result = client.matchFolderFromFolderUptimeCheckConfigName( + fakePath + ); + assert.strictEqual(result, 'folderValue'); + assert( + (client.pathTemplates.folderUptimeCheckConfigPathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchUptimeCheckConfigFromFolderUptimeCheckConfigName', () => { + const result = client.matchUptimeCheckConfigFromFolderUptimeCheckConfigName( + fakePath + ); + assert.strictEqual(result, 'uptimeCheckConfigValue'); + assert( + (client.pathTemplates.folderUptimeCheckConfigPathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('organizationAlertPolicy', () => { + const fakePath = '/rendered/path/organizationAlertPolicy'; + const expectedParameters = { + organization: 'organizationValue', + alert_policy: 'alertPolicyValue', + }; + const client = new uptimecheckserviceModule.v3.UptimeCheckServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.organizationAlertPolicyPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.organizationAlertPolicyPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('organizationAlertPolicyPath', () => { + const result = client.organizationAlertPolicyPath( + 'organizationValue', + 'alertPolicyValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.organizationAlertPolicyPathTemplate + .render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchOrganizationFromOrganizationAlertPolicyName', () => { + const result = client.matchOrganizationFromOrganizationAlertPolicyName( + fakePath + ); + assert.strictEqual(result, 'organizationValue'); + assert( + (client.pathTemplates.organizationAlertPolicyPathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchAlertPolicyFromOrganizationAlertPolicyName', () => { + const result = client.matchAlertPolicyFromOrganizationAlertPolicyName( + fakePath + ); + assert.strictEqual(result, 'alertPolicyValue'); + assert( + (client.pathTemplates.organizationAlertPolicyPathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('organizationAlertPolicyCondition', () => { + const fakePath = '/rendered/path/organizationAlertPolicyCondition'; + const expectedParameters = { + organization: 'organizationValue', + alert_policy: 'alertPolicyValue', + condition: 'conditionValue', + }; + const client = new uptimecheckserviceModule.v3.UptimeCheckServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.organizationAlertPolicyConditionPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.organizationAlertPolicyConditionPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('organizationAlertPolicyConditionPath', () => { + const result = client.organizationAlertPolicyConditionPath( + 'organizationValue', + 'alertPolicyValue', + 'conditionValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.organizationAlertPolicyConditionPathTemplate + .render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchOrganizationFromOrganizationAlertPolicyConditionName', () => { + const result = client.matchOrganizationFromOrganizationAlertPolicyConditionName( + fakePath + ); + assert.strictEqual(result, 'organizationValue'); + assert( + (client.pathTemplates.organizationAlertPolicyConditionPathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchAlertPolicyFromOrganizationAlertPolicyConditionName', () => { + const result = client.matchAlertPolicyFromOrganizationAlertPolicyConditionName( + fakePath + ); + assert.strictEqual(result, 'alertPolicyValue'); + assert( + (client.pathTemplates.organizationAlertPolicyConditionPathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchConditionFromOrganizationAlertPolicyConditionName', () => { + const result = client.matchConditionFromOrganizationAlertPolicyConditionName( + fakePath + ); + assert.strictEqual(result, 'conditionValue'); + assert( + (client.pathTemplates.organizationAlertPolicyConditionPathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('organizationChannelDescriptor', () => { + const fakePath = '/rendered/path/organizationChannelDescriptor'; + const expectedParameters = { + organization: 'organizationValue', + channel_descriptor: 'channelDescriptorValue', + }; + const client = new uptimecheckserviceModule.v3.UptimeCheckServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.organizationChannelDescriptorPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.organizationChannelDescriptorPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('organizationChannelDescriptorPath', () => { + const result = client.organizationChannelDescriptorPath( + 'organizationValue', + 'channelDescriptorValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.organizationChannelDescriptorPathTemplate + .render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchOrganizationFromOrganizationChannelDescriptorName', () => { + const result = client.matchOrganizationFromOrganizationChannelDescriptorName( + fakePath + ); + assert.strictEqual(result, 'organizationValue'); + assert( + (client.pathTemplates.organizationChannelDescriptorPathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchChannelDescriptorFromOrganizationChannelDescriptorName', () => { + const result = client.matchChannelDescriptorFromOrganizationChannelDescriptorName( + fakePath + ); + assert.strictEqual(result, 'channelDescriptorValue'); + assert( + (client.pathTemplates.organizationChannelDescriptorPathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('organizationGroup', () => { + const fakePath = '/rendered/path/organizationGroup'; + const expectedParameters = { + organization: 'organizationValue', + group: 'groupValue', + }; + const client = new uptimecheckserviceModule.v3.UptimeCheckServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.organizationGroupPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.organizationGroupPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('organizationGroupPath', () => { + const result = client.organizationGroupPath( + 'organizationValue', + 'groupValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.organizationGroupPathTemplate + .render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchOrganizationFromOrganizationGroupName', () => { + const result = client.matchOrganizationFromOrganizationGroupName( + fakePath + ); + assert.strictEqual(result, 'organizationValue'); + assert( + (client.pathTemplates.organizationGroupPathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchGroupFromOrganizationGroupName', () => { + const result = client.matchGroupFromOrganizationGroupName(fakePath); + assert.strictEqual(result, 'groupValue'); + assert( + (client.pathTemplates.organizationGroupPathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('organizationNotificationChannel', () => { + const fakePath = '/rendered/path/organizationNotificationChannel'; + const expectedParameters = { + organization: 'organizationValue', + notification_channel: 'notificationChannelValue', + }; + const client = new uptimecheckserviceModule.v3.UptimeCheckServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.organizationNotificationChannelPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.organizationNotificationChannelPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('organizationNotificationChannelPath', () => { + const result = client.organizationNotificationChannelPath( + 'organizationValue', + 'notificationChannelValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.organizationNotificationChannelPathTemplate + .render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchOrganizationFromOrganizationNotificationChannelName', () => { + const result = client.matchOrganizationFromOrganizationNotificationChannelName( + fakePath + ); + assert.strictEqual(result, 'organizationValue'); + assert( + (client.pathTemplates.organizationNotificationChannelPathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchNotificationChannelFromOrganizationNotificationChannelName', () => { + const result = client.matchNotificationChannelFromOrganizationNotificationChannelName( + fakePath + ); + assert.strictEqual(result, 'notificationChannelValue'); + assert( + (client.pathTemplates.organizationNotificationChannelPathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('organizationService', () => { + const fakePath = '/rendered/path/organizationService'; + const expectedParameters = { + organization: 'organizationValue', + service: 'serviceValue', + }; + const client = new uptimecheckserviceModule.v3.UptimeCheckServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.organizationServicePathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.organizationServicePathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('organizationServicePath', () => { + const result = client.organizationServicePath( + 'organizationValue', + 'serviceValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.organizationServicePathTemplate + .render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchOrganizationFromOrganizationServiceName', () => { + const result = client.matchOrganizationFromOrganizationServiceName( + fakePath + ); + assert.strictEqual(result, 'organizationValue'); + assert( + (client.pathTemplates.organizationServicePathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchServiceFromOrganizationServiceName', () => { + const result = client.matchServiceFromOrganizationServiceName(fakePath); + assert.strictEqual(result, 'serviceValue'); + assert( + (client.pathTemplates.organizationServicePathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('organizationServiceServiceLevelObjective', () => { + const fakePath = + '/rendered/path/organizationServiceServiceLevelObjective'; + const expectedParameters = { + organization: 'organizationValue', + service: 'serviceValue', + service_level_objective: 'serviceLevelObjectiveValue', + }; + const client = new uptimecheckserviceModule.v3.UptimeCheckServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.organizationServiceServiceLevelObjectivePathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.organizationServiceServiceLevelObjectivePathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('organizationServiceServiceLevelObjectivePath', () => { + const result = client.organizationServiceServiceLevelObjectivePath( + 'organizationValue', + 'serviceValue', + 'serviceLevelObjectiveValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates + .organizationServiceServiceLevelObjectivePathTemplate + .render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchOrganizationFromOrganizationServiceServiceLevelObjectiveName', () => { + const result = client.matchOrganizationFromOrganizationServiceServiceLevelObjectiveName( + fakePath + ); + assert.strictEqual(result, 'organizationValue'); + assert( + (client.pathTemplates + .organizationServiceServiceLevelObjectivePathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchServiceFromOrganizationServiceServiceLevelObjectiveName', () => { + const result = client.matchServiceFromOrganizationServiceServiceLevelObjectiveName( + fakePath + ); + assert.strictEqual(result, 'serviceValue'); + assert( + (client.pathTemplates + .organizationServiceServiceLevelObjectivePathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchServiceLevelObjectiveFromOrganizationServiceServiceLevelObjectiveName', () => { + const result = client.matchServiceLevelObjectiveFromOrganizationServiceServiceLevelObjectiveName( + fakePath + ); + assert.strictEqual(result, 'serviceLevelObjectiveValue'); + assert( + (client.pathTemplates + .organizationServiceServiceLevelObjectivePathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('organizationUptimeCheckConfig', () => { + const fakePath = '/rendered/path/organizationUptimeCheckConfig'; + const expectedParameters = { + organization: 'organizationValue', + uptime_check_config: 'uptimeCheckConfigValue', + }; + const client = new uptimecheckserviceModule.v3.UptimeCheckServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.organizationUptimeCheckConfigPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.organizationUptimeCheckConfigPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('organizationUptimeCheckConfigPath', () => { + const result = client.organizationUptimeCheckConfigPath( + 'organizationValue', + 'uptimeCheckConfigValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.organizationUptimeCheckConfigPathTemplate + .render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchOrganizationFromOrganizationUptimeCheckConfigName', () => { + const result = client.matchOrganizationFromOrganizationUptimeCheckConfigName( + fakePath + ); + assert.strictEqual(result, 'organizationValue'); + assert( + (client.pathTemplates.organizationUptimeCheckConfigPathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchUptimeCheckConfigFromOrganizationUptimeCheckConfigName', () => { + const result = client.matchUptimeCheckConfigFromOrganizationUptimeCheckConfigName( + fakePath + ); + assert.strictEqual(result, 'uptimeCheckConfigValue'); + assert( + (client.pathTemplates.organizationUptimeCheckConfigPathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('project', () => { + const fakePath = '/rendered/path/project'; + const expectedParameters = { + project: 'projectValue', + }; + const client = new uptimecheckserviceModule.v3.UptimeCheckServiceClient({ + 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('matchProjectFromProjectName', () => { + const result = client.matchProjectFromProjectName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.projectPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('projectAlertPolicy', () => { + const fakePath = '/rendered/path/projectAlertPolicy'; + const expectedParameters = { + project: 'projectValue', + alert_policy: 'alertPolicyValue', + }; + const client = new uptimecheckserviceModule.v3.UptimeCheckServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.projectAlertPolicyPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.projectAlertPolicyPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('projectAlertPolicyPath', () => { + const result = client.projectAlertPolicyPath( + 'projectValue', + 'alertPolicyValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.projectAlertPolicyPathTemplate + .render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromProjectAlertPolicyName', () => { + const result = client.matchProjectFromProjectAlertPolicyName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.projectAlertPolicyPathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchAlertPolicyFromProjectAlertPolicyName', () => { + const result = client.matchAlertPolicyFromProjectAlertPolicyName( + fakePath + ); + assert.strictEqual(result, 'alertPolicyValue'); + assert( + (client.pathTemplates.projectAlertPolicyPathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('projectAlertPolicyCondition', () => { + const fakePath = '/rendered/path/projectAlertPolicyCondition'; + const expectedParameters = { + project: 'projectValue', + alert_policy: 'alertPolicyValue', + condition: 'conditionValue', + }; + const client = new uptimecheckserviceModule.v3.UptimeCheckServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.projectAlertPolicyConditionPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.projectAlertPolicyConditionPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('projectAlertPolicyConditionPath', () => { + const result = client.projectAlertPolicyConditionPath( + 'projectValue', + 'alertPolicyValue', + 'conditionValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.projectAlertPolicyConditionPathTemplate + .render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromProjectAlertPolicyConditionName', () => { + const result = client.matchProjectFromProjectAlertPolicyConditionName( + fakePath + ); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.projectAlertPolicyConditionPathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchAlertPolicyFromProjectAlertPolicyConditionName', () => { + const result = client.matchAlertPolicyFromProjectAlertPolicyConditionName( + fakePath + ); + assert.strictEqual(result, 'alertPolicyValue'); + assert( + (client.pathTemplates.projectAlertPolicyConditionPathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchConditionFromProjectAlertPolicyConditionName', () => { + const result = client.matchConditionFromProjectAlertPolicyConditionName( + fakePath + ); + assert.strictEqual(result, 'conditionValue'); + assert( + (client.pathTemplates.projectAlertPolicyConditionPathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('projectChannelDescriptor', () => { + const fakePath = '/rendered/path/projectChannelDescriptor'; + const expectedParameters = { + project: 'projectValue', + channel_descriptor: 'channelDescriptorValue', + }; + const client = new uptimecheckserviceModule.v3.UptimeCheckServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.projectChannelDescriptorPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.projectChannelDescriptorPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('projectChannelDescriptorPath', () => { + const result = client.projectChannelDescriptorPath( + 'projectValue', + 'channelDescriptorValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.projectChannelDescriptorPathTemplate + .render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromProjectChannelDescriptorName', () => { + const result = client.matchProjectFromProjectChannelDescriptorName( + fakePath + ); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.projectChannelDescriptorPathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchChannelDescriptorFromProjectChannelDescriptorName', () => { + const result = client.matchChannelDescriptorFromProjectChannelDescriptorName( + fakePath + ); + assert.strictEqual(result, 'channelDescriptorValue'); + assert( + (client.pathTemplates.projectChannelDescriptorPathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('projectGroup', () => { + const fakePath = '/rendered/path/projectGroup'; + const expectedParameters = { + project: 'projectValue', + group: 'groupValue', + }; + const client = new uptimecheckserviceModule.v3.UptimeCheckServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.projectGroupPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.projectGroupPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('projectGroupPath', () => { + const result = client.projectGroupPath('projectValue', 'groupValue'); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.projectGroupPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromProjectGroupName', () => { + const result = client.matchProjectFromProjectGroupName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.projectGroupPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchGroupFromProjectGroupName', () => { + const result = client.matchGroupFromProjectGroupName(fakePath); + assert.strictEqual(result, 'groupValue'); + assert( + (client.pathTemplates.projectGroupPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('projectNotificationChannel', () => { + const fakePath = '/rendered/path/projectNotificationChannel'; + const expectedParameters = { + project: 'projectValue', + notification_channel: 'notificationChannelValue', + }; + const client = new uptimecheckserviceModule.v3.UptimeCheckServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.projectNotificationChannelPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.projectNotificationChannelPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('projectNotificationChannelPath', () => { + const result = client.projectNotificationChannelPath( + 'projectValue', + 'notificationChannelValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.projectNotificationChannelPathTemplate + .render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromProjectNotificationChannelName', () => { + const result = client.matchProjectFromProjectNotificationChannelName( + fakePath + ); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.projectNotificationChannelPathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchNotificationChannelFromProjectNotificationChannelName', () => { + const result = client.matchNotificationChannelFromProjectNotificationChannelName( + fakePath + ); + assert.strictEqual(result, 'notificationChannelValue'); + assert( + (client.pathTemplates.projectNotificationChannelPathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('projectService', () => { + const fakePath = '/rendered/path/projectService'; + const expectedParameters = { + project: 'projectValue', + service: 'serviceValue', + }; + const client = new uptimecheckserviceModule.v3.UptimeCheckServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.projectServicePathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.projectServicePathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('projectServicePath', () => { + const result = client.projectServicePath( + 'projectValue', + 'serviceValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.projectServicePathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromProjectServiceName', () => { + const result = client.matchProjectFromProjectServiceName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.projectServicePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchServiceFromProjectServiceName', () => { + const result = client.matchServiceFromProjectServiceName(fakePath); + assert.strictEqual(result, 'serviceValue'); + assert( + (client.pathTemplates.projectServicePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('projectServiceServiceLevelObjective', () => { + const fakePath = '/rendered/path/projectServiceServiceLevelObjective'; + const expectedParameters = { + project: 'projectValue', + service: 'serviceValue', + service_level_objective: 'serviceLevelObjectiveValue', + }; + const client = new uptimecheckserviceModule.v3.UptimeCheckServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.projectServiceServiceLevelObjectivePathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.projectServiceServiceLevelObjectivePathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('projectServiceServiceLevelObjectivePath', () => { + const result = client.projectServiceServiceLevelObjectivePath( + 'projectValue', + 'serviceValue', + 'serviceLevelObjectiveValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.projectServiceServiceLevelObjectivePathTemplate + .render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromProjectServiceServiceLevelObjectiveName', () => { + const result = client.matchProjectFromProjectServiceServiceLevelObjectiveName( + fakePath + ); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.projectServiceServiceLevelObjectivePathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchServiceFromProjectServiceServiceLevelObjectiveName', () => { + const result = client.matchServiceFromProjectServiceServiceLevelObjectiveName( + fakePath + ); + assert.strictEqual(result, 'serviceValue'); + assert( + (client.pathTemplates.projectServiceServiceLevelObjectivePathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchServiceLevelObjectiveFromProjectServiceServiceLevelObjectiveName', () => { + const result = client.matchServiceLevelObjectiveFromProjectServiceServiceLevelObjectiveName( + fakePath + ); + assert.strictEqual(result, 'serviceLevelObjectiveValue'); + assert( + (client.pathTemplates.projectServiceServiceLevelObjectivePathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('projectUptimeCheckConfig', () => { + const fakePath = '/rendered/path/projectUptimeCheckConfig'; + const expectedParameters = { + project: 'projectValue', + uptime_check_config: 'uptimeCheckConfigValue', + }; + const client = new uptimecheckserviceModule.v3.UptimeCheckServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.projectUptimeCheckConfigPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.projectUptimeCheckConfigPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('projectUptimeCheckConfigPath', () => { + const result = client.projectUptimeCheckConfigPath( + 'projectValue', + 'uptimeCheckConfigValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.projectUptimeCheckConfigPathTemplate + .render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromProjectUptimeCheckConfigName', () => { + const result = client.matchProjectFromProjectUptimeCheckConfigName( + fakePath + ); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.projectUptimeCheckConfigPathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchUptimeCheckConfigFromProjectUptimeCheckConfigName', () => { + const result = client.matchUptimeCheckConfigFromProjectUptimeCheckConfigName( + fakePath + ); + assert.strictEqual(result, 'uptimeCheckConfigValue'); + assert( + (client.pathTemplates.projectUptimeCheckConfigPathTemplate + .match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + }); +}); diff --git a/packages/google-cloud-monitoring/webpack.config.js b/packages/google-cloud-monitoring/webpack.config.js index c38f3d48b36..39aa3c704a3 100644 --- a/packages/google-cloud-monitoring/webpack.config.js +++ b/packages/google-cloud-monitoring/webpack.config.js @@ -1,4 +1,4 @@ -// Copyright 2019 Google LLC +// Copyright 2020 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -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', }, ], },