From 1633f575c618000931ecf2783680ca1f93c1e19f Mon Sep 17 00:00:00 2001 From: summerji Date: Wed, 5 Feb 2020 15:20:51 -0800 Subject: [PATCH 1/6] fix: remove the filter if protos in both googleapis and gax --- typescript/src/schema/api.ts | 7 +- .../testdata/monitoring/proto.list.baseline | 27 +- .../testdata/monitoring/src/index.ts.baseline | 10 +- .../alert_policy_service_client.ts.baseline | 1593 ++++++++++++ ...policy_service_client_config.json.baseline | 46 + ...rt_policy_service_proto_list.json.baseline | 16 + .../src/v3/group_service_client.ts.baseline | 1708 +++++++++++++ .../group_service_client_config.json.baseline | 50 + .../v3/group_service_proto_list.json.baseline | 16 + .../monitoring/src/v3/index.ts.baseline | 2 +- .../src/v3/metric_service_client.ts.baseline | 2161 +++++++++++++++++ ...metric_service_client_config.json.baseline | 58 + .../metric_service_proto_list.json.baseline | 16 + ...ication_channel_service_client.ts.baseline | 1993 +++++++++++++++ ...hannel_service_client_config.json.baseline | 66 + ...n_channel_service_proto_list.json.baseline | 16 + ...vice_monitoring_service_client.ts.baseline | 1946 +++++++++++++++ ...toring_service_client_config.json.baseline | 66 + ...onitoring_service_proto_list.json.baseline | 16 + .../uptime_check_service_client.ts.baseline | 1661 +++++++++++++ ..._check_service_client_config.json.baseline | 50 + ...ime_check_service_proto_list.json.baseline | 16 + .../fixtures/sample/src/index.js.baseline | 6 + .../fixtures/sample/src/index.ts.baseline | 8 +- .../gapic-alert_policy_service-v3.ts.baseline | 323 +++ .../test/gapic-group_service-v3.ts.baseline | 371 +++ .../test/gapic-metric_service-v3.ts.baseline | 465 ++++ ...otification_channel_service-v3.ts.baseline | 563 +++++ ...-service_monitoring_service-v3.ts.baseline | 565 +++++ .../gapic-uptime_check_service-v3.ts.baseline | 369 +++ typescript/test/unit/monitor.ts | 28 +- 31 files changed, 14208 insertions(+), 30 deletions(-) create mode 100644 typescript/test/testdata/monitoring/src/v3/alert_policy_service_client.ts.baseline create mode 100644 typescript/test/testdata/monitoring/src/v3/alert_policy_service_client_config.json.baseline create mode 100644 typescript/test/testdata/monitoring/src/v3/alert_policy_service_proto_list.json.baseline create mode 100644 typescript/test/testdata/monitoring/src/v3/group_service_client.ts.baseline create mode 100644 typescript/test/testdata/monitoring/src/v3/group_service_client_config.json.baseline create mode 100644 typescript/test/testdata/monitoring/src/v3/group_service_proto_list.json.baseline create mode 100644 typescript/test/testdata/monitoring/src/v3/metric_service_client.ts.baseline create mode 100644 typescript/test/testdata/monitoring/src/v3/metric_service_client_config.json.baseline create mode 100644 typescript/test/testdata/monitoring/src/v3/metric_service_proto_list.json.baseline create mode 100644 typescript/test/testdata/monitoring/src/v3/notification_channel_service_client.ts.baseline create mode 100644 typescript/test/testdata/monitoring/src/v3/notification_channel_service_client_config.json.baseline create mode 100644 typescript/test/testdata/monitoring/src/v3/notification_channel_service_proto_list.json.baseline create mode 100644 typescript/test/testdata/monitoring/src/v3/service_monitoring_service_client.ts.baseline create mode 100644 typescript/test/testdata/monitoring/src/v3/service_monitoring_service_client_config.json.baseline create mode 100644 typescript/test/testdata/monitoring/src/v3/service_monitoring_service_proto_list.json.baseline create mode 100644 typescript/test/testdata/monitoring/src/v3/uptime_check_service_client.ts.baseline create mode 100644 typescript/test/testdata/monitoring/src/v3/uptime_check_service_client_config.json.baseline create mode 100644 typescript/test/testdata/monitoring/src/v3/uptime_check_service_proto_list.json.baseline create mode 100644 typescript/test/testdata/monitoring/test/gapic-alert_policy_service-v3.ts.baseline create mode 100644 typescript/test/testdata/monitoring/test/gapic-group_service-v3.ts.baseline create mode 100644 typescript/test/testdata/monitoring/test/gapic-metric_service-v3.ts.baseline create mode 100644 typescript/test/testdata/monitoring/test/gapic-notification_channel_service-v3.ts.baseline create mode 100644 typescript/test/testdata/monitoring/test/gapic-service_monitoring_service-v3.ts.baseline create mode 100644 typescript/test/testdata/monitoring/test/gapic-uptime_check_service-v3.ts.baseline diff --git a/typescript/src/schema/api.ts b/typescript/src/schema/api.ts index 892f1a095..e5d8eed19 100644 --- a/typescript/src/schema/api.ts +++ b/typescript/src/schema/api.ts @@ -16,9 +16,9 @@ import * as plugin from '../../../pbjs-genfiles/plugin'; import * as fs from 'fs'; import * as path from 'path'; -import { Naming, Options as namingOptions } from './naming'; -import { Proto, MessagesMap } from './proto'; -import { ResourceDatabase, ResourceDescriptor } from './resourceDatabase'; +import {Naming, Options as namingOptions} from './naming'; +import {Proto, MessagesMap} from './proto'; +import {ResourceDatabase, ResourceDescriptor} from './resourceDatabase'; const googleGaxLocation = path.dirname(require.resolve('google-gax')); const gaxProtosLocation = path.join(googleGaxLocation, '..', '..', 'protos'); @@ -59,7 +59,6 @@ export class API { // parse resource map to Proto constructor this.protos = fileDescriptors .filter(fd => fd.name) - .filter(fd => !fs.existsSync(path.join(gaxProtosLocation, fd.name!))) .reduce((map, fd) => { map[fd.name!] = new Proto( fd, diff --git a/typescript/test/testdata/monitoring/proto.list.baseline b/typescript/test/testdata/monitoring/proto.list.baseline index f2467e62f..42caeb97a 100644 --- a/typescript/test/testdata/monitoring/proto.list.baseline +++ b/typescript/test/testdata/monitoring/proto.list.baseline @@ -3,15 +3,32 @@ google/protobuf/descriptor.proto google/api/annotations.proto google/api/client.proto google/api/field_behavior.proto +google/api/resource.proto +google/protobuf/any.proto +google/protobuf/timestamp.proto +google/api/distribution.proto +google/protobuf/duration.proto +google/monitoring/v3/common.proto +google/monitoring/v3/mutation_record.proto +google/protobuf/wrappers.proto +google/rpc/status.proto +google/monitoring/v3/alert.proto +google/protobuf/empty.proto +google/protobuf/field_mask.proto +google/monitoring/v3/alert_service.proto google/api/label.proto google/api/launch_stage.proto google/protobuf/struct.proto google/api/monitored_resource.proto -google/api/resource.proto -google/protobuf/duration.proto -google/protobuf/timestamp.proto +google/monitoring/v3/group.proto +google/monitoring/v3/group_service.proto +google/api/metric.proto +google/monitoring/v3/metric.proto +google/monitoring/v3/metric_service.proto +google/monitoring/v3/notification.proto +google/monitoring/v3/notification_service.proto google/type/calendar_period.proto google/monitoring/v3/service.proto -google/protobuf/empty.proto -google/protobuf/field_mask.proto google/monitoring/v3/service_service.proto +google/monitoring/v3/uptime.proto +google/monitoring/v3/uptime_service.proto diff --git a/typescript/test/testdata/monitoring/src/index.ts.baseline b/typescript/test/testdata/monitoring/src/index.ts.baseline index dc5a358b0..cf6f9adf2 100644 --- a/typescript/test/testdata/monitoring/src/index.ts.baseline +++ b/typescript/test/testdata/monitoring/src/index.ts.baseline @@ -17,7 +17,13 @@ // ** All changes to this file may be overwritten. ** import * as v3 from './v3'; -export {v3}; +const AlertPolicyServiceClient = v3.AlertPolicyServiceClient; +const GroupServiceClient = v3.GroupServiceClient; +const MetricServiceClient = v3.MetricServiceClient; +const NotificationChannelServiceClient = v3.NotificationChannelServiceClient; +const ServiceMonitoringServiceClient = v3.ServiceMonitoringServiceClient; +const UptimeCheckServiceClient = v3.UptimeCheckServiceClient; +export {v3, AlertPolicyServiceClient, GroupServiceClient, MetricServiceClient, NotificationChannelServiceClient, ServiceMonitoringServiceClient, UptimeCheckServiceClient}; // For compatibility with JavaScript libraries we need to provide this default export: // tslint:disable-next-line no-default-export -export default {v3}; +export default {v3, AlertPolicyServiceClient, GroupServiceClient, MetricServiceClient, NotificationChannelServiceClient, ServiceMonitoringServiceClient, UptimeCheckServiceClient}; diff --git a/typescript/test/testdata/monitoring/src/v3/alert_policy_service_client.ts.baseline b/typescript/test/testdata/monitoring/src/v3/alert_policy_service_client.ts.baseline new file mode 100644 index 000000000..a81005e90 --- /dev/null +++ b/typescript/test/testdata/monitoring/src/v3/alert_policy_service_client.ts.baseline @@ -0,0 +1,1593 @@ +// 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 gax from 'google-gax'; +import {APICallback, Callback, CallOptions, Descriptors, ClientOptions, PaginationCallback, PaginationResponse} from 'google-gax'; +import * as path from 'path'; + +import { Transform } from 'stream'; +import * as protosTypes from '../../protos/protos'; +import * as gapicConfig from './alert_policy_service_client_config.json'; + +const version = require('../../../package.json').version; + +/** + * The AlertPolicyService API is used to manage (list, create, delete, + * edit) alert policies in Stackdriver Monitoring. An alerting policy is + * a description of the conditions under which some aspect of your + * system is considered to be "unhealthy" and the ways to notify + * people or services about this state. In addition to using this API, alert + * policies can also be managed through + * [Stackdriver Monitoring](https://cloud.google.com/monitoring/docs/), + * which can be reached by clicking the "Monitoring" tab in + * [Cloud Console](https://console.cloud.google.com/). + * @class + * @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; + auth: gax.GoogleAuth; + alertPolicyServiceStub: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of AlertPolicyServiceClient. + * + * @param {object} [options] - The configuration object. See the subsequent + * parameters for more details. + * @param {object} [options.credentials] - Credentials object. + * @param {string} [options.credentials.client_email] + * @param {string} [options.credentials.private_key] + * @param {string} [options.email] - Account email address. Required when + * using a .pem or .p12 keyFilename. + * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or + * .p12 key downloaded from the Google Developers Console. If you provide + * a path to a JSON file, the projectId option below is not necessary. + * NOTE: .pem and .p12 require you to specify options.email as well. + * @param {number} [options.port] - The port on which to connect to + * the remote host. + * @param {string} [options.projectId] - The project ID from the Google + * Developer's Console, e.g. 'grape-spaceship-123'. We will also check + * the environment variable GCLOUD_PROJECT for your project ID. If your + * app is running in an environment which supports + * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, + * your project ID will be detected automatically. + * @param {function} [options.promise] - Custom promise module to use instead + * of native Promises. + * @param {string} [options.apiEndpoint] - The domain name of the + * API remote host. + */ + + constructor(opts?: ClientOptions) { + // Ensure that options include the service address and port. + const staticMembers = this.constructor as typeof AlertPolicyServiceClient; + const servicePath = opts && opts.servicePath ? + opts.servicePath : + ((opts && opts.apiEndpoint) ? opts.apiEndpoint : + staticMembers.servicePath); + const port = opts && opts.port ? opts.port : staticMembers.port; + + if (!opts) { + opts = {servicePath, port}; + } + opts.servicePath = opts.servicePath || servicePath; + opts.port = opts.port || port; + opts.clientConfig = opts.clientConfig || {}; + + const isBrowser = (typeof window !== 'undefined'); + if (isBrowser){ + opts.fallback = true; + } + // If we are in browser, we are already using fallback because of the + // "browser" field in package.json. + // But if we were explicitly requested to use fallback, let's do it now. + const gaxModule = !isBrowser && opts.fallback ? gax.fallback : gax; + + // Create a `gaxGrpc` object, with any grpc-specific options + // sent to the client. + opts.scopes = (this.constructor as typeof AlertPolicyServiceClient).scopes; + const gaxGrpc = new gaxModule.GrpcClient(opts); + + // Save the auth object to the client, for use by other methods. + this.auth = (gaxGrpc.auth as gax.GoogleAuth); + + // Determine the client header string. + const clientHeader = [ + `gax/${gaxModule.version}`, + `gapic/${version}`, + ]; + if (typeof process !== 'undefined' && 'versions' in process) { + clientHeader.push(`gl-node/${process.versions.node}`); + } else { + clientHeader.push(`gl-web/${gaxModule.version}`); + } + if (!opts.fallback) { + clientHeader.push(`grpc/${gaxGrpc.grpcVersion}`); + } + if (opts.libName && opts.libVersion) { + clientHeader.push(`${opts.libName}/${opts.libVersion}`); + } + // Load the applicable protos. + // For Node.js, pass the path to JSON proto file. + // For browsers, pass the JSON content. + + const nodejsProtoPath = path.join(__dirname, '..', '..', 'protos', 'protos.json'); + const protos = gaxGrpc.loadProto( + opts.fallback ? + 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 = { + projectAlertPolicyPathTemplate: new gaxModule.PathTemplate( + 'projects/{project}/alertPolicies/{alert_policy}' + ), + organizationAlertPolicyPathTemplate: new gaxModule.PathTemplate( + 'organizations/{organization}/alertPolicies/{alert_policy}' + ), + folderAlertPolicyPathTemplate: new gaxModule.PathTemplate( + 'folders/{folder}/alertPolicies/{alert_policy}' + ), + PathTemplate: new gaxModule.PathTemplate( + '*' + ), + projectGroupPathTemplate: new gaxModule.PathTemplate( + 'projects/{project}/groups/{group}' + ), + organizationGroupPathTemplate: new gaxModule.PathTemplate( + 'organizations/{organization}/groups/{group}' + ), + folderGroupPathTemplate: new gaxModule.PathTemplate( + 'folders/{folder}/groups/{group}' + ), + projectChannelDescriptorPathTemplate: new gaxModule.PathTemplate( + 'projects/{project}/notificationChannelDescriptors/{channel_descriptor}' + ), + organizationChannelDescriptorPathTemplate: new gaxModule.PathTemplate( + 'organizations/{organization}/notificationChannelDescriptors/{channel_descriptor}' + ), + folderChannelDescriptorPathTemplate: new gaxModule.PathTemplate( + 'folders/{folder}/notificationChannelDescriptors/{channel_descriptor}' + ), + projectNotificationChannelPathTemplate: new gaxModule.PathTemplate( + 'projects/{project}/notificationChannels/{notification_channel}' + ), + organizationNotificationChannelPathTemplate: new gaxModule.PathTemplate( + 'organizations/{organization}/notificationChannels/{notification_channel}' + ), + folderNotificationChannelPathTemplate: new gaxModule.PathTemplate( + 'folders/{folder}/notificationChannels/{notification_channel}' + ), + projectServicePathTemplate: new gaxModule.PathTemplate( + 'projects/{project}/services/{service}' + ), + organizationServicePathTemplate: new gaxModule.PathTemplate( + 'organizations/{organization}/services/{service}' + ), + folderServicePathTemplate: new gaxModule.PathTemplate( + 'folders/{folder}/services/{service}' + ), + projectServiceServiceLevelObjectivePathTemplate: new gaxModule.PathTemplate( + 'projects/{project}/services/{service}/serviceLevelObjectives/{service_level_objective}' + ), + organizationServiceServiceLevelObjectivePathTemplate: new gaxModule.PathTemplate( + 'organizations/{organization}/services/{service}/serviceLevelObjectives/{service_level_objective}' + ), + folderServiceServiceLevelObjectivePathTemplate: new gaxModule.PathTemplate( + 'folders/{folder}/services/{service}/serviceLevelObjectives/{service_level_objective}' + ), + projectUptimeCheckConfigPathTemplate: new gaxModule.PathTemplate( + 'projects/{project}/uptimeCheckConfigs/{uptime_check_config}' + ), + organizationUptimeCheckConfigPathTemplate: new gaxModule.PathTemplate( + 'organizations/{organization}/uptimeCheckConfigs/{uptime_check_config}' + ), + folderUptimeCheckConfigPathTemplate: new gaxModule.PathTemplate( + 'folders/{folder}/uptimeCheckConfigs/{uptime_check_config}' + ), + }; + + // 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 = { + listAlertPolicies: + new gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'alertPolicies') + }; + + // Put together the default options sent with requests. + const defaults = gaxGrpc.constructSettings( + 'google.monitoring.v3.AlertPolicyService', gapicConfig as gax.ClientConfig, + opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + + // Set up a dictionary of "inner API calls"; the core implementation + // of calling the API is handled in `google-gax`, with this code + // merely providing the destination and request information. + this._innerApiCalls = {}; + + // Put together the "service stub" for + // google.monitoring.v3.AlertPolicyService. + this.alertPolicyServiceStub = gaxGrpc.createStub( + opts.fallback ? + (protos as protobuf.Root).lookupService('google.monitoring.v3.AlertPolicyService') : + // tslint:disable-next-line no-any + (protos as any).google.monitoring.v3.AlertPolicyService, + opts) as Promise<{[method: string]: Function}>; + + // Iterate over each of the methods that the service provides + // and create an API call method for each. + const alertPolicyServiceStubMethods = + ['listAlertPolicies', 'getAlertPolicy', 'createAlertPolicy', 'deleteAlertPolicy', 'updateAlertPolicy']; + + for (const methodName of alertPolicyServiceStubMethods) { + const innerCallPromise = this.alertPolicyServiceStub.then( + stub => (...args: Array<{}>) => { + if (this._terminated) { + return Promise.reject('The client has already been closed.'); + } + return stub[methodName].apply(stub, args); + }, + (err: Error|null|undefined) => () => { + throw err; + }); + + const apiCall = gaxModule.createApiCall( + innerCallPromise, + defaults[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); + }; + } + } + + /** + * The DNS address for this API service. + */ + static get servicePath() { + return 'monitoring.googleapis.com'; + } + + /** + * The DNS address for this API service - same as servicePath(), + * exists for compatibility reasons. + */ + static get apiEndpoint() { + return 'monitoring.googleapis.com'; + } + + /** + * The port for this API service. + */ + static get port() { + return 443; + } + + /** + * The scopes needed to make gRPC calls for every method defined + * in this service. + */ + static get scopes() { + return [ + 'https://www.googleapis.com/auth/cloud-platform', + 'https://www.googleapis.com/auth/monitoring', + 'https://www.googleapis.com/auth/monitoring.read' + ]; + } + + getProjectId(): Promise; + getProjectId(callback: Callback): void; + /** + * Return the project ID used by this class. + * @param {function(Error, string)} callback - the callback to + * be called with the current project Id. + */ + getProjectId(callback?: Callback): + Promise|void { + if (callback) { + this.auth.getProjectId(callback); + return; + } + return this.auth.getProjectId(); + } + + // ------------------- + // -- Service calls -- + // ------------------- + getAlertPolicy( + request: protosTypes.google.monitoring.v3.IGetAlertPolicyRequest, + options?: gax.CallOptions): + Promise<[ + protosTypes.google.monitoring.v3.IAlertPolicy, + protosTypes.google.monitoring.v3.IGetAlertPolicyRequest|undefined, {}|undefined + ]>; + getAlertPolicy( + request: protosTypes.google.monitoring.v3.IGetAlertPolicyRequest, + options: gax.CallOptions, + callback: Callback< + protosTypes.google.monitoring.v3.IAlertPolicy, + protosTypes.google.monitoring.v3.IGetAlertPolicyRequest|undefined, + {}|undefined>): void; +/** + * Gets a single alerting policy. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The alerting policy to retrieve. The format is + * + * projects/[PROJECT_ID]/alertPolicies/[ALERT_POLICY_ID] + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [AlertPolicy]{@link google.monitoring.v3.AlertPolicy}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ + getAlertPolicy( + request: protosTypes.google.monitoring.v3.IGetAlertPolicyRequest, + optionsOrCallback?: gax.CallOptions|Callback< + protosTypes.google.monitoring.v3.IAlertPolicy, + protosTypes.google.monitoring.v3.IGetAlertPolicyRequest|undefined, {}|undefined>, + callback?: Callback< + protosTypes.google.monitoring.v3.IAlertPolicy, + protosTypes.google.monitoring.v3.IGetAlertPolicyRequest|undefined, + {}|undefined>): + Promise<[ + protosTypes.google.monitoring.v3.IAlertPolicy, + protosTypes.google.monitoring.v3.IGetAlertPolicyRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as gax.CallOptions; + } + 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 || '', + }); + return this._innerApiCalls.getAlertPolicy(request, options, callback); + } + createAlertPolicy( + request: protosTypes.google.monitoring.v3.ICreateAlertPolicyRequest, + options?: gax.CallOptions): + Promise<[ + protosTypes.google.monitoring.v3.IAlertPolicy, + protosTypes.google.monitoring.v3.ICreateAlertPolicyRequest|undefined, {}|undefined + ]>; + createAlertPolicy( + request: protosTypes.google.monitoring.v3.ICreateAlertPolicyRequest, + options: gax.CallOptions, + callback: Callback< + protosTypes.google.monitoring.v3.IAlertPolicy, + protosTypes.google.monitoring.v3.ICreateAlertPolicyRequest|undefined, + {}|undefined>): void; +/** + * Creates a new alerting policy. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The project in which to create the alerting policy. The format is + * `projects/[PROJECT_ID]`. + * + * Note that this field names the parent container in which the alerting + * policy will be written, not the name of the created policy. The alerting + * policy that is returned will have a name that contains a normalized + * representation of this name as a prefix but adds a suffix of the form + * `/alertPolicies/[POLICY_ID]`, identifying the policy in the container. + * @param {google.monitoring.v3.AlertPolicy} request.alertPolicy + * Required. The requested alerting policy. You should omit the `name` field in this + * policy. The name will be returned in the new policy, including + * a new [ALERT_POLICY_ID] value. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [AlertPolicy]{@link google.monitoring.v3.AlertPolicy}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ + createAlertPolicy( + request: protosTypes.google.monitoring.v3.ICreateAlertPolicyRequest, + optionsOrCallback?: gax.CallOptions|Callback< + protosTypes.google.monitoring.v3.IAlertPolicy, + protosTypes.google.monitoring.v3.ICreateAlertPolicyRequest|undefined, {}|undefined>, + callback?: Callback< + protosTypes.google.monitoring.v3.IAlertPolicy, + protosTypes.google.monitoring.v3.ICreateAlertPolicyRequest|undefined, + {}|undefined>): + Promise<[ + protosTypes.google.monitoring.v3.IAlertPolicy, + protosTypes.google.monitoring.v3.ICreateAlertPolicyRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as gax.CallOptions; + } + 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 || '', + }); + return this._innerApiCalls.createAlertPolicy(request, options, callback); + } + deleteAlertPolicy( + request: protosTypes.google.monitoring.v3.IDeleteAlertPolicyRequest, + options?: gax.CallOptions): + Promise<[ + protosTypes.google.protobuf.IEmpty, + protosTypes.google.monitoring.v3.IDeleteAlertPolicyRequest|undefined, {}|undefined + ]>; + deleteAlertPolicy( + request: protosTypes.google.monitoring.v3.IDeleteAlertPolicyRequest, + options: gax.CallOptions, + callback: Callback< + protosTypes.google.protobuf.IEmpty, + protosTypes.google.monitoring.v3.IDeleteAlertPolicyRequest|undefined, + {}|undefined>): void; +/** + * Deletes an alerting policy. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The alerting policy to delete. The format is: + * + * projects/[PROJECT_ID]/alertPolicies/[ALERT_POLICY_ID] + * + * For more information, see [AlertPolicy][google.monitoring.v3.AlertPolicy]. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ + deleteAlertPolicy( + request: protosTypes.google.monitoring.v3.IDeleteAlertPolicyRequest, + optionsOrCallback?: gax.CallOptions|Callback< + protosTypes.google.protobuf.IEmpty, + protosTypes.google.monitoring.v3.IDeleteAlertPolicyRequest|undefined, {}|undefined>, + callback?: Callback< + protosTypes.google.protobuf.IEmpty, + protosTypes.google.monitoring.v3.IDeleteAlertPolicyRequest|undefined, + {}|undefined>): + Promise<[ + protosTypes.google.protobuf.IEmpty, + protosTypes.google.monitoring.v3.IDeleteAlertPolicyRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as gax.CallOptions; + } + 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 || '', + }); + return this._innerApiCalls.deleteAlertPolicy(request, options, callback); + } + updateAlertPolicy( + request: protosTypes.google.monitoring.v3.IUpdateAlertPolicyRequest, + options?: gax.CallOptions): + Promise<[ + protosTypes.google.monitoring.v3.IAlertPolicy, + protosTypes.google.monitoring.v3.IUpdateAlertPolicyRequest|undefined, {}|undefined + ]>; + updateAlertPolicy( + request: protosTypes.google.monitoring.v3.IUpdateAlertPolicyRequest, + options: gax.CallOptions, + callback: Callback< + protosTypes.google.monitoring.v3.IAlertPolicy, + protosTypes.google.monitoring.v3.IUpdateAlertPolicyRequest|undefined, + {}|undefined>): void; +/** + * Updates an alerting policy. You can either replace the entire policy with + * a new one or replace only certain fields in the current alerting policy by + * specifying the fields to be updated via `updateMask`. Returns the + * updated alerting policy. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.protobuf.FieldMask} request.updateMask + * Optional. A list of alerting policy field names. If this field is not + * empty, each listed field in the existing alerting policy is set to the + * value of the corresponding field in the supplied policy (`alert_policy`), + * or to the field's default value if the field is not in the supplied + * alerting policy. Fields not listed retain their previous value. + * + * Examples of valid field masks include `display_name`, `documentation`, + * `documentation.content`, `documentation.mime_type`, `user_labels`, + * `user_label.nameofkey`, `enabled`, `conditions`, `combiner`, etc. + * + * If this field is empty, then the supplied alerting policy replaces the + * existing policy. It is the same as deleting the existing policy and + * adding the supplied policy, except for the following: + * + * + The new policy will have the same `[ALERT_POLICY_ID]` as the former + * policy. This gives you continuity with the former policy in your + * notifications and incidents. + * + Conditions in the new policy will keep their former `[CONDITION_ID]` if + * the supplied condition includes the `name` field with that + * `[CONDITION_ID]`. If the supplied condition omits the `name` field, + * then a new `[CONDITION_ID]` is created. + * @param {google.monitoring.v3.AlertPolicy} request.alertPolicy + * Required. The updated alerting policy or the updated values for the + * fields listed in `update_mask`. + * If `update_mask` is not empty, any fields in this policy that are + * not in `update_mask` are ignored. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [AlertPolicy]{@link google.monitoring.v3.AlertPolicy}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ + updateAlertPolicy( + request: protosTypes.google.monitoring.v3.IUpdateAlertPolicyRequest, + optionsOrCallback?: gax.CallOptions|Callback< + protosTypes.google.monitoring.v3.IAlertPolicy, + protosTypes.google.monitoring.v3.IUpdateAlertPolicyRequest|undefined, {}|undefined>, + callback?: Callback< + protosTypes.google.monitoring.v3.IAlertPolicy, + protosTypes.google.monitoring.v3.IUpdateAlertPolicyRequest|undefined, + {}|undefined>): + Promise<[ + protosTypes.google.monitoring.v3.IAlertPolicy, + protosTypes.google.monitoring.v3.IUpdateAlertPolicyRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as gax.CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'alert_policy.name': request.alertPolicy!.name || '', + }); + return this._innerApiCalls.updateAlertPolicy(request, options, callback); + } + + listAlertPolicies( + request: protosTypes.google.monitoring.v3.IListAlertPoliciesRequest, + options?: gax.CallOptions): + Promise<[ + protosTypes.google.monitoring.v3.IAlertPolicy[], + protosTypes.google.monitoring.v3.IListAlertPoliciesRequest|null, + protosTypes.google.monitoring.v3.IListAlertPoliciesResponse + ]>; + listAlertPolicies( + request: protosTypes.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>): void; +/** + * Lists the existing alerting policies for the project. + * + * @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] + * + * 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 + * [GetAlertPolicy][google.monitoring.v3.AlertPolicyService.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](/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](/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 {Promise} - The promise which resolves to an array. + * The first element of the array is Array of [AlertPolicy]{@link google.monitoring.v3.AlertPolicy}. + * The client library support auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * + * When autoPaginate: false is specified through options, the array has three elements. + * The first element is Array of [AlertPolicy]{@link google.monitoring.v3.AlertPolicy} that corresponds to + * the one page received from the API server. + * If the second element is not null it contains the request object of type [ListAlertPoliciesRequest]{@link google.monitoring.v3.ListAlertPoliciesRequest} + * that can be used to obtain the next page of the results. + * If it is null, the next page does not exist. + * The third element contains the raw response received from the API server. Its type is + * [ListAlertPoliciesResponse]{@link google.monitoring.v3.ListAlertPoliciesResponse}. + * + * The promise has a method named "cancel" which cancels the ongoing API call. + */ + listAlertPolicies( + request: protosTypes.google.monitoring.v3.IListAlertPoliciesRequest, + optionsOrCallback?: gax.CallOptions|Callback< + protosTypes.google.monitoring.v3.IAlertPolicy[], + protosTypes.google.monitoring.v3.IListAlertPoliciesRequest|null, + protosTypes.google.monitoring.v3.IListAlertPoliciesResponse>, + callback?: Callback< + protosTypes.google.monitoring.v3.IAlertPolicy[], + protosTypes.google.monitoring.v3.IListAlertPoliciesRequest|null, + protosTypes.google.monitoring.v3.IListAlertPoliciesResponse>): + Promise<[ + protosTypes.google.monitoring.v3.IAlertPolicy[], + protosTypes.google.monitoring.v3.IListAlertPoliciesRequest|null, + protosTypes.google.monitoring.v3.IListAlertPoliciesResponse + ]>|void { + request = request || {}; + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as gax.CallOptions; + } + 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 || '', + }); + return this._innerApiCalls.listAlertPolicies(request, options, callback); + } + +/** + * Equivalent to {@link listAlertPolicies}, but returns a NodeJS Stream object. + * + * This fetches the paged responses for {@link listAlertPolicies} continuously + * and invokes the callback registered for 'data' event for each element in the + * responses. + * + * The returned object has 'end' method when no more elements are required. + * + * autoPaginate option will be ignored. + * + * @see {@link https://nodejs.org/api/stream.html} + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The project whose alert policies are to be listed. The format is + * + * projects/[PROJECT_ID] + * + * 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 + * [GetAlertPolicy][google.monitoring.v3.AlertPolicyService.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](/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](/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 {Stream} + * An object stream which emits an object representing [AlertPolicy]{@link google.monitoring.v3.AlertPolicy} on 'data' event. + */ + listAlertPoliciesStream( + request?: protosTypes.google.monitoring.v3.IListAlertPoliciesRequest, + options?: gax.CallOptions | {}): + Transform{ + request = request || {}; + const callSettings = new gax.CallSettings(options); + return this._descriptors.page.listAlertPolicies.createStream( + this._innerApiCalls.listAlertPolicies as gax.GaxCall, + request, + callSettings + ); + } + // -------------------- + // -- Path templates -- + // -------------------- + + /** + * Return a fully-qualified projectAlertPolicy resource name string. + * + * @param {string} project + * @param {string} alert_policy + * @returns {string} Resource name string. + */ + projectAlertPolicyPath(project:string,alertPolicy:string) { + return this._pathTemplates.projectAlertPolicyPathTemplate.render({ + project: project, + alert_policy: alertPolicy, + }); + } + + /** + * Parse the project from ProjectAlertPolicy resource. + * + * @param {string} projectAlertPolicyName + * A fully-qualified path representing project_alert_policy resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectAlertPolicyName(projectAlertPolicyName: string) { + return this._pathTemplates.projectAlertPolicyPathTemplate.match(projectAlertPolicyName).project; + } + + /** + * Parse the alert_policy from ProjectAlertPolicy resource. + * + * @param {string} projectAlertPolicyName + * A fully-qualified path representing project_alert_policy resource. + * @returns {string} A string representing the alert_policy. + */ + matchAlertPolicyFromProjectAlertPolicyName(projectAlertPolicyName: string) { + return this._pathTemplates.projectAlertPolicyPathTemplate.match(projectAlertPolicyName).alert_policy; + } + + /** + * Return a fully-qualified organizationAlertPolicy resource name string. + * + * @param {string} organization + * @param {string} alert_policy + * @returns {string} Resource name string. + */ + organizationAlertPolicyPath(organization:string,alertPolicy:string) { + return this._pathTemplates.organizationAlertPolicyPathTemplate.render({ + organization: organization, + alert_policy: alertPolicy, + }); + } + + /** + * Parse the organization from OrganizationAlertPolicy resource. + * + * @param {string} organizationAlertPolicyName + * A fully-qualified path representing organization_alert_policy resource. + * @returns {string} A string representing the organization. + */ + matchOrganizationFromOrganizationAlertPolicyName(organizationAlertPolicyName: string) { + return this._pathTemplates.organizationAlertPolicyPathTemplate.match(organizationAlertPolicyName).organization; + } + + /** + * Parse the alert_policy from OrganizationAlertPolicy resource. + * + * @param {string} organizationAlertPolicyName + * A fully-qualified path representing organization_alert_policy resource. + * @returns {string} A string representing the alert_policy. + */ + matchAlertPolicyFromOrganizationAlertPolicyName(organizationAlertPolicyName: string) { + return this._pathTemplates.organizationAlertPolicyPathTemplate.match(organizationAlertPolicyName).alert_policy; + } + + /** + * Return a fully-qualified folderAlertPolicy resource name string. + * + * @param {string} folder + * @param {string} alert_policy + * @returns {string} Resource name string. + */ + folderAlertPolicyPath(folder:string,alertPolicy:string) { + return this._pathTemplates.folderAlertPolicyPathTemplate.render({ + folder: folder, + alert_policy: alertPolicy, + }); + } + + /** + * Parse the folder from FolderAlertPolicy resource. + * + * @param {string} folderAlertPolicyName + * A fully-qualified path representing folder_alert_policy resource. + * @returns {string} A string representing the folder. + */ + matchFolderFromFolderAlertPolicyName(folderAlertPolicyName: string) { + return this._pathTemplates.folderAlertPolicyPathTemplate.match(folderAlertPolicyName).folder; + } + + /** + * Parse the alert_policy from FolderAlertPolicy resource. + * + * @param {string} folderAlertPolicyName + * A fully-qualified path representing folder_alert_policy resource. + * @returns {string} A string representing the alert_policy. + */ + matchAlertPolicyFromFolderAlertPolicyName(folderAlertPolicyName: string) { + return this._pathTemplates.folderAlertPolicyPathTemplate.match(folderAlertPolicyName).alert_policy; + } + + /** + * Return a fully-qualified resource name string. + * + * @returns {string} Resource name string. + */ + Path() { + return this._pathTemplates.PathTemplate.render({ + }); + } + + /** + * Return a fully-qualified projectGroup resource name string. + * + * @param {string} project + * @param {string} group + * @returns {string} Resource name string. + */ + projectGroupPath(project:string,group:string) { + return this._pathTemplates.projectGroupPathTemplate.render({ + project: project, + group: group, + }); + } + + /** + * Parse the project from ProjectGroup resource. + * + * @param {string} projectGroupName + * A fully-qualified path representing project_group resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectGroupName(projectGroupName: string) { + return this._pathTemplates.projectGroupPathTemplate.match(projectGroupName).project; + } + + /** + * Parse the group from ProjectGroup resource. + * + * @param {string} projectGroupName + * A fully-qualified path representing project_group resource. + * @returns {string} A string representing the group. + */ + matchGroupFromProjectGroupName(projectGroupName: string) { + return this._pathTemplates.projectGroupPathTemplate.match(projectGroupName).group; + } + + /** + * Return a fully-qualified organizationGroup resource name string. + * + * @param {string} organization + * @param {string} group + * @returns {string} Resource name string. + */ + organizationGroupPath(organization:string,group:string) { + return this._pathTemplates.organizationGroupPathTemplate.render({ + organization: organization, + group: group, + }); + } + + /** + * Parse the organization from OrganizationGroup resource. + * + * @param {string} organizationGroupName + * A fully-qualified path representing organization_group resource. + * @returns {string} A string representing the organization. + */ + matchOrganizationFromOrganizationGroupName(organizationGroupName: string) { + return this._pathTemplates.organizationGroupPathTemplate.match(organizationGroupName).organization; + } + + /** + * Parse the group from OrganizationGroup resource. + * + * @param {string} organizationGroupName + * A fully-qualified path representing organization_group resource. + * @returns {string} A string representing the group. + */ + matchGroupFromOrganizationGroupName(organizationGroupName: string) { + return this._pathTemplates.organizationGroupPathTemplate.match(organizationGroupName).group; + } + + /** + * Return a fully-qualified folderGroup resource name string. + * + * @param {string} folder + * @param {string} group + * @returns {string} Resource name string. + */ + folderGroupPath(folder:string,group:string) { + return this._pathTemplates.folderGroupPathTemplate.render({ + folder: folder, + group: group, + }); + } + + /** + * Parse the folder from FolderGroup resource. + * + * @param {string} folderGroupName + * A fully-qualified path representing folder_group resource. + * @returns {string} A string representing the folder. + */ + matchFolderFromFolderGroupName(folderGroupName: string) { + return this._pathTemplates.folderGroupPathTemplate.match(folderGroupName).folder; + } + + /** + * Parse the group from FolderGroup resource. + * + * @param {string} folderGroupName + * A fully-qualified path representing folder_group resource. + * @returns {string} A string representing the group. + */ + matchGroupFromFolderGroupName(folderGroupName: string) { + return this._pathTemplates.folderGroupPathTemplate.match(folderGroupName).group; + } + + /** + * Return a fully-qualified projectChannelDescriptor resource name string. + * + * @param {string} project + * @param {string} channel_descriptor + * @returns {string} Resource name string. + */ + projectChannelDescriptorPath(project:string,channelDescriptor:string) { + return this._pathTemplates.projectChannelDescriptorPathTemplate.render({ + project: project, + channel_descriptor: channelDescriptor, + }); + } + + /** + * Parse the project from ProjectChannelDescriptor resource. + * + * @param {string} projectChannelDescriptorName + * A fully-qualified path representing project_channel_descriptor resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectChannelDescriptorName(projectChannelDescriptorName: string) { + return this._pathTemplates.projectChannelDescriptorPathTemplate.match(projectChannelDescriptorName).project; + } + + /** + * Parse the channel_descriptor from ProjectChannelDescriptor resource. + * + * @param {string} projectChannelDescriptorName + * A fully-qualified path representing project_channel_descriptor resource. + * @returns {string} A string representing the channel_descriptor. + */ + matchChannelDescriptorFromProjectChannelDescriptorName(projectChannelDescriptorName: string) { + return this._pathTemplates.projectChannelDescriptorPathTemplate.match(projectChannelDescriptorName).channel_descriptor; + } + + /** + * Return a fully-qualified organizationChannelDescriptor resource name string. + * + * @param {string} organization + * @param {string} channel_descriptor + * @returns {string} Resource name string. + */ + organizationChannelDescriptorPath(organization:string,channelDescriptor:string) { + return this._pathTemplates.organizationChannelDescriptorPathTemplate.render({ + organization: organization, + channel_descriptor: channelDescriptor, + }); + } + + /** + * Parse the organization from OrganizationChannelDescriptor resource. + * + * @param {string} organizationChannelDescriptorName + * A fully-qualified path representing organization_channel_descriptor resource. + * @returns {string} A string representing the organization. + */ + matchOrganizationFromOrganizationChannelDescriptorName(organizationChannelDescriptorName: string) { + return this._pathTemplates.organizationChannelDescriptorPathTemplate.match(organizationChannelDescriptorName).organization; + } + + /** + * Parse the channel_descriptor from OrganizationChannelDescriptor resource. + * + * @param {string} organizationChannelDescriptorName + * A fully-qualified path representing organization_channel_descriptor resource. + * @returns {string} A string representing the channel_descriptor. + */ + matchChannelDescriptorFromOrganizationChannelDescriptorName(organizationChannelDescriptorName: string) { + return this._pathTemplates.organizationChannelDescriptorPathTemplate.match(organizationChannelDescriptorName).channel_descriptor; + } + + /** + * Return a fully-qualified folderChannelDescriptor resource name string. + * + * @param {string} folder + * @param {string} channel_descriptor + * @returns {string} Resource name string. + */ + folderChannelDescriptorPath(folder:string,channelDescriptor:string) { + return this._pathTemplates.folderChannelDescriptorPathTemplate.render({ + folder: folder, + channel_descriptor: channelDescriptor, + }); + } + + /** + * Parse the folder from FolderChannelDescriptor resource. + * + * @param {string} folderChannelDescriptorName + * A fully-qualified path representing folder_channel_descriptor resource. + * @returns {string} A string representing the folder. + */ + matchFolderFromFolderChannelDescriptorName(folderChannelDescriptorName: string) { + return this._pathTemplates.folderChannelDescriptorPathTemplate.match(folderChannelDescriptorName).folder; + } + + /** + * Parse the channel_descriptor from FolderChannelDescriptor resource. + * + * @param {string} folderChannelDescriptorName + * A fully-qualified path representing folder_channel_descriptor resource. + * @returns {string} A string representing the channel_descriptor. + */ + matchChannelDescriptorFromFolderChannelDescriptorName(folderChannelDescriptorName: string) { + return this._pathTemplates.folderChannelDescriptorPathTemplate.match(folderChannelDescriptorName).channel_descriptor; + } + + /** + * Return a fully-qualified projectNotificationChannel resource name string. + * + * @param {string} project + * @param {string} notification_channel + * @returns {string} Resource name string. + */ + projectNotificationChannelPath(project:string,notificationChannel:string) { + return this._pathTemplates.projectNotificationChannelPathTemplate.render({ + project: project, + notification_channel: notificationChannel, + }); + } + + /** + * Parse the project from ProjectNotificationChannel resource. + * + * @param {string} projectNotificationChannelName + * A fully-qualified path representing project_notification_channel resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectNotificationChannelName(projectNotificationChannelName: string) { + return this._pathTemplates.projectNotificationChannelPathTemplate.match(projectNotificationChannelName).project; + } + + /** + * Parse the notification_channel from ProjectNotificationChannel resource. + * + * @param {string} projectNotificationChannelName + * A fully-qualified path representing project_notification_channel resource. + * @returns {string} A string representing the notification_channel. + */ + matchNotificationChannelFromProjectNotificationChannelName(projectNotificationChannelName: string) { + return this._pathTemplates.projectNotificationChannelPathTemplate.match(projectNotificationChannelName).notification_channel; + } + + /** + * Return a fully-qualified organizationNotificationChannel resource name string. + * + * @param {string} organization + * @param {string} notification_channel + * @returns {string} Resource name string. + */ + organizationNotificationChannelPath(organization:string,notificationChannel:string) { + return this._pathTemplates.organizationNotificationChannelPathTemplate.render({ + organization: organization, + notification_channel: notificationChannel, + }); + } + + /** + * Parse the organization from OrganizationNotificationChannel resource. + * + * @param {string} organizationNotificationChannelName + * A fully-qualified path representing organization_notification_channel resource. + * @returns {string} A string representing the organization. + */ + matchOrganizationFromOrganizationNotificationChannelName(organizationNotificationChannelName: string) { + return this._pathTemplates.organizationNotificationChannelPathTemplate.match(organizationNotificationChannelName).organization; + } + + /** + * Parse the notification_channel from OrganizationNotificationChannel resource. + * + * @param {string} organizationNotificationChannelName + * A fully-qualified path representing organization_notification_channel resource. + * @returns {string} A string representing the notification_channel. + */ + matchNotificationChannelFromOrganizationNotificationChannelName(organizationNotificationChannelName: string) { + return this._pathTemplates.organizationNotificationChannelPathTemplate.match(organizationNotificationChannelName).notification_channel; + } + + /** + * Return a fully-qualified folderNotificationChannel resource name string. + * + * @param {string} folder + * @param {string} notification_channel + * @returns {string} Resource name string. + */ + folderNotificationChannelPath(folder:string,notificationChannel:string) { + return this._pathTemplates.folderNotificationChannelPathTemplate.render({ + folder: folder, + notification_channel: notificationChannel, + }); + } + + /** + * Parse the folder from FolderNotificationChannel resource. + * + * @param {string} folderNotificationChannelName + * A fully-qualified path representing folder_notification_channel resource. + * @returns {string} A string representing the folder. + */ + matchFolderFromFolderNotificationChannelName(folderNotificationChannelName: string) { + return this._pathTemplates.folderNotificationChannelPathTemplate.match(folderNotificationChannelName).folder; + } + + /** + * Parse the notification_channel from FolderNotificationChannel resource. + * + * @param {string} folderNotificationChannelName + * A fully-qualified path representing folder_notification_channel resource. + * @returns {string} A string representing the notification_channel. + */ + matchNotificationChannelFromFolderNotificationChannelName(folderNotificationChannelName: string) { + return this._pathTemplates.folderNotificationChannelPathTemplate.match(folderNotificationChannelName).notification_channel; + } + + /** + * Return a fully-qualified projectService resource name string. + * + * @param {string} project + * @param {string} service + * @returns {string} Resource name string. + */ + projectServicePath(project:string,service:string) { + return this._pathTemplates.projectServicePathTemplate.render({ + project: project, + service: service, + }); + } + + /** + * Parse the project from ProjectService resource. + * + * @param {string} projectServiceName + * A fully-qualified path representing project_service resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectServiceName(projectServiceName: string) { + return this._pathTemplates.projectServicePathTemplate.match(projectServiceName).project; + } + + /** + * Parse the service from ProjectService resource. + * + * @param {string} projectServiceName + * A fully-qualified path representing project_service resource. + * @returns {string} A string representing the service. + */ + matchServiceFromProjectServiceName(projectServiceName: string) { + return this._pathTemplates.projectServicePathTemplate.match(projectServiceName).service; + } + + /** + * Return a fully-qualified organizationService resource name string. + * + * @param {string} organization + * @param {string} service + * @returns {string} Resource name string. + */ + organizationServicePath(organization:string,service:string) { + return this._pathTemplates.organizationServicePathTemplate.render({ + organization: organization, + service: service, + }); + } + + /** + * Parse the organization from OrganizationService resource. + * + * @param {string} organizationServiceName + * A fully-qualified path representing organization_service resource. + * @returns {string} A string representing the organization. + */ + matchOrganizationFromOrganizationServiceName(organizationServiceName: string) { + return this._pathTemplates.organizationServicePathTemplate.match(organizationServiceName).organization; + } + + /** + * Parse the service from OrganizationService resource. + * + * @param {string} organizationServiceName + * A fully-qualified path representing organization_service resource. + * @returns {string} A string representing the service. + */ + matchServiceFromOrganizationServiceName(organizationServiceName: string) { + return this._pathTemplates.organizationServicePathTemplate.match(organizationServiceName).service; + } + + /** + * Return a fully-qualified folderService resource name string. + * + * @param {string} folder + * @param {string} service + * @returns {string} Resource name string. + */ + folderServicePath(folder:string,service:string) { + return this._pathTemplates.folderServicePathTemplate.render({ + folder: folder, + service: service, + }); + } + + /** + * Parse the folder from FolderService resource. + * + * @param {string} folderServiceName + * A fully-qualified path representing folder_service resource. + * @returns {string} A string representing the folder. + */ + matchFolderFromFolderServiceName(folderServiceName: string) { + return this._pathTemplates.folderServicePathTemplate.match(folderServiceName).folder; + } + + /** + * Parse the service from FolderService resource. + * + * @param {string} folderServiceName + * A fully-qualified path representing folder_service resource. + * @returns {string} A string representing the service. + */ + matchServiceFromFolderServiceName(folderServiceName: string) { + return this._pathTemplates.folderServicePathTemplate.match(folderServiceName).service; + } + + /** + * Return a fully-qualified projectServiceServiceLevelObjective resource name string. + * + * @param {string} project + * @param {string} service + * @param {string} service_level_objective + * @returns {string} Resource name string. + */ + projectServiceServiceLevelObjectivePath(project:string,service:string,serviceLevelObjective:string) { + return this._pathTemplates.projectServiceServiceLevelObjectivePathTemplate.render({ + project: project, + service: service, + service_level_objective: serviceLevelObjective, + }); + } + + /** + * Parse the project from ProjectServiceServiceLevelObjective resource. + * + * @param {string} projectServiceServiceLevelObjectiveName + * A fully-qualified path representing project_service_service_level_objective resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectServiceServiceLevelObjectiveName(projectServiceServiceLevelObjectiveName: string) { + return this._pathTemplates.projectServiceServiceLevelObjectivePathTemplate.match(projectServiceServiceLevelObjectiveName).project; + } + + /** + * Parse the service from ProjectServiceServiceLevelObjective resource. + * + * @param {string} projectServiceServiceLevelObjectiveName + * A fully-qualified path representing project_service_service_level_objective resource. + * @returns {string} A string representing the service. + */ + matchServiceFromProjectServiceServiceLevelObjectiveName(projectServiceServiceLevelObjectiveName: string) { + return this._pathTemplates.projectServiceServiceLevelObjectivePathTemplate.match(projectServiceServiceLevelObjectiveName).service; + } + + /** + * Parse the service_level_objective from ProjectServiceServiceLevelObjective resource. + * + * @param {string} projectServiceServiceLevelObjectiveName + * A fully-qualified path representing project_service_service_level_objective resource. + * @returns {string} A string representing the service_level_objective. + */ + matchServiceLevelObjectiveFromProjectServiceServiceLevelObjectiveName(projectServiceServiceLevelObjectiveName: string) { + return this._pathTemplates.projectServiceServiceLevelObjectivePathTemplate.match(projectServiceServiceLevelObjectiveName).service_level_objective; + } + + /** + * Return a fully-qualified organizationServiceServiceLevelObjective resource name string. + * + * @param {string} organization + * @param {string} service + * @param {string} service_level_objective + * @returns {string} Resource name string. + */ + organizationServiceServiceLevelObjectivePath(organization:string,service:string,serviceLevelObjective:string) { + return this._pathTemplates.organizationServiceServiceLevelObjectivePathTemplate.render({ + organization: organization, + service: service, + service_level_objective: serviceLevelObjective, + }); + } + + /** + * Parse the organization from OrganizationServiceServiceLevelObjective resource. + * + * @param {string} organizationServiceServiceLevelObjectiveName + * A fully-qualified path representing organization_service_service_level_objective resource. + * @returns {string} A string representing the organization. + */ + matchOrganizationFromOrganizationServiceServiceLevelObjectiveName(organizationServiceServiceLevelObjectiveName: string) { + return this._pathTemplates.organizationServiceServiceLevelObjectivePathTemplate.match(organizationServiceServiceLevelObjectiveName).organization; + } + + /** + * Parse the service from OrganizationServiceServiceLevelObjective resource. + * + * @param {string} organizationServiceServiceLevelObjectiveName + * A fully-qualified path representing organization_service_service_level_objective resource. + * @returns {string} A string representing the service. + */ + matchServiceFromOrganizationServiceServiceLevelObjectiveName(organizationServiceServiceLevelObjectiveName: string) { + return this._pathTemplates.organizationServiceServiceLevelObjectivePathTemplate.match(organizationServiceServiceLevelObjectiveName).service; + } + + /** + * Parse the service_level_objective from OrganizationServiceServiceLevelObjective resource. + * + * @param {string} organizationServiceServiceLevelObjectiveName + * A fully-qualified path representing organization_service_service_level_objective resource. + * @returns {string} A string representing the service_level_objective. + */ + matchServiceLevelObjectiveFromOrganizationServiceServiceLevelObjectiveName(organizationServiceServiceLevelObjectiveName: string) { + return this._pathTemplates.organizationServiceServiceLevelObjectivePathTemplate.match(organizationServiceServiceLevelObjectiveName).service_level_objective; + } + + /** + * Return a fully-qualified folderServiceServiceLevelObjective resource name string. + * + * @param {string} folder + * @param {string} service + * @param {string} service_level_objective + * @returns {string} Resource name string. + */ + folderServiceServiceLevelObjectivePath(folder:string,service:string,serviceLevelObjective:string) { + return this._pathTemplates.folderServiceServiceLevelObjectivePathTemplate.render({ + folder: folder, + service: service, + service_level_objective: serviceLevelObjective, + }); + } + + /** + * Parse the folder from FolderServiceServiceLevelObjective resource. + * + * @param {string} folderServiceServiceLevelObjectiveName + * A fully-qualified path representing folder_service_service_level_objective resource. + * @returns {string} A string representing the folder. + */ + matchFolderFromFolderServiceServiceLevelObjectiveName(folderServiceServiceLevelObjectiveName: string) { + return this._pathTemplates.folderServiceServiceLevelObjectivePathTemplate.match(folderServiceServiceLevelObjectiveName).folder; + } + + /** + * Parse the service from FolderServiceServiceLevelObjective resource. + * + * @param {string} folderServiceServiceLevelObjectiveName + * A fully-qualified path representing folder_service_service_level_objective resource. + * @returns {string} A string representing the service. + */ + matchServiceFromFolderServiceServiceLevelObjectiveName(folderServiceServiceLevelObjectiveName: string) { + return this._pathTemplates.folderServiceServiceLevelObjectivePathTemplate.match(folderServiceServiceLevelObjectiveName).service; + } + + /** + * Parse the service_level_objective from FolderServiceServiceLevelObjective resource. + * + * @param {string} folderServiceServiceLevelObjectiveName + * A fully-qualified path representing folder_service_service_level_objective resource. + * @returns {string} A string representing the service_level_objective. + */ + matchServiceLevelObjectiveFromFolderServiceServiceLevelObjectiveName(folderServiceServiceLevelObjectiveName: string) { + return this._pathTemplates.folderServiceServiceLevelObjectivePathTemplate.match(folderServiceServiceLevelObjectiveName).service_level_objective; + } + + /** + * Return a fully-qualified projectUptimeCheckConfig resource name string. + * + * @param {string} project + * @param {string} uptime_check_config + * @returns {string} Resource name string. + */ + projectUptimeCheckConfigPath(project:string,uptimeCheckConfig:string) { + return this._pathTemplates.projectUptimeCheckConfigPathTemplate.render({ + project: project, + uptime_check_config: uptimeCheckConfig, + }); + } + + /** + * Parse the project from ProjectUptimeCheckConfig resource. + * + * @param {string} projectUptimeCheckConfigName + * A fully-qualified path representing project_uptime_check_config resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectUptimeCheckConfigName(projectUptimeCheckConfigName: string) { + return this._pathTemplates.projectUptimeCheckConfigPathTemplate.match(projectUptimeCheckConfigName).project; + } + + /** + * Parse the uptime_check_config from ProjectUptimeCheckConfig resource. + * + * @param {string} projectUptimeCheckConfigName + * A fully-qualified path representing project_uptime_check_config resource. + * @returns {string} A string representing the uptime_check_config. + */ + matchUptimeCheckConfigFromProjectUptimeCheckConfigName(projectUptimeCheckConfigName: string) { + return this._pathTemplates.projectUptimeCheckConfigPathTemplate.match(projectUptimeCheckConfigName).uptime_check_config; + } + + /** + * Return a fully-qualified organizationUptimeCheckConfig resource name string. + * + * @param {string} organization + * @param {string} uptime_check_config + * @returns {string} Resource name string. + */ + organizationUptimeCheckConfigPath(organization:string,uptimeCheckConfig:string) { + return this._pathTemplates.organizationUptimeCheckConfigPathTemplate.render({ + organization: organization, + uptime_check_config: uptimeCheckConfig, + }); + } + + /** + * Parse the organization from OrganizationUptimeCheckConfig resource. + * + * @param {string} organizationUptimeCheckConfigName + * A fully-qualified path representing organization_uptime_check_config resource. + * @returns {string} A string representing the organization. + */ + matchOrganizationFromOrganizationUptimeCheckConfigName(organizationUptimeCheckConfigName: string) { + return this._pathTemplates.organizationUptimeCheckConfigPathTemplate.match(organizationUptimeCheckConfigName).organization; + } + + /** + * Parse the uptime_check_config from OrganizationUptimeCheckConfig resource. + * + * @param {string} organizationUptimeCheckConfigName + * A fully-qualified path representing organization_uptime_check_config resource. + * @returns {string} A string representing the uptime_check_config. + */ + matchUptimeCheckConfigFromOrganizationUptimeCheckConfigName(organizationUptimeCheckConfigName: string) { + return this._pathTemplates.organizationUptimeCheckConfigPathTemplate.match(organizationUptimeCheckConfigName).uptime_check_config; + } + + /** + * Return a fully-qualified folderUptimeCheckConfig resource name string. + * + * @param {string} folder + * @param {string} uptime_check_config + * @returns {string} Resource name string. + */ + folderUptimeCheckConfigPath(folder:string,uptimeCheckConfig:string) { + return this._pathTemplates.folderUptimeCheckConfigPathTemplate.render({ + folder: folder, + uptime_check_config: uptimeCheckConfig, + }); + } + + /** + * Parse the folder from FolderUptimeCheckConfig resource. + * + * @param {string} folderUptimeCheckConfigName + * A fully-qualified path representing folder_uptime_check_config resource. + * @returns {string} A string representing the folder. + */ + matchFolderFromFolderUptimeCheckConfigName(folderUptimeCheckConfigName: string) { + return this._pathTemplates.folderUptimeCheckConfigPathTemplate.match(folderUptimeCheckConfigName).folder; + } + + /** + * Parse the uptime_check_config from FolderUptimeCheckConfig resource. + * + * @param {string} folderUptimeCheckConfigName + * A fully-qualified path representing folder_uptime_check_config resource. + * @returns {string} A string representing the uptime_check_config. + */ + matchUptimeCheckConfigFromFolderUptimeCheckConfigName(folderUptimeCheckConfigName: string) { + return this._pathTemplates.folderUptimeCheckConfigPathTemplate.match(folderUptimeCheckConfigName).uptime_check_config; + } + + /** + * Terminate the GRPC channel and close the client. + * + * The client will no longer be usable and all future behavior is undefined. + */ + close(): Promise { + if (!this._terminated) { + return this.alertPolicyServiceStub.then(stub => { + this._terminated = true; + stub.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/typescript/test/testdata/monitoring/src/v3/alert_policy_service_client_config.json.baseline b/typescript/test/testdata/monitoring/src/v3/alert_policy_service_client_config.json.baseline new file mode 100644 index 000000000..5c3935f3c --- /dev/null +++ b/typescript/test/testdata/monitoring/src/v3/alert_policy_service_client_config.json.baseline @@ -0,0 +1,46 @@ +{ + "interfaces": { + "google.monitoring.v3.AlertPolicyService": { + "retry_codes": { + "non_idempotent": [], + "idempotent": [ + "DEADLINE_EXCEEDED", + "UNAVAILABLE" + ] + }, + "retry_params": { + "default": { + "initial_retry_delay_millis": 100, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 60000, + "initial_rpc_timeout_millis": 60000, + "rpc_timeout_multiplier": 1, + "max_rpc_timeout_millis": 60000, + "total_timeout_millis": 600000 + } + }, + "methods": { + "ListAlertPolicies": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "GetAlertPolicy": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "CreateAlertPolicy": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "DeleteAlertPolicy": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "UpdateAlertPolicy": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/typescript/test/testdata/monitoring/src/v3/alert_policy_service_proto_list.json.baseline b/typescript/test/testdata/monitoring/src/v3/alert_policy_service_proto_list.json.baseline new file mode 100644 index 000000000..aacceb22f --- /dev/null +++ b/typescript/test/testdata/monitoring/src/v3/alert_policy_service_proto_list.json.baseline @@ -0,0 +1,16 @@ +[ + "../../protos/google/monitoring/v3/alert.proto", + "../../protos/google/monitoring/v3/alert_service.proto", + "../../protos/google/monitoring/v3/common.proto", + "../../protos/google/monitoring/v3/group.proto", + "../../protos/google/monitoring/v3/group_service.proto", + "../../protos/google/monitoring/v3/metric.proto", + "../../protos/google/monitoring/v3/metric_service.proto", + "../../protos/google/monitoring/v3/mutation_record.proto", + "../../protos/google/monitoring/v3/notification.proto", + "../../protos/google/monitoring/v3/notification_service.proto", + "../../protos/google/monitoring/v3/service.proto", + "../../protos/google/monitoring/v3/service_service.proto", + "../../protos/google/monitoring/v3/uptime.proto", + "../../protos/google/monitoring/v3/uptime_service.proto" +] diff --git a/typescript/test/testdata/monitoring/src/v3/group_service_client.ts.baseline b/typescript/test/testdata/monitoring/src/v3/group_service_client.ts.baseline new file mode 100644 index 000000000..74d2fbff0 --- /dev/null +++ b/typescript/test/testdata/monitoring/src/v3/group_service_client.ts.baseline @@ -0,0 +1,1708 @@ +// 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 gax from 'google-gax'; +import {APICallback, Callback, CallOptions, Descriptors, ClientOptions, PaginationCallback, PaginationResponse} from 'google-gax'; +import * as path from 'path'; + +import { Transform } from 'stream'; +import * as protosTypes from '../../protos/protos'; +import * as gapicConfig from './group_service_client_config.json'; + +const version = require('../../../package.json').version; + +/** + * The Group API lets you inspect and manage your + * [groups](#google.monitoring.v3.Group). + * + * A group is a named filter that is used to identify + * a collection of monitored resources. Groups are typically used to + * mirror the physical and/or logical topology of the environment. + * Because group membership is computed dynamically, monitored + * resources that are started in the future are automatically placed + * in matching groups. By using a group to name monitored resources in, + * for example, an alert policy, the target of that alert policy is + * updated automatically as monitored resources are added and removed + * from the infrastructure. + * @class + * @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; + auth: gax.GoogleAuth; + groupServiceStub: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of GroupServiceClient. + * + * @param {object} [options] - The configuration object. See the subsequent + * parameters for more details. + * @param {object} [options.credentials] - Credentials object. + * @param {string} [options.credentials.client_email] + * @param {string} [options.credentials.private_key] + * @param {string} [options.email] - Account email address. Required when + * using a .pem or .p12 keyFilename. + * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or + * .p12 key downloaded from the Google Developers Console. If you provide + * a path to a JSON file, the projectId option below is not necessary. + * NOTE: .pem and .p12 require you to specify options.email as well. + * @param {number} [options.port] - The port on which to connect to + * the remote host. + * @param {string} [options.projectId] - The project ID from the Google + * Developer's Console, e.g. 'grape-spaceship-123'. We will also check + * the environment variable GCLOUD_PROJECT for your project ID. If your + * app is running in an environment which supports + * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, + * your project ID will be detected automatically. + * @param {function} [options.promise] - Custom promise module to use instead + * of native Promises. + * @param {string} [options.apiEndpoint] - The domain name of the + * API remote host. + */ + + constructor(opts?: ClientOptions) { + // Ensure that options include the service address and port. + const staticMembers = this.constructor as typeof GroupServiceClient; + const servicePath = opts && opts.servicePath ? + opts.servicePath : + ((opts && opts.apiEndpoint) ? opts.apiEndpoint : + staticMembers.servicePath); + const port = opts && opts.port ? opts.port : staticMembers.port; + + if (!opts) { + opts = {servicePath, port}; + } + opts.servicePath = opts.servicePath || servicePath; + opts.port = opts.port || port; + opts.clientConfig = opts.clientConfig || {}; + + const isBrowser = (typeof window !== 'undefined'); + if (isBrowser){ + opts.fallback = true; + } + // If we are in browser, we are already using fallback because of the + // "browser" field in package.json. + // But if we were explicitly requested to use fallback, let's do it now. + const gaxModule = !isBrowser && opts.fallback ? gax.fallback : gax; + + // Create a `gaxGrpc` object, with any grpc-specific options + // sent to the client. + opts.scopes = (this.constructor as typeof GroupServiceClient).scopes; + const gaxGrpc = new gaxModule.GrpcClient(opts); + + // Save the auth object to the client, for use by other methods. + this.auth = (gaxGrpc.auth as gax.GoogleAuth); + + // Determine the client header string. + const clientHeader = [ + `gax/${gaxModule.version}`, + `gapic/${version}`, + ]; + if (typeof process !== 'undefined' && 'versions' in process) { + clientHeader.push(`gl-node/${process.versions.node}`); + } else { + clientHeader.push(`gl-web/${gaxModule.version}`); + } + if (!opts.fallback) { + clientHeader.push(`grpc/${gaxGrpc.grpcVersion}`); + } + if (opts.libName && opts.libVersion) { + clientHeader.push(`${opts.libName}/${opts.libVersion}`); + } + // Load the applicable protos. + // For Node.js, pass the path to JSON proto file. + // For browsers, pass the JSON content. + + const nodejsProtoPath = path.join(__dirname, '..', '..', 'protos', 'protos.json'); + const protos = gaxGrpc.loadProto( + opts.fallback ? + 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 = { + projectAlertPolicyPathTemplate: new gaxModule.PathTemplate( + 'projects/{project}/alertPolicies/{alert_policy}' + ), + organizationAlertPolicyPathTemplate: new gaxModule.PathTemplate( + 'organizations/{organization}/alertPolicies/{alert_policy}' + ), + folderAlertPolicyPathTemplate: new gaxModule.PathTemplate( + 'folders/{folder}/alertPolicies/{alert_policy}' + ), + PathTemplate: new gaxModule.PathTemplate( + '*' + ), + projectGroupPathTemplate: new gaxModule.PathTemplate( + 'projects/{project}/groups/{group}' + ), + organizationGroupPathTemplate: new gaxModule.PathTemplate( + 'organizations/{organization}/groups/{group}' + ), + folderGroupPathTemplate: new gaxModule.PathTemplate( + 'folders/{folder}/groups/{group}' + ), + projectChannelDescriptorPathTemplate: new gaxModule.PathTemplate( + 'projects/{project}/notificationChannelDescriptors/{channel_descriptor}' + ), + organizationChannelDescriptorPathTemplate: new gaxModule.PathTemplate( + 'organizations/{organization}/notificationChannelDescriptors/{channel_descriptor}' + ), + folderChannelDescriptorPathTemplate: new gaxModule.PathTemplate( + 'folders/{folder}/notificationChannelDescriptors/{channel_descriptor}' + ), + projectNotificationChannelPathTemplate: new gaxModule.PathTemplate( + 'projects/{project}/notificationChannels/{notification_channel}' + ), + organizationNotificationChannelPathTemplate: new gaxModule.PathTemplate( + 'organizations/{organization}/notificationChannels/{notification_channel}' + ), + folderNotificationChannelPathTemplate: new gaxModule.PathTemplate( + 'folders/{folder}/notificationChannels/{notification_channel}' + ), + projectServicePathTemplate: new gaxModule.PathTemplate( + 'projects/{project}/services/{service}' + ), + organizationServicePathTemplate: new gaxModule.PathTemplate( + 'organizations/{organization}/services/{service}' + ), + folderServicePathTemplate: new gaxModule.PathTemplate( + 'folders/{folder}/services/{service}' + ), + projectServiceServiceLevelObjectivePathTemplate: new gaxModule.PathTemplate( + 'projects/{project}/services/{service}/serviceLevelObjectives/{service_level_objective}' + ), + organizationServiceServiceLevelObjectivePathTemplate: new gaxModule.PathTemplate( + 'organizations/{organization}/services/{service}/serviceLevelObjectives/{service_level_objective}' + ), + folderServiceServiceLevelObjectivePathTemplate: new gaxModule.PathTemplate( + 'folders/{folder}/services/{service}/serviceLevelObjectives/{service_level_objective}' + ), + projectUptimeCheckConfigPathTemplate: new gaxModule.PathTemplate( + 'projects/{project}/uptimeCheckConfigs/{uptime_check_config}' + ), + organizationUptimeCheckConfigPathTemplate: new gaxModule.PathTemplate( + 'organizations/{organization}/uptimeCheckConfigs/{uptime_check_config}' + ), + folderUptimeCheckConfigPathTemplate: new gaxModule.PathTemplate( + 'folders/{folder}/uptimeCheckConfigs/{uptime_check_config}' + ), + }; + + // 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 = { + listGroups: + new gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'group'), + listGroupMembers: + new gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'members') + }; + + // Put together the default options sent with requests. + const defaults = gaxGrpc.constructSettings( + 'google.monitoring.v3.GroupService', gapicConfig as gax.ClientConfig, + opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + + // Set up a dictionary of "inner API calls"; the core implementation + // of calling the API is handled in `google-gax`, with this code + // merely providing the destination and request information. + this._innerApiCalls = {}; + + // Put together the "service stub" for + // google.monitoring.v3.GroupService. + this.groupServiceStub = gaxGrpc.createStub( + opts.fallback ? + (protos as protobuf.Root).lookupService('google.monitoring.v3.GroupService') : + // tslint:disable-next-line no-any + (protos as any).google.monitoring.v3.GroupService, + opts) as Promise<{[method: string]: Function}>; + + // Iterate over each of the methods that the service provides + // and create an API call method for each. + const groupServiceStubMethods = + ['listGroups', 'getGroup', 'createGroup', 'updateGroup', 'deleteGroup', 'listGroupMembers']; + + for (const methodName of groupServiceStubMethods) { + const innerCallPromise = this.groupServiceStub.then( + stub => (...args: Array<{}>) => { + if (this._terminated) { + return Promise.reject('The client has already been closed.'); + } + return stub[methodName].apply(stub, args); + }, + (err: Error|null|undefined) => () => { + throw err; + }); + + const apiCall = gaxModule.createApiCall( + innerCallPromise, + defaults[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); + }; + } + } + + /** + * The DNS address for this API service. + */ + static get servicePath() { + return 'monitoring.googleapis.com'; + } + + /** + * The DNS address for this API service - same as servicePath(), + * exists for compatibility reasons. + */ + static get apiEndpoint() { + return 'monitoring.googleapis.com'; + } + + /** + * The port for this API service. + */ + static get port() { + return 443; + } + + /** + * The scopes needed to make gRPC calls for every method defined + * in this service. + */ + static get scopes() { + return [ + 'https://www.googleapis.com/auth/cloud-platform', + 'https://www.googleapis.com/auth/monitoring', + 'https://www.googleapis.com/auth/monitoring.read' + ]; + } + + getProjectId(): Promise; + getProjectId(callback: Callback): void; + /** + * Return the project ID used by this class. + * @param {function(Error, string)} callback - the callback to + * be called with the current project Id. + */ + getProjectId(callback?: Callback): + Promise|void { + if (callback) { + this.auth.getProjectId(callback); + return; + } + return this.auth.getProjectId(); + } + + // ------------------- + // -- Service calls -- + // ------------------- + getGroup( + request: protosTypes.google.monitoring.v3.IGetGroupRequest, + options?: gax.CallOptions): + Promise<[ + protosTypes.google.monitoring.v3.IGroup, + protosTypes.google.monitoring.v3.IGetGroupRequest|undefined, {}|undefined + ]>; + getGroup( + request: protosTypes.google.monitoring.v3.IGetGroupRequest, + options: gax.CallOptions, + callback: Callback< + protosTypes.google.monitoring.v3.IGroup, + protosTypes.google.monitoring.v3.IGetGroupRequest|undefined, + {}|undefined>): void; +/** + * Gets a single group. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The group to retrieve. The format is + * `"projects/{project_id_or_number}/groups/{group_id}"`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Group]{@link google.monitoring.v3.Group}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ + getGroup( + request: protosTypes.google.monitoring.v3.IGetGroupRequest, + optionsOrCallback?: gax.CallOptions|Callback< + protosTypes.google.monitoring.v3.IGroup, + protosTypes.google.monitoring.v3.IGetGroupRequest|undefined, {}|undefined>, + callback?: Callback< + protosTypes.google.monitoring.v3.IGroup, + protosTypes.google.monitoring.v3.IGetGroupRequest|undefined, + {}|undefined>): + Promise<[ + protosTypes.google.monitoring.v3.IGroup, + protosTypes.google.monitoring.v3.IGetGroupRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as gax.CallOptions; + } + 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 || '', + }); + return this._innerApiCalls.getGroup(request, options, callback); + } + createGroup( + request: protosTypes.google.monitoring.v3.ICreateGroupRequest, + options?: gax.CallOptions): + Promise<[ + protosTypes.google.monitoring.v3.IGroup, + protosTypes.google.monitoring.v3.ICreateGroupRequest|undefined, {}|undefined + ]>; + createGroup( + request: protosTypes.google.monitoring.v3.ICreateGroupRequest, + options: gax.CallOptions, + callback: Callback< + protosTypes.google.monitoring.v3.IGroup, + protosTypes.google.monitoring.v3.ICreateGroupRequest|undefined, + {}|undefined>): void; +/** + * Creates a new group. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The project in which to create the group. The format is + * `"projects/{project_id_or_number}"`. + * @param {google.monitoring.v3.Group} request.group + * Required. A group definition. It is an error to define the `name` field because + * the system assigns the name. + * @param {boolean} request.validateOnly + * If true, validate this request but do not create the group. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Group]{@link google.monitoring.v3.Group}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ + createGroup( + request: protosTypes.google.monitoring.v3.ICreateGroupRequest, + optionsOrCallback?: gax.CallOptions|Callback< + protosTypes.google.monitoring.v3.IGroup, + protosTypes.google.monitoring.v3.ICreateGroupRequest|undefined, {}|undefined>, + callback?: Callback< + protosTypes.google.monitoring.v3.IGroup, + protosTypes.google.monitoring.v3.ICreateGroupRequest|undefined, + {}|undefined>): + Promise<[ + protosTypes.google.monitoring.v3.IGroup, + protosTypes.google.monitoring.v3.ICreateGroupRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as gax.CallOptions; + } + 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 || '', + }); + return this._innerApiCalls.createGroup(request, options, callback); + } + updateGroup( + request: protosTypes.google.monitoring.v3.IUpdateGroupRequest, + options?: gax.CallOptions): + Promise<[ + protosTypes.google.monitoring.v3.IGroup, + protosTypes.google.monitoring.v3.IUpdateGroupRequest|undefined, {}|undefined + ]>; + updateGroup( + request: protosTypes.google.monitoring.v3.IUpdateGroupRequest, + options: gax.CallOptions, + callback: Callback< + protosTypes.google.monitoring.v3.IGroup, + protosTypes.google.monitoring.v3.IUpdateGroupRequest|undefined, + {}|undefined>): void; +/** + * Updates an existing group. + * You can change any group attributes except `name`. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.monitoring.v3.Group} request.group + * Required. The new definition of the group. All fields of the existing group, + * excepting `name`, are replaced with the corresponding fields of this group. + * @param {boolean} request.validateOnly + * If true, validate this request but do not update the existing group. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Group]{@link google.monitoring.v3.Group}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ + updateGroup( + request: protosTypes.google.monitoring.v3.IUpdateGroupRequest, + optionsOrCallback?: gax.CallOptions|Callback< + protosTypes.google.monitoring.v3.IGroup, + protosTypes.google.monitoring.v3.IUpdateGroupRequest|undefined, {}|undefined>, + callback?: Callback< + protosTypes.google.monitoring.v3.IGroup, + protosTypes.google.monitoring.v3.IUpdateGroupRequest|undefined, + {}|undefined>): + Promise<[ + protosTypes.google.monitoring.v3.IGroup, + protosTypes.google.monitoring.v3.IUpdateGroupRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as gax.CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'group.name': request.group!.name || '', + }); + return this._innerApiCalls.updateGroup(request, options, callback); + } + deleteGroup( + request: protosTypes.google.monitoring.v3.IDeleteGroupRequest, + options?: gax.CallOptions): + Promise<[ + protosTypes.google.protobuf.IEmpty, + protosTypes.google.monitoring.v3.IDeleteGroupRequest|undefined, {}|undefined + ]>; + deleteGroup( + request: protosTypes.google.monitoring.v3.IDeleteGroupRequest, + options: gax.CallOptions, + callback: Callback< + protosTypes.google.protobuf.IEmpty, + protosTypes.google.monitoring.v3.IDeleteGroupRequest|undefined, + {}|undefined>): void; +/** + * Deletes an existing group. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The group to delete. The format is + * `"projects/{project_id_or_number}/groups/{group_id}"`. + * @param {boolean} request.recursive + * If this field is true, then the request means to delete a group with all + * its descendants. Otherwise, the request means to delete a group only when + * it has no descendants. The default value is false. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ + deleteGroup( + request: protosTypes.google.monitoring.v3.IDeleteGroupRequest, + optionsOrCallback?: gax.CallOptions|Callback< + protosTypes.google.protobuf.IEmpty, + protosTypes.google.monitoring.v3.IDeleteGroupRequest|undefined, {}|undefined>, + callback?: Callback< + protosTypes.google.protobuf.IEmpty, + protosTypes.google.monitoring.v3.IDeleteGroupRequest|undefined, + {}|undefined>): + Promise<[ + protosTypes.google.protobuf.IEmpty, + protosTypes.google.monitoring.v3.IDeleteGroupRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as gax.CallOptions; + } + 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 || '', + }); + return this._innerApiCalls.deleteGroup(request, options, callback); + } + + listGroups( + request: protosTypes.google.monitoring.v3.IListGroupsRequest, + options?: gax.CallOptions): + Promise<[ + protosTypes.google.monitoring.v3.IGroup[], + protosTypes.google.monitoring.v3.IListGroupsRequest|null, + protosTypes.google.monitoring.v3.IListGroupsResponse + ]>; + listGroups( + request: protosTypes.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>): void; +/** + * Lists the existing groups. + * + * @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: `"projects/{project_id_or_number}/groups/{group_id}"`. + * Returns groups whose `parentName` field contains the group + * name. If no groups have this parent, the results are empty. + * @param {string} request.ancestorsOfGroup + * A group name: `"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: `"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 `childrenOfGroup` 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 `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 {Promise} - The promise which resolves to an array. + * The first element of the array is Array of [Group]{@link google.monitoring.v3.Group}. + * The client library support auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * + * When autoPaginate: false is specified through options, the array has three elements. + * The first element is Array of [Group]{@link google.monitoring.v3.Group} that corresponds to + * the one page received from the API server. + * If the second element is not null it contains the request object of type [ListGroupsRequest]{@link google.monitoring.v3.ListGroupsRequest} + * that can be used to obtain the next page of the results. + * If it is null, the next page does not exist. + * The third element contains the raw response received from the API server. Its type is + * [ListGroupsResponse]{@link google.monitoring.v3.ListGroupsResponse}. + * + * The promise has a method named "cancel" which cancels the ongoing API call. + */ + listGroups( + request: protosTypes.google.monitoring.v3.IListGroupsRequest, + optionsOrCallback?: gax.CallOptions|Callback< + protosTypes.google.monitoring.v3.IGroup[], + protosTypes.google.monitoring.v3.IListGroupsRequest|null, + protosTypes.google.monitoring.v3.IListGroupsResponse>, + callback?: Callback< + protosTypes.google.monitoring.v3.IGroup[], + protosTypes.google.monitoring.v3.IListGroupsRequest|null, + protosTypes.google.monitoring.v3.IListGroupsResponse>): + Promise<[ + protosTypes.google.monitoring.v3.IGroup[], + protosTypes.google.monitoring.v3.IListGroupsRequest|null, + protosTypes.google.monitoring.v3.IListGroupsResponse + ]>|void { + request = request || {}; + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as gax.CallOptions; + } + 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 || '', + }); + return this._innerApiCalls.listGroups(request, options, callback); + } + +/** + * Equivalent to {@link listGroups}, but returns a NodeJS Stream object. + * + * This fetches the paged responses for {@link listGroups} continuously + * and invokes the callback registered for 'data' event for each element in the + * responses. + * + * The returned object has 'end' method when no more elements are required. + * + * autoPaginate option will be ignored. + * + * @see {@link https://nodejs.org/api/stream.html} + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.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: `"projects/{project_id_or_number}/groups/{group_id}"`. + * Returns groups whose `parentName` field contains the group + * name. If no groups have this parent, the results are empty. + * @param {string} request.ancestorsOfGroup + * A group name: `"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: `"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 `childrenOfGroup` 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 `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 {Stream} + * An object stream which emits an object representing [Group]{@link google.monitoring.v3.Group} on 'data' event. + */ + listGroupsStream( + request?: protosTypes.google.monitoring.v3.IListGroupsRequest, + options?: gax.CallOptions | {}): + Transform{ + request = request || {}; + const callSettings = new gax.CallSettings(options); + return this._descriptors.page.listGroups.createStream( + this._innerApiCalls.listGroups as gax.GaxCall, + request, + callSettings + ); + } + listGroupMembers( + request: protosTypes.google.monitoring.v3.IListGroupMembersRequest, + options?: gax.CallOptions): + Promise<[ + protosTypes.google.api.IMonitoredResource[], + protosTypes.google.monitoring.v3.IListGroupMembersRequest|null, + protosTypes.google.monitoring.v3.IListGroupMembersResponse + ]>; + listGroupMembers( + request: protosTypes.google.monitoring.v3.IListGroupMembersRequest, + options: gax.CallOptions, + callback: Callback< + protosTypes.google.api.IMonitoredResource[], + protosTypes.google.monitoring.v3.IListGroupMembersRequest|null, + protosTypes.google.monitoring.v3.IListGroupMembersResponse>): void; +/** + * Lists the monitored resources that are members of a group. + * + * @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 `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 {string} request.filter + * An optional [list filter](/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 {Promise} - The promise which resolves to an array. + * The first element of the array is Array of [MonitoredResource]{@link google.api.MonitoredResource}. + * The client library support auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * + * When autoPaginate: false is specified through options, the array has three elements. + * The first element is Array of [MonitoredResource]{@link google.api.MonitoredResource} that corresponds to + * the one page received from the API server. + * If the second element is not null it contains the request object of type [ListGroupMembersRequest]{@link google.monitoring.v3.ListGroupMembersRequest} + * that can be used to obtain the next page of the results. + * If it is null, the next page does not exist. + * The third element contains the raw response received from the API server. Its type is + * [ListGroupMembersResponse]{@link google.monitoring.v3.ListGroupMembersResponse}. + * + * The promise has a method named "cancel" which cancels the ongoing API call. + */ + listGroupMembers( + request: protosTypes.google.monitoring.v3.IListGroupMembersRequest, + optionsOrCallback?: gax.CallOptions|Callback< + protosTypes.google.api.IMonitoredResource[], + protosTypes.google.monitoring.v3.IListGroupMembersRequest|null, + protosTypes.google.monitoring.v3.IListGroupMembersResponse>, + callback?: Callback< + protosTypes.google.api.IMonitoredResource[], + protosTypes.google.monitoring.v3.IListGroupMembersRequest|null, + protosTypes.google.monitoring.v3.IListGroupMembersResponse>): + Promise<[ + protosTypes.google.api.IMonitoredResource[], + protosTypes.google.monitoring.v3.IListGroupMembersRequest|null, + protosTypes.google.monitoring.v3.IListGroupMembersResponse + ]>|void { + request = request || {}; + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as gax.CallOptions; + } + 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 || '', + }); + return this._innerApiCalls.listGroupMembers(request, options, callback); + } + +/** + * Equivalent to {@link listGroupMembers}, but returns a NodeJS Stream object. + * + * This fetches the paged responses for {@link listGroupMembers} continuously + * and invokes the callback registered for 'data' event for each element in the + * responses. + * + * The returned object has 'end' method when no more elements are required. + * + * autoPaginate option will be ignored. + * + * @see {@link https://nodejs.org/api/stream.html} + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.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 `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 {string} request.filter + * An optional [list filter](/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 {Stream} + * An object stream which emits an object representing [MonitoredResource]{@link google.api.MonitoredResource} on 'data' event. + */ + listGroupMembersStream( + request?: protosTypes.google.monitoring.v3.IListGroupMembersRequest, + options?: gax.CallOptions | {}): + Transform{ + request = request || {}; + const callSettings = new gax.CallSettings(options); + return this._descriptors.page.listGroupMembers.createStream( + this._innerApiCalls.listGroupMembers as gax.GaxCall, + request, + callSettings + ); + } + // -------------------- + // -- Path templates -- + // -------------------- + + /** + * Return a fully-qualified projectAlertPolicy resource name string. + * + * @param {string} project + * @param {string} alert_policy + * @returns {string} Resource name string. + */ + projectAlertPolicyPath(project:string,alertPolicy:string) { + return this._pathTemplates.projectAlertPolicyPathTemplate.render({ + project: project, + alert_policy: alertPolicy, + }); + } + + /** + * Parse the project from ProjectAlertPolicy resource. + * + * @param {string} projectAlertPolicyName + * A fully-qualified path representing project_alert_policy resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectAlertPolicyName(projectAlertPolicyName: string) { + return this._pathTemplates.projectAlertPolicyPathTemplate.match(projectAlertPolicyName).project; + } + + /** + * Parse the alert_policy from ProjectAlertPolicy resource. + * + * @param {string} projectAlertPolicyName + * A fully-qualified path representing project_alert_policy resource. + * @returns {string} A string representing the alert_policy. + */ + matchAlertPolicyFromProjectAlertPolicyName(projectAlertPolicyName: string) { + return this._pathTemplates.projectAlertPolicyPathTemplate.match(projectAlertPolicyName).alert_policy; + } + + /** + * Return a fully-qualified organizationAlertPolicy resource name string. + * + * @param {string} organization + * @param {string} alert_policy + * @returns {string} Resource name string. + */ + organizationAlertPolicyPath(organization:string,alertPolicy:string) { + return this._pathTemplates.organizationAlertPolicyPathTemplate.render({ + organization: organization, + alert_policy: alertPolicy, + }); + } + + /** + * Parse the organization from OrganizationAlertPolicy resource. + * + * @param {string} organizationAlertPolicyName + * A fully-qualified path representing organization_alert_policy resource. + * @returns {string} A string representing the organization. + */ + matchOrganizationFromOrganizationAlertPolicyName(organizationAlertPolicyName: string) { + return this._pathTemplates.organizationAlertPolicyPathTemplate.match(organizationAlertPolicyName).organization; + } + + /** + * Parse the alert_policy from OrganizationAlertPolicy resource. + * + * @param {string} organizationAlertPolicyName + * A fully-qualified path representing organization_alert_policy resource. + * @returns {string} A string representing the alert_policy. + */ + matchAlertPolicyFromOrganizationAlertPolicyName(organizationAlertPolicyName: string) { + return this._pathTemplates.organizationAlertPolicyPathTemplate.match(organizationAlertPolicyName).alert_policy; + } + + /** + * Return a fully-qualified folderAlertPolicy resource name string. + * + * @param {string} folder + * @param {string} alert_policy + * @returns {string} Resource name string. + */ + folderAlertPolicyPath(folder:string,alertPolicy:string) { + return this._pathTemplates.folderAlertPolicyPathTemplate.render({ + folder: folder, + alert_policy: alertPolicy, + }); + } + + /** + * Parse the folder from FolderAlertPolicy resource. + * + * @param {string} folderAlertPolicyName + * A fully-qualified path representing folder_alert_policy resource. + * @returns {string} A string representing the folder. + */ + matchFolderFromFolderAlertPolicyName(folderAlertPolicyName: string) { + return this._pathTemplates.folderAlertPolicyPathTemplate.match(folderAlertPolicyName).folder; + } + + /** + * Parse the alert_policy from FolderAlertPolicy resource. + * + * @param {string} folderAlertPolicyName + * A fully-qualified path representing folder_alert_policy resource. + * @returns {string} A string representing the alert_policy. + */ + matchAlertPolicyFromFolderAlertPolicyName(folderAlertPolicyName: string) { + return this._pathTemplates.folderAlertPolicyPathTemplate.match(folderAlertPolicyName).alert_policy; + } + + /** + * Return a fully-qualified resource name string. + * + * @returns {string} Resource name string. + */ + Path() { + return this._pathTemplates.PathTemplate.render({ + }); + } + + /** + * Return a fully-qualified projectGroup resource name string. + * + * @param {string} project + * @param {string} group + * @returns {string} Resource name string. + */ + projectGroupPath(project:string,group:string) { + return this._pathTemplates.projectGroupPathTemplate.render({ + project: project, + group: group, + }); + } + + /** + * Parse the project from ProjectGroup resource. + * + * @param {string} projectGroupName + * A fully-qualified path representing project_group resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectGroupName(projectGroupName: string) { + return this._pathTemplates.projectGroupPathTemplate.match(projectGroupName).project; + } + + /** + * Parse the group from ProjectGroup resource. + * + * @param {string} projectGroupName + * A fully-qualified path representing project_group resource. + * @returns {string} A string representing the group. + */ + matchGroupFromProjectGroupName(projectGroupName: string) { + return this._pathTemplates.projectGroupPathTemplate.match(projectGroupName).group; + } + + /** + * Return a fully-qualified organizationGroup resource name string. + * + * @param {string} organization + * @param {string} group + * @returns {string} Resource name string. + */ + organizationGroupPath(organization:string,group:string) { + return this._pathTemplates.organizationGroupPathTemplate.render({ + organization: organization, + group: group, + }); + } + + /** + * Parse the organization from OrganizationGroup resource. + * + * @param {string} organizationGroupName + * A fully-qualified path representing organization_group resource. + * @returns {string} A string representing the organization. + */ + matchOrganizationFromOrganizationGroupName(organizationGroupName: string) { + return this._pathTemplates.organizationGroupPathTemplate.match(organizationGroupName).organization; + } + + /** + * Parse the group from OrganizationGroup resource. + * + * @param {string} organizationGroupName + * A fully-qualified path representing organization_group resource. + * @returns {string} A string representing the group. + */ + matchGroupFromOrganizationGroupName(organizationGroupName: string) { + return this._pathTemplates.organizationGroupPathTemplate.match(organizationGroupName).group; + } + + /** + * Return a fully-qualified folderGroup resource name string. + * + * @param {string} folder + * @param {string} group + * @returns {string} Resource name string. + */ + folderGroupPath(folder:string,group:string) { + return this._pathTemplates.folderGroupPathTemplate.render({ + folder: folder, + group: group, + }); + } + + /** + * Parse the folder from FolderGroup resource. + * + * @param {string} folderGroupName + * A fully-qualified path representing folder_group resource. + * @returns {string} A string representing the folder. + */ + matchFolderFromFolderGroupName(folderGroupName: string) { + return this._pathTemplates.folderGroupPathTemplate.match(folderGroupName).folder; + } + + /** + * Parse the group from FolderGroup resource. + * + * @param {string} folderGroupName + * A fully-qualified path representing folder_group resource. + * @returns {string} A string representing the group. + */ + matchGroupFromFolderGroupName(folderGroupName: string) { + return this._pathTemplates.folderGroupPathTemplate.match(folderGroupName).group; + } + + /** + * Return a fully-qualified projectChannelDescriptor resource name string. + * + * @param {string} project + * @param {string} channel_descriptor + * @returns {string} Resource name string. + */ + projectChannelDescriptorPath(project:string,channelDescriptor:string) { + return this._pathTemplates.projectChannelDescriptorPathTemplate.render({ + project: project, + channel_descriptor: channelDescriptor, + }); + } + + /** + * Parse the project from ProjectChannelDescriptor resource. + * + * @param {string} projectChannelDescriptorName + * A fully-qualified path representing project_channel_descriptor resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectChannelDescriptorName(projectChannelDescriptorName: string) { + return this._pathTemplates.projectChannelDescriptorPathTemplate.match(projectChannelDescriptorName).project; + } + + /** + * Parse the channel_descriptor from ProjectChannelDescriptor resource. + * + * @param {string} projectChannelDescriptorName + * A fully-qualified path representing project_channel_descriptor resource. + * @returns {string} A string representing the channel_descriptor. + */ + matchChannelDescriptorFromProjectChannelDescriptorName(projectChannelDescriptorName: string) { + return this._pathTemplates.projectChannelDescriptorPathTemplate.match(projectChannelDescriptorName).channel_descriptor; + } + + /** + * Return a fully-qualified organizationChannelDescriptor resource name string. + * + * @param {string} organization + * @param {string} channel_descriptor + * @returns {string} Resource name string. + */ + organizationChannelDescriptorPath(organization:string,channelDescriptor:string) { + return this._pathTemplates.organizationChannelDescriptorPathTemplate.render({ + organization: organization, + channel_descriptor: channelDescriptor, + }); + } + + /** + * Parse the organization from OrganizationChannelDescriptor resource. + * + * @param {string} organizationChannelDescriptorName + * A fully-qualified path representing organization_channel_descriptor resource. + * @returns {string} A string representing the organization. + */ + matchOrganizationFromOrganizationChannelDescriptorName(organizationChannelDescriptorName: string) { + return this._pathTemplates.organizationChannelDescriptorPathTemplate.match(organizationChannelDescriptorName).organization; + } + + /** + * Parse the channel_descriptor from OrganizationChannelDescriptor resource. + * + * @param {string} organizationChannelDescriptorName + * A fully-qualified path representing organization_channel_descriptor resource. + * @returns {string} A string representing the channel_descriptor. + */ + matchChannelDescriptorFromOrganizationChannelDescriptorName(organizationChannelDescriptorName: string) { + return this._pathTemplates.organizationChannelDescriptorPathTemplate.match(organizationChannelDescriptorName).channel_descriptor; + } + + /** + * Return a fully-qualified folderChannelDescriptor resource name string. + * + * @param {string} folder + * @param {string} channel_descriptor + * @returns {string} Resource name string. + */ + folderChannelDescriptorPath(folder:string,channelDescriptor:string) { + return this._pathTemplates.folderChannelDescriptorPathTemplate.render({ + folder: folder, + channel_descriptor: channelDescriptor, + }); + } + + /** + * Parse the folder from FolderChannelDescriptor resource. + * + * @param {string} folderChannelDescriptorName + * A fully-qualified path representing folder_channel_descriptor resource. + * @returns {string} A string representing the folder. + */ + matchFolderFromFolderChannelDescriptorName(folderChannelDescriptorName: string) { + return this._pathTemplates.folderChannelDescriptorPathTemplate.match(folderChannelDescriptorName).folder; + } + + /** + * Parse the channel_descriptor from FolderChannelDescriptor resource. + * + * @param {string} folderChannelDescriptorName + * A fully-qualified path representing folder_channel_descriptor resource. + * @returns {string} A string representing the channel_descriptor. + */ + matchChannelDescriptorFromFolderChannelDescriptorName(folderChannelDescriptorName: string) { + return this._pathTemplates.folderChannelDescriptorPathTemplate.match(folderChannelDescriptorName).channel_descriptor; + } + + /** + * Return a fully-qualified projectNotificationChannel resource name string. + * + * @param {string} project + * @param {string} notification_channel + * @returns {string} Resource name string. + */ + projectNotificationChannelPath(project:string,notificationChannel:string) { + return this._pathTemplates.projectNotificationChannelPathTemplate.render({ + project: project, + notification_channel: notificationChannel, + }); + } + + /** + * Parse the project from ProjectNotificationChannel resource. + * + * @param {string} projectNotificationChannelName + * A fully-qualified path representing project_notification_channel resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectNotificationChannelName(projectNotificationChannelName: string) { + return this._pathTemplates.projectNotificationChannelPathTemplate.match(projectNotificationChannelName).project; + } + + /** + * Parse the notification_channel from ProjectNotificationChannel resource. + * + * @param {string} projectNotificationChannelName + * A fully-qualified path representing project_notification_channel resource. + * @returns {string} A string representing the notification_channel. + */ + matchNotificationChannelFromProjectNotificationChannelName(projectNotificationChannelName: string) { + return this._pathTemplates.projectNotificationChannelPathTemplate.match(projectNotificationChannelName).notification_channel; + } + + /** + * Return a fully-qualified organizationNotificationChannel resource name string. + * + * @param {string} organization + * @param {string} notification_channel + * @returns {string} Resource name string. + */ + organizationNotificationChannelPath(organization:string,notificationChannel:string) { + return this._pathTemplates.organizationNotificationChannelPathTemplate.render({ + organization: organization, + notification_channel: notificationChannel, + }); + } + + /** + * Parse the organization from OrganizationNotificationChannel resource. + * + * @param {string} organizationNotificationChannelName + * A fully-qualified path representing organization_notification_channel resource. + * @returns {string} A string representing the organization. + */ + matchOrganizationFromOrganizationNotificationChannelName(organizationNotificationChannelName: string) { + return this._pathTemplates.organizationNotificationChannelPathTemplate.match(organizationNotificationChannelName).organization; + } + + /** + * Parse the notification_channel from OrganizationNotificationChannel resource. + * + * @param {string} organizationNotificationChannelName + * A fully-qualified path representing organization_notification_channel resource. + * @returns {string} A string representing the notification_channel. + */ + matchNotificationChannelFromOrganizationNotificationChannelName(organizationNotificationChannelName: string) { + return this._pathTemplates.organizationNotificationChannelPathTemplate.match(organizationNotificationChannelName).notification_channel; + } + + /** + * Return a fully-qualified folderNotificationChannel resource name string. + * + * @param {string} folder + * @param {string} notification_channel + * @returns {string} Resource name string. + */ + folderNotificationChannelPath(folder:string,notificationChannel:string) { + return this._pathTemplates.folderNotificationChannelPathTemplate.render({ + folder: folder, + notification_channel: notificationChannel, + }); + } + + /** + * Parse the folder from FolderNotificationChannel resource. + * + * @param {string} folderNotificationChannelName + * A fully-qualified path representing folder_notification_channel resource. + * @returns {string} A string representing the folder. + */ + matchFolderFromFolderNotificationChannelName(folderNotificationChannelName: string) { + return this._pathTemplates.folderNotificationChannelPathTemplate.match(folderNotificationChannelName).folder; + } + + /** + * Parse the notification_channel from FolderNotificationChannel resource. + * + * @param {string} folderNotificationChannelName + * A fully-qualified path representing folder_notification_channel resource. + * @returns {string} A string representing the notification_channel. + */ + matchNotificationChannelFromFolderNotificationChannelName(folderNotificationChannelName: string) { + return this._pathTemplates.folderNotificationChannelPathTemplate.match(folderNotificationChannelName).notification_channel; + } + + /** + * Return a fully-qualified projectService resource name string. + * + * @param {string} project + * @param {string} service + * @returns {string} Resource name string. + */ + projectServicePath(project:string,service:string) { + return this._pathTemplates.projectServicePathTemplate.render({ + project: project, + service: service, + }); + } + + /** + * Parse the project from ProjectService resource. + * + * @param {string} projectServiceName + * A fully-qualified path representing project_service resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectServiceName(projectServiceName: string) { + return this._pathTemplates.projectServicePathTemplate.match(projectServiceName).project; + } + + /** + * Parse the service from ProjectService resource. + * + * @param {string} projectServiceName + * A fully-qualified path representing project_service resource. + * @returns {string} A string representing the service. + */ + matchServiceFromProjectServiceName(projectServiceName: string) { + return this._pathTemplates.projectServicePathTemplate.match(projectServiceName).service; + } + + /** + * Return a fully-qualified organizationService resource name string. + * + * @param {string} organization + * @param {string} service + * @returns {string} Resource name string. + */ + organizationServicePath(organization:string,service:string) { + return this._pathTemplates.organizationServicePathTemplate.render({ + organization: organization, + service: service, + }); + } + + /** + * Parse the organization from OrganizationService resource. + * + * @param {string} organizationServiceName + * A fully-qualified path representing organization_service resource. + * @returns {string} A string representing the organization. + */ + matchOrganizationFromOrganizationServiceName(organizationServiceName: string) { + return this._pathTemplates.organizationServicePathTemplate.match(organizationServiceName).organization; + } + + /** + * Parse the service from OrganizationService resource. + * + * @param {string} organizationServiceName + * A fully-qualified path representing organization_service resource. + * @returns {string} A string representing the service. + */ + matchServiceFromOrganizationServiceName(organizationServiceName: string) { + return this._pathTemplates.organizationServicePathTemplate.match(organizationServiceName).service; + } + + /** + * Return a fully-qualified folderService resource name string. + * + * @param {string} folder + * @param {string} service + * @returns {string} Resource name string. + */ + folderServicePath(folder:string,service:string) { + return this._pathTemplates.folderServicePathTemplate.render({ + folder: folder, + service: service, + }); + } + + /** + * Parse the folder from FolderService resource. + * + * @param {string} folderServiceName + * A fully-qualified path representing folder_service resource. + * @returns {string} A string representing the folder. + */ + matchFolderFromFolderServiceName(folderServiceName: string) { + return this._pathTemplates.folderServicePathTemplate.match(folderServiceName).folder; + } + + /** + * Parse the service from FolderService resource. + * + * @param {string} folderServiceName + * A fully-qualified path representing folder_service resource. + * @returns {string} A string representing the service. + */ + matchServiceFromFolderServiceName(folderServiceName: string) { + return this._pathTemplates.folderServicePathTemplate.match(folderServiceName).service; + } + + /** + * Return a fully-qualified projectServiceServiceLevelObjective resource name string. + * + * @param {string} project + * @param {string} service + * @param {string} service_level_objective + * @returns {string} Resource name string. + */ + projectServiceServiceLevelObjectivePath(project:string,service:string,serviceLevelObjective:string) { + return this._pathTemplates.projectServiceServiceLevelObjectivePathTemplate.render({ + project: project, + service: service, + service_level_objective: serviceLevelObjective, + }); + } + + /** + * Parse the project from ProjectServiceServiceLevelObjective resource. + * + * @param {string} projectServiceServiceLevelObjectiveName + * A fully-qualified path representing project_service_service_level_objective resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectServiceServiceLevelObjectiveName(projectServiceServiceLevelObjectiveName: string) { + return this._pathTemplates.projectServiceServiceLevelObjectivePathTemplate.match(projectServiceServiceLevelObjectiveName).project; + } + + /** + * Parse the service from ProjectServiceServiceLevelObjective resource. + * + * @param {string} projectServiceServiceLevelObjectiveName + * A fully-qualified path representing project_service_service_level_objective resource. + * @returns {string} A string representing the service. + */ + matchServiceFromProjectServiceServiceLevelObjectiveName(projectServiceServiceLevelObjectiveName: string) { + return this._pathTemplates.projectServiceServiceLevelObjectivePathTemplate.match(projectServiceServiceLevelObjectiveName).service; + } + + /** + * Parse the service_level_objective from ProjectServiceServiceLevelObjective resource. + * + * @param {string} projectServiceServiceLevelObjectiveName + * A fully-qualified path representing project_service_service_level_objective resource. + * @returns {string} A string representing the service_level_objective. + */ + matchServiceLevelObjectiveFromProjectServiceServiceLevelObjectiveName(projectServiceServiceLevelObjectiveName: string) { + return this._pathTemplates.projectServiceServiceLevelObjectivePathTemplate.match(projectServiceServiceLevelObjectiveName).service_level_objective; + } + + /** + * Return a fully-qualified organizationServiceServiceLevelObjective resource name string. + * + * @param {string} organization + * @param {string} service + * @param {string} service_level_objective + * @returns {string} Resource name string. + */ + organizationServiceServiceLevelObjectivePath(organization:string,service:string,serviceLevelObjective:string) { + return this._pathTemplates.organizationServiceServiceLevelObjectivePathTemplate.render({ + organization: organization, + service: service, + service_level_objective: serviceLevelObjective, + }); + } + + /** + * Parse the organization from OrganizationServiceServiceLevelObjective resource. + * + * @param {string} organizationServiceServiceLevelObjectiveName + * A fully-qualified path representing organization_service_service_level_objective resource. + * @returns {string} A string representing the organization. + */ + matchOrganizationFromOrganizationServiceServiceLevelObjectiveName(organizationServiceServiceLevelObjectiveName: string) { + return this._pathTemplates.organizationServiceServiceLevelObjectivePathTemplate.match(organizationServiceServiceLevelObjectiveName).organization; + } + + /** + * Parse the service from OrganizationServiceServiceLevelObjective resource. + * + * @param {string} organizationServiceServiceLevelObjectiveName + * A fully-qualified path representing organization_service_service_level_objective resource. + * @returns {string} A string representing the service. + */ + matchServiceFromOrganizationServiceServiceLevelObjectiveName(organizationServiceServiceLevelObjectiveName: string) { + return this._pathTemplates.organizationServiceServiceLevelObjectivePathTemplate.match(organizationServiceServiceLevelObjectiveName).service; + } + + /** + * Parse the service_level_objective from OrganizationServiceServiceLevelObjective resource. + * + * @param {string} organizationServiceServiceLevelObjectiveName + * A fully-qualified path representing organization_service_service_level_objective resource. + * @returns {string} A string representing the service_level_objective. + */ + matchServiceLevelObjectiveFromOrganizationServiceServiceLevelObjectiveName(organizationServiceServiceLevelObjectiveName: string) { + return this._pathTemplates.organizationServiceServiceLevelObjectivePathTemplate.match(organizationServiceServiceLevelObjectiveName).service_level_objective; + } + + /** + * Return a fully-qualified folderServiceServiceLevelObjective resource name string. + * + * @param {string} folder + * @param {string} service + * @param {string} service_level_objective + * @returns {string} Resource name string. + */ + folderServiceServiceLevelObjectivePath(folder:string,service:string,serviceLevelObjective:string) { + return this._pathTemplates.folderServiceServiceLevelObjectivePathTemplate.render({ + folder: folder, + service: service, + service_level_objective: serviceLevelObjective, + }); + } + + /** + * Parse the folder from FolderServiceServiceLevelObjective resource. + * + * @param {string} folderServiceServiceLevelObjectiveName + * A fully-qualified path representing folder_service_service_level_objective resource. + * @returns {string} A string representing the folder. + */ + matchFolderFromFolderServiceServiceLevelObjectiveName(folderServiceServiceLevelObjectiveName: string) { + return this._pathTemplates.folderServiceServiceLevelObjectivePathTemplate.match(folderServiceServiceLevelObjectiveName).folder; + } + + /** + * Parse the service from FolderServiceServiceLevelObjective resource. + * + * @param {string} folderServiceServiceLevelObjectiveName + * A fully-qualified path representing folder_service_service_level_objective resource. + * @returns {string} A string representing the service. + */ + matchServiceFromFolderServiceServiceLevelObjectiveName(folderServiceServiceLevelObjectiveName: string) { + return this._pathTemplates.folderServiceServiceLevelObjectivePathTemplate.match(folderServiceServiceLevelObjectiveName).service; + } + + /** + * Parse the service_level_objective from FolderServiceServiceLevelObjective resource. + * + * @param {string} folderServiceServiceLevelObjectiveName + * A fully-qualified path representing folder_service_service_level_objective resource. + * @returns {string} A string representing the service_level_objective. + */ + matchServiceLevelObjectiveFromFolderServiceServiceLevelObjectiveName(folderServiceServiceLevelObjectiveName: string) { + return this._pathTemplates.folderServiceServiceLevelObjectivePathTemplate.match(folderServiceServiceLevelObjectiveName).service_level_objective; + } + + /** + * Return a fully-qualified projectUptimeCheckConfig resource name string. + * + * @param {string} project + * @param {string} uptime_check_config + * @returns {string} Resource name string. + */ + projectUptimeCheckConfigPath(project:string,uptimeCheckConfig:string) { + return this._pathTemplates.projectUptimeCheckConfigPathTemplate.render({ + project: project, + uptime_check_config: uptimeCheckConfig, + }); + } + + /** + * Parse the project from ProjectUptimeCheckConfig resource. + * + * @param {string} projectUptimeCheckConfigName + * A fully-qualified path representing project_uptime_check_config resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectUptimeCheckConfigName(projectUptimeCheckConfigName: string) { + return this._pathTemplates.projectUptimeCheckConfigPathTemplate.match(projectUptimeCheckConfigName).project; + } + + /** + * Parse the uptime_check_config from ProjectUptimeCheckConfig resource. + * + * @param {string} projectUptimeCheckConfigName + * A fully-qualified path representing project_uptime_check_config resource. + * @returns {string} A string representing the uptime_check_config. + */ + matchUptimeCheckConfigFromProjectUptimeCheckConfigName(projectUptimeCheckConfigName: string) { + return this._pathTemplates.projectUptimeCheckConfigPathTemplate.match(projectUptimeCheckConfigName).uptime_check_config; + } + + /** + * Return a fully-qualified organizationUptimeCheckConfig resource name string. + * + * @param {string} organization + * @param {string} uptime_check_config + * @returns {string} Resource name string. + */ + organizationUptimeCheckConfigPath(organization:string,uptimeCheckConfig:string) { + return this._pathTemplates.organizationUptimeCheckConfigPathTemplate.render({ + organization: organization, + uptime_check_config: uptimeCheckConfig, + }); + } + + /** + * Parse the organization from OrganizationUptimeCheckConfig resource. + * + * @param {string} organizationUptimeCheckConfigName + * A fully-qualified path representing organization_uptime_check_config resource. + * @returns {string} A string representing the organization. + */ + matchOrganizationFromOrganizationUptimeCheckConfigName(organizationUptimeCheckConfigName: string) { + return this._pathTemplates.organizationUptimeCheckConfigPathTemplate.match(organizationUptimeCheckConfigName).organization; + } + + /** + * Parse the uptime_check_config from OrganizationUptimeCheckConfig resource. + * + * @param {string} organizationUptimeCheckConfigName + * A fully-qualified path representing organization_uptime_check_config resource. + * @returns {string} A string representing the uptime_check_config. + */ + matchUptimeCheckConfigFromOrganizationUptimeCheckConfigName(organizationUptimeCheckConfigName: string) { + return this._pathTemplates.organizationUptimeCheckConfigPathTemplate.match(organizationUptimeCheckConfigName).uptime_check_config; + } + + /** + * Return a fully-qualified folderUptimeCheckConfig resource name string. + * + * @param {string} folder + * @param {string} uptime_check_config + * @returns {string} Resource name string. + */ + folderUptimeCheckConfigPath(folder:string,uptimeCheckConfig:string) { + return this._pathTemplates.folderUptimeCheckConfigPathTemplate.render({ + folder: folder, + uptime_check_config: uptimeCheckConfig, + }); + } + + /** + * Parse the folder from FolderUptimeCheckConfig resource. + * + * @param {string} folderUptimeCheckConfigName + * A fully-qualified path representing folder_uptime_check_config resource. + * @returns {string} A string representing the folder. + */ + matchFolderFromFolderUptimeCheckConfigName(folderUptimeCheckConfigName: string) { + return this._pathTemplates.folderUptimeCheckConfigPathTemplate.match(folderUptimeCheckConfigName).folder; + } + + /** + * Parse the uptime_check_config from FolderUptimeCheckConfig resource. + * + * @param {string} folderUptimeCheckConfigName + * A fully-qualified path representing folder_uptime_check_config resource. + * @returns {string} A string representing the uptime_check_config. + */ + matchUptimeCheckConfigFromFolderUptimeCheckConfigName(folderUptimeCheckConfigName: string) { + return this._pathTemplates.folderUptimeCheckConfigPathTemplate.match(folderUptimeCheckConfigName).uptime_check_config; + } + + /** + * Terminate the GRPC channel and close the client. + * + * The client will no longer be usable and all future behavior is undefined. + */ + close(): Promise { + if (!this._terminated) { + return this.groupServiceStub.then(stub => { + this._terminated = true; + stub.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/typescript/test/testdata/monitoring/src/v3/group_service_client_config.json.baseline b/typescript/test/testdata/monitoring/src/v3/group_service_client_config.json.baseline new file mode 100644 index 000000000..e63f2afe3 --- /dev/null +++ b/typescript/test/testdata/monitoring/src/v3/group_service_client_config.json.baseline @@ -0,0 +1,50 @@ +{ + "interfaces": { + "google.monitoring.v3.GroupService": { + "retry_codes": { + "non_idempotent": [], + "idempotent": [ + "DEADLINE_EXCEEDED", + "UNAVAILABLE" + ] + }, + "retry_params": { + "default": { + "initial_retry_delay_millis": 100, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 60000, + "initial_rpc_timeout_millis": 60000, + "rpc_timeout_multiplier": 1, + "max_rpc_timeout_millis": 60000, + "total_timeout_millis": 600000 + } + }, + "methods": { + "ListGroups": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "GetGroup": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "CreateGroup": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "UpdateGroup": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "DeleteGroup": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "ListGroupMembers": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/typescript/test/testdata/monitoring/src/v3/group_service_proto_list.json.baseline b/typescript/test/testdata/monitoring/src/v3/group_service_proto_list.json.baseline new file mode 100644 index 000000000..aacceb22f --- /dev/null +++ b/typescript/test/testdata/monitoring/src/v3/group_service_proto_list.json.baseline @@ -0,0 +1,16 @@ +[ + "../../protos/google/monitoring/v3/alert.proto", + "../../protos/google/monitoring/v3/alert_service.proto", + "../../protos/google/monitoring/v3/common.proto", + "../../protos/google/monitoring/v3/group.proto", + "../../protos/google/monitoring/v3/group_service.proto", + "../../protos/google/monitoring/v3/metric.proto", + "../../protos/google/monitoring/v3/metric_service.proto", + "../../protos/google/monitoring/v3/mutation_record.proto", + "../../protos/google/monitoring/v3/notification.proto", + "../../protos/google/monitoring/v3/notification_service.proto", + "../../protos/google/monitoring/v3/service.proto", + "../../protos/google/monitoring/v3/service_service.proto", + "../../protos/google/monitoring/v3/uptime.proto", + "../../protos/google/monitoring/v3/uptime_service.proto" +] diff --git a/typescript/test/testdata/monitoring/src/v3/index.ts.baseline b/typescript/test/testdata/monitoring/src/v3/index.ts.baseline index c8ae05a7a..bb9e596d2 100644 --- a/typescript/test/testdata/monitoring/src/v3/index.ts.baseline +++ b/typescript/test/testdata/monitoring/src/v3/index.ts.baseline @@ -16,4 +16,4 @@ // ** https://github.com/googleapis/gapic-generator-typescript ** // ** All changes to this file may be overwritten. ** - +export {AlertPolicyServiceClient} from './alert_policy_service_client';export {GroupServiceClient} from './group_service_client';export {MetricServiceClient} from './metric_service_client';export {NotificationChannelServiceClient} from './notification_channel_service_client';export {ServiceMonitoringServiceClient} from './service_monitoring_service_client';export {UptimeCheckServiceClient} from './uptime_check_service_client'; diff --git a/typescript/test/testdata/monitoring/src/v3/metric_service_client.ts.baseline b/typescript/test/testdata/monitoring/src/v3/metric_service_client.ts.baseline new file mode 100644 index 000000000..c43607f4d --- /dev/null +++ b/typescript/test/testdata/monitoring/src/v3/metric_service_client.ts.baseline @@ -0,0 +1,2161 @@ +// 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 gax from 'google-gax'; +import {APICallback, Callback, CallOptions, Descriptors, ClientOptions, PaginationCallback, PaginationResponse} from 'google-gax'; +import * as path from 'path'; + +import { Transform } from 'stream'; +import * as protosTypes from '../../protos/protos'; +import * as gapicConfig from './metric_service_client_config.json'; + +const version = require('../../../package.json').version; + +/** + * Manages metric descriptors, monitored resource descriptors, and + * time series data. + * @class + * @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; + auth: gax.GoogleAuth; + metricServiceStub: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of MetricServiceClient. + * + * @param {object} [options] - The configuration object. See the subsequent + * parameters for more details. + * @param {object} [options.credentials] - Credentials object. + * @param {string} [options.credentials.client_email] + * @param {string} [options.credentials.private_key] + * @param {string} [options.email] - Account email address. Required when + * using a .pem or .p12 keyFilename. + * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or + * .p12 key downloaded from the Google Developers Console. If you provide + * a path to a JSON file, the projectId option below is not necessary. + * NOTE: .pem and .p12 require you to specify options.email as well. + * @param {number} [options.port] - The port on which to connect to + * the remote host. + * @param {string} [options.projectId] - The project ID from the Google + * Developer's Console, e.g. 'grape-spaceship-123'. We will also check + * the environment variable GCLOUD_PROJECT for your project ID. If your + * app is running in an environment which supports + * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, + * your project ID will be detected automatically. + * @param {function} [options.promise] - Custom promise module to use instead + * of native Promises. + * @param {string} [options.apiEndpoint] - The domain name of the + * API remote host. + */ + + constructor(opts?: ClientOptions) { + // Ensure that options include the service address and port. + const staticMembers = this.constructor as typeof MetricServiceClient; + const servicePath = opts && opts.servicePath ? + opts.servicePath : + ((opts && opts.apiEndpoint) ? opts.apiEndpoint : + staticMembers.servicePath); + const port = opts && opts.port ? opts.port : staticMembers.port; + + if (!opts) { + opts = {servicePath, port}; + } + opts.servicePath = opts.servicePath || servicePath; + opts.port = opts.port || port; + opts.clientConfig = opts.clientConfig || {}; + + const isBrowser = (typeof window !== 'undefined'); + if (isBrowser){ + opts.fallback = true; + } + // If we are in browser, we are already using fallback because of the + // "browser" field in package.json. + // But if we were explicitly requested to use fallback, let's do it now. + const gaxModule = !isBrowser && opts.fallback ? gax.fallback : gax; + + // Create a `gaxGrpc` object, with any grpc-specific options + // sent to the client. + opts.scopes = (this.constructor as typeof MetricServiceClient).scopes; + const gaxGrpc = new gaxModule.GrpcClient(opts); + + // Save the auth object to the client, for use by other methods. + this.auth = (gaxGrpc.auth as gax.GoogleAuth); + + // Determine the client header string. + const clientHeader = [ + `gax/${gaxModule.version}`, + `gapic/${version}`, + ]; + if (typeof process !== 'undefined' && 'versions' in process) { + clientHeader.push(`gl-node/${process.versions.node}`); + } else { + clientHeader.push(`gl-web/${gaxModule.version}`); + } + if (!opts.fallback) { + clientHeader.push(`grpc/${gaxGrpc.grpcVersion}`); + } + if (opts.libName && opts.libVersion) { + clientHeader.push(`${opts.libName}/${opts.libVersion}`); + } + // Load the applicable protos. + // For Node.js, pass the path to JSON proto file. + // For browsers, pass the JSON content. + + const nodejsProtoPath = path.join(__dirname, '..', '..', 'protos', 'protos.json'); + const protos = gaxGrpc.loadProto( + opts.fallback ? + 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 = { + projectAlertPolicyPathTemplate: new gaxModule.PathTemplate( + 'projects/{project}/alertPolicies/{alert_policy}' + ), + organizationAlertPolicyPathTemplate: new gaxModule.PathTemplate( + 'organizations/{organization}/alertPolicies/{alert_policy}' + ), + folderAlertPolicyPathTemplate: new gaxModule.PathTemplate( + 'folders/{folder}/alertPolicies/{alert_policy}' + ), + PathTemplate: new gaxModule.PathTemplate( + '*' + ), + projectGroupPathTemplate: new gaxModule.PathTemplate( + 'projects/{project}/groups/{group}' + ), + organizationGroupPathTemplate: new gaxModule.PathTemplate( + 'organizations/{organization}/groups/{group}' + ), + folderGroupPathTemplate: new gaxModule.PathTemplate( + 'folders/{folder}/groups/{group}' + ), + projectChannelDescriptorPathTemplate: new gaxModule.PathTemplate( + 'projects/{project}/notificationChannelDescriptors/{channel_descriptor}' + ), + organizationChannelDescriptorPathTemplate: new gaxModule.PathTemplate( + 'organizations/{organization}/notificationChannelDescriptors/{channel_descriptor}' + ), + folderChannelDescriptorPathTemplate: new gaxModule.PathTemplate( + 'folders/{folder}/notificationChannelDescriptors/{channel_descriptor}' + ), + projectNotificationChannelPathTemplate: new gaxModule.PathTemplate( + 'projects/{project}/notificationChannels/{notification_channel}' + ), + organizationNotificationChannelPathTemplate: new gaxModule.PathTemplate( + 'organizations/{organization}/notificationChannels/{notification_channel}' + ), + folderNotificationChannelPathTemplate: new gaxModule.PathTemplate( + 'folders/{folder}/notificationChannels/{notification_channel}' + ), + projectServicePathTemplate: new gaxModule.PathTemplate( + 'projects/{project}/services/{service}' + ), + organizationServicePathTemplate: new gaxModule.PathTemplate( + 'organizations/{organization}/services/{service}' + ), + folderServicePathTemplate: new gaxModule.PathTemplate( + 'folders/{folder}/services/{service}' + ), + projectServiceServiceLevelObjectivePathTemplate: new gaxModule.PathTemplate( + 'projects/{project}/services/{service}/serviceLevelObjectives/{service_level_objective}' + ), + organizationServiceServiceLevelObjectivePathTemplate: new gaxModule.PathTemplate( + 'organizations/{organization}/services/{service}/serviceLevelObjectives/{service_level_objective}' + ), + folderServiceServiceLevelObjectivePathTemplate: new gaxModule.PathTemplate( + 'folders/{folder}/services/{service}/serviceLevelObjectives/{service_level_objective}' + ), + projectUptimeCheckConfigPathTemplate: new gaxModule.PathTemplate( + 'projects/{project}/uptimeCheckConfigs/{uptime_check_config}' + ), + organizationUptimeCheckConfigPathTemplate: new gaxModule.PathTemplate( + 'organizations/{organization}/uptimeCheckConfigs/{uptime_check_config}' + ), + folderUptimeCheckConfigPathTemplate: new gaxModule.PathTemplate( + 'folders/{folder}/uptimeCheckConfigs/{uptime_check_config}' + ), + projectMonitoredResourceDescriptorPathTemplate: new gaxModule.PathTemplate( + 'projects/{project}/monitoredResourceDescriptors/{monitored_resource_descriptor}' + ), + organizationMonitoredResourceDescriptorPathTemplate: new gaxModule.PathTemplate( + 'organizations/{organization}/monitoredResourceDescriptors/{monitored_resource_descriptor}' + ), + folderMonitoredResourceDescriptorPathTemplate: new gaxModule.PathTemplate( + 'folders/{folder}/monitoredResourceDescriptors/{monitored_resource_descriptor}' + ), + projectMetricDescriptorPathTemplate: new gaxModule.PathTemplate( + 'projects/{project}/metricDescriptors/{metric_descriptor=**}' + ), + organizationMetricDescriptorPathTemplate: new gaxModule.PathTemplate( + 'organizations/{organization}/metricDescriptors/{metric_descriptor=**}' + ), + folderMetricDescriptorPathTemplate: new gaxModule.PathTemplate( + 'folders/{folder}/metricDescriptors/{metric_descriptor=**}' + ), + }; + + // 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 = { + listMonitoredResourceDescriptors: + new gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'resourceDescriptors'), + listMetricDescriptors: + new gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'metricDescriptors'), + listTimeSeries: + new gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'timeSeries') + }; + + // Put together the default options sent with requests. + const defaults = gaxGrpc.constructSettings( + 'google.monitoring.v3.MetricService', gapicConfig as gax.ClientConfig, + opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + + // Set up a dictionary of "inner API calls"; the core implementation + // of calling the API is handled in `google-gax`, with this code + // merely providing the destination and request information. + this._innerApiCalls = {}; + + // Put together the "service stub" for + // google.monitoring.v3.MetricService. + this.metricServiceStub = gaxGrpc.createStub( + opts.fallback ? + (protos as protobuf.Root).lookupService('google.monitoring.v3.MetricService') : + // tslint:disable-next-line no-any + (protos as any).google.monitoring.v3.MetricService, + opts) as Promise<{[method: string]: Function}>; + + // Iterate over each of the methods that the service provides + // and create an API call method for each. + const metricServiceStubMethods = + ['listMonitoredResourceDescriptors', 'getMonitoredResourceDescriptor', 'listMetricDescriptors', 'getMetricDescriptor', 'createMetricDescriptor', 'deleteMetricDescriptor', 'listTimeSeries', 'createTimeSeries']; + + for (const methodName of metricServiceStubMethods) { + const innerCallPromise = this.metricServiceStub.then( + stub => (...args: Array<{}>) => { + if (this._terminated) { + return Promise.reject('The client has already been closed.'); + } + return stub[methodName].apply(stub, args); + }, + (err: Error|null|undefined) => () => { + throw err; + }); + + const apiCall = gaxModule.createApiCall( + innerCallPromise, + defaults[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); + }; + } + } + + /** + * The DNS address for this API service. + */ + static get servicePath() { + return 'monitoring.googleapis.com'; + } + + /** + * The DNS address for this API service - same as servicePath(), + * exists for compatibility reasons. + */ + static get apiEndpoint() { + return 'monitoring.googleapis.com'; + } + + /** + * The port for this API service. + */ + static get port() { + return 443; + } + + /** + * The scopes needed to make gRPC calls for every method defined + * in this service. + */ + static get scopes() { + return [ + 'https://www.googleapis.com/auth/cloud-platform', + 'https://www.googleapis.com/auth/monitoring', + 'https://www.googleapis.com/auth/monitoring.read', + 'https://www.googleapis.com/auth/monitoring.write' + ]; + } + + getProjectId(): Promise; + getProjectId(callback: Callback): void; + /** + * Return the project ID used by this class. + * @param {function(Error, string)} callback - the callback to + * be called with the current project Id. + */ + getProjectId(callback?: Callback): + Promise|void { + if (callback) { + this.auth.getProjectId(callback); + return; + } + return this.auth.getProjectId(); + } + + // ------------------- + // -- Service calls -- + // ------------------- + getMonitoredResourceDescriptor( + request: protosTypes.google.monitoring.v3.IGetMonitoredResourceDescriptorRequest, + options?: gax.CallOptions): + Promise<[ + protosTypes.google.api.IMonitoredResourceDescriptor, + protosTypes.google.monitoring.v3.IGetMonitoredResourceDescriptorRequest|undefined, {}|undefined + ]>; + getMonitoredResourceDescriptor( + request: protosTypes.google.monitoring.v3.IGetMonitoredResourceDescriptorRequest, + options: gax.CallOptions, + callback: Callback< + protosTypes.google.api.IMonitoredResourceDescriptor, + protosTypes.google.monitoring.v3.IGetMonitoredResourceDescriptorRequest|undefined, + {}|undefined>): void; +/** + * Gets a single monitored resource descriptor. This method does not require a Stackdriver account. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The monitored resource descriptor to get. The format is + * `"projects/{project_id_or_number}/monitoredResourceDescriptors/{resource_type}"`. + * The `{resource_type}` is a predefined type, such as + * `cloudsql_database`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [MonitoredResourceDescriptor]{@link google.api.MonitoredResourceDescriptor}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ + getMonitoredResourceDescriptor( + request: protosTypes.google.monitoring.v3.IGetMonitoredResourceDescriptorRequest, + optionsOrCallback?: gax.CallOptions|Callback< + protosTypes.google.api.IMonitoredResourceDescriptor, + protosTypes.google.monitoring.v3.IGetMonitoredResourceDescriptorRequest|undefined, {}|undefined>, + callback?: Callback< + protosTypes.google.api.IMonitoredResourceDescriptor, + protosTypes.google.monitoring.v3.IGetMonitoredResourceDescriptorRequest|undefined, + {}|undefined>): + Promise<[ + protosTypes.google.api.IMonitoredResourceDescriptor, + protosTypes.google.monitoring.v3.IGetMonitoredResourceDescriptorRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as gax.CallOptions; + } + 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 || '', + }); + return this._innerApiCalls.getMonitoredResourceDescriptor(request, options, callback); + } + getMetricDescriptor( + request: protosTypes.google.monitoring.v3.IGetMetricDescriptorRequest, + options?: gax.CallOptions): + Promise<[ + protosTypes.google.api.IMetricDescriptor, + protosTypes.google.monitoring.v3.IGetMetricDescriptorRequest|undefined, {}|undefined + ]>; + getMetricDescriptor( + request: protosTypes.google.monitoring.v3.IGetMetricDescriptorRequest, + options: gax.CallOptions, + callback: Callback< + protosTypes.google.api.IMetricDescriptor, + protosTypes.google.monitoring.v3.IGetMetricDescriptorRequest|undefined, + {}|undefined>): void; +/** + * Gets a single metric descriptor. This method does not require a Stackdriver account. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The metric descriptor on which to execute the request. The format is + * `"projects/{project_id_or_number}/metricDescriptors/{metric_id}"`. + * An example value of `{metric_id}` is + * `"compute.googleapis.com/instance/disk/read_bytes_count"`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [MetricDescriptor]{@link google.api.MetricDescriptor}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ + getMetricDescriptor( + request: protosTypes.google.monitoring.v3.IGetMetricDescriptorRequest, + optionsOrCallback?: gax.CallOptions|Callback< + protosTypes.google.api.IMetricDescriptor, + protosTypes.google.monitoring.v3.IGetMetricDescriptorRequest|undefined, {}|undefined>, + callback?: Callback< + protosTypes.google.api.IMetricDescriptor, + protosTypes.google.monitoring.v3.IGetMetricDescriptorRequest|undefined, + {}|undefined>): + Promise<[ + protosTypes.google.api.IMetricDescriptor, + protosTypes.google.monitoring.v3.IGetMetricDescriptorRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as gax.CallOptions; + } + 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 || '', + }); + return this._innerApiCalls.getMetricDescriptor(request, options, callback); + } + createMetricDescriptor( + request: protosTypes.google.monitoring.v3.ICreateMetricDescriptorRequest, + options?: gax.CallOptions): + Promise<[ + protosTypes.google.api.IMetricDescriptor, + protosTypes.google.monitoring.v3.ICreateMetricDescriptorRequest|undefined, {}|undefined + ]>; + createMetricDescriptor( + request: protosTypes.google.monitoring.v3.ICreateMetricDescriptorRequest, + options: gax.CallOptions, + callback: Callback< + protosTypes.google.api.IMetricDescriptor, + protosTypes.google.monitoring.v3.ICreateMetricDescriptorRequest|undefined, + {}|undefined>): void; +/** + * Creates a new metric descriptor. + * User-created metric descriptors define + * [custom metrics](/monitoring/custom-metrics). + * + * @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 {google.api.MetricDescriptor} request.metricDescriptor + * Required. The new [custom metric](/monitoring/custom-metrics) + * descriptor. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [MetricDescriptor]{@link google.api.MetricDescriptor}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ + createMetricDescriptor( + request: protosTypes.google.monitoring.v3.ICreateMetricDescriptorRequest, + optionsOrCallback?: gax.CallOptions|Callback< + protosTypes.google.api.IMetricDescriptor, + protosTypes.google.monitoring.v3.ICreateMetricDescriptorRequest|undefined, {}|undefined>, + callback?: Callback< + protosTypes.google.api.IMetricDescriptor, + protosTypes.google.monitoring.v3.ICreateMetricDescriptorRequest|undefined, + {}|undefined>): + Promise<[ + protosTypes.google.api.IMetricDescriptor, + protosTypes.google.monitoring.v3.ICreateMetricDescriptorRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as gax.CallOptions; + } + 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 || '', + }); + return this._innerApiCalls.createMetricDescriptor(request, options, callback); + } + deleteMetricDescriptor( + request: protosTypes.google.monitoring.v3.IDeleteMetricDescriptorRequest, + options?: gax.CallOptions): + Promise<[ + protosTypes.google.protobuf.IEmpty, + protosTypes.google.monitoring.v3.IDeleteMetricDescriptorRequest|undefined, {}|undefined + ]>; + deleteMetricDescriptor( + request: protosTypes.google.monitoring.v3.IDeleteMetricDescriptorRequest, + options: gax.CallOptions, + callback: Callback< + protosTypes.google.protobuf.IEmpty, + protosTypes.google.monitoring.v3.IDeleteMetricDescriptorRequest|undefined, + {}|undefined>): void; +/** + * Deletes a metric descriptor. Only user-created + * [custom metrics](/monitoring/custom-metrics) can be deleted. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The metric descriptor on which to execute the request. The format is + * `"projects/{project_id_or_number}/metricDescriptors/{metric_id}"`. + * An example of `{metric_id}` is: + * `"custom.googleapis.com/my_test_metric"`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ + deleteMetricDescriptor( + request: protosTypes.google.monitoring.v3.IDeleteMetricDescriptorRequest, + optionsOrCallback?: gax.CallOptions|Callback< + protosTypes.google.protobuf.IEmpty, + protosTypes.google.monitoring.v3.IDeleteMetricDescriptorRequest|undefined, {}|undefined>, + callback?: Callback< + protosTypes.google.protobuf.IEmpty, + protosTypes.google.monitoring.v3.IDeleteMetricDescriptorRequest|undefined, + {}|undefined>): + Promise<[ + protosTypes.google.protobuf.IEmpty, + protosTypes.google.monitoring.v3.IDeleteMetricDescriptorRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as gax.CallOptions; + } + 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 || '', + }); + return this._innerApiCalls.deleteMetricDescriptor(request, options, callback); + } + createTimeSeries( + request: protosTypes.google.monitoring.v3.ICreateTimeSeriesRequest, + options?: gax.CallOptions): + Promise<[ + protosTypes.google.protobuf.IEmpty, + protosTypes.google.monitoring.v3.ICreateTimeSeriesRequest|undefined, {}|undefined + ]>; + createTimeSeries( + request: protosTypes.google.monitoring.v3.ICreateTimeSeriesRequest, + options: gax.CallOptions, + callback: Callback< + protosTypes.google.protobuf.IEmpty, + protosTypes.google.monitoring.v3.ICreateTimeSeriesRequest|undefined, + {}|undefined>): void; +/** + * Creates or adds data to one or more time series. + * The response is empty if all time series in the request were written. + * If any time series could not be written, a corresponding failure message is + * included in the error response. + * + * @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 {number[]} request.timeSeries + * Required. The new data to be added to a list of time series. + * Adds at most one data point to each of several time series. The new data + * point must be more recent than any other point in its time series. Each + * `TimeSeries` value must fully specify a unique time series by supplying + * all label values for the metric and the monitored resource. + * + * The maximum number of `TimeSeries` objects per `Create` request is 200. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ + createTimeSeries( + request: protosTypes.google.monitoring.v3.ICreateTimeSeriesRequest, + optionsOrCallback?: gax.CallOptions|Callback< + protosTypes.google.protobuf.IEmpty, + protosTypes.google.monitoring.v3.ICreateTimeSeriesRequest|undefined, {}|undefined>, + callback?: Callback< + protosTypes.google.protobuf.IEmpty, + protosTypes.google.monitoring.v3.ICreateTimeSeriesRequest|undefined, + {}|undefined>): + Promise<[ + protosTypes.google.protobuf.IEmpty, + protosTypes.google.monitoring.v3.ICreateTimeSeriesRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as gax.CallOptions; + } + 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 || '', + }); + return this._innerApiCalls.createTimeSeries(request, options, callback); + } + + listMonitoredResourceDescriptors( + request: protosTypes.google.monitoring.v3.IListMonitoredResourceDescriptorsRequest, + options?: gax.CallOptions): + Promise<[ + protosTypes.google.api.IMonitoredResourceDescriptor[], + protosTypes.google.monitoring.v3.IListMonitoredResourceDescriptorsRequest|null, + protosTypes.google.monitoring.v3.IListMonitoredResourceDescriptorsResponse + ]>; + listMonitoredResourceDescriptors( + request: protosTypes.google.monitoring.v3.IListMonitoredResourceDescriptorsRequest, + options: gax.CallOptions, + callback: Callback< + protosTypes.google.api.IMonitoredResourceDescriptor[], + protosTypes.google.monitoring.v3.IListMonitoredResourceDescriptorsRequest|null, + protosTypes.google.monitoring.v3.IListMonitoredResourceDescriptorsResponse>): void; +/** + * Lists monitored resource descriptors that match a filter. This method does not require a Stackdriver account. + * + * @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](/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 {Promise} - The promise which resolves to an array. + * The first element of the array is Array of [MonitoredResourceDescriptor]{@link google.api.MonitoredResourceDescriptor}. + * The client library support auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * + * When autoPaginate: false is specified through options, the array has three elements. + * The first element is Array of [MonitoredResourceDescriptor]{@link google.api.MonitoredResourceDescriptor} that corresponds to + * the one page received from the API server. + * If the second element is not null it contains the request object of type [ListMonitoredResourceDescriptorsRequest]{@link google.monitoring.v3.ListMonitoredResourceDescriptorsRequest} + * that can be used to obtain the next page of the results. + * If it is null, the next page does not exist. + * The third element contains the raw response received from the API server. Its type is + * [ListMonitoredResourceDescriptorsResponse]{@link google.monitoring.v3.ListMonitoredResourceDescriptorsResponse}. + * + * The promise has a method named "cancel" which cancels the ongoing API call. + */ + listMonitoredResourceDescriptors( + request: protosTypes.google.monitoring.v3.IListMonitoredResourceDescriptorsRequest, + optionsOrCallback?: gax.CallOptions|Callback< + protosTypes.google.api.IMonitoredResourceDescriptor[], + protosTypes.google.monitoring.v3.IListMonitoredResourceDescriptorsRequest|null, + protosTypes.google.monitoring.v3.IListMonitoredResourceDescriptorsResponse>, + callback?: Callback< + protosTypes.google.api.IMonitoredResourceDescriptor[], + protosTypes.google.monitoring.v3.IListMonitoredResourceDescriptorsRequest|null, + protosTypes.google.monitoring.v3.IListMonitoredResourceDescriptorsResponse>): + Promise<[ + protosTypes.google.api.IMonitoredResourceDescriptor[], + protosTypes.google.monitoring.v3.IListMonitoredResourceDescriptorsRequest|null, + protosTypes.google.monitoring.v3.IListMonitoredResourceDescriptorsResponse + ]>|void { + request = request || {}; + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as gax.CallOptions; + } + 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 || '', + }); + return this._innerApiCalls.listMonitoredResourceDescriptors(request, options, callback); + } + +/** + * Equivalent to {@link listMonitoredResourceDescriptors}, but returns a NodeJS Stream object. + * + * This fetches the paged responses for {@link listMonitoredResourceDescriptors} continuously + * and invokes the callback registered for 'data' event for each element in the + * responses. + * + * The returned object has 'end' method when no more elements are required. + * + * autoPaginate option will be ignored. + * + * @see {@link https://nodejs.org/api/stream.html} + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.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](/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 {Stream} + * An object stream which emits an object representing [MonitoredResourceDescriptor]{@link google.api.MonitoredResourceDescriptor} on 'data' event. + */ + listMonitoredResourceDescriptorsStream( + request?: protosTypes.google.monitoring.v3.IListMonitoredResourceDescriptorsRequest, + options?: gax.CallOptions | {}): + Transform{ + request = request || {}; + const callSettings = new gax.CallSettings(options); + return this._descriptors.page.listMonitoredResourceDescriptors.createStream( + this._innerApiCalls.listMonitoredResourceDescriptors as gax.GaxCall, + request, + callSettings + ); + } + listMetricDescriptors( + request: protosTypes.google.monitoring.v3.IListMetricDescriptorsRequest, + options?: gax.CallOptions): + Promise<[ + protosTypes.google.api.IMetricDescriptor[], + protosTypes.google.monitoring.v3.IListMetricDescriptorsRequest|null, + protosTypes.google.monitoring.v3.IListMetricDescriptorsResponse + ]>; + listMetricDescriptors( + request: protosTypes.google.monitoring.v3.IListMetricDescriptorsRequest, + options: gax.CallOptions, + callback: Callback< + protosTypes.google.api.IMetricDescriptor[], + protosTypes.google.monitoring.v3.IListMetricDescriptorsRequest|null, + protosTypes.google.monitoring.v3.IListMetricDescriptorsResponse>): void; +/** + * Lists metric descriptors that match a filter. This method does not require a Stackdriver account. + * + * @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](/monitoring/api/v3/filters) + * specifies which metric descriptors are to be + * returned. For example, the following filter matches all + * [custom metrics](/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 {Promise} - The promise which resolves to an array. + * The first element of the array is Array of [MetricDescriptor]{@link google.api.MetricDescriptor}. + * The client library support auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * + * When autoPaginate: false is specified through options, the array has three elements. + * The first element is Array of [MetricDescriptor]{@link google.api.MetricDescriptor} that corresponds to + * the one page received from the API server. + * If the second element is not null it contains the request object of type [ListMetricDescriptorsRequest]{@link google.monitoring.v3.ListMetricDescriptorsRequest} + * that can be used to obtain the next page of the results. + * If it is null, the next page does not exist. + * The third element contains the raw response received from the API server. Its type is + * [ListMetricDescriptorsResponse]{@link google.monitoring.v3.ListMetricDescriptorsResponse}. + * + * The promise has a method named "cancel" which cancels the ongoing API call. + */ + listMetricDescriptors( + request: protosTypes.google.monitoring.v3.IListMetricDescriptorsRequest, + optionsOrCallback?: gax.CallOptions|Callback< + protosTypes.google.api.IMetricDescriptor[], + protosTypes.google.monitoring.v3.IListMetricDescriptorsRequest|null, + protosTypes.google.monitoring.v3.IListMetricDescriptorsResponse>, + callback?: Callback< + protosTypes.google.api.IMetricDescriptor[], + protosTypes.google.monitoring.v3.IListMetricDescriptorsRequest|null, + protosTypes.google.monitoring.v3.IListMetricDescriptorsResponse>): + Promise<[ + protosTypes.google.api.IMetricDescriptor[], + protosTypes.google.monitoring.v3.IListMetricDescriptorsRequest|null, + protosTypes.google.monitoring.v3.IListMetricDescriptorsResponse + ]>|void { + request = request || {}; + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as gax.CallOptions; + } + 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 || '', + }); + return this._innerApiCalls.listMetricDescriptors(request, options, callback); + } + +/** + * Equivalent to {@link listMetricDescriptors}, but returns a NodeJS Stream object. + * + * This fetches the paged responses for {@link listMetricDescriptors} continuously + * and invokes the callback registered for 'data' event for each element in the + * responses. + * + * The returned object has 'end' method when no more elements are required. + * + * autoPaginate option will be ignored. + * + * @see {@link https://nodejs.org/api/stream.html} + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.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](/monitoring/api/v3/filters) + * specifies which metric descriptors are to be + * returned. For example, the following filter matches all + * [custom metrics](/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 {Stream} + * An object stream which emits an object representing [MetricDescriptor]{@link google.api.MetricDescriptor} on 'data' event. + */ + listMetricDescriptorsStream( + request?: protosTypes.google.monitoring.v3.IListMetricDescriptorsRequest, + options?: gax.CallOptions | {}): + Transform{ + request = request || {}; + const callSettings = new gax.CallSettings(options); + return this._descriptors.page.listMetricDescriptors.createStream( + this._innerApiCalls.listMetricDescriptors as gax.GaxCall, + request, + callSettings + ); + } + listTimeSeries( + request: protosTypes.google.monitoring.v3.IListTimeSeriesRequest, + options?: gax.CallOptions): + Promise<[ + protosTypes.google.monitoring.v3.ITimeSeries[], + protosTypes.google.monitoring.v3.IListTimeSeriesRequest|null, + protosTypes.google.monitoring.v3.IListTimeSeriesResponse + ]>; + listTimeSeries( + request: protosTypes.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>): void; +/** + * Lists time series that match a filter. This method does not require a Stackdriver account. + * + * @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](/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 {Promise} - The promise which resolves to an array. + * The first element of the array is Array of [TimeSeries]{@link google.monitoring.v3.TimeSeries}. + * The client library support auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * + * When autoPaginate: false is specified through options, the array has three elements. + * The first element is Array of [TimeSeries]{@link google.monitoring.v3.TimeSeries} that corresponds to + * the one page received from the API server. + * If the second element is not null it contains the request object of type [ListTimeSeriesRequest]{@link google.monitoring.v3.ListTimeSeriesRequest} + * that can be used to obtain the next page of the results. + * If it is null, the next page does not exist. + * The third element contains the raw response received from the API server. Its type is + * [ListTimeSeriesResponse]{@link google.monitoring.v3.ListTimeSeriesResponse}. + * + * The promise has a method named "cancel" which cancels the ongoing API call. + */ + listTimeSeries( + request: protosTypes.google.monitoring.v3.IListTimeSeriesRequest, + optionsOrCallback?: gax.CallOptions|Callback< + protosTypes.google.monitoring.v3.ITimeSeries[], + protosTypes.google.monitoring.v3.IListTimeSeriesRequest|null, + protosTypes.google.monitoring.v3.IListTimeSeriesResponse>, + callback?: Callback< + protosTypes.google.monitoring.v3.ITimeSeries[], + protosTypes.google.monitoring.v3.IListTimeSeriesRequest|null, + protosTypes.google.monitoring.v3.IListTimeSeriesResponse>): + Promise<[ + protosTypes.google.monitoring.v3.ITimeSeries[], + protosTypes.google.monitoring.v3.IListTimeSeriesRequest|null, + protosTypes.google.monitoring.v3.IListTimeSeriesResponse + ]>|void { + request = request || {}; + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as gax.CallOptions; + } + 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 || '', + }); + return this._innerApiCalls.listTimeSeries(request, options, callback); + } + +/** + * Equivalent to {@link listTimeSeries}, but returns a NodeJS Stream object. + * + * This fetches the paged responses for {@link listTimeSeries} continuously + * and invokes the callback registered for 'data' event for each element in the + * responses. + * + * The returned object has 'end' method when no more elements are required. + * + * autoPaginate option will be ignored. + * + * @see {@link https://nodejs.org/api/stream.html} + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.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](/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 {Stream} + * An object stream which emits an object representing [TimeSeries]{@link google.monitoring.v3.TimeSeries} on 'data' event. + */ + listTimeSeriesStream( + request?: protosTypes.google.monitoring.v3.IListTimeSeriesRequest, + options?: gax.CallOptions | {}): + Transform{ + request = request || {}; + const callSettings = new gax.CallSettings(options); + return this._descriptors.page.listTimeSeries.createStream( + this._innerApiCalls.listTimeSeries as gax.GaxCall, + request, + callSettings + ); + } + // -------------------- + // -- Path templates -- + // -------------------- + + /** + * Return a fully-qualified projectAlertPolicy resource name string. + * + * @param {string} project + * @param {string} alert_policy + * @returns {string} Resource name string. + */ + projectAlertPolicyPath(project:string,alertPolicy:string) { + return this._pathTemplates.projectAlertPolicyPathTemplate.render({ + project: project, + alert_policy: alertPolicy, + }); + } + + /** + * Parse the project from ProjectAlertPolicy resource. + * + * @param {string} projectAlertPolicyName + * A fully-qualified path representing project_alert_policy resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectAlertPolicyName(projectAlertPolicyName: string) { + return this._pathTemplates.projectAlertPolicyPathTemplate.match(projectAlertPolicyName).project; + } + + /** + * Parse the alert_policy from ProjectAlertPolicy resource. + * + * @param {string} projectAlertPolicyName + * A fully-qualified path representing project_alert_policy resource. + * @returns {string} A string representing the alert_policy. + */ + matchAlertPolicyFromProjectAlertPolicyName(projectAlertPolicyName: string) { + return this._pathTemplates.projectAlertPolicyPathTemplate.match(projectAlertPolicyName).alert_policy; + } + + /** + * Return a fully-qualified organizationAlertPolicy resource name string. + * + * @param {string} organization + * @param {string} alert_policy + * @returns {string} Resource name string. + */ + organizationAlertPolicyPath(organization:string,alertPolicy:string) { + return this._pathTemplates.organizationAlertPolicyPathTemplate.render({ + organization: organization, + alert_policy: alertPolicy, + }); + } + + /** + * Parse the organization from OrganizationAlertPolicy resource. + * + * @param {string} organizationAlertPolicyName + * A fully-qualified path representing organization_alert_policy resource. + * @returns {string} A string representing the organization. + */ + matchOrganizationFromOrganizationAlertPolicyName(organizationAlertPolicyName: string) { + return this._pathTemplates.organizationAlertPolicyPathTemplate.match(organizationAlertPolicyName).organization; + } + + /** + * Parse the alert_policy from OrganizationAlertPolicy resource. + * + * @param {string} organizationAlertPolicyName + * A fully-qualified path representing organization_alert_policy resource. + * @returns {string} A string representing the alert_policy. + */ + matchAlertPolicyFromOrganizationAlertPolicyName(organizationAlertPolicyName: string) { + return this._pathTemplates.organizationAlertPolicyPathTemplate.match(organizationAlertPolicyName).alert_policy; + } + + /** + * Return a fully-qualified folderAlertPolicy resource name string. + * + * @param {string} folder + * @param {string} alert_policy + * @returns {string} Resource name string. + */ + folderAlertPolicyPath(folder:string,alertPolicy:string) { + return this._pathTemplates.folderAlertPolicyPathTemplate.render({ + folder: folder, + alert_policy: alertPolicy, + }); + } + + /** + * Parse the folder from FolderAlertPolicy resource. + * + * @param {string} folderAlertPolicyName + * A fully-qualified path representing folder_alert_policy resource. + * @returns {string} A string representing the folder. + */ + matchFolderFromFolderAlertPolicyName(folderAlertPolicyName: string) { + return this._pathTemplates.folderAlertPolicyPathTemplate.match(folderAlertPolicyName).folder; + } + + /** + * Parse the alert_policy from FolderAlertPolicy resource. + * + * @param {string} folderAlertPolicyName + * A fully-qualified path representing folder_alert_policy resource. + * @returns {string} A string representing the alert_policy. + */ + matchAlertPolicyFromFolderAlertPolicyName(folderAlertPolicyName: string) { + return this._pathTemplates.folderAlertPolicyPathTemplate.match(folderAlertPolicyName).alert_policy; + } + + /** + * Return a fully-qualified resource name string. + * + * @returns {string} Resource name string. + */ + Path() { + return this._pathTemplates.PathTemplate.render({ + }); + } + + /** + * Return a fully-qualified projectGroup resource name string. + * + * @param {string} project + * @param {string} group + * @returns {string} Resource name string. + */ + projectGroupPath(project:string,group:string) { + return this._pathTemplates.projectGroupPathTemplate.render({ + project: project, + group: group, + }); + } + + /** + * Parse the project from ProjectGroup resource. + * + * @param {string} projectGroupName + * A fully-qualified path representing project_group resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectGroupName(projectGroupName: string) { + return this._pathTemplates.projectGroupPathTemplate.match(projectGroupName).project; + } + + /** + * Parse the group from ProjectGroup resource. + * + * @param {string} projectGroupName + * A fully-qualified path representing project_group resource. + * @returns {string} A string representing the group. + */ + matchGroupFromProjectGroupName(projectGroupName: string) { + return this._pathTemplates.projectGroupPathTemplate.match(projectGroupName).group; + } + + /** + * Return a fully-qualified organizationGroup resource name string. + * + * @param {string} organization + * @param {string} group + * @returns {string} Resource name string. + */ + organizationGroupPath(organization:string,group:string) { + return this._pathTemplates.organizationGroupPathTemplate.render({ + organization: organization, + group: group, + }); + } + + /** + * Parse the organization from OrganizationGroup resource. + * + * @param {string} organizationGroupName + * A fully-qualified path representing organization_group resource. + * @returns {string} A string representing the organization. + */ + matchOrganizationFromOrganizationGroupName(organizationGroupName: string) { + return this._pathTemplates.organizationGroupPathTemplate.match(organizationGroupName).organization; + } + + /** + * Parse the group from OrganizationGroup resource. + * + * @param {string} organizationGroupName + * A fully-qualified path representing organization_group resource. + * @returns {string} A string representing the group. + */ + matchGroupFromOrganizationGroupName(organizationGroupName: string) { + return this._pathTemplates.organizationGroupPathTemplate.match(organizationGroupName).group; + } + + /** + * Return a fully-qualified folderGroup resource name string. + * + * @param {string} folder + * @param {string} group + * @returns {string} Resource name string. + */ + folderGroupPath(folder:string,group:string) { + return this._pathTemplates.folderGroupPathTemplate.render({ + folder: folder, + group: group, + }); + } + + /** + * Parse the folder from FolderGroup resource. + * + * @param {string} folderGroupName + * A fully-qualified path representing folder_group resource. + * @returns {string} A string representing the folder. + */ + matchFolderFromFolderGroupName(folderGroupName: string) { + return this._pathTemplates.folderGroupPathTemplate.match(folderGroupName).folder; + } + + /** + * Parse the group from FolderGroup resource. + * + * @param {string} folderGroupName + * A fully-qualified path representing folder_group resource. + * @returns {string} A string representing the group. + */ + matchGroupFromFolderGroupName(folderGroupName: string) { + return this._pathTemplates.folderGroupPathTemplate.match(folderGroupName).group; + } + + /** + * Return a fully-qualified projectChannelDescriptor resource name string. + * + * @param {string} project + * @param {string} channel_descriptor + * @returns {string} Resource name string. + */ + projectChannelDescriptorPath(project:string,channelDescriptor:string) { + return this._pathTemplates.projectChannelDescriptorPathTemplate.render({ + project: project, + channel_descriptor: channelDescriptor, + }); + } + + /** + * Parse the project from ProjectChannelDescriptor resource. + * + * @param {string} projectChannelDescriptorName + * A fully-qualified path representing project_channel_descriptor resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectChannelDescriptorName(projectChannelDescriptorName: string) { + return this._pathTemplates.projectChannelDescriptorPathTemplate.match(projectChannelDescriptorName).project; + } + + /** + * Parse the channel_descriptor from ProjectChannelDescriptor resource. + * + * @param {string} projectChannelDescriptorName + * A fully-qualified path representing project_channel_descriptor resource. + * @returns {string} A string representing the channel_descriptor. + */ + matchChannelDescriptorFromProjectChannelDescriptorName(projectChannelDescriptorName: string) { + return this._pathTemplates.projectChannelDescriptorPathTemplate.match(projectChannelDescriptorName).channel_descriptor; + } + + /** + * Return a fully-qualified organizationChannelDescriptor resource name string. + * + * @param {string} organization + * @param {string} channel_descriptor + * @returns {string} Resource name string. + */ + organizationChannelDescriptorPath(organization:string,channelDescriptor:string) { + return this._pathTemplates.organizationChannelDescriptorPathTemplate.render({ + organization: organization, + channel_descriptor: channelDescriptor, + }); + } + + /** + * Parse the organization from OrganizationChannelDescriptor resource. + * + * @param {string} organizationChannelDescriptorName + * A fully-qualified path representing organization_channel_descriptor resource. + * @returns {string} A string representing the organization. + */ + matchOrganizationFromOrganizationChannelDescriptorName(organizationChannelDescriptorName: string) { + return this._pathTemplates.organizationChannelDescriptorPathTemplate.match(organizationChannelDescriptorName).organization; + } + + /** + * Parse the channel_descriptor from OrganizationChannelDescriptor resource. + * + * @param {string} organizationChannelDescriptorName + * A fully-qualified path representing organization_channel_descriptor resource. + * @returns {string} A string representing the channel_descriptor. + */ + matchChannelDescriptorFromOrganizationChannelDescriptorName(organizationChannelDescriptorName: string) { + return this._pathTemplates.organizationChannelDescriptorPathTemplate.match(organizationChannelDescriptorName).channel_descriptor; + } + + /** + * Return a fully-qualified folderChannelDescriptor resource name string. + * + * @param {string} folder + * @param {string} channel_descriptor + * @returns {string} Resource name string. + */ + folderChannelDescriptorPath(folder:string,channelDescriptor:string) { + return this._pathTemplates.folderChannelDescriptorPathTemplate.render({ + folder: folder, + channel_descriptor: channelDescriptor, + }); + } + + /** + * Parse the folder from FolderChannelDescriptor resource. + * + * @param {string} folderChannelDescriptorName + * A fully-qualified path representing folder_channel_descriptor resource. + * @returns {string} A string representing the folder. + */ + matchFolderFromFolderChannelDescriptorName(folderChannelDescriptorName: string) { + return this._pathTemplates.folderChannelDescriptorPathTemplate.match(folderChannelDescriptorName).folder; + } + + /** + * Parse the channel_descriptor from FolderChannelDescriptor resource. + * + * @param {string} folderChannelDescriptorName + * A fully-qualified path representing folder_channel_descriptor resource. + * @returns {string} A string representing the channel_descriptor. + */ + matchChannelDescriptorFromFolderChannelDescriptorName(folderChannelDescriptorName: string) { + return this._pathTemplates.folderChannelDescriptorPathTemplate.match(folderChannelDescriptorName).channel_descriptor; + } + + /** + * Return a fully-qualified projectNotificationChannel resource name string. + * + * @param {string} project + * @param {string} notification_channel + * @returns {string} Resource name string. + */ + projectNotificationChannelPath(project:string,notificationChannel:string) { + return this._pathTemplates.projectNotificationChannelPathTemplate.render({ + project: project, + notification_channel: notificationChannel, + }); + } + + /** + * Parse the project from ProjectNotificationChannel resource. + * + * @param {string} projectNotificationChannelName + * A fully-qualified path representing project_notification_channel resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectNotificationChannelName(projectNotificationChannelName: string) { + return this._pathTemplates.projectNotificationChannelPathTemplate.match(projectNotificationChannelName).project; + } + + /** + * Parse the notification_channel from ProjectNotificationChannel resource. + * + * @param {string} projectNotificationChannelName + * A fully-qualified path representing project_notification_channel resource. + * @returns {string} A string representing the notification_channel. + */ + matchNotificationChannelFromProjectNotificationChannelName(projectNotificationChannelName: string) { + return this._pathTemplates.projectNotificationChannelPathTemplate.match(projectNotificationChannelName).notification_channel; + } + + /** + * Return a fully-qualified organizationNotificationChannel resource name string. + * + * @param {string} organization + * @param {string} notification_channel + * @returns {string} Resource name string. + */ + organizationNotificationChannelPath(organization:string,notificationChannel:string) { + return this._pathTemplates.organizationNotificationChannelPathTemplate.render({ + organization: organization, + notification_channel: notificationChannel, + }); + } + + /** + * Parse the organization from OrganizationNotificationChannel resource. + * + * @param {string} organizationNotificationChannelName + * A fully-qualified path representing organization_notification_channel resource. + * @returns {string} A string representing the organization. + */ + matchOrganizationFromOrganizationNotificationChannelName(organizationNotificationChannelName: string) { + return this._pathTemplates.organizationNotificationChannelPathTemplate.match(organizationNotificationChannelName).organization; + } + + /** + * Parse the notification_channel from OrganizationNotificationChannel resource. + * + * @param {string} organizationNotificationChannelName + * A fully-qualified path representing organization_notification_channel resource. + * @returns {string} A string representing the notification_channel. + */ + matchNotificationChannelFromOrganizationNotificationChannelName(organizationNotificationChannelName: string) { + return this._pathTemplates.organizationNotificationChannelPathTemplate.match(organizationNotificationChannelName).notification_channel; + } + + /** + * Return a fully-qualified folderNotificationChannel resource name string. + * + * @param {string} folder + * @param {string} notification_channel + * @returns {string} Resource name string. + */ + folderNotificationChannelPath(folder:string,notificationChannel:string) { + return this._pathTemplates.folderNotificationChannelPathTemplate.render({ + folder: folder, + notification_channel: notificationChannel, + }); + } + + /** + * Parse the folder from FolderNotificationChannel resource. + * + * @param {string} folderNotificationChannelName + * A fully-qualified path representing folder_notification_channel resource. + * @returns {string} A string representing the folder. + */ + matchFolderFromFolderNotificationChannelName(folderNotificationChannelName: string) { + return this._pathTemplates.folderNotificationChannelPathTemplate.match(folderNotificationChannelName).folder; + } + + /** + * Parse the notification_channel from FolderNotificationChannel resource. + * + * @param {string} folderNotificationChannelName + * A fully-qualified path representing folder_notification_channel resource. + * @returns {string} A string representing the notification_channel. + */ + matchNotificationChannelFromFolderNotificationChannelName(folderNotificationChannelName: string) { + return this._pathTemplates.folderNotificationChannelPathTemplate.match(folderNotificationChannelName).notification_channel; + } + + /** + * Return a fully-qualified projectService resource name string. + * + * @param {string} project + * @param {string} service + * @returns {string} Resource name string. + */ + projectServicePath(project:string,service:string) { + return this._pathTemplates.projectServicePathTemplate.render({ + project: project, + service: service, + }); + } + + /** + * Parse the project from ProjectService resource. + * + * @param {string} projectServiceName + * A fully-qualified path representing project_service resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectServiceName(projectServiceName: string) { + return this._pathTemplates.projectServicePathTemplate.match(projectServiceName).project; + } + + /** + * Parse the service from ProjectService resource. + * + * @param {string} projectServiceName + * A fully-qualified path representing project_service resource. + * @returns {string} A string representing the service. + */ + matchServiceFromProjectServiceName(projectServiceName: string) { + return this._pathTemplates.projectServicePathTemplate.match(projectServiceName).service; + } + + /** + * Return a fully-qualified organizationService resource name string. + * + * @param {string} organization + * @param {string} service + * @returns {string} Resource name string. + */ + organizationServicePath(organization:string,service:string) { + return this._pathTemplates.organizationServicePathTemplate.render({ + organization: organization, + service: service, + }); + } + + /** + * Parse the organization from OrganizationService resource. + * + * @param {string} organizationServiceName + * A fully-qualified path representing organization_service resource. + * @returns {string} A string representing the organization. + */ + matchOrganizationFromOrganizationServiceName(organizationServiceName: string) { + return this._pathTemplates.organizationServicePathTemplate.match(organizationServiceName).organization; + } + + /** + * Parse the service from OrganizationService resource. + * + * @param {string} organizationServiceName + * A fully-qualified path representing organization_service resource. + * @returns {string} A string representing the service. + */ + matchServiceFromOrganizationServiceName(organizationServiceName: string) { + return this._pathTemplates.organizationServicePathTemplate.match(organizationServiceName).service; + } + + /** + * Return a fully-qualified folderService resource name string. + * + * @param {string} folder + * @param {string} service + * @returns {string} Resource name string. + */ + folderServicePath(folder:string,service:string) { + return this._pathTemplates.folderServicePathTemplate.render({ + folder: folder, + service: service, + }); + } + + /** + * Parse the folder from FolderService resource. + * + * @param {string} folderServiceName + * A fully-qualified path representing folder_service resource. + * @returns {string} A string representing the folder. + */ + matchFolderFromFolderServiceName(folderServiceName: string) { + return this._pathTemplates.folderServicePathTemplate.match(folderServiceName).folder; + } + + /** + * Parse the service from FolderService resource. + * + * @param {string} folderServiceName + * A fully-qualified path representing folder_service resource. + * @returns {string} A string representing the service. + */ + matchServiceFromFolderServiceName(folderServiceName: string) { + return this._pathTemplates.folderServicePathTemplate.match(folderServiceName).service; + } + + /** + * Return a fully-qualified projectServiceServiceLevelObjective resource name string. + * + * @param {string} project + * @param {string} service + * @param {string} service_level_objective + * @returns {string} Resource name string. + */ + projectServiceServiceLevelObjectivePath(project:string,service:string,serviceLevelObjective:string) { + return this._pathTemplates.projectServiceServiceLevelObjectivePathTemplate.render({ + project: project, + service: service, + service_level_objective: serviceLevelObjective, + }); + } + + /** + * Parse the project from ProjectServiceServiceLevelObjective resource. + * + * @param {string} projectServiceServiceLevelObjectiveName + * A fully-qualified path representing project_service_service_level_objective resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectServiceServiceLevelObjectiveName(projectServiceServiceLevelObjectiveName: string) { + return this._pathTemplates.projectServiceServiceLevelObjectivePathTemplate.match(projectServiceServiceLevelObjectiveName).project; + } + + /** + * Parse the service from ProjectServiceServiceLevelObjective resource. + * + * @param {string} projectServiceServiceLevelObjectiveName + * A fully-qualified path representing project_service_service_level_objective resource. + * @returns {string} A string representing the service. + */ + matchServiceFromProjectServiceServiceLevelObjectiveName(projectServiceServiceLevelObjectiveName: string) { + return this._pathTemplates.projectServiceServiceLevelObjectivePathTemplate.match(projectServiceServiceLevelObjectiveName).service; + } + + /** + * Parse the service_level_objective from ProjectServiceServiceLevelObjective resource. + * + * @param {string} projectServiceServiceLevelObjectiveName + * A fully-qualified path representing project_service_service_level_objective resource. + * @returns {string} A string representing the service_level_objective. + */ + matchServiceLevelObjectiveFromProjectServiceServiceLevelObjectiveName(projectServiceServiceLevelObjectiveName: string) { + return this._pathTemplates.projectServiceServiceLevelObjectivePathTemplate.match(projectServiceServiceLevelObjectiveName).service_level_objective; + } + + /** + * Return a fully-qualified organizationServiceServiceLevelObjective resource name string. + * + * @param {string} organization + * @param {string} service + * @param {string} service_level_objective + * @returns {string} Resource name string. + */ + organizationServiceServiceLevelObjectivePath(organization:string,service:string,serviceLevelObjective:string) { + return this._pathTemplates.organizationServiceServiceLevelObjectivePathTemplate.render({ + organization: organization, + service: service, + service_level_objective: serviceLevelObjective, + }); + } + + /** + * Parse the organization from OrganizationServiceServiceLevelObjective resource. + * + * @param {string} organizationServiceServiceLevelObjectiveName + * A fully-qualified path representing organization_service_service_level_objective resource. + * @returns {string} A string representing the organization. + */ + matchOrganizationFromOrganizationServiceServiceLevelObjectiveName(organizationServiceServiceLevelObjectiveName: string) { + return this._pathTemplates.organizationServiceServiceLevelObjectivePathTemplate.match(organizationServiceServiceLevelObjectiveName).organization; + } + + /** + * Parse the service from OrganizationServiceServiceLevelObjective resource. + * + * @param {string} organizationServiceServiceLevelObjectiveName + * A fully-qualified path representing organization_service_service_level_objective resource. + * @returns {string} A string representing the service. + */ + matchServiceFromOrganizationServiceServiceLevelObjectiveName(organizationServiceServiceLevelObjectiveName: string) { + return this._pathTemplates.organizationServiceServiceLevelObjectivePathTemplate.match(organizationServiceServiceLevelObjectiveName).service; + } + + /** + * Parse the service_level_objective from OrganizationServiceServiceLevelObjective resource. + * + * @param {string} organizationServiceServiceLevelObjectiveName + * A fully-qualified path representing organization_service_service_level_objective resource. + * @returns {string} A string representing the service_level_objective. + */ + matchServiceLevelObjectiveFromOrganizationServiceServiceLevelObjectiveName(organizationServiceServiceLevelObjectiveName: string) { + return this._pathTemplates.organizationServiceServiceLevelObjectivePathTemplate.match(organizationServiceServiceLevelObjectiveName).service_level_objective; + } + + /** + * Return a fully-qualified folderServiceServiceLevelObjective resource name string. + * + * @param {string} folder + * @param {string} service + * @param {string} service_level_objective + * @returns {string} Resource name string. + */ + folderServiceServiceLevelObjectivePath(folder:string,service:string,serviceLevelObjective:string) { + return this._pathTemplates.folderServiceServiceLevelObjectivePathTemplate.render({ + folder: folder, + service: service, + service_level_objective: serviceLevelObjective, + }); + } + + /** + * Parse the folder from FolderServiceServiceLevelObjective resource. + * + * @param {string} folderServiceServiceLevelObjectiveName + * A fully-qualified path representing folder_service_service_level_objective resource. + * @returns {string} A string representing the folder. + */ + matchFolderFromFolderServiceServiceLevelObjectiveName(folderServiceServiceLevelObjectiveName: string) { + return this._pathTemplates.folderServiceServiceLevelObjectivePathTemplate.match(folderServiceServiceLevelObjectiveName).folder; + } + + /** + * Parse the service from FolderServiceServiceLevelObjective resource. + * + * @param {string} folderServiceServiceLevelObjectiveName + * A fully-qualified path representing folder_service_service_level_objective resource. + * @returns {string} A string representing the service. + */ + matchServiceFromFolderServiceServiceLevelObjectiveName(folderServiceServiceLevelObjectiveName: string) { + return this._pathTemplates.folderServiceServiceLevelObjectivePathTemplate.match(folderServiceServiceLevelObjectiveName).service; + } + + /** + * Parse the service_level_objective from FolderServiceServiceLevelObjective resource. + * + * @param {string} folderServiceServiceLevelObjectiveName + * A fully-qualified path representing folder_service_service_level_objective resource. + * @returns {string} A string representing the service_level_objective. + */ + matchServiceLevelObjectiveFromFolderServiceServiceLevelObjectiveName(folderServiceServiceLevelObjectiveName: string) { + return this._pathTemplates.folderServiceServiceLevelObjectivePathTemplate.match(folderServiceServiceLevelObjectiveName).service_level_objective; + } + + /** + * Return a fully-qualified projectUptimeCheckConfig resource name string. + * + * @param {string} project + * @param {string} uptime_check_config + * @returns {string} Resource name string. + */ + projectUptimeCheckConfigPath(project:string,uptimeCheckConfig:string) { + return this._pathTemplates.projectUptimeCheckConfigPathTemplate.render({ + project: project, + uptime_check_config: uptimeCheckConfig, + }); + } + + /** + * Parse the project from ProjectUptimeCheckConfig resource. + * + * @param {string} projectUptimeCheckConfigName + * A fully-qualified path representing project_uptime_check_config resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectUptimeCheckConfigName(projectUptimeCheckConfigName: string) { + return this._pathTemplates.projectUptimeCheckConfigPathTemplate.match(projectUptimeCheckConfigName).project; + } + + /** + * Parse the uptime_check_config from ProjectUptimeCheckConfig resource. + * + * @param {string} projectUptimeCheckConfigName + * A fully-qualified path representing project_uptime_check_config resource. + * @returns {string} A string representing the uptime_check_config. + */ + matchUptimeCheckConfigFromProjectUptimeCheckConfigName(projectUptimeCheckConfigName: string) { + return this._pathTemplates.projectUptimeCheckConfigPathTemplate.match(projectUptimeCheckConfigName).uptime_check_config; + } + + /** + * Return a fully-qualified organizationUptimeCheckConfig resource name string. + * + * @param {string} organization + * @param {string} uptime_check_config + * @returns {string} Resource name string. + */ + organizationUptimeCheckConfigPath(organization:string,uptimeCheckConfig:string) { + return this._pathTemplates.organizationUptimeCheckConfigPathTemplate.render({ + organization: organization, + uptime_check_config: uptimeCheckConfig, + }); + } + + /** + * Parse the organization from OrganizationUptimeCheckConfig resource. + * + * @param {string} organizationUptimeCheckConfigName + * A fully-qualified path representing organization_uptime_check_config resource. + * @returns {string} A string representing the organization. + */ + matchOrganizationFromOrganizationUptimeCheckConfigName(organizationUptimeCheckConfigName: string) { + return this._pathTemplates.organizationUptimeCheckConfigPathTemplate.match(organizationUptimeCheckConfigName).organization; + } + + /** + * Parse the uptime_check_config from OrganizationUptimeCheckConfig resource. + * + * @param {string} organizationUptimeCheckConfigName + * A fully-qualified path representing organization_uptime_check_config resource. + * @returns {string} A string representing the uptime_check_config. + */ + matchUptimeCheckConfigFromOrganizationUptimeCheckConfigName(organizationUptimeCheckConfigName: string) { + return this._pathTemplates.organizationUptimeCheckConfigPathTemplate.match(organizationUptimeCheckConfigName).uptime_check_config; + } + + /** + * Return a fully-qualified folderUptimeCheckConfig resource name string. + * + * @param {string} folder + * @param {string} uptime_check_config + * @returns {string} Resource name string. + */ + folderUptimeCheckConfigPath(folder:string,uptimeCheckConfig:string) { + return this._pathTemplates.folderUptimeCheckConfigPathTemplate.render({ + folder: folder, + uptime_check_config: uptimeCheckConfig, + }); + } + + /** + * Parse the folder from FolderUptimeCheckConfig resource. + * + * @param {string} folderUptimeCheckConfigName + * A fully-qualified path representing folder_uptime_check_config resource. + * @returns {string} A string representing the folder. + */ + matchFolderFromFolderUptimeCheckConfigName(folderUptimeCheckConfigName: string) { + return this._pathTemplates.folderUptimeCheckConfigPathTemplate.match(folderUptimeCheckConfigName).folder; + } + + /** + * Parse the uptime_check_config from FolderUptimeCheckConfig resource. + * + * @param {string} folderUptimeCheckConfigName + * A fully-qualified path representing folder_uptime_check_config resource. + * @returns {string} A string representing the uptime_check_config. + */ + matchUptimeCheckConfigFromFolderUptimeCheckConfigName(folderUptimeCheckConfigName: string) { + return this._pathTemplates.folderUptimeCheckConfigPathTemplate.match(folderUptimeCheckConfigName).uptime_check_config; + } + + /** + * Return a fully-qualified projectMonitoredResourceDescriptor resource name string. + * + * @param {string} project + * @param {string} monitored_resource_descriptor + * @returns {string} Resource name string. + */ + projectMonitoredResourceDescriptorPath(project:string,monitoredResourceDescriptor:string) { + return this._pathTemplates.projectMonitoredResourceDescriptorPathTemplate.render({ + project: project, + monitored_resource_descriptor: monitoredResourceDescriptor, + }); + } + + /** + * Parse the project from ProjectMonitoredResourceDescriptor resource. + * + * @param {string} projectMonitoredResourceDescriptorName + * A fully-qualified path representing project_monitored_resource_descriptor resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectMonitoredResourceDescriptorName(projectMonitoredResourceDescriptorName: string) { + return this._pathTemplates.projectMonitoredResourceDescriptorPathTemplate.match(projectMonitoredResourceDescriptorName).project; + } + + /** + * Parse the monitored_resource_descriptor from ProjectMonitoredResourceDescriptor resource. + * + * @param {string} projectMonitoredResourceDescriptorName + * A fully-qualified path representing project_monitored_resource_descriptor resource. + * @returns {string} A string representing the monitored_resource_descriptor. + */ + matchMonitoredResourceDescriptorFromProjectMonitoredResourceDescriptorName(projectMonitoredResourceDescriptorName: string) { + return this._pathTemplates.projectMonitoredResourceDescriptorPathTemplate.match(projectMonitoredResourceDescriptorName).monitored_resource_descriptor; + } + + /** + * Return a fully-qualified organizationMonitoredResourceDescriptor resource name string. + * + * @param {string} organization + * @param {string} monitored_resource_descriptor + * @returns {string} Resource name string. + */ + organizationMonitoredResourceDescriptorPath(organization:string,monitoredResourceDescriptor:string) { + return this._pathTemplates.organizationMonitoredResourceDescriptorPathTemplate.render({ + organization: organization, + monitored_resource_descriptor: monitoredResourceDescriptor, + }); + } + + /** + * Parse the organization from OrganizationMonitoredResourceDescriptor resource. + * + * @param {string} organizationMonitoredResourceDescriptorName + * A fully-qualified path representing organization_monitored_resource_descriptor resource. + * @returns {string} A string representing the organization. + */ + matchOrganizationFromOrganizationMonitoredResourceDescriptorName(organizationMonitoredResourceDescriptorName: string) { + return this._pathTemplates.organizationMonitoredResourceDescriptorPathTemplate.match(organizationMonitoredResourceDescriptorName).organization; + } + + /** + * Parse the monitored_resource_descriptor from OrganizationMonitoredResourceDescriptor resource. + * + * @param {string} organizationMonitoredResourceDescriptorName + * A fully-qualified path representing organization_monitored_resource_descriptor resource. + * @returns {string} A string representing the monitored_resource_descriptor. + */ + matchMonitoredResourceDescriptorFromOrganizationMonitoredResourceDescriptorName(organizationMonitoredResourceDescriptorName: string) { + return this._pathTemplates.organizationMonitoredResourceDescriptorPathTemplate.match(organizationMonitoredResourceDescriptorName).monitored_resource_descriptor; + } + + /** + * Return a fully-qualified folderMonitoredResourceDescriptor resource name string. + * + * @param {string} folder + * @param {string} monitored_resource_descriptor + * @returns {string} Resource name string. + */ + folderMonitoredResourceDescriptorPath(folder:string,monitoredResourceDescriptor:string) { + return this._pathTemplates.folderMonitoredResourceDescriptorPathTemplate.render({ + folder: folder, + monitored_resource_descriptor: monitoredResourceDescriptor, + }); + } + + /** + * Parse the folder from FolderMonitoredResourceDescriptor resource. + * + * @param {string} folderMonitoredResourceDescriptorName + * A fully-qualified path representing folder_monitored_resource_descriptor resource. + * @returns {string} A string representing the folder. + */ + matchFolderFromFolderMonitoredResourceDescriptorName(folderMonitoredResourceDescriptorName: string) { + return this._pathTemplates.folderMonitoredResourceDescriptorPathTemplate.match(folderMonitoredResourceDescriptorName).folder; + } + + /** + * Parse the monitored_resource_descriptor from FolderMonitoredResourceDescriptor resource. + * + * @param {string} folderMonitoredResourceDescriptorName + * A fully-qualified path representing folder_monitored_resource_descriptor resource. + * @returns {string} A string representing the monitored_resource_descriptor. + */ + matchMonitoredResourceDescriptorFromFolderMonitoredResourceDescriptorName(folderMonitoredResourceDescriptorName: string) { + return this._pathTemplates.folderMonitoredResourceDescriptorPathTemplate.match(folderMonitoredResourceDescriptorName).monitored_resource_descriptor; + } + + /** + * Return a fully-qualified projectMetricDescriptor resource name string. + * + * @param {string} project + * @param {string} metric_descriptor + * @returns {string} Resource name string. + */ + projectMetricDescriptorPath(project:string,metricDescriptor:string) { + return this._pathTemplates.projectMetricDescriptorPathTemplate.render({ + project: project, + metric_descriptor: metricDescriptor, + }); + } + + /** + * Parse the project from ProjectMetricDescriptor resource. + * + * @param {string} projectMetricDescriptorName + * A fully-qualified path representing project_metric_descriptor resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectMetricDescriptorName(projectMetricDescriptorName: string) { + return this._pathTemplates.projectMetricDescriptorPathTemplate.match(projectMetricDescriptorName).project; + } + + /** + * Parse the metric_descriptor from ProjectMetricDescriptor resource. + * + * @param {string} projectMetricDescriptorName + * A fully-qualified path representing project_metric_descriptor resource. + * @returns {string} A string representing the metric_descriptor. + */ + matchMetricDescriptorFromProjectMetricDescriptorName(projectMetricDescriptorName: string) { + return this._pathTemplates.projectMetricDescriptorPathTemplate.match(projectMetricDescriptorName).metric_descriptor; + } + + /** + * Return a fully-qualified organizationMetricDescriptor resource name string. + * + * @param {string} organization + * @param {string} metric_descriptor + * @returns {string} Resource name string. + */ + organizationMetricDescriptorPath(organization:string,metricDescriptor:string) { + return this._pathTemplates.organizationMetricDescriptorPathTemplate.render({ + organization: organization, + metric_descriptor: metricDescriptor, + }); + } + + /** + * Parse the organization from OrganizationMetricDescriptor resource. + * + * @param {string} organizationMetricDescriptorName + * A fully-qualified path representing organization_metric_descriptor resource. + * @returns {string} A string representing the organization. + */ + matchOrganizationFromOrganizationMetricDescriptorName(organizationMetricDescriptorName: string) { + return this._pathTemplates.organizationMetricDescriptorPathTemplate.match(organizationMetricDescriptorName).organization; + } + + /** + * Parse the metric_descriptor from OrganizationMetricDescriptor resource. + * + * @param {string} organizationMetricDescriptorName + * A fully-qualified path representing organization_metric_descriptor resource. + * @returns {string} A string representing the metric_descriptor. + */ + matchMetricDescriptorFromOrganizationMetricDescriptorName(organizationMetricDescriptorName: string) { + return this._pathTemplates.organizationMetricDescriptorPathTemplate.match(organizationMetricDescriptorName).metric_descriptor; + } + + /** + * Return a fully-qualified folderMetricDescriptor resource name string. + * + * @param {string} folder + * @param {string} metric_descriptor + * @returns {string} Resource name string. + */ + folderMetricDescriptorPath(folder:string,metricDescriptor:string) { + return this._pathTemplates.folderMetricDescriptorPathTemplate.render({ + folder: folder, + metric_descriptor: metricDescriptor, + }); + } + + /** + * Parse the folder from FolderMetricDescriptor resource. + * + * @param {string} folderMetricDescriptorName + * A fully-qualified path representing folder_metric_descriptor resource. + * @returns {string} A string representing the folder. + */ + matchFolderFromFolderMetricDescriptorName(folderMetricDescriptorName: string) { + return this._pathTemplates.folderMetricDescriptorPathTemplate.match(folderMetricDescriptorName).folder; + } + + /** + * Parse the metric_descriptor from FolderMetricDescriptor resource. + * + * @param {string} folderMetricDescriptorName + * A fully-qualified path representing folder_metric_descriptor resource. + * @returns {string} A string representing the metric_descriptor. + */ + matchMetricDescriptorFromFolderMetricDescriptorName(folderMetricDescriptorName: string) { + return this._pathTemplates.folderMetricDescriptorPathTemplate.match(folderMetricDescriptorName).metric_descriptor; + } + + /** + * Terminate the GRPC channel and close the client. + * + * The client will no longer be usable and all future behavior is undefined. + */ + close(): Promise { + if (!this._terminated) { + return this.metricServiceStub.then(stub => { + this._terminated = true; + stub.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/typescript/test/testdata/monitoring/src/v3/metric_service_client_config.json.baseline b/typescript/test/testdata/monitoring/src/v3/metric_service_client_config.json.baseline new file mode 100644 index 000000000..c1826e96c --- /dev/null +++ b/typescript/test/testdata/monitoring/src/v3/metric_service_client_config.json.baseline @@ -0,0 +1,58 @@ +{ + "interfaces": { + "google.monitoring.v3.MetricService": { + "retry_codes": { + "non_idempotent": [], + "idempotent": [ + "DEADLINE_EXCEEDED", + "UNAVAILABLE" + ] + }, + "retry_params": { + "default": { + "initial_retry_delay_millis": 100, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 60000, + "initial_rpc_timeout_millis": 60000, + "rpc_timeout_multiplier": 1, + "max_rpc_timeout_millis": 60000, + "total_timeout_millis": 600000 + } + }, + "methods": { + "ListMonitoredResourceDescriptors": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "GetMonitoredResourceDescriptor": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "ListMetricDescriptors": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "GetMetricDescriptor": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "CreateMetricDescriptor": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "DeleteMetricDescriptor": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "ListTimeSeries": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "CreateTimeSeries": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/typescript/test/testdata/monitoring/src/v3/metric_service_proto_list.json.baseline b/typescript/test/testdata/monitoring/src/v3/metric_service_proto_list.json.baseline new file mode 100644 index 000000000..aacceb22f --- /dev/null +++ b/typescript/test/testdata/monitoring/src/v3/metric_service_proto_list.json.baseline @@ -0,0 +1,16 @@ +[ + "../../protos/google/monitoring/v3/alert.proto", + "../../protos/google/monitoring/v3/alert_service.proto", + "../../protos/google/monitoring/v3/common.proto", + "../../protos/google/monitoring/v3/group.proto", + "../../protos/google/monitoring/v3/group_service.proto", + "../../protos/google/monitoring/v3/metric.proto", + "../../protos/google/monitoring/v3/metric_service.proto", + "../../protos/google/monitoring/v3/mutation_record.proto", + "../../protos/google/monitoring/v3/notification.proto", + "../../protos/google/monitoring/v3/notification_service.proto", + "../../protos/google/monitoring/v3/service.proto", + "../../protos/google/monitoring/v3/service_service.proto", + "../../protos/google/monitoring/v3/uptime.proto", + "../../protos/google/monitoring/v3/uptime_service.proto" +] diff --git a/typescript/test/testdata/monitoring/src/v3/notification_channel_service_client.ts.baseline b/typescript/test/testdata/monitoring/src/v3/notification_channel_service_client.ts.baseline new file mode 100644 index 000000000..20d132d0a --- /dev/null +++ b/typescript/test/testdata/monitoring/src/v3/notification_channel_service_client.ts.baseline @@ -0,0 +1,1993 @@ +// 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 gax from 'google-gax'; +import {APICallback, Callback, CallOptions, Descriptors, ClientOptions, PaginationCallback, PaginationResponse} from 'google-gax'; +import * as path from 'path'; + +import { Transform } from 'stream'; +import * as protosTypes from '../../protos/protos'; +import * as gapicConfig from './notification_channel_service_client_config.json'; + +const version = require('../../../package.json').version; + +/** + * The Notification Channel API provides access to configuration that + * controls how messages related to incidents are sent. + * @class + * @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; + auth: gax.GoogleAuth; + notificationChannelServiceStub: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of NotificationChannelServiceClient. + * + * @param {object} [options] - The configuration object. See the subsequent + * parameters for more details. + * @param {object} [options.credentials] - Credentials object. + * @param {string} [options.credentials.client_email] + * @param {string} [options.credentials.private_key] + * @param {string} [options.email] - Account email address. Required when + * using a .pem or .p12 keyFilename. + * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or + * .p12 key downloaded from the Google Developers Console. If you provide + * a path to a JSON file, the projectId option below is not necessary. + * NOTE: .pem and .p12 require you to specify options.email as well. + * @param {number} [options.port] - The port on which to connect to + * the remote host. + * @param {string} [options.projectId] - The project ID from the Google + * Developer's Console, e.g. 'grape-spaceship-123'. We will also check + * the environment variable GCLOUD_PROJECT for your project ID. If your + * app is running in an environment which supports + * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, + * your project ID will be detected automatically. + * @param {function} [options.promise] - Custom promise module to use instead + * of native Promises. + * @param {string} [options.apiEndpoint] - The domain name of the + * API remote host. + */ + + constructor(opts?: ClientOptions) { + // Ensure that options include the service address and port. + const staticMembers = this.constructor as typeof NotificationChannelServiceClient; + const servicePath = opts && opts.servicePath ? + opts.servicePath : + ((opts && opts.apiEndpoint) ? opts.apiEndpoint : + staticMembers.servicePath); + const port = opts && opts.port ? opts.port : staticMembers.port; + + if (!opts) { + opts = {servicePath, port}; + } + opts.servicePath = opts.servicePath || servicePath; + opts.port = opts.port || port; + opts.clientConfig = opts.clientConfig || {}; + + const isBrowser = (typeof window !== 'undefined'); + if (isBrowser){ + opts.fallback = true; + } + // If we are in browser, we are already using fallback because of the + // "browser" field in package.json. + // But if we were explicitly requested to use fallback, let's do it now. + const gaxModule = !isBrowser && opts.fallback ? gax.fallback : gax; + + // Create a `gaxGrpc` object, with any grpc-specific options + // sent to the client. + opts.scopes = (this.constructor as typeof NotificationChannelServiceClient).scopes; + const gaxGrpc = new gaxModule.GrpcClient(opts); + + // Save the auth object to the client, for use by other methods. + this.auth = (gaxGrpc.auth as gax.GoogleAuth); + + // Determine the client header string. + const clientHeader = [ + `gax/${gaxModule.version}`, + `gapic/${version}`, + ]; + if (typeof process !== 'undefined' && 'versions' in process) { + clientHeader.push(`gl-node/${process.versions.node}`); + } else { + clientHeader.push(`gl-web/${gaxModule.version}`); + } + if (!opts.fallback) { + clientHeader.push(`grpc/${gaxGrpc.grpcVersion}`); + } + if (opts.libName && opts.libVersion) { + clientHeader.push(`${opts.libName}/${opts.libVersion}`); + } + // Load the applicable protos. + // For Node.js, pass the path to JSON proto file. + // For browsers, pass the JSON content. + + const nodejsProtoPath = path.join(__dirname, '..', '..', 'protos', 'protos.json'); + const protos = gaxGrpc.loadProto( + opts.fallback ? + 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 = { + projectAlertPolicyPathTemplate: new gaxModule.PathTemplate( + 'projects/{project}/alertPolicies/{alert_policy}' + ), + organizationAlertPolicyPathTemplate: new gaxModule.PathTemplate( + 'organizations/{organization}/alertPolicies/{alert_policy}' + ), + folderAlertPolicyPathTemplate: new gaxModule.PathTemplate( + 'folders/{folder}/alertPolicies/{alert_policy}' + ), + PathTemplate: new gaxModule.PathTemplate( + '*' + ), + projectGroupPathTemplate: new gaxModule.PathTemplate( + 'projects/{project}/groups/{group}' + ), + organizationGroupPathTemplate: new gaxModule.PathTemplate( + 'organizations/{organization}/groups/{group}' + ), + folderGroupPathTemplate: new gaxModule.PathTemplate( + 'folders/{folder}/groups/{group}' + ), + projectChannelDescriptorPathTemplate: new gaxModule.PathTemplate( + 'projects/{project}/notificationChannelDescriptors/{channel_descriptor}' + ), + organizationChannelDescriptorPathTemplate: new gaxModule.PathTemplate( + 'organizations/{organization}/notificationChannelDescriptors/{channel_descriptor}' + ), + folderChannelDescriptorPathTemplate: new gaxModule.PathTemplate( + 'folders/{folder}/notificationChannelDescriptors/{channel_descriptor}' + ), + projectNotificationChannelPathTemplate: new gaxModule.PathTemplate( + 'projects/{project}/notificationChannels/{notification_channel}' + ), + organizationNotificationChannelPathTemplate: new gaxModule.PathTemplate( + 'organizations/{organization}/notificationChannels/{notification_channel}' + ), + folderNotificationChannelPathTemplate: new gaxModule.PathTemplate( + 'folders/{folder}/notificationChannels/{notification_channel}' + ), + projectServicePathTemplate: new gaxModule.PathTemplate( + 'projects/{project}/services/{service}' + ), + organizationServicePathTemplate: new gaxModule.PathTemplate( + 'organizations/{organization}/services/{service}' + ), + folderServicePathTemplate: new gaxModule.PathTemplate( + 'folders/{folder}/services/{service}' + ), + projectServiceServiceLevelObjectivePathTemplate: new gaxModule.PathTemplate( + 'projects/{project}/services/{service}/serviceLevelObjectives/{service_level_objective}' + ), + organizationServiceServiceLevelObjectivePathTemplate: new gaxModule.PathTemplate( + 'organizations/{organization}/services/{service}/serviceLevelObjectives/{service_level_objective}' + ), + folderServiceServiceLevelObjectivePathTemplate: new gaxModule.PathTemplate( + 'folders/{folder}/services/{service}/serviceLevelObjectives/{service_level_objective}' + ), + projectUptimeCheckConfigPathTemplate: new gaxModule.PathTemplate( + 'projects/{project}/uptimeCheckConfigs/{uptime_check_config}' + ), + organizationUptimeCheckConfigPathTemplate: new gaxModule.PathTemplate( + 'organizations/{organization}/uptimeCheckConfigs/{uptime_check_config}' + ), + folderUptimeCheckConfigPathTemplate: new gaxModule.PathTemplate( + 'folders/{folder}/uptimeCheckConfigs/{uptime_check_config}' + ), + }; + + // 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 = { + listNotificationChannelDescriptors: + new gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'channelDescriptors'), + listNotificationChannels: + new gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'notificationChannels') + }; + + // Put together the default options sent with requests. + const defaults = gaxGrpc.constructSettings( + 'google.monitoring.v3.NotificationChannelService', gapicConfig as gax.ClientConfig, + opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + + // Set up a dictionary of "inner API calls"; the core implementation + // of calling the API is handled in `google-gax`, with this code + // merely providing the destination and request information. + this._innerApiCalls = {}; + + // Put together the "service stub" for + // google.monitoring.v3.NotificationChannelService. + this.notificationChannelServiceStub = gaxGrpc.createStub( + opts.fallback ? + (protos as protobuf.Root).lookupService('google.monitoring.v3.NotificationChannelService') : + // tslint:disable-next-line no-any + (protos as any).google.monitoring.v3.NotificationChannelService, + opts) as Promise<{[method: string]: Function}>; + + // Iterate over each of the methods that the service provides + // and create an API call method for each. + const notificationChannelServiceStubMethods = + ['listNotificationChannelDescriptors', 'getNotificationChannelDescriptor', 'listNotificationChannels', 'getNotificationChannel', 'createNotificationChannel', 'updateNotificationChannel', 'deleteNotificationChannel', 'sendNotificationChannelVerificationCode', 'getNotificationChannelVerificationCode', 'verifyNotificationChannel']; + + for (const methodName of notificationChannelServiceStubMethods) { + const innerCallPromise = this.notificationChannelServiceStub.then( + stub => (...args: Array<{}>) => { + if (this._terminated) { + return Promise.reject('The client has already been closed.'); + } + return stub[methodName].apply(stub, args); + }, + (err: Error|null|undefined) => () => { + throw err; + }); + + const apiCall = gaxModule.createApiCall( + innerCallPromise, + defaults[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); + }; + } + } + + /** + * The DNS address for this API service. + */ + static get servicePath() { + return 'monitoring.googleapis.com'; + } + + /** + * The DNS address for this API service - same as servicePath(), + * exists for compatibility reasons. + */ + static get apiEndpoint() { + return 'monitoring.googleapis.com'; + } + + /** + * The port for this API service. + */ + static get port() { + return 443; + } + + /** + * The scopes needed to make gRPC calls for every method defined + * in this service. + */ + static get scopes() { + return [ + 'https://www.googleapis.com/auth/cloud-platform', + 'https://www.googleapis.com/auth/monitoring', + 'https://www.googleapis.com/auth/monitoring.read' + ]; + } + + getProjectId(): Promise; + getProjectId(callback: Callback): void; + /** + * Return the project ID used by this class. + * @param {function(Error, string)} callback - the callback to + * be called with the current project Id. + */ + getProjectId(callback?: Callback): + Promise|void { + if (callback) { + this.auth.getProjectId(callback); + return; + } + return this.auth.getProjectId(); + } + + // ------------------- + // -- Service calls -- + // ------------------- + getNotificationChannelDescriptor( + request: protosTypes.google.monitoring.v3.IGetNotificationChannelDescriptorRequest, + options?: gax.CallOptions): + Promise<[ + protosTypes.google.monitoring.v3.INotificationChannelDescriptor, + protosTypes.google.monitoring.v3.IGetNotificationChannelDescriptorRequest|undefined, {}|undefined + ]>; + getNotificationChannelDescriptor( + request: protosTypes.google.monitoring.v3.IGetNotificationChannelDescriptorRequest, + options: gax.CallOptions, + callback: Callback< + protosTypes.google.monitoring.v3.INotificationChannelDescriptor, + protosTypes.google.monitoring.v3.IGetNotificationChannelDescriptorRequest|undefined, + {}|undefined>): void; +/** + * Gets a single channel descriptor. The descriptor indicates which fields + * are expected / permitted for a notification channel of the given type. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The channel type for which to execute the request. The format is + * `projects/[PROJECT_ID]/notificationChannelDescriptors/{channel_type}`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [NotificationChannelDescriptor]{@link google.monitoring.v3.NotificationChannelDescriptor}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ + getNotificationChannelDescriptor( + request: protosTypes.google.monitoring.v3.IGetNotificationChannelDescriptorRequest, + optionsOrCallback?: gax.CallOptions|Callback< + protosTypes.google.monitoring.v3.INotificationChannelDescriptor, + protosTypes.google.monitoring.v3.IGetNotificationChannelDescriptorRequest|undefined, {}|undefined>, + callback?: Callback< + protosTypes.google.monitoring.v3.INotificationChannelDescriptor, + protosTypes.google.monitoring.v3.IGetNotificationChannelDescriptorRequest|undefined, + {}|undefined>): + Promise<[ + protosTypes.google.monitoring.v3.INotificationChannelDescriptor, + protosTypes.google.monitoring.v3.IGetNotificationChannelDescriptorRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as gax.CallOptions; + } + 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 || '', + }); + return this._innerApiCalls.getNotificationChannelDescriptor(request, options, callback); + } + getNotificationChannel( + request: protosTypes.google.monitoring.v3.IGetNotificationChannelRequest, + options?: gax.CallOptions): + Promise<[ + protosTypes.google.monitoring.v3.INotificationChannel, + protosTypes.google.monitoring.v3.IGetNotificationChannelRequest|undefined, {}|undefined + ]>; + getNotificationChannel( + request: protosTypes.google.monitoring.v3.IGetNotificationChannelRequest, + options: gax.CallOptions, + callback: Callback< + protosTypes.google.monitoring.v3.INotificationChannel, + protosTypes.google.monitoring.v3.IGetNotificationChannelRequest|undefined, + {}|undefined>): void; +/** + * Gets a single notification channel. The channel includes the relevant + * configuration details with which the channel was created. However, the + * response may truncate or omit passwords, API keys, or other private key + * matter and thus the response may not be 100% identical to the information + * that was supplied in the call to the create method. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The channel for which to execute the request. The format is + * `projects/[PROJECT_ID]/notificationChannels/[CHANNEL_ID]`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [NotificationChannel]{@link google.monitoring.v3.NotificationChannel}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ + getNotificationChannel( + request: protosTypes.google.monitoring.v3.IGetNotificationChannelRequest, + optionsOrCallback?: gax.CallOptions|Callback< + protosTypes.google.monitoring.v3.INotificationChannel, + protosTypes.google.monitoring.v3.IGetNotificationChannelRequest|undefined, {}|undefined>, + callback?: Callback< + protosTypes.google.monitoring.v3.INotificationChannel, + protosTypes.google.monitoring.v3.IGetNotificationChannelRequest|undefined, + {}|undefined>): + Promise<[ + protosTypes.google.monitoring.v3.INotificationChannel, + protosTypes.google.monitoring.v3.IGetNotificationChannelRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as gax.CallOptions; + } + 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 || '', + }); + return this._innerApiCalls.getNotificationChannel(request, options, callback); + } + createNotificationChannel( + request: protosTypes.google.monitoring.v3.ICreateNotificationChannelRequest, + options?: gax.CallOptions): + Promise<[ + protosTypes.google.monitoring.v3.INotificationChannel, + protosTypes.google.monitoring.v3.ICreateNotificationChannelRequest|undefined, {}|undefined + ]>; + createNotificationChannel( + request: protosTypes.google.monitoring.v3.ICreateNotificationChannelRequest, + options: gax.CallOptions, + callback: Callback< + protosTypes.google.monitoring.v3.INotificationChannel, + protosTypes.google.monitoring.v3.ICreateNotificationChannelRequest|undefined, + {}|undefined>): void; +/** + * Creates a new notification channel, representing a single notification + * endpoint such as an email address, SMS number, or PagerDuty service. + * + * @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] + * + * Note that this names the container into which the channel will be + * written. This does not name the newly created channel. The resulting + * channel's name will have a normalized version of this field as a prefix, + * but will add `/notificationChannels/[CHANNEL_ID]` to identify the channel. + * @param {google.monitoring.v3.NotificationChannel} request.notificationChannel + * Required. The definition of the `NotificationChannel` to create. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [NotificationChannel]{@link google.monitoring.v3.NotificationChannel}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ + createNotificationChannel( + request: protosTypes.google.monitoring.v3.ICreateNotificationChannelRequest, + optionsOrCallback?: gax.CallOptions|Callback< + protosTypes.google.monitoring.v3.INotificationChannel, + protosTypes.google.monitoring.v3.ICreateNotificationChannelRequest|undefined, {}|undefined>, + callback?: Callback< + protosTypes.google.monitoring.v3.INotificationChannel, + protosTypes.google.monitoring.v3.ICreateNotificationChannelRequest|undefined, + {}|undefined>): + Promise<[ + protosTypes.google.monitoring.v3.INotificationChannel, + protosTypes.google.monitoring.v3.ICreateNotificationChannelRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as gax.CallOptions; + } + 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 || '', + }); + return this._innerApiCalls.createNotificationChannel(request, options, callback); + } + updateNotificationChannel( + request: protosTypes.google.monitoring.v3.IUpdateNotificationChannelRequest, + options?: gax.CallOptions): + Promise<[ + protosTypes.google.monitoring.v3.INotificationChannel, + protosTypes.google.monitoring.v3.IUpdateNotificationChannelRequest|undefined, {}|undefined + ]>; + updateNotificationChannel( + request: protosTypes.google.monitoring.v3.IUpdateNotificationChannelRequest, + options: gax.CallOptions, + callback: Callback< + protosTypes.google.monitoring.v3.INotificationChannel, + protosTypes.google.monitoring.v3.IUpdateNotificationChannelRequest|undefined, + {}|undefined>): void; +/** + * Updates a notification channel. Fields not specified in the field mask + * remain unchanged. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.protobuf.FieldMask} request.updateMask + * The fields to update. + * @param {google.monitoring.v3.NotificationChannel} request.notificationChannel + * Required. A description of the changes to be applied to the specified + * notification channel. The description must provide a definition for + * fields to be updated; the names of these fields should also be + * included in the `update_mask`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [NotificationChannel]{@link google.monitoring.v3.NotificationChannel}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ + updateNotificationChannel( + request: protosTypes.google.monitoring.v3.IUpdateNotificationChannelRequest, + optionsOrCallback?: gax.CallOptions|Callback< + protosTypes.google.monitoring.v3.INotificationChannel, + protosTypes.google.monitoring.v3.IUpdateNotificationChannelRequest|undefined, {}|undefined>, + callback?: Callback< + protosTypes.google.monitoring.v3.INotificationChannel, + protosTypes.google.monitoring.v3.IUpdateNotificationChannelRequest|undefined, + {}|undefined>): + Promise<[ + protosTypes.google.monitoring.v3.INotificationChannel, + protosTypes.google.monitoring.v3.IUpdateNotificationChannelRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as gax.CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'notification_channel.name': request.notificationChannel!.name || '', + }); + return this._innerApiCalls.updateNotificationChannel(request, options, callback); + } + deleteNotificationChannel( + request: protosTypes.google.monitoring.v3.IDeleteNotificationChannelRequest, + options?: gax.CallOptions): + Promise<[ + protosTypes.google.protobuf.IEmpty, + protosTypes.google.monitoring.v3.IDeleteNotificationChannelRequest|undefined, {}|undefined + ]>; + deleteNotificationChannel( + request: protosTypes.google.monitoring.v3.IDeleteNotificationChannelRequest, + options: gax.CallOptions, + callback: Callback< + protosTypes.google.protobuf.IEmpty, + protosTypes.google.monitoring.v3.IDeleteNotificationChannelRequest|undefined, + {}|undefined>): void; +/** + * Deletes a notification channel. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The channel for which to execute the request. The format is + * `projects/[PROJECT_ID]/notificationChannels/[CHANNEL_ID]`. + * @param {boolean} request.force + * If true, the notification channel will be deleted regardless of its + * use in alert policies (the policies will be updated to remove the + * channel). If false, channels that are still referenced by an existing + * alerting policy will fail to be deleted in a delete operation. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ + deleteNotificationChannel( + request: protosTypes.google.monitoring.v3.IDeleteNotificationChannelRequest, + optionsOrCallback?: gax.CallOptions|Callback< + protosTypes.google.protobuf.IEmpty, + protosTypes.google.monitoring.v3.IDeleteNotificationChannelRequest|undefined, {}|undefined>, + callback?: Callback< + protosTypes.google.protobuf.IEmpty, + protosTypes.google.monitoring.v3.IDeleteNotificationChannelRequest|undefined, + {}|undefined>): + Promise<[ + protosTypes.google.protobuf.IEmpty, + protosTypes.google.monitoring.v3.IDeleteNotificationChannelRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as gax.CallOptions; + } + 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 || '', + }); + return this._innerApiCalls.deleteNotificationChannel(request, options, callback); + } + sendNotificationChannelVerificationCode( + request: protosTypes.google.monitoring.v3.ISendNotificationChannelVerificationCodeRequest, + options?: gax.CallOptions): + Promise<[ + protosTypes.google.protobuf.IEmpty, + protosTypes.google.monitoring.v3.ISendNotificationChannelVerificationCodeRequest|undefined, {}|undefined + ]>; + sendNotificationChannelVerificationCode( + request: protosTypes.google.monitoring.v3.ISendNotificationChannelVerificationCodeRequest, + options: gax.CallOptions, + callback: Callback< + protosTypes.google.protobuf.IEmpty, + protosTypes.google.monitoring.v3.ISendNotificationChannelVerificationCodeRequest|undefined, + {}|undefined>): void; +/** + * Causes a verification code to be delivered to the channel. The code + * can then be supplied in `VerifyNotificationChannel` to verify the channel. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The notification channel to which to send a verification code. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ + sendNotificationChannelVerificationCode( + request: protosTypes.google.monitoring.v3.ISendNotificationChannelVerificationCodeRequest, + optionsOrCallback?: gax.CallOptions|Callback< + protosTypes.google.protobuf.IEmpty, + protosTypes.google.monitoring.v3.ISendNotificationChannelVerificationCodeRequest|undefined, {}|undefined>, + callback?: Callback< + protosTypes.google.protobuf.IEmpty, + protosTypes.google.monitoring.v3.ISendNotificationChannelVerificationCodeRequest|undefined, + {}|undefined>): + Promise<[ + protosTypes.google.protobuf.IEmpty, + protosTypes.google.monitoring.v3.ISendNotificationChannelVerificationCodeRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as gax.CallOptions; + } + 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 || '', + }); + return this._innerApiCalls.sendNotificationChannelVerificationCode(request, options, callback); + } + getNotificationChannelVerificationCode( + request: protosTypes.google.monitoring.v3.IGetNotificationChannelVerificationCodeRequest, + options?: gax.CallOptions): + Promise<[ + protosTypes.google.monitoring.v3.IGetNotificationChannelVerificationCodeResponse, + protosTypes.google.monitoring.v3.IGetNotificationChannelVerificationCodeRequest|undefined, {}|undefined + ]>; + getNotificationChannelVerificationCode( + request: protosTypes.google.monitoring.v3.IGetNotificationChannelVerificationCodeRequest, + options: gax.CallOptions, + callback: Callback< + protosTypes.google.monitoring.v3.IGetNotificationChannelVerificationCodeResponse, + protosTypes.google.monitoring.v3.IGetNotificationChannelVerificationCodeRequest|undefined, + {}|undefined>): void; +/** + * Requests a verification code for an already verified channel that can then + * be used in a call to VerifyNotificationChannel() on a different channel + * with an equivalent identity in the same or in a different project. This + * makes it possible to copy a channel between projects without requiring + * manual reverification of the channel. If the channel is not in the + * verified state, this method will fail (in other words, this may only be + * used if the SendNotificationChannelVerificationCode and + * VerifyNotificationChannel paths have already been used to put the given + * channel into the verified state). + * + * There is no guarantee that the verification codes returned by this method + * will be of a similar structure or form as the ones that are delivered + * to the channel via SendNotificationChannelVerificationCode; while + * VerifyNotificationChannel() will recognize both the codes delivered via + * SendNotificationChannelVerificationCode() and returned from + * GetNotificationChannelVerificationCode(), it is typically the case that + * the verification codes delivered via + * SendNotificationChannelVerificationCode() will be shorter and also + * have a shorter expiration (e.g. codes such as "G-123456") whereas + * GetVerificationCode() will typically return a much longer, websafe base + * 64 encoded string that has a longer expiration time. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The notification channel for which a verification code is to be generated + * and retrieved. This must name a channel that is already verified; if + * the specified channel is not verified, the request will fail. + * @param {google.protobuf.Timestamp} request.expireTime + * The desired expiration time. If specified, the API will guarantee that + * the returned code will not be valid after the specified timestamp; + * however, the API cannot guarantee that the returned code will be + * valid for at least as long as the requested time (the API puts an upper + * bound on the amount of time for which a code may be valid). If omitted, + * a default expiration will be used, which may be less than the max + * permissible expiration (so specifying an expiration may extend the + * code's lifetime over omitting an expiration, even though the API does + * impose an upper limit on the maximum expiration that is permitted). + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [GetNotificationChannelVerificationCodeResponse]{@link google.monitoring.v3.GetNotificationChannelVerificationCodeResponse}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ + getNotificationChannelVerificationCode( + request: protosTypes.google.monitoring.v3.IGetNotificationChannelVerificationCodeRequest, + optionsOrCallback?: gax.CallOptions|Callback< + protosTypes.google.monitoring.v3.IGetNotificationChannelVerificationCodeResponse, + protosTypes.google.monitoring.v3.IGetNotificationChannelVerificationCodeRequest|undefined, {}|undefined>, + callback?: Callback< + protosTypes.google.monitoring.v3.IGetNotificationChannelVerificationCodeResponse, + protosTypes.google.monitoring.v3.IGetNotificationChannelVerificationCodeRequest|undefined, + {}|undefined>): + Promise<[ + protosTypes.google.monitoring.v3.IGetNotificationChannelVerificationCodeResponse, + protosTypes.google.monitoring.v3.IGetNotificationChannelVerificationCodeRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as gax.CallOptions; + } + 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 || '', + }); + return this._innerApiCalls.getNotificationChannelVerificationCode(request, options, callback); + } + verifyNotificationChannel( + request: protosTypes.google.monitoring.v3.IVerifyNotificationChannelRequest, + options?: gax.CallOptions): + Promise<[ + protosTypes.google.monitoring.v3.INotificationChannel, + protosTypes.google.monitoring.v3.IVerifyNotificationChannelRequest|undefined, {}|undefined + ]>; + verifyNotificationChannel( + request: protosTypes.google.monitoring.v3.IVerifyNotificationChannelRequest, + options: gax.CallOptions, + callback: Callback< + protosTypes.google.monitoring.v3.INotificationChannel, + protosTypes.google.monitoring.v3.IVerifyNotificationChannelRequest|undefined, + {}|undefined>): void; +/** + * Verifies a `NotificationChannel` by proving receipt of the code + * delivered to the channel as a result of calling + * `SendNotificationChannelVerificationCode`. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The notification channel to verify. + * @param {string} request.code + * Required. The verification code that was delivered to the channel as + * a result of invoking the `SendNotificationChannelVerificationCode` API + * method or that was retrieved from a verified channel via + * `GetNotificationChannelVerificationCode`. For example, one might have + * "G-123456" or "TKNZGhhd2EyN3I1MnRnMjRv" (in general, one is only + * guaranteed that the code is valid UTF-8; one should not + * make any assumptions regarding the structure or format of the code). + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [NotificationChannel]{@link google.monitoring.v3.NotificationChannel}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ + verifyNotificationChannel( + request: protosTypes.google.monitoring.v3.IVerifyNotificationChannelRequest, + optionsOrCallback?: gax.CallOptions|Callback< + protosTypes.google.monitoring.v3.INotificationChannel, + protosTypes.google.monitoring.v3.IVerifyNotificationChannelRequest|undefined, {}|undefined>, + callback?: Callback< + protosTypes.google.monitoring.v3.INotificationChannel, + protosTypes.google.monitoring.v3.IVerifyNotificationChannelRequest|undefined, + {}|undefined>): + Promise<[ + protosTypes.google.monitoring.v3.INotificationChannel, + protosTypes.google.monitoring.v3.IVerifyNotificationChannelRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as gax.CallOptions; + } + 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 || '', + }); + return this._innerApiCalls.verifyNotificationChannel(request, options, callback); + } + + listNotificationChannelDescriptors( + request: protosTypes.google.monitoring.v3.IListNotificationChannelDescriptorsRequest, + options?: gax.CallOptions): + Promise<[ + protosTypes.google.monitoring.v3.INotificationChannelDescriptor[], + protosTypes.google.monitoring.v3.IListNotificationChannelDescriptorsRequest|null, + protosTypes.google.monitoring.v3.IListNotificationChannelDescriptorsResponse + ]>; + listNotificationChannelDescriptors( + request: protosTypes.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>): void; +/** + * Lists the descriptors for supported channel types. The use of descriptors + * makes it possible for new channel types to be dynamically added. + * + * @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] + * + * Note that this names the parent container in which to look for the + * descriptors; to retrieve a single descriptor by name, use the + * [GetNotificationChannelDescriptor][google.monitoring.v3.NotificationChannelService.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 {Promise} - The promise which resolves to an array. + * The first element of the array is Array of [NotificationChannelDescriptor]{@link google.monitoring.v3.NotificationChannelDescriptor}. + * The client library support auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * + * When autoPaginate: false is specified through options, the array has three elements. + * The first element is Array of [NotificationChannelDescriptor]{@link google.monitoring.v3.NotificationChannelDescriptor} that corresponds to + * the one page received from the API server. + * If the second element is not null it contains the request object of type [ListNotificationChannelDescriptorsRequest]{@link google.monitoring.v3.ListNotificationChannelDescriptorsRequest} + * that can be used to obtain the next page of the results. + * If it is null, the next page does not exist. + * The third element contains the raw response received from the API server. Its type is + * [ListNotificationChannelDescriptorsResponse]{@link google.monitoring.v3.ListNotificationChannelDescriptorsResponse}. + * + * The promise has a method named "cancel" which cancels the ongoing API call. + */ + listNotificationChannelDescriptors( + request: protosTypes.google.monitoring.v3.IListNotificationChannelDescriptorsRequest, + optionsOrCallback?: gax.CallOptions|Callback< + protosTypes.google.monitoring.v3.INotificationChannelDescriptor[], + protosTypes.google.monitoring.v3.IListNotificationChannelDescriptorsRequest|null, + protosTypes.google.monitoring.v3.IListNotificationChannelDescriptorsResponse>, + callback?: Callback< + protosTypes.google.monitoring.v3.INotificationChannelDescriptor[], + protosTypes.google.monitoring.v3.IListNotificationChannelDescriptorsRequest|null, + protosTypes.google.monitoring.v3.IListNotificationChannelDescriptorsResponse>): + Promise<[ + protosTypes.google.monitoring.v3.INotificationChannelDescriptor[], + protosTypes.google.monitoring.v3.IListNotificationChannelDescriptorsRequest|null, + protosTypes.google.monitoring.v3.IListNotificationChannelDescriptorsResponse + ]>|void { + request = request || {}; + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as gax.CallOptions; + } + 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 || '', + }); + return this._innerApiCalls.listNotificationChannelDescriptors(request, options, callback); + } + +/** + * Equivalent to {@link listNotificationChannelDescriptors}, but returns a NodeJS Stream object. + * + * This fetches the paged responses for {@link listNotificationChannelDescriptors} continuously + * and invokes the callback registered for 'data' event for each element in the + * responses. + * + * The returned object has 'end' method when no more elements are required. + * + * autoPaginate option will be ignored. + * + * @see {@link https://nodejs.org/api/stream.html} + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The REST resource name of the parent from which to retrieve + * the notification channel descriptors. The expected syntax is: + * + * projects/[PROJECT_ID] + * + * Note that this names the parent container in which to look for the + * descriptors; to retrieve a single descriptor by name, use the + * [GetNotificationChannelDescriptor][google.monitoring.v3.NotificationChannelService.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 {Stream} + * An object stream which emits an object representing [NotificationChannelDescriptor]{@link google.monitoring.v3.NotificationChannelDescriptor} on 'data' event. + */ + listNotificationChannelDescriptorsStream( + request?: protosTypes.google.monitoring.v3.IListNotificationChannelDescriptorsRequest, + options?: gax.CallOptions | {}): + Transform{ + request = request || {}; + const callSettings = new gax.CallSettings(options); + return this._descriptors.page.listNotificationChannelDescriptors.createStream( + this._innerApiCalls.listNotificationChannelDescriptors as gax.GaxCall, + request, + callSettings + ); + } + listNotificationChannels( + request: protosTypes.google.monitoring.v3.IListNotificationChannelsRequest, + options?: gax.CallOptions): + Promise<[ + protosTypes.google.monitoring.v3.INotificationChannel[], + protosTypes.google.monitoring.v3.IListNotificationChannelsRequest|null, + protosTypes.google.monitoring.v3.IListNotificationChannelsResponse + ]>; + listNotificationChannels( + request: protosTypes.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>): void; +/** + * Lists the notification channels that have been created for the project. + * + * @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]`. That is, 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 + * [`GetNotificationChannel`][google.monitoring.v3.NotificationChannelService.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](/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](/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 {Promise} - The promise which resolves to an array. + * The first element of the array is Array of [NotificationChannel]{@link google.monitoring.v3.NotificationChannel}. + * The client library support auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * + * When autoPaginate: false is specified through options, the array has three elements. + * The first element is Array of [NotificationChannel]{@link google.monitoring.v3.NotificationChannel} that corresponds to + * the one page received from the API server. + * If the second element is not null it contains the request object of type [ListNotificationChannelsRequest]{@link google.monitoring.v3.ListNotificationChannelsRequest} + * that can be used to obtain the next page of the results. + * If it is null, the next page does not exist. + * The third element contains the raw response received from the API server. Its type is + * [ListNotificationChannelsResponse]{@link google.monitoring.v3.ListNotificationChannelsResponse}. + * + * The promise has a method named "cancel" which cancels the ongoing API call. + */ + listNotificationChannels( + request: protosTypes.google.monitoring.v3.IListNotificationChannelsRequest, + optionsOrCallback?: gax.CallOptions|Callback< + protosTypes.google.monitoring.v3.INotificationChannel[], + protosTypes.google.monitoring.v3.IListNotificationChannelsRequest|null, + protosTypes.google.monitoring.v3.IListNotificationChannelsResponse>, + callback?: Callback< + protosTypes.google.monitoring.v3.INotificationChannel[], + protosTypes.google.monitoring.v3.IListNotificationChannelsRequest|null, + protosTypes.google.monitoring.v3.IListNotificationChannelsResponse>): + Promise<[ + protosTypes.google.monitoring.v3.INotificationChannel[], + protosTypes.google.monitoring.v3.IListNotificationChannelsRequest|null, + protosTypes.google.monitoring.v3.IListNotificationChannelsResponse + ]>|void { + request = request || {}; + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as gax.CallOptions; + } + 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 || '', + }); + return this._innerApiCalls.listNotificationChannels(request, options, callback); + } + +/** + * Equivalent to {@link listNotificationChannels}, but returns a NodeJS Stream object. + * + * This fetches the paged responses for {@link listNotificationChannels} continuously + * and invokes the callback registered for 'data' event for each element in the + * responses. + * + * The returned object has 'end' method when no more elements are required. + * + * autoPaginate option will be ignored. + * + * @see {@link https://nodejs.org/api/stream.html} + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The project on which to execute the request. The format is + * `projects/[PROJECT_ID]`. That is, 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 + * [`GetNotificationChannel`][google.monitoring.v3.NotificationChannelService.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](/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](/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 {Stream} + * An object stream which emits an object representing [NotificationChannel]{@link google.monitoring.v3.NotificationChannel} on 'data' event. + */ + listNotificationChannelsStream( + request?: protosTypes.google.monitoring.v3.IListNotificationChannelsRequest, + options?: gax.CallOptions | {}): + Transform{ + request = request || {}; + const callSettings = new gax.CallSettings(options); + return this._descriptors.page.listNotificationChannels.createStream( + this._innerApiCalls.listNotificationChannels as gax.GaxCall, + request, + callSettings + ); + } + // -------------------- + // -- Path templates -- + // -------------------- + + /** + * Return a fully-qualified projectAlertPolicy resource name string. + * + * @param {string} project + * @param {string} alert_policy + * @returns {string} Resource name string. + */ + projectAlertPolicyPath(project:string,alertPolicy:string) { + return this._pathTemplates.projectAlertPolicyPathTemplate.render({ + project: project, + alert_policy: alertPolicy, + }); + } + + /** + * Parse the project from ProjectAlertPolicy resource. + * + * @param {string} projectAlertPolicyName + * A fully-qualified path representing project_alert_policy resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectAlertPolicyName(projectAlertPolicyName: string) { + return this._pathTemplates.projectAlertPolicyPathTemplate.match(projectAlertPolicyName).project; + } + + /** + * Parse the alert_policy from ProjectAlertPolicy resource. + * + * @param {string} projectAlertPolicyName + * A fully-qualified path representing project_alert_policy resource. + * @returns {string} A string representing the alert_policy. + */ + matchAlertPolicyFromProjectAlertPolicyName(projectAlertPolicyName: string) { + return this._pathTemplates.projectAlertPolicyPathTemplate.match(projectAlertPolicyName).alert_policy; + } + + /** + * Return a fully-qualified organizationAlertPolicy resource name string. + * + * @param {string} organization + * @param {string} alert_policy + * @returns {string} Resource name string. + */ + organizationAlertPolicyPath(organization:string,alertPolicy:string) { + return this._pathTemplates.organizationAlertPolicyPathTemplate.render({ + organization: organization, + alert_policy: alertPolicy, + }); + } + + /** + * Parse the organization from OrganizationAlertPolicy resource. + * + * @param {string} organizationAlertPolicyName + * A fully-qualified path representing organization_alert_policy resource. + * @returns {string} A string representing the organization. + */ + matchOrganizationFromOrganizationAlertPolicyName(organizationAlertPolicyName: string) { + return this._pathTemplates.organizationAlertPolicyPathTemplate.match(organizationAlertPolicyName).organization; + } + + /** + * Parse the alert_policy from OrganizationAlertPolicy resource. + * + * @param {string} organizationAlertPolicyName + * A fully-qualified path representing organization_alert_policy resource. + * @returns {string} A string representing the alert_policy. + */ + matchAlertPolicyFromOrganizationAlertPolicyName(organizationAlertPolicyName: string) { + return this._pathTemplates.organizationAlertPolicyPathTemplate.match(organizationAlertPolicyName).alert_policy; + } + + /** + * Return a fully-qualified folderAlertPolicy resource name string. + * + * @param {string} folder + * @param {string} alert_policy + * @returns {string} Resource name string. + */ + folderAlertPolicyPath(folder:string,alertPolicy:string) { + return this._pathTemplates.folderAlertPolicyPathTemplate.render({ + folder: folder, + alert_policy: alertPolicy, + }); + } + + /** + * Parse the folder from FolderAlertPolicy resource. + * + * @param {string} folderAlertPolicyName + * A fully-qualified path representing folder_alert_policy resource. + * @returns {string} A string representing the folder. + */ + matchFolderFromFolderAlertPolicyName(folderAlertPolicyName: string) { + return this._pathTemplates.folderAlertPolicyPathTemplate.match(folderAlertPolicyName).folder; + } + + /** + * Parse the alert_policy from FolderAlertPolicy resource. + * + * @param {string} folderAlertPolicyName + * A fully-qualified path representing folder_alert_policy resource. + * @returns {string} A string representing the alert_policy. + */ + matchAlertPolicyFromFolderAlertPolicyName(folderAlertPolicyName: string) { + return this._pathTemplates.folderAlertPolicyPathTemplate.match(folderAlertPolicyName).alert_policy; + } + + /** + * Return a fully-qualified resource name string. + * + * @returns {string} Resource name string. + */ + Path() { + return this._pathTemplates.PathTemplate.render({ + }); + } + + /** + * Return a fully-qualified projectGroup resource name string. + * + * @param {string} project + * @param {string} group + * @returns {string} Resource name string. + */ + projectGroupPath(project:string,group:string) { + return this._pathTemplates.projectGroupPathTemplate.render({ + project: project, + group: group, + }); + } + + /** + * Parse the project from ProjectGroup resource. + * + * @param {string} projectGroupName + * A fully-qualified path representing project_group resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectGroupName(projectGroupName: string) { + return this._pathTemplates.projectGroupPathTemplate.match(projectGroupName).project; + } + + /** + * Parse the group from ProjectGroup resource. + * + * @param {string} projectGroupName + * A fully-qualified path representing project_group resource. + * @returns {string} A string representing the group. + */ + matchGroupFromProjectGroupName(projectGroupName: string) { + return this._pathTemplates.projectGroupPathTemplate.match(projectGroupName).group; + } + + /** + * Return a fully-qualified organizationGroup resource name string. + * + * @param {string} organization + * @param {string} group + * @returns {string} Resource name string. + */ + organizationGroupPath(organization:string,group:string) { + return this._pathTemplates.organizationGroupPathTemplate.render({ + organization: organization, + group: group, + }); + } + + /** + * Parse the organization from OrganizationGroup resource. + * + * @param {string} organizationGroupName + * A fully-qualified path representing organization_group resource. + * @returns {string} A string representing the organization. + */ + matchOrganizationFromOrganizationGroupName(organizationGroupName: string) { + return this._pathTemplates.organizationGroupPathTemplate.match(organizationGroupName).organization; + } + + /** + * Parse the group from OrganizationGroup resource. + * + * @param {string} organizationGroupName + * A fully-qualified path representing organization_group resource. + * @returns {string} A string representing the group. + */ + matchGroupFromOrganizationGroupName(organizationGroupName: string) { + return this._pathTemplates.organizationGroupPathTemplate.match(organizationGroupName).group; + } + + /** + * Return a fully-qualified folderGroup resource name string. + * + * @param {string} folder + * @param {string} group + * @returns {string} Resource name string. + */ + folderGroupPath(folder:string,group:string) { + return this._pathTemplates.folderGroupPathTemplate.render({ + folder: folder, + group: group, + }); + } + + /** + * Parse the folder from FolderGroup resource. + * + * @param {string} folderGroupName + * A fully-qualified path representing folder_group resource. + * @returns {string} A string representing the folder. + */ + matchFolderFromFolderGroupName(folderGroupName: string) { + return this._pathTemplates.folderGroupPathTemplate.match(folderGroupName).folder; + } + + /** + * Parse the group from FolderGroup resource. + * + * @param {string} folderGroupName + * A fully-qualified path representing folder_group resource. + * @returns {string} A string representing the group. + */ + matchGroupFromFolderGroupName(folderGroupName: string) { + return this._pathTemplates.folderGroupPathTemplate.match(folderGroupName).group; + } + + /** + * Return a fully-qualified projectChannelDescriptor resource name string. + * + * @param {string} project + * @param {string} channel_descriptor + * @returns {string} Resource name string. + */ + projectChannelDescriptorPath(project:string,channelDescriptor:string) { + return this._pathTemplates.projectChannelDescriptorPathTemplate.render({ + project: project, + channel_descriptor: channelDescriptor, + }); + } + + /** + * Parse the project from ProjectChannelDescriptor resource. + * + * @param {string} projectChannelDescriptorName + * A fully-qualified path representing project_channel_descriptor resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectChannelDescriptorName(projectChannelDescriptorName: string) { + return this._pathTemplates.projectChannelDescriptorPathTemplate.match(projectChannelDescriptorName).project; + } + + /** + * Parse the channel_descriptor from ProjectChannelDescriptor resource. + * + * @param {string} projectChannelDescriptorName + * A fully-qualified path representing project_channel_descriptor resource. + * @returns {string} A string representing the channel_descriptor. + */ + matchChannelDescriptorFromProjectChannelDescriptorName(projectChannelDescriptorName: string) { + return this._pathTemplates.projectChannelDescriptorPathTemplate.match(projectChannelDescriptorName).channel_descriptor; + } + + /** + * Return a fully-qualified organizationChannelDescriptor resource name string. + * + * @param {string} organization + * @param {string} channel_descriptor + * @returns {string} Resource name string. + */ + organizationChannelDescriptorPath(organization:string,channelDescriptor:string) { + return this._pathTemplates.organizationChannelDescriptorPathTemplate.render({ + organization: organization, + channel_descriptor: channelDescriptor, + }); + } + + /** + * Parse the organization from OrganizationChannelDescriptor resource. + * + * @param {string} organizationChannelDescriptorName + * A fully-qualified path representing organization_channel_descriptor resource. + * @returns {string} A string representing the organization. + */ + matchOrganizationFromOrganizationChannelDescriptorName(organizationChannelDescriptorName: string) { + return this._pathTemplates.organizationChannelDescriptorPathTemplate.match(organizationChannelDescriptorName).organization; + } + + /** + * Parse the channel_descriptor from OrganizationChannelDescriptor resource. + * + * @param {string} organizationChannelDescriptorName + * A fully-qualified path representing organization_channel_descriptor resource. + * @returns {string} A string representing the channel_descriptor. + */ + matchChannelDescriptorFromOrganizationChannelDescriptorName(organizationChannelDescriptorName: string) { + return this._pathTemplates.organizationChannelDescriptorPathTemplate.match(organizationChannelDescriptorName).channel_descriptor; + } + + /** + * Return a fully-qualified folderChannelDescriptor resource name string. + * + * @param {string} folder + * @param {string} channel_descriptor + * @returns {string} Resource name string. + */ + folderChannelDescriptorPath(folder:string,channelDescriptor:string) { + return this._pathTemplates.folderChannelDescriptorPathTemplate.render({ + folder: folder, + channel_descriptor: channelDescriptor, + }); + } + + /** + * Parse the folder from FolderChannelDescriptor resource. + * + * @param {string} folderChannelDescriptorName + * A fully-qualified path representing folder_channel_descriptor resource. + * @returns {string} A string representing the folder. + */ + matchFolderFromFolderChannelDescriptorName(folderChannelDescriptorName: string) { + return this._pathTemplates.folderChannelDescriptorPathTemplate.match(folderChannelDescriptorName).folder; + } + + /** + * Parse the channel_descriptor from FolderChannelDescriptor resource. + * + * @param {string} folderChannelDescriptorName + * A fully-qualified path representing folder_channel_descriptor resource. + * @returns {string} A string representing the channel_descriptor. + */ + matchChannelDescriptorFromFolderChannelDescriptorName(folderChannelDescriptorName: string) { + return this._pathTemplates.folderChannelDescriptorPathTemplate.match(folderChannelDescriptorName).channel_descriptor; + } + + /** + * Return a fully-qualified projectNotificationChannel resource name string. + * + * @param {string} project + * @param {string} notification_channel + * @returns {string} Resource name string. + */ + projectNotificationChannelPath(project:string,notificationChannel:string) { + return this._pathTemplates.projectNotificationChannelPathTemplate.render({ + project: project, + notification_channel: notificationChannel, + }); + } + + /** + * Parse the project from ProjectNotificationChannel resource. + * + * @param {string} projectNotificationChannelName + * A fully-qualified path representing project_notification_channel resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectNotificationChannelName(projectNotificationChannelName: string) { + return this._pathTemplates.projectNotificationChannelPathTemplate.match(projectNotificationChannelName).project; + } + + /** + * Parse the notification_channel from ProjectNotificationChannel resource. + * + * @param {string} projectNotificationChannelName + * A fully-qualified path representing project_notification_channel resource. + * @returns {string} A string representing the notification_channel. + */ + matchNotificationChannelFromProjectNotificationChannelName(projectNotificationChannelName: string) { + return this._pathTemplates.projectNotificationChannelPathTemplate.match(projectNotificationChannelName).notification_channel; + } + + /** + * Return a fully-qualified organizationNotificationChannel resource name string. + * + * @param {string} organization + * @param {string} notification_channel + * @returns {string} Resource name string. + */ + organizationNotificationChannelPath(organization:string,notificationChannel:string) { + return this._pathTemplates.organizationNotificationChannelPathTemplate.render({ + organization: organization, + notification_channel: notificationChannel, + }); + } + + /** + * Parse the organization from OrganizationNotificationChannel resource. + * + * @param {string} organizationNotificationChannelName + * A fully-qualified path representing organization_notification_channel resource. + * @returns {string} A string representing the organization. + */ + matchOrganizationFromOrganizationNotificationChannelName(organizationNotificationChannelName: string) { + return this._pathTemplates.organizationNotificationChannelPathTemplate.match(organizationNotificationChannelName).organization; + } + + /** + * Parse the notification_channel from OrganizationNotificationChannel resource. + * + * @param {string} organizationNotificationChannelName + * A fully-qualified path representing organization_notification_channel resource. + * @returns {string} A string representing the notification_channel. + */ + matchNotificationChannelFromOrganizationNotificationChannelName(organizationNotificationChannelName: string) { + return this._pathTemplates.organizationNotificationChannelPathTemplate.match(organizationNotificationChannelName).notification_channel; + } + + /** + * Return a fully-qualified folderNotificationChannel resource name string. + * + * @param {string} folder + * @param {string} notification_channel + * @returns {string} Resource name string. + */ + folderNotificationChannelPath(folder:string,notificationChannel:string) { + return this._pathTemplates.folderNotificationChannelPathTemplate.render({ + folder: folder, + notification_channel: notificationChannel, + }); + } + + /** + * Parse the folder from FolderNotificationChannel resource. + * + * @param {string} folderNotificationChannelName + * A fully-qualified path representing folder_notification_channel resource. + * @returns {string} A string representing the folder. + */ + matchFolderFromFolderNotificationChannelName(folderNotificationChannelName: string) { + return this._pathTemplates.folderNotificationChannelPathTemplate.match(folderNotificationChannelName).folder; + } + + /** + * Parse the notification_channel from FolderNotificationChannel resource. + * + * @param {string} folderNotificationChannelName + * A fully-qualified path representing folder_notification_channel resource. + * @returns {string} A string representing the notification_channel. + */ + matchNotificationChannelFromFolderNotificationChannelName(folderNotificationChannelName: string) { + return this._pathTemplates.folderNotificationChannelPathTemplate.match(folderNotificationChannelName).notification_channel; + } + + /** + * Return a fully-qualified projectService resource name string. + * + * @param {string} project + * @param {string} service + * @returns {string} Resource name string. + */ + projectServicePath(project:string,service:string) { + return this._pathTemplates.projectServicePathTemplate.render({ + project: project, + service: service, + }); + } + + /** + * Parse the project from ProjectService resource. + * + * @param {string} projectServiceName + * A fully-qualified path representing project_service resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectServiceName(projectServiceName: string) { + return this._pathTemplates.projectServicePathTemplate.match(projectServiceName).project; + } + + /** + * Parse the service from ProjectService resource. + * + * @param {string} projectServiceName + * A fully-qualified path representing project_service resource. + * @returns {string} A string representing the service. + */ + matchServiceFromProjectServiceName(projectServiceName: string) { + return this._pathTemplates.projectServicePathTemplate.match(projectServiceName).service; + } + + /** + * Return a fully-qualified organizationService resource name string. + * + * @param {string} organization + * @param {string} service + * @returns {string} Resource name string. + */ + organizationServicePath(organization:string,service:string) { + return this._pathTemplates.organizationServicePathTemplate.render({ + organization: organization, + service: service, + }); + } + + /** + * Parse the organization from OrganizationService resource. + * + * @param {string} organizationServiceName + * A fully-qualified path representing organization_service resource. + * @returns {string} A string representing the organization. + */ + matchOrganizationFromOrganizationServiceName(organizationServiceName: string) { + return this._pathTemplates.organizationServicePathTemplate.match(organizationServiceName).organization; + } + + /** + * Parse the service from OrganizationService resource. + * + * @param {string} organizationServiceName + * A fully-qualified path representing organization_service resource. + * @returns {string} A string representing the service. + */ + matchServiceFromOrganizationServiceName(organizationServiceName: string) { + return this._pathTemplates.organizationServicePathTemplate.match(organizationServiceName).service; + } + + /** + * Return a fully-qualified folderService resource name string. + * + * @param {string} folder + * @param {string} service + * @returns {string} Resource name string. + */ + folderServicePath(folder:string,service:string) { + return this._pathTemplates.folderServicePathTemplate.render({ + folder: folder, + service: service, + }); + } + + /** + * Parse the folder from FolderService resource. + * + * @param {string} folderServiceName + * A fully-qualified path representing folder_service resource. + * @returns {string} A string representing the folder. + */ + matchFolderFromFolderServiceName(folderServiceName: string) { + return this._pathTemplates.folderServicePathTemplate.match(folderServiceName).folder; + } + + /** + * Parse the service from FolderService resource. + * + * @param {string} folderServiceName + * A fully-qualified path representing folder_service resource. + * @returns {string} A string representing the service. + */ + matchServiceFromFolderServiceName(folderServiceName: string) { + return this._pathTemplates.folderServicePathTemplate.match(folderServiceName).service; + } + + /** + * Return a fully-qualified projectServiceServiceLevelObjective resource name string. + * + * @param {string} project + * @param {string} service + * @param {string} service_level_objective + * @returns {string} Resource name string. + */ + projectServiceServiceLevelObjectivePath(project:string,service:string,serviceLevelObjective:string) { + return this._pathTemplates.projectServiceServiceLevelObjectivePathTemplate.render({ + project: project, + service: service, + service_level_objective: serviceLevelObjective, + }); + } + + /** + * Parse the project from ProjectServiceServiceLevelObjective resource. + * + * @param {string} projectServiceServiceLevelObjectiveName + * A fully-qualified path representing project_service_service_level_objective resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectServiceServiceLevelObjectiveName(projectServiceServiceLevelObjectiveName: string) { + return this._pathTemplates.projectServiceServiceLevelObjectivePathTemplate.match(projectServiceServiceLevelObjectiveName).project; + } + + /** + * Parse the service from ProjectServiceServiceLevelObjective resource. + * + * @param {string} projectServiceServiceLevelObjectiveName + * A fully-qualified path representing project_service_service_level_objective resource. + * @returns {string} A string representing the service. + */ + matchServiceFromProjectServiceServiceLevelObjectiveName(projectServiceServiceLevelObjectiveName: string) { + return this._pathTemplates.projectServiceServiceLevelObjectivePathTemplate.match(projectServiceServiceLevelObjectiveName).service; + } + + /** + * Parse the service_level_objective from ProjectServiceServiceLevelObjective resource. + * + * @param {string} projectServiceServiceLevelObjectiveName + * A fully-qualified path representing project_service_service_level_objective resource. + * @returns {string} A string representing the service_level_objective. + */ + matchServiceLevelObjectiveFromProjectServiceServiceLevelObjectiveName(projectServiceServiceLevelObjectiveName: string) { + return this._pathTemplates.projectServiceServiceLevelObjectivePathTemplate.match(projectServiceServiceLevelObjectiveName).service_level_objective; + } + + /** + * Return a fully-qualified organizationServiceServiceLevelObjective resource name string. + * + * @param {string} organization + * @param {string} service + * @param {string} service_level_objective + * @returns {string} Resource name string. + */ + organizationServiceServiceLevelObjectivePath(organization:string,service:string,serviceLevelObjective:string) { + return this._pathTemplates.organizationServiceServiceLevelObjectivePathTemplate.render({ + organization: organization, + service: service, + service_level_objective: serviceLevelObjective, + }); + } + + /** + * Parse the organization from OrganizationServiceServiceLevelObjective resource. + * + * @param {string} organizationServiceServiceLevelObjectiveName + * A fully-qualified path representing organization_service_service_level_objective resource. + * @returns {string} A string representing the organization. + */ + matchOrganizationFromOrganizationServiceServiceLevelObjectiveName(organizationServiceServiceLevelObjectiveName: string) { + return this._pathTemplates.organizationServiceServiceLevelObjectivePathTemplate.match(organizationServiceServiceLevelObjectiveName).organization; + } + + /** + * Parse the service from OrganizationServiceServiceLevelObjective resource. + * + * @param {string} organizationServiceServiceLevelObjectiveName + * A fully-qualified path representing organization_service_service_level_objective resource. + * @returns {string} A string representing the service. + */ + matchServiceFromOrganizationServiceServiceLevelObjectiveName(organizationServiceServiceLevelObjectiveName: string) { + return this._pathTemplates.organizationServiceServiceLevelObjectivePathTemplate.match(organizationServiceServiceLevelObjectiveName).service; + } + + /** + * Parse the service_level_objective from OrganizationServiceServiceLevelObjective resource. + * + * @param {string} organizationServiceServiceLevelObjectiveName + * A fully-qualified path representing organization_service_service_level_objective resource. + * @returns {string} A string representing the service_level_objective. + */ + matchServiceLevelObjectiveFromOrganizationServiceServiceLevelObjectiveName(organizationServiceServiceLevelObjectiveName: string) { + return this._pathTemplates.organizationServiceServiceLevelObjectivePathTemplate.match(organizationServiceServiceLevelObjectiveName).service_level_objective; + } + + /** + * Return a fully-qualified folderServiceServiceLevelObjective resource name string. + * + * @param {string} folder + * @param {string} service + * @param {string} service_level_objective + * @returns {string} Resource name string. + */ + folderServiceServiceLevelObjectivePath(folder:string,service:string,serviceLevelObjective:string) { + return this._pathTemplates.folderServiceServiceLevelObjectivePathTemplate.render({ + folder: folder, + service: service, + service_level_objective: serviceLevelObjective, + }); + } + + /** + * Parse the folder from FolderServiceServiceLevelObjective resource. + * + * @param {string} folderServiceServiceLevelObjectiveName + * A fully-qualified path representing folder_service_service_level_objective resource. + * @returns {string} A string representing the folder. + */ + matchFolderFromFolderServiceServiceLevelObjectiveName(folderServiceServiceLevelObjectiveName: string) { + return this._pathTemplates.folderServiceServiceLevelObjectivePathTemplate.match(folderServiceServiceLevelObjectiveName).folder; + } + + /** + * Parse the service from FolderServiceServiceLevelObjective resource. + * + * @param {string} folderServiceServiceLevelObjectiveName + * A fully-qualified path representing folder_service_service_level_objective resource. + * @returns {string} A string representing the service. + */ + matchServiceFromFolderServiceServiceLevelObjectiveName(folderServiceServiceLevelObjectiveName: string) { + return this._pathTemplates.folderServiceServiceLevelObjectivePathTemplate.match(folderServiceServiceLevelObjectiveName).service; + } + + /** + * Parse the service_level_objective from FolderServiceServiceLevelObjective resource. + * + * @param {string} folderServiceServiceLevelObjectiveName + * A fully-qualified path representing folder_service_service_level_objective resource. + * @returns {string} A string representing the service_level_objective. + */ + matchServiceLevelObjectiveFromFolderServiceServiceLevelObjectiveName(folderServiceServiceLevelObjectiveName: string) { + return this._pathTemplates.folderServiceServiceLevelObjectivePathTemplate.match(folderServiceServiceLevelObjectiveName).service_level_objective; + } + + /** + * Return a fully-qualified projectUptimeCheckConfig resource name string. + * + * @param {string} project + * @param {string} uptime_check_config + * @returns {string} Resource name string. + */ + projectUptimeCheckConfigPath(project:string,uptimeCheckConfig:string) { + return this._pathTemplates.projectUptimeCheckConfigPathTemplate.render({ + project: project, + uptime_check_config: uptimeCheckConfig, + }); + } + + /** + * Parse the project from ProjectUptimeCheckConfig resource. + * + * @param {string} projectUptimeCheckConfigName + * A fully-qualified path representing project_uptime_check_config resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectUptimeCheckConfigName(projectUptimeCheckConfigName: string) { + return this._pathTemplates.projectUptimeCheckConfigPathTemplate.match(projectUptimeCheckConfigName).project; + } + + /** + * Parse the uptime_check_config from ProjectUptimeCheckConfig resource. + * + * @param {string} projectUptimeCheckConfigName + * A fully-qualified path representing project_uptime_check_config resource. + * @returns {string} A string representing the uptime_check_config. + */ + matchUptimeCheckConfigFromProjectUptimeCheckConfigName(projectUptimeCheckConfigName: string) { + return this._pathTemplates.projectUptimeCheckConfigPathTemplate.match(projectUptimeCheckConfigName).uptime_check_config; + } + + /** + * Return a fully-qualified organizationUptimeCheckConfig resource name string. + * + * @param {string} organization + * @param {string} uptime_check_config + * @returns {string} Resource name string. + */ + organizationUptimeCheckConfigPath(organization:string,uptimeCheckConfig:string) { + return this._pathTemplates.organizationUptimeCheckConfigPathTemplate.render({ + organization: organization, + uptime_check_config: uptimeCheckConfig, + }); + } + + /** + * Parse the organization from OrganizationUptimeCheckConfig resource. + * + * @param {string} organizationUptimeCheckConfigName + * A fully-qualified path representing organization_uptime_check_config resource. + * @returns {string} A string representing the organization. + */ + matchOrganizationFromOrganizationUptimeCheckConfigName(organizationUptimeCheckConfigName: string) { + return this._pathTemplates.organizationUptimeCheckConfigPathTemplate.match(organizationUptimeCheckConfigName).organization; + } + + /** + * Parse the uptime_check_config from OrganizationUptimeCheckConfig resource. + * + * @param {string} organizationUptimeCheckConfigName + * A fully-qualified path representing organization_uptime_check_config resource. + * @returns {string} A string representing the uptime_check_config. + */ + matchUptimeCheckConfigFromOrganizationUptimeCheckConfigName(organizationUptimeCheckConfigName: string) { + return this._pathTemplates.organizationUptimeCheckConfigPathTemplate.match(organizationUptimeCheckConfigName).uptime_check_config; + } + + /** + * Return a fully-qualified folderUptimeCheckConfig resource name string. + * + * @param {string} folder + * @param {string} uptime_check_config + * @returns {string} Resource name string. + */ + folderUptimeCheckConfigPath(folder:string,uptimeCheckConfig:string) { + return this._pathTemplates.folderUptimeCheckConfigPathTemplate.render({ + folder: folder, + uptime_check_config: uptimeCheckConfig, + }); + } + + /** + * Parse the folder from FolderUptimeCheckConfig resource. + * + * @param {string} folderUptimeCheckConfigName + * A fully-qualified path representing folder_uptime_check_config resource. + * @returns {string} A string representing the folder. + */ + matchFolderFromFolderUptimeCheckConfigName(folderUptimeCheckConfigName: string) { + return this._pathTemplates.folderUptimeCheckConfigPathTemplate.match(folderUptimeCheckConfigName).folder; + } + + /** + * Parse the uptime_check_config from FolderUptimeCheckConfig resource. + * + * @param {string} folderUptimeCheckConfigName + * A fully-qualified path representing folder_uptime_check_config resource. + * @returns {string} A string representing the uptime_check_config. + */ + matchUptimeCheckConfigFromFolderUptimeCheckConfigName(folderUptimeCheckConfigName: string) { + return this._pathTemplates.folderUptimeCheckConfigPathTemplate.match(folderUptimeCheckConfigName).uptime_check_config; + } + + /** + * Terminate the GRPC channel and close the client. + * + * The client will no longer be usable and all future behavior is undefined. + */ + close(): Promise { + if (!this._terminated) { + return this.notificationChannelServiceStub.then(stub => { + this._terminated = true; + stub.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/typescript/test/testdata/monitoring/src/v3/notification_channel_service_client_config.json.baseline b/typescript/test/testdata/monitoring/src/v3/notification_channel_service_client_config.json.baseline new file mode 100644 index 000000000..781b3f0a6 --- /dev/null +++ b/typescript/test/testdata/monitoring/src/v3/notification_channel_service_client_config.json.baseline @@ -0,0 +1,66 @@ +{ + "interfaces": { + "google.monitoring.v3.NotificationChannelService": { + "retry_codes": { + "non_idempotent": [], + "idempotent": [ + "DEADLINE_EXCEEDED", + "UNAVAILABLE" + ] + }, + "retry_params": { + "default": { + "initial_retry_delay_millis": 100, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 60000, + "initial_rpc_timeout_millis": 60000, + "rpc_timeout_multiplier": 1, + "max_rpc_timeout_millis": 60000, + "total_timeout_millis": 600000 + } + }, + "methods": { + "ListNotificationChannelDescriptors": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "GetNotificationChannelDescriptor": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "ListNotificationChannels": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "GetNotificationChannel": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "CreateNotificationChannel": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "UpdateNotificationChannel": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "DeleteNotificationChannel": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "SendNotificationChannelVerificationCode": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "GetNotificationChannelVerificationCode": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "VerifyNotificationChannel": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/typescript/test/testdata/monitoring/src/v3/notification_channel_service_proto_list.json.baseline b/typescript/test/testdata/monitoring/src/v3/notification_channel_service_proto_list.json.baseline new file mode 100644 index 000000000..aacceb22f --- /dev/null +++ b/typescript/test/testdata/monitoring/src/v3/notification_channel_service_proto_list.json.baseline @@ -0,0 +1,16 @@ +[ + "../../protos/google/monitoring/v3/alert.proto", + "../../protos/google/monitoring/v3/alert_service.proto", + "../../protos/google/monitoring/v3/common.proto", + "../../protos/google/monitoring/v3/group.proto", + "../../protos/google/monitoring/v3/group_service.proto", + "../../protos/google/monitoring/v3/metric.proto", + "../../protos/google/monitoring/v3/metric_service.proto", + "../../protos/google/monitoring/v3/mutation_record.proto", + "../../protos/google/monitoring/v3/notification.proto", + "../../protos/google/monitoring/v3/notification_service.proto", + "../../protos/google/monitoring/v3/service.proto", + "../../protos/google/monitoring/v3/service_service.proto", + "../../protos/google/monitoring/v3/uptime.proto", + "../../protos/google/monitoring/v3/uptime_service.proto" +] diff --git a/typescript/test/testdata/monitoring/src/v3/service_monitoring_service_client.ts.baseline b/typescript/test/testdata/monitoring/src/v3/service_monitoring_service_client.ts.baseline new file mode 100644 index 000000000..7d3e91679 --- /dev/null +++ b/typescript/test/testdata/monitoring/src/v3/service_monitoring_service_client.ts.baseline @@ -0,0 +1,1946 @@ +// 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 gax from 'google-gax'; +import {APICallback, Callback, CallOptions, Descriptors, ClientOptions, PaginationCallback, PaginationResponse} from 'google-gax'; +import * as path from 'path'; + +import { Transform } from 'stream'; +import * as protosTypes from '../../protos/protos'; +import * as gapicConfig from './service_monitoring_service_client_config.json'; + +const version = require('../../../package.json').version; + +/** + * The Stackdriver Monitoring Service-Oriented Monitoring API has endpoints for + * managing and querying aspects of a workspace's services. These include the + * `Service`'s monitored resources, its Service-Level Objectives, and a taxonomy + * of categorized Health Metrics. + * @class + * @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; + auth: gax.GoogleAuth; + serviceMonitoringServiceStub: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of ServiceMonitoringServiceClient. + * + * @param {object} [options] - The configuration object. See the subsequent + * parameters for more details. + * @param {object} [options.credentials] - Credentials object. + * @param {string} [options.credentials.client_email] + * @param {string} [options.credentials.private_key] + * @param {string} [options.email] - Account email address. Required when + * using a .pem or .p12 keyFilename. + * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or + * .p12 key downloaded from the Google Developers Console. If you provide + * a path to a JSON file, the projectId option below is not necessary. + * NOTE: .pem and .p12 require you to specify options.email as well. + * @param {number} [options.port] - The port on which to connect to + * the remote host. + * @param {string} [options.projectId] - The project ID from the Google + * Developer's Console, e.g. 'grape-spaceship-123'. We will also check + * the environment variable GCLOUD_PROJECT for your project ID. If your + * app is running in an environment which supports + * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, + * your project ID will be detected automatically. + * @param {function} [options.promise] - Custom promise module to use instead + * of native Promises. + * @param {string} [options.apiEndpoint] - The domain name of the + * API remote host. + */ + + constructor(opts?: ClientOptions) { + // Ensure that options include the service address and port. + const staticMembers = this.constructor as typeof ServiceMonitoringServiceClient; + const servicePath = opts && opts.servicePath ? + opts.servicePath : + ((opts && opts.apiEndpoint) ? opts.apiEndpoint : + staticMembers.servicePath); + const port = opts && opts.port ? opts.port : staticMembers.port; + + if (!opts) { + opts = {servicePath, port}; + } + opts.servicePath = opts.servicePath || servicePath; + opts.port = opts.port || port; + opts.clientConfig = opts.clientConfig || {}; + + const isBrowser = (typeof window !== 'undefined'); + if (isBrowser){ + opts.fallback = true; + } + // If we are in browser, we are already using fallback because of the + // "browser" field in package.json. + // But if we were explicitly requested to use fallback, let's do it now. + const gaxModule = !isBrowser && opts.fallback ? gax.fallback : gax; + + // Create a `gaxGrpc` object, with any grpc-specific options + // sent to the client. + opts.scopes = (this.constructor as typeof ServiceMonitoringServiceClient).scopes; + const gaxGrpc = new gaxModule.GrpcClient(opts); + + // Save the auth object to the client, for use by other methods. + this.auth = (gaxGrpc.auth as gax.GoogleAuth); + + // Determine the client header string. + const clientHeader = [ + `gax/${gaxModule.version}`, + `gapic/${version}`, + ]; + if (typeof process !== 'undefined' && 'versions' in process) { + clientHeader.push(`gl-node/${process.versions.node}`); + } else { + clientHeader.push(`gl-web/${gaxModule.version}`); + } + if (!opts.fallback) { + clientHeader.push(`grpc/${gaxGrpc.grpcVersion}`); + } + if (opts.libName && opts.libVersion) { + clientHeader.push(`${opts.libName}/${opts.libVersion}`); + } + // Load the applicable protos. + // For Node.js, pass the path to JSON proto file. + // For browsers, pass the JSON content. + + const nodejsProtoPath = path.join(__dirname, '..', '..', 'protos', 'protos.json'); + const protos = gaxGrpc.loadProto( + opts.fallback ? + 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 = { + projectAlertPolicyPathTemplate: new gaxModule.PathTemplate( + 'projects/{project}/alertPolicies/{alert_policy}' + ), + organizationAlertPolicyPathTemplate: new gaxModule.PathTemplate( + 'organizations/{organization}/alertPolicies/{alert_policy}' + ), + folderAlertPolicyPathTemplate: new gaxModule.PathTemplate( + 'folders/{folder}/alertPolicies/{alert_policy}' + ), + PathTemplate: new gaxModule.PathTemplate( + '*' + ), + projectGroupPathTemplate: new gaxModule.PathTemplate( + 'projects/{project}/groups/{group}' + ), + organizationGroupPathTemplate: new gaxModule.PathTemplate( + 'organizations/{organization}/groups/{group}' + ), + folderGroupPathTemplate: new gaxModule.PathTemplate( + 'folders/{folder}/groups/{group}' + ), + projectChannelDescriptorPathTemplate: new gaxModule.PathTemplate( + 'projects/{project}/notificationChannelDescriptors/{channel_descriptor}' + ), + organizationChannelDescriptorPathTemplate: new gaxModule.PathTemplate( + 'organizations/{organization}/notificationChannelDescriptors/{channel_descriptor}' + ), + folderChannelDescriptorPathTemplate: new gaxModule.PathTemplate( + 'folders/{folder}/notificationChannelDescriptors/{channel_descriptor}' + ), + projectNotificationChannelPathTemplate: new gaxModule.PathTemplate( + 'projects/{project}/notificationChannels/{notification_channel}' + ), + organizationNotificationChannelPathTemplate: new gaxModule.PathTemplate( + 'organizations/{organization}/notificationChannels/{notification_channel}' + ), + folderNotificationChannelPathTemplate: new gaxModule.PathTemplate( + 'folders/{folder}/notificationChannels/{notification_channel}' + ), + projectServicePathTemplate: new gaxModule.PathTemplate( + 'projects/{project}/services/{service}' + ), + organizationServicePathTemplate: new gaxModule.PathTemplate( + 'organizations/{organization}/services/{service}' + ), + folderServicePathTemplate: new gaxModule.PathTemplate( + 'folders/{folder}/services/{service}' + ), + projectServiceServiceLevelObjectivePathTemplate: new gaxModule.PathTemplate( + 'projects/{project}/services/{service}/serviceLevelObjectives/{service_level_objective}' + ), + organizationServiceServiceLevelObjectivePathTemplate: new gaxModule.PathTemplate( + 'organizations/{organization}/services/{service}/serviceLevelObjectives/{service_level_objective}' + ), + folderServiceServiceLevelObjectivePathTemplate: new gaxModule.PathTemplate( + 'folders/{folder}/services/{service}/serviceLevelObjectives/{service_level_objective}' + ), + projectUptimeCheckConfigPathTemplate: new gaxModule.PathTemplate( + 'projects/{project}/uptimeCheckConfigs/{uptime_check_config}' + ), + organizationUptimeCheckConfigPathTemplate: new gaxModule.PathTemplate( + 'organizations/{organization}/uptimeCheckConfigs/{uptime_check_config}' + ), + folderUptimeCheckConfigPathTemplate: new gaxModule.PathTemplate( + 'folders/{folder}/uptimeCheckConfigs/{uptime_check_config}' + ), + }; + + // 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 = { + listServices: + new gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'services'), + listServiceLevelObjectives: + new gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'serviceLevelObjectives') + }; + + // Put together the default options sent with requests. + const defaults = gaxGrpc.constructSettings( + 'google.monitoring.v3.ServiceMonitoringService', gapicConfig as gax.ClientConfig, + opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + + // Set up a dictionary of "inner API calls"; the core implementation + // of calling the API is handled in `google-gax`, with this code + // merely providing the destination and request information. + this._innerApiCalls = {}; + + // Put together the "service stub" for + // google.monitoring.v3.ServiceMonitoringService. + this.serviceMonitoringServiceStub = gaxGrpc.createStub( + opts.fallback ? + (protos as protobuf.Root).lookupService('google.monitoring.v3.ServiceMonitoringService') : + // tslint:disable-next-line no-any + (protos as any).google.monitoring.v3.ServiceMonitoringService, + opts) as Promise<{[method: string]: Function}>; + + // Iterate over each of the methods that the service provides + // and create an API call method for each. + const serviceMonitoringServiceStubMethods = + ['createService', 'getService', 'listServices', 'updateService', 'deleteService', 'createServiceLevelObjective', 'getServiceLevelObjective', 'listServiceLevelObjectives', 'updateServiceLevelObjective', 'deleteServiceLevelObjective']; + + for (const methodName of serviceMonitoringServiceStubMethods) { + const innerCallPromise = this.serviceMonitoringServiceStub.then( + stub => (...args: Array<{}>) => { + if (this._terminated) { + return Promise.reject('The client has already been closed.'); + } + return stub[methodName].apply(stub, args); + }, + (err: Error|null|undefined) => () => { + throw err; + }); + + const apiCall = gaxModule.createApiCall( + innerCallPromise, + defaults[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); + }; + } + } + + /** + * The DNS address for this API service. + */ + static get servicePath() { + return 'monitoring.googleapis.com'; + } + + /** + * The DNS address for this API service - same as servicePath(), + * exists for compatibility reasons. + */ + static get apiEndpoint() { + return 'monitoring.googleapis.com'; + } + + /** + * The port for this API service. + */ + static get port() { + return 443; + } + + /** + * The scopes needed to make gRPC calls for every method defined + * in this service. + */ + static get scopes() { + return [ + 'https://www.googleapis.com/auth/cloud-platform', + 'https://www.googleapis.com/auth/monitoring', + 'https://www.googleapis.com/auth/monitoring.read' + ]; + } + + getProjectId(): Promise; + getProjectId(callback: Callback): void; + /** + * Return the project ID used by this class. + * @param {function(Error, string)} callback - the callback to + * be called with the current project Id. + */ + getProjectId(callback?: Callback): + Promise|void { + if (callback) { + this.auth.getProjectId(callback); + return; + } + return this.auth.getProjectId(); + } + + // ------------------- + // -- Service calls -- + // ------------------- + createService( + request: protosTypes.google.monitoring.v3.ICreateServiceRequest, + options?: gax.CallOptions): + Promise<[ + protosTypes.google.monitoring.v3.IService, + protosTypes.google.monitoring.v3.ICreateServiceRequest|undefined, {}|undefined + ]>; + createService( + request: protosTypes.google.monitoring.v3.ICreateServiceRequest, + options: gax.CallOptions, + callback: Callback< + protosTypes.google.monitoring.v3.IService, + protosTypes.google.monitoring.v3.ICreateServiceRequest|undefined, + {}|undefined>): void; +/** + * Create a `Service`. + * + * @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.serviceId + * Optional. The Service id to use for this Service. If omitted, an id will be + * generated instead. Must match the pattern [a-z0-9\-]+ + * @param {google.monitoring.v3.Service} request.service + * Required. The `Service` to create. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Service]{@link google.monitoring.v3.Service}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ + createService( + request: protosTypes.google.monitoring.v3.ICreateServiceRequest, + optionsOrCallback?: gax.CallOptions|Callback< + protosTypes.google.monitoring.v3.IService, + protosTypes.google.monitoring.v3.ICreateServiceRequest|undefined, {}|undefined>, + callback?: Callback< + protosTypes.google.monitoring.v3.IService, + protosTypes.google.monitoring.v3.ICreateServiceRequest|undefined, + {}|undefined>): + Promise<[ + protosTypes.google.monitoring.v3.IService, + protosTypes.google.monitoring.v3.ICreateServiceRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as gax.CallOptions; + } + 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 || '', + }); + return this._innerApiCalls.createService(request, options, callback); + } + getService( + request: protosTypes.google.monitoring.v3.IGetServiceRequest, + options?: gax.CallOptions): + Promise<[ + protosTypes.google.monitoring.v3.IService, + protosTypes.google.monitoring.v3.IGetServiceRequest|undefined, {}|undefined + ]>; + getService( + request: protosTypes.google.monitoring.v3.IGetServiceRequest, + options: gax.CallOptions, + callback: Callback< + protosTypes.google.monitoring.v3.IService, + protosTypes.google.monitoring.v3.IGetServiceRequest|undefined, + {}|undefined>): void; +/** + * Get the named `Service`. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Resource name of the `Service`. + * Of the form `projects/{project_id}/services/{service_id}`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Service]{@link google.monitoring.v3.Service}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ + getService( + request: protosTypes.google.monitoring.v3.IGetServiceRequest, + optionsOrCallback?: gax.CallOptions|Callback< + protosTypes.google.monitoring.v3.IService, + protosTypes.google.monitoring.v3.IGetServiceRequest|undefined, {}|undefined>, + callback?: Callback< + protosTypes.google.monitoring.v3.IService, + protosTypes.google.monitoring.v3.IGetServiceRequest|undefined, + {}|undefined>): + Promise<[ + protosTypes.google.monitoring.v3.IService, + protosTypes.google.monitoring.v3.IGetServiceRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as gax.CallOptions; + } + 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 || '', + }); + return this._innerApiCalls.getService(request, options, callback); + } + updateService( + request: protosTypes.google.monitoring.v3.IUpdateServiceRequest, + options?: gax.CallOptions): + Promise<[ + protosTypes.google.monitoring.v3.IService, + protosTypes.google.monitoring.v3.IUpdateServiceRequest|undefined, {}|undefined + ]>; + updateService( + request: protosTypes.google.monitoring.v3.IUpdateServiceRequest, + options: gax.CallOptions, + callback: Callback< + protosTypes.google.monitoring.v3.IService, + protosTypes.google.monitoring.v3.IUpdateServiceRequest|undefined, + {}|undefined>): void; +/** + * Update this `Service`. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.monitoring.v3.Service} request.service + * Required. The `Service` to draw updates from. + * The given `name` specifies the resource to update. + * @param {google.protobuf.FieldMask} request.updateMask + * A set of field paths defining which fields to use for the update. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Service]{@link google.monitoring.v3.Service}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ + updateService( + request: protosTypes.google.monitoring.v3.IUpdateServiceRequest, + optionsOrCallback?: gax.CallOptions|Callback< + protosTypes.google.monitoring.v3.IService, + protosTypes.google.monitoring.v3.IUpdateServiceRequest|undefined, {}|undefined>, + callback?: Callback< + protosTypes.google.monitoring.v3.IService, + protosTypes.google.monitoring.v3.IUpdateServiceRequest|undefined, + {}|undefined>): + Promise<[ + protosTypes.google.monitoring.v3.IService, + protosTypes.google.monitoring.v3.IUpdateServiceRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as gax.CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'service.name': request.service!.name || '', + }); + return this._innerApiCalls.updateService(request, options, callback); + } + deleteService( + request: protosTypes.google.monitoring.v3.IDeleteServiceRequest, + options?: gax.CallOptions): + Promise<[ + protosTypes.google.protobuf.IEmpty, + protosTypes.google.monitoring.v3.IDeleteServiceRequest|undefined, {}|undefined + ]>; + deleteService( + request: protosTypes.google.monitoring.v3.IDeleteServiceRequest, + options: gax.CallOptions, + callback: Callback< + protosTypes.google.protobuf.IEmpty, + protosTypes.google.monitoring.v3.IDeleteServiceRequest|undefined, + {}|undefined>): void; +/** + * Soft delete this `Service`. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Resource name of the `Service` to delete. + * Of the form `projects/{project_id}/services/{service_id}`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ + deleteService( + request: protosTypes.google.monitoring.v3.IDeleteServiceRequest, + optionsOrCallback?: gax.CallOptions|Callback< + protosTypes.google.protobuf.IEmpty, + protosTypes.google.monitoring.v3.IDeleteServiceRequest|undefined, {}|undefined>, + callback?: Callback< + protosTypes.google.protobuf.IEmpty, + protosTypes.google.monitoring.v3.IDeleteServiceRequest|undefined, + {}|undefined>): + Promise<[ + protosTypes.google.protobuf.IEmpty, + protosTypes.google.monitoring.v3.IDeleteServiceRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as gax.CallOptions; + } + 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 || '', + }); + return this._innerApiCalls.deleteService(request, options, callback); + } + createServiceLevelObjective( + request: protosTypes.google.monitoring.v3.ICreateServiceLevelObjectiveRequest, + options?: gax.CallOptions): + Promise<[ + protosTypes.google.monitoring.v3.IServiceLevelObjective, + protosTypes.google.monitoring.v3.ICreateServiceLevelObjectiveRequest|undefined, {}|undefined + ]>; + createServiceLevelObjective( + request: protosTypes.google.monitoring.v3.ICreateServiceLevelObjectiveRequest, + options: gax.CallOptions, + callback: Callback< + protosTypes.google.monitoring.v3.IServiceLevelObjective, + protosTypes.google.monitoring.v3.ICreateServiceLevelObjectiveRequest|undefined, + {}|undefined>): void; +/** + * Create a `ServiceLevelObjective` for the given `Service`. + * + * @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.serviceLevelObjectiveId + * Optional. The ServiceLevelObjective id to use for this + * ServiceLevelObjective. If omitted, an id will be generated instead. Must + * match the pattern [a-z0-9\-]+ + * @param {google.monitoring.v3.ServiceLevelObjective} request.serviceLevelObjective + * Required. The `ServiceLevelObjective` to create. + * The provided `name` will be respected if no `ServiceLevelObjective` exists + * with this name. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [ServiceLevelObjective]{@link google.monitoring.v3.ServiceLevelObjective}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ + createServiceLevelObjective( + request: protosTypes.google.monitoring.v3.ICreateServiceLevelObjectiveRequest, + optionsOrCallback?: gax.CallOptions|Callback< + protosTypes.google.monitoring.v3.IServiceLevelObjective, + protosTypes.google.monitoring.v3.ICreateServiceLevelObjectiveRequest|undefined, {}|undefined>, + callback?: Callback< + protosTypes.google.monitoring.v3.IServiceLevelObjective, + protosTypes.google.monitoring.v3.ICreateServiceLevelObjectiveRequest|undefined, + {}|undefined>): + Promise<[ + protosTypes.google.monitoring.v3.IServiceLevelObjective, + protosTypes.google.monitoring.v3.ICreateServiceLevelObjectiveRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as gax.CallOptions; + } + 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 || '', + }); + return this._innerApiCalls.createServiceLevelObjective(request, options, callback); + } + getServiceLevelObjective( + request: protosTypes.google.monitoring.v3.IGetServiceLevelObjectiveRequest, + options?: gax.CallOptions): + Promise<[ + protosTypes.google.monitoring.v3.IServiceLevelObjective, + protosTypes.google.monitoring.v3.IGetServiceLevelObjectiveRequest|undefined, {}|undefined + ]>; + getServiceLevelObjective( + request: protosTypes.google.monitoring.v3.IGetServiceLevelObjectiveRequest, + options: gax.CallOptions, + callback: Callback< + protosTypes.google.monitoring.v3.IServiceLevelObjective, + protosTypes.google.monitoring.v3.IGetServiceLevelObjectiveRequest|undefined, + {}|undefined>): void; +/** + * Get a `ServiceLevelObjective` by name. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Resource name of the `ServiceLevelObjective` to get. + * Of the form + * `projects/{project_id}/services/{service_id}/serviceLevelObjectives/{slo_name}`. + * @param {google.monitoring.v3.ServiceLevelObjective.View} request.view + * View of the `ServiceLevelObjective` to return. If `DEFAULT`, return the + * `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 {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [ServiceLevelObjective]{@link google.monitoring.v3.ServiceLevelObjective}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ + getServiceLevelObjective( + request: protosTypes.google.monitoring.v3.IGetServiceLevelObjectiveRequest, + optionsOrCallback?: gax.CallOptions|Callback< + protosTypes.google.monitoring.v3.IServiceLevelObjective, + protosTypes.google.monitoring.v3.IGetServiceLevelObjectiveRequest|undefined, {}|undefined>, + callback?: Callback< + protosTypes.google.monitoring.v3.IServiceLevelObjective, + protosTypes.google.monitoring.v3.IGetServiceLevelObjectiveRequest|undefined, + {}|undefined>): + Promise<[ + protosTypes.google.monitoring.v3.IServiceLevelObjective, + protosTypes.google.monitoring.v3.IGetServiceLevelObjectiveRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as gax.CallOptions; + } + 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 || '', + }); + return this._innerApiCalls.getServiceLevelObjective(request, options, callback); + } + updateServiceLevelObjective( + request: protosTypes.google.monitoring.v3.IUpdateServiceLevelObjectiveRequest, + options?: gax.CallOptions): + Promise<[ + protosTypes.google.monitoring.v3.IServiceLevelObjective, + protosTypes.google.monitoring.v3.IUpdateServiceLevelObjectiveRequest|undefined, {}|undefined + ]>; + updateServiceLevelObjective( + request: protosTypes.google.monitoring.v3.IUpdateServiceLevelObjectiveRequest, + options: gax.CallOptions, + callback: Callback< + protosTypes.google.monitoring.v3.IServiceLevelObjective, + protosTypes.google.monitoring.v3.IUpdateServiceLevelObjectiveRequest|undefined, + {}|undefined>): void; +/** + * Update the given `ServiceLevelObjective`. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.monitoring.v3.ServiceLevelObjective} request.serviceLevelObjective + * Required. The `ServiceLevelObjective` to draw updates from. + * The given `name` specifies the resource to update. + * @param {google.protobuf.FieldMask} request.updateMask + * A set of field paths defining which fields to use for the update. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [ServiceLevelObjective]{@link google.monitoring.v3.ServiceLevelObjective}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ + updateServiceLevelObjective( + request: protosTypes.google.monitoring.v3.IUpdateServiceLevelObjectiveRequest, + optionsOrCallback?: gax.CallOptions|Callback< + protosTypes.google.monitoring.v3.IServiceLevelObjective, + protosTypes.google.monitoring.v3.IUpdateServiceLevelObjectiveRequest|undefined, {}|undefined>, + callback?: Callback< + protosTypes.google.monitoring.v3.IServiceLevelObjective, + protosTypes.google.monitoring.v3.IUpdateServiceLevelObjectiveRequest|undefined, + {}|undefined>): + Promise<[ + protosTypes.google.monitoring.v3.IServiceLevelObjective, + protosTypes.google.monitoring.v3.IUpdateServiceLevelObjectiveRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as gax.CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'service_level_objective.name': request.serviceLevelObjective!.name || '', + }); + return this._innerApiCalls.updateServiceLevelObjective(request, options, callback); + } + deleteServiceLevelObjective( + request: protosTypes.google.monitoring.v3.IDeleteServiceLevelObjectiveRequest, + options?: gax.CallOptions): + Promise<[ + protosTypes.google.protobuf.IEmpty, + protosTypes.google.monitoring.v3.IDeleteServiceLevelObjectiveRequest|undefined, {}|undefined + ]>; + deleteServiceLevelObjective( + request: protosTypes.google.monitoring.v3.IDeleteServiceLevelObjectiveRequest, + options: gax.CallOptions, + callback: Callback< + protosTypes.google.protobuf.IEmpty, + protosTypes.google.monitoring.v3.IDeleteServiceLevelObjectiveRequest|undefined, + {}|undefined>): void; +/** + * Delete the given `ServiceLevelObjective`. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Resource name of the `ServiceLevelObjective` to delete. + * Of the form + * `projects/{project_id}/services/{service_id}/serviceLevelObjectives/{slo_name}`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ + deleteServiceLevelObjective( + request: protosTypes.google.monitoring.v3.IDeleteServiceLevelObjectiveRequest, + optionsOrCallback?: gax.CallOptions|Callback< + protosTypes.google.protobuf.IEmpty, + protosTypes.google.monitoring.v3.IDeleteServiceLevelObjectiveRequest|undefined, {}|undefined>, + callback?: Callback< + protosTypes.google.protobuf.IEmpty, + protosTypes.google.monitoring.v3.IDeleteServiceLevelObjectiveRequest|undefined, + {}|undefined>): + Promise<[ + protosTypes.google.protobuf.IEmpty, + protosTypes.google.monitoring.v3.IDeleteServiceLevelObjectiveRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as gax.CallOptions; + } + 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 || '', + }); + return this._innerApiCalls.deleteServiceLevelObjective(request, options, callback); + } + + listServices( + request: protosTypes.google.monitoring.v3.IListServicesRequest, + options?: gax.CallOptions): + Promise<[ + protosTypes.google.monitoring.v3.IService[], + protosTypes.google.monitoring.v3.IListServicesRequest|null, + protosTypes.google.monitoring.v3.IListServicesResponse + ]>; + listServices( + request: protosTypes.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>): void; +/** + * List `Service`s for this workspace. + * + * @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 {Promise} - The promise which resolves to an array. + * The first element of the array is Array of [Service]{@link google.monitoring.v3.Service}. + * The client library support auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * + * When autoPaginate: false is specified through options, the array has three elements. + * The first element is Array of [Service]{@link google.monitoring.v3.Service} that corresponds to + * the one page received from the API server. + * If the second element is not null it contains the request object of type [ListServicesRequest]{@link google.monitoring.v3.ListServicesRequest} + * that can be used to obtain the next page of the results. + * If it is null, the next page does not exist. + * The third element contains the raw response received from the API server. Its type is + * [ListServicesResponse]{@link google.monitoring.v3.ListServicesResponse}. + * + * The promise has a method named "cancel" which cancels the ongoing API call. + */ + listServices( + request: protosTypes.google.monitoring.v3.IListServicesRequest, + optionsOrCallback?: gax.CallOptions|Callback< + protosTypes.google.monitoring.v3.IService[], + protosTypes.google.monitoring.v3.IListServicesRequest|null, + protosTypes.google.monitoring.v3.IListServicesResponse>, + callback?: Callback< + protosTypes.google.monitoring.v3.IService[], + protosTypes.google.monitoring.v3.IListServicesRequest|null, + protosTypes.google.monitoring.v3.IListServicesResponse>): + Promise<[ + protosTypes.google.monitoring.v3.IService[], + protosTypes.google.monitoring.v3.IListServicesRequest|null, + protosTypes.google.monitoring.v3.IListServicesResponse + ]>|void { + request = request || {}; + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as gax.CallOptions; + } + 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 || '', + }); + return this._innerApiCalls.listServices(request, options, callback); + } + +/** + * Equivalent to {@link listServices}, but returns a NodeJS Stream object. + * + * This fetches the paged responses for {@link listServices} continuously + * and invokes the callback registered for 'data' event for each element in the + * responses. + * + * The returned object has 'end' method when no more elements are required. + * + * autoPaginate option will be ignored. + * + * @see {@link https://nodejs.org/api/stream.html} + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. 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 {Stream} + * An object stream which emits an object representing [Service]{@link google.monitoring.v3.Service} on 'data' event. + */ + listServicesStream( + request?: protosTypes.google.monitoring.v3.IListServicesRequest, + options?: gax.CallOptions | {}): + Transform{ + request = request || {}; + const callSettings = new gax.CallSettings(options); + return this._descriptors.page.listServices.createStream( + this._innerApiCalls.listServices as gax.GaxCall, + request, + callSettings + ); + } + listServiceLevelObjectives( + request: protosTypes.google.monitoring.v3.IListServiceLevelObjectivesRequest, + options?: gax.CallOptions): + Promise<[ + protosTypes.google.monitoring.v3.IServiceLevelObjective[], + protosTypes.google.monitoring.v3.IListServiceLevelObjectivesRequest|null, + protosTypes.google.monitoring.v3.IListServiceLevelObjectivesResponse + ]>; + listServiceLevelObjectives( + request: protosTypes.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>): void; +/** + * List the `ServiceLevelObjective`s for the given `Service`. + * + * @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 {Promise} - The promise which resolves to an array. + * The first element of the array is Array of [ServiceLevelObjective]{@link google.monitoring.v3.ServiceLevelObjective}. + * The client library support auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * + * When autoPaginate: false is specified through options, the array has three elements. + * The first element is Array of [ServiceLevelObjective]{@link google.monitoring.v3.ServiceLevelObjective} that corresponds to + * the one page received from the API server. + * If the second element is not null it contains the request object of type [ListServiceLevelObjectivesRequest]{@link google.monitoring.v3.ListServiceLevelObjectivesRequest} + * that can be used to obtain the next page of the results. + * If it is null, the next page does not exist. + * The third element contains the raw response received from the API server. Its type is + * [ListServiceLevelObjectivesResponse]{@link google.monitoring.v3.ListServiceLevelObjectivesResponse}. + * + * The promise has a method named "cancel" which cancels the ongoing API call. + */ + listServiceLevelObjectives( + request: protosTypes.google.monitoring.v3.IListServiceLevelObjectivesRequest, + optionsOrCallback?: gax.CallOptions|Callback< + protosTypes.google.monitoring.v3.IServiceLevelObjective[], + protosTypes.google.monitoring.v3.IListServiceLevelObjectivesRequest|null, + protosTypes.google.monitoring.v3.IListServiceLevelObjectivesResponse>, + callback?: Callback< + protosTypes.google.monitoring.v3.IServiceLevelObjective[], + protosTypes.google.monitoring.v3.IListServiceLevelObjectivesRequest|null, + protosTypes.google.monitoring.v3.IListServiceLevelObjectivesResponse>): + Promise<[ + protosTypes.google.monitoring.v3.IServiceLevelObjective[], + protosTypes.google.monitoring.v3.IListServiceLevelObjectivesRequest|null, + protosTypes.google.monitoring.v3.IListServiceLevelObjectivesResponse + ]>|void { + request = request || {}; + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as gax.CallOptions; + } + 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 || '', + }); + return this._innerApiCalls.listServiceLevelObjectives(request, options, callback); + } + +/** + * Equivalent to {@link listServiceLevelObjectives}, but returns a NodeJS Stream object. + * + * This fetches the paged responses for {@link listServiceLevelObjectives} continuously + * and invokes the callback registered for 'data' event for each element in the + * responses. + * + * The returned object has 'end' method when no more elements are required. + * + * autoPaginate option will be ignored. + * + * @see {@link https://nodejs.org/api/stream.html} + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. 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 {Stream} + * An object stream which emits an object representing [ServiceLevelObjective]{@link google.monitoring.v3.ServiceLevelObjective} on 'data' event. + */ + listServiceLevelObjectivesStream( + request?: protosTypes.google.monitoring.v3.IListServiceLevelObjectivesRequest, + options?: gax.CallOptions | {}): + Transform{ + request = request || {}; + const callSettings = new gax.CallSettings(options); + return this._descriptors.page.listServiceLevelObjectives.createStream( + this._innerApiCalls.listServiceLevelObjectives as gax.GaxCall, + request, + callSettings + ); + } + // -------------------- + // -- Path templates -- + // -------------------- + + /** + * Return a fully-qualified projectAlertPolicy resource name string. + * + * @param {string} project + * @param {string} alert_policy + * @returns {string} Resource name string. + */ + projectAlertPolicyPath(project:string,alertPolicy:string) { + return this._pathTemplates.projectAlertPolicyPathTemplate.render({ + project: project, + alert_policy: alertPolicy, + }); + } + + /** + * Parse the project from ProjectAlertPolicy resource. + * + * @param {string} projectAlertPolicyName + * A fully-qualified path representing project_alert_policy resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectAlertPolicyName(projectAlertPolicyName: string) { + return this._pathTemplates.projectAlertPolicyPathTemplate.match(projectAlertPolicyName).project; + } + + /** + * Parse the alert_policy from ProjectAlertPolicy resource. + * + * @param {string} projectAlertPolicyName + * A fully-qualified path representing project_alert_policy resource. + * @returns {string} A string representing the alert_policy. + */ + matchAlertPolicyFromProjectAlertPolicyName(projectAlertPolicyName: string) { + return this._pathTemplates.projectAlertPolicyPathTemplate.match(projectAlertPolicyName).alert_policy; + } + + /** + * Return a fully-qualified organizationAlertPolicy resource name string. + * + * @param {string} organization + * @param {string} alert_policy + * @returns {string} Resource name string. + */ + organizationAlertPolicyPath(organization:string,alertPolicy:string) { + return this._pathTemplates.organizationAlertPolicyPathTemplate.render({ + organization: organization, + alert_policy: alertPolicy, + }); + } + + /** + * Parse the organization from OrganizationAlertPolicy resource. + * + * @param {string} organizationAlertPolicyName + * A fully-qualified path representing organization_alert_policy resource. + * @returns {string} A string representing the organization. + */ + matchOrganizationFromOrganizationAlertPolicyName(organizationAlertPolicyName: string) { + return this._pathTemplates.organizationAlertPolicyPathTemplate.match(organizationAlertPolicyName).organization; + } + + /** + * Parse the alert_policy from OrganizationAlertPolicy resource. + * + * @param {string} organizationAlertPolicyName + * A fully-qualified path representing organization_alert_policy resource. + * @returns {string} A string representing the alert_policy. + */ + matchAlertPolicyFromOrganizationAlertPolicyName(organizationAlertPolicyName: string) { + return this._pathTemplates.organizationAlertPolicyPathTemplate.match(organizationAlertPolicyName).alert_policy; + } + + /** + * Return a fully-qualified folderAlertPolicy resource name string. + * + * @param {string} folder + * @param {string} alert_policy + * @returns {string} Resource name string. + */ + folderAlertPolicyPath(folder:string,alertPolicy:string) { + return this._pathTemplates.folderAlertPolicyPathTemplate.render({ + folder: folder, + alert_policy: alertPolicy, + }); + } + + /** + * Parse the folder from FolderAlertPolicy resource. + * + * @param {string} folderAlertPolicyName + * A fully-qualified path representing folder_alert_policy resource. + * @returns {string} A string representing the folder. + */ + matchFolderFromFolderAlertPolicyName(folderAlertPolicyName: string) { + return this._pathTemplates.folderAlertPolicyPathTemplate.match(folderAlertPolicyName).folder; + } + + /** + * Parse the alert_policy from FolderAlertPolicy resource. + * + * @param {string} folderAlertPolicyName + * A fully-qualified path representing folder_alert_policy resource. + * @returns {string} A string representing the alert_policy. + */ + matchAlertPolicyFromFolderAlertPolicyName(folderAlertPolicyName: string) { + return this._pathTemplates.folderAlertPolicyPathTemplate.match(folderAlertPolicyName).alert_policy; + } + + /** + * Return a fully-qualified resource name string. + * + * @returns {string} Resource name string. + */ + Path() { + return this._pathTemplates.PathTemplate.render({ + }); + } + + /** + * Return a fully-qualified projectGroup resource name string. + * + * @param {string} project + * @param {string} group + * @returns {string} Resource name string. + */ + projectGroupPath(project:string,group:string) { + return this._pathTemplates.projectGroupPathTemplate.render({ + project: project, + group: group, + }); + } + + /** + * Parse the project from ProjectGroup resource. + * + * @param {string} projectGroupName + * A fully-qualified path representing project_group resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectGroupName(projectGroupName: string) { + return this._pathTemplates.projectGroupPathTemplate.match(projectGroupName).project; + } + + /** + * Parse the group from ProjectGroup resource. + * + * @param {string} projectGroupName + * A fully-qualified path representing project_group resource. + * @returns {string} A string representing the group. + */ + matchGroupFromProjectGroupName(projectGroupName: string) { + return this._pathTemplates.projectGroupPathTemplate.match(projectGroupName).group; + } + + /** + * Return a fully-qualified organizationGroup resource name string. + * + * @param {string} organization + * @param {string} group + * @returns {string} Resource name string. + */ + organizationGroupPath(organization:string,group:string) { + return this._pathTemplates.organizationGroupPathTemplate.render({ + organization: organization, + group: group, + }); + } + + /** + * Parse the organization from OrganizationGroup resource. + * + * @param {string} organizationGroupName + * A fully-qualified path representing organization_group resource. + * @returns {string} A string representing the organization. + */ + matchOrganizationFromOrganizationGroupName(organizationGroupName: string) { + return this._pathTemplates.organizationGroupPathTemplate.match(organizationGroupName).organization; + } + + /** + * Parse the group from OrganizationGroup resource. + * + * @param {string} organizationGroupName + * A fully-qualified path representing organization_group resource. + * @returns {string} A string representing the group. + */ + matchGroupFromOrganizationGroupName(organizationGroupName: string) { + return this._pathTemplates.organizationGroupPathTemplate.match(organizationGroupName).group; + } + + /** + * Return a fully-qualified folderGroup resource name string. + * + * @param {string} folder + * @param {string} group + * @returns {string} Resource name string. + */ + folderGroupPath(folder:string,group:string) { + return this._pathTemplates.folderGroupPathTemplate.render({ + folder: folder, + group: group, + }); + } + + /** + * Parse the folder from FolderGroup resource. + * + * @param {string} folderGroupName + * A fully-qualified path representing folder_group resource. + * @returns {string} A string representing the folder. + */ + matchFolderFromFolderGroupName(folderGroupName: string) { + return this._pathTemplates.folderGroupPathTemplate.match(folderGroupName).folder; + } + + /** + * Parse the group from FolderGroup resource. + * + * @param {string} folderGroupName + * A fully-qualified path representing folder_group resource. + * @returns {string} A string representing the group. + */ + matchGroupFromFolderGroupName(folderGroupName: string) { + return this._pathTemplates.folderGroupPathTemplate.match(folderGroupName).group; + } + + /** + * Return a fully-qualified projectChannelDescriptor resource name string. + * + * @param {string} project + * @param {string} channel_descriptor + * @returns {string} Resource name string. + */ + projectChannelDescriptorPath(project:string,channelDescriptor:string) { + return this._pathTemplates.projectChannelDescriptorPathTemplate.render({ + project: project, + channel_descriptor: channelDescriptor, + }); + } + + /** + * Parse the project from ProjectChannelDescriptor resource. + * + * @param {string} projectChannelDescriptorName + * A fully-qualified path representing project_channel_descriptor resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectChannelDescriptorName(projectChannelDescriptorName: string) { + return this._pathTemplates.projectChannelDescriptorPathTemplate.match(projectChannelDescriptorName).project; + } + + /** + * Parse the channel_descriptor from ProjectChannelDescriptor resource. + * + * @param {string} projectChannelDescriptorName + * A fully-qualified path representing project_channel_descriptor resource. + * @returns {string} A string representing the channel_descriptor. + */ + matchChannelDescriptorFromProjectChannelDescriptorName(projectChannelDescriptorName: string) { + return this._pathTemplates.projectChannelDescriptorPathTemplate.match(projectChannelDescriptorName).channel_descriptor; + } + + /** + * Return a fully-qualified organizationChannelDescriptor resource name string. + * + * @param {string} organization + * @param {string} channel_descriptor + * @returns {string} Resource name string. + */ + organizationChannelDescriptorPath(organization:string,channelDescriptor:string) { + return this._pathTemplates.organizationChannelDescriptorPathTemplate.render({ + organization: organization, + channel_descriptor: channelDescriptor, + }); + } + + /** + * Parse the organization from OrganizationChannelDescriptor resource. + * + * @param {string} organizationChannelDescriptorName + * A fully-qualified path representing organization_channel_descriptor resource. + * @returns {string} A string representing the organization. + */ + matchOrganizationFromOrganizationChannelDescriptorName(organizationChannelDescriptorName: string) { + return this._pathTemplates.organizationChannelDescriptorPathTemplate.match(organizationChannelDescriptorName).organization; + } + + /** + * Parse the channel_descriptor from OrganizationChannelDescriptor resource. + * + * @param {string} organizationChannelDescriptorName + * A fully-qualified path representing organization_channel_descriptor resource. + * @returns {string} A string representing the channel_descriptor. + */ + matchChannelDescriptorFromOrganizationChannelDescriptorName(organizationChannelDescriptorName: string) { + return this._pathTemplates.organizationChannelDescriptorPathTemplate.match(organizationChannelDescriptorName).channel_descriptor; + } + + /** + * Return a fully-qualified folderChannelDescriptor resource name string. + * + * @param {string} folder + * @param {string} channel_descriptor + * @returns {string} Resource name string. + */ + folderChannelDescriptorPath(folder:string,channelDescriptor:string) { + return this._pathTemplates.folderChannelDescriptorPathTemplate.render({ + folder: folder, + channel_descriptor: channelDescriptor, + }); + } + + /** + * Parse the folder from FolderChannelDescriptor resource. + * + * @param {string} folderChannelDescriptorName + * A fully-qualified path representing folder_channel_descriptor resource. + * @returns {string} A string representing the folder. + */ + matchFolderFromFolderChannelDescriptorName(folderChannelDescriptorName: string) { + return this._pathTemplates.folderChannelDescriptorPathTemplate.match(folderChannelDescriptorName).folder; + } + + /** + * Parse the channel_descriptor from FolderChannelDescriptor resource. + * + * @param {string} folderChannelDescriptorName + * A fully-qualified path representing folder_channel_descriptor resource. + * @returns {string} A string representing the channel_descriptor. + */ + matchChannelDescriptorFromFolderChannelDescriptorName(folderChannelDescriptorName: string) { + return this._pathTemplates.folderChannelDescriptorPathTemplate.match(folderChannelDescriptorName).channel_descriptor; + } + + /** + * Return a fully-qualified projectNotificationChannel resource name string. + * + * @param {string} project + * @param {string} notification_channel + * @returns {string} Resource name string. + */ + projectNotificationChannelPath(project:string,notificationChannel:string) { + return this._pathTemplates.projectNotificationChannelPathTemplate.render({ + project: project, + notification_channel: notificationChannel, + }); + } + + /** + * Parse the project from ProjectNotificationChannel resource. + * + * @param {string} projectNotificationChannelName + * A fully-qualified path representing project_notification_channel resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectNotificationChannelName(projectNotificationChannelName: string) { + return this._pathTemplates.projectNotificationChannelPathTemplate.match(projectNotificationChannelName).project; + } + + /** + * Parse the notification_channel from ProjectNotificationChannel resource. + * + * @param {string} projectNotificationChannelName + * A fully-qualified path representing project_notification_channel resource. + * @returns {string} A string representing the notification_channel. + */ + matchNotificationChannelFromProjectNotificationChannelName(projectNotificationChannelName: string) { + return this._pathTemplates.projectNotificationChannelPathTemplate.match(projectNotificationChannelName).notification_channel; + } + + /** + * Return a fully-qualified organizationNotificationChannel resource name string. + * + * @param {string} organization + * @param {string} notification_channel + * @returns {string} Resource name string. + */ + organizationNotificationChannelPath(organization:string,notificationChannel:string) { + return this._pathTemplates.organizationNotificationChannelPathTemplate.render({ + organization: organization, + notification_channel: notificationChannel, + }); + } + + /** + * Parse the organization from OrganizationNotificationChannel resource. + * + * @param {string} organizationNotificationChannelName + * A fully-qualified path representing organization_notification_channel resource. + * @returns {string} A string representing the organization. + */ + matchOrganizationFromOrganizationNotificationChannelName(organizationNotificationChannelName: string) { + return this._pathTemplates.organizationNotificationChannelPathTemplate.match(organizationNotificationChannelName).organization; + } + + /** + * Parse the notification_channel from OrganizationNotificationChannel resource. + * + * @param {string} organizationNotificationChannelName + * A fully-qualified path representing organization_notification_channel resource. + * @returns {string} A string representing the notification_channel. + */ + matchNotificationChannelFromOrganizationNotificationChannelName(organizationNotificationChannelName: string) { + return this._pathTemplates.organizationNotificationChannelPathTemplate.match(organizationNotificationChannelName).notification_channel; + } + + /** + * Return a fully-qualified folderNotificationChannel resource name string. + * + * @param {string} folder + * @param {string} notification_channel + * @returns {string} Resource name string. + */ + folderNotificationChannelPath(folder:string,notificationChannel:string) { + return this._pathTemplates.folderNotificationChannelPathTemplate.render({ + folder: folder, + notification_channel: notificationChannel, + }); + } + + /** + * Parse the folder from FolderNotificationChannel resource. + * + * @param {string} folderNotificationChannelName + * A fully-qualified path representing folder_notification_channel resource. + * @returns {string} A string representing the folder. + */ + matchFolderFromFolderNotificationChannelName(folderNotificationChannelName: string) { + return this._pathTemplates.folderNotificationChannelPathTemplate.match(folderNotificationChannelName).folder; + } + + /** + * Parse the notification_channel from FolderNotificationChannel resource. + * + * @param {string} folderNotificationChannelName + * A fully-qualified path representing folder_notification_channel resource. + * @returns {string} A string representing the notification_channel. + */ + matchNotificationChannelFromFolderNotificationChannelName(folderNotificationChannelName: string) { + return this._pathTemplates.folderNotificationChannelPathTemplate.match(folderNotificationChannelName).notification_channel; + } + + /** + * Return a fully-qualified projectService resource name string. + * + * @param {string} project + * @param {string} service + * @returns {string} Resource name string. + */ + projectServicePath(project:string,service:string) { + return this._pathTemplates.projectServicePathTemplate.render({ + project: project, + service: service, + }); + } + + /** + * Parse the project from ProjectService resource. + * + * @param {string} projectServiceName + * A fully-qualified path representing project_service resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectServiceName(projectServiceName: string) { + return this._pathTemplates.projectServicePathTemplate.match(projectServiceName).project; + } + + /** + * Parse the service from ProjectService resource. + * + * @param {string} projectServiceName + * A fully-qualified path representing project_service resource. + * @returns {string} A string representing the service. + */ + matchServiceFromProjectServiceName(projectServiceName: string) { + return this._pathTemplates.projectServicePathTemplate.match(projectServiceName).service; + } + + /** + * Return a fully-qualified organizationService resource name string. + * + * @param {string} organization + * @param {string} service + * @returns {string} Resource name string. + */ + organizationServicePath(organization:string,service:string) { + return this._pathTemplates.organizationServicePathTemplate.render({ + organization: organization, + service: service, + }); + } + + /** + * Parse the organization from OrganizationService resource. + * + * @param {string} organizationServiceName + * A fully-qualified path representing organization_service resource. + * @returns {string} A string representing the organization. + */ + matchOrganizationFromOrganizationServiceName(organizationServiceName: string) { + return this._pathTemplates.organizationServicePathTemplate.match(organizationServiceName).organization; + } + + /** + * Parse the service from OrganizationService resource. + * + * @param {string} organizationServiceName + * A fully-qualified path representing organization_service resource. + * @returns {string} A string representing the service. + */ + matchServiceFromOrganizationServiceName(organizationServiceName: string) { + return this._pathTemplates.organizationServicePathTemplate.match(organizationServiceName).service; + } + + /** + * Return a fully-qualified folderService resource name string. + * + * @param {string} folder + * @param {string} service + * @returns {string} Resource name string. + */ + folderServicePath(folder:string,service:string) { + return this._pathTemplates.folderServicePathTemplate.render({ + folder: folder, + service: service, + }); + } + + /** + * Parse the folder from FolderService resource. + * + * @param {string} folderServiceName + * A fully-qualified path representing folder_service resource. + * @returns {string} A string representing the folder. + */ + matchFolderFromFolderServiceName(folderServiceName: string) { + return this._pathTemplates.folderServicePathTemplate.match(folderServiceName).folder; + } + + /** + * Parse the service from FolderService resource. + * + * @param {string} folderServiceName + * A fully-qualified path representing folder_service resource. + * @returns {string} A string representing the service. + */ + matchServiceFromFolderServiceName(folderServiceName: string) { + return this._pathTemplates.folderServicePathTemplate.match(folderServiceName).service; + } + + /** + * Return a fully-qualified projectServiceServiceLevelObjective resource name string. + * + * @param {string} project + * @param {string} service + * @param {string} service_level_objective + * @returns {string} Resource name string. + */ + projectServiceServiceLevelObjectivePath(project:string,service:string,serviceLevelObjective:string) { + return this._pathTemplates.projectServiceServiceLevelObjectivePathTemplate.render({ + project: project, + service: service, + service_level_objective: serviceLevelObjective, + }); + } + + /** + * Parse the project from ProjectServiceServiceLevelObjective resource. + * + * @param {string} projectServiceServiceLevelObjectiveName + * A fully-qualified path representing project_service_service_level_objective resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectServiceServiceLevelObjectiveName(projectServiceServiceLevelObjectiveName: string) { + return this._pathTemplates.projectServiceServiceLevelObjectivePathTemplate.match(projectServiceServiceLevelObjectiveName).project; + } + + /** + * Parse the service from ProjectServiceServiceLevelObjective resource. + * + * @param {string} projectServiceServiceLevelObjectiveName + * A fully-qualified path representing project_service_service_level_objective resource. + * @returns {string} A string representing the service. + */ + matchServiceFromProjectServiceServiceLevelObjectiveName(projectServiceServiceLevelObjectiveName: string) { + return this._pathTemplates.projectServiceServiceLevelObjectivePathTemplate.match(projectServiceServiceLevelObjectiveName).service; + } + + /** + * Parse the service_level_objective from ProjectServiceServiceLevelObjective resource. + * + * @param {string} projectServiceServiceLevelObjectiveName + * A fully-qualified path representing project_service_service_level_objective resource. + * @returns {string} A string representing the service_level_objective. + */ + matchServiceLevelObjectiveFromProjectServiceServiceLevelObjectiveName(projectServiceServiceLevelObjectiveName: string) { + return this._pathTemplates.projectServiceServiceLevelObjectivePathTemplate.match(projectServiceServiceLevelObjectiveName).service_level_objective; + } + + /** + * Return a fully-qualified organizationServiceServiceLevelObjective resource name string. + * + * @param {string} organization + * @param {string} service + * @param {string} service_level_objective + * @returns {string} Resource name string. + */ + organizationServiceServiceLevelObjectivePath(organization:string,service:string,serviceLevelObjective:string) { + return this._pathTemplates.organizationServiceServiceLevelObjectivePathTemplate.render({ + organization: organization, + service: service, + service_level_objective: serviceLevelObjective, + }); + } + + /** + * Parse the organization from OrganizationServiceServiceLevelObjective resource. + * + * @param {string} organizationServiceServiceLevelObjectiveName + * A fully-qualified path representing organization_service_service_level_objective resource. + * @returns {string} A string representing the organization. + */ + matchOrganizationFromOrganizationServiceServiceLevelObjectiveName(organizationServiceServiceLevelObjectiveName: string) { + return this._pathTemplates.organizationServiceServiceLevelObjectivePathTemplate.match(organizationServiceServiceLevelObjectiveName).organization; + } + + /** + * Parse the service from OrganizationServiceServiceLevelObjective resource. + * + * @param {string} organizationServiceServiceLevelObjectiveName + * A fully-qualified path representing organization_service_service_level_objective resource. + * @returns {string} A string representing the service. + */ + matchServiceFromOrganizationServiceServiceLevelObjectiveName(organizationServiceServiceLevelObjectiveName: string) { + return this._pathTemplates.organizationServiceServiceLevelObjectivePathTemplate.match(organizationServiceServiceLevelObjectiveName).service; + } + + /** + * Parse the service_level_objective from OrganizationServiceServiceLevelObjective resource. + * + * @param {string} organizationServiceServiceLevelObjectiveName + * A fully-qualified path representing organization_service_service_level_objective resource. + * @returns {string} A string representing the service_level_objective. + */ + matchServiceLevelObjectiveFromOrganizationServiceServiceLevelObjectiveName(organizationServiceServiceLevelObjectiveName: string) { + return this._pathTemplates.organizationServiceServiceLevelObjectivePathTemplate.match(organizationServiceServiceLevelObjectiveName).service_level_objective; + } + + /** + * Return a fully-qualified folderServiceServiceLevelObjective resource name string. + * + * @param {string} folder + * @param {string} service + * @param {string} service_level_objective + * @returns {string} Resource name string. + */ + folderServiceServiceLevelObjectivePath(folder:string,service:string,serviceLevelObjective:string) { + return this._pathTemplates.folderServiceServiceLevelObjectivePathTemplate.render({ + folder: folder, + service: service, + service_level_objective: serviceLevelObjective, + }); + } + + /** + * Parse the folder from FolderServiceServiceLevelObjective resource. + * + * @param {string} folderServiceServiceLevelObjectiveName + * A fully-qualified path representing folder_service_service_level_objective resource. + * @returns {string} A string representing the folder. + */ + matchFolderFromFolderServiceServiceLevelObjectiveName(folderServiceServiceLevelObjectiveName: string) { + return this._pathTemplates.folderServiceServiceLevelObjectivePathTemplate.match(folderServiceServiceLevelObjectiveName).folder; + } + + /** + * Parse the service from FolderServiceServiceLevelObjective resource. + * + * @param {string} folderServiceServiceLevelObjectiveName + * A fully-qualified path representing folder_service_service_level_objective resource. + * @returns {string} A string representing the service. + */ + matchServiceFromFolderServiceServiceLevelObjectiveName(folderServiceServiceLevelObjectiveName: string) { + return this._pathTemplates.folderServiceServiceLevelObjectivePathTemplate.match(folderServiceServiceLevelObjectiveName).service; + } + + /** + * Parse the service_level_objective from FolderServiceServiceLevelObjective resource. + * + * @param {string} folderServiceServiceLevelObjectiveName + * A fully-qualified path representing folder_service_service_level_objective resource. + * @returns {string} A string representing the service_level_objective. + */ + matchServiceLevelObjectiveFromFolderServiceServiceLevelObjectiveName(folderServiceServiceLevelObjectiveName: string) { + return this._pathTemplates.folderServiceServiceLevelObjectivePathTemplate.match(folderServiceServiceLevelObjectiveName).service_level_objective; + } + + /** + * Return a fully-qualified projectUptimeCheckConfig resource name string. + * + * @param {string} project + * @param {string} uptime_check_config + * @returns {string} Resource name string. + */ + projectUptimeCheckConfigPath(project:string,uptimeCheckConfig:string) { + return this._pathTemplates.projectUptimeCheckConfigPathTemplate.render({ + project: project, + uptime_check_config: uptimeCheckConfig, + }); + } + + /** + * Parse the project from ProjectUptimeCheckConfig resource. + * + * @param {string} projectUptimeCheckConfigName + * A fully-qualified path representing project_uptime_check_config resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectUptimeCheckConfigName(projectUptimeCheckConfigName: string) { + return this._pathTemplates.projectUptimeCheckConfigPathTemplate.match(projectUptimeCheckConfigName).project; + } + + /** + * Parse the uptime_check_config from ProjectUptimeCheckConfig resource. + * + * @param {string} projectUptimeCheckConfigName + * A fully-qualified path representing project_uptime_check_config resource. + * @returns {string} A string representing the uptime_check_config. + */ + matchUptimeCheckConfigFromProjectUptimeCheckConfigName(projectUptimeCheckConfigName: string) { + return this._pathTemplates.projectUptimeCheckConfigPathTemplate.match(projectUptimeCheckConfigName).uptime_check_config; + } + + /** + * Return a fully-qualified organizationUptimeCheckConfig resource name string. + * + * @param {string} organization + * @param {string} uptime_check_config + * @returns {string} Resource name string. + */ + organizationUptimeCheckConfigPath(organization:string,uptimeCheckConfig:string) { + return this._pathTemplates.organizationUptimeCheckConfigPathTemplate.render({ + organization: organization, + uptime_check_config: uptimeCheckConfig, + }); + } + + /** + * Parse the organization from OrganizationUptimeCheckConfig resource. + * + * @param {string} organizationUptimeCheckConfigName + * A fully-qualified path representing organization_uptime_check_config resource. + * @returns {string} A string representing the organization. + */ + matchOrganizationFromOrganizationUptimeCheckConfigName(organizationUptimeCheckConfigName: string) { + return this._pathTemplates.organizationUptimeCheckConfigPathTemplate.match(organizationUptimeCheckConfigName).organization; + } + + /** + * Parse the uptime_check_config from OrganizationUptimeCheckConfig resource. + * + * @param {string} organizationUptimeCheckConfigName + * A fully-qualified path representing organization_uptime_check_config resource. + * @returns {string} A string representing the uptime_check_config. + */ + matchUptimeCheckConfigFromOrganizationUptimeCheckConfigName(organizationUptimeCheckConfigName: string) { + return this._pathTemplates.organizationUptimeCheckConfigPathTemplate.match(organizationUptimeCheckConfigName).uptime_check_config; + } + + /** + * Return a fully-qualified folderUptimeCheckConfig resource name string. + * + * @param {string} folder + * @param {string} uptime_check_config + * @returns {string} Resource name string. + */ + folderUptimeCheckConfigPath(folder:string,uptimeCheckConfig:string) { + return this._pathTemplates.folderUptimeCheckConfigPathTemplate.render({ + folder: folder, + uptime_check_config: uptimeCheckConfig, + }); + } + + /** + * Parse the folder from FolderUptimeCheckConfig resource. + * + * @param {string} folderUptimeCheckConfigName + * A fully-qualified path representing folder_uptime_check_config resource. + * @returns {string} A string representing the folder. + */ + matchFolderFromFolderUptimeCheckConfigName(folderUptimeCheckConfigName: string) { + return this._pathTemplates.folderUptimeCheckConfigPathTemplate.match(folderUptimeCheckConfigName).folder; + } + + /** + * Parse the uptime_check_config from FolderUptimeCheckConfig resource. + * + * @param {string} folderUptimeCheckConfigName + * A fully-qualified path representing folder_uptime_check_config resource. + * @returns {string} A string representing the uptime_check_config. + */ + matchUptimeCheckConfigFromFolderUptimeCheckConfigName(folderUptimeCheckConfigName: string) { + return this._pathTemplates.folderUptimeCheckConfigPathTemplate.match(folderUptimeCheckConfigName).uptime_check_config; + } + + /** + * Terminate the GRPC channel and close the client. + * + * The client will no longer be usable and all future behavior is undefined. + */ + close(): Promise { + if (!this._terminated) { + return this.serviceMonitoringServiceStub.then(stub => { + this._terminated = true; + stub.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/typescript/test/testdata/monitoring/src/v3/service_monitoring_service_client_config.json.baseline b/typescript/test/testdata/monitoring/src/v3/service_monitoring_service_client_config.json.baseline new file mode 100644 index 000000000..fe6218668 --- /dev/null +++ b/typescript/test/testdata/monitoring/src/v3/service_monitoring_service_client_config.json.baseline @@ -0,0 +1,66 @@ +{ + "interfaces": { + "google.monitoring.v3.ServiceMonitoringService": { + "retry_codes": { + "non_idempotent": [], + "idempotent": [ + "DEADLINE_EXCEEDED", + "UNAVAILABLE" + ] + }, + "retry_params": { + "default": { + "initial_retry_delay_millis": 100, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 60000, + "initial_rpc_timeout_millis": 60000, + "rpc_timeout_multiplier": 1, + "max_rpc_timeout_millis": 60000, + "total_timeout_millis": 600000 + } + }, + "methods": { + "CreateService": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "GetService": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "ListServices": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "UpdateService": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "DeleteService": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "CreateServiceLevelObjective": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "GetServiceLevelObjective": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "ListServiceLevelObjectives": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "UpdateServiceLevelObjective": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "DeleteServiceLevelObjective": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/typescript/test/testdata/monitoring/src/v3/service_monitoring_service_proto_list.json.baseline b/typescript/test/testdata/monitoring/src/v3/service_monitoring_service_proto_list.json.baseline new file mode 100644 index 000000000..aacceb22f --- /dev/null +++ b/typescript/test/testdata/monitoring/src/v3/service_monitoring_service_proto_list.json.baseline @@ -0,0 +1,16 @@ +[ + "../../protos/google/monitoring/v3/alert.proto", + "../../protos/google/monitoring/v3/alert_service.proto", + "../../protos/google/monitoring/v3/common.proto", + "../../protos/google/monitoring/v3/group.proto", + "../../protos/google/monitoring/v3/group_service.proto", + "../../protos/google/monitoring/v3/metric.proto", + "../../protos/google/monitoring/v3/metric_service.proto", + "../../protos/google/monitoring/v3/mutation_record.proto", + "../../protos/google/monitoring/v3/notification.proto", + "../../protos/google/monitoring/v3/notification_service.proto", + "../../protos/google/monitoring/v3/service.proto", + "../../protos/google/monitoring/v3/service_service.proto", + "../../protos/google/monitoring/v3/uptime.proto", + "../../protos/google/monitoring/v3/uptime_service.proto" +] diff --git a/typescript/test/testdata/monitoring/src/v3/uptime_check_service_client.ts.baseline b/typescript/test/testdata/monitoring/src/v3/uptime_check_service_client.ts.baseline new file mode 100644 index 000000000..475ed31ae --- /dev/null +++ b/typescript/test/testdata/monitoring/src/v3/uptime_check_service_client.ts.baseline @@ -0,0 +1,1661 @@ +// 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 gax from 'google-gax'; +import {APICallback, Callback, CallOptions, Descriptors, ClientOptions, PaginationCallback, PaginationResponse} from 'google-gax'; +import * as path from 'path'; + +import { Transform } from 'stream'; +import * as protosTypes from '../../protos/protos'; +import * as gapicConfig from './uptime_check_service_client_config.json'; + +const version = require('../../../package.json').version; + +/** + * The UptimeCheckService API is used to manage (list, create, delete, edit) + * Uptime check configurations in the Stackdriver Monitoring product. An Uptime + * check is a piece of configuration that determines which resources and + * services to monitor for availability. These configurations can also be + * configured interactively by navigating to the [Cloud Console] + * (http://console.cloud.google.com), selecting the appropriate project, + * clicking on "Monitoring" on the left-hand side to navigate to Stackdriver, + * and then clicking on "Uptime". + * @class + * @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; + auth: gax.GoogleAuth; + uptimeCheckServiceStub: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of UptimeCheckServiceClient. + * + * @param {object} [options] - The configuration object. See the subsequent + * parameters for more details. + * @param {object} [options.credentials] - Credentials object. + * @param {string} [options.credentials.client_email] + * @param {string} [options.credentials.private_key] + * @param {string} [options.email] - Account email address. Required when + * using a .pem or .p12 keyFilename. + * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or + * .p12 key downloaded from the Google Developers Console. If you provide + * a path to a JSON file, the projectId option below is not necessary. + * NOTE: .pem and .p12 require you to specify options.email as well. + * @param {number} [options.port] - The port on which to connect to + * the remote host. + * @param {string} [options.projectId] - The project ID from the Google + * Developer's Console, e.g. 'grape-spaceship-123'. We will also check + * the environment variable GCLOUD_PROJECT for your project ID. If your + * app is running in an environment which supports + * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, + * your project ID will be detected automatically. + * @param {function} [options.promise] - Custom promise module to use instead + * of native Promises. + * @param {string} [options.apiEndpoint] - The domain name of the + * API remote host. + */ + + constructor(opts?: ClientOptions) { + // Ensure that options include the service address and port. + const staticMembers = this.constructor as typeof UptimeCheckServiceClient; + const servicePath = opts && opts.servicePath ? + opts.servicePath : + ((opts && opts.apiEndpoint) ? opts.apiEndpoint : + staticMembers.servicePath); + const port = opts && opts.port ? opts.port : staticMembers.port; + + if (!opts) { + opts = {servicePath, port}; + } + opts.servicePath = opts.servicePath || servicePath; + opts.port = opts.port || port; + opts.clientConfig = opts.clientConfig || {}; + + const isBrowser = (typeof window !== 'undefined'); + if (isBrowser){ + opts.fallback = true; + } + // If we are in browser, we are already using fallback because of the + // "browser" field in package.json. + // But if we were explicitly requested to use fallback, let's do it now. + const gaxModule = !isBrowser && opts.fallback ? gax.fallback : gax; + + // Create a `gaxGrpc` object, with any grpc-specific options + // sent to the client. + opts.scopes = (this.constructor as typeof UptimeCheckServiceClient).scopes; + const gaxGrpc = new gaxModule.GrpcClient(opts); + + // Save the auth object to the client, for use by other methods. + this.auth = (gaxGrpc.auth as gax.GoogleAuth); + + // Determine the client header string. + const clientHeader = [ + `gax/${gaxModule.version}`, + `gapic/${version}`, + ]; + if (typeof process !== 'undefined' && 'versions' in process) { + clientHeader.push(`gl-node/${process.versions.node}`); + } else { + clientHeader.push(`gl-web/${gaxModule.version}`); + } + if (!opts.fallback) { + clientHeader.push(`grpc/${gaxGrpc.grpcVersion}`); + } + if (opts.libName && opts.libVersion) { + clientHeader.push(`${opts.libName}/${opts.libVersion}`); + } + // Load the applicable protos. + // For Node.js, pass the path to JSON proto file. + // For browsers, pass the JSON content. + + const nodejsProtoPath = path.join(__dirname, '..', '..', 'protos', 'protos.json'); + const protos = gaxGrpc.loadProto( + opts.fallback ? + 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 = { + projectAlertPolicyPathTemplate: new gaxModule.PathTemplate( + 'projects/{project}/alertPolicies/{alert_policy}' + ), + organizationAlertPolicyPathTemplate: new gaxModule.PathTemplate( + 'organizations/{organization}/alertPolicies/{alert_policy}' + ), + folderAlertPolicyPathTemplate: new gaxModule.PathTemplate( + 'folders/{folder}/alertPolicies/{alert_policy}' + ), + PathTemplate: new gaxModule.PathTemplate( + '*' + ), + projectGroupPathTemplate: new gaxModule.PathTemplate( + 'projects/{project}/groups/{group}' + ), + organizationGroupPathTemplate: new gaxModule.PathTemplate( + 'organizations/{organization}/groups/{group}' + ), + folderGroupPathTemplate: new gaxModule.PathTemplate( + 'folders/{folder}/groups/{group}' + ), + projectChannelDescriptorPathTemplate: new gaxModule.PathTemplate( + 'projects/{project}/notificationChannelDescriptors/{channel_descriptor}' + ), + organizationChannelDescriptorPathTemplate: new gaxModule.PathTemplate( + 'organizations/{organization}/notificationChannelDescriptors/{channel_descriptor}' + ), + folderChannelDescriptorPathTemplate: new gaxModule.PathTemplate( + 'folders/{folder}/notificationChannelDescriptors/{channel_descriptor}' + ), + projectNotificationChannelPathTemplate: new gaxModule.PathTemplate( + 'projects/{project}/notificationChannels/{notification_channel}' + ), + organizationNotificationChannelPathTemplate: new gaxModule.PathTemplate( + 'organizations/{organization}/notificationChannels/{notification_channel}' + ), + folderNotificationChannelPathTemplate: new gaxModule.PathTemplate( + 'folders/{folder}/notificationChannels/{notification_channel}' + ), + projectServicePathTemplate: new gaxModule.PathTemplate( + 'projects/{project}/services/{service}' + ), + organizationServicePathTemplate: new gaxModule.PathTemplate( + 'organizations/{organization}/services/{service}' + ), + folderServicePathTemplate: new gaxModule.PathTemplate( + 'folders/{folder}/services/{service}' + ), + projectServiceServiceLevelObjectivePathTemplate: new gaxModule.PathTemplate( + 'projects/{project}/services/{service}/serviceLevelObjectives/{service_level_objective}' + ), + organizationServiceServiceLevelObjectivePathTemplate: new gaxModule.PathTemplate( + 'organizations/{organization}/services/{service}/serviceLevelObjectives/{service_level_objective}' + ), + folderServiceServiceLevelObjectivePathTemplate: new gaxModule.PathTemplate( + 'folders/{folder}/services/{service}/serviceLevelObjectives/{service_level_objective}' + ), + projectUptimeCheckConfigPathTemplate: new gaxModule.PathTemplate( + 'projects/{project}/uptimeCheckConfigs/{uptime_check_config}' + ), + organizationUptimeCheckConfigPathTemplate: new gaxModule.PathTemplate( + 'organizations/{organization}/uptimeCheckConfigs/{uptime_check_config}' + ), + folderUptimeCheckConfigPathTemplate: new gaxModule.PathTemplate( + 'folders/{folder}/uptimeCheckConfigs/{uptime_check_config}' + ), + }; + + // 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 = { + listUptimeCheckConfigs: + new gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'uptimeCheckConfigs'), + listUptimeCheckIps: + new gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'uptimeCheckIps') + }; + + // Put together the default options sent with requests. + const defaults = gaxGrpc.constructSettings( + 'google.monitoring.v3.UptimeCheckService', gapicConfig as gax.ClientConfig, + opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + + // Set up a dictionary of "inner API calls"; the core implementation + // of calling the API is handled in `google-gax`, with this code + // merely providing the destination and request information. + this._innerApiCalls = {}; + + // Put together the "service stub" for + // google.monitoring.v3.UptimeCheckService. + this.uptimeCheckServiceStub = gaxGrpc.createStub( + opts.fallback ? + (protos as protobuf.Root).lookupService('google.monitoring.v3.UptimeCheckService') : + // tslint:disable-next-line no-any + (protos as any).google.monitoring.v3.UptimeCheckService, + opts) as Promise<{[method: string]: Function}>; + + // Iterate over each of the methods that the service provides + // and create an API call method for each. + const uptimeCheckServiceStubMethods = + ['listUptimeCheckConfigs', 'getUptimeCheckConfig', 'createUptimeCheckConfig', 'updateUptimeCheckConfig', 'deleteUptimeCheckConfig', 'listUptimeCheckIps']; + + for (const methodName of uptimeCheckServiceStubMethods) { + const innerCallPromise = this.uptimeCheckServiceStub.then( + stub => (...args: Array<{}>) => { + if (this._terminated) { + return Promise.reject('The client has already been closed.'); + } + return stub[methodName].apply(stub, args); + }, + (err: Error|null|undefined) => () => { + throw err; + }); + + const apiCall = gaxModule.createApiCall( + innerCallPromise, + defaults[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); + }; + } + } + + /** + * The DNS address for this API service. + */ + static get servicePath() { + return 'monitoring.googleapis.com'; + } + + /** + * The DNS address for this API service - same as servicePath(), + * exists for compatibility reasons. + */ + static get apiEndpoint() { + return 'monitoring.googleapis.com'; + } + + /** + * The port for this API service. + */ + static get port() { + return 443; + } + + /** + * The scopes needed to make gRPC calls for every method defined + * in this service. + */ + static get scopes() { + return [ + 'https://www.googleapis.com/auth/cloud-platform', + 'https://www.googleapis.com/auth/monitoring', + 'https://www.googleapis.com/auth/monitoring.read' + ]; + } + + getProjectId(): Promise; + getProjectId(callback: Callback): void; + /** + * Return the project ID used by this class. + * @param {function(Error, string)} callback - the callback to + * be called with the current project Id. + */ + getProjectId(callback?: Callback): + Promise|void { + if (callback) { + this.auth.getProjectId(callback); + return; + } + return this.auth.getProjectId(); + } + + // ------------------- + // -- Service calls -- + // ------------------- + getUptimeCheckConfig( + request: protosTypes.google.monitoring.v3.IGetUptimeCheckConfigRequest, + options?: gax.CallOptions): + Promise<[ + protosTypes.google.monitoring.v3.IUptimeCheckConfig, + protosTypes.google.monitoring.v3.IGetUptimeCheckConfigRequest|undefined, {}|undefined + ]>; + getUptimeCheckConfig( + request: protosTypes.google.monitoring.v3.IGetUptimeCheckConfigRequest, + options: gax.CallOptions, + callback: Callback< + protosTypes.google.monitoring.v3.IUptimeCheckConfig, + protosTypes.google.monitoring.v3.IGetUptimeCheckConfigRequest|undefined, + {}|undefined>): void; +/** + * Gets a single Uptime check configuration. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The Uptime check configuration to retrieve. The format + * is `projects/[PROJECT_ID]/uptimeCheckConfigs/[UPTIME_CHECK_ID]`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [UptimeCheckConfig]{@link google.monitoring.v3.UptimeCheckConfig}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ + getUptimeCheckConfig( + request: protosTypes.google.monitoring.v3.IGetUptimeCheckConfigRequest, + optionsOrCallback?: gax.CallOptions|Callback< + protosTypes.google.monitoring.v3.IUptimeCheckConfig, + protosTypes.google.monitoring.v3.IGetUptimeCheckConfigRequest|undefined, {}|undefined>, + callback?: Callback< + protosTypes.google.monitoring.v3.IUptimeCheckConfig, + protosTypes.google.monitoring.v3.IGetUptimeCheckConfigRequest|undefined, + {}|undefined>): + Promise<[ + protosTypes.google.monitoring.v3.IUptimeCheckConfig, + protosTypes.google.monitoring.v3.IGetUptimeCheckConfigRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as gax.CallOptions; + } + 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 || '', + }); + return this._innerApiCalls.getUptimeCheckConfig(request, options, callback); + } + createUptimeCheckConfig( + request: protosTypes.google.monitoring.v3.ICreateUptimeCheckConfigRequest, + options?: gax.CallOptions): + Promise<[ + protosTypes.google.monitoring.v3.IUptimeCheckConfig, + protosTypes.google.monitoring.v3.ICreateUptimeCheckConfigRequest|undefined, {}|undefined + ]>; + createUptimeCheckConfig( + request: protosTypes.google.monitoring.v3.ICreateUptimeCheckConfigRequest, + options: gax.CallOptions, + callback: Callback< + protosTypes.google.monitoring.v3.IUptimeCheckConfig, + protosTypes.google.monitoring.v3.ICreateUptimeCheckConfigRequest|undefined, + {}|undefined>): void; +/** + * Creates a new Uptime check configuration. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The project in which to create the Uptime check. The format + * is `projects/[PROJECT_ID]`. + * @param {google.monitoring.v3.UptimeCheckConfig} request.uptimeCheckConfig + * Required. The new Uptime check configuration. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [UptimeCheckConfig]{@link google.monitoring.v3.UptimeCheckConfig}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ + createUptimeCheckConfig( + request: protosTypes.google.monitoring.v3.ICreateUptimeCheckConfigRequest, + optionsOrCallback?: gax.CallOptions|Callback< + protosTypes.google.monitoring.v3.IUptimeCheckConfig, + protosTypes.google.monitoring.v3.ICreateUptimeCheckConfigRequest|undefined, {}|undefined>, + callback?: Callback< + protosTypes.google.monitoring.v3.IUptimeCheckConfig, + protosTypes.google.monitoring.v3.ICreateUptimeCheckConfigRequest|undefined, + {}|undefined>): + Promise<[ + protosTypes.google.monitoring.v3.IUptimeCheckConfig, + protosTypes.google.monitoring.v3.ICreateUptimeCheckConfigRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as gax.CallOptions; + } + 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 || '', + }); + return this._innerApiCalls.createUptimeCheckConfig(request, options, callback); + } + updateUptimeCheckConfig( + request: protosTypes.google.monitoring.v3.IUpdateUptimeCheckConfigRequest, + options?: gax.CallOptions): + Promise<[ + protosTypes.google.monitoring.v3.IUptimeCheckConfig, + protosTypes.google.monitoring.v3.IUpdateUptimeCheckConfigRequest|undefined, {}|undefined + ]>; + updateUptimeCheckConfig( + request: protosTypes.google.monitoring.v3.IUpdateUptimeCheckConfigRequest, + options: gax.CallOptions, + callback: Callback< + protosTypes.google.monitoring.v3.IUptimeCheckConfig, + protosTypes.google.monitoring.v3.IUpdateUptimeCheckConfigRequest|undefined, + {}|undefined>): void; +/** + * Updates an Uptime check configuration. You can either replace the entire + * configuration with a new one or replace only certain fields in the current + * configuration by specifying the fields to be updated via `updateMask`. + * Returns the updated configuration. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.protobuf.FieldMask} request.updateMask + * Optional. If present, only the listed fields in the current Uptime check + * configuration are updated with values from the new configuration. If this + * field is empty, then the current configuration is completely replaced with + * the new configuration. + * @param {google.monitoring.v3.UptimeCheckConfig} request.uptimeCheckConfig + * Required. If an `updateMask` has been specified, this field gives + * the values for the set of fields mentioned in the `updateMask`. If an + * `updateMask` has not been given, this Uptime check configuration replaces + * the current configuration. If a field is mentioned in `updateMask` but + * the corresonding field is omitted in this partial Uptime check + * configuration, it has the effect of deleting/clearing the field from the + * configuration on the server. + * + * The following fields can be updated: `display_name`, + * `http_check`, `tcp_check`, `timeout`, `content_matchers`, and + * `selected_regions`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [UptimeCheckConfig]{@link google.monitoring.v3.UptimeCheckConfig}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ + updateUptimeCheckConfig( + request: protosTypes.google.monitoring.v3.IUpdateUptimeCheckConfigRequest, + optionsOrCallback?: gax.CallOptions|Callback< + protosTypes.google.monitoring.v3.IUptimeCheckConfig, + protosTypes.google.monitoring.v3.IUpdateUptimeCheckConfigRequest|undefined, {}|undefined>, + callback?: Callback< + protosTypes.google.monitoring.v3.IUptimeCheckConfig, + protosTypes.google.monitoring.v3.IUpdateUptimeCheckConfigRequest|undefined, + {}|undefined>): + Promise<[ + protosTypes.google.monitoring.v3.IUptimeCheckConfig, + protosTypes.google.monitoring.v3.IUpdateUptimeCheckConfigRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as gax.CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'uptime_check_config.name': request.uptimeCheckConfig!.name || '', + }); + return this._innerApiCalls.updateUptimeCheckConfig(request, options, callback); + } + deleteUptimeCheckConfig( + request: protosTypes.google.monitoring.v3.IDeleteUptimeCheckConfigRequest, + options?: gax.CallOptions): + Promise<[ + protosTypes.google.protobuf.IEmpty, + protosTypes.google.monitoring.v3.IDeleteUptimeCheckConfigRequest|undefined, {}|undefined + ]>; + deleteUptimeCheckConfig( + request: protosTypes.google.monitoring.v3.IDeleteUptimeCheckConfigRequest, + options: gax.CallOptions, + callback: Callback< + protosTypes.google.protobuf.IEmpty, + protosTypes.google.monitoring.v3.IDeleteUptimeCheckConfigRequest|undefined, + {}|undefined>): void; +/** + * Deletes an Uptime check configuration. Note that this method will fail + * if the Uptime check configuration is referenced by an alert policy or + * other dependent configs that would be rendered invalid by the deletion. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The Uptime check configuration to delete. The format + * is `projects/[PROJECT_ID]/uptimeCheckConfigs/[UPTIME_CHECK_ID]`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ + deleteUptimeCheckConfig( + request: protosTypes.google.monitoring.v3.IDeleteUptimeCheckConfigRequest, + optionsOrCallback?: gax.CallOptions|Callback< + protosTypes.google.protobuf.IEmpty, + protosTypes.google.monitoring.v3.IDeleteUptimeCheckConfigRequest|undefined, {}|undefined>, + callback?: Callback< + protosTypes.google.protobuf.IEmpty, + protosTypes.google.monitoring.v3.IDeleteUptimeCheckConfigRequest|undefined, + {}|undefined>): + Promise<[ + protosTypes.google.protobuf.IEmpty, + protosTypes.google.monitoring.v3.IDeleteUptimeCheckConfigRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as gax.CallOptions; + } + 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 || '', + }); + return this._innerApiCalls.deleteUptimeCheckConfig(request, options, callback); + } + + listUptimeCheckConfigs( + request: protosTypes.google.monitoring.v3.IListUptimeCheckConfigsRequest, + options?: gax.CallOptions): + Promise<[ + protosTypes.google.monitoring.v3.IUptimeCheckConfig[], + protosTypes.google.monitoring.v3.IListUptimeCheckConfigsRequest|null, + protosTypes.google.monitoring.v3.IListUptimeCheckConfigsResponse + ]>; + listUptimeCheckConfigs( + request: protosTypes.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>): void; +/** + * Lists the existing valid Uptime check configurations for the project + * (leaving out any invalid configurations). + * + * @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 {Promise} - The promise which resolves to an array. + * The first element of the array is Array of [UptimeCheckConfig]{@link google.monitoring.v3.UptimeCheckConfig}. + * The client library support auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * + * When autoPaginate: false is specified through options, the array has three elements. + * The first element is Array of [UptimeCheckConfig]{@link google.monitoring.v3.UptimeCheckConfig} that corresponds to + * the one page received from the API server. + * If the second element is not null it contains the request object of type [ListUptimeCheckConfigsRequest]{@link google.monitoring.v3.ListUptimeCheckConfigsRequest} + * that can be used to obtain the next page of the results. + * If it is null, the next page does not exist. + * The third element contains the raw response received from the API server. Its type is + * [ListUptimeCheckConfigsResponse]{@link google.monitoring.v3.ListUptimeCheckConfigsResponse}. + * + * The promise has a method named "cancel" which cancels the ongoing API call. + */ + listUptimeCheckConfigs( + request: protosTypes.google.monitoring.v3.IListUptimeCheckConfigsRequest, + optionsOrCallback?: gax.CallOptions|Callback< + protosTypes.google.monitoring.v3.IUptimeCheckConfig[], + protosTypes.google.monitoring.v3.IListUptimeCheckConfigsRequest|null, + protosTypes.google.monitoring.v3.IListUptimeCheckConfigsResponse>, + callback?: Callback< + protosTypes.google.monitoring.v3.IUptimeCheckConfig[], + protosTypes.google.monitoring.v3.IListUptimeCheckConfigsRequest|null, + protosTypes.google.monitoring.v3.IListUptimeCheckConfigsResponse>): + Promise<[ + protosTypes.google.monitoring.v3.IUptimeCheckConfig[], + protosTypes.google.monitoring.v3.IListUptimeCheckConfigsRequest|null, + protosTypes.google.monitoring.v3.IListUptimeCheckConfigsResponse + ]>|void { + request = request || {}; + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as gax.CallOptions; + } + 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 || '', + }); + return this._innerApiCalls.listUptimeCheckConfigs(request, options, callback); + } + +/** + * Equivalent to {@link listUptimeCheckConfigs}, but returns a NodeJS Stream object. + * + * This fetches the paged responses for {@link listUptimeCheckConfigs} continuously + * and invokes the callback registered for 'data' event for each element in the + * responses. + * + * The returned object has 'end' method when no more elements are required. + * + * autoPaginate option will be ignored. + * + * @see {@link https://nodejs.org/api/stream.html} + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The 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 {Stream} + * An object stream which emits an object representing [UptimeCheckConfig]{@link google.monitoring.v3.UptimeCheckConfig} on 'data' event. + */ + listUptimeCheckConfigsStream( + request?: protosTypes.google.monitoring.v3.IListUptimeCheckConfigsRequest, + options?: gax.CallOptions | {}): + Transform{ + request = request || {}; + const callSettings = new gax.CallSettings(options); + return this._descriptors.page.listUptimeCheckConfigs.createStream( + this._innerApiCalls.listUptimeCheckConfigs as gax.GaxCall, + request, + callSettings + ); + } + listUptimeCheckIps( + request: protosTypes.google.monitoring.v3.IListUptimeCheckIpsRequest, + options?: gax.CallOptions): + Promise<[ + protosTypes.google.monitoring.v3.IUptimeCheckIp[], + protosTypes.google.monitoring.v3.IListUptimeCheckIpsRequest|null, + protosTypes.google.monitoring.v3.IListUptimeCheckIpsResponse + ]>; + listUptimeCheckIps( + request: protosTypes.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>): void; +/** + * Returns the list of IP addresses that checkers run from + * + * @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 {Promise} - The promise which resolves to an array. + * The first element of the array is Array of [UptimeCheckIp]{@link google.monitoring.v3.UptimeCheckIp}. + * The client library support auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * + * When autoPaginate: false is specified through options, the array has three elements. + * The first element is Array of [UptimeCheckIp]{@link google.monitoring.v3.UptimeCheckIp} that corresponds to + * the one page received from the API server. + * If the second element is not null it contains the request object of type [ListUptimeCheckIpsRequest]{@link google.monitoring.v3.ListUptimeCheckIpsRequest} + * that can be used to obtain the next page of the results. + * If it is null, the next page does not exist. + * The third element contains the raw response received from the API server. Its type is + * [ListUptimeCheckIpsResponse]{@link google.monitoring.v3.ListUptimeCheckIpsResponse}. + * + * The promise has a method named "cancel" which cancels the ongoing API call. + */ + listUptimeCheckIps( + request: protosTypes.google.monitoring.v3.IListUptimeCheckIpsRequest, + optionsOrCallback?: gax.CallOptions|Callback< + protosTypes.google.monitoring.v3.IUptimeCheckIp[], + protosTypes.google.monitoring.v3.IListUptimeCheckIpsRequest|null, + protosTypes.google.monitoring.v3.IListUptimeCheckIpsResponse>, + callback?: Callback< + protosTypes.google.monitoring.v3.IUptimeCheckIp[], + protosTypes.google.monitoring.v3.IListUptimeCheckIpsRequest|null, + protosTypes.google.monitoring.v3.IListUptimeCheckIpsResponse>): + Promise<[ + protosTypes.google.monitoring.v3.IUptimeCheckIp[], + protosTypes.google.monitoring.v3.IListUptimeCheckIpsRequest|null, + protosTypes.google.monitoring.v3.IListUptimeCheckIpsResponse + ]>|void { + request = request || {}; + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as gax.CallOptions; + } + options = options || {}; + return this._innerApiCalls.listUptimeCheckIps(request, options, callback); + } + +/** + * Equivalent to {@link listUptimeCheckIps}, but returns a NodeJS Stream object. + * + * This fetches the paged responses for {@link listUptimeCheckIps} continuously + * and invokes the callback registered for 'data' event for each element in the + * responses. + * + * The returned object has 'end' method when no more elements are required. + * + * autoPaginate option will be ignored. + * + * @see {@link https://nodejs.org/api/stream.html} + * + * @param {Object} request + * The request object that will be sent. + * @param {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 {Stream} + * An object stream which emits an object representing [UptimeCheckIp]{@link google.monitoring.v3.UptimeCheckIp} on 'data' event. + */ + listUptimeCheckIpsStream( + request?: protosTypes.google.monitoring.v3.IListUptimeCheckIpsRequest, + options?: gax.CallOptions | {}): + Transform{ + request = request || {}; + const callSettings = new gax.CallSettings(options); + return this._descriptors.page.listUptimeCheckIps.createStream( + this._innerApiCalls.listUptimeCheckIps as gax.GaxCall, + request, + callSettings + ); + } + // -------------------- + // -- Path templates -- + // -------------------- + + /** + * Return a fully-qualified projectAlertPolicy resource name string. + * + * @param {string} project + * @param {string} alert_policy + * @returns {string} Resource name string. + */ + projectAlertPolicyPath(project:string,alertPolicy:string) { + return this._pathTemplates.projectAlertPolicyPathTemplate.render({ + project: project, + alert_policy: alertPolicy, + }); + } + + /** + * Parse the project from ProjectAlertPolicy resource. + * + * @param {string} projectAlertPolicyName + * A fully-qualified path representing project_alert_policy resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectAlertPolicyName(projectAlertPolicyName: string) { + return this._pathTemplates.projectAlertPolicyPathTemplate.match(projectAlertPolicyName).project; + } + + /** + * Parse the alert_policy from ProjectAlertPolicy resource. + * + * @param {string} projectAlertPolicyName + * A fully-qualified path representing project_alert_policy resource. + * @returns {string} A string representing the alert_policy. + */ + matchAlertPolicyFromProjectAlertPolicyName(projectAlertPolicyName: string) { + return this._pathTemplates.projectAlertPolicyPathTemplate.match(projectAlertPolicyName).alert_policy; + } + + /** + * Return a fully-qualified organizationAlertPolicy resource name string. + * + * @param {string} organization + * @param {string} alert_policy + * @returns {string} Resource name string. + */ + organizationAlertPolicyPath(organization:string,alertPolicy:string) { + return this._pathTemplates.organizationAlertPolicyPathTemplate.render({ + organization: organization, + alert_policy: alertPolicy, + }); + } + + /** + * Parse the organization from OrganizationAlertPolicy resource. + * + * @param {string} organizationAlertPolicyName + * A fully-qualified path representing organization_alert_policy resource. + * @returns {string} A string representing the organization. + */ + matchOrganizationFromOrganizationAlertPolicyName(organizationAlertPolicyName: string) { + return this._pathTemplates.organizationAlertPolicyPathTemplate.match(organizationAlertPolicyName).organization; + } + + /** + * Parse the alert_policy from OrganizationAlertPolicy resource. + * + * @param {string} organizationAlertPolicyName + * A fully-qualified path representing organization_alert_policy resource. + * @returns {string} A string representing the alert_policy. + */ + matchAlertPolicyFromOrganizationAlertPolicyName(organizationAlertPolicyName: string) { + return this._pathTemplates.organizationAlertPolicyPathTemplate.match(organizationAlertPolicyName).alert_policy; + } + + /** + * Return a fully-qualified folderAlertPolicy resource name string. + * + * @param {string} folder + * @param {string} alert_policy + * @returns {string} Resource name string. + */ + folderAlertPolicyPath(folder:string,alertPolicy:string) { + return this._pathTemplates.folderAlertPolicyPathTemplate.render({ + folder: folder, + alert_policy: alertPolicy, + }); + } + + /** + * Parse the folder from FolderAlertPolicy resource. + * + * @param {string} folderAlertPolicyName + * A fully-qualified path representing folder_alert_policy resource. + * @returns {string} A string representing the folder. + */ + matchFolderFromFolderAlertPolicyName(folderAlertPolicyName: string) { + return this._pathTemplates.folderAlertPolicyPathTemplate.match(folderAlertPolicyName).folder; + } + + /** + * Parse the alert_policy from FolderAlertPolicy resource. + * + * @param {string} folderAlertPolicyName + * A fully-qualified path representing folder_alert_policy resource. + * @returns {string} A string representing the alert_policy. + */ + matchAlertPolicyFromFolderAlertPolicyName(folderAlertPolicyName: string) { + return this._pathTemplates.folderAlertPolicyPathTemplate.match(folderAlertPolicyName).alert_policy; + } + + /** + * Return a fully-qualified resource name string. + * + * @returns {string} Resource name string. + */ + Path() { + return this._pathTemplates.PathTemplate.render({ + }); + } + + /** + * Return a fully-qualified projectGroup resource name string. + * + * @param {string} project + * @param {string} group + * @returns {string} Resource name string. + */ + projectGroupPath(project:string,group:string) { + return this._pathTemplates.projectGroupPathTemplate.render({ + project: project, + group: group, + }); + } + + /** + * Parse the project from ProjectGroup resource. + * + * @param {string} projectGroupName + * A fully-qualified path representing project_group resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectGroupName(projectGroupName: string) { + return this._pathTemplates.projectGroupPathTemplate.match(projectGroupName).project; + } + + /** + * Parse the group from ProjectGroup resource. + * + * @param {string} projectGroupName + * A fully-qualified path representing project_group resource. + * @returns {string} A string representing the group. + */ + matchGroupFromProjectGroupName(projectGroupName: string) { + return this._pathTemplates.projectGroupPathTemplate.match(projectGroupName).group; + } + + /** + * Return a fully-qualified organizationGroup resource name string. + * + * @param {string} organization + * @param {string} group + * @returns {string} Resource name string. + */ + organizationGroupPath(organization:string,group:string) { + return this._pathTemplates.organizationGroupPathTemplate.render({ + organization: organization, + group: group, + }); + } + + /** + * Parse the organization from OrganizationGroup resource. + * + * @param {string} organizationGroupName + * A fully-qualified path representing organization_group resource. + * @returns {string} A string representing the organization. + */ + matchOrganizationFromOrganizationGroupName(organizationGroupName: string) { + return this._pathTemplates.organizationGroupPathTemplate.match(organizationGroupName).organization; + } + + /** + * Parse the group from OrganizationGroup resource. + * + * @param {string} organizationGroupName + * A fully-qualified path representing organization_group resource. + * @returns {string} A string representing the group. + */ + matchGroupFromOrganizationGroupName(organizationGroupName: string) { + return this._pathTemplates.organizationGroupPathTemplate.match(organizationGroupName).group; + } + + /** + * Return a fully-qualified folderGroup resource name string. + * + * @param {string} folder + * @param {string} group + * @returns {string} Resource name string. + */ + folderGroupPath(folder:string,group:string) { + return this._pathTemplates.folderGroupPathTemplate.render({ + folder: folder, + group: group, + }); + } + + /** + * Parse the folder from FolderGroup resource. + * + * @param {string} folderGroupName + * A fully-qualified path representing folder_group resource. + * @returns {string} A string representing the folder. + */ + matchFolderFromFolderGroupName(folderGroupName: string) { + return this._pathTemplates.folderGroupPathTemplate.match(folderGroupName).folder; + } + + /** + * Parse the group from FolderGroup resource. + * + * @param {string} folderGroupName + * A fully-qualified path representing folder_group resource. + * @returns {string} A string representing the group. + */ + matchGroupFromFolderGroupName(folderGroupName: string) { + return this._pathTemplates.folderGroupPathTemplate.match(folderGroupName).group; + } + + /** + * Return a fully-qualified projectChannelDescriptor resource name string. + * + * @param {string} project + * @param {string} channel_descriptor + * @returns {string} Resource name string. + */ + projectChannelDescriptorPath(project:string,channelDescriptor:string) { + return this._pathTemplates.projectChannelDescriptorPathTemplate.render({ + project: project, + channel_descriptor: channelDescriptor, + }); + } + + /** + * Parse the project from ProjectChannelDescriptor resource. + * + * @param {string} projectChannelDescriptorName + * A fully-qualified path representing project_channel_descriptor resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectChannelDescriptorName(projectChannelDescriptorName: string) { + return this._pathTemplates.projectChannelDescriptorPathTemplate.match(projectChannelDescriptorName).project; + } + + /** + * Parse the channel_descriptor from ProjectChannelDescriptor resource. + * + * @param {string} projectChannelDescriptorName + * A fully-qualified path representing project_channel_descriptor resource. + * @returns {string} A string representing the channel_descriptor. + */ + matchChannelDescriptorFromProjectChannelDescriptorName(projectChannelDescriptorName: string) { + return this._pathTemplates.projectChannelDescriptorPathTemplate.match(projectChannelDescriptorName).channel_descriptor; + } + + /** + * Return a fully-qualified organizationChannelDescriptor resource name string. + * + * @param {string} organization + * @param {string} channel_descriptor + * @returns {string} Resource name string. + */ + organizationChannelDescriptorPath(organization:string,channelDescriptor:string) { + return this._pathTemplates.organizationChannelDescriptorPathTemplate.render({ + organization: organization, + channel_descriptor: channelDescriptor, + }); + } + + /** + * Parse the organization from OrganizationChannelDescriptor resource. + * + * @param {string} organizationChannelDescriptorName + * A fully-qualified path representing organization_channel_descriptor resource. + * @returns {string} A string representing the organization. + */ + matchOrganizationFromOrganizationChannelDescriptorName(organizationChannelDescriptorName: string) { + return this._pathTemplates.organizationChannelDescriptorPathTemplate.match(organizationChannelDescriptorName).organization; + } + + /** + * Parse the channel_descriptor from OrganizationChannelDescriptor resource. + * + * @param {string} organizationChannelDescriptorName + * A fully-qualified path representing organization_channel_descriptor resource. + * @returns {string} A string representing the channel_descriptor. + */ + matchChannelDescriptorFromOrganizationChannelDescriptorName(organizationChannelDescriptorName: string) { + return this._pathTemplates.organizationChannelDescriptorPathTemplate.match(organizationChannelDescriptorName).channel_descriptor; + } + + /** + * Return a fully-qualified folderChannelDescriptor resource name string. + * + * @param {string} folder + * @param {string} channel_descriptor + * @returns {string} Resource name string. + */ + folderChannelDescriptorPath(folder:string,channelDescriptor:string) { + return this._pathTemplates.folderChannelDescriptorPathTemplate.render({ + folder: folder, + channel_descriptor: channelDescriptor, + }); + } + + /** + * Parse the folder from FolderChannelDescriptor resource. + * + * @param {string} folderChannelDescriptorName + * A fully-qualified path representing folder_channel_descriptor resource. + * @returns {string} A string representing the folder. + */ + matchFolderFromFolderChannelDescriptorName(folderChannelDescriptorName: string) { + return this._pathTemplates.folderChannelDescriptorPathTemplate.match(folderChannelDescriptorName).folder; + } + + /** + * Parse the channel_descriptor from FolderChannelDescriptor resource. + * + * @param {string} folderChannelDescriptorName + * A fully-qualified path representing folder_channel_descriptor resource. + * @returns {string} A string representing the channel_descriptor. + */ + matchChannelDescriptorFromFolderChannelDescriptorName(folderChannelDescriptorName: string) { + return this._pathTemplates.folderChannelDescriptorPathTemplate.match(folderChannelDescriptorName).channel_descriptor; + } + + /** + * Return a fully-qualified projectNotificationChannel resource name string. + * + * @param {string} project + * @param {string} notification_channel + * @returns {string} Resource name string. + */ + projectNotificationChannelPath(project:string,notificationChannel:string) { + return this._pathTemplates.projectNotificationChannelPathTemplate.render({ + project: project, + notification_channel: notificationChannel, + }); + } + + /** + * Parse the project from ProjectNotificationChannel resource. + * + * @param {string} projectNotificationChannelName + * A fully-qualified path representing project_notification_channel resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectNotificationChannelName(projectNotificationChannelName: string) { + return this._pathTemplates.projectNotificationChannelPathTemplate.match(projectNotificationChannelName).project; + } + + /** + * Parse the notification_channel from ProjectNotificationChannel resource. + * + * @param {string} projectNotificationChannelName + * A fully-qualified path representing project_notification_channel resource. + * @returns {string} A string representing the notification_channel. + */ + matchNotificationChannelFromProjectNotificationChannelName(projectNotificationChannelName: string) { + return this._pathTemplates.projectNotificationChannelPathTemplate.match(projectNotificationChannelName).notification_channel; + } + + /** + * Return a fully-qualified organizationNotificationChannel resource name string. + * + * @param {string} organization + * @param {string} notification_channel + * @returns {string} Resource name string. + */ + organizationNotificationChannelPath(organization:string,notificationChannel:string) { + return this._pathTemplates.organizationNotificationChannelPathTemplate.render({ + organization: organization, + notification_channel: notificationChannel, + }); + } + + /** + * Parse the organization from OrganizationNotificationChannel resource. + * + * @param {string} organizationNotificationChannelName + * A fully-qualified path representing organization_notification_channel resource. + * @returns {string} A string representing the organization. + */ + matchOrganizationFromOrganizationNotificationChannelName(organizationNotificationChannelName: string) { + return this._pathTemplates.organizationNotificationChannelPathTemplate.match(organizationNotificationChannelName).organization; + } + + /** + * Parse the notification_channel from OrganizationNotificationChannel resource. + * + * @param {string} organizationNotificationChannelName + * A fully-qualified path representing organization_notification_channel resource. + * @returns {string} A string representing the notification_channel. + */ + matchNotificationChannelFromOrganizationNotificationChannelName(organizationNotificationChannelName: string) { + return this._pathTemplates.organizationNotificationChannelPathTemplate.match(organizationNotificationChannelName).notification_channel; + } + + /** + * Return a fully-qualified folderNotificationChannel resource name string. + * + * @param {string} folder + * @param {string} notification_channel + * @returns {string} Resource name string. + */ + folderNotificationChannelPath(folder:string,notificationChannel:string) { + return this._pathTemplates.folderNotificationChannelPathTemplate.render({ + folder: folder, + notification_channel: notificationChannel, + }); + } + + /** + * Parse the folder from FolderNotificationChannel resource. + * + * @param {string} folderNotificationChannelName + * A fully-qualified path representing folder_notification_channel resource. + * @returns {string} A string representing the folder. + */ + matchFolderFromFolderNotificationChannelName(folderNotificationChannelName: string) { + return this._pathTemplates.folderNotificationChannelPathTemplate.match(folderNotificationChannelName).folder; + } + + /** + * Parse the notification_channel from FolderNotificationChannel resource. + * + * @param {string} folderNotificationChannelName + * A fully-qualified path representing folder_notification_channel resource. + * @returns {string} A string representing the notification_channel. + */ + matchNotificationChannelFromFolderNotificationChannelName(folderNotificationChannelName: string) { + return this._pathTemplates.folderNotificationChannelPathTemplate.match(folderNotificationChannelName).notification_channel; + } + + /** + * Return a fully-qualified projectService resource name string. + * + * @param {string} project + * @param {string} service + * @returns {string} Resource name string. + */ + projectServicePath(project:string,service:string) { + return this._pathTemplates.projectServicePathTemplate.render({ + project: project, + service: service, + }); + } + + /** + * Parse the project from ProjectService resource. + * + * @param {string} projectServiceName + * A fully-qualified path representing project_service resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectServiceName(projectServiceName: string) { + return this._pathTemplates.projectServicePathTemplate.match(projectServiceName).project; + } + + /** + * Parse the service from ProjectService resource. + * + * @param {string} projectServiceName + * A fully-qualified path representing project_service resource. + * @returns {string} A string representing the service. + */ + matchServiceFromProjectServiceName(projectServiceName: string) { + return this._pathTemplates.projectServicePathTemplate.match(projectServiceName).service; + } + + /** + * Return a fully-qualified organizationService resource name string. + * + * @param {string} organization + * @param {string} service + * @returns {string} Resource name string. + */ + organizationServicePath(organization:string,service:string) { + return this._pathTemplates.organizationServicePathTemplate.render({ + organization: organization, + service: service, + }); + } + + /** + * Parse the organization from OrganizationService resource. + * + * @param {string} organizationServiceName + * A fully-qualified path representing organization_service resource. + * @returns {string} A string representing the organization. + */ + matchOrganizationFromOrganizationServiceName(organizationServiceName: string) { + return this._pathTemplates.organizationServicePathTemplate.match(organizationServiceName).organization; + } + + /** + * Parse the service from OrganizationService resource. + * + * @param {string} organizationServiceName + * A fully-qualified path representing organization_service resource. + * @returns {string} A string representing the service. + */ + matchServiceFromOrganizationServiceName(organizationServiceName: string) { + return this._pathTemplates.organizationServicePathTemplate.match(organizationServiceName).service; + } + + /** + * Return a fully-qualified folderService resource name string. + * + * @param {string} folder + * @param {string} service + * @returns {string} Resource name string. + */ + folderServicePath(folder:string,service:string) { + return this._pathTemplates.folderServicePathTemplate.render({ + folder: folder, + service: service, + }); + } + + /** + * Parse the folder from FolderService resource. + * + * @param {string} folderServiceName + * A fully-qualified path representing folder_service resource. + * @returns {string} A string representing the folder. + */ + matchFolderFromFolderServiceName(folderServiceName: string) { + return this._pathTemplates.folderServicePathTemplate.match(folderServiceName).folder; + } + + /** + * Parse the service from FolderService resource. + * + * @param {string} folderServiceName + * A fully-qualified path representing folder_service resource. + * @returns {string} A string representing the service. + */ + matchServiceFromFolderServiceName(folderServiceName: string) { + return this._pathTemplates.folderServicePathTemplate.match(folderServiceName).service; + } + + /** + * Return a fully-qualified projectServiceServiceLevelObjective resource name string. + * + * @param {string} project + * @param {string} service + * @param {string} service_level_objective + * @returns {string} Resource name string. + */ + projectServiceServiceLevelObjectivePath(project:string,service:string,serviceLevelObjective:string) { + return this._pathTemplates.projectServiceServiceLevelObjectivePathTemplate.render({ + project: project, + service: service, + service_level_objective: serviceLevelObjective, + }); + } + + /** + * Parse the project from ProjectServiceServiceLevelObjective resource. + * + * @param {string} projectServiceServiceLevelObjectiveName + * A fully-qualified path representing project_service_service_level_objective resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectServiceServiceLevelObjectiveName(projectServiceServiceLevelObjectiveName: string) { + return this._pathTemplates.projectServiceServiceLevelObjectivePathTemplate.match(projectServiceServiceLevelObjectiveName).project; + } + + /** + * Parse the service from ProjectServiceServiceLevelObjective resource. + * + * @param {string} projectServiceServiceLevelObjectiveName + * A fully-qualified path representing project_service_service_level_objective resource. + * @returns {string} A string representing the service. + */ + matchServiceFromProjectServiceServiceLevelObjectiveName(projectServiceServiceLevelObjectiveName: string) { + return this._pathTemplates.projectServiceServiceLevelObjectivePathTemplate.match(projectServiceServiceLevelObjectiveName).service; + } + + /** + * Parse the service_level_objective from ProjectServiceServiceLevelObjective resource. + * + * @param {string} projectServiceServiceLevelObjectiveName + * A fully-qualified path representing project_service_service_level_objective resource. + * @returns {string} A string representing the service_level_objective. + */ + matchServiceLevelObjectiveFromProjectServiceServiceLevelObjectiveName(projectServiceServiceLevelObjectiveName: string) { + return this._pathTemplates.projectServiceServiceLevelObjectivePathTemplate.match(projectServiceServiceLevelObjectiveName).service_level_objective; + } + + /** + * Return a fully-qualified organizationServiceServiceLevelObjective resource name string. + * + * @param {string} organization + * @param {string} service + * @param {string} service_level_objective + * @returns {string} Resource name string. + */ + organizationServiceServiceLevelObjectivePath(organization:string,service:string,serviceLevelObjective:string) { + return this._pathTemplates.organizationServiceServiceLevelObjectivePathTemplate.render({ + organization: organization, + service: service, + service_level_objective: serviceLevelObjective, + }); + } + + /** + * Parse the organization from OrganizationServiceServiceLevelObjective resource. + * + * @param {string} organizationServiceServiceLevelObjectiveName + * A fully-qualified path representing organization_service_service_level_objective resource. + * @returns {string} A string representing the organization. + */ + matchOrganizationFromOrganizationServiceServiceLevelObjectiveName(organizationServiceServiceLevelObjectiveName: string) { + return this._pathTemplates.organizationServiceServiceLevelObjectivePathTemplate.match(organizationServiceServiceLevelObjectiveName).organization; + } + + /** + * Parse the service from OrganizationServiceServiceLevelObjective resource. + * + * @param {string} organizationServiceServiceLevelObjectiveName + * A fully-qualified path representing organization_service_service_level_objective resource. + * @returns {string} A string representing the service. + */ + matchServiceFromOrganizationServiceServiceLevelObjectiveName(organizationServiceServiceLevelObjectiveName: string) { + return this._pathTemplates.organizationServiceServiceLevelObjectivePathTemplate.match(organizationServiceServiceLevelObjectiveName).service; + } + + /** + * Parse the service_level_objective from OrganizationServiceServiceLevelObjective resource. + * + * @param {string} organizationServiceServiceLevelObjectiveName + * A fully-qualified path representing organization_service_service_level_objective resource. + * @returns {string} A string representing the service_level_objective. + */ + matchServiceLevelObjectiveFromOrganizationServiceServiceLevelObjectiveName(organizationServiceServiceLevelObjectiveName: string) { + return this._pathTemplates.organizationServiceServiceLevelObjectivePathTemplate.match(organizationServiceServiceLevelObjectiveName).service_level_objective; + } + + /** + * Return a fully-qualified folderServiceServiceLevelObjective resource name string. + * + * @param {string} folder + * @param {string} service + * @param {string} service_level_objective + * @returns {string} Resource name string. + */ + folderServiceServiceLevelObjectivePath(folder:string,service:string,serviceLevelObjective:string) { + return this._pathTemplates.folderServiceServiceLevelObjectivePathTemplate.render({ + folder: folder, + service: service, + service_level_objective: serviceLevelObjective, + }); + } + + /** + * Parse the folder from FolderServiceServiceLevelObjective resource. + * + * @param {string} folderServiceServiceLevelObjectiveName + * A fully-qualified path representing folder_service_service_level_objective resource. + * @returns {string} A string representing the folder. + */ + matchFolderFromFolderServiceServiceLevelObjectiveName(folderServiceServiceLevelObjectiveName: string) { + return this._pathTemplates.folderServiceServiceLevelObjectivePathTemplate.match(folderServiceServiceLevelObjectiveName).folder; + } + + /** + * Parse the service from FolderServiceServiceLevelObjective resource. + * + * @param {string} folderServiceServiceLevelObjectiveName + * A fully-qualified path representing folder_service_service_level_objective resource. + * @returns {string} A string representing the service. + */ + matchServiceFromFolderServiceServiceLevelObjectiveName(folderServiceServiceLevelObjectiveName: string) { + return this._pathTemplates.folderServiceServiceLevelObjectivePathTemplate.match(folderServiceServiceLevelObjectiveName).service; + } + + /** + * Parse the service_level_objective from FolderServiceServiceLevelObjective resource. + * + * @param {string} folderServiceServiceLevelObjectiveName + * A fully-qualified path representing folder_service_service_level_objective resource. + * @returns {string} A string representing the service_level_objective. + */ + matchServiceLevelObjectiveFromFolderServiceServiceLevelObjectiveName(folderServiceServiceLevelObjectiveName: string) { + return this._pathTemplates.folderServiceServiceLevelObjectivePathTemplate.match(folderServiceServiceLevelObjectiveName).service_level_objective; + } + + /** + * Return a fully-qualified projectUptimeCheckConfig resource name string. + * + * @param {string} project + * @param {string} uptime_check_config + * @returns {string} Resource name string. + */ + projectUptimeCheckConfigPath(project:string,uptimeCheckConfig:string) { + return this._pathTemplates.projectUptimeCheckConfigPathTemplate.render({ + project: project, + uptime_check_config: uptimeCheckConfig, + }); + } + + /** + * Parse the project from ProjectUptimeCheckConfig resource. + * + * @param {string} projectUptimeCheckConfigName + * A fully-qualified path representing project_uptime_check_config resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectUptimeCheckConfigName(projectUptimeCheckConfigName: string) { + return this._pathTemplates.projectUptimeCheckConfigPathTemplate.match(projectUptimeCheckConfigName).project; + } + + /** + * Parse the uptime_check_config from ProjectUptimeCheckConfig resource. + * + * @param {string} projectUptimeCheckConfigName + * A fully-qualified path representing project_uptime_check_config resource. + * @returns {string} A string representing the uptime_check_config. + */ + matchUptimeCheckConfigFromProjectUptimeCheckConfigName(projectUptimeCheckConfigName: string) { + return this._pathTemplates.projectUptimeCheckConfigPathTemplate.match(projectUptimeCheckConfigName).uptime_check_config; + } + + /** + * Return a fully-qualified organizationUptimeCheckConfig resource name string. + * + * @param {string} organization + * @param {string} uptime_check_config + * @returns {string} Resource name string. + */ + organizationUptimeCheckConfigPath(organization:string,uptimeCheckConfig:string) { + return this._pathTemplates.organizationUptimeCheckConfigPathTemplate.render({ + organization: organization, + uptime_check_config: uptimeCheckConfig, + }); + } + + /** + * Parse the organization from OrganizationUptimeCheckConfig resource. + * + * @param {string} organizationUptimeCheckConfigName + * A fully-qualified path representing organization_uptime_check_config resource. + * @returns {string} A string representing the organization. + */ + matchOrganizationFromOrganizationUptimeCheckConfigName(organizationUptimeCheckConfigName: string) { + return this._pathTemplates.organizationUptimeCheckConfigPathTemplate.match(organizationUptimeCheckConfigName).organization; + } + + /** + * Parse the uptime_check_config from OrganizationUptimeCheckConfig resource. + * + * @param {string} organizationUptimeCheckConfigName + * A fully-qualified path representing organization_uptime_check_config resource. + * @returns {string} A string representing the uptime_check_config. + */ + matchUptimeCheckConfigFromOrganizationUptimeCheckConfigName(organizationUptimeCheckConfigName: string) { + return this._pathTemplates.organizationUptimeCheckConfigPathTemplate.match(organizationUptimeCheckConfigName).uptime_check_config; + } + + /** + * Return a fully-qualified folderUptimeCheckConfig resource name string. + * + * @param {string} folder + * @param {string} uptime_check_config + * @returns {string} Resource name string. + */ + folderUptimeCheckConfigPath(folder:string,uptimeCheckConfig:string) { + return this._pathTemplates.folderUptimeCheckConfigPathTemplate.render({ + folder: folder, + uptime_check_config: uptimeCheckConfig, + }); + } + + /** + * Parse the folder from FolderUptimeCheckConfig resource. + * + * @param {string} folderUptimeCheckConfigName + * A fully-qualified path representing folder_uptime_check_config resource. + * @returns {string} A string representing the folder. + */ + matchFolderFromFolderUptimeCheckConfigName(folderUptimeCheckConfigName: string) { + return this._pathTemplates.folderUptimeCheckConfigPathTemplate.match(folderUptimeCheckConfigName).folder; + } + + /** + * Parse the uptime_check_config from FolderUptimeCheckConfig resource. + * + * @param {string} folderUptimeCheckConfigName + * A fully-qualified path representing folder_uptime_check_config resource. + * @returns {string} A string representing the uptime_check_config. + */ + matchUptimeCheckConfigFromFolderUptimeCheckConfigName(folderUptimeCheckConfigName: string) { + return this._pathTemplates.folderUptimeCheckConfigPathTemplate.match(folderUptimeCheckConfigName).uptime_check_config; + } + + /** + * Terminate the GRPC channel and close the client. + * + * The client will no longer be usable and all future behavior is undefined. + */ + close(): Promise { + if (!this._terminated) { + return this.uptimeCheckServiceStub.then(stub => { + this._terminated = true; + stub.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/typescript/test/testdata/monitoring/src/v3/uptime_check_service_client_config.json.baseline b/typescript/test/testdata/monitoring/src/v3/uptime_check_service_client_config.json.baseline new file mode 100644 index 000000000..0e638c2df --- /dev/null +++ b/typescript/test/testdata/monitoring/src/v3/uptime_check_service_client_config.json.baseline @@ -0,0 +1,50 @@ +{ + "interfaces": { + "google.monitoring.v3.UptimeCheckService": { + "retry_codes": { + "non_idempotent": [], + "idempotent": [ + "DEADLINE_EXCEEDED", + "UNAVAILABLE" + ] + }, + "retry_params": { + "default": { + "initial_retry_delay_millis": 100, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 60000, + "initial_rpc_timeout_millis": 60000, + "rpc_timeout_multiplier": 1, + "max_rpc_timeout_millis": 60000, + "total_timeout_millis": 600000 + } + }, + "methods": { + "ListUptimeCheckConfigs": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "GetUptimeCheckConfig": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "CreateUptimeCheckConfig": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "UpdateUptimeCheckConfig": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "DeleteUptimeCheckConfig": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "ListUptimeCheckIps": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/typescript/test/testdata/monitoring/src/v3/uptime_check_service_proto_list.json.baseline b/typescript/test/testdata/monitoring/src/v3/uptime_check_service_proto_list.json.baseline new file mode 100644 index 000000000..aacceb22f --- /dev/null +++ b/typescript/test/testdata/monitoring/src/v3/uptime_check_service_proto_list.json.baseline @@ -0,0 +1,16 @@ +[ + "../../protos/google/monitoring/v3/alert.proto", + "../../protos/google/monitoring/v3/alert_service.proto", + "../../protos/google/monitoring/v3/common.proto", + "../../protos/google/monitoring/v3/group.proto", + "../../protos/google/monitoring/v3/group_service.proto", + "../../protos/google/monitoring/v3/metric.proto", + "../../protos/google/monitoring/v3/metric_service.proto", + "../../protos/google/monitoring/v3/mutation_record.proto", + "../../protos/google/monitoring/v3/notification.proto", + "../../protos/google/monitoring/v3/notification_service.proto", + "../../protos/google/monitoring/v3/service.proto", + "../../protos/google/monitoring/v3/service_service.proto", + "../../protos/google/monitoring/v3/uptime.proto", + "../../protos/google/monitoring/v3/uptime_service.proto" +] diff --git a/typescript/test/testdata/monitoring/system-test/fixtures/sample/src/index.js.baseline b/typescript/test/testdata/monitoring/system-test/fixtures/sample/src/index.js.baseline index d6aa6493c..7b3918c1b 100644 --- a/typescript/test/testdata/monitoring/system-test/fixtures/sample/src/index.js.baseline +++ b/typescript/test/testdata/monitoring/system-test/fixtures/sample/src/index.js.baseline @@ -21,6 +21,12 @@ const monitoring = require('monitoring'); function main() { + const alertPolicyServiceClient = new monitoring.AlertPolicyServiceClient(); + const groupServiceClient = new monitoring.GroupServiceClient(); + const metricServiceClient = new monitoring.MetricServiceClient(); + const notificationChannelServiceClient = new monitoring.NotificationChannelServiceClient(); + const serviceMonitoringServiceClient = new monitoring.ServiceMonitoringServiceClient(); + const uptimeCheckServiceClient = new monitoring.UptimeCheckServiceClient(); } main(); diff --git a/typescript/test/testdata/monitoring/system-test/fixtures/sample/src/index.ts.baseline b/typescript/test/testdata/monitoring/system-test/fixtures/sample/src/index.ts.baseline index cf2e349fd..e6cea60a7 100644 --- a/typescript/test/testdata/monitoring/system-test/fixtures/sample/src/index.ts.baseline +++ b/typescript/test/testdata/monitoring/system-test/fixtures/sample/src/index.ts.baseline @@ -16,9 +16,15 @@ // ** https://github.com/googleapis/gapic-generator-typescript ** // ** All changes to this file may be overwritten. ** -import {} from 'monitoring'; +import {AlertPolicyServiceClient, GroupServiceClient, MetricServiceClient, NotificationChannelServiceClient, ServiceMonitoringServiceClient, UptimeCheckServiceClient} from '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(); } main(); diff --git a/typescript/test/testdata/monitoring/test/gapic-alert_policy_service-v3.ts.baseline b/typescript/test/testdata/monitoring/test/gapic-alert_policy_service-v3.ts.baseline new file mode 100644 index 000000000..13fa999b8 --- /dev/null +++ b/typescript/test/testdata/monitoring/test/gapic-alert_policy_service-v3.ts.baseline @@ -0,0 +1,323 @@ +// 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); + }); + describe('getAlertPolicy', () => { + it('invokes getAlertPolicy without error', done => { + const client = new alertpolicyserviceModule.v3.AlertPolicyServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + // 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', + }); + // 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', + }); + // 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', + }); + // 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', + }); + // 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', + }); + // 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', + }); + // 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', + }); + // 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', + }); + // 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', + }); + // 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/typescript/test/testdata/monitoring/test/gapic-group_service-v3.ts.baseline b/typescript/test/testdata/monitoring/test/gapic-group_service-v3.ts.baseline new file mode 100644 index 000000000..df8dfb910 --- /dev/null +++ b/typescript/test/testdata/monitoring/test/gapic-group_service-v3.ts.baseline @@ -0,0 +1,371 @@ +// 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); + }); + describe('getGroup', () => { + it('invokes getGroup without error', done => { + const client = new groupserviceModule.v3.GroupServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + // 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', + }); + // 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', + }); + // 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', + }); + // 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', + }); + // 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', + }); + // 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', + }); + // 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', + }); + // 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', + }); + // 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', + }); + // 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', + }); + // 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', + }); + // 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/typescript/test/testdata/monitoring/test/gapic-metric_service-v3.ts.baseline b/typescript/test/testdata/monitoring/test/gapic-metric_service-v3.ts.baseline new file mode 100644 index 000000000..a709a3212 --- /dev/null +++ b/typescript/test/testdata/monitoring/test/gapic-metric_service-v3.ts.baseline @@ -0,0 +1,465 @@ +// 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); + }); + describe('getMonitoredResourceDescriptor', () => { + it('invokes getMonitoredResourceDescriptor without error', done => { + const client = new metricserviceModule.v3.MetricServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + // 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', + }); + // 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', + }); + // 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', + }); + // 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', + }); + // 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', + }); + // 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', + }); + // 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', + }); + // 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', + }); + // 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', + }); + // 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', + }); + // 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', + }); + // 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', + }); + // 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', + }); + // 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', + }); + // 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', + }); + // 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/typescript/test/testdata/monitoring/test/gapic-notification_channel_service-v3.ts.baseline b/typescript/test/testdata/monitoring/test/gapic-notification_channel_service-v3.ts.baseline new file mode 100644 index 000000000..e3fff90fc --- /dev/null +++ b/typescript/test/testdata/monitoring/test/gapic-notification_channel_service-v3.ts.baseline @@ -0,0 +1,563 @@ +// 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); + }); + describe('getNotificationChannelDescriptor', () => { + it('invokes getNotificationChannelDescriptor without error', done => { + const client = new notificationchannelserviceModule.v3.NotificationChannelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + // 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', + }); + // 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', + }); + // 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', + }); + // 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', + }); + // 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', + }); + // 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', + }); + // 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', + }); + // 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', + }); + // 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', + }); + // 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', + }); + // 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', + }); + // 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', + }); + // 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', + }); + // 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', + }); + // 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', + }); + // 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', + }); + // 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', + }); + // 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', + }); + // 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', + }); + // 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/typescript/test/testdata/monitoring/test/gapic-service_monitoring_service-v3.ts.baseline b/typescript/test/testdata/monitoring/test/gapic-service_monitoring_service-v3.ts.baseline new file mode 100644 index 000000000..780f79dd4 --- /dev/null +++ b/typescript/test/testdata/monitoring/test/gapic-service_monitoring_service-v3.ts.baseline @@ -0,0 +1,565 @@ +// 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); + }); + describe('createService', () => { + it('invokes createService without error', done => { + const client = new servicemonitoringserviceModule.v3.ServiceMonitoringServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + // 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', + }); + // 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', + }); + // 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', + }); + // 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', + }); + // 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', + }); + // 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', + }); + // 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', + }); + // 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', + }); + // 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', + }); + // 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', + }); + // 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', + }); + // 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', + }); + // 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', + }); + // 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', + }); + // 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', + }); + // 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', + }); + // 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', + }); + // 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', + }); + // 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', + }); + // 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/typescript/test/testdata/monitoring/test/gapic-uptime_check_service-v3.ts.baseline b/typescript/test/testdata/monitoring/test/gapic-uptime_check_service-v3.ts.baseline new file mode 100644 index 000000000..f7c232f70 --- /dev/null +++ b/typescript/test/testdata/monitoring/test/gapic-uptime_check_service-v3.ts.baseline @@ -0,0 +1,369 @@ +// 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); + }); + describe('getUptimeCheckConfig', () => { + it('invokes getUptimeCheckConfig without error', done => { + const client = new uptimecheckserviceModule.v3.UptimeCheckServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + // 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', + }); + // 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', + }); + // 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', + }); + // 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', + }); + // 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', + }); + // 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', + }); + // 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', + }); + // 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', + }); + // 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', + }); + // 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', + }); + // 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', + }); + // 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/typescript/test/unit/monitor.ts b/typescript/test/unit/monitor.ts index 3637f1728..7d105f403 100644 --- a/typescript/test/unit/monitor.ts +++ b/typescript/test/unit/monitor.ts @@ -1,11 +1,11 @@ import * as assert from 'assert'; -import { execSync } from 'child_process'; +import {execSync} from 'child_process'; import * as fs from 'fs'; -import { describe, it } from 'mocha'; +import {describe, it} from 'mocha'; import * as path from 'path'; import * as rimraf from 'rimraf'; -import { equalToBaseline } from '../util'; +import {equalToBaseline} from '../util'; const cwd = process.cwd(); @@ -17,20 +17,14 @@ const START_SCRIPT = path.join( ); const OUTPUT_DIR = path.join(cwd, '.test-out-monitoring'); -const GOOGLE_GAX_PROTOS_DIR = path.join( - cwd, - 'node_modules', - 'google-gax', - 'protos' -); const PROTOS_DIR = path.join(cwd, 'build', 'test', 'protos'); -const MONITOR_PROTO_FILE = path.join( +const MONITOR_PROTO_FILE1 = path.join( PROTOS_DIR, 'google', 'monitoring', 'v3', - 'service_service.proto' + '*_service.proto' ); const BASELINE_DIR = path.join( @@ -50,7 +44,7 @@ const PLUGIN = path.join(SRCDIR, 'protoc-gen-typescript_gapic'); describe('MonitoringGenerateTest', () => { describe('Generate Client library', () => { - it('Generated proto list should have same output with baseline.', function() { + it('Generated proto list should have same output with baseline.', function () { this.timeout(10000); if (fs.existsSync(OUTPUT_DIR)) { rimraf.sync(OUTPUT_DIR); @@ -71,11 +65,11 @@ describe('MonitoringGenerateTest', () => { execSync( 'node ' + - START_SCRIPT + - ` -I${PROTOS_DIR}` + - ` ${MONITOR_PROTO_FILE}` + - ` --output_dir=${OUTPUT_DIR}` + - ` --main_service=monitoring` + START_SCRIPT + + ` -I${PROTOS_DIR}` + + ` ${MONITOR_PROTO_FILE1}` + + ` --output_dir=${OUTPUT_DIR}` + + ` --main_service=monitoring` ); assert(equalToBaseline(OUTPUT_DIR, BASELINE_DIR_MONITOR)); }); From 0db0a222ccb33da5ce2ebd0c52edbd49787bf29d Mon Sep 17 00:00:00 2001 From: summerji Date: Wed, 5 Feb 2020 15:24:41 -0800 Subject: [PATCH 2/6] fix lint --- typescript/src/schema/api.ts | 6 +++--- typescript/test/unit/monitor.ts | 18 +++++++++--------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/typescript/src/schema/api.ts b/typescript/src/schema/api.ts index e5d8eed19..d90439402 100644 --- a/typescript/src/schema/api.ts +++ b/typescript/src/schema/api.ts @@ -16,9 +16,9 @@ import * as plugin from '../../../pbjs-genfiles/plugin'; import * as fs from 'fs'; import * as path from 'path'; -import {Naming, Options as namingOptions} from './naming'; -import {Proto, MessagesMap} from './proto'; -import {ResourceDatabase, ResourceDescriptor} from './resourceDatabase'; +import { Naming, Options as namingOptions } from './naming'; +import { Proto, MessagesMap } from './proto'; +import { ResourceDatabase, ResourceDescriptor } from './resourceDatabase'; const googleGaxLocation = path.dirname(require.resolve('google-gax')); const gaxProtosLocation = path.join(googleGaxLocation, '..', '..', 'protos'); diff --git a/typescript/test/unit/monitor.ts b/typescript/test/unit/monitor.ts index 7d105f403..20e471612 100644 --- a/typescript/test/unit/monitor.ts +++ b/typescript/test/unit/monitor.ts @@ -1,11 +1,11 @@ import * as assert from 'assert'; -import {execSync} from 'child_process'; +import { execSync } from 'child_process'; import * as fs from 'fs'; -import {describe, it} from 'mocha'; +import { describe, it } from 'mocha'; import * as path from 'path'; import * as rimraf from 'rimraf'; -import {equalToBaseline} from '../util'; +import { equalToBaseline } from '../util'; const cwd = process.cwd(); @@ -44,7 +44,7 @@ const PLUGIN = path.join(SRCDIR, 'protoc-gen-typescript_gapic'); describe('MonitoringGenerateTest', () => { describe('Generate Client library', () => { - it('Generated proto list should have same output with baseline.', function () { + it('Generated proto list should have same output with baseline.', function() { this.timeout(10000); if (fs.existsSync(OUTPUT_DIR)) { rimraf.sync(OUTPUT_DIR); @@ -65,11 +65,11 @@ describe('MonitoringGenerateTest', () => { execSync( 'node ' + - START_SCRIPT + - ` -I${PROTOS_DIR}` + - ` ${MONITOR_PROTO_FILE1}` + - ` --output_dir=${OUTPUT_DIR}` + - ` --main_service=monitoring` + START_SCRIPT + + ` -I${PROTOS_DIR}` + + ` ${MONITOR_PROTO_FILE1}` + + ` --output_dir=${OUTPUT_DIR}` + + ` --main_service=monitoring` ); assert(equalToBaseline(OUTPUT_DIR, BASELINE_DIR_MONITOR)); }); From 724717c20c8827a260dc4ad187e882b1bf502481 Mon Sep 17 00:00:00 2001 From: summerji Date: Wed, 5 Feb 2020 15:37:12 -0800 Subject: [PATCH 3/6] fix: test name change --- typescript/test/unit/monitor.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/typescript/test/unit/monitor.ts b/typescript/test/unit/monitor.ts index 20e471612..c11bdfc2a 100644 --- a/typescript/test/unit/monitor.ts +++ b/typescript/test/unit/monitor.ts @@ -44,7 +44,7 @@ const PLUGIN = path.join(SRCDIR, 'protoc-gen-typescript_gapic'); describe('MonitoringGenerateTest', () => { describe('Generate Client library', () => { - it('Generated proto list should have same output with baseline.', function() { + it('Generated monitoring library have same output with baseline.', function() { this.timeout(10000); if (fs.existsSync(OUTPUT_DIR)) { rimraf.sync(OUTPUT_DIR); From 70665a360804e47b25a8ea1cda142a5d1f1cc64c Mon Sep 17 00:00:00 2001 From: summerji Date: Wed, 5 Feb 2020 15:43:42 -0800 Subject: [PATCH 4/6] fix: baselines --- .../testdata/monitoring/proto.list.baseline | 25 +- .../testdata/monitoring/src/index.ts.baseline | 8 +- .../alert_policy_service_client.ts.baseline | 1593 ------------ ...policy_service_client_config.json.baseline | 46 - ...rt_policy_service_proto_list.json.baseline | 16 - .../src/v3/group_service_client.ts.baseline | 1708 ------------- .../group_service_client_config.json.baseline | 50 - .../v3/group_service_proto_list.json.baseline | 16 - .../monitoring/src/v3/index.ts.baseline | 2 +- .../src/v3/metric_service_client.ts.baseline | 2161 ----------------- ...metric_service_client_config.json.baseline | 58 - .../metric_service_proto_list.json.baseline | 16 - ...ication_channel_service_client.ts.baseline | 1993 --------------- ...hannel_service_client_config.json.baseline | 66 - ...n_channel_service_proto_list.json.baseline | 16 - ...vice_monitoring_service_client.ts.baseline | 494 +--- ...onitoring_service_proto_list.json.baseline | 10 - .../uptime_check_service_client.ts.baseline | 494 +--- ...ime_check_service_proto_list.json.baseline | 10 - .../fixtures/sample/src/index.js.baseline | 4 - .../fixtures/sample/src/index.ts.baseline | 6 +- .../gapic-alert_policy_service-v3.ts.baseline | 323 --- .../test/gapic-group_service-v3.ts.baseline | 371 --- .../test/gapic-metric_service-v3.ts.baseline | 465 ---- ...otification_channel_service-v3.ts.baseline | 563 ----- 25 files changed, 35 insertions(+), 10479 deletions(-) delete mode 100644 typescript/test/testdata/monitoring/src/v3/alert_policy_service_client.ts.baseline delete mode 100644 typescript/test/testdata/monitoring/src/v3/alert_policy_service_client_config.json.baseline delete mode 100644 typescript/test/testdata/monitoring/src/v3/alert_policy_service_proto_list.json.baseline delete mode 100644 typescript/test/testdata/monitoring/src/v3/group_service_client.ts.baseline delete mode 100644 typescript/test/testdata/monitoring/src/v3/group_service_client_config.json.baseline delete mode 100644 typescript/test/testdata/monitoring/src/v3/group_service_proto_list.json.baseline delete mode 100644 typescript/test/testdata/monitoring/src/v3/metric_service_client.ts.baseline delete mode 100644 typescript/test/testdata/monitoring/src/v3/metric_service_client_config.json.baseline delete mode 100644 typescript/test/testdata/monitoring/src/v3/metric_service_proto_list.json.baseline delete mode 100644 typescript/test/testdata/monitoring/src/v3/notification_channel_service_client.ts.baseline delete mode 100644 typescript/test/testdata/monitoring/src/v3/notification_channel_service_client_config.json.baseline delete mode 100644 typescript/test/testdata/monitoring/src/v3/notification_channel_service_proto_list.json.baseline delete mode 100644 typescript/test/testdata/monitoring/test/gapic-alert_policy_service-v3.ts.baseline delete mode 100644 typescript/test/testdata/monitoring/test/gapic-group_service-v3.ts.baseline delete mode 100644 typescript/test/testdata/monitoring/test/gapic-metric_service-v3.ts.baseline delete mode 100644 typescript/test/testdata/monitoring/test/gapic-notification_channel_service-v3.ts.baseline diff --git a/typescript/test/testdata/monitoring/proto.list.baseline b/typescript/test/testdata/monitoring/proto.list.baseline index 42caeb97a..f9cc3f4c9 100644 --- a/typescript/test/testdata/monitoring/proto.list.baseline +++ b/typescript/test/testdata/monitoring/proto.list.baseline @@ -3,32 +3,17 @@ google/protobuf/descriptor.proto google/api/annotations.proto google/api/client.proto google/api/field_behavior.proto -google/api/resource.proto -google/protobuf/any.proto -google/protobuf/timestamp.proto -google/api/distribution.proto -google/protobuf/duration.proto -google/monitoring/v3/common.proto -google/monitoring/v3/mutation_record.proto -google/protobuf/wrappers.proto -google/rpc/status.proto -google/monitoring/v3/alert.proto -google/protobuf/empty.proto -google/protobuf/field_mask.proto -google/monitoring/v3/alert_service.proto google/api/label.proto google/api/launch_stage.proto google/protobuf/struct.proto google/api/monitored_resource.proto -google/monitoring/v3/group.proto -google/monitoring/v3/group_service.proto -google/api/metric.proto -google/monitoring/v3/metric.proto -google/monitoring/v3/metric_service.proto -google/monitoring/v3/notification.proto -google/monitoring/v3/notification_service.proto +google/api/resource.proto +google/protobuf/duration.proto +google/protobuf/timestamp.proto google/type/calendar_period.proto google/monitoring/v3/service.proto +google/protobuf/empty.proto +google/protobuf/field_mask.proto google/monitoring/v3/service_service.proto google/monitoring/v3/uptime.proto google/monitoring/v3/uptime_service.proto diff --git a/typescript/test/testdata/monitoring/src/index.ts.baseline b/typescript/test/testdata/monitoring/src/index.ts.baseline index cf6f9adf2..7e05abce5 100644 --- a/typescript/test/testdata/monitoring/src/index.ts.baseline +++ b/typescript/test/testdata/monitoring/src/index.ts.baseline @@ -17,13 +17,9 @@ // ** All changes to this file may be overwritten. ** import * as v3 from './v3'; -const AlertPolicyServiceClient = v3.AlertPolicyServiceClient; -const GroupServiceClient = v3.GroupServiceClient; -const MetricServiceClient = v3.MetricServiceClient; -const NotificationChannelServiceClient = v3.NotificationChannelServiceClient; const ServiceMonitoringServiceClient = v3.ServiceMonitoringServiceClient; const UptimeCheckServiceClient = v3.UptimeCheckServiceClient; -export {v3, AlertPolicyServiceClient, GroupServiceClient, MetricServiceClient, NotificationChannelServiceClient, ServiceMonitoringServiceClient, UptimeCheckServiceClient}; +export {v3, ServiceMonitoringServiceClient, UptimeCheckServiceClient}; // For compatibility with JavaScript libraries we need to provide this default export: // tslint:disable-next-line no-default-export -export default {v3, AlertPolicyServiceClient, GroupServiceClient, MetricServiceClient, NotificationChannelServiceClient, ServiceMonitoringServiceClient, UptimeCheckServiceClient}; +export default {v3, ServiceMonitoringServiceClient, UptimeCheckServiceClient}; diff --git a/typescript/test/testdata/monitoring/src/v3/alert_policy_service_client.ts.baseline b/typescript/test/testdata/monitoring/src/v3/alert_policy_service_client.ts.baseline deleted file mode 100644 index a81005e90..000000000 --- a/typescript/test/testdata/monitoring/src/v3/alert_policy_service_client.ts.baseline +++ /dev/null @@ -1,1593 +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 gax from 'google-gax'; -import {APICallback, Callback, CallOptions, Descriptors, ClientOptions, PaginationCallback, PaginationResponse} from 'google-gax'; -import * as path from 'path'; - -import { Transform } from 'stream'; -import * as protosTypes from '../../protos/protos'; -import * as gapicConfig from './alert_policy_service_client_config.json'; - -const version = require('../../../package.json').version; - -/** - * The AlertPolicyService API is used to manage (list, create, delete, - * edit) alert policies in Stackdriver Monitoring. An alerting policy is - * a description of the conditions under which some aspect of your - * system is considered to be "unhealthy" and the ways to notify - * people or services about this state. In addition to using this API, alert - * policies can also be managed through - * [Stackdriver Monitoring](https://cloud.google.com/monitoring/docs/), - * which can be reached by clicking the "Monitoring" tab in - * [Cloud Console](https://console.cloud.google.com/). - * @class - * @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; - auth: gax.GoogleAuth; - alertPolicyServiceStub: Promise<{[name: string]: Function}>; - - /** - * Construct an instance of AlertPolicyServiceClient. - * - * @param {object} [options] - The configuration object. See the subsequent - * parameters for more details. - * @param {object} [options.credentials] - Credentials object. - * @param {string} [options.credentials.client_email] - * @param {string} [options.credentials.private_key] - * @param {string} [options.email] - Account email address. Required when - * using a .pem or .p12 keyFilename. - * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or - * .p12 key downloaded from the Google Developers Console. If you provide - * a path to a JSON file, the projectId option below is not necessary. - * NOTE: .pem and .p12 require you to specify options.email as well. - * @param {number} [options.port] - The port on which to connect to - * the remote host. - * @param {string} [options.projectId] - The project ID from the Google - * Developer's Console, e.g. 'grape-spaceship-123'. We will also check - * the environment variable GCLOUD_PROJECT for your project ID. If your - * app is running in an environment which supports - * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, - * your project ID will be detected automatically. - * @param {function} [options.promise] - Custom promise module to use instead - * of native Promises. - * @param {string} [options.apiEndpoint] - The domain name of the - * API remote host. - */ - - constructor(opts?: ClientOptions) { - // Ensure that options include the service address and port. - const staticMembers = this.constructor as typeof AlertPolicyServiceClient; - const servicePath = opts && opts.servicePath ? - opts.servicePath : - ((opts && opts.apiEndpoint) ? opts.apiEndpoint : - staticMembers.servicePath); - const port = opts && opts.port ? opts.port : staticMembers.port; - - if (!opts) { - opts = {servicePath, port}; - } - opts.servicePath = opts.servicePath || servicePath; - opts.port = opts.port || port; - opts.clientConfig = opts.clientConfig || {}; - - const isBrowser = (typeof window !== 'undefined'); - if (isBrowser){ - opts.fallback = true; - } - // If we are in browser, we are already using fallback because of the - // "browser" field in package.json. - // But if we were explicitly requested to use fallback, let's do it now. - const gaxModule = !isBrowser && opts.fallback ? gax.fallback : gax; - - // Create a `gaxGrpc` object, with any grpc-specific options - // sent to the client. - opts.scopes = (this.constructor as typeof AlertPolicyServiceClient).scopes; - const gaxGrpc = new gaxModule.GrpcClient(opts); - - // Save the auth object to the client, for use by other methods. - this.auth = (gaxGrpc.auth as gax.GoogleAuth); - - // Determine the client header string. - const clientHeader = [ - `gax/${gaxModule.version}`, - `gapic/${version}`, - ]; - if (typeof process !== 'undefined' && 'versions' in process) { - clientHeader.push(`gl-node/${process.versions.node}`); - } else { - clientHeader.push(`gl-web/${gaxModule.version}`); - } - if (!opts.fallback) { - clientHeader.push(`grpc/${gaxGrpc.grpcVersion}`); - } - if (opts.libName && opts.libVersion) { - clientHeader.push(`${opts.libName}/${opts.libVersion}`); - } - // Load the applicable protos. - // For Node.js, pass the path to JSON proto file. - // For browsers, pass the JSON content. - - const nodejsProtoPath = path.join(__dirname, '..', '..', 'protos', 'protos.json'); - const protos = gaxGrpc.loadProto( - opts.fallback ? - 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 = { - projectAlertPolicyPathTemplate: new gaxModule.PathTemplate( - 'projects/{project}/alertPolicies/{alert_policy}' - ), - organizationAlertPolicyPathTemplate: new gaxModule.PathTemplate( - 'organizations/{organization}/alertPolicies/{alert_policy}' - ), - folderAlertPolicyPathTemplate: new gaxModule.PathTemplate( - 'folders/{folder}/alertPolicies/{alert_policy}' - ), - PathTemplate: new gaxModule.PathTemplate( - '*' - ), - projectGroupPathTemplate: new gaxModule.PathTemplate( - 'projects/{project}/groups/{group}' - ), - organizationGroupPathTemplate: new gaxModule.PathTemplate( - 'organizations/{organization}/groups/{group}' - ), - folderGroupPathTemplate: new gaxModule.PathTemplate( - 'folders/{folder}/groups/{group}' - ), - projectChannelDescriptorPathTemplate: new gaxModule.PathTemplate( - 'projects/{project}/notificationChannelDescriptors/{channel_descriptor}' - ), - organizationChannelDescriptorPathTemplate: new gaxModule.PathTemplate( - 'organizations/{organization}/notificationChannelDescriptors/{channel_descriptor}' - ), - folderChannelDescriptorPathTemplate: new gaxModule.PathTemplate( - 'folders/{folder}/notificationChannelDescriptors/{channel_descriptor}' - ), - projectNotificationChannelPathTemplate: new gaxModule.PathTemplate( - 'projects/{project}/notificationChannels/{notification_channel}' - ), - organizationNotificationChannelPathTemplate: new gaxModule.PathTemplate( - 'organizations/{organization}/notificationChannels/{notification_channel}' - ), - folderNotificationChannelPathTemplate: new gaxModule.PathTemplate( - 'folders/{folder}/notificationChannels/{notification_channel}' - ), - projectServicePathTemplate: new gaxModule.PathTemplate( - 'projects/{project}/services/{service}' - ), - organizationServicePathTemplate: new gaxModule.PathTemplate( - 'organizations/{organization}/services/{service}' - ), - folderServicePathTemplate: new gaxModule.PathTemplate( - 'folders/{folder}/services/{service}' - ), - projectServiceServiceLevelObjectivePathTemplate: new gaxModule.PathTemplate( - 'projects/{project}/services/{service}/serviceLevelObjectives/{service_level_objective}' - ), - organizationServiceServiceLevelObjectivePathTemplate: new gaxModule.PathTemplate( - 'organizations/{organization}/services/{service}/serviceLevelObjectives/{service_level_objective}' - ), - folderServiceServiceLevelObjectivePathTemplate: new gaxModule.PathTemplate( - 'folders/{folder}/services/{service}/serviceLevelObjectives/{service_level_objective}' - ), - projectUptimeCheckConfigPathTemplate: new gaxModule.PathTemplate( - 'projects/{project}/uptimeCheckConfigs/{uptime_check_config}' - ), - organizationUptimeCheckConfigPathTemplate: new gaxModule.PathTemplate( - 'organizations/{organization}/uptimeCheckConfigs/{uptime_check_config}' - ), - folderUptimeCheckConfigPathTemplate: new gaxModule.PathTemplate( - 'folders/{folder}/uptimeCheckConfigs/{uptime_check_config}' - ), - }; - - // 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 = { - listAlertPolicies: - new gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'alertPolicies') - }; - - // Put together the default options sent with requests. - const defaults = gaxGrpc.constructSettings( - 'google.monitoring.v3.AlertPolicyService', gapicConfig as gax.ClientConfig, - opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); - - // Set up a dictionary of "inner API calls"; the core implementation - // of calling the API is handled in `google-gax`, with this code - // merely providing the destination and request information. - this._innerApiCalls = {}; - - // Put together the "service stub" for - // google.monitoring.v3.AlertPolicyService. - this.alertPolicyServiceStub = gaxGrpc.createStub( - opts.fallback ? - (protos as protobuf.Root).lookupService('google.monitoring.v3.AlertPolicyService') : - // tslint:disable-next-line no-any - (protos as any).google.monitoring.v3.AlertPolicyService, - opts) as Promise<{[method: string]: Function}>; - - // Iterate over each of the methods that the service provides - // and create an API call method for each. - const alertPolicyServiceStubMethods = - ['listAlertPolicies', 'getAlertPolicy', 'createAlertPolicy', 'deleteAlertPolicy', 'updateAlertPolicy']; - - for (const methodName of alertPolicyServiceStubMethods) { - const innerCallPromise = this.alertPolicyServiceStub.then( - stub => (...args: Array<{}>) => { - if (this._terminated) { - return Promise.reject('The client has already been closed.'); - } - return stub[methodName].apply(stub, args); - }, - (err: Error|null|undefined) => () => { - throw err; - }); - - const apiCall = gaxModule.createApiCall( - innerCallPromise, - defaults[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); - }; - } - } - - /** - * The DNS address for this API service. - */ - static get servicePath() { - return 'monitoring.googleapis.com'; - } - - /** - * The DNS address for this API service - same as servicePath(), - * exists for compatibility reasons. - */ - static get apiEndpoint() { - return 'monitoring.googleapis.com'; - } - - /** - * The port for this API service. - */ - static get port() { - return 443; - } - - /** - * The scopes needed to make gRPC calls for every method defined - * in this service. - */ - static get scopes() { - return [ - 'https://www.googleapis.com/auth/cloud-platform', - 'https://www.googleapis.com/auth/monitoring', - 'https://www.googleapis.com/auth/monitoring.read' - ]; - } - - getProjectId(): Promise; - getProjectId(callback: Callback): void; - /** - * Return the project ID used by this class. - * @param {function(Error, string)} callback - the callback to - * be called with the current project Id. - */ - getProjectId(callback?: Callback): - Promise|void { - if (callback) { - this.auth.getProjectId(callback); - return; - } - return this.auth.getProjectId(); - } - - // ------------------- - // -- Service calls -- - // ------------------- - getAlertPolicy( - request: protosTypes.google.monitoring.v3.IGetAlertPolicyRequest, - options?: gax.CallOptions): - Promise<[ - protosTypes.google.monitoring.v3.IAlertPolicy, - protosTypes.google.monitoring.v3.IGetAlertPolicyRequest|undefined, {}|undefined - ]>; - getAlertPolicy( - request: protosTypes.google.monitoring.v3.IGetAlertPolicyRequest, - options: gax.CallOptions, - callback: Callback< - protosTypes.google.monitoring.v3.IAlertPolicy, - protosTypes.google.monitoring.v3.IGetAlertPolicyRequest|undefined, - {}|undefined>): void; -/** - * Gets a single alerting policy. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The alerting policy to retrieve. The format is - * - * projects/[PROJECT_ID]/alertPolicies/[ALERT_POLICY_ID] - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [AlertPolicy]{@link google.monitoring.v3.AlertPolicy}. - * The promise has a method named "cancel" which cancels the ongoing API call. - */ - getAlertPolicy( - request: protosTypes.google.monitoring.v3.IGetAlertPolicyRequest, - optionsOrCallback?: gax.CallOptions|Callback< - protosTypes.google.monitoring.v3.IAlertPolicy, - protosTypes.google.monitoring.v3.IGetAlertPolicyRequest|undefined, {}|undefined>, - callback?: Callback< - protosTypes.google.monitoring.v3.IAlertPolicy, - protosTypes.google.monitoring.v3.IGetAlertPolicyRequest|undefined, - {}|undefined>): - Promise<[ - protosTypes.google.monitoring.v3.IAlertPolicy, - protosTypes.google.monitoring.v3.IGetAlertPolicyRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: gax.CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as gax.CallOptions; - } - 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 || '', - }); - return this._innerApiCalls.getAlertPolicy(request, options, callback); - } - createAlertPolicy( - request: protosTypes.google.monitoring.v3.ICreateAlertPolicyRequest, - options?: gax.CallOptions): - Promise<[ - protosTypes.google.monitoring.v3.IAlertPolicy, - protosTypes.google.monitoring.v3.ICreateAlertPolicyRequest|undefined, {}|undefined - ]>; - createAlertPolicy( - request: protosTypes.google.monitoring.v3.ICreateAlertPolicyRequest, - options: gax.CallOptions, - callback: Callback< - protosTypes.google.monitoring.v3.IAlertPolicy, - protosTypes.google.monitoring.v3.ICreateAlertPolicyRequest|undefined, - {}|undefined>): void; -/** - * Creates a new alerting policy. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The project in which to create the alerting policy. The format is - * `projects/[PROJECT_ID]`. - * - * Note that this field names the parent container in which the alerting - * policy will be written, not the name of the created policy. The alerting - * policy that is returned will have a name that contains a normalized - * representation of this name as a prefix but adds a suffix of the form - * `/alertPolicies/[POLICY_ID]`, identifying the policy in the container. - * @param {google.monitoring.v3.AlertPolicy} request.alertPolicy - * Required. The requested alerting policy. You should omit the `name` field in this - * policy. The name will be returned in the new policy, including - * a new [ALERT_POLICY_ID] value. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [AlertPolicy]{@link google.monitoring.v3.AlertPolicy}. - * The promise has a method named "cancel" which cancels the ongoing API call. - */ - createAlertPolicy( - request: protosTypes.google.monitoring.v3.ICreateAlertPolicyRequest, - optionsOrCallback?: gax.CallOptions|Callback< - protosTypes.google.monitoring.v3.IAlertPolicy, - protosTypes.google.monitoring.v3.ICreateAlertPolicyRequest|undefined, {}|undefined>, - callback?: Callback< - protosTypes.google.monitoring.v3.IAlertPolicy, - protosTypes.google.monitoring.v3.ICreateAlertPolicyRequest|undefined, - {}|undefined>): - Promise<[ - protosTypes.google.monitoring.v3.IAlertPolicy, - protosTypes.google.monitoring.v3.ICreateAlertPolicyRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: gax.CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as gax.CallOptions; - } - 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 || '', - }); - return this._innerApiCalls.createAlertPolicy(request, options, callback); - } - deleteAlertPolicy( - request: protosTypes.google.monitoring.v3.IDeleteAlertPolicyRequest, - options?: gax.CallOptions): - Promise<[ - protosTypes.google.protobuf.IEmpty, - protosTypes.google.monitoring.v3.IDeleteAlertPolicyRequest|undefined, {}|undefined - ]>; - deleteAlertPolicy( - request: protosTypes.google.monitoring.v3.IDeleteAlertPolicyRequest, - options: gax.CallOptions, - callback: Callback< - protosTypes.google.protobuf.IEmpty, - protosTypes.google.monitoring.v3.IDeleteAlertPolicyRequest|undefined, - {}|undefined>): void; -/** - * Deletes an alerting policy. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The alerting policy to delete. The format is: - * - * projects/[PROJECT_ID]/alertPolicies/[ALERT_POLICY_ID] - * - * For more information, see [AlertPolicy][google.monitoring.v3.AlertPolicy]. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. - * The promise has a method named "cancel" which cancels the ongoing API call. - */ - deleteAlertPolicy( - request: protosTypes.google.monitoring.v3.IDeleteAlertPolicyRequest, - optionsOrCallback?: gax.CallOptions|Callback< - protosTypes.google.protobuf.IEmpty, - protosTypes.google.monitoring.v3.IDeleteAlertPolicyRequest|undefined, {}|undefined>, - callback?: Callback< - protosTypes.google.protobuf.IEmpty, - protosTypes.google.monitoring.v3.IDeleteAlertPolicyRequest|undefined, - {}|undefined>): - Promise<[ - protosTypes.google.protobuf.IEmpty, - protosTypes.google.monitoring.v3.IDeleteAlertPolicyRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: gax.CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as gax.CallOptions; - } - 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 || '', - }); - return this._innerApiCalls.deleteAlertPolicy(request, options, callback); - } - updateAlertPolicy( - request: protosTypes.google.monitoring.v3.IUpdateAlertPolicyRequest, - options?: gax.CallOptions): - Promise<[ - protosTypes.google.monitoring.v3.IAlertPolicy, - protosTypes.google.monitoring.v3.IUpdateAlertPolicyRequest|undefined, {}|undefined - ]>; - updateAlertPolicy( - request: protosTypes.google.monitoring.v3.IUpdateAlertPolicyRequest, - options: gax.CallOptions, - callback: Callback< - protosTypes.google.monitoring.v3.IAlertPolicy, - protosTypes.google.monitoring.v3.IUpdateAlertPolicyRequest|undefined, - {}|undefined>): void; -/** - * Updates an alerting policy. You can either replace the entire policy with - * a new one or replace only certain fields in the current alerting policy by - * specifying the fields to be updated via `updateMask`. Returns the - * updated alerting policy. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.protobuf.FieldMask} request.updateMask - * Optional. A list of alerting policy field names. If this field is not - * empty, each listed field in the existing alerting policy is set to the - * value of the corresponding field in the supplied policy (`alert_policy`), - * or to the field's default value if the field is not in the supplied - * alerting policy. Fields not listed retain their previous value. - * - * Examples of valid field masks include `display_name`, `documentation`, - * `documentation.content`, `documentation.mime_type`, `user_labels`, - * `user_label.nameofkey`, `enabled`, `conditions`, `combiner`, etc. - * - * If this field is empty, then the supplied alerting policy replaces the - * existing policy. It is the same as deleting the existing policy and - * adding the supplied policy, except for the following: - * - * + The new policy will have the same `[ALERT_POLICY_ID]` as the former - * policy. This gives you continuity with the former policy in your - * notifications and incidents. - * + Conditions in the new policy will keep their former `[CONDITION_ID]` if - * the supplied condition includes the `name` field with that - * `[CONDITION_ID]`. If the supplied condition omits the `name` field, - * then a new `[CONDITION_ID]` is created. - * @param {google.monitoring.v3.AlertPolicy} request.alertPolicy - * Required. The updated alerting policy or the updated values for the - * fields listed in `update_mask`. - * If `update_mask` is not empty, any fields in this policy that are - * not in `update_mask` are ignored. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [AlertPolicy]{@link google.monitoring.v3.AlertPolicy}. - * The promise has a method named "cancel" which cancels the ongoing API call. - */ - updateAlertPolicy( - request: protosTypes.google.monitoring.v3.IUpdateAlertPolicyRequest, - optionsOrCallback?: gax.CallOptions|Callback< - protosTypes.google.monitoring.v3.IAlertPolicy, - protosTypes.google.monitoring.v3.IUpdateAlertPolicyRequest|undefined, {}|undefined>, - callback?: Callback< - protosTypes.google.monitoring.v3.IAlertPolicy, - protosTypes.google.monitoring.v3.IUpdateAlertPolicyRequest|undefined, - {}|undefined>): - Promise<[ - protosTypes.google.monitoring.v3.IAlertPolicy, - protosTypes.google.monitoring.v3.IUpdateAlertPolicyRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: gax.CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as gax.CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'alert_policy.name': request.alertPolicy!.name || '', - }); - return this._innerApiCalls.updateAlertPolicy(request, options, callback); - } - - listAlertPolicies( - request: protosTypes.google.monitoring.v3.IListAlertPoliciesRequest, - options?: gax.CallOptions): - Promise<[ - protosTypes.google.monitoring.v3.IAlertPolicy[], - protosTypes.google.monitoring.v3.IListAlertPoliciesRequest|null, - protosTypes.google.monitoring.v3.IListAlertPoliciesResponse - ]>; - listAlertPolicies( - request: protosTypes.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>): void; -/** - * Lists the existing alerting policies for the project. - * - * @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] - * - * 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 - * [GetAlertPolicy][google.monitoring.v3.AlertPolicyService.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](/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](/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 {Promise} - The promise which resolves to an array. - * The first element of the array is Array of [AlertPolicy]{@link google.monitoring.v3.AlertPolicy}. - * The client library support auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * - * When autoPaginate: false is specified through options, the array has three elements. - * The first element is Array of [AlertPolicy]{@link google.monitoring.v3.AlertPolicy} that corresponds to - * the one page received from the API server. - * If the second element is not null it contains the request object of type [ListAlertPoliciesRequest]{@link google.monitoring.v3.ListAlertPoliciesRequest} - * that can be used to obtain the next page of the results. - * If it is null, the next page does not exist. - * The third element contains the raw response received from the API server. Its type is - * [ListAlertPoliciesResponse]{@link google.monitoring.v3.ListAlertPoliciesResponse}. - * - * The promise has a method named "cancel" which cancels the ongoing API call. - */ - listAlertPolicies( - request: protosTypes.google.monitoring.v3.IListAlertPoliciesRequest, - optionsOrCallback?: gax.CallOptions|Callback< - protosTypes.google.monitoring.v3.IAlertPolicy[], - protosTypes.google.monitoring.v3.IListAlertPoliciesRequest|null, - protosTypes.google.monitoring.v3.IListAlertPoliciesResponse>, - callback?: Callback< - protosTypes.google.monitoring.v3.IAlertPolicy[], - protosTypes.google.monitoring.v3.IListAlertPoliciesRequest|null, - protosTypes.google.monitoring.v3.IListAlertPoliciesResponse>): - Promise<[ - protosTypes.google.monitoring.v3.IAlertPolicy[], - protosTypes.google.monitoring.v3.IListAlertPoliciesRequest|null, - protosTypes.google.monitoring.v3.IListAlertPoliciesResponse - ]>|void { - request = request || {}; - let options: gax.CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as gax.CallOptions; - } - 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 || '', - }); - return this._innerApiCalls.listAlertPolicies(request, options, callback); - } - -/** - * Equivalent to {@link listAlertPolicies}, but returns a NodeJS Stream object. - * - * This fetches the paged responses for {@link listAlertPolicies} continuously - * and invokes the callback registered for 'data' event for each element in the - * responses. - * - * The returned object has 'end' method when no more elements are required. - * - * autoPaginate option will be ignored. - * - * @see {@link https://nodejs.org/api/stream.html} - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The project whose alert policies are to be listed. The format is - * - * projects/[PROJECT_ID] - * - * 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 - * [GetAlertPolicy][google.monitoring.v3.AlertPolicyService.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](/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](/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 {Stream} - * An object stream which emits an object representing [AlertPolicy]{@link google.monitoring.v3.AlertPolicy} on 'data' event. - */ - listAlertPoliciesStream( - request?: protosTypes.google.monitoring.v3.IListAlertPoliciesRequest, - options?: gax.CallOptions | {}): - Transform{ - request = request || {}; - const callSettings = new gax.CallSettings(options); - return this._descriptors.page.listAlertPolicies.createStream( - this._innerApiCalls.listAlertPolicies as gax.GaxCall, - request, - callSettings - ); - } - // -------------------- - // -- Path templates -- - // -------------------- - - /** - * Return a fully-qualified projectAlertPolicy resource name string. - * - * @param {string} project - * @param {string} alert_policy - * @returns {string} Resource name string. - */ - projectAlertPolicyPath(project:string,alertPolicy:string) { - return this._pathTemplates.projectAlertPolicyPathTemplate.render({ - project: project, - alert_policy: alertPolicy, - }); - } - - /** - * Parse the project from ProjectAlertPolicy resource. - * - * @param {string} projectAlertPolicyName - * A fully-qualified path representing project_alert_policy resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProjectAlertPolicyName(projectAlertPolicyName: string) { - return this._pathTemplates.projectAlertPolicyPathTemplate.match(projectAlertPolicyName).project; - } - - /** - * Parse the alert_policy from ProjectAlertPolicy resource. - * - * @param {string} projectAlertPolicyName - * A fully-qualified path representing project_alert_policy resource. - * @returns {string} A string representing the alert_policy. - */ - matchAlertPolicyFromProjectAlertPolicyName(projectAlertPolicyName: string) { - return this._pathTemplates.projectAlertPolicyPathTemplate.match(projectAlertPolicyName).alert_policy; - } - - /** - * Return a fully-qualified organizationAlertPolicy resource name string. - * - * @param {string} organization - * @param {string} alert_policy - * @returns {string} Resource name string. - */ - organizationAlertPolicyPath(organization:string,alertPolicy:string) { - return this._pathTemplates.organizationAlertPolicyPathTemplate.render({ - organization: organization, - alert_policy: alertPolicy, - }); - } - - /** - * Parse the organization from OrganizationAlertPolicy resource. - * - * @param {string} organizationAlertPolicyName - * A fully-qualified path representing organization_alert_policy resource. - * @returns {string} A string representing the organization. - */ - matchOrganizationFromOrganizationAlertPolicyName(organizationAlertPolicyName: string) { - return this._pathTemplates.organizationAlertPolicyPathTemplate.match(organizationAlertPolicyName).organization; - } - - /** - * Parse the alert_policy from OrganizationAlertPolicy resource. - * - * @param {string} organizationAlertPolicyName - * A fully-qualified path representing organization_alert_policy resource. - * @returns {string} A string representing the alert_policy. - */ - matchAlertPolicyFromOrganizationAlertPolicyName(organizationAlertPolicyName: string) { - return this._pathTemplates.organizationAlertPolicyPathTemplate.match(organizationAlertPolicyName).alert_policy; - } - - /** - * Return a fully-qualified folderAlertPolicy resource name string. - * - * @param {string} folder - * @param {string} alert_policy - * @returns {string} Resource name string. - */ - folderAlertPolicyPath(folder:string,alertPolicy:string) { - return this._pathTemplates.folderAlertPolicyPathTemplate.render({ - folder: folder, - alert_policy: alertPolicy, - }); - } - - /** - * Parse the folder from FolderAlertPolicy resource. - * - * @param {string} folderAlertPolicyName - * A fully-qualified path representing folder_alert_policy resource. - * @returns {string} A string representing the folder. - */ - matchFolderFromFolderAlertPolicyName(folderAlertPolicyName: string) { - return this._pathTemplates.folderAlertPolicyPathTemplate.match(folderAlertPolicyName).folder; - } - - /** - * Parse the alert_policy from FolderAlertPolicy resource. - * - * @param {string} folderAlertPolicyName - * A fully-qualified path representing folder_alert_policy resource. - * @returns {string} A string representing the alert_policy. - */ - matchAlertPolicyFromFolderAlertPolicyName(folderAlertPolicyName: string) { - return this._pathTemplates.folderAlertPolicyPathTemplate.match(folderAlertPolicyName).alert_policy; - } - - /** - * Return a fully-qualified resource name string. - * - * @returns {string} Resource name string. - */ - Path() { - return this._pathTemplates.PathTemplate.render({ - }); - } - - /** - * Return a fully-qualified projectGroup resource name string. - * - * @param {string} project - * @param {string} group - * @returns {string} Resource name string. - */ - projectGroupPath(project:string,group:string) { - return this._pathTemplates.projectGroupPathTemplate.render({ - project: project, - group: group, - }); - } - - /** - * Parse the project from ProjectGroup resource. - * - * @param {string} projectGroupName - * A fully-qualified path representing project_group resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProjectGroupName(projectGroupName: string) { - return this._pathTemplates.projectGroupPathTemplate.match(projectGroupName).project; - } - - /** - * Parse the group from ProjectGroup resource. - * - * @param {string} projectGroupName - * A fully-qualified path representing project_group resource. - * @returns {string} A string representing the group. - */ - matchGroupFromProjectGroupName(projectGroupName: string) { - return this._pathTemplates.projectGroupPathTemplate.match(projectGroupName).group; - } - - /** - * Return a fully-qualified organizationGroup resource name string. - * - * @param {string} organization - * @param {string} group - * @returns {string} Resource name string. - */ - organizationGroupPath(organization:string,group:string) { - return this._pathTemplates.organizationGroupPathTemplate.render({ - organization: organization, - group: group, - }); - } - - /** - * Parse the organization from OrganizationGroup resource. - * - * @param {string} organizationGroupName - * A fully-qualified path representing organization_group resource. - * @returns {string} A string representing the organization. - */ - matchOrganizationFromOrganizationGroupName(organizationGroupName: string) { - return this._pathTemplates.organizationGroupPathTemplate.match(organizationGroupName).organization; - } - - /** - * Parse the group from OrganizationGroup resource. - * - * @param {string} organizationGroupName - * A fully-qualified path representing organization_group resource. - * @returns {string} A string representing the group. - */ - matchGroupFromOrganizationGroupName(organizationGroupName: string) { - return this._pathTemplates.organizationGroupPathTemplate.match(organizationGroupName).group; - } - - /** - * Return a fully-qualified folderGroup resource name string. - * - * @param {string} folder - * @param {string} group - * @returns {string} Resource name string. - */ - folderGroupPath(folder:string,group:string) { - return this._pathTemplates.folderGroupPathTemplate.render({ - folder: folder, - group: group, - }); - } - - /** - * Parse the folder from FolderGroup resource. - * - * @param {string} folderGroupName - * A fully-qualified path representing folder_group resource. - * @returns {string} A string representing the folder. - */ - matchFolderFromFolderGroupName(folderGroupName: string) { - return this._pathTemplates.folderGroupPathTemplate.match(folderGroupName).folder; - } - - /** - * Parse the group from FolderGroup resource. - * - * @param {string} folderGroupName - * A fully-qualified path representing folder_group resource. - * @returns {string} A string representing the group. - */ - matchGroupFromFolderGroupName(folderGroupName: string) { - return this._pathTemplates.folderGroupPathTemplate.match(folderGroupName).group; - } - - /** - * Return a fully-qualified projectChannelDescriptor resource name string. - * - * @param {string} project - * @param {string} channel_descriptor - * @returns {string} Resource name string. - */ - projectChannelDescriptorPath(project:string,channelDescriptor:string) { - return this._pathTemplates.projectChannelDescriptorPathTemplate.render({ - project: project, - channel_descriptor: channelDescriptor, - }); - } - - /** - * Parse the project from ProjectChannelDescriptor resource. - * - * @param {string} projectChannelDescriptorName - * A fully-qualified path representing project_channel_descriptor resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProjectChannelDescriptorName(projectChannelDescriptorName: string) { - return this._pathTemplates.projectChannelDescriptorPathTemplate.match(projectChannelDescriptorName).project; - } - - /** - * Parse the channel_descriptor from ProjectChannelDescriptor resource. - * - * @param {string} projectChannelDescriptorName - * A fully-qualified path representing project_channel_descriptor resource. - * @returns {string} A string representing the channel_descriptor. - */ - matchChannelDescriptorFromProjectChannelDescriptorName(projectChannelDescriptorName: string) { - return this._pathTemplates.projectChannelDescriptorPathTemplate.match(projectChannelDescriptorName).channel_descriptor; - } - - /** - * Return a fully-qualified organizationChannelDescriptor resource name string. - * - * @param {string} organization - * @param {string} channel_descriptor - * @returns {string} Resource name string. - */ - organizationChannelDescriptorPath(organization:string,channelDescriptor:string) { - return this._pathTemplates.organizationChannelDescriptorPathTemplate.render({ - organization: organization, - channel_descriptor: channelDescriptor, - }); - } - - /** - * Parse the organization from OrganizationChannelDescriptor resource. - * - * @param {string} organizationChannelDescriptorName - * A fully-qualified path representing organization_channel_descriptor resource. - * @returns {string} A string representing the organization. - */ - matchOrganizationFromOrganizationChannelDescriptorName(organizationChannelDescriptorName: string) { - return this._pathTemplates.organizationChannelDescriptorPathTemplate.match(organizationChannelDescriptorName).organization; - } - - /** - * Parse the channel_descriptor from OrganizationChannelDescriptor resource. - * - * @param {string} organizationChannelDescriptorName - * A fully-qualified path representing organization_channel_descriptor resource. - * @returns {string} A string representing the channel_descriptor. - */ - matchChannelDescriptorFromOrganizationChannelDescriptorName(organizationChannelDescriptorName: string) { - return this._pathTemplates.organizationChannelDescriptorPathTemplate.match(organizationChannelDescriptorName).channel_descriptor; - } - - /** - * Return a fully-qualified folderChannelDescriptor resource name string. - * - * @param {string} folder - * @param {string} channel_descriptor - * @returns {string} Resource name string. - */ - folderChannelDescriptorPath(folder:string,channelDescriptor:string) { - return this._pathTemplates.folderChannelDescriptorPathTemplate.render({ - folder: folder, - channel_descriptor: channelDescriptor, - }); - } - - /** - * Parse the folder from FolderChannelDescriptor resource. - * - * @param {string} folderChannelDescriptorName - * A fully-qualified path representing folder_channel_descriptor resource. - * @returns {string} A string representing the folder. - */ - matchFolderFromFolderChannelDescriptorName(folderChannelDescriptorName: string) { - return this._pathTemplates.folderChannelDescriptorPathTemplate.match(folderChannelDescriptorName).folder; - } - - /** - * Parse the channel_descriptor from FolderChannelDescriptor resource. - * - * @param {string} folderChannelDescriptorName - * A fully-qualified path representing folder_channel_descriptor resource. - * @returns {string} A string representing the channel_descriptor. - */ - matchChannelDescriptorFromFolderChannelDescriptorName(folderChannelDescriptorName: string) { - return this._pathTemplates.folderChannelDescriptorPathTemplate.match(folderChannelDescriptorName).channel_descriptor; - } - - /** - * Return a fully-qualified projectNotificationChannel resource name string. - * - * @param {string} project - * @param {string} notification_channel - * @returns {string} Resource name string. - */ - projectNotificationChannelPath(project:string,notificationChannel:string) { - return this._pathTemplates.projectNotificationChannelPathTemplate.render({ - project: project, - notification_channel: notificationChannel, - }); - } - - /** - * Parse the project from ProjectNotificationChannel resource. - * - * @param {string} projectNotificationChannelName - * A fully-qualified path representing project_notification_channel resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProjectNotificationChannelName(projectNotificationChannelName: string) { - return this._pathTemplates.projectNotificationChannelPathTemplate.match(projectNotificationChannelName).project; - } - - /** - * Parse the notification_channel from ProjectNotificationChannel resource. - * - * @param {string} projectNotificationChannelName - * A fully-qualified path representing project_notification_channel resource. - * @returns {string} A string representing the notification_channel. - */ - matchNotificationChannelFromProjectNotificationChannelName(projectNotificationChannelName: string) { - return this._pathTemplates.projectNotificationChannelPathTemplate.match(projectNotificationChannelName).notification_channel; - } - - /** - * Return a fully-qualified organizationNotificationChannel resource name string. - * - * @param {string} organization - * @param {string} notification_channel - * @returns {string} Resource name string. - */ - organizationNotificationChannelPath(organization:string,notificationChannel:string) { - return this._pathTemplates.organizationNotificationChannelPathTemplate.render({ - organization: organization, - notification_channel: notificationChannel, - }); - } - - /** - * Parse the organization from OrganizationNotificationChannel resource. - * - * @param {string} organizationNotificationChannelName - * A fully-qualified path representing organization_notification_channel resource. - * @returns {string} A string representing the organization. - */ - matchOrganizationFromOrganizationNotificationChannelName(organizationNotificationChannelName: string) { - return this._pathTemplates.organizationNotificationChannelPathTemplate.match(organizationNotificationChannelName).organization; - } - - /** - * Parse the notification_channel from OrganizationNotificationChannel resource. - * - * @param {string} organizationNotificationChannelName - * A fully-qualified path representing organization_notification_channel resource. - * @returns {string} A string representing the notification_channel. - */ - matchNotificationChannelFromOrganizationNotificationChannelName(organizationNotificationChannelName: string) { - return this._pathTemplates.organizationNotificationChannelPathTemplate.match(organizationNotificationChannelName).notification_channel; - } - - /** - * Return a fully-qualified folderNotificationChannel resource name string. - * - * @param {string} folder - * @param {string} notification_channel - * @returns {string} Resource name string. - */ - folderNotificationChannelPath(folder:string,notificationChannel:string) { - return this._pathTemplates.folderNotificationChannelPathTemplate.render({ - folder: folder, - notification_channel: notificationChannel, - }); - } - - /** - * Parse the folder from FolderNotificationChannel resource. - * - * @param {string} folderNotificationChannelName - * A fully-qualified path representing folder_notification_channel resource. - * @returns {string} A string representing the folder. - */ - matchFolderFromFolderNotificationChannelName(folderNotificationChannelName: string) { - return this._pathTemplates.folderNotificationChannelPathTemplate.match(folderNotificationChannelName).folder; - } - - /** - * Parse the notification_channel from FolderNotificationChannel resource. - * - * @param {string} folderNotificationChannelName - * A fully-qualified path representing folder_notification_channel resource. - * @returns {string} A string representing the notification_channel. - */ - matchNotificationChannelFromFolderNotificationChannelName(folderNotificationChannelName: string) { - return this._pathTemplates.folderNotificationChannelPathTemplate.match(folderNotificationChannelName).notification_channel; - } - - /** - * Return a fully-qualified projectService resource name string. - * - * @param {string} project - * @param {string} service - * @returns {string} Resource name string. - */ - projectServicePath(project:string,service:string) { - return this._pathTemplates.projectServicePathTemplate.render({ - project: project, - service: service, - }); - } - - /** - * Parse the project from ProjectService resource. - * - * @param {string} projectServiceName - * A fully-qualified path representing project_service resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProjectServiceName(projectServiceName: string) { - return this._pathTemplates.projectServicePathTemplate.match(projectServiceName).project; - } - - /** - * Parse the service from ProjectService resource. - * - * @param {string} projectServiceName - * A fully-qualified path representing project_service resource. - * @returns {string} A string representing the service. - */ - matchServiceFromProjectServiceName(projectServiceName: string) { - return this._pathTemplates.projectServicePathTemplate.match(projectServiceName).service; - } - - /** - * Return a fully-qualified organizationService resource name string. - * - * @param {string} organization - * @param {string} service - * @returns {string} Resource name string. - */ - organizationServicePath(organization:string,service:string) { - return this._pathTemplates.organizationServicePathTemplate.render({ - organization: organization, - service: service, - }); - } - - /** - * Parse the organization from OrganizationService resource. - * - * @param {string} organizationServiceName - * A fully-qualified path representing organization_service resource. - * @returns {string} A string representing the organization. - */ - matchOrganizationFromOrganizationServiceName(organizationServiceName: string) { - return this._pathTemplates.organizationServicePathTemplate.match(organizationServiceName).organization; - } - - /** - * Parse the service from OrganizationService resource. - * - * @param {string} organizationServiceName - * A fully-qualified path representing organization_service resource. - * @returns {string} A string representing the service. - */ - matchServiceFromOrganizationServiceName(organizationServiceName: string) { - return this._pathTemplates.organizationServicePathTemplate.match(organizationServiceName).service; - } - - /** - * Return a fully-qualified folderService resource name string. - * - * @param {string} folder - * @param {string} service - * @returns {string} Resource name string. - */ - folderServicePath(folder:string,service:string) { - return this._pathTemplates.folderServicePathTemplate.render({ - folder: folder, - service: service, - }); - } - - /** - * Parse the folder from FolderService resource. - * - * @param {string} folderServiceName - * A fully-qualified path representing folder_service resource. - * @returns {string} A string representing the folder. - */ - matchFolderFromFolderServiceName(folderServiceName: string) { - return this._pathTemplates.folderServicePathTemplate.match(folderServiceName).folder; - } - - /** - * Parse the service from FolderService resource. - * - * @param {string} folderServiceName - * A fully-qualified path representing folder_service resource. - * @returns {string} A string representing the service. - */ - matchServiceFromFolderServiceName(folderServiceName: string) { - return this._pathTemplates.folderServicePathTemplate.match(folderServiceName).service; - } - - /** - * Return a fully-qualified projectServiceServiceLevelObjective resource name string. - * - * @param {string} project - * @param {string} service - * @param {string} service_level_objective - * @returns {string} Resource name string. - */ - projectServiceServiceLevelObjectivePath(project:string,service:string,serviceLevelObjective:string) { - return this._pathTemplates.projectServiceServiceLevelObjectivePathTemplate.render({ - project: project, - service: service, - service_level_objective: serviceLevelObjective, - }); - } - - /** - * Parse the project from ProjectServiceServiceLevelObjective resource. - * - * @param {string} projectServiceServiceLevelObjectiveName - * A fully-qualified path representing project_service_service_level_objective resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProjectServiceServiceLevelObjectiveName(projectServiceServiceLevelObjectiveName: string) { - return this._pathTemplates.projectServiceServiceLevelObjectivePathTemplate.match(projectServiceServiceLevelObjectiveName).project; - } - - /** - * Parse the service from ProjectServiceServiceLevelObjective resource. - * - * @param {string} projectServiceServiceLevelObjectiveName - * A fully-qualified path representing project_service_service_level_objective resource. - * @returns {string} A string representing the service. - */ - matchServiceFromProjectServiceServiceLevelObjectiveName(projectServiceServiceLevelObjectiveName: string) { - return this._pathTemplates.projectServiceServiceLevelObjectivePathTemplate.match(projectServiceServiceLevelObjectiveName).service; - } - - /** - * Parse the service_level_objective from ProjectServiceServiceLevelObjective resource. - * - * @param {string} projectServiceServiceLevelObjectiveName - * A fully-qualified path representing project_service_service_level_objective resource. - * @returns {string} A string representing the service_level_objective. - */ - matchServiceLevelObjectiveFromProjectServiceServiceLevelObjectiveName(projectServiceServiceLevelObjectiveName: string) { - return this._pathTemplates.projectServiceServiceLevelObjectivePathTemplate.match(projectServiceServiceLevelObjectiveName).service_level_objective; - } - - /** - * Return a fully-qualified organizationServiceServiceLevelObjective resource name string. - * - * @param {string} organization - * @param {string} service - * @param {string} service_level_objective - * @returns {string} Resource name string. - */ - organizationServiceServiceLevelObjectivePath(organization:string,service:string,serviceLevelObjective:string) { - return this._pathTemplates.organizationServiceServiceLevelObjectivePathTemplate.render({ - organization: organization, - service: service, - service_level_objective: serviceLevelObjective, - }); - } - - /** - * Parse the organization from OrganizationServiceServiceLevelObjective resource. - * - * @param {string} organizationServiceServiceLevelObjectiveName - * A fully-qualified path representing organization_service_service_level_objective resource. - * @returns {string} A string representing the organization. - */ - matchOrganizationFromOrganizationServiceServiceLevelObjectiveName(organizationServiceServiceLevelObjectiveName: string) { - return this._pathTemplates.organizationServiceServiceLevelObjectivePathTemplate.match(organizationServiceServiceLevelObjectiveName).organization; - } - - /** - * Parse the service from OrganizationServiceServiceLevelObjective resource. - * - * @param {string} organizationServiceServiceLevelObjectiveName - * A fully-qualified path representing organization_service_service_level_objective resource. - * @returns {string} A string representing the service. - */ - matchServiceFromOrganizationServiceServiceLevelObjectiveName(organizationServiceServiceLevelObjectiveName: string) { - return this._pathTemplates.organizationServiceServiceLevelObjectivePathTemplate.match(organizationServiceServiceLevelObjectiveName).service; - } - - /** - * Parse the service_level_objective from OrganizationServiceServiceLevelObjective resource. - * - * @param {string} organizationServiceServiceLevelObjectiveName - * A fully-qualified path representing organization_service_service_level_objective resource. - * @returns {string} A string representing the service_level_objective. - */ - matchServiceLevelObjectiveFromOrganizationServiceServiceLevelObjectiveName(organizationServiceServiceLevelObjectiveName: string) { - return this._pathTemplates.organizationServiceServiceLevelObjectivePathTemplate.match(organizationServiceServiceLevelObjectiveName).service_level_objective; - } - - /** - * Return a fully-qualified folderServiceServiceLevelObjective resource name string. - * - * @param {string} folder - * @param {string} service - * @param {string} service_level_objective - * @returns {string} Resource name string. - */ - folderServiceServiceLevelObjectivePath(folder:string,service:string,serviceLevelObjective:string) { - return this._pathTemplates.folderServiceServiceLevelObjectivePathTemplate.render({ - folder: folder, - service: service, - service_level_objective: serviceLevelObjective, - }); - } - - /** - * Parse the folder from FolderServiceServiceLevelObjective resource. - * - * @param {string} folderServiceServiceLevelObjectiveName - * A fully-qualified path representing folder_service_service_level_objective resource. - * @returns {string} A string representing the folder. - */ - matchFolderFromFolderServiceServiceLevelObjectiveName(folderServiceServiceLevelObjectiveName: string) { - return this._pathTemplates.folderServiceServiceLevelObjectivePathTemplate.match(folderServiceServiceLevelObjectiveName).folder; - } - - /** - * Parse the service from FolderServiceServiceLevelObjective resource. - * - * @param {string} folderServiceServiceLevelObjectiveName - * A fully-qualified path representing folder_service_service_level_objective resource. - * @returns {string} A string representing the service. - */ - matchServiceFromFolderServiceServiceLevelObjectiveName(folderServiceServiceLevelObjectiveName: string) { - return this._pathTemplates.folderServiceServiceLevelObjectivePathTemplate.match(folderServiceServiceLevelObjectiveName).service; - } - - /** - * Parse the service_level_objective from FolderServiceServiceLevelObjective resource. - * - * @param {string} folderServiceServiceLevelObjectiveName - * A fully-qualified path representing folder_service_service_level_objective resource. - * @returns {string} A string representing the service_level_objective. - */ - matchServiceLevelObjectiveFromFolderServiceServiceLevelObjectiveName(folderServiceServiceLevelObjectiveName: string) { - return this._pathTemplates.folderServiceServiceLevelObjectivePathTemplate.match(folderServiceServiceLevelObjectiveName).service_level_objective; - } - - /** - * Return a fully-qualified projectUptimeCheckConfig resource name string. - * - * @param {string} project - * @param {string} uptime_check_config - * @returns {string} Resource name string. - */ - projectUptimeCheckConfigPath(project:string,uptimeCheckConfig:string) { - return this._pathTemplates.projectUptimeCheckConfigPathTemplate.render({ - project: project, - uptime_check_config: uptimeCheckConfig, - }); - } - - /** - * Parse the project from ProjectUptimeCheckConfig resource. - * - * @param {string} projectUptimeCheckConfigName - * A fully-qualified path representing project_uptime_check_config resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProjectUptimeCheckConfigName(projectUptimeCheckConfigName: string) { - return this._pathTemplates.projectUptimeCheckConfigPathTemplate.match(projectUptimeCheckConfigName).project; - } - - /** - * Parse the uptime_check_config from ProjectUptimeCheckConfig resource. - * - * @param {string} projectUptimeCheckConfigName - * A fully-qualified path representing project_uptime_check_config resource. - * @returns {string} A string representing the uptime_check_config. - */ - matchUptimeCheckConfigFromProjectUptimeCheckConfigName(projectUptimeCheckConfigName: string) { - return this._pathTemplates.projectUptimeCheckConfigPathTemplate.match(projectUptimeCheckConfigName).uptime_check_config; - } - - /** - * Return a fully-qualified organizationUptimeCheckConfig resource name string. - * - * @param {string} organization - * @param {string} uptime_check_config - * @returns {string} Resource name string. - */ - organizationUptimeCheckConfigPath(organization:string,uptimeCheckConfig:string) { - return this._pathTemplates.organizationUptimeCheckConfigPathTemplate.render({ - organization: organization, - uptime_check_config: uptimeCheckConfig, - }); - } - - /** - * Parse the organization from OrganizationUptimeCheckConfig resource. - * - * @param {string} organizationUptimeCheckConfigName - * A fully-qualified path representing organization_uptime_check_config resource. - * @returns {string} A string representing the organization. - */ - matchOrganizationFromOrganizationUptimeCheckConfigName(organizationUptimeCheckConfigName: string) { - return this._pathTemplates.organizationUptimeCheckConfigPathTemplate.match(organizationUptimeCheckConfigName).organization; - } - - /** - * Parse the uptime_check_config from OrganizationUptimeCheckConfig resource. - * - * @param {string} organizationUptimeCheckConfigName - * A fully-qualified path representing organization_uptime_check_config resource. - * @returns {string} A string representing the uptime_check_config. - */ - matchUptimeCheckConfigFromOrganizationUptimeCheckConfigName(organizationUptimeCheckConfigName: string) { - return this._pathTemplates.organizationUptimeCheckConfigPathTemplate.match(organizationUptimeCheckConfigName).uptime_check_config; - } - - /** - * Return a fully-qualified folderUptimeCheckConfig resource name string. - * - * @param {string} folder - * @param {string} uptime_check_config - * @returns {string} Resource name string. - */ - folderUptimeCheckConfigPath(folder:string,uptimeCheckConfig:string) { - return this._pathTemplates.folderUptimeCheckConfigPathTemplate.render({ - folder: folder, - uptime_check_config: uptimeCheckConfig, - }); - } - - /** - * Parse the folder from FolderUptimeCheckConfig resource. - * - * @param {string} folderUptimeCheckConfigName - * A fully-qualified path representing folder_uptime_check_config resource. - * @returns {string} A string representing the folder. - */ - matchFolderFromFolderUptimeCheckConfigName(folderUptimeCheckConfigName: string) { - return this._pathTemplates.folderUptimeCheckConfigPathTemplate.match(folderUptimeCheckConfigName).folder; - } - - /** - * Parse the uptime_check_config from FolderUptimeCheckConfig resource. - * - * @param {string} folderUptimeCheckConfigName - * A fully-qualified path representing folder_uptime_check_config resource. - * @returns {string} A string representing the uptime_check_config. - */ - matchUptimeCheckConfigFromFolderUptimeCheckConfigName(folderUptimeCheckConfigName: string) { - return this._pathTemplates.folderUptimeCheckConfigPathTemplate.match(folderUptimeCheckConfigName).uptime_check_config; - } - - /** - * Terminate the GRPC channel and close the client. - * - * The client will no longer be usable and all future behavior is undefined. - */ - close(): Promise { - if (!this._terminated) { - return this.alertPolicyServiceStub.then(stub => { - this._terminated = true; - stub.close(); - }); - } - return Promise.resolve(); - } -} diff --git a/typescript/test/testdata/monitoring/src/v3/alert_policy_service_client_config.json.baseline b/typescript/test/testdata/monitoring/src/v3/alert_policy_service_client_config.json.baseline deleted file mode 100644 index 5c3935f3c..000000000 --- a/typescript/test/testdata/monitoring/src/v3/alert_policy_service_client_config.json.baseline +++ /dev/null @@ -1,46 +0,0 @@ -{ - "interfaces": { - "google.monitoring.v3.AlertPolicyService": { - "retry_codes": { - "non_idempotent": [], - "idempotent": [ - "DEADLINE_EXCEEDED", - "UNAVAILABLE" - ] - }, - "retry_params": { - "default": { - "initial_retry_delay_millis": 100, - "retry_delay_multiplier": 1.3, - "max_retry_delay_millis": 60000, - "initial_rpc_timeout_millis": 60000, - "rpc_timeout_multiplier": 1, - "max_rpc_timeout_millis": 60000, - "total_timeout_millis": 600000 - } - }, - "methods": { - "ListAlertPolicies": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "GetAlertPolicy": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "CreateAlertPolicy": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "DeleteAlertPolicy": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "UpdateAlertPolicy": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - } - } - } - } -} diff --git a/typescript/test/testdata/monitoring/src/v3/alert_policy_service_proto_list.json.baseline b/typescript/test/testdata/monitoring/src/v3/alert_policy_service_proto_list.json.baseline deleted file mode 100644 index aacceb22f..000000000 --- a/typescript/test/testdata/monitoring/src/v3/alert_policy_service_proto_list.json.baseline +++ /dev/null @@ -1,16 +0,0 @@ -[ - "../../protos/google/monitoring/v3/alert.proto", - "../../protos/google/monitoring/v3/alert_service.proto", - "../../protos/google/monitoring/v3/common.proto", - "../../protos/google/monitoring/v3/group.proto", - "../../protos/google/monitoring/v3/group_service.proto", - "../../protos/google/monitoring/v3/metric.proto", - "../../protos/google/monitoring/v3/metric_service.proto", - "../../protos/google/monitoring/v3/mutation_record.proto", - "../../protos/google/monitoring/v3/notification.proto", - "../../protos/google/monitoring/v3/notification_service.proto", - "../../protos/google/monitoring/v3/service.proto", - "../../protos/google/monitoring/v3/service_service.proto", - "../../protos/google/monitoring/v3/uptime.proto", - "../../protos/google/monitoring/v3/uptime_service.proto" -] diff --git a/typescript/test/testdata/monitoring/src/v3/group_service_client.ts.baseline b/typescript/test/testdata/monitoring/src/v3/group_service_client.ts.baseline deleted file mode 100644 index 74d2fbff0..000000000 --- a/typescript/test/testdata/monitoring/src/v3/group_service_client.ts.baseline +++ /dev/null @@ -1,1708 +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 gax from 'google-gax'; -import {APICallback, Callback, CallOptions, Descriptors, ClientOptions, PaginationCallback, PaginationResponse} from 'google-gax'; -import * as path from 'path'; - -import { Transform } from 'stream'; -import * as protosTypes from '../../protos/protos'; -import * as gapicConfig from './group_service_client_config.json'; - -const version = require('../../../package.json').version; - -/** - * The Group API lets you inspect and manage your - * [groups](#google.monitoring.v3.Group). - * - * A group is a named filter that is used to identify - * a collection of monitored resources. Groups are typically used to - * mirror the physical and/or logical topology of the environment. - * Because group membership is computed dynamically, monitored - * resources that are started in the future are automatically placed - * in matching groups. By using a group to name monitored resources in, - * for example, an alert policy, the target of that alert policy is - * updated automatically as monitored resources are added and removed - * from the infrastructure. - * @class - * @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; - auth: gax.GoogleAuth; - groupServiceStub: Promise<{[name: string]: Function}>; - - /** - * Construct an instance of GroupServiceClient. - * - * @param {object} [options] - The configuration object. See the subsequent - * parameters for more details. - * @param {object} [options.credentials] - Credentials object. - * @param {string} [options.credentials.client_email] - * @param {string} [options.credentials.private_key] - * @param {string} [options.email] - Account email address. Required when - * using a .pem or .p12 keyFilename. - * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or - * .p12 key downloaded from the Google Developers Console. If you provide - * a path to a JSON file, the projectId option below is not necessary. - * NOTE: .pem and .p12 require you to specify options.email as well. - * @param {number} [options.port] - The port on which to connect to - * the remote host. - * @param {string} [options.projectId] - The project ID from the Google - * Developer's Console, e.g. 'grape-spaceship-123'. We will also check - * the environment variable GCLOUD_PROJECT for your project ID. If your - * app is running in an environment which supports - * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, - * your project ID will be detected automatically. - * @param {function} [options.promise] - Custom promise module to use instead - * of native Promises. - * @param {string} [options.apiEndpoint] - The domain name of the - * API remote host. - */ - - constructor(opts?: ClientOptions) { - // Ensure that options include the service address and port. - const staticMembers = this.constructor as typeof GroupServiceClient; - const servicePath = opts && opts.servicePath ? - opts.servicePath : - ((opts && opts.apiEndpoint) ? opts.apiEndpoint : - staticMembers.servicePath); - const port = opts && opts.port ? opts.port : staticMembers.port; - - if (!opts) { - opts = {servicePath, port}; - } - opts.servicePath = opts.servicePath || servicePath; - opts.port = opts.port || port; - opts.clientConfig = opts.clientConfig || {}; - - const isBrowser = (typeof window !== 'undefined'); - if (isBrowser){ - opts.fallback = true; - } - // If we are in browser, we are already using fallback because of the - // "browser" field in package.json. - // But if we were explicitly requested to use fallback, let's do it now. - const gaxModule = !isBrowser && opts.fallback ? gax.fallback : gax; - - // Create a `gaxGrpc` object, with any grpc-specific options - // sent to the client. - opts.scopes = (this.constructor as typeof GroupServiceClient).scopes; - const gaxGrpc = new gaxModule.GrpcClient(opts); - - // Save the auth object to the client, for use by other methods. - this.auth = (gaxGrpc.auth as gax.GoogleAuth); - - // Determine the client header string. - const clientHeader = [ - `gax/${gaxModule.version}`, - `gapic/${version}`, - ]; - if (typeof process !== 'undefined' && 'versions' in process) { - clientHeader.push(`gl-node/${process.versions.node}`); - } else { - clientHeader.push(`gl-web/${gaxModule.version}`); - } - if (!opts.fallback) { - clientHeader.push(`grpc/${gaxGrpc.grpcVersion}`); - } - if (opts.libName && opts.libVersion) { - clientHeader.push(`${opts.libName}/${opts.libVersion}`); - } - // Load the applicable protos. - // For Node.js, pass the path to JSON proto file. - // For browsers, pass the JSON content. - - const nodejsProtoPath = path.join(__dirname, '..', '..', 'protos', 'protos.json'); - const protos = gaxGrpc.loadProto( - opts.fallback ? - 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 = { - projectAlertPolicyPathTemplate: new gaxModule.PathTemplate( - 'projects/{project}/alertPolicies/{alert_policy}' - ), - organizationAlertPolicyPathTemplate: new gaxModule.PathTemplate( - 'organizations/{organization}/alertPolicies/{alert_policy}' - ), - folderAlertPolicyPathTemplate: new gaxModule.PathTemplate( - 'folders/{folder}/alertPolicies/{alert_policy}' - ), - PathTemplate: new gaxModule.PathTemplate( - '*' - ), - projectGroupPathTemplate: new gaxModule.PathTemplate( - 'projects/{project}/groups/{group}' - ), - organizationGroupPathTemplate: new gaxModule.PathTemplate( - 'organizations/{organization}/groups/{group}' - ), - folderGroupPathTemplate: new gaxModule.PathTemplate( - 'folders/{folder}/groups/{group}' - ), - projectChannelDescriptorPathTemplate: new gaxModule.PathTemplate( - 'projects/{project}/notificationChannelDescriptors/{channel_descriptor}' - ), - organizationChannelDescriptorPathTemplate: new gaxModule.PathTemplate( - 'organizations/{organization}/notificationChannelDescriptors/{channel_descriptor}' - ), - folderChannelDescriptorPathTemplate: new gaxModule.PathTemplate( - 'folders/{folder}/notificationChannelDescriptors/{channel_descriptor}' - ), - projectNotificationChannelPathTemplate: new gaxModule.PathTemplate( - 'projects/{project}/notificationChannels/{notification_channel}' - ), - organizationNotificationChannelPathTemplate: new gaxModule.PathTemplate( - 'organizations/{organization}/notificationChannels/{notification_channel}' - ), - folderNotificationChannelPathTemplate: new gaxModule.PathTemplate( - 'folders/{folder}/notificationChannels/{notification_channel}' - ), - projectServicePathTemplate: new gaxModule.PathTemplate( - 'projects/{project}/services/{service}' - ), - organizationServicePathTemplate: new gaxModule.PathTemplate( - 'organizations/{organization}/services/{service}' - ), - folderServicePathTemplate: new gaxModule.PathTemplate( - 'folders/{folder}/services/{service}' - ), - projectServiceServiceLevelObjectivePathTemplate: new gaxModule.PathTemplate( - 'projects/{project}/services/{service}/serviceLevelObjectives/{service_level_objective}' - ), - organizationServiceServiceLevelObjectivePathTemplate: new gaxModule.PathTemplate( - 'organizations/{organization}/services/{service}/serviceLevelObjectives/{service_level_objective}' - ), - folderServiceServiceLevelObjectivePathTemplate: new gaxModule.PathTemplate( - 'folders/{folder}/services/{service}/serviceLevelObjectives/{service_level_objective}' - ), - projectUptimeCheckConfigPathTemplate: new gaxModule.PathTemplate( - 'projects/{project}/uptimeCheckConfigs/{uptime_check_config}' - ), - organizationUptimeCheckConfigPathTemplate: new gaxModule.PathTemplate( - 'organizations/{organization}/uptimeCheckConfigs/{uptime_check_config}' - ), - folderUptimeCheckConfigPathTemplate: new gaxModule.PathTemplate( - 'folders/{folder}/uptimeCheckConfigs/{uptime_check_config}' - ), - }; - - // 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 = { - listGroups: - new gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'group'), - listGroupMembers: - new gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'members') - }; - - // Put together the default options sent with requests. - const defaults = gaxGrpc.constructSettings( - 'google.monitoring.v3.GroupService', gapicConfig as gax.ClientConfig, - opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); - - // Set up a dictionary of "inner API calls"; the core implementation - // of calling the API is handled in `google-gax`, with this code - // merely providing the destination and request information. - this._innerApiCalls = {}; - - // Put together the "service stub" for - // google.monitoring.v3.GroupService. - this.groupServiceStub = gaxGrpc.createStub( - opts.fallback ? - (protos as protobuf.Root).lookupService('google.monitoring.v3.GroupService') : - // tslint:disable-next-line no-any - (protos as any).google.monitoring.v3.GroupService, - opts) as Promise<{[method: string]: Function}>; - - // Iterate over each of the methods that the service provides - // and create an API call method for each. - const groupServiceStubMethods = - ['listGroups', 'getGroup', 'createGroup', 'updateGroup', 'deleteGroup', 'listGroupMembers']; - - for (const methodName of groupServiceStubMethods) { - const innerCallPromise = this.groupServiceStub.then( - stub => (...args: Array<{}>) => { - if (this._terminated) { - return Promise.reject('The client has already been closed.'); - } - return stub[methodName].apply(stub, args); - }, - (err: Error|null|undefined) => () => { - throw err; - }); - - const apiCall = gaxModule.createApiCall( - innerCallPromise, - defaults[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); - }; - } - } - - /** - * The DNS address for this API service. - */ - static get servicePath() { - return 'monitoring.googleapis.com'; - } - - /** - * The DNS address for this API service - same as servicePath(), - * exists for compatibility reasons. - */ - static get apiEndpoint() { - return 'monitoring.googleapis.com'; - } - - /** - * The port for this API service. - */ - static get port() { - return 443; - } - - /** - * The scopes needed to make gRPC calls for every method defined - * in this service. - */ - static get scopes() { - return [ - 'https://www.googleapis.com/auth/cloud-platform', - 'https://www.googleapis.com/auth/monitoring', - 'https://www.googleapis.com/auth/monitoring.read' - ]; - } - - getProjectId(): Promise; - getProjectId(callback: Callback): void; - /** - * Return the project ID used by this class. - * @param {function(Error, string)} callback - the callback to - * be called with the current project Id. - */ - getProjectId(callback?: Callback): - Promise|void { - if (callback) { - this.auth.getProjectId(callback); - return; - } - return this.auth.getProjectId(); - } - - // ------------------- - // -- Service calls -- - // ------------------- - getGroup( - request: protosTypes.google.monitoring.v3.IGetGroupRequest, - options?: gax.CallOptions): - Promise<[ - protosTypes.google.monitoring.v3.IGroup, - protosTypes.google.monitoring.v3.IGetGroupRequest|undefined, {}|undefined - ]>; - getGroup( - request: protosTypes.google.monitoring.v3.IGetGroupRequest, - options: gax.CallOptions, - callback: Callback< - protosTypes.google.monitoring.v3.IGroup, - protosTypes.google.monitoring.v3.IGetGroupRequest|undefined, - {}|undefined>): void; -/** - * Gets a single group. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The group to retrieve. The format is - * `"projects/{project_id_or_number}/groups/{group_id}"`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Group]{@link google.monitoring.v3.Group}. - * The promise has a method named "cancel" which cancels the ongoing API call. - */ - getGroup( - request: protosTypes.google.monitoring.v3.IGetGroupRequest, - optionsOrCallback?: gax.CallOptions|Callback< - protosTypes.google.monitoring.v3.IGroup, - protosTypes.google.monitoring.v3.IGetGroupRequest|undefined, {}|undefined>, - callback?: Callback< - protosTypes.google.monitoring.v3.IGroup, - protosTypes.google.monitoring.v3.IGetGroupRequest|undefined, - {}|undefined>): - Promise<[ - protosTypes.google.monitoring.v3.IGroup, - protosTypes.google.monitoring.v3.IGetGroupRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: gax.CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as gax.CallOptions; - } - 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 || '', - }); - return this._innerApiCalls.getGroup(request, options, callback); - } - createGroup( - request: protosTypes.google.monitoring.v3.ICreateGroupRequest, - options?: gax.CallOptions): - Promise<[ - protosTypes.google.monitoring.v3.IGroup, - protosTypes.google.monitoring.v3.ICreateGroupRequest|undefined, {}|undefined - ]>; - createGroup( - request: protosTypes.google.monitoring.v3.ICreateGroupRequest, - options: gax.CallOptions, - callback: Callback< - protosTypes.google.monitoring.v3.IGroup, - protosTypes.google.monitoring.v3.ICreateGroupRequest|undefined, - {}|undefined>): void; -/** - * Creates a new group. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The project in which to create the group. The format is - * `"projects/{project_id_or_number}"`. - * @param {google.monitoring.v3.Group} request.group - * Required. A group definition. It is an error to define the `name` field because - * the system assigns the name. - * @param {boolean} request.validateOnly - * If true, validate this request but do not create the group. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Group]{@link google.monitoring.v3.Group}. - * The promise has a method named "cancel" which cancels the ongoing API call. - */ - createGroup( - request: protosTypes.google.monitoring.v3.ICreateGroupRequest, - optionsOrCallback?: gax.CallOptions|Callback< - protosTypes.google.monitoring.v3.IGroup, - protosTypes.google.monitoring.v3.ICreateGroupRequest|undefined, {}|undefined>, - callback?: Callback< - protosTypes.google.monitoring.v3.IGroup, - protosTypes.google.monitoring.v3.ICreateGroupRequest|undefined, - {}|undefined>): - Promise<[ - protosTypes.google.monitoring.v3.IGroup, - protosTypes.google.monitoring.v3.ICreateGroupRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: gax.CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as gax.CallOptions; - } - 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 || '', - }); - return this._innerApiCalls.createGroup(request, options, callback); - } - updateGroup( - request: protosTypes.google.monitoring.v3.IUpdateGroupRequest, - options?: gax.CallOptions): - Promise<[ - protosTypes.google.monitoring.v3.IGroup, - protosTypes.google.monitoring.v3.IUpdateGroupRequest|undefined, {}|undefined - ]>; - updateGroup( - request: protosTypes.google.monitoring.v3.IUpdateGroupRequest, - options: gax.CallOptions, - callback: Callback< - protosTypes.google.monitoring.v3.IGroup, - protosTypes.google.monitoring.v3.IUpdateGroupRequest|undefined, - {}|undefined>): void; -/** - * Updates an existing group. - * You can change any group attributes except `name`. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.monitoring.v3.Group} request.group - * Required. The new definition of the group. All fields of the existing group, - * excepting `name`, are replaced with the corresponding fields of this group. - * @param {boolean} request.validateOnly - * If true, validate this request but do not update the existing group. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Group]{@link google.monitoring.v3.Group}. - * The promise has a method named "cancel" which cancels the ongoing API call. - */ - updateGroup( - request: protosTypes.google.monitoring.v3.IUpdateGroupRequest, - optionsOrCallback?: gax.CallOptions|Callback< - protosTypes.google.monitoring.v3.IGroup, - protosTypes.google.monitoring.v3.IUpdateGroupRequest|undefined, {}|undefined>, - callback?: Callback< - protosTypes.google.monitoring.v3.IGroup, - protosTypes.google.monitoring.v3.IUpdateGroupRequest|undefined, - {}|undefined>): - Promise<[ - protosTypes.google.monitoring.v3.IGroup, - protosTypes.google.monitoring.v3.IUpdateGroupRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: gax.CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as gax.CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'group.name': request.group!.name || '', - }); - return this._innerApiCalls.updateGroup(request, options, callback); - } - deleteGroup( - request: protosTypes.google.monitoring.v3.IDeleteGroupRequest, - options?: gax.CallOptions): - Promise<[ - protosTypes.google.protobuf.IEmpty, - protosTypes.google.monitoring.v3.IDeleteGroupRequest|undefined, {}|undefined - ]>; - deleteGroup( - request: protosTypes.google.monitoring.v3.IDeleteGroupRequest, - options: gax.CallOptions, - callback: Callback< - protosTypes.google.protobuf.IEmpty, - protosTypes.google.monitoring.v3.IDeleteGroupRequest|undefined, - {}|undefined>): void; -/** - * Deletes an existing group. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The group to delete. The format is - * `"projects/{project_id_or_number}/groups/{group_id}"`. - * @param {boolean} request.recursive - * If this field is true, then the request means to delete a group with all - * its descendants. Otherwise, the request means to delete a group only when - * it has no descendants. The default value is false. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. - * The promise has a method named "cancel" which cancels the ongoing API call. - */ - deleteGroup( - request: protosTypes.google.monitoring.v3.IDeleteGroupRequest, - optionsOrCallback?: gax.CallOptions|Callback< - protosTypes.google.protobuf.IEmpty, - protosTypes.google.monitoring.v3.IDeleteGroupRequest|undefined, {}|undefined>, - callback?: Callback< - protosTypes.google.protobuf.IEmpty, - protosTypes.google.monitoring.v3.IDeleteGroupRequest|undefined, - {}|undefined>): - Promise<[ - protosTypes.google.protobuf.IEmpty, - protosTypes.google.monitoring.v3.IDeleteGroupRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: gax.CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as gax.CallOptions; - } - 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 || '', - }); - return this._innerApiCalls.deleteGroup(request, options, callback); - } - - listGroups( - request: protosTypes.google.monitoring.v3.IListGroupsRequest, - options?: gax.CallOptions): - Promise<[ - protosTypes.google.monitoring.v3.IGroup[], - protosTypes.google.monitoring.v3.IListGroupsRequest|null, - protosTypes.google.monitoring.v3.IListGroupsResponse - ]>; - listGroups( - request: protosTypes.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>): void; -/** - * Lists the existing groups. - * - * @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: `"projects/{project_id_or_number}/groups/{group_id}"`. - * Returns groups whose `parentName` field contains the group - * name. If no groups have this parent, the results are empty. - * @param {string} request.ancestorsOfGroup - * A group name: `"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: `"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 `childrenOfGroup` 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 `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 {Promise} - The promise which resolves to an array. - * The first element of the array is Array of [Group]{@link google.monitoring.v3.Group}. - * The client library support auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * - * When autoPaginate: false is specified through options, the array has three elements. - * The first element is Array of [Group]{@link google.monitoring.v3.Group} that corresponds to - * the one page received from the API server. - * If the second element is not null it contains the request object of type [ListGroupsRequest]{@link google.monitoring.v3.ListGroupsRequest} - * that can be used to obtain the next page of the results. - * If it is null, the next page does not exist. - * The third element contains the raw response received from the API server. Its type is - * [ListGroupsResponse]{@link google.monitoring.v3.ListGroupsResponse}. - * - * The promise has a method named "cancel" which cancels the ongoing API call. - */ - listGroups( - request: protosTypes.google.monitoring.v3.IListGroupsRequest, - optionsOrCallback?: gax.CallOptions|Callback< - protosTypes.google.monitoring.v3.IGroup[], - protosTypes.google.monitoring.v3.IListGroupsRequest|null, - protosTypes.google.monitoring.v3.IListGroupsResponse>, - callback?: Callback< - protosTypes.google.monitoring.v3.IGroup[], - protosTypes.google.monitoring.v3.IListGroupsRequest|null, - protosTypes.google.monitoring.v3.IListGroupsResponse>): - Promise<[ - protosTypes.google.monitoring.v3.IGroup[], - protosTypes.google.monitoring.v3.IListGroupsRequest|null, - protosTypes.google.monitoring.v3.IListGroupsResponse - ]>|void { - request = request || {}; - let options: gax.CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as gax.CallOptions; - } - 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 || '', - }); - return this._innerApiCalls.listGroups(request, options, callback); - } - -/** - * Equivalent to {@link listGroups}, but returns a NodeJS Stream object. - * - * This fetches the paged responses for {@link listGroups} continuously - * and invokes the callback registered for 'data' event for each element in the - * responses. - * - * The returned object has 'end' method when no more elements are required. - * - * autoPaginate option will be ignored. - * - * @see {@link https://nodejs.org/api/stream.html} - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.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: `"projects/{project_id_or_number}/groups/{group_id}"`. - * Returns groups whose `parentName` field contains the group - * name. If no groups have this parent, the results are empty. - * @param {string} request.ancestorsOfGroup - * A group name: `"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: `"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 `childrenOfGroup` 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 `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 {Stream} - * An object stream which emits an object representing [Group]{@link google.monitoring.v3.Group} on 'data' event. - */ - listGroupsStream( - request?: protosTypes.google.monitoring.v3.IListGroupsRequest, - options?: gax.CallOptions | {}): - Transform{ - request = request || {}; - const callSettings = new gax.CallSettings(options); - return this._descriptors.page.listGroups.createStream( - this._innerApiCalls.listGroups as gax.GaxCall, - request, - callSettings - ); - } - listGroupMembers( - request: protosTypes.google.monitoring.v3.IListGroupMembersRequest, - options?: gax.CallOptions): - Promise<[ - protosTypes.google.api.IMonitoredResource[], - protosTypes.google.monitoring.v3.IListGroupMembersRequest|null, - protosTypes.google.monitoring.v3.IListGroupMembersResponse - ]>; - listGroupMembers( - request: protosTypes.google.monitoring.v3.IListGroupMembersRequest, - options: gax.CallOptions, - callback: Callback< - protosTypes.google.api.IMonitoredResource[], - protosTypes.google.monitoring.v3.IListGroupMembersRequest|null, - protosTypes.google.monitoring.v3.IListGroupMembersResponse>): void; -/** - * Lists the monitored resources that are members of a group. - * - * @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 `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 {string} request.filter - * An optional [list filter](/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 {Promise} - The promise which resolves to an array. - * The first element of the array is Array of [MonitoredResource]{@link google.api.MonitoredResource}. - * The client library support auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * - * When autoPaginate: false is specified through options, the array has three elements. - * The first element is Array of [MonitoredResource]{@link google.api.MonitoredResource} that corresponds to - * the one page received from the API server. - * If the second element is not null it contains the request object of type [ListGroupMembersRequest]{@link google.monitoring.v3.ListGroupMembersRequest} - * that can be used to obtain the next page of the results. - * If it is null, the next page does not exist. - * The third element contains the raw response received from the API server. Its type is - * [ListGroupMembersResponse]{@link google.monitoring.v3.ListGroupMembersResponse}. - * - * The promise has a method named "cancel" which cancels the ongoing API call. - */ - listGroupMembers( - request: protosTypes.google.monitoring.v3.IListGroupMembersRequest, - optionsOrCallback?: gax.CallOptions|Callback< - protosTypes.google.api.IMonitoredResource[], - protosTypes.google.monitoring.v3.IListGroupMembersRequest|null, - protosTypes.google.monitoring.v3.IListGroupMembersResponse>, - callback?: Callback< - protosTypes.google.api.IMonitoredResource[], - protosTypes.google.monitoring.v3.IListGroupMembersRequest|null, - protosTypes.google.monitoring.v3.IListGroupMembersResponse>): - Promise<[ - protosTypes.google.api.IMonitoredResource[], - protosTypes.google.monitoring.v3.IListGroupMembersRequest|null, - protosTypes.google.monitoring.v3.IListGroupMembersResponse - ]>|void { - request = request || {}; - let options: gax.CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as gax.CallOptions; - } - 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 || '', - }); - return this._innerApiCalls.listGroupMembers(request, options, callback); - } - -/** - * Equivalent to {@link listGroupMembers}, but returns a NodeJS Stream object. - * - * This fetches the paged responses for {@link listGroupMembers} continuously - * and invokes the callback registered for 'data' event for each element in the - * responses. - * - * The returned object has 'end' method when no more elements are required. - * - * autoPaginate option will be ignored. - * - * @see {@link https://nodejs.org/api/stream.html} - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.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 `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 {string} request.filter - * An optional [list filter](/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 {Stream} - * An object stream which emits an object representing [MonitoredResource]{@link google.api.MonitoredResource} on 'data' event. - */ - listGroupMembersStream( - request?: protosTypes.google.monitoring.v3.IListGroupMembersRequest, - options?: gax.CallOptions | {}): - Transform{ - request = request || {}; - const callSettings = new gax.CallSettings(options); - return this._descriptors.page.listGroupMembers.createStream( - this._innerApiCalls.listGroupMembers as gax.GaxCall, - request, - callSettings - ); - } - // -------------------- - // -- Path templates -- - // -------------------- - - /** - * Return a fully-qualified projectAlertPolicy resource name string. - * - * @param {string} project - * @param {string} alert_policy - * @returns {string} Resource name string. - */ - projectAlertPolicyPath(project:string,alertPolicy:string) { - return this._pathTemplates.projectAlertPolicyPathTemplate.render({ - project: project, - alert_policy: alertPolicy, - }); - } - - /** - * Parse the project from ProjectAlertPolicy resource. - * - * @param {string} projectAlertPolicyName - * A fully-qualified path representing project_alert_policy resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProjectAlertPolicyName(projectAlertPolicyName: string) { - return this._pathTemplates.projectAlertPolicyPathTemplate.match(projectAlertPolicyName).project; - } - - /** - * Parse the alert_policy from ProjectAlertPolicy resource. - * - * @param {string} projectAlertPolicyName - * A fully-qualified path representing project_alert_policy resource. - * @returns {string} A string representing the alert_policy. - */ - matchAlertPolicyFromProjectAlertPolicyName(projectAlertPolicyName: string) { - return this._pathTemplates.projectAlertPolicyPathTemplate.match(projectAlertPolicyName).alert_policy; - } - - /** - * Return a fully-qualified organizationAlertPolicy resource name string. - * - * @param {string} organization - * @param {string} alert_policy - * @returns {string} Resource name string. - */ - organizationAlertPolicyPath(organization:string,alertPolicy:string) { - return this._pathTemplates.organizationAlertPolicyPathTemplate.render({ - organization: organization, - alert_policy: alertPolicy, - }); - } - - /** - * Parse the organization from OrganizationAlertPolicy resource. - * - * @param {string} organizationAlertPolicyName - * A fully-qualified path representing organization_alert_policy resource. - * @returns {string} A string representing the organization. - */ - matchOrganizationFromOrganizationAlertPolicyName(organizationAlertPolicyName: string) { - return this._pathTemplates.organizationAlertPolicyPathTemplate.match(organizationAlertPolicyName).organization; - } - - /** - * Parse the alert_policy from OrganizationAlertPolicy resource. - * - * @param {string} organizationAlertPolicyName - * A fully-qualified path representing organization_alert_policy resource. - * @returns {string} A string representing the alert_policy. - */ - matchAlertPolicyFromOrganizationAlertPolicyName(organizationAlertPolicyName: string) { - return this._pathTemplates.organizationAlertPolicyPathTemplate.match(organizationAlertPolicyName).alert_policy; - } - - /** - * Return a fully-qualified folderAlertPolicy resource name string. - * - * @param {string} folder - * @param {string} alert_policy - * @returns {string} Resource name string. - */ - folderAlertPolicyPath(folder:string,alertPolicy:string) { - return this._pathTemplates.folderAlertPolicyPathTemplate.render({ - folder: folder, - alert_policy: alertPolicy, - }); - } - - /** - * Parse the folder from FolderAlertPolicy resource. - * - * @param {string} folderAlertPolicyName - * A fully-qualified path representing folder_alert_policy resource. - * @returns {string} A string representing the folder. - */ - matchFolderFromFolderAlertPolicyName(folderAlertPolicyName: string) { - return this._pathTemplates.folderAlertPolicyPathTemplate.match(folderAlertPolicyName).folder; - } - - /** - * Parse the alert_policy from FolderAlertPolicy resource. - * - * @param {string} folderAlertPolicyName - * A fully-qualified path representing folder_alert_policy resource. - * @returns {string} A string representing the alert_policy. - */ - matchAlertPolicyFromFolderAlertPolicyName(folderAlertPolicyName: string) { - return this._pathTemplates.folderAlertPolicyPathTemplate.match(folderAlertPolicyName).alert_policy; - } - - /** - * Return a fully-qualified resource name string. - * - * @returns {string} Resource name string. - */ - Path() { - return this._pathTemplates.PathTemplate.render({ - }); - } - - /** - * Return a fully-qualified projectGroup resource name string. - * - * @param {string} project - * @param {string} group - * @returns {string} Resource name string. - */ - projectGroupPath(project:string,group:string) { - return this._pathTemplates.projectGroupPathTemplate.render({ - project: project, - group: group, - }); - } - - /** - * Parse the project from ProjectGroup resource. - * - * @param {string} projectGroupName - * A fully-qualified path representing project_group resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProjectGroupName(projectGroupName: string) { - return this._pathTemplates.projectGroupPathTemplate.match(projectGroupName).project; - } - - /** - * Parse the group from ProjectGroup resource. - * - * @param {string} projectGroupName - * A fully-qualified path representing project_group resource. - * @returns {string} A string representing the group. - */ - matchGroupFromProjectGroupName(projectGroupName: string) { - return this._pathTemplates.projectGroupPathTemplate.match(projectGroupName).group; - } - - /** - * Return a fully-qualified organizationGroup resource name string. - * - * @param {string} organization - * @param {string} group - * @returns {string} Resource name string. - */ - organizationGroupPath(organization:string,group:string) { - return this._pathTemplates.organizationGroupPathTemplate.render({ - organization: organization, - group: group, - }); - } - - /** - * Parse the organization from OrganizationGroup resource. - * - * @param {string} organizationGroupName - * A fully-qualified path representing organization_group resource. - * @returns {string} A string representing the organization. - */ - matchOrganizationFromOrganizationGroupName(organizationGroupName: string) { - return this._pathTemplates.organizationGroupPathTemplate.match(organizationGroupName).organization; - } - - /** - * Parse the group from OrganizationGroup resource. - * - * @param {string} organizationGroupName - * A fully-qualified path representing organization_group resource. - * @returns {string} A string representing the group. - */ - matchGroupFromOrganizationGroupName(organizationGroupName: string) { - return this._pathTemplates.organizationGroupPathTemplate.match(organizationGroupName).group; - } - - /** - * Return a fully-qualified folderGroup resource name string. - * - * @param {string} folder - * @param {string} group - * @returns {string} Resource name string. - */ - folderGroupPath(folder:string,group:string) { - return this._pathTemplates.folderGroupPathTemplate.render({ - folder: folder, - group: group, - }); - } - - /** - * Parse the folder from FolderGroup resource. - * - * @param {string} folderGroupName - * A fully-qualified path representing folder_group resource. - * @returns {string} A string representing the folder. - */ - matchFolderFromFolderGroupName(folderGroupName: string) { - return this._pathTemplates.folderGroupPathTemplate.match(folderGroupName).folder; - } - - /** - * Parse the group from FolderGroup resource. - * - * @param {string} folderGroupName - * A fully-qualified path representing folder_group resource. - * @returns {string} A string representing the group. - */ - matchGroupFromFolderGroupName(folderGroupName: string) { - return this._pathTemplates.folderGroupPathTemplate.match(folderGroupName).group; - } - - /** - * Return a fully-qualified projectChannelDescriptor resource name string. - * - * @param {string} project - * @param {string} channel_descriptor - * @returns {string} Resource name string. - */ - projectChannelDescriptorPath(project:string,channelDescriptor:string) { - return this._pathTemplates.projectChannelDescriptorPathTemplate.render({ - project: project, - channel_descriptor: channelDescriptor, - }); - } - - /** - * Parse the project from ProjectChannelDescriptor resource. - * - * @param {string} projectChannelDescriptorName - * A fully-qualified path representing project_channel_descriptor resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProjectChannelDescriptorName(projectChannelDescriptorName: string) { - return this._pathTemplates.projectChannelDescriptorPathTemplate.match(projectChannelDescriptorName).project; - } - - /** - * Parse the channel_descriptor from ProjectChannelDescriptor resource. - * - * @param {string} projectChannelDescriptorName - * A fully-qualified path representing project_channel_descriptor resource. - * @returns {string} A string representing the channel_descriptor. - */ - matchChannelDescriptorFromProjectChannelDescriptorName(projectChannelDescriptorName: string) { - return this._pathTemplates.projectChannelDescriptorPathTemplate.match(projectChannelDescriptorName).channel_descriptor; - } - - /** - * Return a fully-qualified organizationChannelDescriptor resource name string. - * - * @param {string} organization - * @param {string} channel_descriptor - * @returns {string} Resource name string. - */ - organizationChannelDescriptorPath(organization:string,channelDescriptor:string) { - return this._pathTemplates.organizationChannelDescriptorPathTemplate.render({ - organization: organization, - channel_descriptor: channelDescriptor, - }); - } - - /** - * Parse the organization from OrganizationChannelDescriptor resource. - * - * @param {string} organizationChannelDescriptorName - * A fully-qualified path representing organization_channel_descriptor resource. - * @returns {string} A string representing the organization. - */ - matchOrganizationFromOrganizationChannelDescriptorName(organizationChannelDescriptorName: string) { - return this._pathTemplates.organizationChannelDescriptorPathTemplate.match(organizationChannelDescriptorName).organization; - } - - /** - * Parse the channel_descriptor from OrganizationChannelDescriptor resource. - * - * @param {string} organizationChannelDescriptorName - * A fully-qualified path representing organization_channel_descriptor resource. - * @returns {string} A string representing the channel_descriptor. - */ - matchChannelDescriptorFromOrganizationChannelDescriptorName(organizationChannelDescriptorName: string) { - return this._pathTemplates.organizationChannelDescriptorPathTemplate.match(organizationChannelDescriptorName).channel_descriptor; - } - - /** - * Return a fully-qualified folderChannelDescriptor resource name string. - * - * @param {string} folder - * @param {string} channel_descriptor - * @returns {string} Resource name string. - */ - folderChannelDescriptorPath(folder:string,channelDescriptor:string) { - return this._pathTemplates.folderChannelDescriptorPathTemplate.render({ - folder: folder, - channel_descriptor: channelDescriptor, - }); - } - - /** - * Parse the folder from FolderChannelDescriptor resource. - * - * @param {string} folderChannelDescriptorName - * A fully-qualified path representing folder_channel_descriptor resource. - * @returns {string} A string representing the folder. - */ - matchFolderFromFolderChannelDescriptorName(folderChannelDescriptorName: string) { - return this._pathTemplates.folderChannelDescriptorPathTemplate.match(folderChannelDescriptorName).folder; - } - - /** - * Parse the channel_descriptor from FolderChannelDescriptor resource. - * - * @param {string} folderChannelDescriptorName - * A fully-qualified path representing folder_channel_descriptor resource. - * @returns {string} A string representing the channel_descriptor. - */ - matchChannelDescriptorFromFolderChannelDescriptorName(folderChannelDescriptorName: string) { - return this._pathTemplates.folderChannelDescriptorPathTemplate.match(folderChannelDescriptorName).channel_descriptor; - } - - /** - * Return a fully-qualified projectNotificationChannel resource name string. - * - * @param {string} project - * @param {string} notification_channel - * @returns {string} Resource name string. - */ - projectNotificationChannelPath(project:string,notificationChannel:string) { - return this._pathTemplates.projectNotificationChannelPathTemplate.render({ - project: project, - notification_channel: notificationChannel, - }); - } - - /** - * Parse the project from ProjectNotificationChannel resource. - * - * @param {string} projectNotificationChannelName - * A fully-qualified path representing project_notification_channel resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProjectNotificationChannelName(projectNotificationChannelName: string) { - return this._pathTemplates.projectNotificationChannelPathTemplate.match(projectNotificationChannelName).project; - } - - /** - * Parse the notification_channel from ProjectNotificationChannel resource. - * - * @param {string} projectNotificationChannelName - * A fully-qualified path representing project_notification_channel resource. - * @returns {string} A string representing the notification_channel. - */ - matchNotificationChannelFromProjectNotificationChannelName(projectNotificationChannelName: string) { - return this._pathTemplates.projectNotificationChannelPathTemplate.match(projectNotificationChannelName).notification_channel; - } - - /** - * Return a fully-qualified organizationNotificationChannel resource name string. - * - * @param {string} organization - * @param {string} notification_channel - * @returns {string} Resource name string. - */ - organizationNotificationChannelPath(organization:string,notificationChannel:string) { - return this._pathTemplates.organizationNotificationChannelPathTemplate.render({ - organization: organization, - notification_channel: notificationChannel, - }); - } - - /** - * Parse the organization from OrganizationNotificationChannel resource. - * - * @param {string} organizationNotificationChannelName - * A fully-qualified path representing organization_notification_channel resource. - * @returns {string} A string representing the organization. - */ - matchOrganizationFromOrganizationNotificationChannelName(organizationNotificationChannelName: string) { - return this._pathTemplates.organizationNotificationChannelPathTemplate.match(organizationNotificationChannelName).organization; - } - - /** - * Parse the notification_channel from OrganizationNotificationChannel resource. - * - * @param {string} organizationNotificationChannelName - * A fully-qualified path representing organization_notification_channel resource. - * @returns {string} A string representing the notification_channel. - */ - matchNotificationChannelFromOrganizationNotificationChannelName(organizationNotificationChannelName: string) { - return this._pathTemplates.organizationNotificationChannelPathTemplate.match(organizationNotificationChannelName).notification_channel; - } - - /** - * Return a fully-qualified folderNotificationChannel resource name string. - * - * @param {string} folder - * @param {string} notification_channel - * @returns {string} Resource name string. - */ - folderNotificationChannelPath(folder:string,notificationChannel:string) { - return this._pathTemplates.folderNotificationChannelPathTemplate.render({ - folder: folder, - notification_channel: notificationChannel, - }); - } - - /** - * Parse the folder from FolderNotificationChannel resource. - * - * @param {string} folderNotificationChannelName - * A fully-qualified path representing folder_notification_channel resource. - * @returns {string} A string representing the folder. - */ - matchFolderFromFolderNotificationChannelName(folderNotificationChannelName: string) { - return this._pathTemplates.folderNotificationChannelPathTemplate.match(folderNotificationChannelName).folder; - } - - /** - * Parse the notification_channel from FolderNotificationChannel resource. - * - * @param {string} folderNotificationChannelName - * A fully-qualified path representing folder_notification_channel resource. - * @returns {string} A string representing the notification_channel. - */ - matchNotificationChannelFromFolderNotificationChannelName(folderNotificationChannelName: string) { - return this._pathTemplates.folderNotificationChannelPathTemplate.match(folderNotificationChannelName).notification_channel; - } - - /** - * Return a fully-qualified projectService resource name string. - * - * @param {string} project - * @param {string} service - * @returns {string} Resource name string. - */ - projectServicePath(project:string,service:string) { - return this._pathTemplates.projectServicePathTemplate.render({ - project: project, - service: service, - }); - } - - /** - * Parse the project from ProjectService resource. - * - * @param {string} projectServiceName - * A fully-qualified path representing project_service resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProjectServiceName(projectServiceName: string) { - return this._pathTemplates.projectServicePathTemplate.match(projectServiceName).project; - } - - /** - * Parse the service from ProjectService resource. - * - * @param {string} projectServiceName - * A fully-qualified path representing project_service resource. - * @returns {string} A string representing the service. - */ - matchServiceFromProjectServiceName(projectServiceName: string) { - return this._pathTemplates.projectServicePathTemplate.match(projectServiceName).service; - } - - /** - * Return a fully-qualified organizationService resource name string. - * - * @param {string} organization - * @param {string} service - * @returns {string} Resource name string. - */ - organizationServicePath(organization:string,service:string) { - return this._pathTemplates.organizationServicePathTemplate.render({ - organization: organization, - service: service, - }); - } - - /** - * Parse the organization from OrganizationService resource. - * - * @param {string} organizationServiceName - * A fully-qualified path representing organization_service resource. - * @returns {string} A string representing the organization. - */ - matchOrganizationFromOrganizationServiceName(organizationServiceName: string) { - return this._pathTemplates.organizationServicePathTemplate.match(organizationServiceName).organization; - } - - /** - * Parse the service from OrganizationService resource. - * - * @param {string} organizationServiceName - * A fully-qualified path representing organization_service resource. - * @returns {string} A string representing the service. - */ - matchServiceFromOrganizationServiceName(organizationServiceName: string) { - return this._pathTemplates.organizationServicePathTemplate.match(organizationServiceName).service; - } - - /** - * Return a fully-qualified folderService resource name string. - * - * @param {string} folder - * @param {string} service - * @returns {string} Resource name string. - */ - folderServicePath(folder:string,service:string) { - return this._pathTemplates.folderServicePathTemplate.render({ - folder: folder, - service: service, - }); - } - - /** - * Parse the folder from FolderService resource. - * - * @param {string} folderServiceName - * A fully-qualified path representing folder_service resource. - * @returns {string} A string representing the folder. - */ - matchFolderFromFolderServiceName(folderServiceName: string) { - return this._pathTemplates.folderServicePathTemplate.match(folderServiceName).folder; - } - - /** - * Parse the service from FolderService resource. - * - * @param {string} folderServiceName - * A fully-qualified path representing folder_service resource. - * @returns {string} A string representing the service. - */ - matchServiceFromFolderServiceName(folderServiceName: string) { - return this._pathTemplates.folderServicePathTemplate.match(folderServiceName).service; - } - - /** - * Return a fully-qualified projectServiceServiceLevelObjective resource name string. - * - * @param {string} project - * @param {string} service - * @param {string} service_level_objective - * @returns {string} Resource name string. - */ - projectServiceServiceLevelObjectivePath(project:string,service:string,serviceLevelObjective:string) { - return this._pathTemplates.projectServiceServiceLevelObjectivePathTemplate.render({ - project: project, - service: service, - service_level_objective: serviceLevelObjective, - }); - } - - /** - * Parse the project from ProjectServiceServiceLevelObjective resource. - * - * @param {string} projectServiceServiceLevelObjectiveName - * A fully-qualified path representing project_service_service_level_objective resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProjectServiceServiceLevelObjectiveName(projectServiceServiceLevelObjectiveName: string) { - return this._pathTemplates.projectServiceServiceLevelObjectivePathTemplate.match(projectServiceServiceLevelObjectiveName).project; - } - - /** - * Parse the service from ProjectServiceServiceLevelObjective resource. - * - * @param {string} projectServiceServiceLevelObjectiveName - * A fully-qualified path representing project_service_service_level_objective resource. - * @returns {string} A string representing the service. - */ - matchServiceFromProjectServiceServiceLevelObjectiveName(projectServiceServiceLevelObjectiveName: string) { - return this._pathTemplates.projectServiceServiceLevelObjectivePathTemplate.match(projectServiceServiceLevelObjectiveName).service; - } - - /** - * Parse the service_level_objective from ProjectServiceServiceLevelObjective resource. - * - * @param {string} projectServiceServiceLevelObjectiveName - * A fully-qualified path representing project_service_service_level_objective resource. - * @returns {string} A string representing the service_level_objective. - */ - matchServiceLevelObjectiveFromProjectServiceServiceLevelObjectiveName(projectServiceServiceLevelObjectiveName: string) { - return this._pathTemplates.projectServiceServiceLevelObjectivePathTemplate.match(projectServiceServiceLevelObjectiveName).service_level_objective; - } - - /** - * Return a fully-qualified organizationServiceServiceLevelObjective resource name string. - * - * @param {string} organization - * @param {string} service - * @param {string} service_level_objective - * @returns {string} Resource name string. - */ - organizationServiceServiceLevelObjectivePath(organization:string,service:string,serviceLevelObjective:string) { - return this._pathTemplates.organizationServiceServiceLevelObjectivePathTemplate.render({ - organization: organization, - service: service, - service_level_objective: serviceLevelObjective, - }); - } - - /** - * Parse the organization from OrganizationServiceServiceLevelObjective resource. - * - * @param {string} organizationServiceServiceLevelObjectiveName - * A fully-qualified path representing organization_service_service_level_objective resource. - * @returns {string} A string representing the organization. - */ - matchOrganizationFromOrganizationServiceServiceLevelObjectiveName(organizationServiceServiceLevelObjectiveName: string) { - return this._pathTemplates.organizationServiceServiceLevelObjectivePathTemplate.match(organizationServiceServiceLevelObjectiveName).organization; - } - - /** - * Parse the service from OrganizationServiceServiceLevelObjective resource. - * - * @param {string} organizationServiceServiceLevelObjectiveName - * A fully-qualified path representing organization_service_service_level_objective resource. - * @returns {string} A string representing the service. - */ - matchServiceFromOrganizationServiceServiceLevelObjectiveName(organizationServiceServiceLevelObjectiveName: string) { - return this._pathTemplates.organizationServiceServiceLevelObjectivePathTemplate.match(organizationServiceServiceLevelObjectiveName).service; - } - - /** - * Parse the service_level_objective from OrganizationServiceServiceLevelObjective resource. - * - * @param {string} organizationServiceServiceLevelObjectiveName - * A fully-qualified path representing organization_service_service_level_objective resource. - * @returns {string} A string representing the service_level_objective. - */ - matchServiceLevelObjectiveFromOrganizationServiceServiceLevelObjectiveName(organizationServiceServiceLevelObjectiveName: string) { - return this._pathTemplates.organizationServiceServiceLevelObjectivePathTemplate.match(organizationServiceServiceLevelObjectiveName).service_level_objective; - } - - /** - * Return a fully-qualified folderServiceServiceLevelObjective resource name string. - * - * @param {string} folder - * @param {string} service - * @param {string} service_level_objective - * @returns {string} Resource name string. - */ - folderServiceServiceLevelObjectivePath(folder:string,service:string,serviceLevelObjective:string) { - return this._pathTemplates.folderServiceServiceLevelObjectivePathTemplate.render({ - folder: folder, - service: service, - service_level_objective: serviceLevelObjective, - }); - } - - /** - * Parse the folder from FolderServiceServiceLevelObjective resource. - * - * @param {string} folderServiceServiceLevelObjectiveName - * A fully-qualified path representing folder_service_service_level_objective resource. - * @returns {string} A string representing the folder. - */ - matchFolderFromFolderServiceServiceLevelObjectiveName(folderServiceServiceLevelObjectiveName: string) { - return this._pathTemplates.folderServiceServiceLevelObjectivePathTemplate.match(folderServiceServiceLevelObjectiveName).folder; - } - - /** - * Parse the service from FolderServiceServiceLevelObjective resource. - * - * @param {string} folderServiceServiceLevelObjectiveName - * A fully-qualified path representing folder_service_service_level_objective resource. - * @returns {string} A string representing the service. - */ - matchServiceFromFolderServiceServiceLevelObjectiveName(folderServiceServiceLevelObjectiveName: string) { - return this._pathTemplates.folderServiceServiceLevelObjectivePathTemplate.match(folderServiceServiceLevelObjectiveName).service; - } - - /** - * Parse the service_level_objective from FolderServiceServiceLevelObjective resource. - * - * @param {string} folderServiceServiceLevelObjectiveName - * A fully-qualified path representing folder_service_service_level_objective resource. - * @returns {string} A string representing the service_level_objective. - */ - matchServiceLevelObjectiveFromFolderServiceServiceLevelObjectiveName(folderServiceServiceLevelObjectiveName: string) { - return this._pathTemplates.folderServiceServiceLevelObjectivePathTemplate.match(folderServiceServiceLevelObjectiveName).service_level_objective; - } - - /** - * Return a fully-qualified projectUptimeCheckConfig resource name string. - * - * @param {string} project - * @param {string} uptime_check_config - * @returns {string} Resource name string. - */ - projectUptimeCheckConfigPath(project:string,uptimeCheckConfig:string) { - return this._pathTemplates.projectUptimeCheckConfigPathTemplate.render({ - project: project, - uptime_check_config: uptimeCheckConfig, - }); - } - - /** - * Parse the project from ProjectUptimeCheckConfig resource. - * - * @param {string} projectUptimeCheckConfigName - * A fully-qualified path representing project_uptime_check_config resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProjectUptimeCheckConfigName(projectUptimeCheckConfigName: string) { - return this._pathTemplates.projectUptimeCheckConfigPathTemplate.match(projectUptimeCheckConfigName).project; - } - - /** - * Parse the uptime_check_config from ProjectUptimeCheckConfig resource. - * - * @param {string} projectUptimeCheckConfigName - * A fully-qualified path representing project_uptime_check_config resource. - * @returns {string} A string representing the uptime_check_config. - */ - matchUptimeCheckConfigFromProjectUptimeCheckConfigName(projectUptimeCheckConfigName: string) { - return this._pathTemplates.projectUptimeCheckConfigPathTemplate.match(projectUptimeCheckConfigName).uptime_check_config; - } - - /** - * Return a fully-qualified organizationUptimeCheckConfig resource name string. - * - * @param {string} organization - * @param {string} uptime_check_config - * @returns {string} Resource name string. - */ - organizationUptimeCheckConfigPath(organization:string,uptimeCheckConfig:string) { - return this._pathTemplates.organizationUptimeCheckConfigPathTemplate.render({ - organization: organization, - uptime_check_config: uptimeCheckConfig, - }); - } - - /** - * Parse the organization from OrganizationUptimeCheckConfig resource. - * - * @param {string} organizationUptimeCheckConfigName - * A fully-qualified path representing organization_uptime_check_config resource. - * @returns {string} A string representing the organization. - */ - matchOrganizationFromOrganizationUptimeCheckConfigName(organizationUptimeCheckConfigName: string) { - return this._pathTemplates.organizationUptimeCheckConfigPathTemplate.match(organizationUptimeCheckConfigName).organization; - } - - /** - * Parse the uptime_check_config from OrganizationUptimeCheckConfig resource. - * - * @param {string} organizationUptimeCheckConfigName - * A fully-qualified path representing organization_uptime_check_config resource. - * @returns {string} A string representing the uptime_check_config. - */ - matchUptimeCheckConfigFromOrganizationUptimeCheckConfigName(organizationUptimeCheckConfigName: string) { - return this._pathTemplates.organizationUptimeCheckConfigPathTemplate.match(organizationUptimeCheckConfigName).uptime_check_config; - } - - /** - * Return a fully-qualified folderUptimeCheckConfig resource name string. - * - * @param {string} folder - * @param {string} uptime_check_config - * @returns {string} Resource name string. - */ - folderUptimeCheckConfigPath(folder:string,uptimeCheckConfig:string) { - return this._pathTemplates.folderUptimeCheckConfigPathTemplate.render({ - folder: folder, - uptime_check_config: uptimeCheckConfig, - }); - } - - /** - * Parse the folder from FolderUptimeCheckConfig resource. - * - * @param {string} folderUptimeCheckConfigName - * A fully-qualified path representing folder_uptime_check_config resource. - * @returns {string} A string representing the folder. - */ - matchFolderFromFolderUptimeCheckConfigName(folderUptimeCheckConfigName: string) { - return this._pathTemplates.folderUptimeCheckConfigPathTemplate.match(folderUptimeCheckConfigName).folder; - } - - /** - * Parse the uptime_check_config from FolderUptimeCheckConfig resource. - * - * @param {string} folderUptimeCheckConfigName - * A fully-qualified path representing folder_uptime_check_config resource. - * @returns {string} A string representing the uptime_check_config. - */ - matchUptimeCheckConfigFromFolderUptimeCheckConfigName(folderUptimeCheckConfigName: string) { - return this._pathTemplates.folderUptimeCheckConfigPathTemplate.match(folderUptimeCheckConfigName).uptime_check_config; - } - - /** - * Terminate the GRPC channel and close the client. - * - * The client will no longer be usable and all future behavior is undefined. - */ - close(): Promise { - if (!this._terminated) { - return this.groupServiceStub.then(stub => { - this._terminated = true; - stub.close(); - }); - } - return Promise.resolve(); - } -} diff --git a/typescript/test/testdata/monitoring/src/v3/group_service_client_config.json.baseline b/typescript/test/testdata/monitoring/src/v3/group_service_client_config.json.baseline deleted file mode 100644 index e63f2afe3..000000000 --- a/typescript/test/testdata/monitoring/src/v3/group_service_client_config.json.baseline +++ /dev/null @@ -1,50 +0,0 @@ -{ - "interfaces": { - "google.monitoring.v3.GroupService": { - "retry_codes": { - "non_idempotent": [], - "idempotent": [ - "DEADLINE_EXCEEDED", - "UNAVAILABLE" - ] - }, - "retry_params": { - "default": { - "initial_retry_delay_millis": 100, - "retry_delay_multiplier": 1.3, - "max_retry_delay_millis": 60000, - "initial_rpc_timeout_millis": 60000, - "rpc_timeout_multiplier": 1, - "max_rpc_timeout_millis": 60000, - "total_timeout_millis": 600000 - } - }, - "methods": { - "ListGroups": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "GetGroup": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "CreateGroup": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "UpdateGroup": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "DeleteGroup": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "ListGroupMembers": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - } - } - } - } -} diff --git a/typescript/test/testdata/monitoring/src/v3/group_service_proto_list.json.baseline b/typescript/test/testdata/monitoring/src/v3/group_service_proto_list.json.baseline deleted file mode 100644 index aacceb22f..000000000 --- a/typescript/test/testdata/monitoring/src/v3/group_service_proto_list.json.baseline +++ /dev/null @@ -1,16 +0,0 @@ -[ - "../../protos/google/monitoring/v3/alert.proto", - "../../protos/google/monitoring/v3/alert_service.proto", - "../../protos/google/monitoring/v3/common.proto", - "../../protos/google/monitoring/v3/group.proto", - "../../protos/google/monitoring/v3/group_service.proto", - "../../protos/google/monitoring/v3/metric.proto", - "../../protos/google/monitoring/v3/metric_service.proto", - "../../protos/google/monitoring/v3/mutation_record.proto", - "../../protos/google/monitoring/v3/notification.proto", - "../../protos/google/monitoring/v3/notification_service.proto", - "../../protos/google/monitoring/v3/service.proto", - "../../protos/google/monitoring/v3/service_service.proto", - "../../protos/google/monitoring/v3/uptime.proto", - "../../protos/google/monitoring/v3/uptime_service.proto" -] diff --git a/typescript/test/testdata/monitoring/src/v3/index.ts.baseline b/typescript/test/testdata/monitoring/src/v3/index.ts.baseline index bb9e596d2..ac6b0b979 100644 --- a/typescript/test/testdata/monitoring/src/v3/index.ts.baseline +++ b/typescript/test/testdata/monitoring/src/v3/index.ts.baseline @@ -16,4 +16,4 @@ // ** https://github.com/googleapis/gapic-generator-typescript ** // ** All changes to this file may be overwritten. ** -export {AlertPolicyServiceClient} from './alert_policy_service_client';export {GroupServiceClient} from './group_service_client';export {MetricServiceClient} from './metric_service_client';export {NotificationChannelServiceClient} from './notification_channel_service_client';export {ServiceMonitoringServiceClient} from './service_monitoring_service_client';export {UptimeCheckServiceClient} from './uptime_check_service_client'; +export {ServiceMonitoringServiceClient} from './service_monitoring_service_client';export {UptimeCheckServiceClient} from './uptime_check_service_client'; diff --git a/typescript/test/testdata/monitoring/src/v3/metric_service_client.ts.baseline b/typescript/test/testdata/monitoring/src/v3/metric_service_client.ts.baseline deleted file mode 100644 index c43607f4d..000000000 --- a/typescript/test/testdata/monitoring/src/v3/metric_service_client.ts.baseline +++ /dev/null @@ -1,2161 +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 gax from 'google-gax'; -import {APICallback, Callback, CallOptions, Descriptors, ClientOptions, PaginationCallback, PaginationResponse} from 'google-gax'; -import * as path from 'path'; - -import { Transform } from 'stream'; -import * as protosTypes from '../../protos/protos'; -import * as gapicConfig from './metric_service_client_config.json'; - -const version = require('../../../package.json').version; - -/** - * Manages metric descriptors, monitored resource descriptors, and - * time series data. - * @class - * @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; - auth: gax.GoogleAuth; - metricServiceStub: Promise<{[name: string]: Function}>; - - /** - * Construct an instance of MetricServiceClient. - * - * @param {object} [options] - The configuration object. See the subsequent - * parameters for more details. - * @param {object} [options.credentials] - Credentials object. - * @param {string} [options.credentials.client_email] - * @param {string} [options.credentials.private_key] - * @param {string} [options.email] - Account email address. Required when - * using a .pem or .p12 keyFilename. - * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or - * .p12 key downloaded from the Google Developers Console. If you provide - * a path to a JSON file, the projectId option below is not necessary. - * NOTE: .pem and .p12 require you to specify options.email as well. - * @param {number} [options.port] - The port on which to connect to - * the remote host. - * @param {string} [options.projectId] - The project ID from the Google - * Developer's Console, e.g. 'grape-spaceship-123'. We will also check - * the environment variable GCLOUD_PROJECT for your project ID. If your - * app is running in an environment which supports - * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, - * your project ID will be detected automatically. - * @param {function} [options.promise] - Custom promise module to use instead - * of native Promises. - * @param {string} [options.apiEndpoint] - The domain name of the - * API remote host. - */ - - constructor(opts?: ClientOptions) { - // Ensure that options include the service address and port. - const staticMembers = this.constructor as typeof MetricServiceClient; - const servicePath = opts && opts.servicePath ? - opts.servicePath : - ((opts && opts.apiEndpoint) ? opts.apiEndpoint : - staticMembers.servicePath); - const port = opts && opts.port ? opts.port : staticMembers.port; - - if (!opts) { - opts = {servicePath, port}; - } - opts.servicePath = opts.servicePath || servicePath; - opts.port = opts.port || port; - opts.clientConfig = opts.clientConfig || {}; - - const isBrowser = (typeof window !== 'undefined'); - if (isBrowser){ - opts.fallback = true; - } - // If we are in browser, we are already using fallback because of the - // "browser" field in package.json. - // But if we were explicitly requested to use fallback, let's do it now. - const gaxModule = !isBrowser && opts.fallback ? gax.fallback : gax; - - // Create a `gaxGrpc` object, with any grpc-specific options - // sent to the client. - opts.scopes = (this.constructor as typeof MetricServiceClient).scopes; - const gaxGrpc = new gaxModule.GrpcClient(opts); - - // Save the auth object to the client, for use by other methods. - this.auth = (gaxGrpc.auth as gax.GoogleAuth); - - // Determine the client header string. - const clientHeader = [ - `gax/${gaxModule.version}`, - `gapic/${version}`, - ]; - if (typeof process !== 'undefined' && 'versions' in process) { - clientHeader.push(`gl-node/${process.versions.node}`); - } else { - clientHeader.push(`gl-web/${gaxModule.version}`); - } - if (!opts.fallback) { - clientHeader.push(`grpc/${gaxGrpc.grpcVersion}`); - } - if (opts.libName && opts.libVersion) { - clientHeader.push(`${opts.libName}/${opts.libVersion}`); - } - // Load the applicable protos. - // For Node.js, pass the path to JSON proto file. - // For browsers, pass the JSON content. - - const nodejsProtoPath = path.join(__dirname, '..', '..', 'protos', 'protos.json'); - const protos = gaxGrpc.loadProto( - opts.fallback ? - 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 = { - projectAlertPolicyPathTemplate: new gaxModule.PathTemplate( - 'projects/{project}/alertPolicies/{alert_policy}' - ), - organizationAlertPolicyPathTemplate: new gaxModule.PathTemplate( - 'organizations/{organization}/alertPolicies/{alert_policy}' - ), - folderAlertPolicyPathTemplate: new gaxModule.PathTemplate( - 'folders/{folder}/alertPolicies/{alert_policy}' - ), - PathTemplate: new gaxModule.PathTemplate( - '*' - ), - projectGroupPathTemplate: new gaxModule.PathTemplate( - 'projects/{project}/groups/{group}' - ), - organizationGroupPathTemplate: new gaxModule.PathTemplate( - 'organizations/{organization}/groups/{group}' - ), - folderGroupPathTemplate: new gaxModule.PathTemplate( - 'folders/{folder}/groups/{group}' - ), - projectChannelDescriptorPathTemplate: new gaxModule.PathTemplate( - 'projects/{project}/notificationChannelDescriptors/{channel_descriptor}' - ), - organizationChannelDescriptorPathTemplate: new gaxModule.PathTemplate( - 'organizations/{organization}/notificationChannelDescriptors/{channel_descriptor}' - ), - folderChannelDescriptorPathTemplate: new gaxModule.PathTemplate( - 'folders/{folder}/notificationChannelDescriptors/{channel_descriptor}' - ), - projectNotificationChannelPathTemplate: new gaxModule.PathTemplate( - 'projects/{project}/notificationChannels/{notification_channel}' - ), - organizationNotificationChannelPathTemplate: new gaxModule.PathTemplate( - 'organizations/{organization}/notificationChannels/{notification_channel}' - ), - folderNotificationChannelPathTemplate: new gaxModule.PathTemplate( - 'folders/{folder}/notificationChannels/{notification_channel}' - ), - projectServicePathTemplate: new gaxModule.PathTemplate( - 'projects/{project}/services/{service}' - ), - organizationServicePathTemplate: new gaxModule.PathTemplate( - 'organizations/{organization}/services/{service}' - ), - folderServicePathTemplate: new gaxModule.PathTemplate( - 'folders/{folder}/services/{service}' - ), - projectServiceServiceLevelObjectivePathTemplate: new gaxModule.PathTemplate( - 'projects/{project}/services/{service}/serviceLevelObjectives/{service_level_objective}' - ), - organizationServiceServiceLevelObjectivePathTemplate: new gaxModule.PathTemplate( - 'organizations/{organization}/services/{service}/serviceLevelObjectives/{service_level_objective}' - ), - folderServiceServiceLevelObjectivePathTemplate: new gaxModule.PathTemplate( - 'folders/{folder}/services/{service}/serviceLevelObjectives/{service_level_objective}' - ), - projectUptimeCheckConfigPathTemplate: new gaxModule.PathTemplate( - 'projects/{project}/uptimeCheckConfigs/{uptime_check_config}' - ), - organizationUptimeCheckConfigPathTemplate: new gaxModule.PathTemplate( - 'organizations/{organization}/uptimeCheckConfigs/{uptime_check_config}' - ), - folderUptimeCheckConfigPathTemplate: new gaxModule.PathTemplate( - 'folders/{folder}/uptimeCheckConfigs/{uptime_check_config}' - ), - projectMonitoredResourceDescriptorPathTemplate: new gaxModule.PathTemplate( - 'projects/{project}/monitoredResourceDescriptors/{monitored_resource_descriptor}' - ), - organizationMonitoredResourceDescriptorPathTemplate: new gaxModule.PathTemplate( - 'organizations/{organization}/monitoredResourceDescriptors/{monitored_resource_descriptor}' - ), - folderMonitoredResourceDescriptorPathTemplate: new gaxModule.PathTemplate( - 'folders/{folder}/monitoredResourceDescriptors/{monitored_resource_descriptor}' - ), - projectMetricDescriptorPathTemplate: new gaxModule.PathTemplate( - 'projects/{project}/metricDescriptors/{metric_descriptor=**}' - ), - organizationMetricDescriptorPathTemplate: new gaxModule.PathTemplate( - 'organizations/{organization}/metricDescriptors/{metric_descriptor=**}' - ), - folderMetricDescriptorPathTemplate: new gaxModule.PathTemplate( - 'folders/{folder}/metricDescriptors/{metric_descriptor=**}' - ), - }; - - // 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 = { - listMonitoredResourceDescriptors: - new gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'resourceDescriptors'), - listMetricDescriptors: - new gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'metricDescriptors'), - listTimeSeries: - new gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'timeSeries') - }; - - // Put together the default options sent with requests. - const defaults = gaxGrpc.constructSettings( - 'google.monitoring.v3.MetricService', gapicConfig as gax.ClientConfig, - opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); - - // Set up a dictionary of "inner API calls"; the core implementation - // of calling the API is handled in `google-gax`, with this code - // merely providing the destination and request information. - this._innerApiCalls = {}; - - // Put together the "service stub" for - // google.monitoring.v3.MetricService. - this.metricServiceStub = gaxGrpc.createStub( - opts.fallback ? - (protos as protobuf.Root).lookupService('google.monitoring.v3.MetricService') : - // tslint:disable-next-line no-any - (protos as any).google.monitoring.v3.MetricService, - opts) as Promise<{[method: string]: Function}>; - - // Iterate over each of the methods that the service provides - // and create an API call method for each. - const metricServiceStubMethods = - ['listMonitoredResourceDescriptors', 'getMonitoredResourceDescriptor', 'listMetricDescriptors', 'getMetricDescriptor', 'createMetricDescriptor', 'deleteMetricDescriptor', 'listTimeSeries', 'createTimeSeries']; - - for (const methodName of metricServiceStubMethods) { - const innerCallPromise = this.metricServiceStub.then( - stub => (...args: Array<{}>) => { - if (this._terminated) { - return Promise.reject('The client has already been closed.'); - } - return stub[methodName].apply(stub, args); - }, - (err: Error|null|undefined) => () => { - throw err; - }); - - const apiCall = gaxModule.createApiCall( - innerCallPromise, - defaults[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); - }; - } - } - - /** - * The DNS address for this API service. - */ - static get servicePath() { - return 'monitoring.googleapis.com'; - } - - /** - * The DNS address for this API service - same as servicePath(), - * exists for compatibility reasons. - */ - static get apiEndpoint() { - return 'monitoring.googleapis.com'; - } - - /** - * The port for this API service. - */ - static get port() { - return 443; - } - - /** - * The scopes needed to make gRPC calls for every method defined - * in this service. - */ - static get scopes() { - return [ - 'https://www.googleapis.com/auth/cloud-platform', - 'https://www.googleapis.com/auth/monitoring', - 'https://www.googleapis.com/auth/monitoring.read', - 'https://www.googleapis.com/auth/monitoring.write' - ]; - } - - getProjectId(): Promise; - getProjectId(callback: Callback): void; - /** - * Return the project ID used by this class. - * @param {function(Error, string)} callback - the callback to - * be called with the current project Id. - */ - getProjectId(callback?: Callback): - Promise|void { - if (callback) { - this.auth.getProjectId(callback); - return; - } - return this.auth.getProjectId(); - } - - // ------------------- - // -- Service calls -- - // ------------------- - getMonitoredResourceDescriptor( - request: protosTypes.google.monitoring.v3.IGetMonitoredResourceDescriptorRequest, - options?: gax.CallOptions): - Promise<[ - protosTypes.google.api.IMonitoredResourceDescriptor, - protosTypes.google.monitoring.v3.IGetMonitoredResourceDescriptorRequest|undefined, {}|undefined - ]>; - getMonitoredResourceDescriptor( - request: protosTypes.google.monitoring.v3.IGetMonitoredResourceDescriptorRequest, - options: gax.CallOptions, - callback: Callback< - protosTypes.google.api.IMonitoredResourceDescriptor, - protosTypes.google.monitoring.v3.IGetMonitoredResourceDescriptorRequest|undefined, - {}|undefined>): void; -/** - * Gets a single monitored resource descriptor. This method does not require a Stackdriver account. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The monitored resource descriptor to get. The format is - * `"projects/{project_id_or_number}/monitoredResourceDescriptors/{resource_type}"`. - * The `{resource_type}` is a predefined type, such as - * `cloudsql_database`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [MonitoredResourceDescriptor]{@link google.api.MonitoredResourceDescriptor}. - * The promise has a method named "cancel" which cancels the ongoing API call. - */ - getMonitoredResourceDescriptor( - request: protosTypes.google.monitoring.v3.IGetMonitoredResourceDescriptorRequest, - optionsOrCallback?: gax.CallOptions|Callback< - protosTypes.google.api.IMonitoredResourceDescriptor, - protosTypes.google.monitoring.v3.IGetMonitoredResourceDescriptorRequest|undefined, {}|undefined>, - callback?: Callback< - protosTypes.google.api.IMonitoredResourceDescriptor, - protosTypes.google.monitoring.v3.IGetMonitoredResourceDescriptorRequest|undefined, - {}|undefined>): - Promise<[ - protosTypes.google.api.IMonitoredResourceDescriptor, - protosTypes.google.monitoring.v3.IGetMonitoredResourceDescriptorRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: gax.CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as gax.CallOptions; - } - 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 || '', - }); - return this._innerApiCalls.getMonitoredResourceDescriptor(request, options, callback); - } - getMetricDescriptor( - request: protosTypes.google.monitoring.v3.IGetMetricDescriptorRequest, - options?: gax.CallOptions): - Promise<[ - protosTypes.google.api.IMetricDescriptor, - protosTypes.google.monitoring.v3.IGetMetricDescriptorRequest|undefined, {}|undefined - ]>; - getMetricDescriptor( - request: protosTypes.google.monitoring.v3.IGetMetricDescriptorRequest, - options: gax.CallOptions, - callback: Callback< - protosTypes.google.api.IMetricDescriptor, - protosTypes.google.monitoring.v3.IGetMetricDescriptorRequest|undefined, - {}|undefined>): void; -/** - * Gets a single metric descriptor. This method does not require a Stackdriver account. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The metric descriptor on which to execute the request. The format is - * `"projects/{project_id_or_number}/metricDescriptors/{metric_id}"`. - * An example value of `{metric_id}` is - * `"compute.googleapis.com/instance/disk/read_bytes_count"`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [MetricDescriptor]{@link google.api.MetricDescriptor}. - * The promise has a method named "cancel" which cancels the ongoing API call. - */ - getMetricDescriptor( - request: protosTypes.google.monitoring.v3.IGetMetricDescriptorRequest, - optionsOrCallback?: gax.CallOptions|Callback< - protosTypes.google.api.IMetricDescriptor, - protosTypes.google.monitoring.v3.IGetMetricDescriptorRequest|undefined, {}|undefined>, - callback?: Callback< - protosTypes.google.api.IMetricDescriptor, - protosTypes.google.monitoring.v3.IGetMetricDescriptorRequest|undefined, - {}|undefined>): - Promise<[ - protosTypes.google.api.IMetricDescriptor, - protosTypes.google.monitoring.v3.IGetMetricDescriptorRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: gax.CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as gax.CallOptions; - } - 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 || '', - }); - return this._innerApiCalls.getMetricDescriptor(request, options, callback); - } - createMetricDescriptor( - request: protosTypes.google.monitoring.v3.ICreateMetricDescriptorRequest, - options?: gax.CallOptions): - Promise<[ - protosTypes.google.api.IMetricDescriptor, - protosTypes.google.monitoring.v3.ICreateMetricDescriptorRequest|undefined, {}|undefined - ]>; - createMetricDescriptor( - request: protosTypes.google.monitoring.v3.ICreateMetricDescriptorRequest, - options: gax.CallOptions, - callback: Callback< - protosTypes.google.api.IMetricDescriptor, - protosTypes.google.monitoring.v3.ICreateMetricDescriptorRequest|undefined, - {}|undefined>): void; -/** - * Creates a new metric descriptor. - * User-created metric descriptors define - * [custom metrics](/monitoring/custom-metrics). - * - * @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 {google.api.MetricDescriptor} request.metricDescriptor - * Required. The new [custom metric](/monitoring/custom-metrics) - * descriptor. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [MetricDescriptor]{@link google.api.MetricDescriptor}. - * The promise has a method named "cancel" which cancels the ongoing API call. - */ - createMetricDescriptor( - request: protosTypes.google.monitoring.v3.ICreateMetricDescriptorRequest, - optionsOrCallback?: gax.CallOptions|Callback< - protosTypes.google.api.IMetricDescriptor, - protosTypes.google.monitoring.v3.ICreateMetricDescriptorRequest|undefined, {}|undefined>, - callback?: Callback< - protosTypes.google.api.IMetricDescriptor, - protosTypes.google.monitoring.v3.ICreateMetricDescriptorRequest|undefined, - {}|undefined>): - Promise<[ - protosTypes.google.api.IMetricDescriptor, - protosTypes.google.monitoring.v3.ICreateMetricDescriptorRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: gax.CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as gax.CallOptions; - } - 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 || '', - }); - return this._innerApiCalls.createMetricDescriptor(request, options, callback); - } - deleteMetricDescriptor( - request: protosTypes.google.monitoring.v3.IDeleteMetricDescriptorRequest, - options?: gax.CallOptions): - Promise<[ - protosTypes.google.protobuf.IEmpty, - protosTypes.google.monitoring.v3.IDeleteMetricDescriptorRequest|undefined, {}|undefined - ]>; - deleteMetricDescriptor( - request: protosTypes.google.monitoring.v3.IDeleteMetricDescriptorRequest, - options: gax.CallOptions, - callback: Callback< - protosTypes.google.protobuf.IEmpty, - protosTypes.google.monitoring.v3.IDeleteMetricDescriptorRequest|undefined, - {}|undefined>): void; -/** - * Deletes a metric descriptor. Only user-created - * [custom metrics](/monitoring/custom-metrics) can be deleted. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The metric descriptor on which to execute the request. The format is - * `"projects/{project_id_or_number}/metricDescriptors/{metric_id}"`. - * An example of `{metric_id}` is: - * `"custom.googleapis.com/my_test_metric"`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. - * The promise has a method named "cancel" which cancels the ongoing API call. - */ - deleteMetricDescriptor( - request: protosTypes.google.monitoring.v3.IDeleteMetricDescriptorRequest, - optionsOrCallback?: gax.CallOptions|Callback< - protosTypes.google.protobuf.IEmpty, - protosTypes.google.monitoring.v3.IDeleteMetricDescriptorRequest|undefined, {}|undefined>, - callback?: Callback< - protosTypes.google.protobuf.IEmpty, - protosTypes.google.monitoring.v3.IDeleteMetricDescriptorRequest|undefined, - {}|undefined>): - Promise<[ - protosTypes.google.protobuf.IEmpty, - protosTypes.google.monitoring.v3.IDeleteMetricDescriptorRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: gax.CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as gax.CallOptions; - } - 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 || '', - }); - return this._innerApiCalls.deleteMetricDescriptor(request, options, callback); - } - createTimeSeries( - request: protosTypes.google.monitoring.v3.ICreateTimeSeriesRequest, - options?: gax.CallOptions): - Promise<[ - protosTypes.google.protobuf.IEmpty, - protosTypes.google.monitoring.v3.ICreateTimeSeriesRequest|undefined, {}|undefined - ]>; - createTimeSeries( - request: protosTypes.google.monitoring.v3.ICreateTimeSeriesRequest, - options: gax.CallOptions, - callback: Callback< - protosTypes.google.protobuf.IEmpty, - protosTypes.google.monitoring.v3.ICreateTimeSeriesRequest|undefined, - {}|undefined>): void; -/** - * Creates or adds data to one or more time series. - * The response is empty if all time series in the request were written. - * If any time series could not be written, a corresponding failure message is - * included in the error response. - * - * @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 {number[]} request.timeSeries - * Required. The new data to be added to a list of time series. - * Adds at most one data point to each of several time series. The new data - * point must be more recent than any other point in its time series. Each - * `TimeSeries` value must fully specify a unique time series by supplying - * all label values for the metric and the monitored resource. - * - * The maximum number of `TimeSeries` objects per `Create` request is 200. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. - * The promise has a method named "cancel" which cancels the ongoing API call. - */ - createTimeSeries( - request: protosTypes.google.monitoring.v3.ICreateTimeSeriesRequest, - optionsOrCallback?: gax.CallOptions|Callback< - protosTypes.google.protobuf.IEmpty, - protosTypes.google.monitoring.v3.ICreateTimeSeriesRequest|undefined, {}|undefined>, - callback?: Callback< - protosTypes.google.protobuf.IEmpty, - protosTypes.google.monitoring.v3.ICreateTimeSeriesRequest|undefined, - {}|undefined>): - Promise<[ - protosTypes.google.protobuf.IEmpty, - protosTypes.google.monitoring.v3.ICreateTimeSeriesRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: gax.CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as gax.CallOptions; - } - 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 || '', - }); - return this._innerApiCalls.createTimeSeries(request, options, callback); - } - - listMonitoredResourceDescriptors( - request: protosTypes.google.monitoring.v3.IListMonitoredResourceDescriptorsRequest, - options?: gax.CallOptions): - Promise<[ - protosTypes.google.api.IMonitoredResourceDescriptor[], - protosTypes.google.monitoring.v3.IListMonitoredResourceDescriptorsRequest|null, - protosTypes.google.monitoring.v3.IListMonitoredResourceDescriptorsResponse - ]>; - listMonitoredResourceDescriptors( - request: protosTypes.google.monitoring.v3.IListMonitoredResourceDescriptorsRequest, - options: gax.CallOptions, - callback: Callback< - protosTypes.google.api.IMonitoredResourceDescriptor[], - protosTypes.google.monitoring.v3.IListMonitoredResourceDescriptorsRequest|null, - protosTypes.google.monitoring.v3.IListMonitoredResourceDescriptorsResponse>): void; -/** - * Lists monitored resource descriptors that match a filter. This method does not require a Stackdriver account. - * - * @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](/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 {Promise} - The promise which resolves to an array. - * The first element of the array is Array of [MonitoredResourceDescriptor]{@link google.api.MonitoredResourceDescriptor}. - * The client library support auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * - * When autoPaginate: false is specified through options, the array has three elements. - * The first element is Array of [MonitoredResourceDescriptor]{@link google.api.MonitoredResourceDescriptor} that corresponds to - * the one page received from the API server. - * If the second element is not null it contains the request object of type [ListMonitoredResourceDescriptorsRequest]{@link google.monitoring.v3.ListMonitoredResourceDescriptorsRequest} - * that can be used to obtain the next page of the results. - * If it is null, the next page does not exist. - * The third element contains the raw response received from the API server. Its type is - * [ListMonitoredResourceDescriptorsResponse]{@link google.monitoring.v3.ListMonitoredResourceDescriptorsResponse}. - * - * The promise has a method named "cancel" which cancels the ongoing API call. - */ - listMonitoredResourceDescriptors( - request: protosTypes.google.monitoring.v3.IListMonitoredResourceDescriptorsRequest, - optionsOrCallback?: gax.CallOptions|Callback< - protosTypes.google.api.IMonitoredResourceDescriptor[], - protosTypes.google.monitoring.v3.IListMonitoredResourceDescriptorsRequest|null, - protosTypes.google.monitoring.v3.IListMonitoredResourceDescriptorsResponse>, - callback?: Callback< - protosTypes.google.api.IMonitoredResourceDescriptor[], - protosTypes.google.monitoring.v3.IListMonitoredResourceDescriptorsRequest|null, - protosTypes.google.monitoring.v3.IListMonitoredResourceDescriptorsResponse>): - Promise<[ - protosTypes.google.api.IMonitoredResourceDescriptor[], - protosTypes.google.monitoring.v3.IListMonitoredResourceDescriptorsRequest|null, - protosTypes.google.monitoring.v3.IListMonitoredResourceDescriptorsResponse - ]>|void { - request = request || {}; - let options: gax.CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as gax.CallOptions; - } - 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 || '', - }); - return this._innerApiCalls.listMonitoredResourceDescriptors(request, options, callback); - } - -/** - * Equivalent to {@link listMonitoredResourceDescriptors}, but returns a NodeJS Stream object. - * - * This fetches the paged responses for {@link listMonitoredResourceDescriptors} continuously - * and invokes the callback registered for 'data' event for each element in the - * responses. - * - * The returned object has 'end' method when no more elements are required. - * - * autoPaginate option will be ignored. - * - * @see {@link https://nodejs.org/api/stream.html} - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.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](/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 {Stream} - * An object stream which emits an object representing [MonitoredResourceDescriptor]{@link google.api.MonitoredResourceDescriptor} on 'data' event. - */ - listMonitoredResourceDescriptorsStream( - request?: protosTypes.google.monitoring.v3.IListMonitoredResourceDescriptorsRequest, - options?: gax.CallOptions | {}): - Transform{ - request = request || {}; - const callSettings = new gax.CallSettings(options); - return this._descriptors.page.listMonitoredResourceDescriptors.createStream( - this._innerApiCalls.listMonitoredResourceDescriptors as gax.GaxCall, - request, - callSettings - ); - } - listMetricDescriptors( - request: protosTypes.google.monitoring.v3.IListMetricDescriptorsRequest, - options?: gax.CallOptions): - Promise<[ - protosTypes.google.api.IMetricDescriptor[], - protosTypes.google.monitoring.v3.IListMetricDescriptorsRequest|null, - protosTypes.google.monitoring.v3.IListMetricDescriptorsResponse - ]>; - listMetricDescriptors( - request: protosTypes.google.monitoring.v3.IListMetricDescriptorsRequest, - options: gax.CallOptions, - callback: Callback< - protosTypes.google.api.IMetricDescriptor[], - protosTypes.google.monitoring.v3.IListMetricDescriptorsRequest|null, - protosTypes.google.monitoring.v3.IListMetricDescriptorsResponse>): void; -/** - * Lists metric descriptors that match a filter. This method does not require a Stackdriver account. - * - * @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](/monitoring/api/v3/filters) - * specifies which metric descriptors are to be - * returned. For example, the following filter matches all - * [custom metrics](/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 {Promise} - The promise which resolves to an array. - * The first element of the array is Array of [MetricDescriptor]{@link google.api.MetricDescriptor}. - * The client library support auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * - * When autoPaginate: false is specified through options, the array has three elements. - * The first element is Array of [MetricDescriptor]{@link google.api.MetricDescriptor} that corresponds to - * the one page received from the API server. - * If the second element is not null it contains the request object of type [ListMetricDescriptorsRequest]{@link google.monitoring.v3.ListMetricDescriptorsRequest} - * that can be used to obtain the next page of the results. - * If it is null, the next page does not exist. - * The third element contains the raw response received from the API server. Its type is - * [ListMetricDescriptorsResponse]{@link google.monitoring.v3.ListMetricDescriptorsResponse}. - * - * The promise has a method named "cancel" which cancels the ongoing API call. - */ - listMetricDescriptors( - request: protosTypes.google.monitoring.v3.IListMetricDescriptorsRequest, - optionsOrCallback?: gax.CallOptions|Callback< - protosTypes.google.api.IMetricDescriptor[], - protosTypes.google.monitoring.v3.IListMetricDescriptorsRequest|null, - protosTypes.google.monitoring.v3.IListMetricDescriptorsResponse>, - callback?: Callback< - protosTypes.google.api.IMetricDescriptor[], - protosTypes.google.monitoring.v3.IListMetricDescriptorsRequest|null, - protosTypes.google.monitoring.v3.IListMetricDescriptorsResponse>): - Promise<[ - protosTypes.google.api.IMetricDescriptor[], - protosTypes.google.monitoring.v3.IListMetricDescriptorsRequest|null, - protosTypes.google.monitoring.v3.IListMetricDescriptorsResponse - ]>|void { - request = request || {}; - let options: gax.CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as gax.CallOptions; - } - 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 || '', - }); - return this._innerApiCalls.listMetricDescriptors(request, options, callback); - } - -/** - * Equivalent to {@link listMetricDescriptors}, but returns a NodeJS Stream object. - * - * This fetches the paged responses for {@link listMetricDescriptors} continuously - * and invokes the callback registered for 'data' event for each element in the - * responses. - * - * The returned object has 'end' method when no more elements are required. - * - * autoPaginate option will be ignored. - * - * @see {@link https://nodejs.org/api/stream.html} - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.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](/monitoring/api/v3/filters) - * specifies which metric descriptors are to be - * returned. For example, the following filter matches all - * [custom metrics](/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 {Stream} - * An object stream which emits an object representing [MetricDescriptor]{@link google.api.MetricDescriptor} on 'data' event. - */ - listMetricDescriptorsStream( - request?: protosTypes.google.monitoring.v3.IListMetricDescriptorsRequest, - options?: gax.CallOptions | {}): - Transform{ - request = request || {}; - const callSettings = new gax.CallSettings(options); - return this._descriptors.page.listMetricDescriptors.createStream( - this._innerApiCalls.listMetricDescriptors as gax.GaxCall, - request, - callSettings - ); - } - listTimeSeries( - request: protosTypes.google.monitoring.v3.IListTimeSeriesRequest, - options?: gax.CallOptions): - Promise<[ - protosTypes.google.monitoring.v3.ITimeSeries[], - protosTypes.google.monitoring.v3.IListTimeSeriesRequest|null, - protosTypes.google.monitoring.v3.IListTimeSeriesResponse - ]>; - listTimeSeries( - request: protosTypes.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>): void; -/** - * Lists time series that match a filter. This method does not require a Stackdriver account. - * - * @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](/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 {Promise} - The promise which resolves to an array. - * The first element of the array is Array of [TimeSeries]{@link google.monitoring.v3.TimeSeries}. - * The client library support auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * - * When autoPaginate: false is specified through options, the array has three elements. - * The first element is Array of [TimeSeries]{@link google.monitoring.v3.TimeSeries} that corresponds to - * the one page received from the API server. - * If the second element is not null it contains the request object of type [ListTimeSeriesRequest]{@link google.monitoring.v3.ListTimeSeriesRequest} - * that can be used to obtain the next page of the results. - * If it is null, the next page does not exist. - * The third element contains the raw response received from the API server. Its type is - * [ListTimeSeriesResponse]{@link google.monitoring.v3.ListTimeSeriesResponse}. - * - * The promise has a method named "cancel" which cancels the ongoing API call. - */ - listTimeSeries( - request: protosTypes.google.monitoring.v3.IListTimeSeriesRequest, - optionsOrCallback?: gax.CallOptions|Callback< - protosTypes.google.monitoring.v3.ITimeSeries[], - protosTypes.google.monitoring.v3.IListTimeSeriesRequest|null, - protosTypes.google.monitoring.v3.IListTimeSeriesResponse>, - callback?: Callback< - protosTypes.google.monitoring.v3.ITimeSeries[], - protosTypes.google.monitoring.v3.IListTimeSeriesRequest|null, - protosTypes.google.monitoring.v3.IListTimeSeriesResponse>): - Promise<[ - protosTypes.google.monitoring.v3.ITimeSeries[], - protosTypes.google.monitoring.v3.IListTimeSeriesRequest|null, - protosTypes.google.monitoring.v3.IListTimeSeriesResponse - ]>|void { - request = request || {}; - let options: gax.CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as gax.CallOptions; - } - 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 || '', - }); - return this._innerApiCalls.listTimeSeries(request, options, callback); - } - -/** - * Equivalent to {@link listTimeSeries}, but returns a NodeJS Stream object. - * - * This fetches the paged responses for {@link listTimeSeries} continuously - * and invokes the callback registered for 'data' event for each element in the - * responses. - * - * The returned object has 'end' method when no more elements are required. - * - * autoPaginate option will be ignored. - * - * @see {@link https://nodejs.org/api/stream.html} - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.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](/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 {Stream} - * An object stream which emits an object representing [TimeSeries]{@link google.monitoring.v3.TimeSeries} on 'data' event. - */ - listTimeSeriesStream( - request?: protosTypes.google.monitoring.v3.IListTimeSeriesRequest, - options?: gax.CallOptions | {}): - Transform{ - request = request || {}; - const callSettings = new gax.CallSettings(options); - return this._descriptors.page.listTimeSeries.createStream( - this._innerApiCalls.listTimeSeries as gax.GaxCall, - request, - callSettings - ); - } - // -------------------- - // -- Path templates -- - // -------------------- - - /** - * Return a fully-qualified projectAlertPolicy resource name string. - * - * @param {string} project - * @param {string} alert_policy - * @returns {string} Resource name string. - */ - projectAlertPolicyPath(project:string,alertPolicy:string) { - return this._pathTemplates.projectAlertPolicyPathTemplate.render({ - project: project, - alert_policy: alertPolicy, - }); - } - - /** - * Parse the project from ProjectAlertPolicy resource. - * - * @param {string} projectAlertPolicyName - * A fully-qualified path representing project_alert_policy resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProjectAlertPolicyName(projectAlertPolicyName: string) { - return this._pathTemplates.projectAlertPolicyPathTemplate.match(projectAlertPolicyName).project; - } - - /** - * Parse the alert_policy from ProjectAlertPolicy resource. - * - * @param {string} projectAlertPolicyName - * A fully-qualified path representing project_alert_policy resource. - * @returns {string} A string representing the alert_policy. - */ - matchAlertPolicyFromProjectAlertPolicyName(projectAlertPolicyName: string) { - return this._pathTemplates.projectAlertPolicyPathTemplate.match(projectAlertPolicyName).alert_policy; - } - - /** - * Return a fully-qualified organizationAlertPolicy resource name string. - * - * @param {string} organization - * @param {string} alert_policy - * @returns {string} Resource name string. - */ - organizationAlertPolicyPath(organization:string,alertPolicy:string) { - return this._pathTemplates.organizationAlertPolicyPathTemplate.render({ - organization: organization, - alert_policy: alertPolicy, - }); - } - - /** - * Parse the organization from OrganizationAlertPolicy resource. - * - * @param {string} organizationAlertPolicyName - * A fully-qualified path representing organization_alert_policy resource. - * @returns {string} A string representing the organization. - */ - matchOrganizationFromOrganizationAlertPolicyName(organizationAlertPolicyName: string) { - return this._pathTemplates.organizationAlertPolicyPathTemplate.match(organizationAlertPolicyName).organization; - } - - /** - * Parse the alert_policy from OrganizationAlertPolicy resource. - * - * @param {string} organizationAlertPolicyName - * A fully-qualified path representing organization_alert_policy resource. - * @returns {string} A string representing the alert_policy. - */ - matchAlertPolicyFromOrganizationAlertPolicyName(organizationAlertPolicyName: string) { - return this._pathTemplates.organizationAlertPolicyPathTemplate.match(organizationAlertPolicyName).alert_policy; - } - - /** - * Return a fully-qualified folderAlertPolicy resource name string. - * - * @param {string} folder - * @param {string} alert_policy - * @returns {string} Resource name string. - */ - folderAlertPolicyPath(folder:string,alertPolicy:string) { - return this._pathTemplates.folderAlertPolicyPathTemplate.render({ - folder: folder, - alert_policy: alertPolicy, - }); - } - - /** - * Parse the folder from FolderAlertPolicy resource. - * - * @param {string} folderAlertPolicyName - * A fully-qualified path representing folder_alert_policy resource. - * @returns {string} A string representing the folder. - */ - matchFolderFromFolderAlertPolicyName(folderAlertPolicyName: string) { - return this._pathTemplates.folderAlertPolicyPathTemplate.match(folderAlertPolicyName).folder; - } - - /** - * Parse the alert_policy from FolderAlertPolicy resource. - * - * @param {string} folderAlertPolicyName - * A fully-qualified path representing folder_alert_policy resource. - * @returns {string} A string representing the alert_policy. - */ - matchAlertPolicyFromFolderAlertPolicyName(folderAlertPolicyName: string) { - return this._pathTemplates.folderAlertPolicyPathTemplate.match(folderAlertPolicyName).alert_policy; - } - - /** - * Return a fully-qualified resource name string. - * - * @returns {string} Resource name string. - */ - Path() { - return this._pathTemplates.PathTemplate.render({ - }); - } - - /** - * Return a fully-qualified projectGroup resource name string. - * - * @param {string} project - * @param {string} group - * @returns {string} Resource name string. - */ - projectGroupPath(project:string,group:string) { - return this._pathTemplates.projectGroupPathTemplate.render({ - project: project, - group: group, - }); - } - - /** - * Parse the project from ProjectGroup resource. - * - * @param {string} projectGroupName - * A fully-qualified path representing project_group resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProjectGroupName(projectGroupName: string) { - return this._pathTemplates.projectGroupPathTemplate.match(projectGroupName).project; - } - - /** - * Parse the group from ProjectGroup resource. - * - * @param {string} projectGroupName - * A fully-qualified path representing project_group resource. - * @returns {string} A string representing the group. - */ - matchGroupFromProjectGroupName(projectGroupName: string) { - return this._pathTemplates.projectGroupPathTemplate.match(projectGroupName).group; - } - - /** - * Return a fully-qualified organizationGroup resource name string. - * - * @param {string} organization - * @param {string} group - * @returns {string} Resource name string. - */ - organizationGroupPath(organization:string,group:string) { - return this._pathTemplates.organizationGroupPathTemplate.render({ - organization: organization, - group: group, - }); - } - - /** - * Parse the organization from OrganizationGroup resource. - * - * @param {string} organizationGroupName - * A fully-qualified path representing organization_group resource. - * @returns {string} A string representing the organization. - */ - matchOrganizationFromOrganizationGroupName(organizationGroupName: string) { - return this._pathTemplates.organizationGroupPathTemplate.match(organizationGroupName).organization; - } - - /** - * Parse the group from OrganizationGroup resource. - * - * @param {string} organizationGroupName - * A fully-qualified path representing organization_group resource. - * @returns {string} A string representing the group. - */ - matchGroupFromOrganizationGroupName(organizationGroupName: string) { - return this._pathTemplates.organizationGroupPathTemplate.match(organizationGroupName).group; - } - - /** - * Return a fully-qualified folderGroup resource name string. - * - * @param {string} folder - * @param {string} group - * @returns {string} Resource name string. - */ - folderGroupPath(folder:string,group:string) { - return this._pathTemplates.folderGroupPathTemplate.render({ - folder: folder, - group: group, - }); - } - - /** - * Parse the folder from FolderGroup resource. - * - * @param {string} folderGroupName - * A fully-qualified path representing folder_group resource. - * @returns {string} A string representing the folder. - */ - matchFolderFromFolderGroupName(folderGroupName: string) { - return this._pathTemplates.folderGroupPathTemplate.match(folderGroupName).folder; - } - - /** - * Parse the group from FolderGroup resource. - * - * @param {string} folderGroupName - * A fully-qualified path representing folder_group resource. - * @returns {string} A string representing the group. - */ - matchGroupFromFolderGroupName(folderGroupName: string) { - return this._pathTemplates.folderGroupPathTemplate.match(folderGroupName).group; - } - - /** - * Return a fully-qualified projectChannelDescriptor resource name string. - * - * @param {string} project - * @param {string} channel_descriptor - * @returns {string} Resource name string. - */ - projectChannelDescriptorPath(project:string,channelDescriptor:string) { - return this._pathTemplates.projectChannelDescriptorPathTemplate.render({ - project: project, - channel_descriptor: channelDescriptor, - }); - } - - /** - * Parse the project from ProjectChannelDescriptor resource. - * - * @param {string} projectChannelDescriptorName - * A fully-qualified path representing project_channel_descriptor resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProjectChannelDescriptorName(projectChannelDescriptorName: string) { - return this._pathTemplates.projectChannelDescriptorPathTemplate.match(projectChannelDescriptorName).project; - } - - /** - * Parse the channel_descriptor from ProjectChannelDescriptor resource. - * - * @param {string} projectChannelDescriptorName - * A fully-qualified path representing project_channel_descriptor resource. - * @returns {string} A string representing the channel_descriptor. - */ - matchChannelDescriptorFromProjectChannelDescriptorName(projectChannelDescriptorName: string) { - return this._pathTemplates.projectChannelDescriptorPathTemplate.match(projectChannelDescriptorName).channel_descriptor; - } - - /** - * Return a fully-qualified organizationChannelDescriptor resource name string. - * - * @param {string} organization - * @param {string} channel_descriptor - * @returns {string} Resource name string. - */ - organizationChannelDescriptorPath(organization:string,channelDescriptor:string) { - return this._pathTemplates.organizationChannelDescriptorPathTemplate.render({ - organization: organization, - channel_descriptor: channelDescriptor, - }); - } - - /** - * Parse the organization from OrganizationChannelDescriptor resource. - * - * @param {string} organizationChannelDescriptorName - * A fully-qualified path representing organization_channel_descriptor resource. - * @returns {string} A string representing the organization. - */ - matchOrganizationFromOrganizationChannelDescriptorName(organizationChannelDescriptorName: string) { - return this._pathTemplates.organizationChannelDescriptorPathTemplate.match(organizationChannelDescriptorName).organization; - } - - /** - * Parse the channel_descriptor from OrganizationChannelDescriptor resource. - * - * @param {string} organizationChannelDescriptorName - * A fully-qualified path representing organization_channel_descriptor resource. - * @returns {string} A string representing the channel_descriptor. - */ - matchChannelDescriptorFromOrganizationChannelDescriptorName(organizationChannelDescriptorName: string) { - return this._pathTemplates.organizationChannelDescriptorPathTemplate.match(organizationChannelDescriptorName).channel_descriptor; - } - - /** - * Return a fully-qualified folderChannelDescriptor resource name string. - * - * @param {string} folder - * @param {string} channel_descriptor - * @returns {string} Resource name string. - */ - folderChannelDescriptorPath(folder:string,channelDescriptor:string) { - return this._pathTemplates.folderChannelDescriptorPathTemplate.render({ - folder: folder, - channel_descriptor: channelDescriptor, - }); - } - - /** - * Parse the folder from FolderChannelDescriptor resource. - * - * @param {string} folderChannelDescriptorName - * A fully-qualified path representing folder_channel_descriptor resource. - * @returns {string} A string representing the folder. - */ - matchFolderFromFolderChannelDescriptorName(folderChannelDescriptorName: string) { - return this._pathTemplates.folderChannelDescriptorPathTemplate.match(folderChannelDescriptorName).folder; - } - - /** - * Parse the channel_descriptor from FolderChannelDescriptor resource. - * - * @param {string} folderChannelDescriptorName - * A fully-qualified path representing folder_channel_descriptor resource. - * @returns {string} A string representing the channel_descriptor. - */ - matchChannelDescriptorFromFolderChannelDescriptorName(folderChannelDescriptorName: string) { - return this._pathTemplates.folderChannelDescriptorPathTemplate.match(folderChannelDescriptorName).channel_descriptor; - } - - /** - * Return a fully-qualified projectNotificationChannel resource name string. - * - * @param {string} project - * @param {string} notification_channel - * @returns {string} Resource name string. - */ - projectNotificationChannelPath(project:string,notificationChannel:string) { - return this._pathTemplates.projectNotificationChannelPathTemplate.render({ - project: project, - notification_channel: notificationChannel, - }); - } - - /** - * Parse the project from ProjectNotificationChannel resource. - * - * @param {string} projectNotificationChannelName - * A fully-qualified path representing project_notification_channel resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProjectNotificationChannelName(projectNotificationChannelName: string) { - return this._pathTemplates.projectNotificationChannelPathTemplate.match(projectNotificationChannelName).project; - } - - /** - * Parse the notification_channel from ProjectNotificationChannel resource. - * - * @param {string} projectNotificationChannelName - * A fully-qualified path representing project_notification_channel resource. - * @returns {string} A string representing the notification_channel. - */ - matchNotificationChannelFromProjectNotificationChannelName(projectNotificationChannelName: string) { - return this._pathTemplates.projectNotificationChannelPathTemplate.match(projectNotificationChannelName).notification_channel; - } - - /** - * Return a fully-qualified organizationNotificationChannel resource name string. - * - * @param {string} organization - * @param {string} notification_channel - * @returns {string} Resource name string. - */ - organizationNotificationChannelPath(organization:string,notificationChannel:string) { - return this._pathTemplates.organizationNotificationChannelPathTemplate.render({ - organization: organization, - notification_channel: notificationChannel, - }); - } - - /** - * Parse the organization from OrganizationNotificationChannel resource. - * - * @param {string} organizationNotificationChannelName - * A fully-qualified path representing organization_notification_channel resource. - * @returns {string} A string representing the organization. - */ - matchOrganizationFromOrganizationNotificationChannelName(organizationNotificationChannelName: string) { - return this._pathTemplates.organizationNotificationChannelPathTemplate.match(organizationNotificationChannelName).organization; - } - - /** - * Parse the notification_channel from OrganizationNotificationChannel resource. - * - * @param {string} organizationNotificationChannelName - * A fully-qualified path representing organization_notification_channel resource. - * @returns {string} A string representing the notification_channel. - */ - matchNotificationChannelFromOrganizationNotificationChannelName(organizationNotificationChannelName: string) { - return this._pathTemplates.organizationNotificationChannelPathTemplate.match(organizationNotificationChannelName).notification_channel; - } - - /** - * Return a fully-qualified folderNotificationChannel resource name string. - * - * @param {string} folder - * @param {string} notification_channel - * @returns {string} Resource name string. - */ - folderNotificationChannelPath(folder:string,notificationChannel:string) { - return this._pathTemplates.folderNotificationChannelPathTemplate.render({ - folder: folder, - notification_channel: notificationChannel, - }); - } - - /** - * Parse the folder from FolderNotificationChannel resource. - * - * @param {string} folderNotificationChannelName - * A fully-qualified path representing folder_notification_channel resource. - * @returns {string} A string representing the folder. - */ - matchFolderFromFolderNotificationChannelName(folderNotificationChannelName: string) { - return this._pathTemplates.folderNotificationChannelPathTemplate.match(folderNotificationChannelName).folder; - } - - /** - * Parse the notification_channel from FolderNotificationChannel resource. - * - * @param {string} folderNotificationChannelName - * A fully-qualified path representing folder_notification_channel resource. - * @returns {string} A string representing the notification_channel. - */ - matchNotificationChannelFromFolderNotificationChannelName(folderNotificationChannelName: string) { - return this._pathTemplates.folderNotificationChannelPathTemplate.match(folderNotificationChannelName).notification_channel; - } - - /** - * Return a fully-qualified projectService resource name string. - * - * @param {string} project - * @param {string} service - * @returns {string} Resource name string. - */ - projectServicePath(project:string,service:string) { - return this._pathTemplates.projectServicePathTemplate.render({ - project: project, - service: service, - }); - } - - /** - * Parse the project from ProjectService resource. - * - * @param {string} projectServiceName - * A fully-qualified path representing project_service resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProjectServiceName(projectServiceName: string) { - return this._pathTemplates.projectServicePathTemplate.match(projectServiceName).project; - } - - /** - * Parse the service from ProjectService resource. - * - * @param {string} projectServiceName - * A fully-qualified path representing project_service resource. - * @returns {string} A string representing the service. - */ - matchServiceFromProjectServiceName(projectServiceName: string) { - return this._pathTemplates.projectServicePathTemplate.match(projectServiceName).service; - } - - /** - * Return a fully-qualified organizationService resource name string. - * - * @param {string} organization - * @param {string} service - * @returns {string} Resource name string. - */ - organizationServicePath(organization:string,service:string) { - return this._pathTemplates.organizationServicePathTemplate.render({ - organization: organization, - service: service, - }); - } - - /** - * Parse the organization from OrganizationService resource. - * - * @param {string} organizationServiceName - * A fully-qualified path representing organization_service resource. - * @returns {string} A string representing the organization. - */ - matchOrganizationFromOrganizationServiceName(organizationServiceName: string) { - return this._pathTemplates.organizationServicePathTemplate.match(organizationServiceName).organization; - } - - /** - * Parse the service from OrganizationService resource. - * - * @param {string} organizationServiceName - * A fully-qualified path representing organization_service resource. - * @returns {string} A string representing the service. - */ - matchServiceFromOrganizationServiceName(organizationServiceName: string) { - return this._pathTemplates.organizationServicePathTemplate.match(organizationServiceName).service; - } - - /** - * Return a fully-qualified folderService resource name string. - * - * @param {string} folder - * @param {string} service - * @returns {string} Resource name string. - */ - folderServicePath(folder:string,service:string) { - return this._pathTemplates.folderServicePathTemplate.render({ - folder: folder, - service: service, - }); - } - - /** - * Parse the folder from FolderService resource. - * - * @param {string} folderServiceName - * A fully-qualified path representing folder_service resource. - * @returns {string} A string representing the folder. - */ - matchFolderFromFolderServiceName(folderServiceName: string) { - return this._pathTemplates.folderServicePathTemplate.match(folderServiceName).folder; - } - - /** - * Parse the service from FolderService resource. - * - * @param {string} folderServiceName - * A fully-qualified path representing folder_service resource. - * @returns {string} A string representing the service. - */ - matchServiceFromFolderServiceName(folderServiceName: string) { - return this._pathTemplates.folderServicePathTemplate.match(folderServiceName).service; - } - - /** - * Return a fully-qualified projectServiceServiceLevelObjective resource name string. - * - * @param {string} project - * @param {string} service - * @param {string} service_level_objective - * @returns {string} Resource name string. - */ - projectServiceServiceLevelObjectivePath(project:string,service:string,serviceLevelObjective:string) { - return this._pathTemplates.projectServiceServiceLevelObjectivePathTemplate.render({ - project: project, - service: service, - service_level_objective: serviceLevelObjective, - }); - } - - /** - * Parse the project from ProjectServiceServiceLevelObjective resource. - * - * @param {string} projectServiceServiceLevelObjectiveName - * A fully-qualified path representing project_service_service_level_objective resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProjectServiceServiceLevelObjectiveName(projectServiceServiceLevelObjectiveName: string) { - return this._pathTemplates.projectServiceServiceLevelObjectivePathTemplate.match(projectServiceServiceLevelObjectiveName).project; - } - - /** - * Parse the service from ProjectServiceServiceLevelObjective resource. - * - * @param {string} projectServiceServiceLevelObjectiveName - * A fully-qualified path representing project_service_service_level_objective resource. - * @returns {string} A string representing the service. - */ - matchServiceFromProjectServiceServiceLevelObjectiveName(projectServiceServiceLevelObjectiveName: string) { - return this._pathTemplates.projectServiceServiceLevelObjectivePathTemplate.match(projectServiceServiceLevelObjectiveName).service; - } - - /** - * Parse the service_level_objective from ProjectServiceServiceLevelObjective resource. - * - * @param {string} projectServiceServiceLevelObjectiveName - * A fully-qualified path representing project_service_service_level_objective resource. - * @returns {string} A string representing the service_level_objective. - */ - matchServiceLevelObjectiveFromProjectServiceServiceLevelObjectiveName(projectServiceServiceLevelObjectiveName: string) { - return this._pathTemplates.projectServiceServiceLevelObjectivePathTemplate.match(projectServiceServiceLevelObjectiveName).service_level_objective; - } - - /** - * Return a fully-qualified organizationServiceServiceLevelObjective resource name string. - * - * @param {string} organization - * @param {string} service - * @param {string} service_level_objective - * @returns {string} Resource name string. - */ - organizationServiceServiceLevelObjectivePath(organization:string,service:string,serviceLevelObjective:string) { - return this._pathTemplates.organizationServiceServiceLevelObjectivePathTemplate.render({ - organization: organization, - service: service, - service_level_objective: serviceLevelObjective, - }); - } - - /** - * Parse the organization from OrganizationServiceServiceLevelObjective resource. - * - * @param {string} organizationServiceServiceLevelObjectiveName - * A fully-qualified path representing organization_service_service_level_objective resource. - * @returns {string} A string representing the organization. - */ - matchOrganizationFromOrganizationServiceServiceLevelObjectiveName(organizationServiceServiceLevelObjectiveName: string) { - return this._pathTemplates.organizationServiceServiceLevelObjectivePathTemplate.match(organizationServiceServiceLevelObjectiveName).organization; - } - - /** - * Parse the service from OrganizationServiceServiceLevelObjective resource. - * - * @param {string} organizationServiceServiceLevelObjectiveName - * A fully-qualified path representing organization_service_service_level_objective resource. - * @returns {string} A string representing the service. - */ - matchServiceFromOrganizationServiceServiceLevelObjectiveName(organizationServiceServiceLevelObjectiveName: string) { - return this._pathTemplates.organizationServiceServiceLevelObjectivePathTemplate.match(organizationServiceServiceLevelObjectiveName).service; - } - - /** - * Parse the service_level_objective from OrganizationServiceServiceLevelObjective resource. - * - * @param {string} organizationServiceServiceLevelObjectiveName - * A fully-qualified path representing organization_service_service_level_objective resource. - * @returns {string} A string representing the service_level_objective. - */ - matchServiceLevelObjectiveFromOrganizationServiceServiceLevelObjectiveName(organizationServiceServiceLevelObjectiveName: string) { - return this._pathTemplates.organizationServiceServiceLevelObjectivePathTemplate.match(organizationServiceServiceLevelObjectiveName).service_level_objective; - } - - /** - * Return a fully-qualified folderServiceServiceLevelObjective resource name string. - * - * @param {string} folder - * @param {string} service - * @param {string} service_level_objective - * @returns {string} Resource name string. - */ - folderServiceServiceLevelObjectivePath(folder:string,service:string,serviceLevelObjective:string) { - return this._pathTemplates.folderServiceServiceLevelObjectivePathTemplate.render({ - folder: folder, - service: service, - service_level_objective: serviceLevelObjective, - }); - } - - /** - * Parse the folder from FolderServiceServiceLevelObjective resource. - * - * @param {string} folderServiceServiceLevelObjectiveName - * A fully-qualified path representing folder_service_service_level_objective resource. - * @returns {string} A string representing the folder. - */ - matchFolderFromFolderServiceServiceLevelObjectiveName(folderServiceServiceLevelObjectiveName: string) { - return this._pathTemplates.folderServiceServiceLevelObjectivePathTemplate.match(folderServiceServiceLevelObjectiveName).folder; - } - - /** - * Parse the service from FolderServiceServiceLevelObjective resource. - * - * @param {string} folderServiceServiceLevelObjectiveName - * A fully-qualified path representing folder_service_service_level_objective resource. - * @returns {string} A string representing the service. - */ - matchServiceFromFolderServiceServiceLevelObjectiveName(folderServiceServiceLevelObjectiveName: string) { - return this._pathTemplates.folderServiceServiceLevelObjectivePathTemplate.match(folderServiceServiceLevelObjectiveName).service; - } - - /** - * Parse the service_level_objective from FolderServiceServiceLevelObjective resource. - * - * @param {string} folderServiceServiceLevelObjectiveName - * A fully-qualified path representing folder_service_service_level_objective resource. - * @returns {string} A string representing the service_level_objective. - */ - matchServiceLevelObjectiveFromFolderServiceServiceLevelObjectiveName(folderServiceServiceLevelObjectiveName: string) { - return this._pathTemplates.folderServiceServiceLevelObjectivePathTemplate.match(folderServiceServiceLevelObjectiveName).service_level_objective; - } - - /** - * Return a fully-qualified projectUptimeCheckConfig resource name string. - * - * @param {string} project - * @param {string} uptime_check_config - * @returns {string} Resource name string. - */ - projectUptimeCheckConfigPath(project:string,uptimeCheckConfig:string) { - return this._pathTemplates.projectUptimeCheckConfigPathTemplate.render({ - project: project, - uptime_check_config: uptimeCheckConfig, - }); - } - - /** - * Parse the project from ProjectUptimeCheckConfig resource. - * - * @param {string} projectUptimeCheckConfigName - * A fully-qualified path representing project_uptime_check_config resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProjectUptimeCheckConfigName(projectUptimeCheckConfigName: string) { - return this._pathTemplates.projectUptimeCheckConfigPathTemplate.match(projectUptimeCheckConfigName).project; - } - - /** - * Parse the uptime_check_config from ProjectUptimeCheckConfig resource. - * - * @param {string} projectUptimeCheckConfigName - * A fully-qualified path representing project_uptime_check_config resource. - * @returns {string} A string representing the uptime_check_config. - */ - matchUptimeCheckConfigFromProjectUptimeCheckConfigName(projectUptimeCheckConfigName: string) { - return this._pathTemplates.projectUptimeCheckConfigPathTemplate.match(projectUptimeCheckConfigName).uptime_check_config; - } - - /** - * Return a fully-qualified organizationUptimeCheckConfig resource name string. - * - * @param {string} organization - * @param {string} uptime_check_config - * @returns {string} Resource name string. - */ - organizationUptimeCheckConfigPath(organization:string,uptimeCheckConfig:string) { - return this._pathTemplates.organizationUptimeCheckConfigPathTemplate.render({ - organization: organization, - uptime_check_config: uptimeCheckConfig, - }); - } - - /** - * Parse the organization from OrganizationUptimeCheckConfig resource. - * - * @param {string} organizationUptimeCheckConfigName - * A fully-qualified path representing organization_uptime_check_config resource. - * @returns {string} A string representing the organization. - */ - matchOrganizationFromOrganizationUptimeCheckConfigName(organizationUptimeCheckConfigName: string) { - return this._pathTemplates.organizationUptimeCheckConfigPathTemplate.match(organizationUptimeCheckConfigName).organization; - } - - /** - * Parse the uptime_check_config from OrganizationUptimeCheckConfig resource. - * - * @param {string} organizationUptimeCheckConfigName - * A fully-qualified path representing organization_uptime_check_config resource. - * @returns {string} A string representing the uptime_check_config. - */ - matchUptimeCheckConfigFromOrganizationUptimeCheckConfigName(organizationUptimeCheckConfigName: string) { - return this._pathTemplates.organizationUptimeCheckConfigPathTemplate.match(organizationUptimeCheckConfigName).uptime_check_config; - } - - /** - * Return a fully-qualified folderUptimeCheckConfig resource name string. - * - * @param {string} folder - * @param {string} uptime_check_config - * @returns {string} Resource name string. - */ - folderUptimeCheckConfigPath(folder:string,uptimeCheckConfig:string) { - return this._pathTemplates.folderUptimeCheckConfigPathTemplate.render({ - folder: folder, - uptime_check_config: uptimeCheckConfig, - }); - } - - /** - * Parse the folder from FolderUptimeCheckConfig resource. - * - * @param {string} folderUptimeCheckConfigName - * A fully-qualified path representing folder_uptime_check_config resource. - * @returns {string} A string representing the folder. - */ - matchFolderFromFolderUptimeCheckConfigName(folderUptimeCheckConfigName: string) { - return this._pathTemplates.folderUptimeCheckConfigPathTemplate.match(folderUptimeCheckConfigName).folder; - } - - /** - * Parse the uptime_check_config from FolderUptimeCheckConfig resource. - * - * @param {string} folderUptimeCheckConfigName - * A fully-qualified path representing folder_uptime_check_config resource. - * @returns {string} A string representing the uptime_check_config. - */ - matchUptimeCheckConfigFromFolderUptimeCheckConfigName(folderUptimeCheckConfigName: string) { - return this._pathTemplates.folderUptimeCheckConfigPathTemplate.match(folderUptimeCheckConfigName).uptime_check_config; - } - - /** - * Return a fully-qualified projectMonitoredResourceDescriptor resource name string. - * - * @param {string} project - * @param {string} monitored_resource_descriptor - * @returns {string} Resource name string. - */ - projectMonitoredResourceDescriptorPath(project:string,monitoredResourceDescriptor:string) { - return this._pathTemplates.projectMonitoredResourceDescriptorPathTemplate.render({ - project: project, - monitored_resource_descriptor: monitoredResourceDescriptor, - }); - } - - /** - * Parse the project from ProjectMonitoredResourceDescriptor resource. - * - * @param {string} projectMonitoredResourceDescriptorName - * A fully-qualified path representing project_monitored_resource_descriptor resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProjectMonitoredResourceDescriptorName(projectMonitoredResourceDescriptorName: string) { - return this._pathTemplates.projectMonitoredResourceDescriptorPathTemplate.match(projectMonitoredResourceDescriptorName).project; - } - - /** - * Parse the monitored_resource_descriptor from ProjectMonitoredResourceDescriptor resource. - * - * @param {string} projectMonitoredResourceDescriptorName - * A fully-qualified path representing project_monitored_resource_descriptor resource. - * @returns {string} A string representing the monitored_resource_descriptor. - */ - matchMonitoredResourceDescriptorFromProjectMonitoredResourceDescriptorName(projectMonitoredResourceDescriptorName: string) { - return this._pathTemplates.projectMonitoredResourceDescriptorPathTemplate.match(projectMonitoredResourceDescriptorName).monitored_resource_descriptor; - } - - /** - * Return a fully-qualified organizationMonitoredResourceDescriptor resource name string. - * - * @param {string} organization - * @param {string} monitored_resource_descriptor - * @returns {string} Resource name string. - */ - organizationMonitoredResourceDescriptorPath(organization:string,monitoredResourceDescriptor:string) { - return this._pathTemplates.organizationMonitoredResourceDescriptorPathTemplate.render({ - organization: organization, - monitored_resource_descriptor: monitoredResourceDescriptor, - }); - } - - /** - * Parse the organization from OrganizationMonitoredResourceDescriptor resource. - * - * @param {string} organizationMonitoredResourceDescriptorName - * A fully-qualified path representing organization_monitored_resource_descriptor resource. - * @returns {string} A string representing the organization. - */ - matchOrganizationFromOrganizationMonitoredResourceDescriptorName(organizationMonitoredResourceDescriptorName: string) { - return this._pathTemplates.organizationMonitoredResourceDescriptorPathTemplate.match(organizationMonitoredResourceDescriptorName).organization; - } - - /** - * Parse the monitored_resource_descriptor from OrganizationMonitoredResourceDescriptor resource. - * - * @param {string} organizationMonitoredResourceDescriptorName - * A fully-qualified path representing organization_monitored_resource_descriptor resource. - * @returns {string} A string representing the monitored_resource_descriptor. - */ - matchMonitoredResourceDescriptorFromOrganizationMonitoredResourceDescriptorName(organizationMonitoredResourceDescriptorName: string) { - return this._pathTemplates.organizationMonitoredResourceDescriptorPathTemplate.match(organizationMonitoredResourceDescriptorName).monitored_resource_descriptor; - } - - /** - * Return a fully-qualified folderMonitoredResourceDescriptor resource name string. - * - * @param {string} folder - * @param {string} monitored_resource_descriptor - * @returns {string} Resource name string. - */ - folderMonitoredResourceDescriptorPath(folder:string,monitoredResourceDescriptor:string) { - return this._pathTemplates.folderMonitoredResourceDescriptorPathTemplate.render({ - folder: folder, - monitored_resource_descriptor: monitoredResourceDescriptor, - }); - } - - /** - * Parse the folder from FolderMonitoredResourceDescriptor resource. - * - * @param {string} folderMonitoredResourceDescriptorName - * A fully-qualified path representing folder_monitored_resource_descriptor resource. - * @returns {string} A string representing the folder. - */ - matchFolderFromFolderMonitoredResourceDescriptorName(folderMonitoredResourceDescriptorName: string) { - return this._pathTemplates.folderMonitoredResourceDescriptorPathTemplate.match(folderMonitoredResourceDescriptorName).folder; - } - - /** - * Parse the monitored_resource_descriptor from FolderMonitoredResourceDescriptor resource. - * - * @param {string} folderMonitoredResourceDescriptorName - * A fully-qualified path representing folder_monitored_resource_descriptor resource. - * @returns {string} A string representing the monitored_resource_descriptor. - */ - matchMonitoredResourceDescriptorFromFolderMonitoredResourceDescriptorName(folderMonitoredResourceDescriptorName: string) { - return this._pathTemplates.folderMonitoredResourceDescriptorPathTemplate.match(folderMonitoredResourceDescriptorName).monitored_resource_descriptor; - } - - /** - * Return a fully-qualified projectMetricDescriptor resource name string. - * - * @param {string} project - * @param {string} metric_descriptor - * @returns {string} Resource name string. - */ - projectMetricDescriptorPath(project:string,metricDescriptor:string) { - return this._pathTemplates.projectMetricDescriptorPathTemplate.render({ - project: project, - metric_descriptor: metricDescriptor, - }); - } - - /** - * Parse the project from ProjectMetricDescriptor resource. - * - * @param {string} projectMetricDescriptorName - * A fully-qualified path representing project_metric_descriptor resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProjectMetricDescriptorName(projectMetricDescriptorName: string) { - return this._pathTemplates.projectMetricDescriptorPathTemplate.match(projectMetricDescriptorName).project; - } - - /** - * Parse the metric_descriptor from ProjectMetricDescriptor resource. - * - * @param {string} projectMetricDescriptorName - * A fully-qualified path representing project_metric_descriptor resource. - * @returns {string} A string representing the metric_descriptor. - */ - matchMetricDescriptorFromProjectMetricDescriptorName(projectMetricDescriptorName: string) { - return this._pathTemplates.projectMetricDescriptorPathTemplate.match(projectMetricDescriptorName).metric_descriptor; - } - - /** - * Return a fully-qualified organizationMetricDescriptor resource name string. - * - * @param {string} organization - * @param {string} metric_descriptor - * @returns {string} Resource name string. - */ - organizationMetricDescriptorPath(organization:string,metricDescriptor:string) { - return this._pathTemplates.organizationMetricDescriptorPathTemplate.render({ - organization: organization, - metric_descriptor: metricDescriptor, - }); - } - - /** - * Parse the organization from OrganizationMetricDescriptor resource. - * - * @param {string} organizationMetricDescriptorName - * A fully-qualified path representing organization_metric_descriptor resource. - * @returns {string} A string representing the organization. - */ - matchOrganizationFromOrganizationMetricDescriptorName(organizationMetricDescriptorName: string) { - return this._pathTemplates.organizationMetricDescriptorPathTemplate.match(organizationMetricDescriptorName).organization; - } - - /** - * Parse the metric_descriptor from OrganizationMetricDescriptor resource. - * - * @param {string} organizationMetricDescriptorName - * A fully-qualified path representing organization_metric_descriptor resource. - * @returns {string} A string representing the metric_descriptor. - */ - matchMetricDescriptorFromOrganizationMetricDescriptorName(organizationMetricDescriptorName: string) { - return this._pathTemplates.organizationMetricDescriptorPathTemplate.match(organizationMetricDescriptorName).metric_descriptor; - } - - /** - * Return a fully-qualified folderMetricDescriptor resource name string. - * - * @param {string} folder - * @param {string} metric_descriptor - * @returns {string} Resource name string. - */ - folderMetricDescriptorPath(folder:string,metricDescriptor:string) { - return this._pathTemplates.folderMetricDescriptorPathTemplate.render({ - folder: folder, - metric_descriptor: metricDescriptor, - }); - } - - /** - * Parse the folder from FolderMetricDescriptor resource. - * - * @param {string} folderMetricDescriptorName - * A fully-qualified path representing folder_metric_descriptor resource. - * @returns {string} A string representing the folder. - */ - matchFolderFromFolderMetricDescriptorName(folderMetricDescriptorName: string) { - return this._pathTemplates.folderMetricDescriptorPathTemplate.match(folderMetricDescriptorName).folder; - } - - /** - * Parse the metric_descriptor from FolderMetricDescriptor resource. - * - * @param {string} folderMetricDescriptorName - * A fully-qualified path representing folder_metric_descriptor resource. - * @returns {string} A string representing the metric_descriptor. - */ - matchMetricDescriptorFromFolderMetricDescriptorName(folderMetricDescriptorName: string) { - return this._pathTemplates.folderMetricDescriptorPathTemplate.match(folderMetricDescriptorName).metric_descriptor; - } - - /** - * Terminate the GRPC channel and close the client. - * - * The client will no longer be usable and all future behavior is undefined. - */ - close(): Promise { - if (!this._terminated) { - return this.metricServiceStub.then(stub => { - this._terminated = true; - stub.close(); - }); - } - return Promise.resolve(); - } -} diff --git a/typescript/test/testdata/monitoring/src/v3/metric_service_client_config.json.baseline b/typescript/test/testdata/monitoring/src/v3/metric_service_client_config.json.baseline deleted file mode 100644 index c1826e96c..000000000 --- a/typescript/test/testdata/monitoring/src/v3/metric_service_client_config.json.baseline +++ /dev/null @@ -1,58 +0,0 @@ -{ - "interfaces": { - "google.monitoring.v3.MetricService": { - "retry_codes": { - "non_idempotent": [], - "idempotent": [ - "DEADLINE_EXCEEDED", - "UNAVAILABLE" - ] - }, - "retry_params": { - "default": { - "initial_retry_delay_millis": 100, - "retry_delay_multiplier": 1.3, - "max_retry_delay_millis": 60000, - "initial_rpc_timeout_millis": 60000, - "rpc_timeout_multiplier": 1, - "max_rpc_timeout_millis": 60000, - "total_timeout_millis": 600000 - } - }, - "methods": { - "ListMonitoredResourceDescriptors": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "GetMonitoredResourceDescriptor": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "ListMetricDescriptors": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "GetMetricDescriptor": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "CreateMetricDescriptor": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "DeleteMetricDescriptor": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "ListTimeSeries": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "CreateTimeSeries": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - } - } - } - } -} diff --git a/typescript/test/testdata/monitoring/src/v3/metric_service_proto_list.json.baseline b/typescript/test/testdata/monitoring/src/v3/metric_service_proto_list.json.baseline deleted file mode 100644 index aacceb22f..000000000 --- a/typescript/test/testdata/monitoring/src/v3/metric_service_proto_list.json.baseline +++ /dev/null @@ -1,16 +0,0 @@ -[ - "../../protos/google/monitoring/v3/alert.proto", - "../../protos/google/monitoring/v3/alert_service.proto", - "../../protos/google/monitoring/v3/common.proto", - "../../protos/google/monitoring/v3/group.proto", - "../../protos/google/monitoring/v3/group_service.proto", - "../../protos/google/monitoring/v3/metric.proto", - "../../protos/google/monitoring/v3/metric_service.proto", - "../../protos/google/monitoring/v3/mutation_record.proto", - "../../protos/google/monitoring/v3/notification.proto", - "../../protos/google/monitoring/v3/notification_service.proto", - "../../protos/google/monitoring/v3/service.proto", - "../../protos/google/monitoring/v3/service_service.proto", - "../../protos/google/monitoring/v3/uptime.proto", - "../../protos/google/monitoring/v3/uptime_service.proto" -] diff --git a/typescript/test/testdata/monitoring/src/v3/notification_channel_service_client.ts.baseline b/typescript/test/testdata/monitoring/src/v3/notification_channel_service_client.ts.baseline deleted file mode 100644 index 20d132d0a..000000000 --- a/typescript/test/testdata/monitoring/src/v3/notification_channel_service_client.ts.baseline +++ /dev/null @@ -1,1993 +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 gax from 'google-gax'; -import {APICallback, Callback, CallOptions, Descriptors, ClientOptions, PaginationCallback, PaginationResponse} from 'google-gax'; -import * as path from 'path'; - -import { Transform } from 'stream'; -import * as protosTypes from '../../protos/protos'; -import * as gapicConfig from './notification_channel_service_client_config.json'; - -const version = require('../../../package.json').version; - -/** - * The Notification Channel API provides access to configuration that - * controls how messages related to incidents are sent. - * @class - * @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; - auth: gax.GoogleAuth; - notificationChannelServiceStub: Promise<{[name: string]: Function}>; - - /** - * Construct an instance of NotificationChannelServiceClient. - * - * @param {object} [options] - The configuration object. See the subsequent - * parameters for more details. - * @param {object} [options.credentials] - Credentials object. - * @param {string} [options.credentials.client_email] - * @param {string} [options.credentials.private_key] - * @param {string} [options.email] - Account email address. Required when - * using a .pem or .p12 keyFilename. - * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or - * .p12 key downloaded from the Google Developers Console. If you provide - * a path to a JSON file, the projectId option below is not necessary. - * NOTE: .pem and .p12 require you to specify options.email as well. - * @param {number} [options.port] - The port on which to connect to - * the remote host. - * @param {string} [options.projectId] - The project ID from the Google - * Developer's Console, e.g. 'grape-spaceship-123'. We will also check - * the environment variable GCLOUD_PROJECT for your project ID. If your - * app is running in an environment which supports - * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, - * your project ID will be detected automatically. - * @param {function} [options.promise] - Custom promise module to use instead - * of native Promises. - * @param {string} [options.apiEndpoint] - The domain name of the - * API remote host. - */ - - constructor(opts?: ClientOptions) { - // Ensure that options include the service address and port. - const staticMembers = this.constructor as typeof NotificationChannelServiceClient; - const servicePath = opts && opts.servicePath ? - opts.servicePath : - ((opts && opts.apiEndpoint) ? opts.apiEndpoint : - staticMembers.servicePath); - const port = opts && opts.port ? opts.port : staticMembers.port; - - if (!opts) { - opts = {servicePath, port}; - } - opts.servicePath = opts.servicePath || servicePath; - opts.port = opts.port || port; - opts.clientConfig = opts.clientConfig || {}; - - const isBrowser = (typeof window !== 'undefined'); - if (isBrowser){ - opts.fallback = true; - } - // If we are in browser, we are already using fallback because of the - // "browser" field in package.json. - // But if we were explicitly requested to use fallback, let's do it now. - const gaxModule = !isBrowser && opts.fallback ? gax.fallback : gax; - - // Create a `gaxGrpc` object, with any grpc-specific options - // sent to the client. - opts.scopes = (this.constructor as typeof NotificationChannelServiceClient).scopes; - const gaxGrpc = new gaxModule.GrpcClient(opts); - - // Save the auth object to the client, for use by other methods. - this.auth = (gaxGrpc.auth as gax.GoogleAuth); - - // Determine the client header string. - const clientHeader = [ - `gax/${gaxModule.version}`, - `gapic/${version}`, - ]; - if (typeof process !== 'undefined' && 'versions' in process) { - clientHeader.push(`gl-node/${process.versions.node}`); - } else { - clientHeader.push(`gl-web/${gaxModule.version}`); - } - if (!opts.fallback) { - clientHeader.push(`grpc/${gaxGrpc.grpcVersion}`); - } - if (opts.libName && opts.libVersion) { - clientHeader.push(`${opts.libName}/${opts.libVersion}`); - } - // Load the applicable protos. - // For Node.js, pass the path to JSON proto file. - // For browsers, pass the JSON content. - - const nodejsProtoPath = path.join(__dirname, '..', '..', 'protos', 'protos.json'); - const protos = gaxGrpc.loadProto( - opts.fallback ? - 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 = { - projectAlertPolicyPathTemplate: new gaxModule.PathTemplate( - 'projects/{project}/alertPolicies/{alert_policy}' - ), - organizationAlertPolicyPathTemplate: new gaxModule.PathTemplate( - 'organizations/{organization}/alertPolicies/{alert_policy}' - ), - folderAlertPolicyPathTemplate: new gaxModule.PathTemplate( - 'folders/{folder}/alertPolicies/{alert_policy}' - ), - PathTemplate: new gaxModule.PathTemplate( - '*' - ), - projectGroupPathTemplate: new gaxModule.PathTemplate( - 'projects/{project}/groups/{group}' - ), - organizationGroupPathTemplate: new gaxModule.PathTemplate( - 'organizations/{organization}/groups/{group}' - ), - folderGroupPathTemplate: new gaxModule.PathTemplate( - 'folders/{folder}/groups/{group}' - ), - projectChannelDescriptorPathTemplate: new gaxModule.PathTemplate( - 'projects/{project}/notificationChannelDescriptors/{channel_descriptor}' - ), - organizationChannelDescriptorPathTemplate: new gaxModule.PathTemplate( - 'organizations/{organization}/notificationChannelDescriptors/{channel_descriptor}' - ), - folderChannelDescriptorPathTemplate: new gaxModule.PathTemplate( - 'folders/{folder}/notificationChannelDescriptors/{channel_descriptor}' - ), - projectNotificationChannelPathTemplate: new gaxModule.PathTemplate( - 'projects/{project}/notificationChannels/{notification_channel}' - ), - organizationNotificationChannelPathTemplate: new gaxModule.PathTemplate( - 'organizations/{organization}/notificationChannels/{notification_channel}' - ), - folderNotificationChannelPathTemplate: new gaxModule.PathTemplate( - 'folders/{folder}/notificationChannels/{notification_channel}' - ), - projectServicePathTemplate: new gaxModule.PathTemplate( - 'projects/{project}/services/{service}' - ), - organizationServicePathTemplate: new gaxModule.PathTemplate( - 'organizations/{organization}/services/{service}' - ), - folderServicePathTemplate: new gaxModule.PathTemplate( - 'folders/{folder}/services/{service}' - ), - projectServiceServiceLevelObjectivePathTemplate: new gaxModule.PathTemplate( - 'projects/{project}/services/{service}/serviceLevelObjectives/{service_level_objective}' - ), - organizationServiceServiceLevelObjectivePathTemplate: new gaxModule.PathTemplate( - 'organizations/{organization}/services/{service}/serviceLevelObjectives/{service_level_objective}' - ), - folderServiceServiceLevelObjectivePathTemplate: new gaxModule.PathTemplate( - 'folders/{folder}/services/{service}/serviceLevelObjectives/{service_level_objective}' - ), - projectUptimeCheckConfigPathTemplate: new gaxModule.PathTemplate( - 'projects/{project}/uptimeCheckConfigs/{uptime_check_config}' - ), - organizationUptimeCheckConfigPathTemplate: new gaxModule.PathTemplate( - 'organizations/{organization}/uptimeCheckConfigs/{uptime_check_config}' - ), - folderUptimeCheckConfigPathTemplate: new gaxModule.PathTemplate( - 'folders/{folder}/uptimeCheckConfigs/{uptime_check_config}' - ), - }; - - // 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 = { - listNotificationChannelDescriptors: - new gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'channelDescriptors'), - listNotificationChannels: - new gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'notificationChannels') - }; - - // Put together the default options sent with requests. - const defaults = gaxGrpc.constructSettings( - 'google.monitoring.v3.NotificationChannelService', gapicConfig as gax.ClientConfig, - opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); - - // Set up a dictionary of "inner API calls"; the core implementation - // of calling the API is handled in `google-gax`, with this code - // merely providing the destination and request information. - this._innerApiCalls = {}; - - // Put together the "service stub" for - // google.monitoring.v3.NotificationChannelService. - this.notificationChannelServiceStub = gaxGrpc.createStub( - opts.fallback ? - (protos as protobuf.Root).lookupService('google.monitoring.v3.NotificationChannelService') : - // tslint:disable-next-line no-any - (protos as any).google.monitoring.v3.NotificationChannelService, - opts) as Promise<{[method: string]: Function}>; - - // Iterate over each of the methods that the service provides - // and create an API call method for each. - const notificationChannelServiceStubMethods = - ['listNotificationChannelDescriptors', 'getNotificationChannelDescriptor', 'listNotificationChannels', 'getNotificationChannel', 'createNotificationChannel', 'updateNotificationChannel', 'deleteNotificationChannel', 'sendNotificationChannelVerificationCode', 'getNotificationChannelVerificationCode', 'verifyNotificationChannel']; - - for (const methodName of notificationChannelServiceStubMethods) { - const innerCallPromise = this.notificationChannelServiceStub.then( - stub => (...args: Array<{}>) => { - if (this._terminated) { - return Promise.reject('The client has already been closed.'); - } - return stub[methodName].apply(stub, args); - }, - (err: Error|null|undefined) => () => { - throw err; - }); - - const apiCall = gaxModule.createApiCall( - innerCallPromise, - defaults[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); - }; - } - } - - /** - * The DNS address for this API service. - */ - static get servicePath() { - return 'monitoring.googleapis.com'; - } - - /** - * The DNS address for this API service - same as servicePath(), - * exists for compatibility reasons. - */ - static get apiEndpoint() { - return 'monitoring.googleapis.com'; - } - - /** - * The port for this API service. - */ - static get port() { - return 443; - } - - /** - * The scopes needed to make gRPC calls for every method defined - * in this service. - */ - static get scopes() { - return [ - 'https://www.googleapis.com/auth/cloud-platform', - 'https://www.googleapis.com/auth/monitoring', - 'https://www.googleapis.com/auth/monitoring.read' - ]; - } - - getProjectId(): Promise; - getProjectId(callback: Callback): void; - /** - * Return the project ID used by this class. - * @param {function(Error, string)} callback - the callback to - * be called with the current project Id. - */ - getProjectId(callback?: Callback): - Promise|void { - if (callback) { - this.auth.getProjectId(callback); - return; - } - return this.auth.getProjectId(); - } - - // ------------------- - // -- Service calls -- - // ------------------- - getNotificationChannelDescriptor( - request: protosTypes.google.monitoring.v3.IGetNotificationChannelDescriptorRequest, - options?: gax.CallOptions): - Promise<[ - protosTypes.google.monitoring.v3.INotificationChannelDescriptor, - protosTypes.google.monitoring.v3.IGetNotificationChannelDescriptorRequest|undefined, {}|undefined - ]>; - getNotificationChannelDescriptor( - request: protosTypes.google.monitoring.v3.IGetNotificationChannelDescriptorRequest, - options: gax.CallOptions, - callback: Callback< - protosTypes.google.monitoring.v3.INotificationChannelDescriptor, - protosTypes.google.monitoring.v3.IGetNotificationChannelDescriptorRequest|undefined, - {}|undefined>): void; -/** - * Gets a single channel descriptor. The descriptor indicates which fields - * are expected / permitted for a notification channel of the given type. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The channel type for which to execute the request. The format is - * `projects/[PROJECT_ID]/notificationChannelDescriptors/{channel_type}`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [NotificationChannelDescriptor]{@link google.monitoring.v3.NotificationChannelDescriptor}. - * The promise has a method named "cancel" which cancels the ongoing API call. - */ - getNotificationChannelDescriptor( - request: protosTypes.google.monitoring.v3.IGetNotificationChannelDescriptorRequest, - optionsOrCallback?: gax.CallOptions|Callback< - protosTypes.google.monitoring.v3.INotificationChannelDescriptor, - protosTypes.google.monitoring.v3.IGetNotificationChannelDescriptorRequest|undefined, {}|undefined>, - callback?: Callback< - protosTypes.google.monitoring.v3.INotificationChannelDescriptor, - protosTypes.google.monitoring.v3.IGetNotificationChannelDescriptorRequest|undefined, - {}|undefined>): - Promise<[ - protosTypes.google.monitoring.v3.INotificationChannelDescriptor, - protosTypes.google.monitoring.v3.IGetNotificationChannelDescriptorRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: gax.CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as gax.CallOptions; - } - 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 || '', - }); - return this._innerApiCalls.getNotificationChannelDescriptor(request, options, callback); - } - getNotificationChannel( - request: protosTypes.google.monitoring.v3.IGetNotificationChannelRequest, - options?: gax.CallOptions): - Promise<[ - protosTypes.google.monitoring.v3.INotificationChannel, - protosTypes.google.monitoring.v3.IGetNotificationChannelRequest|undefined, {}|undefined - ]>; - getNotificationChannel( - request: protosTypes.google.monitoring.v3.IGetNotificationChannelRequest, - options: gax.CallOptions, - callback: Callback< - protosTypes.google.monitoring.v3.INotificationChannel, - protosTypes.google.monitoring.v3.IGetNotificationChannelRequest|undefined, - {}|undefined>): void; -/** - * Gets a single notification channel. The channel includes the relevant - * configuration details with which the channel was created. However, the - * response may truncate or omit passwords, API keys, or other private key - * matter and thus the response may not be 100% identical to the information - * that was supplied in the call to the create method. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The channel for which to execute the request. The format is - * `projects/[PROJECT_ID]/notificationChannels/[CHANNEL_ID]`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [NotificationChannel]{@link google.monitoring.v3.NotificationChannel}. - * The promise has a method named "cancel" which cancels the ongoing API call. - */ - getNotificationChannel( - request: protosTypes.google.monitoring.v3.IGetNotificationChannelRequest, - optionsOrCallback?: gax.CallOptions|Callback< - protosTypes.google.monitoring.v3.INotificationChannel, - protosTypes.google.monitoring.v3.IGetNotificationChannelRequest|undefined, {}|undefined>, - callback?: Callback< - protosTypes.google.monitoring.v3.INotificationChannel, - protosTypes.google.monitoring.v3.IGetNotificationChannelRequest|undefined, - {}|undefined>): - Promise<[ - protosTypes.google.monitoring.v3.INotificationChannel, - protosTypes.google.monitoring.v3.IGetNotificationChannelRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: gax.CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as gax.CallOptions; - } - 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 || '', - }); - return this._innerApiCalls.getNotificationChannel(request, options, callback); - } - createNotificationChannel( - request: protosTypes.google.monitoring.v3.ICreateNotificationChannelRequest, - options?: gax.CallOptions): - Promise<[ - protosTypes.google.monitoring.v3.INotificationChannel, - protosTypes.google.monitoring.v3.ICreateNotificationChannelRequest|undefined, {}|undefined - ]>; - createNotificationChannel( - request: protosTypes.google.monitoring.v3.ICreateNotificationChannelRequest, - options: gax.CallOptions, - callback: Callback< - protosTypes.google.monitoring.v3.INotificationChannel, - protosTypes.google.monitoring.v3.ICreateNotificationChannelRequest|undefined, - {}|undefined>): void; -/** - * Creates a new notification channel, representing a single notification - * endpoint such as an email address, SMS number, or PagerDuty service. - * - * @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] - * - * Note that this names the container into which the channel will be - * written. This does not name the newly created channel. The resulting - * channel's name will have a normalized version of this field as a prefix, - * but will add `/notificationChannels/[CHANNEL_ID]` to identify the channel. - * @param {google.monitoring.v3.NotificationChannel} request.notificationChannel - * Required. The definition of the `NotificationChannel` to create. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [NotificationChannel]{@link google.monitoring.v3.NotificationChannel}. - * The promise has a method named "cancel" which cancels the ongoing API call. - */ - createNotificationChannel( - request: protosTypes.google.monitoring.v3.ICreateNotificationChannelRequest, - optionsOrCallback?: gax.CallOptions|Callback< - protosTypes.google.monitoring.v3.INotificationChannel, - protosTypes.google.monitoring.v3.ICreateNotificationChannelRequest|undefined, {}|undefined>, - callback?: Callback< - protosTypes.google.monitoring.v3.INotificationChannel, - protosTypes.google.monitoring.v3.ICreateNotificationChannelRequest|undefined, - {}|undefined>): - Promise<[ - protosTypes.google.monitoring.v3.INotificationChannel, - protosTypes.google.monitoring.v3.ICreateNotificationChannelRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: gax.CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as gax.CallOptions; - } - 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 || '', - }); - return this._innerApiCalls.createNotificationChannel(request, options, callback); - } - updateNotificationChannel( - request: protosTypes.google.monitoring.v3.IUpdateNotificationChannelRequest, - options?: gax.CallOptions): - Promise<[ - protosTypes.google.monitoring.v3.INotificationChannel, - protosTypes.google.monitoring.v3.IUpdateNotificationChannelRequest|undefined, {}|undefined - ]>; - updateNotificationChannel( - request: protosTypes.google.monitoring.v3.IUpdateNotificationChannelRequest, - options: gax.CallOptions, - callback: Callback< - protosTypes.google.monitoring.v3.INotificationChannel, - protosTypes.google.monitoring.v3.IUpdateNotificationChannelRequest|undefined, - {}|undefined>): void; -/** - * Updates a notification channel. Fields not specified in the field mask - * remain unchanged. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.protobuf.FieldMask} request.updateMask - * The fields to update. - * @param {google.monitoring.v3.NotificationChannel} request.notificationChannel - * Required. A description of the changes to be applied to the specified - * notification channel. The description must provide a definition for - * fields to be updated; the names of these fields should also be - * included in the `update_mask`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [NotificationChannel]{@link google.monitoring.v3.NotificationChannel}. - * The promise has a method named "cancel" which cancels the ongoing API call. - */ - updateNotificationChannel( - request: protosTypes.google.monitoring.v3.IUpdateNotificationChannelRequest, - optionsOrCallback?: gax.CallOptions|Callback< - protosTypes.google.monitoring.v3.INotificationChannel, - protosTypes.google.monitoring.v3.IUpdateNotificationChannelRequest|undefined, {}|undefined>, - callback?: Callback< - protosTypes.google.monitoring.v3.INotificationChannel, - protosTypes.google.monitoring.v3.IUpdateNotificationChannelRequest|undefined, - {}|undefined>): - Promise<[ - protosTypes.google.monitoring.v3.INotificationChannel, - protosTypes.google.monitoring.v3.IUpdateNotificationChannelRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: gax.CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as gax.CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'notification_channel.name': request.notificationChannel!.name || '', - }); - return this._innerApiCalls.updateNotificationChannel(request, options, callback); - } - deleteNotificationChannel( - request: protosTypes.google.monitoring.v3.IDeleteNotificationChannelRequest, - options?: gax.CallOptions): - Promise<[ - protosTypes.google.protobuf.IEmpty, - protosTypes.google.monitoring.v3.IDeleteNotificationChannelRequest|undefined, {}|undefined - ]>; - deleteNotificationChannel( - request: protosTypes.google.monitoring.v3.IDeleteNotificationChannelRequest, - options: gax.CallOptions, - callback: Callback< - protosTypes.google.protobuf.IEmpty, - protosTypes.google.monitoring.v3.IDeleteNotificationChannelRequest|undefined, - {}|undefined>): void; -/** - * Deletes a notification channel. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The channel for which to execute the request. The format is - * `projects/[PROJECT_ID]/notificationChannels/[CHANNEL_ID]`. - * @param {boolean} request.force - * If true, the notification channel will be deleted regardless of its - * use in alert policies (the policies will be updated to remove the - * channel). If false, channels that are still referenced by an existing - * alerting policy will fail to be deleted in a delete operation. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. - * The promise has a method named "cancel" which cancels the ongoing API call. - */ - deleteNotificationChannel( - request: protosTypes.google.monitoring.v3.IDeleteNotificationChannelRequest, - optionsOrCallback?: gax.CallOptions|Callback< - protosTypes.google.protobuf.IEmpty, - protosTypes.google.monitoring.v3.IDeleteNotificationChannelRequest|undefined, {}|undefined>, - callback?: Callback< - protosTypes.google.protobuf.IEmpty, - protosTypes.google.monitoring.v3.IDeleteNotificationChannelRequest|undefined, - {}|undefined>): - Promise<[ - protosTypes.google.protobuf.IEmpty, - protosTypes.google.monitoring.v3.IDeleteNotificationChannelRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: gax.CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as gax.CallOptions; - } - 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 || '', - }); - return this._innerApiCalls.deleteNotificationChannel(request, options, callback); - } - sendNotificationChannelVerificationCode( - request: protosTypes.google.monitoring.v3.ISendNotificationChannelVerificationCodeRequest, - options?: gax.CallOptions): - Promise<[ - protosTypes.google.protobuf.IEmpty, - protosTypes.google.monitoring.v3.ISendNotificationChannelVerificationCodeRequest|undefined, {}|undefined - ]>; - sendNotificationChannelVerificationCode( - request: protosTypes.google.monitoring.v3.ISendNotificationChannelVerificationCodeRequest, - options: gax.CallOptions, - callback: Callback< - protosTypes.google.protobuf.IEmpty, - protosTypes.google.monitoring.v3.ISendNotificationChannelVerificationCodeRequest|undefined, - {}|undefined>): void; -/** - * Causes a verification code to be delivered to the channel. The code - * can then be supplied in `VerifyNotificationChannel` to verify the channel. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The notification channel to which to send a verification code. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. - * The promise has a method named "cancel" which cancels the ongoing API call. - */ - sendNotificationChannelVerificationCode( - request: protosTypes.google.monitoring.v3.ISendNotificationChannelVerificationCodeRequest, - optionsOrCallback?: gax.CallOptions|Callback< - protosTypes.google.protobuf.IEmpty, - protosTypes.google.monitoring.v3.ISendNotificationChannelVerificationCodeRequest|undefined, {}|undefined>, - callback?: Callback< - protosTypes.google.protobuf.IEmpty, - protosTypes.google.monitoring.v3.ISendNotificationChannelVerificationCodeRequest|undefined, - {}|undefined>): - Promise<[ - protosTypes.google.protobuf.IEmpty, - protosTypes.google.monitoring.v3.ISendNotificationChannelVerificationCodeRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: gax.CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as gax.CallOptions; - } - 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 || '', - }); - return this._innerApiCalls.sendNotificationChannelVerificationCode(request, options, callback); - } - getNotificationChannelVerificationCode( - request: protosTypes.google.monitoring.v3.IGetNotificationChannelVerificationCodeRequest, - options?: gax.CallOptions): - Promise<[ - protosTypes.google.monitoring.v3.IGetNotificationChannelVerificationCodeResponse, - protosTypes.google.monitoring.v3.IGetNotificationChannelVerificationCodeRequest|undefined, {}|undefined - ]>; - getNotificationChannelVerificationCode( - request: protosTypes.google.monitoring.v3.IGetNotificationChannelVerificationCodeRequest, - options: gax.CallOptions, - callback: Callback< - protosTypes.google.monitoring.v3.IGetNotificationChannelVerificationCodeResponse, - protosTypes.google.monitoring.v3.IGetNotificationChannelVerificationCodeRequest|undefined, - {}|undefined>): void; -/** - * Requests a verification code for an already verified channel that can then - * be used in a call to VerifyNotificationChannel() on a different channel - * with an equivalent identity in the same or in a different project. This - * makes it possible to copy a channel between projects without requiring - * manual reverification of the channel. If the channel is not in the - * verified state, this method will fail (in other words, this may only be - * used if the SendNotificationChannelVerificationCode and - * VerifyNotificationChannel paths have already been used to put the given - * channel into the verified state). - * - * There is no guarantee that the verification codes returned by this method - * will be of a similar structure or form as the ones that are delivered - * to the channel via SendNotificationChannelVerificationCode; while - * VerifyNotificationChannel() will recognize both the codes delivered via - * SendNotificationChannelVerificationCode() and returned from - * GetNotificationChannelVerificationCode(), it is typically the case that - * the verification codes delivered via - * SendNotificationChannelVerificationCode() will be shorter and also - * have a shorter expiration (e.g. codes such as "G-123456") whereas - * GetVerificationCode() will typically return a much longer, websafe base - * 64 encoded string that has a longer expiration time. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The notification channel for which a verification code is to be generated - * and retrieved. This must name a channel that is already verified; if - * the specified channel is not verified, the request will fail. - * @param {google.protobuf.Timestamp} request.expireTime - * The desired expiration time. If specified, the API will guarantee that - * the returned code will not be valid after the specified timestamp; - * however, the API cannot guarantee that the returned code will be - * valid for at least as long as the requested time (the API puts an upper - * bound on the amount of time for which a code may be valid). If omitted, - * a default expiration will be used, which may be less than the max - * permissible expiration (so specifying an expiration may extend the - * code's lifetime over omitting an expiration, even though the API does - * impose an upper limit on the maximum expiration that is permitted). - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [GetNotificationChannelVerificationCodeResponse]{@link google.monitoring.v3.GetNotificationChannelVerificationCodeResponse}. - * The promise has a method named "cancel" which cancels the ongoing API call. - */ - getNotificationChannelVerificationCode( - request: protosTypes.google.monitoring.v3.IGetNotificationChannelVerificationCodeRequest, - optionsOrCallback?: gax.CallOptions|Callback< - protosTypes.google.monitoring.v3.IGetNotificationChannelVerificationCodeResponse, - protosTypes.google.monitoring.v3.IGetNotificationChannelVerificationCodeRequest|undefined, {}|undefined>, - callback?: Callback< - protosTypes.google.monitoring.v3.IGetNotificationChannelVerificationCodeResponse, - protosTypes.google.monitoring.v3.IGetNotificationChannelVerificationCodeRequest|undefined, - {}|undefined>): - Promise<[ - protosTypes.google.monitoring.v3.IGetNotificationChannelVerificationCodeResponse, - protosTypes.google.monitoring.v3.IGetNotificationChannelVerificationCodeRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: gax.CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as gax.CallOptions; - } - 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 || '', - }); - return this._innerApiCalls.getNotificationChannelVerificationCode(request, options, callback); - } - verifyNotificationChannel( - request: protosTypes.google.monitoring.v3.IVerifyNotificationChannelRequest, - options?: gax.CallOptions): - Promise<[ - protosTypes.google.monitoring.v3.INotificationChannel, - protosTypes.google.monitoring.v3.IVerifyNotificationChannelRequest|undefined, {}|undefined - ]>; - verifyNotificationChannel( - request: protosTypes.google.monitoring.v3.IVerifyNotificationChannelRequest, - options: gax.CallOptions, - callback: Callback< - protosTypes.google.monitoring.v3.INotificationChannel, - protosTypes.google.monitoring.v3.IVerifyNotificationChannelRequest|undefined, - {}|undefined>): void; -/** - * Verifies a `NotificationChannel` by proving receipt of the code - * delivered to the channel as a result of calling - * `SendNotificationChannelVerificationCode`. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The notification channel to verify. - * @param {string} request.code - * Required. The verification code that was delivered to the channel as - * a result of invoking the `SendNotificationChannelVerificationCode` API - * method or that was retrieved from a verified channel via - * `GetNotificationChannelVerificationCode`. For example, one might have - * "G-123456" or "TKNZGhhd2EyN3I1MnRnMjRv" (in general, one is only - * guaranteed that the code is valid UTF-8; one should not - * make any assumptions regarding the structure or format of the code). - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [NotificationChannel]{@link google.monitoring.v3.NotificationChannel}. - * The promise has a method named "cancel" which cancels the ongoing API call. - */ - verifyNotificationChannel( - request: protosTypes.google.monitoring.v3.IVerifyNotificationChannelRequest, - optionsOrCallback?: gax.CallOptions|Callback< - protosTypes.google.monitoring.v3.INotificationChannel, - protosTypes.google.monitoring.v3.IVerifyNotificationChannelRequest|undefined, {}|undefined>, - callback?: Callback< - protosTypes.google.monitoring.v3.INotificationChannel, - protosTypes.google.monitoring.v3.IVerifyNotificationChannelRequest|undefined, - {}|undefined>): - Promise<[ - protosTypes.google.monitoring.v3.INotificationChannel, - protosTypes.google.monitoring.v3.IVerifyNotificationChannelRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: gax.CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as gax.CallOptions; - } - 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 || '', - }); - return this._innerApiCalls.verifyNotificationChannel(request, options, callback); - } - - listNotificationChannelDescriptors( - request: protosTypes.google.monitoring.v3.IListNotificationChannelDescriptorsRequest, - options?: gax.CallOptions): - Promise<[ - protosTypes.google.monitoring.v3.INotificationChannelDescriptor[], - protosTypes.google.monitoring.v3.IListNotificationChannelDescriptorsRequest|null, - protosTypes.google.monitoring.v3.IListNotificationChannelDescriptorsResponse - ]>; - listNotificationChannelDescriptors( - request: protosTypes.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>): void; -/** - * Lists the descriptors for supported channel types. The use of descriptors - * makes it possible for new channel types to be dynamically added. - * - * @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] - * - * Note that this names the parent container in which to look for the - * descriptors; to retrieve a single descriptor by name, use the - * [GetNotificationChannelDescriptor][google.monitoring.v3.NotificationChannelService.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 {Promise} - The promise which resolves to an array. - * The first element of the array is Array of [NotificationChannelDescriptor]{@link google.monitoring.v3.NotificationChannelDescriptor}. - * The client library support auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * - * When autoPaginate: false is specified through options, the array has three elements. - * The first element is Array of [NotificationChannelDescriptor]{@link google.monitoring.v3.NotificationChannelDescriptor} that corresponds to - * the one page received from the API server. - * If the second element is not null it contains the request object of type [ListNotificationChannelDescriptorsRequest]{@link google.monitoring.v3.ListNotificationChannelDescriptorsRequest} - * that can be used to obtain the next page of the results. - * If it is null, the next page does not exist. - * The third element contains the raw response received from the API server. Its type is - * [ListNotificationChannelDescriptorsResponse]{@link google.monitoring.v3.ListNotificationChannelDescriptorsResponse}. - * - * The promise has a method named "cancel" which cancels the ongoing API call. - */ - listNotificationChannelDescriptors( - request: protosTypes.google.monitoring.v3.IListNotificationChannelDescriptorsRequest, - optionsOrCallback?: gax.CallOptions|Callback< - protosTypes.google.monitoring.v3.INotificationChannelDescriptor[], - protosTypes.google.monitoring.v3.IListNotificationChannelDescriptorsRequest|null, - protosTypes.google.monitoring.v3.IListNotificationChannelDescriptorsResponse>, - callback?: Callback< - protosTypes.google.monitoring.v3.INotificationChannelDescriptor[], - protosTypes.google.monitoring.v3.IListNotificationChannelDescriptorsRequest|null, - protosTypes.google.monitoring.v3.IListNotificationChannelDescriptorsResponse>): - Promise<[ - protosTypes.google.monitoring.v3.INotificationChannelDescriptor[], - protosTypes.google.monitoring.v3.IListNotificationChannelDescriptorsRequest|null, - protosTypes.google.monitoring.v3.IListNotificationChannelDescriptorsResponse - ]>|void { - request = request || {}; - let options: gax.CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as gax.CallOptions; - } - 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 || '', - }); - return this._innerApiCalls.listNotificationChannelDescriptors(request, options, callback); - } - -/** - * Equivalent to {@link listNotificationChannelDescriptors}, but returns a NodeJS Stream object. - * - * This fetches the paged responses for {@link listNotificationChannelDescriptors} continuously - * and invokes the callback registered for 'data' event for each element in the - * responses. - * - * The returned object has 'end' method when no more elements are required. - * - * autoPaginate option will be ignored. - * - * @see {@link https://nodejs.org/api/stream.html} - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The REST resource name of the parent from which to retrieve - * the notification channel descriptors. The expected syntax is: - * - * projects/[PROJECT_ID] - * - * Note that this names the parent container in which to look for the - * descriptors; to retrieve a single descriptor by name, use the - * [GetNotificationChannelDescriptor][google.monitoring.v3.NotificationChannelService.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 {Stream} - * An object stream which emits an object representing [NotificationChannelDescriptor]{@link google.monitoring.v3.NotificationChannelDescriptor} on 'data' event. - */ - listNotificationChannelDescriptorsStream( - request?: protosTypes.google.monitoring.v3.IListNotificationChannelDescriptorsRequest, - options?: gax.CallOptions | {}): - Transform{ - request = request || {}; - const callSettings = new gax.CallSettings(options); - return this._descriptors.page.listNotificationChannelDescriptors.createStream( - this._innerApiCalls.listNotificationChannelDescriptors as gax.GaxCall, - request, - callSettings - ); - } - listNotificationChannels( - request: protosTypes.google.monitoring.v3.IListNotificationChannelsRequest, - options?: gax.CallOptions): - Promise<[ - protosTypes.google.monitoring.v3.INotificationChannel[], - protosTypes.google.monitoring.v3.IListNotificationChannelsRequest|null, - protosTypes.google.monitoring.v3.IListNotificationChannelsResponse - ]>; - listNotificationChannels( - request: protosTypes.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>): void; -/** - * Lists the notification channels that have been created for the project. - * - * @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]`. That is, 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 - * [`GetNotificationChannel`][google.monitoring.v3.NotificationChannelService.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](/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](/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 {Promise} - The promise which resolves to an array. - * The first element of the array is Array of [NotificationChannel]{@link google.monitoring.v3.NotificationChannel}. - * The client library support auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * - * When autoPaginate: false is specified through options, the array has three elements. - * The first element is Array of [NotificationChannel]{@link google.monitoring.v3.NotificationChannel} that corresponds to - * the one page received from the API server. - * If the second element is not null it contains the request object of type [ListNotificationChannelsRequest]{@link google.monitoring.v3.ListNotificationChannelsRequest} - * that can be used to obtain the next page of the results. - * If it is null, the next page does not exist. - * The third element contains the raw response received from the API server. Its type is - * [ListNotificationChannelsResponse]{@link google.monitoring.v3.ListNotificationChannelsResponse}. - * - * The promise has a method named "cancel" which cancels the ongoing API call. - */ - listNotificationChannels( - request: protosTypes.google.monitoring.v3.IListNotificationChannelsRequest, - optionsOrCallback?: gax.CallOptions|Callback< - protosTypes.google.monitoring.v3.INotificationChannel[], - protosTypes.google.monitoring.v3.IListNotificationChannelsRequest|null, - protosTypes.google.monitoring.v3.IListNotificationChannelsResponse>, - callback?: Callback< - protosTypes.google.monitoring.v3.INotificationChannel[], - protosTypes.google.monitoring.v3.IListNotificationChannelsRequest|null, - protosTypes.google.monitoring.v3.IListNotificationChannelsResponse>): - Promise<[ - protosTypes.google.monitoring.v3.INotificationChannel[], - protosTypes.google.monitoring.v3.IListNotificationChannelsRequest|null, - protosTypes.google.monitoring.v3.IListNotificationChannelsResponse - ]>|void { - request = request || {}; - let options: gax.CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as gax.CallOptions; - } - 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 || '', - }); - return this._innerApiCalls.listNotificationChannels(request, options, callback); - } - -/** - * Equivalent to {@link listNotificationChannels}, but returns a NodeJS Stream object. - * - * This fetches the paged responses for {@link listNotificationChannels} continuously - * and invokes the callback registered for 'data' event for each element in the - * responses. - * - * The returned object has 'end' method when no more elements are required. - * - * autoPaginate option will be ignored. - * - * @see {@link https://nodejs.org/api/stream.html} - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The project on which to execute the request. The format is - * `projects/[PROJECT_ID]`. That is, 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 - * [`GetNotificationChannel`][google.monitoring.v3.NotificationChannelService.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](/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](/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 {Stream} - * An object stream which emits an object representing [NotificationChannel]{@link google.monitoring.v3.NotificationChannel} on 'data' event. - */ - listNotificationChannelsStream( - request?: protosTypes.google.monitoring.v3.IListNotificationChannelsRequest, - options?: gax.CallOptions | {}): - Transform{ - request = request || {}; - const callSettings = new gax.CallSettings(options); - return this._descriptors.page.listNotificationChannels.createStream( - this._innerApiCalls.listNotificationChannels as gax.GaxCall, - request, - callSettings - ); - } - // -------------------- - // -- Path templates -- - // -------------------- - - /** - * Return a fully-qualified projectAlertPolicy resource name string. - * - * @param {string} project - * @param {string} alert_policy - * @returns {string} Resource name string. - */ - projectAlertPolicyPath(project:string,alertPolicy:string) { - return this._pathTemplates.projectAlertPolicyPathTemplate.render({ - project: project, - alert_policy: alertPolicy, - }); - } - - /** - * Parse the project from ProjectAlertPolicy resource. - * - * @param {string} projectAlertPolicyName - * A fully-qualified path representing project_alert_policy resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProjectAlertPolicyName(projectAlertPolicyName: string) { - return this._pathTemplates.projectAlertPolicyPathTemplate.match(projectAlertPolicyName).project; - } - - /** - * Parse the alert_policy from ProjectAlertPolicy resource. - * - * @param {string} projectAlertPolicyName - * A fully-qualified path representing project_alert_policy resource. - * @returns {string} A string representing the alert_policy. - */ - matchAlertPolicyFromProjectAlertPolicyName(projectAlertPolicyName: string) { - return this._pathTemplates.projectAlertPolicyPathTemplate.match(projectAlertPolicyName).alert_policy; - } - - /** - * Return a fully-qualified organizationAlertPolicy resource name string. - * - * @param {string} organization - * @param {string} alert_policy - * @returns {string} Resource name string. - */ - organizationAlertPolicyPath(organization:string,alertPolicy:string) { - return this._pathTemplates.organizationAlertPolicyPathTemplate.render({ - organization: organization, - alert_policy: alertPolicy, - }); - } - - /** - * Parse the organization from OrganizationAlertPolicy resource. - * - * @param {string} organizationAlertPolicyName - * A fully-qualified path representing organization_alert_policy resource. - * @returns {string} A string representing the organization. - */ - matchOrganizationFromOrganizationAlertPolicyName(organizationAlertPolicyName: string) { - return this._pathTemplates.organizationAlertPolicyPathTemplate.match(organizationAlertPolicyName).organization; - } - - /** - * Parse the alert_policy from OrganizationAlertPolicy resource. - * - * @param {string} organizationAlertPolicyName - * A fully-qualified path representing organization_alert_policy resource. - * @returns {string} A string representing the alert_policy. - */ - matchAlertPolicyFromOrganizationAlertPolicyName(organizationAlertPolicyName: string) { - return this._pathTemplates.organizationAlertPolicyPathTemplate.match(organizationAlertPolicyName).alert_policy; - } - - /** - * Return a fully-qualified folderAlertPolicy resource name string. - * - * @param {string} folder - * @param {string} alert_policy - * @returns {string} Resource name string. - */ - folderAlertPolicyPath(folder:string,alertPolicy:string) { - return this._pathTemplates.folderAlertPolicyPathTemplate.render({ - folder: folder, - alert_policy: alertPolicy, - }); - } - - /** - * Parse the folder from FolderAlertPolicy resource. - * - * @param {string} folderAlertPolicyName - * A fully-qualified path representing folder_alert_policy resource. - * @returns {string} A string representing the folder. - */ - matchFolderFromFolderAlertPolicyName(folderAlertPolicyName: string) { - return this._pathTemplates.folderAlertPolicyPathTemplate.match(folderAlertPolicyName).folder; - } - - /** - * Parse the alert_policy from FolderAlertPolicy resource. - * - * @param {string} folderAlertPolicyName - * A fully-qualified path representing folder_alert_policy resource. - * @returns {string} A string representing the alert_policy. - */ - matchAlertPolicyFromFolderAlertPolicyName(folderAlertPolicyName: string) { - return this._pathTemplates.folderAlertPolicyPathTemplate.match(folderAlertPolicyName).alert_policy; - } - - /** - * Return a fully-qualified resource name string. - * - * @returns {string} Resource name string. - */ - Path() { - return this._pathTemplates.PathTemplate.render({ - }); - } - - /** - * Return a fully-qualified projectGroup resource name string. - * - * @param {string} project - * @param {string} group - * @returns {string} Resource name string. - */ - projectGroupPath(project:string,group:string) { - return this._pathTemplates.projectGroupPathTemplate.render({ - project: project, - group: group, - }); - } - - /** - * Parse the project from ProjectGroup resource. - * - * @param {string} projectGroupName - * A fully-qualified path representing project_group resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProjectGroupName(projectGroupName: string) { - return this._pathTemplates.projectGroupPathTemplate.match(projectGroupName).project; - } - - /** - * Parse the group from ProjectGroup resource. - * - * @param {string} projectGroupName - * A fully-qualified path representing project_group resource. - * @returns {string} A string representing the group. - */ - matchGroupFromProjectGroupName(projectGroupName: string) { - return this._pathTemplates.projectGroupPathTemplate.match(projectGroupName).group; - } - - /** - * Return a fully-qualified organizationGroup resource name string. - * - * @param {string} organization - * @param {string} group - * @returns {string} Resource name string. - */ - organizationGroupPath(organization:string,group:string) { - return this._pathTemplates.organizationGroupPathTemplate.render({ - organization: organization, - group: group, - }); - } - - /** - * Parse the organization from OrganizationGroup resource. - * - * @param {string} organizationGroupName - * A fully-qualified path representing organization_group resource. - * @returns {string} A string representing the organization. - */ - matchOrganizationFromOrganizationGroupName(organizationGroupName: string) { - return this._pathTemplates.organizationGroupPathTemplate.match(organizationGroupName).organization; - } - - /** - * Parse the group from OrganizationGroup resource. - * - * @param {string} organizationGroupName - * A fully-qualified path representing organization_group resource. - * @returns {string} A string representing the group. - */ - matchGroupFromOrganizationGroupName(organizationGroupName: string) { - return this._pathTemplates.organizationGroupPathTemplate.match(organizationGroupName).group; - } - - /** - * Return a fully-qualified folderGroup resource name string. - * - * @param {string} folder - * @param {string} group - * @returns {string} Resource name string. - */ - folderGroupPath(folder:string,group:string) { - return this._pathTemplates.folderGroupPathTemplate.render({ - folder: folder, - group: group, - }); - } - - /** - * Parse the folder from FolderGroup resource. - * - * @param {string} folderGroupName - * A fully-qualified path representing folder_group resource. - * @returns {string} A string representing the folder. - */ - matchFolderFromFolderGroupName(folderGroupName: string) { - return this._pathTemplates.folderGroupPathTemplate.match(folderGroupName).folder; - } - - /** - * Parse the group from FolderGroup resource. - * - * @param {string} folderGroupName - * A fully-qualified path representing folder_group resource. - * @returns {string} A string representing the group. - */ - matchGroupFromFolderGroupName(folderGroupName: string) { - return this._pathTemplates.folderGroupPathTemplate.match(folderGroupName).group; - } - - /** - * Return a fully-qualified projectChannelDescriptor resource name string. - * - * @param {string} project - * @param {string} channel_descriptor - * @returns {string} Resource name string. - */ - projectChannelDescriptorPath(project:string,channelDescriptor:string) { - return this._pathTemplates.projectChannelDescriptorPathTemplate.render({ - project: project, - channel_descriptor: channelDescriptor, - }); - } - - /** - * Parse the project from ProjectChannelDescriptor resource. - * - * @param {string} projectChannelDescriptorName - * A fully-qualified path representing project_channel_descriptor resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProjectChannelDescriptorName(projectChannelDescriptorName: string) { - return this._pathTemplates.projectChannelDescriptorPathTemplate.match(projectChannelDescriptorName).project; - } - - /** - * Parse the channel_descriptor from ProjectChannelDescriptor resource. - * - * @param {string} projectChannelDescriptorName - * A fully-qualified path representing project_channel_descriptor resource. - * @returns {string} A string representing the channel_descriptor. - */ - matchChannelDescriptorFromProjectChannelDescriptorName(projectChannelDescriptorName: string) { - return this._pathTemplates.projectChannelDescriptorPathTemplate.match(projectChannelDescriptorName).channel_descriptor; - } - - /** - * Return a fully-qualified organizationChannelDescriptor resource name string. - * - * @param {string} organization - * @param {string} channel_descriptor - * @returns {string} Resource name string. - */ - organizationChannelDescriptorPath(organization:string,channelDescriptor:string) { - return this._pathTemplates.organizationChannelDescriptorPathTemplate.render({ - organization: organization, - channel_descriptor: channelDescriptor, - }); - } - - /** - * Parse the organization from OrganizationChannelDescriptor resource. - * - * @param {string} organizationChannelDescriptorName - * A fully-qualified path representing organization_channel_descriptor resource. - * @returns {string} A string representing the organization. - */ - matchOrganizationFromOrganizationChannelDescriptorName(organizationChannelDescriptorName: string) { - return this._pathTemplates.organizationChannelDescriptorPathTemplate.match(organizationChannelDescriptorName).organization; - } - - /** - * Parse the channel_descriptor from OrganizationChannelDescriptor resource. - * - * @param {string} organizationChannelDescriptorName - * A fully-qualified path representing organization_channel_descriptor resource. - * @returns {string} A string representing the channel_descriptor. - */ - matchChannelDescriptorFromOrganizationChannelDescriptorName(organizationChannelDescriptorName: string) { - return this._pathTemplates.organizationChannelDescriptorPathTemplate.match(organizationChannelDescriptorName).channel_descriptor; - } - - /** - * Return a fully-qualified folderChannelDescriptor resource name string. - * - * @param {string} folder - * @param {string} channel_descriptor - * @returns {string} Resource name string. - */ - folderChannelDescriptorPath(folder:string,channelDescriptor:string) { - return this._pathTemplates.folderChannelDescriptorPathTemplate.render({ - folder: folder, - channel_descriptor: channelDescriptor, - }); - } - - /** - * Parse the folder from FolderChannelDescriptor resource. - * - * @param {string} folderChannelDescriptorName - * A fully-qualified path representing folder_channel_descriptor resource. - * @returns {string} A string representing the folder. - */ - matchFolderFromFolderChannelDescriptorName(folderChannelDescriptorName: string) { - return this._pathTemplates.folderChannelDescriptorPathTemplate.match(folderChannelDescriptorName).folder; - } - - /** - * Parse the channel_descriptor from FolderChannelDescriptor resource. - * - * @param {string} folderChannelDescriptorName - * A fully-qualified path representing folder_channel_descriptor resource. - * @returns {string} A string representing the channel_descriptor. - */ - matchChannelDescriptorFromFolderChannelDescriptorName(folderChannelDescriptorName: string) { - return this._pathTemplates.folderChannelDescriptorPathTemplate.match(folderChannelDescriptorName).channel_descriptor; - } - - /** - * Return a fully-qualified projectNotificationChannel resource name string. - * - * @param {string} project - * @param {string} notification_channel - * @returns {string} Resource name string. - */ - projectNotificationChannelPath(project:string,notificationChannel:string) { - return this._pathTemplates.projectNotificationChannelPathTemplate.render({ - project: project, - notification_channel: notificationChannel, - }); - } - - /** - * Parse the project from ProjectNotificationChannel resource. - * - * @param {string} projectNotificationChannelName - * A fully-qualified path representing project_notification_channel resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProjectNotificationChannelName(projectNotificationChannelName: string) { - return this._pathTemplates.projectNotificationChannelPathTemplate.match(projectNotificationChannelName).project; - } - - /** - * Parse the notification_channel from ProjectNotificationChannel resource. - * - * @param {string} projectNotificationChannelName - * A fully-qualified path representing project_notification_channel resource. - * @returns {string} A string representing the notification_channel. - */ - matchNotificationChannelFromProjectNotificationChannelName(projectNotificationChannelName: string) { - return this._pathTemplates.projectNotificationChannelPathTemplate.match(projectNotificationChannelName).notification_channel; - } - - /** - * Return a fully-qualified organizationNotificationChannel resource name string. - * - * @param {string} organization - * @param {string} notification_channel - * @returns {string} Resource name string. - */ - organizationNotificationChannelPath(organization:string,notificationChannel:string) { - return this._pathTemplates.organizationNotificationChannelPathTemplate.render({ - organization: organization, - notification_channel: notificationChannel, - }); - } - - /** - * Parse the organization from OrganizationNotificationChannel resource. - * - * @param {string} organizationNotificationChannelName - * A fully-qualified path representing organization_notification_channel resource. - * @returns {string} A string representing the organization. - */ - matchOrganizationFromOrganizationNotificationChannelName(organizationNotificationChannelName: string) { - return this._pathTemplates.organizationNotificationChannelPathTemplate.match(organizationNotificationChannelName).organization; - } - - /** - * Parse the notification_channel from OrganizationNotificationChannel resource. - * - * @param {string} organizationNotificationChannelName - * A fully-qualified path representing organization_notification_channel resource. - * @returns {string} A string representing the notification_channel. - */ - matchNotificationChannelFromOrganizationNotificationChannelName(organizationNotificationChannelName: string) { - return this._pathTemplates.organizationNotificationChannelPathTemplate.match(organizationNotificationChannelName).notification_channel; - } - - /** - * Return a fully-qualified folderNotificationChannel resource name string. - * - * @param {string} folder - * @param {string} notification_channel - * @returns {string} Resource name string. - */ - folderNotificationChannelPath(folder:string,notificationChannel:string) { - return this._pathTemplates.folderNotificationChannelPathTemplate.render({ - folder: folder, - notification_channel: notificationChannel, - }); - } - - /** - * Parse the folder from FolderNotificationChannel resource. - * - * @param {string} folderNotificationChannelName - * A fully-qualified path representing folder_notification_channel resource. - * @returns {string} A string representing the folder. - */ - matchFolderFromFolderNotificationChannelName(folderNotificationChannelName: string) { - return this._pathTemplates.folderNotificationChannelPathTemplate.match(folderNotificationChannelName).folder; - } - - /** - * Parse the notification_channel from FolderNotificationChannel resource. - * - * @param {string} folderNotificationChannelName - * A fully-qualified path representing folder_notification_channel resource. - * @returns {string} A string representing the notification_channel. - */ - matchNotificationChannelFromFolderNotificationChannelName(folderNotificationChannelName: string) { - return this._pathTemplates.folderNotificationChannelPathTemplate.match(folderNotificationChannelName).notification_channel; - } - - /** - * Return a fully-qualified projectService resource name string. - * - * @param {string} project - * @param {string} service - * @returns {string} Resource name string. - */ - projectServicePath(project:string,service:string) { - return this._pathTemplates.projectServicePathTemplate.render({ - project: project, - service: service, - }); - } - - /** - * Parse the project from ProjectService resource. - * - * @param {string} projectServiceName - * A fully-qualified path representing project_service resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProjectServiceName(projectServiceName: string) { - return this._pathTemplates.projectServicePathTemplate.match(projectServiceName).project; - } - - /** - * Parse the service from ProjectService resource. - * - * @param {string} projectServiceName - * A fully-qualified path representing project_service resource. - * @returns {string} A string representing the service. - */ - matchServiceFromProjectServiceName(projectServiceName: string) { - return this._pathTemplates.projectServicePathTemplate.match(projectServiceName).service; - } - - /** - * Return a fully-qualified organizationService resource name string. - * - * @param {string} organization - * @param {string} service - * @returns {string} Resource name string. - */ - organizationServicePath(organization:string,service:string) { - return this._pathTemplates.organizationServicePathTemplate.render({ - organization: organization, - service: service, - }); - } - - /** - * Parse the organization from OrganizationService resource. - * - * @param {string} organizationServiceName - * A fully-qualified path representing organization_service resource. - * @returns {string} A string representing the organization. - */ - matchOrganizationFromOrganizationServiceName(organizationServiceName: string) { - return this._pathTemplates.organizationServicePathTemplate.match(organizationServiceName).organization; - } - - /** - * Parse the service from OrganizationService resource. - * - * @param {string} organizationServiceName - * A fully-qualified path representing organization_service resource. - * @returns {string} A string representing the service. - */ - matchServiceFromOrganizationServiceName(organizationServiceName: string) { - return this._pathTemplates.organizationServicePathTemplate.match(organizationServiceName).service; - } - - /** - * Return a fully-qualified folderService resource name string. - * - * @param {string} folder - * @param {string} service - * @returns {string} Resource name string. - */ - folderServicePath(folder:string,service:string) { - return this._pathTemplates.folderServicePathTemplate.render({ - folder: folder, - service: service, - }); - } - - /** - * Parse the folder from FolderService resource. - * - * @param {string} folderServiceName - * A fully-qualified path representing folder_service resource. - * @returns {string} A string representing the folder. - */ - matchFolderFromFolderServiceName(folderServiceName: string) { - return this._pathTemplates.folderServicePathTemplate.match(folderServiceName).folder; - } - - /** - * Parse the service from FolderService resource. - * - * @param {string} folderServiceName - * A fully-qualified path representing folder_service resource. - * @returns {string} A string representing the service. - */ - matchServiceFromFolderServiceName(folderServiceName: string) { - return this._pathTemplates.folderServicePathTemplate.match(folderServiceName).service; - } - - /** - * Return a fully-qualified projectServiceServiceLevelObjective resource name string. - * - * @param {string} project - * @param {string} service - * @param {string} service_level_objective - * @returns {string} Resource name string. - */ - projectServiceServiceLevelObjectivePath(project:string,service:string,serviceLevelObjective:string) { - return this._pathTemplates.projectServiceServiceLevelObjectivePathTemplate.render({ - project: project, - service: service, - service_level_objective: serviceLevelObjective, - }); - } - - /** - * Parse the project from ProjectServiceServiceLevelObjective resource. - * - * @param {string} projectServiceServiceLevelObjectiveName - * A fully-qualified path representing project_service_service_level_objective resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProjectServiceServiceLevelObjectiveName(projectServiceServiceLevelObjectiveName: string) { - return this._pathTemplates.projectServiceServiceLevelObjectivePathTemplate.match(projectServiceServiceLevelObjectiveName).project; - } - - /** - * Parse the service from ProjectServiceServiceLevelObjective resource. - * - * @param {string} projectServiceServiceLevelObjectiveName - * A fully-qualified path representing project_service_service_level_objective resource. - * @returns {string} A string representing the service. - */ - matchServiceFromProjectServiceServiceLevelObjectiveName(projectServiceServiceLevelObjectiveName: string) { - return this._pathTemplates.projectServiceServiceLevelObjectivePathTemplate.match(projectServiceServiceLevelObjectiveName).service; - } - - /** - * Parse the service_level_objective from ProjectServiceServiceLevelObjective resource. - * - * @param {string} projectServiceServiceLevelObjectiveName - * A fully-qualified path representing project_service_service_level_objective resource. - * @returns {string} A string representing the service_level_objective. - */ - matchServiceLevelObjectiveFromProjectServiceServiceLevelObjectiveName(projectServiceServiceLevelObjectiveName: string) { - return this._pathTemplates.projectServiceServiceLevelObjectivePathTemplate.match(projectServiceServiceLevelObjectiveName).service_level_objective; - } - - /** - * Return a fully-qualified organizationServiceServiceLevelObjective resource name string. - * - * @param {string} organization - * @param {string} service - * @param {string} service_level_objective - * @returns {string} Resource name string. - */ - organizationServiceServiceLevelObjectivePath(organization:string,service:string,serviceLevelObjective:string) { - return this._pathTemplates.organizationServiceServiceLevelObjectivePathTemplate.render({ - organization: organization, - service: service, - service_level_objective: serviceLevelObjective, - }); - } - - /** - * Parse the organization from OrganizationServiceServiceLevelObjective resource. - * - * @param {string} organizationServiceServiceLevelObjectiveName - * A fully-qualified path representing organization_service_service_level_objective resource. - * @returns {string} A string representing the organization. - */ - matchOrganizationFromOrganizationServiceServiceLevelObjectiveName(organizationServiceServiceLevelObjectiveName: string) { - return this._pathTemplates.organizationServiceServiceLevelObjectivePathTemplate.match(organizationServiceServiceLevelObjectiveName).organization; - } - - /** - * Parse the service from OrganizationServiceServiceLevelObjective resource. - * - * @param {string} organizationServiceServiceLevelObjectiveName - * A fully-qualified path representing organization_service_service_level_objective resource. - * @returns {string} A string representing the service. - */ - matchServiceFromOrganizationServiceServiceLevelObjectiveName(organizationServiceServiceLevelObjectiveName: string) { - return this._pathTemplates.organizationServiceServiceLevelObjectivePathTemplate.match(organizationServiceServiceLevelObjectiveName).service; - } - - /** - * Parse the service_level_objective from OrganizationServiceServiceLevelObjective resource. - * - * @param {string} organizationServiceServiceLevelObjectiveName - * A fully-qualified path representing organization_service_service_level_objective resource. - * @returns {string} A string representing the service_level_objective. - */ - matchServiceLevelObjectiveFromOrganizationServiceServiceLevelObjectiveName(organizationServiceServiceLevelObjectiveName: string) { - return this._pathTemplates.organizationServiceServiceLevelObjectivePathTemplate.match(organizationServiceServiceLevelObjectiveName).service_level_objective; - } - - /** - * Return a fully-qualified folderServiceServiceLevelObjective resource name string. - * - * @param {string} folder - * @param {string} service - * @param {string} service_level_objective - * @returns {string} Resource name string. - */ - folderServiceServiceLevelObjectivePath(folder:string,service:string,serviceLevelObjective:string) { - return this._pathTemplates.folderServiceServiceLevelObjectivePathTemplate.render({ - folder: folder, - service: service, - service_level_objective: serviceLevelObjective, - }); - } - - /** - * Parse the folder from FolderServiceServiceLevelObjective resource. - * - * @param {string} folderServiceServiceLevelObjectiveName - * A fully-qualified path representing folder_service_service_level_objective resource. - * @returns {string} A string representing the folder. - */ - matchFolderFromFolderServiceServiceLevelObjectiveName(folderServiceServiceLevelObjectiveName: string) { - return this._pathTemplates.folderServiceServiceLevelObjectivePathTemplate.match(folderServiceServiceLevelObjectiveName).folder; - } - - /** - * Parse the service from FolderServiceServiceLevelObjective resource. - * - * @param {string} folderServiceServiceLevelObjectiveName - * A fully-qualified path representing folder_service_service_level_objective resource. - * @returns {string} A string representing the service. - */ - matchServiceFromFolderServiceServiceLevelObjectiveName(folderServiceServiceLevelObjectiveName: string) { - return this._pathTemplates.folderServiceServiceLevelObjectivePathTemplate.match(folderServiceServiceLevelObjectiveName).service; - } - - /** - * Parse the service_level_objective from FolderServiceServiceLevelObjective resource. - * - * @param {string} folderServiceServiceLevelObjectiveName - * A fully-qualified path representing folder_service_service_level_objective resource. - * @returns {string} A string representing the service_level_objective. - */ - matchServiceLevelObjectiveFromFolderServiceServiceLevelObjectiveName(folderServiceServiceLevelObjectiveName: string) { - return this._pathTemplates.folderServiceServiceLevelObjectivePathTemplate.match(folderServiceServiceLevelObjectiveName).service_level_objective; - } - - /** - * Return a fully-qualified projectUptimeCheckConfig resource name string. - * - * @param {string} project - * @param {string} uptime_check_config - * @returns {string} Resource name string. - */ - projectUptimeCheckConfigPath(project:string,uptimeCheckConfig:string) { - return this._pathTemplates.projectUptimeCheckConfigPathTemplate.render({ - project: project, - uptime_check_config: uptimeCheckConfig, - }); - } - - /** - * Parse the project from ProjectUptimeCheckConfig resource. - * - * @param {string} projectUptimeCheckConfigName - * A fully-qualified path representing project_uptime_check_config resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProjectUptimeCheckConfigName(projectUptimeCheckConfigName: string) { - return this._pathTemplates.projectUptimeCheckConfigPathTemplate.match(projectUptimeCheckConfigName).project; - } - - /** - * Parse the uptime_check_config from ProjectUptimeCheckConfig resource. - * - * @param {string} projectUptimeCheckConfigName - * A fully-qualified path representing project_uptime_check_config resource. - * @returns {string} A string representing the uptime_check_config. - */ - matchUptimeCheckConfigFromProjectUptimeCheckConfigName(projectUptimeCheckConfigName: string) { - return this._pathTemplates.projectUptimeCheckConfigPathTemplate.match(projectUptimeCheckConfigName).uptime_check_config; - } - - /** - * Return a fully-qualified organizationUptimeCheckConfig resource name string. - * - * @param {string} organization - * @param {string} uptime_check_config - * @returns {string} Resource name string. - */ - organizationUptimeCheckConfigPath(organization:string,uptimeCheckConfig:string) { - return this._pathTemplates.organizationUptimeCheckConfigPathTemplate.render({ - organization: organization, - uptime_check_config: uptimeCheckConfig, - }); - } - - /** - * Parse the organization from OrganizationUptimeCheckConfig resource. - * - * @param {string} organizationUptimeCheckConfigName - * A fully-qualified path representing organization_uptime_check_config resource. - * @returns {string} A string representing the organization. - */ - matchOrganizationFromOrganizationUptimeCheckConfigName(organizationUptimeCheckConfigName: string) { - return this._pathTemplates.organizationUptimeCheckConfigPathTemplate.match(organizationUptimeCheckConfigName).organization; - } - - /** - * Parse the uptime_check_config from OrganizationUptimeCheckConfig resource. - * - * @param {string} organizationUptimeCheckConfigName - * A fully-qualified path representing organization_uptime_check_config resource. - * @returns {string} A string representing the uptime_check_config. - */ - matchUptimeCheckConfigFromOrganizationUptimeCheckConfigName(organizationUptimeCheckConfigName: string) { - return this._pathTemplates.organizationUptimeCheckConfigPathTemplate.match(organizationUptimeCheckConfigName).uptime_check_config; - } - - /** - * Return a fully-qualified folderUptimeCheckConfig resource name string. - * - * @param {string} folder - * @param {string} uptime_check_config - * @returns {string} Resource name string. - */ - folderUptimeCheckConfigPath(folder:string,uptimeCheckConfig:string) { - return this._pathTemplates.folderUptimeCheckConfigPathTemplate.render({ - folder: folder, - uptime_check_config: uptimeCheckConfig, - }); - } - - /** - * Parse the folder from FolderUptimeCheckConfig resource. - * - * @param {string} folderUptimeCheckConfigName - * A fully-qualified path representing folder_uptime_check_config resource. - * @returns {string} A string representing the folder. - */ - matchFolderFromFolderUptimeCheckConfigName(folderUptimeCheckConfigName: string) { - return this._pathTemplates.folderUptimeCheckConfigPathTemplate.match(folderUptimeCheckConfigName).folder; - } - - /** - * Parse the uptime_check_config from FolderUptimeCheckConfig resource. - * - * @param {string} folderUptimeCheckConfigName - * A fully-qualified path representing folder_uptime_check_config resource. - * @returns {string} A string representing the uptime_check_config. - */ - matchUptimeCheckConfigFromFolderUptimeCheckConfigName(folderUptimeCheckConfigName: string) { - return this._pathTemplates.folderUptimeCheckConfigPathTemplate.match(folderUptimeCheckConfigName).uptime_check_config; - } - - /** - * Terminate the GRPC channel and close the client. - * - * The client will no longer be usable and all future behavior is undefined. - */ - close(): Promise { - if (!this._terminated) { - return this.notificationChannelServiceStub.then(stub => { - this._terminated = true; - stub.close(); - }); - } - return Promise.resolve(); - } -} diff --git a/typescript/test/testdata/monitoring/src/v3/notification_channel_service_client_config.json.baseline b/typescript/test/testdata/monitoring/src/v3/notification_channel_service_client_config.json.baseline deleted file mode 100644 index 781b3f0a6..000000000 --- a/typescript/test/testdata/monitoring/src/v3/notification_channel_service_client_config.json.baseline +++ /dev/null @@ -1,66 +0,0 @@ -{ - "interfaces": { - "google.monitoring.v3.NotificationChannelService": { - "retry_codes": { - "non_idempotent": [], - "idempotent": [ - "DEADLINE_EXCEEDED", - "UNAVAILABLE" - ] - }, - "retry_params": { - "default": { - "initial_retry_delay_millis": 100, - "retry_delay_multiplier": 1.3, - "max_retry_delay_millis": 60000, - "initial_rpc_timeout_millis": 60000, - "rpc_timeout_multiplier": 1, - "max_rpc_timeout_millis": 60000, - "total_timeout_millis": 600000 - } - }, - "methods": { - "ListNotificationChannelDescriptors": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "GetNotificationChannelDescriptor": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "ListNotificationChannels": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "GetNotificationChannel": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "CreateNotificationChannel": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "UpdateNotificationChannel": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "DeleteNotificationChannel": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "SendNotificationChannelVerificationCode": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "GetNotificationChannelVerificationCode": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "VerifyNotificationChannel": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - } - } - } - } -} diff --git a/typescript/test/testdata/monitoring/src/v3/notification_channel_service_proto_list.json.baseline b/typescript/test/testdata/monitoring/src/v3/notification_channel_service_proto_list.json.baseline deleted file mode 100644 index aacceb22f..000000000 --- a/typescript/test/testdata/monitoring/src/v3/notification_channel_service_proto_list.json.baseline +++ /dev/null @@ -1,16 +0,0 @@ -[ - "../../protos/google/monitoring/v3/alert.proto", - "../../protos/google/monitoring/v3/alert_service.proto", - "../../protos/google/monitoring/v3/common.proto", - "../../protos/google/monitoring/v3/group.proto", - "../../protos/google/monitoring/v3/group_service.proto", - "../../protos/google/monitoring/v3/metric.proto", - "../../protos/google/monitoring/v3/metric_service.proto", - "../../protos/google/monitoring/v3/mutation_record.proto", - "../../protos/google/monitoring/v3/notification.proto", - "../../protos/google/monitoring/v3/notification_service.proto", - "../../protos/google/monitoring/v3/service.proto", - "../../protos/google/monitoring/v3/service_service.proto", - "../../protos/google/monitoring/v3/uptime.proto", - "../../protos/google/monitoring/v3/uptime_service.proto" -] diff --git a/typescript/test/testdata/monitoring/src/v3/service_monitoring_service_client.ts.baseline b/typescript/test/testdata/monitoring/src/v3/service_monitoring_service_client.ts.baseline index 7d3e91679..2cb638e2d 100644 --- a/typescript/test/testdata/monitoring/src/v3/service_monitoring_service_client.ts.baseline +++ b/typescript/test/testdata/monitoring/src/v3/service_monitoring_service_client.ts.baseline @@ -134,45 +134,6 @@ export class ServiceMonitoringServiceClient { // identifiers to uniquely identify resources within the API. // Create useful helper objects for these. this._pathTemplates = { - projectAlertPolicyPathTemplate: new gaxModule.PathTemplate( - 'projects/{project}/alertPolicies/{alert_policy}' - ), - organizationAlertPolicyPathTemplate: new gaxModule.PathTemplate( - 'organizations/{organization}/alertPolicies/{alert_policy}' - ), - folderAlertPolicyPathTemplate: new gaxModule.PathTemplate( - 'folders/{folder}/alertPolicies/{alert_policy}' - ), - PathTemplate: new gaxModule.PathTemplate( - '*' - ), - projectGroupPathTemplate: new gaxModule.PathTemplate( - 'projects/{project}/groups/{group}' - ), - organizationGroupPathTemplate: new gaxModule.PathTemplate( - 'organizations/{organization}/groups/{group}' - ), - folderGroupPathTemplate: new gaxModule.PathTemplate( - 'folders/{folder}/groups/{group}' - ), - projectChannelDescriptorPathTemplate: new gaxModule.PathTemplate( - 'projects/{project}/notificationChannelDescriptors/{channel_descriptor}' - ), - organizationChannelDescriptorPathTemplate: new gaxModule.PathTemplate( - 'organizations/{organization}/notificationChannelDescriptors/{channel_descriptor}' - ), - folderChannelDescriptorPathTemplate: new gaxModule.PathTemplate( - 'folders/{folder}/notificationChannelDescriptors/{channel_descriptor}' - ), - projectNotificationChannelPathTemplate: new gaxModule.PathTemplate( - 'projects/{project}/notificationChannels/{notification_channel}' - ), - organizationNotificationChannelPathTemplate: new gaxModule.PathTemplate( - 'organizations/{organization}/notificationChannels/{notification_channel}' - ), - folderNotificationChannelPathTemplate: new gaxModule.PathTemplate( - 'folders/{folder}/notificationChannels/{notification_channel}' - ), projectServicePathTemplate: new gaxModule.PathTemplate( 'projects/{project}/services/{service}' ), @@ -182,6 +143,9 @@ export class ServiceMonitoringServiceClient { folderServicePathTemplate: new gaxModule.PathTemplate( 'folders/{folder}/services/{service}' ), + PathTemplate: new gaxModule.PathTemplate( + '*' + ), projectServiceServiceLevelObjectivePathTemplate: new gaxModule.PathTemplate( 'projects/{project}/services/{service}/serviceLevelObjectives/{service_level_objective}' ), @@ -1124,448 +1088,6 @@ export class ServiceMonitoringServiceClient { // -- Path templates -- // -------------------- - /** - * Return a fully-qualified projectAlertPolicy resource name string. - * - * @param {string} project - * @param {string} alert_policy - * @returns {string} Resource name string. - */ - projectAlertPolicyPath(project:string,alertPolicy:string) { - return this._pathTemplates.projectAlertPolicyPathTemplate.render({ - project: project, - alert_policy: alertPolicy, - }); - } - - /** - * Parse the project from ProjectAlertPolicy resource. - * - * @param {string} projectAlertPolicyName - * A fully-qualified path representing project_alert_policy resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProjectAlertPolicyName(projectAlertPolicyName: string) { - return this._pathTemplates.projectAlertPolicyPathTemplate.match(projectAlertPolicyName).project; - } - - /** - * Parse the alert_policy from ProjectAlertPolicy resource. - * - * @param {string} projectAlertPolicyName - * A fully-qualified path representing project_alert_policy resource. - * @returns {string} A string representing the alert_policy. - */ - matchAlertPolicyFromProjectAlertPolicyName(projectAlertPolicyName: string) { - return this._pathTemplates.projectAlertPolicyPathTemplate.match(projectAlertPolicyName).alert_policy; - } - - /** - * Return a fully-qualified organizationAlertPolicy resource name string. - * - * @param {string} organization - * @param {string} alert_policy - * @returns {string} Resource name string. - */ - organizationAlertPolicyPath(organization:string,alertPolicy:string) { - return this._pathTemplates.organizationAlertPolicyPathTemplate.render({ - organization: organization, - alert_policy: alertPolicy, - }); - } - - /** - * Parse the organization from OrganizationAlertPolicy resource. - * - * @param {string} organizationAlertPolicyName - * A fully-qualified path representing organization_alert_policy resource. - * @returns {string} A string representing the organization. - */ - matchOrganizationFromOrganizationAlertPolicyName(organizationAlertPolicyName: string) { - return this._pathTemplates.organizationAlertPolicyPathTemplate.match(organizationAlertPolicyName).organization; - } - - /** - * Parse the alert_policy from OrganizationAlertPolicy resource. - * - * @param {string} organizationAlertPolicyName - * A fully-qualified path representing organization_alert_policy resource. - * @returns {string} A string representing the alert_policy. - */ - matchAlertPolicyFromOrganizationAlertPolicyName(organizationAlertPolicyName: string) { - return this._pathTemplates.organizationAlertPolicyPathTemplate.match(organizationAlertPolicyName).alert_policy; - } - - /** - * Return a fully-qualified folderAlertPolicy resource name string. - * - * @param {string} folder - * @param {string} alert_policy - * @returns {string} Resource name string. - */ - folderAlertPolicyPath(folder:string,alertPolicy:string) { - return this._pathTemplates.folderAlertPolicyPathTemplate.render({ - folder: folder, - alert_policy: alertPolicy, - }); - } - - /** - * Parse the folder from FolderAlertPolicy resource. - * - * @param {string} folderAlertPolicyName - * A fully-qualified path representing folder_alert_policy resource. - * @returns {string} A string representing the folder. - */ - matchFolderFromFolderAlertPolicyName(folderAlertPolicyName: string) { - return this._pathTemplates.folderAlertPolicyPathTemplate.match(folderAlertPolicyName).folder; - } - - /** - * Parse the alert_policy from FolderAlertPolicy resource. - * - * @param {string} folderAlertPolicyName - * A fully-qualified path representing folder_alert_policy resource. - * @returns {string} A string representing the alert_policy. - */ - matchAlertPolicyFromFolderAlertPolicyName(folderAlertPolicyName: string) { - return this._pathTemplates.folderAlertPolicyPathTemplate.match(folderAlertPolicyName).alert_policy; - } - - /** - * Return a fully-qualified resource name string. - * - * @returns {string} Resource name string. - */ - Path() { - return this._pathTemplates.PathTemplate.render({ - }); - } - - /** - * Return a fully-qualified projectGroup resource name string. - * - * @param {string} project - * @param {string} group - * @returns {string} Resource name string. - */ - projectGroupPath(project:string,group:string) { - return this._pathTemplates.projectGroupPathTemplate.render({ - project: project, - group: group, - }); - } - - /** - * Parse the project from ProjectGroup resource. - * - * @param {string} projectGroupName - * A fully-qualified path representing project_group resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProjectGroupName(projectGroupName: string) { - return this._pathTemplates.projectGroupPathTemplate.match(projectGroupName).project; - } - - /** - * Parse the group from ProjectGroup resource. - * - * @param {string} projectGroupName - * A fully-qualified path representing project_group resource. - * @returns {string} A string representing the group. - */ - matchGroupFromProjectGroupName(projectGroupName: string) { - return this._pathTemplates.projectGroupPathTemplate.match(projectGroupName).group; - } - - /** - * Return a fully-qualified organizationGroup resource name string. - * - * @param {string} organization - * @param {string} group - * @returns {string} Resource name string. - */ - organizationGroupPath(organization:string,group:string) { - return this._pathTemplates.organizationGroupPathTemplate.render({ - organization: organization, - group: group, - }); - } - - /** - * Parse the organization from OrganizationGroup resource. - * - * @param {string} organizationGroupName - * A fully-qualified path representing organization_group resource. - * @returns {string} A string representing the organization. - */ - matchOrganizationFromOrganizationGroupName(organizationGroupName: string) { - return this._pathTemplates.organizationGroupPathTemplate.match(organizationGroupName).organization; - } - - /** - * Parse the group from OrganizationGroup resource. - * - * @param {string} organizationGroupName - * A fully-qualified path representing organization_group resource. - * @returns {string} A string representing the group. - */ - matchGroupFromOrganizationGroupName(organizationGroupName: string) { - return this._pathTemplates.organizationGroupPathTemplate.match(organizationGroupName).group; - } - - /** - * Return a fully-qualified folderGroup resource name string. - * - * @param {string} folder - * @param {string} group - * @returns {string} Resource name string. - */ - folderGroupPath(folder:string,group:string) { - return this._pathTemplates.folderGroupPathTemplate.render({ - folder: folder, - group: group, - }); - } - - /** - * Parse the folder from FolderGroup resource. - * - * @param {string} folderGroupName - * A fully-qualified path representing folder_group resource. - * @returns {string} A string representing the folder. - */ - matchFolderFromFolderGroupName(folderGroupName: string) { - return this._pathTemplates.folderGroupPathTemplate.match(folderGroupName).folder; - } - - /** - * Parse the group from FolderGroup resource. - * - * @param {string} folderGroupName - * A fully-qualified path representing folder_group resource. - * @returns {string} A string representing the group. - */ - matchGroupFromFolderGroupName(folderGroupName: string) { - return this._pathTemplates.folderGroupPathTemplate.match(folderGroupName).group; - } - - /** - * Return a fully-qualified projectChannelDescriptor resource name string. - * - * @param {string} project - * @param {string} channel_descriptor - * @returns {string} Resource name string. - */ - projectChannelDescriptorPath(project:string,channelDescriptor:string) { - return this._pathTemplates.projectChannelDescriptorPathTemplate.render({ - project: project, - channel_descriptor: channelDescriptor, - }); - } - - /** - * Parse the project from ProjectChannelDescriptor resource. - * - * @param {string} projectChannelDescriptorName - * A fully-qualified path representing project_channel_descriptor resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProjectChannelDescriptorName(projectChannelDescriptorName: string) { - return this._pathTemplates.projectChannelDescriptorPathTemplate.match(projectChannelDescriptorName).project; - } - - /** - * Parse the channel_descriptor from ProjectChannelDescriptor resource. - * - * @param {string} projectChannelDescriptorName - * A fully-qualified path representing project_channel_descriptor resource. - * @returns {string} A string representing the channel_descriptor. - */ - matchChannelDescriptorFromProjectChannelDescriptorName(projectChannelDescriptorName: string) { - return this._pathTemplates.projectChannelDescriptorPathTemplate.match(projectChannelDescriptorName).channel_descriptor; - } - - /** - * Return a fully-qualified organizationChannelDescriptor resource name string. - * - * @param {string} organization - * @param {string} channel_descriptor - * @returns {string} Resource name string. - */ - organizationChannelDescriptorPath(organization:string,channelDescriptor:string) { - return this._pathTemplates.organizationChannelDescriptorPathTemplate.render({ - organization: organization, - channel_descriptor: channelDescriptor, - }); - } - - /** - * Parse the organization from OrganizationChannelDescriptor resource. - * - * @param {string} organizationChannelDescriptorName - * A fully-qualified path representing organization_channel_descriptor resource. - * @returns {string} A string representing the organization. - */ - matchOrganizationFromOrganizationChannelDescriptorName(organizationChannelDescriptorName: string) { - return this._pathTemplates.organizationChannelDescriptorPathTemplate.match(organizationChannelDescriptorName).organization; - } - - /** - * Parse the channel_descriptor from OrganizationChannelDescriptor resource. - * - * @param {string} organizationChannelDescriptorName - * A fully-qualified path representing organization_channel_descriptor resource. - * @returns {string} A string representing the channel_descriptor. - */ - matchChannelDescriptorFromOrganizationChannelDescriptorName(organizationChannelDescriptorName: string) { - return this._pathTemplates.organizationChannelDescriptorPathTemplate.match(organizationChannelDescriptorName).channel_descriptor; - } - - /** - * Return a fully-qualified folderChannelDescriptor resource name string. - * - * @param {string} folder - * @param {string} channel_descriptor - * @returns {string} Resource name string. - */ - folderChannelDescriptorPath(folder:string,channelDescriptor:string) { - return this._pathTemplates.folderChannelDescriptorPathTemplate.render({ - folder: folder, - channel_descriptor: channelDescriptor, - }); - } - - /** - * Parse the folder from FolderChannelDescriptor resource. - * - * @param {string} folderChannelDescriptorName - * A fully-qualified path representing folder_channel_descriptor resource. - * @returns {string} A string representing the folder. - */ - matchFolderFromFolderChannelDescriptorName(folderChannelDescriptorName: string) { - return this._pathTemplates.folderChannelDescriptorPathTemplate.match(folderChannelDescriptorName).folder; - } - - /** - * Parse the channel_descriptor from FolderChannelDescriptor resource. - * - * @param {string} folderChannelDescriptorName - * A fully-qualified path representing folder_channel_descriptor resource. - * @returns {string} A string representing the channel_descriptor. - */ - matchChannelDescriptorFromFolderChannelDescriptorName(folderChannelDescriptorName: string) { - return this._pathTemplates.folderChannelDescriptorPathTemplate.match(folderChannelDescriptorName).channel_descriptor; - } - - /** - * Return a fully-qualified projectNotificationChannel resource name string. - * - * @param {string} project - * @param {string} notification_channel - * @returns {string} Resource name string. - */ - projectNotificationChannelPath(project:string,notificationChannel:string) { - return this._pathTemplates.projectNotificationChannelPathTemplate.render({ - project: project, - notification_channel: notificationChannel, - }); - } - - /** - * Parse the project from ProjectNotificationChannel resource. - * - * @param {string} projectNotificationChannelName - * A fully-qualified path representing project_notification_channel resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProjectNotificationChannelName(projectNotificationChannelName: string) { - return this._pathTemplates.projectNotificationChannelPathTemplate.match(projectNotificationChannelName).project; - } - - /** - * Parse the notification_channel from ProjectNotificationChannel resource. - * - * @param {string} projectNotificationChannelName - * A fully-qualified path representing project_notification_channel resource. - * @returns {string} A string representing the notification_channel. - */ - matchNotificationChannelFromProjectNotificationChannelName(projectNotificationChannelName: string) { - return this._pathTemplates.projectNotificationChannelPathTemplate.match(projectNotificationChannelName).notification_channel; - } - - /** - * Return a fully-qualified organizationNotificationChannel resource name string. - * - * @param {string} organization - * @param {string} notification_channel - * @returns {string} Resource name string. - */ - organizationNotificationChannelPath(organization:string,notificationChannel:string) { - return this._pathTemplates.organizationNotificationChannelPathTemplate.render({ - organization: organization, - notification_channel: notificationChannel, - }); - } - - /** - * Parse the organization from OrganizationNotificationChannel resource. - * - * @param {string} organizationNotificationChannelName - * A fully-qualified path representing organization_notification_channel resource. - * @returns {string} A string representing the organization. - */ - matchOrganizationFromOrganizationNotificationChannelName(organizationNotificationChannelName: string) { - return this._pathTemplates.organizationNotificationChannelPathTemplate.match(organizationNotificationChannelName).organization; - } - - /** - * Parse the notification_channel from OrganizationNotificationChannel resource. - * - * @param {string} organizationNotificationChannelName - * A fully-qualified path representing organization_notification_channel resource. - * @returns {string} A string representing the notification_channel. - */ - matchNotificationChannelFromOrganizationNotificationChannelName(organizationNotificationChannelName: string) { - return this._pathTemplates.organizationNotificationChannelPathTemplate.match(organizationNotificationChannelName).notification_channel; - } - - /** - * Return a fully-qualified folderNotificationChannel resource name string. - * - * @param {string} folder - * @param {string} notification_channel - * @returns {string} Resource name string. - */ - folderNotificationChannelPath(folder:string,notificationChannel:string) { - return this._pathTemplates.folderNotificationChannelPathTemplate.render({ - folder: folder, - notification_channel: notificationChannel, - }); - } - - /** - * Parse the folder from FolderNotificationChannel resource. - * - * @param {string} folderNotificationChannelName - * A fully-qualified path representing folder_notification_channel resource. - * @returns {string} A string representing the folder. - */ - matchFolderFromFolderNotificationChannelName(folderNotificationChannelName: string) { - return this._pathTemplates.folderNotificationChannelPathTemplate.match(folderNotificationChannelName).folder; - } - - /** - * Parse the notification_channel from FolderNotificationChannel resource. - * - * @param {string} folderNotificationChannelName - * A fully-qualified path representing folder_notification_channel resource. - * @returns {string} A string representing the notification_channel. - */ - matchNotificationChannelFromFolderNotificationChannelName(folderNotificationChannelName: string) { - return this._pathTemplates.folderNotificationChannelPathTemplate.match(folderNotificationChannelName).notification_channel; - } - /** * Return a fully-qualified projectService resource name string. * @@ -1674,6 +1196,16 @@ export class ServiceMonitoringServiceClient { return this._pathTemplates.folderServicePathTemplate.match(folderServiceName).service; } + /** + * Return a fully-qualified resource name string. + * + * @returns {string} Resource name string. + */ + Path() { + return this._pathTemplates.PathTemplate.render({ + }); + } + /** * Return a fully-qualified projectServiceServiceLevelObjective resource name string. * diff --git a/typescript/test/testdata/monitoring/src/v3/service_monitoring_service_proto_list.json.baseline b/typescript/test/testdata/monitoring/src/v3/service_monitoring_service_proto_list.json.baseline index aacceb22f..6fec2dd59 100644 --- a/typescript/test/testdata/monitoring/src/v3/service_monitoring_service_proto_list.json.baseline +++ b/typescript/test/testdata/monitoring/src/v3/service_monitoring_service_proto_list.json.baseline @@ -1,14 +1,4 @@ [ - "../../protos/google/monitoring/v3/alert.proto", - "../../protos/google/monitoring/v3/alert_service.proto", - "../../protos/google/monitoring/v3/common.proto", - "../../protos/google/monitoring/v3/group.proto", - "../../protos/google/monitoring/v3/group_service.proto", - "../../protos/google/monitoring/v3/metric.proto", - "../../protos/google/monitoring/v3/metric_service.proto", - "../../protos/google/monitoring/v3/mutation_record.proto", - "../../protos/google/monitoring/v3/notification.proto", - "../../protos/google/monitoring/v3/notification_service.proto", "../../protos/google/monitoring/v3/service.proto", "../../protos/google/monitoring/v3/service_service.proto", "../../protos/google/monitoring/v3/uptime.proto", diff --git a/typescript/test/testdata/monitoring/src/v3/uptime_check_service_client.ts.baseline b/typescript/test/testdata/monitoring/src/v3/uptime_check_service_client.ts.baseline index 475ed31ae..69075e7c8 100644 --- a/typescript/test/testdata/monitoring/src/v3/uptime_check_service_client.ts.baseline +++ b/typescript/test/testdata/monitoring/src/v3/uptime_check_service_client.ts.baseline @@ -138,45 +138,6 @@ export class UptimeCheckServiceClient { // identifiers to uniquely identify resources within the API. // Create useful helper objects for these. this._pathTemplates = { - projectAlertPolicyPathTemplate: new gaxModule.PathTemplate( - 'projects/{project}/alertPolicies/{alert_policy}' - ), - organizationAlertPolicyPathTemplate: new gaxModule.PathTemplate( - 'organizations/{organization}/alertPolicies/{alert_policy}' - ), - folderAlertPolicyPathTemplate: new gaxModule.PathTemplate( - 'folders/{folder}/alertPolicies/{alert_policy}' - ), - PathTemplate: new gaxModule.PathTemplate( - '*' - ), - projectGroupPathTemplate: new gaxModule.PathTemplate( - 'projects/{project}/groups/{group}' - ), - organizationGroupPathTemplate: new gaxModule.PathTemplate( - 'organizations/{organization}/groups/{group}' - ), - folderGroupPathTemplate: new gaxModule.PathTemplate( - 'folders/{folder}/groups/{group}' - ), - projectChannelDescriptorPathTemplate: new gaxModule.PathTemplate( - 'projects/{project}/notificationChannelDescriptors/{channel_descriptor}' - ), - organizationChannelDescriptorPathTemplate: new gaxModule.PathTemplate( - 'organizations/{organization}/notificationChannelDescriptors/{channel_descriptor}' - ), - folderChannelDescriptorPathTemplate: new gaxModule.PathTemplate( - 'folders/{folder}/notificationChannelDescriptors/{channel_descriptor}' - ), - projectNotificationChannelPathTemplate: new gaxModule.PathTemplate( - 'projects/{project}/notificationChannels/{notification_channel}' - ), - organizationNotificationChannelPathTemplate: new gaxModule.PathTemplate( - 'organizations/{organization}/notificationChannels/{notification_channel}' - ), - folderNotificationChannelPathTemplate: new gaxModule.PathTemplate( - 'folders/{folder}/notificationChannels/{notification_channel}' - ), projectServicePathTemplate: new gaxModule.PathTemplate( 'projects/{project}/services/{service}' ), @@ -186,6 +147,9 @@ export class UptimeCheckServiceClient { folderServicePathTemplate: new gaxModule.PathTemplate( 'folders/{folder}/services/{service}' ), + PathTemplate: new gaxModule.PathTemplate( + '*' + ), projectServiceServiceLevelObjectivePathTemplate: new gaxModule.PathTemplate( 'projects/{project}/services/{service}/serviceLevelObjectives/{service_level_objective}' ), @@ -839,448 +803,6 @@ export class UptimeCheckServiceClient { // -- Path templates -- // -------------------- - /** - * Return a fully-qualified projectAlertPolicy resource name string. - * - * @param {string} project - * @param {string} alert_policy - * @returns {string} Resource name string. - */ - projectAlertPolicyPath(project:string,alertPolicy:string) { - return this._pathTemplates.projectAlertPolicyPathTemplate.render({ - project: project, - alert_policy: alertPolicy, - }); - } - - /** - * Parse the project from ProjectAlertPolicy resource. - * - * @param {string} projectAlertPolicyName - * A fully-qualified path representing project_alert_policy resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProjectAlertPolicyName(projectAlertPolicyName: string) { - return this._pathTemplates.projectAlertPolicyPathTemplate.match(projectAlertPolicyName).project; - } - - /** - * Parse the alert_policy from ProjectAlertPolicy resource. - * - * @param {string} projectAlertPolicyName - * A fully-qualified path representing project_alert_policy resource. - * @returns {string} A string representing the alert_policy. - */ - matchAlertPolicyFromProjectAlertPolicyName(projectAlertPolicyName: string) { - return this._pathTemplates.projectAlertPolicyPathTemplate.match(projectAlertPolicyName).alert_policy; - } - - /** - * Return a fully-qualified organizationAlertPolicy resource name string. - * - * @param {string} organization - * @param {string} alert_policy - * @returns {string} Resource name string. - */ - organizationAlertPolicyPath(organization:string,alertPolicy:string) { - return this._pathTemplates.organizationAlertPolicyPathTemplate.render({ - organization: organization, - alert_policy: alertPolicy, - }); - } - - /** - * Parse the organization from OrganizationAlertPolicy resource. - * - * @param {string} organizationAlertPolicyName - * A fully-qualified path representing organization_alert_policy resource. - * @returns {string} A string representing the organization. - */ - matchOrganizationFromOrganizationAlertPolicyName(organizationAlertPolicyName: string) { - return this._pathTemplates.organizationAlertPolicyPathTemplate.match(organizationAlertPolicyName).organization; - } - - /** - * Parse the alert_policy from OrganizationAlertPolicy resource. - * - * @param {string} organizationAlertPolicyName - * A fully-qualified path representing organization_alert_policy resource. - * @returns {string} A string representing the alert_policy. - */ - matchAlertPolicyFromOrganizationAlertPolicyName(organizationAlertPolicyName: string) { - return this._pathTemplates.organizationAlertPolicyPathTemplate.match(organizationAlertPolicyName).alert_policy; - } - - /** - * Return a fully-qualified folderAlertPolicy resource name string. - * - * @param {string} folder - * @param {string} alert_policy - * @returns {string} Resource name string. - */ - folderAlertPolicyPath(folder:string,alertPolicy:string) { - return this._pathTemplates.folderAlertPolicyPathTemplate.render({ - folder: folder, - alert_policy: alertPolicy, - }); - } - - /** - * Parse the folder from FolderAlertPolicy resource. - * - * @param {string} folderAlertPolicyName - * A fully-qualified path representing folder_alert_policy resource. - * @returns {string} A string representing the folder. - */ - matchFolderFromFolderAlertPolicyName(folderAlertPolicyName: string) { - return this._pathTemplates.folderAlertPolicyPathTemplate.match(folderAlertPolicyName).folder; - } - - /** - * Parse the alert_policy from FolderAlertPolicy resource. - * - * @param {string} folderAlertPolicyName - * A fully-qualified path representing folder_alert_policy resource. - * @returns {string} A string representing the alert_policy. - */ - matchAlertPolicyFromFolderAlertPolicyName(folderAlertPolicyName: string) { - return this._pathTemplates.folderAlertPolicyPathTemplate.match(folderAlertPolicyName).alert_policy; - } - - /** - * Return a fully-qualified resource name string. - * - * @returns {string} Resource name string. - */ - Path() { - return this._pathTemplates.PathTemplate.render({ - }); - } - - /** - * Return a fully-qualified projectGroup resource name string. - * - * @param {string} project - * @param {string} group - * @returns {string} Resource name string. - */ - projectGroupPath(project:string,group:string) { - return this._pathTemplates.projectGroupPathTemplate.render({ - project: project, - group: group, - }); - } - - /** - * Parse the project from ProjectGroup resource. - * - * @param {string} projectGroupName - * A fully-qualified path representing project_group resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProjectGroupName(projectGroupName: string) { - return this._pathTemplates.projectGroupPathTemplate.match(projectGroupName).project; - } - - /** - * Parse the group from ProjectGroup resource. - * - * @param {string} projectGroupName - * A fully-qualified path representing project_group resource. - * @returns {string} A string representing the group. - */ - matchGroupFromProjectGroupName(projectGroupName: string) { - return this._pathTemplates.projectGroupPathTemplate.match(projectGroupName).group; - } - - /** - * Return a fully-qualified organizationGroup resource name string. - * - * @param {string} organization - * @param {string} group - * @returns {string} Resource name string. - */ - organizationGroupPath(organization:string,group:string) { - return this._pathTemplates.organizationGroupPathTemplate.render({ - organization: organization, - group: group, - }); - } - - /** - * Parse the organization from OrganizationGroup resource. - * - * @param {string} organizationGroupName - * A fully-qualified path representing organization_group resource. - * @returns {string} A string representing the organization. - */ - matchOrganizationFromOrganizationGroupName(organizationGroupName: string) { - return this._pathTemplates.organizationGroupPathTemplate.match(organizationGroupName).organization; - } - - /** - * Parse the group from OrganizationGroup resource. - * - * @param {string} organizationGroupName - * A fully-qualified path representing organization_group resource. - * @returns {string} A string representing the group. - */ - matchGroupFromOrganizationGroupName(organizationGroupName: string) { - return this._pathTemplates.organizationGroupPathTemplate.match(organizationGroupName).group; - } - - /** - * Return a fully-qualified folderGroup resource name string. - * - * @param {string} folder - * @param {string} group - * @returns {string} Resource name string. - */ - folderGroupPath(folder:string,group:string) { - return this._pathTemplates.folderGroupPathTemplate.render({ - folder: folder, - group: group, - }); - } - - /** - * Parse the folder from FolderGroup resource. - * - * @param {string} folderGroupName - * A fully-qualified path representing folder_group resource. - * @returns {string} A string representing the folder. - */ - matchFolderFromFolderGroupName(folderGroupName: string) { - return this._pathTemplates.folderGroupPathTemplate.match(folderGroupName).folder; - } - - /** - * Parse the group from FolderGroup resource. - * - * @param {string} folderGroupName - * A fully-qualified path representing folder_group resource. - * @returns {string} A string representing the group. - */ - matchGroupFromFolderGroupName(folderGroupName: string) { - return this._pathTemplates.folderGroupPathTemplate.match(folderGroupName).group; - } - - /** - * Return a fully-qualified projectChannelDescriptor resource name string. - * - * @param {string} project - * @param {string} channel_descriptor - * @returns {string} Resource name string. - */ - projectChannelDescriptorPath(project:string,channelDescriptor:string) { - return this._pathTemplates.projectChannelDescriptorPathTemplate.render({ - project: project, - channel_descriptor: channelDescriptor, - }); - } - - /** - * Parse the project from ProjectChannelDescriptor resource. - * - * @param {string} projectChannelDescriptorName - * A fully-qualified path representing project_channel_descriptor resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProjectChannelDescriptorName(projectChannelDescriptorName: string) { - return this._pathTemplates.projectChannelDescriptorPathTemplate.match(projectChannelDescriptorName).project; - } - - /** - * Parse the channel_descriptor from ProjectChannelDescriptor resource. - * - * @param {string} projectChannelDescriptorName - * A fully-qualified path representing project_channel_descriptor resource. - * @returns {string} A string representing the channel_descriptor. - */ - matchChannelDescriptorFromProjectChannelDescriptorName(projectChannelDescriptorName: string) { - return this._pathTemplates.projectChannelDescriptorPathTemplate.match(projectChannelDescriptorName).channel_descriptor; - } - - /** - * Return a fully-qualified organizationChannelDescriptor resource name string. - * - * @param {string} organization - * @param {string} channel_descriptor - * @returns {string} Resource name string. - */ - organizationChannelDescriptorPath(organization:string,channelDescriptor:string) { - return this._pathTemplates.organizationChannelDescriptorPathTemplate.render({ - organization: organization, - channel_descriptor: channelDescriptor, - }); - } - - /** - * Parse the organization from OrganizationChannelDescriptor resource. - * - * @param {string} organizationChannelDescriptorName - * A fully-qualified path representing organization_channel_descriptor resource. - * @returns {string} A string representing the organization. - */ - matchOrganizationFromOrganizationChannelDescriptorName(organizationChannelDescriptorName: string) { - return this._pathTemplates.organizationChannelDescriptorPathTemplate.match(organizationChannelDescriptorName).organization; - } - - /** - * Parse the channel_descriptor from OrganizationChannelDescriptor resource. - * - * @param {string} organizationChannelDescriptorName - * A fully-qualified path representing organization_channel_descriptor resource. - * @returns {string} A string representing the channel_descriptor. - */ - matchChannelDescriptorFromOrganizationChannelDescriptorName(organizationChannelDescriptorName: string) { - return this._pathTemplates.organizationChannelDescriptorPathTemplate.match(organizationChannelDescriptorName).channel_descriptor; - } - - /** - * Return a fully-qualified folderChannelDescriptor resource name string. - * - * @param {string} folder - * @param {string} channel_descriptor - * @returns {string} Resource name string. - */ - folderChannelDescriptorPath(folder:string,channelDescriptor:string) { - return this._pathTemplates.folderChannelDescriptorPathTemplate.render({ - folder: folder, - channel_descriptor: channelDescriptor, - }); - } - - /** - * Parse the folder from FolderChannelDescriptor resource. - * - * @param {string} folderChannelDescriptorName - * A fully-qualified path representing folder_channel_descriptor resource. - * @returns {string} A string representing the folder. - */ - matchFolderFromFolderChannelDescriptorName(folderChannelDescriptorName: string) { - return this._pathTemplates.folderChannelDescriptorPathTemplate.match(folderChannelDescriptorName).folder; - } - - /** - * Parse the channel_descriptor from FolderChannelDescriptor resource. - * - * @param {string} folderChannelDescriptorName - * A fully-qualified path representing folder_channel_descriptor resource. - * @returns {string} A string representing the channel_descriptor. - */ - matchChannelDescriptorFromFolderChannelDescriptorName(folderChannelDescriptorName: string) { - return this._pathTemplates.folderChannelDescriptorPathTemplate.match(folderChannelDescriptorName).channel_descriptor; - } - - /** - * Return a fully-qualified projectNotificationChannel resource name string. - * - * @param {string} project - * @param {string} notification_channel - * @returns {string} Resource name string. - */ - projectNotificationChannelPath(project:string,notificationChannel:string) { - return this._pathTemplates.projectNotificationChannelPathTemplate.render({ - project: project, - notification_channel: notificationChannel, - }); - } - - /** - * Parse the project from ProjectNotificationChannel resource. - * - * @param {string} projectNotificationChannelName - * A fully-qualified path representing project_notification_channel resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProjectNotificationChannelName(projectNotificationChannelName: string) { - return this._pathTemplates.projectNotificationChannelPathTemplate.match(projectNotificationChannelName).project; - } - - /** - * Parse the notification_channel from ProjectNotificationChannel resource. - * - * @param {string} projectNotificationChannelName - * A fully-qualified path representing project_notification_channel resource. - * @returns {string} A string representing the notification_channel. - */ - matchNotificationChannelFromProjectNotificationChannelName(projectNotificationChannelName: string) { - return this._pathTemplates.projectNotificationChannelPathTemplate.match(projectNotificationChannelName).notification_channel; - } - - /** - * Return a fully-qualified organizationNotificationChannel resource name string. - * - * @param {string} organization - * @param {string} notification_channel - * @returns {string} Resource name string. - */ - organizationNotificationChannelPath(organization:string,notificationChannel:string) { - return this._pathTemplates.organizationNotificationChannelPathTemplate.render({ - organization: organization, - notification_channel: notificationChannel, - }); - } - - /** - * Parse the organization from OrganizationNotificationChannel resource. - * - * @param {string} organizationNotificationChannelName - * A fully-qualified path representing organization_notification_channel resource. - * @returns {string} A string representing the organization. - */ - matchOrganizationFromOrganizationNotificationChannelName(organizationNotificationChannelName: string) { - return this._pathTemplates.organizationNotificationChannelPathTemplate.match(organizationNotificationChannelName).organization; - } - - /** - * Parse the notification_channel from OrganizationNotificationChannel resource. - * - * @param {string} organizationNotificationChannelName - * A fully-qualified path representing organization_notification_channel resource. - * @returns {string} A string representing the notification_channel. - */ - matchNotificationChannelFromOrganizationNotificationChannelName(organizationNotificationChannelName: string) { - return this._pathTemplates.organizationNotificationChannelPathTemplate.match(organizationNotificationChannelName).notification_channel; - } - - /** - * Return a fully-qualified folderNotificationChannel resource name string. - * - * @param {string} folder - * @param {string} notification_channel - * @returns {string} Resource name string. - */ - folderNotificationChannelPath(folder:string,notificationChannel:string) { - return this._pathTemplates.folderNotificationChannelPathTemplate.render({ - folder: folder, - notification_channel: notificationChannel, - }); - } - - /** - * Parse the folder from FolderNotificationChannel resource. - * - * @param {string} folderNotificationChannelName - * A fully-qualified path representing folder_notification_channel resource. - * @returns {string} A string representing the folder. - */ - matchFolderFromFolderNotificationChannelName(folderNotificationChannelName: string) { - return this._pathTemplates.folderNotificationChannelPathTemplate.match(folderNotificationChannelName).folder; - } - - /** - * Parse the notification_channel from FolderNotificationChannel resource. - * - * @param {string} folderNotificationChannelName - * A fully-qualified path representing folder_notification_channel resource. - * @returns {string} A string representing the notification_channel. - */ - matchNotificationChannelFromFolderNotificationChannelName(folderNotificationChannelName: string) { - return this._pathTemplates.folderNotificationChannelPathTemplate.match(folderNotificationChannelName).notification_channel; - } - /** * Return a fully-qualified projectService resource name string. * @@ -1389,6 +911,16 @@ export class UptimeCheckServiceClient { return this._pathTemplates.folderServicePathTemplate.match(folderServiceName).service; } + /** + * Return a fully-qualified resource name string. + * + * @returns {string} Resource name string. + */ + Path() { + return this._pathTemplates.PathTemplate.render({ + }); + } + /** * Return a fully-qualified projectServiceServiceLevelObjective resource name string. * diff --git a/typescript/test/testdata/monitoring/src/v3/uptime_check_service_proto_list.json.baseline b/typescript/test/testdata/monitoring/src/v3/uptime_check_service_proto_list.json.baseline index aacceb22f..6fec2dd59 100644 --- a/typescript/test/testdata/monitoring/src/v3/uptime_check_service_proto_list.json.baseline +++ b/typescript/test/testdata/monitoring/src/v3/uptime_check_service_proto_list.json.baseline @@ -1,14 +1,4 @@ [ - "../../protos/google/monitoring/v3/alert.proto", - "../../protos/google/monitoring/v3/alert_service.proto", - "../../protos/google/monitoring/v3/common.proto", - "../../protos/google/monitoring/v3/group.proto", - "../../protos/google/monitoring/v3/group_service.proto", - "../../protos/google/monitoring/v3/metric.proto", - "../../protos/google/monitoring/v3/metric_service.proto", - "../../protos/google/monitoring/v3/mutation_record.proto", - "../../protos/google/monitoring/v3/notification.proto", - "../../protos/google/monitoring/v3/notification_service.proto", "../../protos/google/monitoring/v3/service.proto", "../../protos/google/monitoring/v3/service_service.proto", "../../protos/google/monitoring/v3/uptime.proto", diff --git a/typescript/test/testdata/monitoring/system-test/fixtures/sample/src/index.js.baseline b/typescript/test/testdata/monitoring/system-test/fixtures/sample/src/index.js.baseline index 7b3918c1b..5cf88f5bf 100644 --- a/typescript/test/testdata/monitoring/system-test/fixtures/sample/src/index.js.baseline +++ b/typescript/test/testdata/monitoring/system-test/fixtures/sample/src/index.js.baseline @@ -21,10 +21,6 @@ const monitoring = require('monitoring'); function main() { - const alertPolicyServiceClient = new monitoring.AlertPolicyServiceClient(); - const groupServiceClient = new monitoring.GroupServiceClient(); - const metricServiceClient = new monitoring.MetricServiceClient(); - const notificationChannelServiceClient = new monitoring.NotificationChannelServiceClient(); const serviceMonitoringServiceClient = new monitoring.ServiceMonitoringServiceClient(); const uptimeCheckServiceClient = new monitoring.UptimeCheckServiceClient(); } diff --git a/typescript/test/testdata/monitoring/system-test/fixtures/sample/src/index.ts.baseline b/typescript/test/testdata/monitoring/system-test/fixtures/sample/src/index.ts.baseline index e6cea60a7..23d96dd99 100644 --- a/typescript/test/testdata/monitoring/system-test/fixtures/sample/src/index.ts.baseline +++ b/typescript/test/testdata/monitoring/system-test/fixtures/sample/src/index.ts.baseline @@ -16,13 +16,9 @@ // ** https://github.com/googleapis/gapic-generator-typescript ** // ** All changes to this file may be overwritten. ** -import {AlertPolicyServiceClient, GroupServiceClient, MetricServiceClient, NotificationChannelServiceClient, ServiceMonitoringServiceClient, UptimeCheckServiceClient} from 'monitoring'; +import {ServiceMonitoringServiceClient, UptimeCheckServiceClient} from '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(); } diff --git a/typescript/test/testdata/monitoring/test/gapic-alert_policy_service-v3.ts.baseline b/typescript/test/testdata/monitoring/test/gapic-alert_policy_service-v3.ts.baseline deleted file mode 100644 index 13fa999b8..000000000 --- a/typescript/test/testdata/monitoring/test/gapic-alert_policy_service-v3.ts.baseline +++ /dev/null @@ -1,323 +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); - }); - describe('getAlertPolicy', () => { - it('invokes getAlertPolicy without error', done => { - const client = new alertpolicyserviceModule.v3.AlertPolicyServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - // 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', - }); - // 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', - }); - // 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', - }); - // 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', - }); - // 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', - }); - // 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', - }); - // 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', - }); - // 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', - }); - // 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', - }); - // 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/typescript/test/testdata/monitoring/test/gapic-group_service-v3.ts.baseline b/typescript/test/testdata/monitoring/test/gapic-group_service-v3.ts.baseline deleted file mode 100644 index df8dfb910..000000000 --- a/typescript/test/testdata/monitoring/test/gapic-group_service-v3.ts.baseline +++ /dev/null @@ -1,371 +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); - }); - describe('getGroup', () => { - it('invokes getGroup without error', done => { - const client = new groupserviceModule.v3.GroupServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - // 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', - }); - // 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', - }); - // 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', - }); - // 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', - }); - // 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', - }); - // 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', - }); - // 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', - }); - // 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', - }); - // 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', - }); - // 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', - }); - // 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', - }); - // 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/typescript/test/testdata/monitoring/test/gapic-metric_service-v3.ts.baseline b/typescript/test/testdata/monitoring/test/gapic-metric_service-v3.ts.baseline deleted file mode 100644 index a709a3212..000000000 --- a/typescript/test/testdata/monitoring/test/gapic-metric_service-v3.ts.baseline +++ /dev/null @@ -1,465 +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); - }); - describe('getMonitoredResourceDescriptor', () => { - it('invokes getMonitoredResourceDescriptor without error', done => { - const client = new metricserviceModule.v3.MetricServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - // 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', - }); - // 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', - }); - // 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', - }); - // 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', - }); - // 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', - }); - // 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', - }); - // 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', - }); - // 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', - }); - // 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', - }); - // 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', - }); - // 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', - }); - // 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', - }); - // 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', - }); - // 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', - }); - // 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', - }); - // 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/typescript/test/testdata/monitoring/test/gapic-notification_channel_service-v3.ts.baseline b/typescript/test/testdata/monitoring/test/gapic-notification_channel_service-v3.ts.baseline deleted file mode 100644 index e3fff90fc..000000000 --- a/typescript/test/testdata/monitoring/test/gapic-notification_channel_service-v3.ts.baseline +++ /dev/null @@ -1,563 +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); - }); - describe('getNotificationChannelDescriptor', () => { - it('invokes getNotificationChannelDescriptor without error', done => { - const client = new notificationchannelserviceModule.v3.NotificationChannelServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - // 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', - }); - // 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', - }); - // 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', - }); - // 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', - }); - // 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', - }); - // 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', - }); - // 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', - }); - // 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', - }); - // 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', - }); - // 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', - }); - // 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', - }); - // 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', - }); - // 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', - }); - // 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', - }); - // 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', - }); - // 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', - }); - // 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', - }); - // 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', - }); - // 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', - }); - // 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); - }); - }); -}); From 5b16360ce0faf5c018d4485a6208fd47688fa8ff Mon Sep 17 00:00:00 2001 From: summerji Date: Wed, 5 Feb 2020 15:48:09 -0800 Subject: [PATCH 5/6] test: run monitoring in CI --- .circleci/config.yml | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/.circleci/config.yml b/.circleci/config.yml index 7384c27ff..78848fb0f 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -34,6 +34,7 @@ jobs: cp -r typescript/test/protos .test-out-showcase cp -r typescript/test/protos .test-out-keymanager cp -r typescript/test/protos .test-out-translate + cp -r typescript/test/protos .test-out-monitoring cp -r typescript/test/protos .test-out-texttospeech cp -r typescript/test/protos .test-out-dlp - persist_to_workspace: @@ -122,6 +123,24 @@ jobs: npm run system-test npm run docs npm run docs-test + monitoringLibTest: + docker: + - image: circleci/node:10-browsers + steps: + - checkout + - attach_workspace: + at: workspace + - run: + name: Run unit tests, system tests, jsdoc generation, and gts fix of the generated Monitoring library + command: | + cd workspace/workspace/gapic-generator-typescript/.test-out-monitoring + npm install + npm test + npm run fix + npm run compile + npm run system-test + npm run docs + npm run docs-test dlpLibTest: docker: - image: circleci/node:10-browsers @@ -180,6 +199,9 @@ workflows: - translateLibTest: requires: - testGenerator + - monitoringLibTest: + requires: + - testGenerator - ttsLibTest: requires: - testGenerator From 8b5d246b611d93f14806c628ab8d6246a8fde700 Mon Sep 17 00:00:00 2001 From: summerji Date: Wed, 5 Feb 2020 16:08:21 -0800 Subject: [PATCH 6/6] Improve naming --- typescript/test/unit/monitor.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/typescript/test/unit/monitor.ts b/typescript/test/unit/monitor.ts index c11bdfc2a..36c8a125c 100644 --- a/typescript/test/unit/monitor.ts +++ b/typescript/test/unit/monitor.ts @@ -19,7 +19,7 @@ const START_SCRIPT = path.join( const OUTPUT_DIR = path.join(cwd, '.test-out-monitoring'); const PROTOS_DIR = path.join(cwd, 'build', 'test', 'protos'); -const MONITOR_PROTO_FILE1 = path.join( +const MONITOR_PROTO_FILES = path.join( PROTOS_DIR, 'google', 'monitoring', @@ -67,7 +67,7 @@ describe('MonitoringGenerateTest', () => { 'node ' + START_SCRIPT + ` -I${PROTOS_DIR}` + - ` ${MONITOR_PROTO_FILE1}` + + ` ${MONITOR_PROTO_FILES}` + ` --output_dir=${OUTPUT_DIR}` + ` --main_service=monitoring` );