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 diff --git a/typescript/src/schema/api.ts b/typescript/src/schema/api.ts index 892f1a095..d90439402 100644 --- a/typescript/src/schema/api.ts +++ b/typescript/src/schema/api.ts @@ -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..f9cc3f4c9 100644 --- a/typescript/test/testdata/monitoring/proto.list.baseline +++ b/typescript/test/testdata/monitoring/proto.list.baseline @@ -15,3 +15,5 @@ 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..7e05abce5 100644 --- a/typescript/test/testdata/monitoring/src/index.ts.baseline +++ b/typescript/test/testdata/monitoring/src/index.ts.baseline @@ -17,7 +17,9 @@ // ** All changes to this file may be overwritten. ** import * as v3 from './v3'; -export {v3}; +const ServiceMonitoringServiceClient = v3.ServiceMonitoringServiceClient; +const UptimeCheckServiceClient = v3.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}; +export default {v3, ServiceMonitoringServiceClient, UptimeCheckServiceClient}; diff --git a/typescript/test/testdata/monitoring/src/v3/index.ts.baseline b/typescript/test/testdata/monitoring/src/v3/index.ts.baseline index c8ae05a7a..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 {ServiceMonitoringServiceClient} from './service_monitoring_service_client';export {UptimeCheckServiceClient} from './uptime_check_service_client'; 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..2cb638e2d --- /dev/null +++ b/typescript/test/testdata/monitoring/src/v3/service_monitoring_service_client.ts.baseline @@ -0,0 +1,1478 @@ +// 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 = { + projectServicePathTemplate: new gaxModule.PathTemplate( + 'projects/{project}/services/{service}' + ), + organizationServicePathTemplate: new gaxModule.PathTemplate( + 'organizations/{organization}/services/{service}' + ), + folderServicePathTemplate: new gaxModule.PathTemplate( + 'folders/{folder}/services/{service}' + ), + PathTemplate: new gaxModule.PathTemplate( + '*' + ), + 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 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 resource name string. + * + * @returns {string} Resource name string. + */ + Path() { + return this._pathTemplates.PathTemplate.render({ + }); + } + + /** + * 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..6fec2dd59 --- /dev/null +++ b/typescript/test/testdata/monitoring/src/v3/service_monitoring_service_proto_list.json.baseline @@ -0,0 +1,6 @@ +[ + "../../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..69075e7c8 --- /dev/null +++ b/typescript/test/testdata/monitoring/src/v3/uptime_check_service_client.ts.baseline @@ -0,0 +1,1193 @@ +// 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 = { + projectServicePathTemplate: new gaxModule.PathTemplate( + 'projects/{project}/services/{service}' + ), + organizationServicePathTemplate: new gaxModule.PathTemplate( + 'organizations/{organization}/services/{service}' + ), + folderServicePathTemplate: new gaxModule.PathTemplate( + 'folders/{folder}/services/{service}' + ), + PathTemplate: new gaxModule.PathTemplate( + '*' + ), + 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 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 resource name string. + * + * @returns {string} Resource name string. + */ + Path() { + return this._pathTemplates.PathTemplate.render({ + }); + } + + /** + * 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..6fec2dd59 --- /dev/null +++ b/typescript/test/testdata/monitoring/src/v3/uptime_check_service_proto_list.json.baseline @@ -0,0 +1,6 @@ +[ + "../../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..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,6 +21,8 @@ const monitoring = require('monitoring'); function main() { + 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..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,9 +16,11 @@ // ** https://github.com/googleapis/gapic-generator-typescript ** // ** All changes to this file may be overwritten. ** -import {} from 'monitoring'; +import {ServiceMonitoringServiceClient, UptimeCheckServiceClient} from 'monitoring'; function main() { + const serviceMonitoringServiceClient = new ServiceMonitoringServiceClient(); + const uptimeCheckServiceClient = new UptimeCheckServiceClient(); } main(); 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..36c8a125c 100644 --- a/typescript/test/unit/monitor.ts +++ b/typescript/test/unit/monitor.ts @@ -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_FILES = 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 monitoring library have same output with baseline.', function() { this.timeout(10000); if (fs.existsSync(OUTPUT_DIR)) { rimraf.sync(OUTPUT_DIR); @@ -73,7 +67,7 @@ describe('MonitoringGenerateTest', () => { 'node ' + START_SCRIPT + ` -I${PROTOS_DIR}` + - ` ${MONITOR_PROTO_FILE}` + + ` ${MONITOR_PROTO_FILES}` + ` --output_dir=${OUTPUT_DIR}` + ` --main_service=monitoring` );