From 542742e4004d3688ccefe359b9010bd101f35ed1 Mon Sep 17 00:00:00 2001 From: Ernest Landrito Date: Fri, 30 Sep 2016 17:34:28 -0700 Subject: [PATCH 1/6] Introduce auto-generated Gapic client for monitoring API --- packages/monitoring/LICENSE | 201 +++++ packages/monitoring/README.md | 45 + packages/monitoring/package.json | 21 + packages/monitoring/src/index.js | 18 + .../monitoring/src/v3/group_service_api.js | 631 ++++++++++++++ .../src/v3/group_service_client_config.json | 58 ++ packages/monitoring/src/v3/index.js | 39 + .../monitoring/src/v3/metric_service_api.js | 804 ++++++++++++++++++ .../src/v3/metric_service_client_config.json | 68 ++ 9 files changed, 1885 insertions(+) create mode 100644 packages/monitoring/LICENSE create mode 100644 packages/monitoring/README.md create mode 100644 packages/monitoring/package.json create mode 100644 packages/monitoring/src/index.js create mode 100644 packages/monitoring/src/v3/group_service_api.js create mode 100644 packages/monitoring/src/v3/group_service_client_config.json create mode 100644 packages/monitoring/src/v3/index.js create mode 100644 packages/monitoring/src/v3/metric_service_api.js create mode 100644 packages/monitoring/src/v3/metric_service_client_config.json diff --git a/packages/monitoring/LICENSE b/packages/monitoring/LICENSE new file mode 100644 index 00000000000..724a8807144 --- /dev/null +++ b/packages/monitoring/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/packages/monitoring/README.md b/packages/monitoring/README.md new file mode 100644 index 00000000000..68f88201532 --- /dev/null +++ b/packages/monitoring/README.md @@ -0,0 +1,45 @@ +Stackdriver Monitoring API for Node.js +================================================= + +@google-cloud/monitoring uses [Google API extensions][google-gax] to provide an +easy-to-use client library for the [Stackdriver Monitoring API][] (v3) defined in the [googleapis][] git repository + + +[googleapis]: https://github.com/googleapis/googleapis/tree/master/google/google/monitoring/v3 +[google-gax]: https://github.com/googleapis/gax-nodejs +[Stackdriver Monitoring API]: https://developers.google.com/apis-explorer/#p/monitoring/v3/ + +Getting started +--------------- + +@google-cloud/monitoring will allow you to connect to the [Stackdriver Monitoring API][] and access all its methods. + +In order to do so, you need to set up authentication as well as install the library locally. + + +Setup Authentication +-------------------- + +To authenticate all your API calls, first install and setup the [Google Cloud SDK][]. +Once done, you can then run the following command in your terminal: + + $ gcloud beta auth application-default login + +or + + $ gcloud auth login + +Please see [[gcloud beta auth application-default login][] document for the difference between these commands. + +[Google Cloud SDK]: https://cloud.google.com/sdk/ +[gcloud beta auth application-default login]: https://cloud.google.com/sdk/gcloud/reference/beta/auth/application-default/login + + +Installation +------------------- + +Install this library using npm: + + $ npm install @google-cloud/monitoring + +At this point you are all set to continue. diff --git a/packages/monitoring/package.json b/packages/monitoring/package.json new file mode 100644 index 00000000000..a7da28f138d --- /dev/null +++ b/packages/monitoring/package.json @@ -0,0 +1,21 @@ +{ + "url": "https://github.com/googleapis/googleapis", + "name": "@google-cloud/monitoring", + "version": "0.7.1", + "author": "Google Inc.", + "description": "Stackdriver Monitoring library for Node.js", + "main": "src/index.js", + "files": [ + "src" + ], + "dependencies": { + "google-proto-files": "^0.8.2", + "google-gax": "^0.7.0", + "extend": "^3.0.0", + "lodash.union": "^4.6.0" + }, + "license": "Apache-2.0", + "engines": { + "node": ">=0.12.0" + } +} diff --git a/packages/monitoring/src/index.js b/packages/monitoring/src/index.js new file mode 100644 index 00000000000..fceafde8de9 --- /dev/null +++ b/packages/monitoring/src/index.js @@ -0,0 +1,18 @@ +/*! + * Copyright 2016 Google Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +'use strict'; + +module.exports.v3 = require('./v3'); diff --git a/packages/monitoring/src/v3/group_service_api.js b/packages/monitoring/src/v3/group_service_api.js new file mode 100644 index 00000000000..2db6bbb6bfb --- /dev/null +++ b/packages/monitoring/src/v3/group_service_api.js @@ -0,0 +1,631 @@ +/* + * Copyright 2016 Google Inc. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * EDITING INSTRUCTIONS + * This file was generated from the file + * https://github.com/googleapis/googleapis/blob/master/google/monitoring/v3/group_service.proto, + * and updates to that file get reflected here through a refresh process. + * For the short term, the refresh process will only be runnable by Google + * engineers. + * + * The only allowed edits are to method and file documentation. A 3-way + * merge preserves those additions if the generated source changes. + */ +/* TODO: introduce line-wrapping so that it never exceeds the limit. */ +/* jscs: disable maximumLineLength */ +'use strict'; + +var configData = require('./group_service_client_config'); +var extend = require('extend'); +var gax = require('google-gax'); + +var SERVICE_ADDRESS = 'monitoring.googleapis.com'; + +var DEFAULT_SERVICE_PORT = 443; + +var CODE_GEN_NAME_VERSION = 'gapic/0.1.0'; + + +var PAGE_DESCRIPTORS = { + listGroups: new gax.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'group'), + listGroupMembers: new gax.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'members') +}; + +/** + * The scopes needed to make gRPC calls to all of the methods defined in + * this service. + */ +var ALL_SCOPES = [ +]; + +/** + * The Group API lets you inspect and manage your + * [groups](https://cloud.google.comgoogle.monitoring.v3.Group). + * + * A group is a named filter that is used to identify + * a collection of monitored resources. Groups are typically used to + * mirror the physical and/or logical topology of the environment. + * Because group membership is computed dynamically, monitored + * resources that are started in the future are automatically placed + * in matching groups. By using a group to name monitored resources in, + * for example, an alert policy, the target of that alert policy is + * updated automatically as monitored resources are added and removed + * from the infrastructure. + * + * This will be created through a builder function which can be obtained by the module. + * See the following example of how to initialize the module and how to access to the builder. + * @see {@link groupServiceApi} + * + * @example + * var monitoringV3 = require('@google-cloud/monitoring').v3({ + * // optional auth parameters. + * }); + * var api = monitoringV3.groupServiceApi(); + * + * @class + */ +function GroupServiceApi(gaxGrpc, grpcClients, opts) { + opts = opts || {}; + var servicePath = opts.servicePath || SERVICE_ADDRESS; + var port = opts.port || DEFAULT_SERVICE_PORT; + var sslCreds = opts.sslCreds || null; + var clientConfig = opts.clientConfig || {}; + var appName = opts.appName || 'gax'; + var appVersion = opts.appVersion || gax.version; + + var googleApiClient = [ + appName + '/' + appVersion, + CODE_GEN_NAME_VERSION, + 'gax/' + gax.version, + 'nodejs/' + process.version].join(' '); + + var defaults = gaxGrpc.constructSettings( + 'google.monitoring.v3.GroupService', + configData, + clientConfig, + PAGE_DESCRIPTORS, + null, + {'x-goog-api-client': googleApiClient}); + + var groupServiceStub = gaxGrpc.createStub( + servicePath, + port, + grpcClients.groupServiceClient.google.monitoring.v3.GroupService, + {sslCreds: sslCreds}); + var groupServiceStubMethods = [ + 'listGroups', + 'getGroup', + 'createGroup', + 'updateGroup', + 'deleteGroup', + 'listGroupMembers' + ]; + groupServiceStubMethods.forEach(function(methodName) { + this['_' + methodName] = gax.createApiCall( + groupServiceStub.then(function(groupServiceStub) { + return groupServiceStub[methodName].bind(groupServiceStub); + }), + defaults[methodName]); + }.bind(this)); +} + +// Path templates + +var PROJECT_PATH_TEMPLATE = new gax.PathTemplate( + 'projects/{project}'); + +var GROUP_PATH_TEMPLATE = new gax.PathTemplate( + 'projects/{project}/groups/{group}'); + +/** + * Returns a fully-qualified project resource name string. + * @param {String} project + * @returns {String} + */ +GroupServiceApi.prototype.projectPath = function projectPath(project) { + return PROJECT_PATH_TEMPLATE.render({ + project: project + }); +}; + +/** + * Parses the projectName from a project resource. + * @param {String} projectName + * A fully-qualified path representing a project resources. + * @returns {String} - A string representing the project. + */ +GroupServiceApi.prototype.matchProjectFromProjectName = + function matchProjectFromProjectName(projectName) { + return PROJECT_PATH_TEMPLATE.match(projectName).project; +}; + +/** + * Returns a fully-qualified group resource name string. + * @param {String} project + * @param {String} group + * @returns {String} + */ +GroupServiceApi.prototype.groupPath = function groupPath(project, group) { + return GROUP_PATH_TEMPLATE.render({ + project: project, + group: group + }); +}; + +/** + * Parses the groupName from a group resource. + * @param {String} groupName + * A fully-qualified path representing a group resources. + * @returns {String} - A string representing the project. + */ +GroupServiceApi.prototype.matchProjectFromGroupName = + function matchProjectFromGroupName(groupName) { + return GROUP_PATH_TEMPLATE.match(groupName).project; +}; + +/** + * Parses the groupName from a group resource. + * @param {String} groupName + * A fully-qualified path representing a group resources. + * @returns {String} - A string representing the group. + */ +GroupServiceApi.prototype.matchGroupFromGroupName = + function matchGroupFromGroupName(groupName) { + return GROUP_PATH_TEMPLATE.match(groupName).group; +}; + +// Service calls + +/** + * Lists the existing groups. + * + * @param {string} name + * The project whose groups are to be listed. The format is + * `"projects/{project_id_or_number}"`. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, e.g, timeout, + * retries, paginations, etc. See [gax.CallOptions]{@link https://googleapis.github.io/gax-nodejs/global.html#CallOptions} for the details. + * + * In addition, options may contain the following optional parameters. + * @param {string=} options.childrenOfGroup + * A group name: `"projects/{project_id_or_number}/groups/{group_id}"`. + * Returns groups whose `parentName` field contains the group + * name. If no groups have this parent, the results are empty. + * @param {string=} options.ancestorsOfGroup + * A group name: `"projects/{project_id_or_number}/groups/{group_id}"`. + * Returns groups that are ancestors of the specified group. + * The groups are returned in order, starting with the immediate parent and + * ending with the most distant ancestor. If the specified group has no + * immediate parent, the results are empty. + * @param {string=} options.descendantsOfGroup + * A group name: `"projects/{project_id_or_number}/groups/{group_id}"`. + * Returns the descendants of the specified group. This is a superset of + * the results returned by the `childrenOfGroup` filter, and includes + * children-of-children, and so forth. + * @param {number=} options.pageSize + * The maximum number of resources contained in the underlying API + * response. If page streaming is performed per-resource, this + * parameter does not affect the return value. If page streaming is + * performed per-page, this determines the maximum number of + * resources in a page. + * + * @param {function(?Error, ?Object, ?string)=} callback + * When specified, the results are not streamed but this callback + * will be called with the response object representing [ListGroupsResponse]{@link ListGroupsResponse}. + * The third item will be set if the response contains the token for the further results + * and can be reused to `pageToken` field in the options in the next request. + * @returns {Stream|gax.EventEmitter} + * An object stream which emits an object representing + * [Group]{@link Group} on 'data' event. + * When the callback is specified or streaming is suppressed through options, + * it will return an event emitter to handle the call status and the callback + * will be called with the response object. + * + * @example + * + * var api = monitoringV3.groupServiceApi(); + * var formattedName = api.projectPath("[PROJECT]"); + * // Iterate over all elements. + * api.listGroups(formattedName).on('data', function(element) { + * // doThingsWith(element) + * }); + * + * // Or obtain the paged response through the callback. + * function callback(err, response, nextPageToken) { + * if (err) { + * console.error(err); + * return; + * } + * // doThingsWith(response) + * if (nextPageToken) { + * // fetch the next page. + * api.listGroups(formattedName, {pageToken: nextPageToken}, callback); + * } + * } + * api.listGroups(formattedName, {flattenPages: false}, callback); + */ +GroupServiceApi.prototype.listGroups = function listGroups( + name, + options, + callback) { + if (options instanceof Function && callback === undefined) { + callback = options; + options = {}; + } + if (options === undefined) { + options = {}; + } + var req = { + name: name + }; + if ('childrenOfGroup' in options) { + req.childrenOfGroup = options.childrenOfGroup; + } + if ('ancestorsOfGroup' in options) { + req.ancestorsOfGroup = options.ancestorsOfGroup; + } + if ('descendantsOfGroup' in options) { + req.descendantsOfGroup = options.descendantsOfGroup; + } + if ('pageSize' in options) { + req.pageSize = options.pageSize; + } + return this._listGroups(req, options, callback); +}; + +/** + * Gets a single group. + * + * @param {string} name + * The group to retrieve. The format is + * `"projects/{project_id_or_number}/groups/{group_id}"`. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, e.g, timeout, + * retries, paginations, etc. See [gax.CallOptions]{@link https://googleapis.github.io/gax-nodejs/global.html#CallOptions} for the details. + * @param {function(?Error, ?Object)=} callback + * The function which will be called with the result of the API call. + * + * The second parameter to the callback is an object representing [Group]{@link Group} + * @returns {gax.EventEmitter} - the event emitter to handle the call + * status. + * + * @example + * + * var api = monitoringV3.groupServiceApi(); + * var formattedName = api.groupPath("[PROJECT]", "[GROUP]"); + * api.getGroup(formattedName, function(err, response) { + * if (err) { + * console.error(err); + * return; + * } + * // doThingsWith(response) + * }); + */ +GroupServiceApi.prototype.getGroup = function getGroup( + name, + options, + callback) { + if (options instanceof Function && callback === undefined) { + callback = options; + options = {}; + } + if (options === undefined) { + options = {}; + } + var req = { + name: name + }; + return this._getGroup(req, options, callback); +}; + +/** + * Creates a new group. + * + * @param {string} name + * The project in which to create the group. The format is + * `"projects/{project_id_or_number}"`. + * @param {Object} group + * A group definition. It is an error to define the `name` field because + * the system assigns the name. + * + * This object should have the same structure as [Group]{@link Group} + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, e.g, timeout, + * retries, paginations, etc. See [gax.CallOptions]{@link https://googleapis.github.io/gax-nodejs/global.html#CallOptions} for the details. + * + * In addition, options may contain the following optional parameters. + * @param {boolean=} options.validateOnly + * If true, validate this request but do not create the group. + * + * @param {function(?Error, ?Object)=} callback + * The function which will be called with the result of the API call. + * + * The second parameter to the callback is an object representing [Group]{@link Group} + * @returns {gax.EventEmitter} - the event emitter to handle the call + * status. + * + * @example + * + * var api = monitoringV3.groupServiceApi(); + * var formattedName = api.projectPath("[PROJECT]"); + * var group = {}; + * api.createGroup(formattedName, group, function(err, response) { + * if (err) { + * console.error(err); + * return; + * } + * // doThingsWith(response) + * }); + */ +GroupServiceApi.prototype.createGroup = function createGroup( + name, + group, + options, + callback) { + if (options instanceof Function && callback === undefined) { + callback = options; + options = {}; + } + if (options === undefined) { + options = {}; + } + var req = { + name: name, + group: group + }; + if ('validateOnly' in options) { + req.validateOnly = options.validateOnly; + } + return this._createGroup(req, options, callback); +}; + +/** + * Updates an existing group. + * You can change any group attributes except `name`. + * + * @param {Object} group + * The new definition of the group. All fields of the existing group, + * excepting `name`, are replaced with the corresponding fields of this group. + * + * This object should have the same structure as [Group]{@link Group} + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, e.g, timeout, + * retries, paginations, etc. See [gax.CallOptions]{@link https://googleapis.github.io/gax-nodejs/global.html#CallOptions} for the details. + * + * In addition, options may contain the following optional parameters. + * @param {boolean=} options.validateOnly + * If true, validate this request but do not update the existing group. + * + * @param {function(?Error, ?Object)=} callback + * The function which will be called with the result of the API call. + * + * The second parameter to the callback is an object representing [Group]{@link Group} + * @returns {gax.EventEmitter} - the event emitter to handle the call + * status. + * + * @example + * + * var api = monitoringV3.groupServiceApi(); + * var group = {}; + * api.updateGroup(group, function(err, response) { + * if (err) { + * console.error(err); + * return; + * } + * // doThingsWith(response) + * }); + */ +GroupServiceApi.prototype.updateGroup = function updateGroup( + group, + options, + callback) { + if (options instanceof Function && callback === undefined) { + callback = options; + options = {}; + } + if (options === undefined) { + options = {}; + } + var req = { + group: group + }; + if ('validateOnly' in options) { + req.validateOnly = options.validateOnly; + } + return this._updateGroup(req, options, callback); +}; + +/** + * Deletes an existing group. + * + * @param {string} name + * The group to delete. The format is + * `"projects/{project_id_or_number}/groups/{group_id}"`. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, e.g, timeout, + * retries, paginations, etc. See [gax.CallOptions]{@link https://googleapis.github.io/gax-nodejs/global.html#CallOptions} for the details. + * @param {function(?Error)=} callback + * The function which will be called with the result of the API call. + * @returns {gax.EventEmitter} - the event emitter to handle the call + * status. + * + * @example + * + * var api = monitoringV3.groupServiceApi(); + * var formattedName = api.groupPath("[PROJECT]", "[GROUP]"); + * api.deleteGroup(formattedName, function(err) { + * if (err) { + * console.error(err); + * } + * }); + */ +GroupServiceApi.prototype.deleteGroup = function deleteGroup( + name, + options, + callback) { + if (options instanceof Function && callback === undefined) { + callback = options; + options = {}; + } + if (options === undefined) { + options = {}; + } + var req = { + name: name + }; + return this._deleteGroup(req, options, callback); +}; + +/** + * Lists the monitored resources that are members of a group. + * + * @param {string} name + * The group whose members are listed. The format is + * `"projects/{project_id_or_number}/groups/{group_id}"`. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, e.g, timeout, + * retries, paginations, etc. See [gax.CallOptions]{@link https://googleapis.github.io/gax-nodejs/global.html#CallOptions} for the details. + * + * In addition, options may contain the following optional parameters. + * @param {number=} options.pageSize + * The maximum number of resources contained in the underlying API + * response. If page streaming is performed per-resource, this + * parameter does not affect the return value. If page streaming is + * performed per-page, this determines the maximum number of + * resources in a page. + * @param {string=} options.filter + * An optional [list filter](https://cloud.google.com/monitoring/api/learn_more#filtering) describing + * the members to be returned. The filter may reference the type, labels, and + * metadata of monitored resources that comprise the group. + * For example, to return only resources representing Compute Engine VM + * instances, use this filter: + * + * resource.type = "gce_instance" + * @param {Object=} options.interval + * An optional time interval for which results should be returned. Only + * members that were part of the group during the specified interval are + * included in the response. If no interval is provided then the group + * membership over the last minute is returned. + * + * This object should have the same structure as [TimeInterval]{@link TimeInterval} + * + * @param {function(?Error, ?Object, ?string)=} callback + * When specified, the results are not streamed but this callback + * will be called with the response object representing [ListGroupMembersResponse]{@link ListGroupMembersResponse}. + * The third item will be set if the response contains the token for the further results + * and can be reused to `pageToken` field in the options in the next request. + * @returns {Stream|gax.EventEmitter} + * An object stream which emits an object representing + * [google.api.MonitoredResource]{@link external:"google.api.MonitoredResource"} on 'data' event. + * When the callback is specified or streaming is suppressed through options, + * it will return an event emitter to handle the call status and the callback + * will be called with the response object. + * + * @example + * + * var api = monitoringV3.groupServiceApi(); + * var formattedName = api.groupPath("[PROJECT]", "[GROUP]"); + * // Iterate over all elements. + * api.listGroupMembers(formattedName).on('data', function(element) { + * // doThingsWith(element) + * }); + * + * // Or obtain the paged response through the callback. + * function callback(err, response, nextPageToken) { + * if (err) { + * console.error(err); + * return; + * } + * // doThingsWith(response) + * if (nextPageToken) { + * // fetch the next page. + * api.listGroupMembers(formattedName, {pageToken: nextPageToken}, callback); + * } + * } + * api.listGroupMembers(formattedName, {flattenPages: false}, callback); + */ +GroupServiceApi.prototype.listGroupMembers = function listGroupMembers( + name, + options, + callback) { + if (options instanceof Function && callback === undefined) { + callback = options; + options = {}; + } + if (options === undefined) { + options = {}; + } + var req = { + name: name + }; + if ('pageSize' in options) { + req.pageSize = options.pageSize; + } + if ('filter' in options) { + req.filter = options.filter; + } + if ('interval' in options) { + req.interval = options.interval; + } + return this._listGroupMembers(req, options, callback); +}; + +function GroupServiceApiBuilder(gaxGrpc) { + if (!(this instanceof GroupServiceApiBuilder)) { + return new GroupServiceApiBuilder(gaxGrpc); + } + + var groupServiceClient = gaxGrpc.load([{ + root: require('google-proto-files')('..'), + file: 'google/monitoring/v3/group_service.proto' + }]); + extend(this, groupServiceClient.google.monitoring.v3); + + var grpcClients = { + groupServiceClient: groupServiceClient + }; + + /** + * Build a new instance of {@link GroupServiceApi}. + * + * @param {Object=} opts - The optional parameters. + * @param {String=} opts.servicePath + * The domain name of the API remote host. + * @param {number=} opts.port + * The port on which to connect to the remote host. + * @param {grpc.ClientCredentials=} opts.sslCreds + * A ClientCredentials for use with an SSL-enabled channel. + * @param {Object=} opts.clientConfig + * The customized config to build the call settings. See + * {@link gax.constructSettings} for the format. + * @param {number=} opts.appName + * The codename of the calling service. + * @param {String=} opts.appVersion + * The version of the calling service. + */ + this.groupServiceApi = function(opts) { + return new GroupServiceApi(gaxGrpc, grpcClients, opts); + }; + extend(this.groupServiceApi, GroupServiceApi); +} +module.exports = GroupServiceApiBuilder; +module.exports.SERVICE_ADDRESS = SERVICE_ADDRESS; +module.exports.ALL_SCOPES = ALL_SCOPES; \ No newline at end of file diff --git a/packages/monitoring/src/v3/group_service_client_config.json b/packages/monitoring/src/v3/group_service_client_config.json new file mode 100644 index 00000000000..c1d5d808d10 --- /dev/null +++ b/packages/monitoring/src/v3/group_service_client_config.json @@ -0,0 +1,58 @@ +{ + "interfaces": { + "google.monitoring.v3.GroupService": { + "retry_codes": { + "retry_codes_def": { + "idempotent": [ + "DEADLINE_EXCEEDED", + "UNAVAILABLE" + ], + "non_idempotent": [] + } + }, + "retry_params": { + "default": { + "initial_retry_delay_millis": 100, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 60000, + "initial_rpc_timeout_millis": 20000, + "rpc_timeout_multiplier": 1.0, + "max_rpc_timeout_millis": 20000, + "total_timeout_millis": 600000 + } + }, + "methods": { + "ListGroups": { + "timeout_millis": 60000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "GetGroup": { + "timeout_millis": 60000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "CreateGroup": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "UpdateGroup": { + "timeout_millis": 60000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "DeleteGroup": { + "timeout_millis": 60000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "ListGroupMembers": { + "timeout_millis": 60000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/packages/monitoring/src/v3/index.js b/packages/monitoring/src/v3/index.js new file mode 100644 index 00000000000..2bc63917f04 --- /dev/null +++ b/packages/monitoring/src/v3/index.js @@ -0,0 +1,39 @@ +/*! + * Copyright 2016 Google Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +'use strict'; + +var groupServiceApi = require('./group_service_api'); +var metricServiceApi = require('./metric_service_api'); +var gax = require('google-gax'); +var extend = require('extend'); +var union = require('lodash.union'); + +function v3(options) { + options = extend({ + scopes: v3.ALL_SCOPES + }, options); + var gaxGrpc = gax.grpc(options); + var result = {}; + extend(result, groupServiceApi(gaxGrpc)); + extend(result, metricServiceApi(gaxGrpc)); + return result; +} +v3.SERVICE_ADDRESS = groupServiceApi.SERVICE_ADDRESS; +v3.ALL_SCOPES = union( + groupServiceApi.ALL_SCOPES, + metricServiceApi.ALL_SCOPES +); +module.exports = v3; diff --git a/packages/monitoring/src/v3/metric_service_api.js b/packages/monitoring/src/v3/metric_service_api.js new file mode 100644 index 00000000000..4ea7af7febb --- /dev/null +++ b/packages/monitoring/src/v3/metric_service_api.js @@ -0,0 +1,804 @@ +/* + * Copyright 2016 Google Inc. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * EDITING INSTRUCTIONS + * This file was generated from the file + * https://github.com/googleapis/googleapis/blob/master/google/monitoring/v3/metric_service.proto, + * and updates to that file get reflected here through a refresh process. + * For the short term, the refresh process will only be runnable by Google + * engineers. + * + * The only allowed edits are to method and file documentation. A 3-way + * merge preserves those additions if the generated source changes. + */ +/* TODO: introduce line-wrapping so that it never exceeds the limit. */ +/* jscs: disable maximumLineLength */ +'use strict'; + +var configData = require('./metric_service_client_config'); +var extend = require('extend'); +var gax = require('google-gax'); + +var SERVICE_ADDRESS = 'monitoring.googleapis.com'; + +var DEFAULT_SERVICE_PORT = 443; + +var CODE_GEN_NAME_VERSION = 'gapic/0.1.0'; + + +var PAGE_DESCRIPTORS = { + listMonitoredResourceDescriptors: new gax.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'resourceDescriptors'), + listMetricDescriptors: new gax.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'metricDescriptors'), + listTimeSeries: new gax.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'timeSeries') +}; + +/** + * The scopes needed to make gRPC calls to all of the methods defined in + * this service. + */ +var ALL_SCOPES = [ +]; + +/** + * Manages metric descriptors, monitored resource descriptors, and + * time series data. + * + * This will be created through a builder function which can be obtained by the module. + * See the following example of how to initialize the module and how to access to the builder. + * @see {@link metricServiceApi} + * + * @example + * var monitoringV3 = require('@google-cloud/monitoring').v3({ + * // optional auth parameters. + * }); + * var api = monitoringV3.metricServiceApi(); + * + * @class + */ +function MetricServiceApi(gaxGrpc, grpcClients, opts) { + opts = opts || {}; + var servicePath = opts.servicePath || SERVICE_ADDRESS; + var port = opts.port || DEFAULT_SERVICE_PORT; + var sslCreds = opts.sslCreds || null; + var clientConfig = opts.clientConfig || {}; + var appName = opts.appName || 'gax'; + var appVersion = opts.appVersion || gax.version; + + var googleApiClient = [ + appName + '/' + appVersion, + CODE_GEN_NAME_VERSION, + 'gax/' + gax.version, + 'nodejs/' + process.version].join(' '); + + var defaults = gaxGrpc.constructSettings( + 'google.monitoring.v3.MetricService', + configData, + clientConfig, + PAGE_DESCRIPTORS, + null, + {'x-goog-api-client': googleApiClient}); + + var metricServiceStub = gaxGrpc.createStub( + servicePath, + port, + grpcClients.metricServiceClient.google.monitoring.v3.MetricService, + {sslCreds: sslCreds}); + var metricServiceStubMethods = [ + 'listMonitoredResourceDescriptors', + 'getMonitoredResourceDescriptor', + 'listMetricDescriptors', + 'getMetricDescriptor', + 'createMetricDescriptor', + 'deleteMetricDescriptor', + 'listTimeSeries', + 'createTimeSeries' + ]; + metricServiceStubMethods.forEach(function(methodName) { + this['_' + methodName] = gax.createApiCall( + metricServiceStub.then(function(metricServiceStub) { + return metricServiceStub[methodName].bind(metricServiceStub); + }), + defaults[methodName]); + }.bind(this)); +} + +// Path templates + +var PROJECT_PATH_TEMPLATE = new gax.PathTemplate( + 'projects/{project}'); + +var METRIC_DESCRIPTOR_PATH_PATH_TEMPLATE = new gax.PathTemplate( + 'projects/{project}/metricDescriptors/{metric_descriptor_path=**}'); + +var MONITORED_RESOURCE_DESCRIPTOR_PATH_TEMPLATE = new gax.PathTemplate( + 'projects/{project}/monitoredResourceDescriptors/{monitored_resource_descriptor}'); + +/** + * Returns a fully-qualified project resource name string. + * @param {String} project + * @returns {String} + */ +MetricServiceApi.prototype.projectPath = function projectPath(project) { + return PROJECT_PATH_TEMPLATE.render({ + project: project + }); +}; + +/** + * Parses the projectName from a project resource. + * @param {String} projectName + * A fully-qualified path representing a project resources. + * @returns {String} - A string representing the project. + */ +MetricServiceApi.prototype.matchProjectFromProjectName = + function matchProjectFromProjectName(projectName) { + return PROJECT_PATH_TEMPLATE.match(projectName).project; +}; + +/** + * Returns a fully-qualified metric_descriptor_path resource name string. + * @param {String} project + * @param {String} metric_descriptor_path + * @returns {String} + */ +MetricServiceApi.prototype.metricDescriptorPathPath = function metricDescriptorPathPath(project, metric_descriptor_path) { + return METRIC_DESCRIPTOR_PATH_PATH_TEMPLATE.render({ + project: project, + metric_descriptor_path: metric_descriptor_path + }); +}; + +/** + * Parses the metricDescriptorPathName from a metric_descriptor_path resource. + * @param {String} metricDescriptorPathName + * A fully-qualified path representing a metric_descriptor_path resources. + * @returns {String} - A string representing the project. + */ +MetricServiceApi.prototype.matchProjectFromMetricDescriptorPathName = + function matchProjectFromMetricDescriptorPathName(metricDescriptorPathName) { + return METRIC_DESCRIPTOR_PATH_PATH_TEMPLATE.match(metricDescriptorPathName).project; +}; + +/** + * Parses the metricDescriptorPathName from a metric_descriptor_path resource. + * @param {String} metricDescriptorPathName + * A fully-qualified path representing a metric_descriptor_path resources. + * @returns {String} - A string representing the metric_descriptor_path. + */ +MetricServiceApi.prototype.matchMetricDescriptorPathFromMetricDescriptorPathName = + function matchMetricDescriptorPathFromMetricDescriptorPathName(metricDescriptorPathName) { + return METRIC_DESCRIPTOR_PATH_PATH_TEMPLATE.match(metricDescriptorPathName).metric_descriptor_path; +}; + +/** + * Returns a fully-qualified monitored_resource_descriptor resource name string. + * @param {String} project + * @param {String} monitored_resource_descriptor + * @returns {String} + */ +MetricServiceApi.prototype.monitoredResourceDescriptorPath = function monitoredResourceDescriptorPath(project, monitored_resource_descriptor) { + return MONITORED_RESOURCE_DESCRIPTOR_PATH_TEMPLATE.render({ + project: project, + monitored_resource_descriptor: monitored_resource_descriptor + }); +}; + +/** + * Parses the monitoredResourceDescriptorName from a monitored_resource_descriptor resource. + * @param {String} monitoredResourceDescriptorName + * A fully-qualified path representing a monitored_resource_descriptor resources. + * @returns {String} - A string representing the project. + */ +MetricServiceApi.prototype.matchProjectFromMonitoredResourceDescriptorName = + function matchProjectFromMonitoredResourceDescriptorName(monitoredResourceDescriptorName) { + return MONITORED_RESOURCE_DESCRIPTOR_PATH_TEMPLATE.match(monitoredResourceDescriptorName).project; +}; + +/** + * Parses the monitoredResourceDescriptorName from a monitored_resource_descriptor resource. + * @param {String} monitoredResourceDescriptorName + * A fully-qualified path representing a monitored_resource_descriptor resources. + * @returns {String} - A string representing the monitored_resource_descriptor. + */ +MetricServiceApi.prototype.matchMonitoredResourceDescriptorFromMonitoredResourceDescriptorName = + function matchMonitoredResourceDescriptorFromMonitoredResourceDescriptorName(monitoredResourceDescriptorName) { + return MONITORED_RESOURCE_DESCRIPTOR_PATH_TEMPLATE.match(monitoredResourceDescriptorName).monitored_resource_descriptor; +}; + +// Service calls + +/** + * Lists monitored resource descriptors that match a filter. This method does not require a Stackdriver account. + * + * @param {string} name + * The project on which to execute the request. The format is + * `"projects/{project_id_or_number}"`. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, e.g, timeout, + * retries, paginations, etc. See [gax.CallOptions]{@link https://googleapis.github.io/gax-nodejs/global.html#CallOptions} for the details. + * + * In addition, options may contain the following optional parameters. + * @param {string=} options.filter + * An optional [filter](https://cloud.google.com/monitoring/api/v3/filters) describing + * the descriptors to be returned. The filter can reference + * the descriptor's type and labels. For example, the + * following filter returns only Google Compute Engine descriptors + * that have an `id` label: + * + * resource.type = starts_with("gce_") AND resource.label:id + * @param {number=} options.pageSize + * The maximum number of resources contained in the underlying API + * response. If page streaming is performed per-resource, this + * parameter does not affect the return value. If page streaming is + * performed per-page, this determines the maximum number of + * resources in a page. + * + * @param {function(?Error, ?Object, ?string)=} callback + * When specified, the results are not streamed but this callback + * will be called with the response object representing [ListMonitoredResourceDescriptorsResponse]{@link ListMonitoredResourceDescriptorsResponse}. + * The third item will be set if the response contains the token for the further results + * and can be reused to `pageToken` field in the options in the next request. + * @returns {Stream|gax.EventEmitter} + * An object stream which emits an object representing + * [google.api.MonitoredResourceDescriptor]{@link external:"google.api.MonitoredResourceDescriptor"} on 'data' event. + * When the callback is specified or streaming is suppressed through options, + * it will return an event emitter to handle the call status and the callback + * will be called with the response object. + * + * @example + * + * var api = monitoringV3.metricServiceApi(); + * var formattedName = api.projectPath("[PROJECT]"); + * // Iterate over all elements. + * api.listMonitoredResourceDescriptors(formattedName).on('data', function(element) { + * // doThingsWith(element) + * }); + * + * // Or obtain the paged response through the callback. + * function callback(err, response, nextPageToken) { + * if (err) { + * console.error(err); + * return; + * } + * // doThingsWith(response) + * if (nextPageToken) { + * // fetch the next page. + * api.listMonitoredResourceDescriptors(formattedName, {pageToken: nextPageToken}, callback); + * } + * } + * api.listMonitoredResourceDescriptors(formattedName, {flattenPages: false}, callback); + */ +MetricServiceApi.prototype.listMonitoredResourceDescriptors = function listMonitoredResourceDescriptors( + name, + options, + callback) { + if (options instanceof Function && callback === undefined) { + callback = options; + options = {}; + } + if (options === undefined) { + options = {}; + } + var req = { + name: name + }; + if ('filter' in options) { + req.filter = options.filter; + } + if ('pageSize' in options) { + req.pageSize = options.pageSize; + } + return this._listMonitoredResourceDescriptors(req, options, callback); +}; + +/** + * Gets a single monitored resource descriptor. This method does not require a Stackdriver account. + * + * @param {string} name + * The monitored resource descriptor to get. The format is + * `"projects/{project_id_or_number}/monitoredResourceDescriptors/{resource_type}"`. + * The `{resource_type}` is a predefined type, such as + * `cloudsql_database`. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, e.g, timeout, + * retries, paginations, etc. See [gax.CallOptions]{@link https://googleapis.github.io/gax-nodejs/global.html#CallOptions} for the details. + * @param {function(?Error, ?Object)=} callback + * The function which will be called with the result of the API call. + * + * The second parameter to the callback is an object representing [google.api.MonitoredResourceDescriptor]{@link external:"google.api.MonitoredResourceDescriptor"} + * @returns {gax.EventEmitter} - the event emitter to handle the call + * status. + * + * @example + * + * var api = monitoringV3.metricServiceApi(); + * var formattedName = api.monitoredResourceDescriptorPath("[PROJECT]", "[MONITORED_RESOURCE_DESCRIPTOR]"); + * api.getMonitoredResourceDescriptor(formattedName, function(err, response) { + * if (err) { + * console.error(err); + * return; + * } + * // doThingsWith(response) + * }); + */ +MetricServiceApi.prototype.getMonitoredResourceDescriptor = function getMonitoredResourceDescriptor( + name, + options, + callback) { + if (options instanceof Function && callback === undefined) { + callback = options; + options = {}; + } + if (options === undefined) { + options = {}; + } + var req = { + name: name + }; + return this._getMonitoredResourceDescriptor(req, options, callback); +}; + +/** + * Lists metric descriptors that match a filter. This method does not require a Stackdriver account. + * + * @param {string} name + * The project on which to execute the request. The format is + * `"projects/{project_id_or_number}"`. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, e.g, timeout, + * retries, paginations, etc. See [gax.CallOptions]{@link https://googleapis.github.io/gax-nodejs/global.html#CallOptions} for the details. + * + * In addition, options may contain the following optional parameters. + * @param {string=} options.filter + * If this field is empty, all custom and + * system-defined metric descriptors are returned. + * Otherwise, the [filter](https://cloud.google.com/monitoring/api/v3/filters) + * specifies which metric descriptors are to be + * returned. For example, the following filter matches all + * [custom metrics](https://cloud.google.com/monitoring/custom-metrics): + * + * metric.type = starts_with("custom.googleapis.com/") + * @param {number=} options.pageSize + * The maximum number of resources contained in the underlying API + * response. If page streaming is performed per-resource, this + * parameter does not affect the return value. If page streaming is + * performed per-page, this determines the maximum number of + * resources in a page. + * + * @param {function(?Error, ?Object, ?string)=} callback + * When specified, the results are not streamed but this callback + * will be called with the response object representing [ListMetricDescriptorsResponse]{@link ListMetricDescriptorsResponse}. + * The third item will be set if the response contains the token for the further results + * and can be reused to `pageToken` field in the options in the next request. + * @returns {Stream|gax.EventEmitter} + * An object stream which emits an object representing + * [google.api.MetricDescriptor]{@link external:"google.api.MetricDescriptor"} on 'data' event. + * When the callback is specified or streaming is suppressed through options, + * it will return an event emitter to handle the call status and the callback + * will be called with the response object. + * + * @example + * + * var api = monitoringV3.metricServiceApi(); + * var formattedName = api.projectPath("[PROJECT]"); + * // Iterate over all elements. + * api.listMetricDescriptors(formattedName).on('data', function(element) { + * // doThingsWith(element) + * }); + * + * // Or obtain the paged response through the callback. + * function callback(err, response, nextPageToken) { + * if (err) { + * console.error(err); + * return; + * } + * // doThingsWith(response) + * if (nextPageToken) { + * // fetch the next page. + * api.listMetricDescriptors(formattedName, {pageToken: nextPageToken}, callback); + * } + * } + * api.listMetricDescriptors(formattedName, {flattenPages: false}, callback); + */ +MetricServiceApi.prototype.listMetricDescriptors = function listMetricDescriptors( + name, + options, + callback) { + if (options instanceof Function && callback === undefined) { + callback = options; + options = {}; + } + if (options === undefined) { + options = {}; + } + var req = { + name: name + }; + if ('filter' in options) { + req.filter = options.filter; + } + if ('pageSize' in options) { + req.pageSize = options.pageSize; + } + return this._listMetricDescriptors(req, options, callback); +}; + +/** + * Gets a single metric descriptor. This method does not require a Stackdriver account. + * + * @param {string} name + * The metric descriptor on which to execute the request. The format is + * `"projects/{project_id_or_number}/metricDescriptors/{metric_id}"`. + * An example value of `{metric_id}` is + * `"compute.googleapis.com/instance/disk/read_bytes_count"`. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, e.g, timeout, + * retries, paginations, etc. See [gax.CallOptions]{@link https://googleapis.github.io/gax-nodejs/global.html#CallOptions} for the details. + * @param {function(?Error, ?Object)=} callback + * The function which will be called with the result of the API call. + * + * The second parameter to the callback is an object representing [google.api.MetricDescriptor]{@link external:"google.api.MetricDescriptor"} + * @returns {gax.EventEmitter} - the event emitter to handle the call + * status. + * + * @example + * + * var api = monitoringV3.metricServiceApi(); + * var formattedName = api.metricDescriptorPathPath("[PROJECT]", "[METRIC_DESCRIPTOR_PATH]"); + * api.getMetricDescriptor(formattedName, function(err, response) { + * if (err) { + * console.error(err); + * return; + * } + * // doThingsWith(response) + * }); + */ +MetricServiceApi.prototype.getMetricDescriptor = function getMetricDescriptor( + name, + options, + callback) { + if (options instanceof Function && callback === undefined) { + callback = options; + options = {}; + } + if (options === undefined) { + options = {}; + } + var req = { + name: name + }; + return this._getMetricDescriptor(req, options, callback); +}; + +/** + * Creates a new metric descriptor. + * User-created metric descriptors define + * [custom metrics](https://cloud.google.com/monitoring/custom-metrics). + * + * @param {string} name + * The project on which to execute the request. The format is + * `"projects/{project_id_or_number}"`. + * @param {Object} metricDescriptor + * The new [custom metric](https://cloud.google.com/monitoring/custom-metrics) + * descriptor. + * + * This object should have the same structure as [google.api.MetricDescriptor]{@link external:"google.api.MetricDescriptor"} + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, e.g, timeout, + * retries, paginations, etc. See [gax.CallOptions]{@link https://googleapis.github.io/gax-nodejs/global.html#CallOptions} for the details. + * @param {function(?Error, ?Object)=} callback + * The function which will be called with the result of the API call. + * + * The second parameter to the callback is an object representing [google.api.MetricDescriptor]{@link external:"google.api.MetricDescriptor"} + * @returns {gax.EventEmitter} - the event emitter to handle the call + * status. + * + * @example + * + * var api = monitoringV3.metricServiceApi(); + * var formattedName = api.projectPath("[PROJECT]"); + * var metricDescriptor = {}; + * api.createMetricDescriptor(formattedName, metricDescriptor, function(err, response) { + * if (err) { + * console.error(err); + * return; + * } + * // doThingsWith(response) + * }); + */ +MetricServiceApi.prototype.createMetricDescriptor = function createMetricDescriptor( + name, + metricDescriptor, + options, + callback) { + if (options instanceof Function && callback === undefined) { + callback = options; + options = {}; + } + if (options === undefined) { + options = {}; + } + var req = { + name: name, + metricDescriptor: metricDescriptor + }; + return this._createMetricDescriptor(req, options, callback); +}; + +/** + * Deletes a metric descriptor. Only user-created + * [custom metrics](https://cloud.google.com/monitoring/custom-metrics) can be deleted. + * + * @param {string} name + * The metric descriptor on which to execute the request. The format is + * `"projects/{project_id_or_number}/metricDescriptors/{metric_id}"`. + * An example of `{metric_id}` is: + * `"custom.googleapis.com/my_test_metric"`. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, e.g, timeout, + * retries, paginations, etc. See [gax.CallOptions]{@link https://googleapis.github.io/gax-nodejs/global.html#CallOptions} for the details. + * @param {function(?Error)=} callback + * The function which will be called with the result of the API call. + * @returns {gax.EventEmitter} - the event emitter to handle the call + * status. + * + * @example + * + * var api = monitoringV3.metricServiceApi(); + * var formattedName = api.metricDescriptorPathPath("[PROJECT]", "[METRIC_DESCRIPTOR_PATH]"); + * api.deleteMetricDescriptor(formattedName, function(err) { + * if (err) { + * console.error(err); + * } + * }); + */ +MetricServiceApi.prototype.deleteMetricDescriptor = function deleteMetricDescriptor( + name, + options, + callback) { + if (options instanceof Function && callback === undefined) { + callback = options; + options = {}; + } + if (options === undefined) { + options = {}; + } + var req = { + name: name + }; + return this._deleteMetricDescriptor(req, options, callback); +}; + +/** + * Lists time series that match a filter. This method does not require a Stackdriver account. + * + * @param {string} name + * The project on which to execute the request. The format is + * "projects/{project_id_or_number}". + * @param {string} filter + * A [monitoring filter](https://cloud.google.com/monitoring/api/v3/filters) that specifies which time + * series should be returned. The filter must specify a single metric type, + * and can additionally specify metric labels and other information. For + * example: + * + * metric.type = "compute.googleapis.com/instance/cpu/usage_time" AND + * metric.label.instance_name = "my-instance-name" + * @param {Object} interval + * The time interval for which results should be returned. Only time series + * that contain data points in the specified interval are included + * in the response. + * + * This object should have the same structure as [TimeInterval]{@link TimeInterval} + * @param {number} view + * Specifies which information is returned about the time series. + * + * The number should be among the values of [TimeSeriesView]{@link TimeSeriesView} + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, e.g, timeout, + * retries, paginations, etc. See [gax.CallOptions]{@link https://googleapis.github.io/gax-nodejs/global.html#CallOptions} for the details. + * + * In addition, options may contain the following optional parameters. + * @param {Object=} options.aggregation + * By default, the raw time series data is returned. + * Use this field to combine multiple time series for different + * views of the data. + * + * This object should have the same structure as [Aggregation]{@link Aggregation} + * @param {string=} options.orderBy + * Specifies the order in which the points of the time series should + * be returned. By default, results are not ordered. Currently, + * this field must be left blank. + * @param {number=} options.pageSize + * The maximum number of resources contained in the underlying API + * response. If page streaming is performed per-resource, this + * parameter does not affect the return value. If page streaming is + * performed per-page, this determines the maximum number of + * resources in a page. + * + * @param {function(?Error, ?Object, ?string)=} callback + * When specified, the results are not streamed but this callback + * will be called with the response object representing [ListTimeSeriesResponse]{@link ListTimeSeriesResponse}. + * The third item will be set if the response contains the token for the further results + * and can be reused to `pageToken` field in the options in the next request. + * @returns {Stream|gax.EventEmitter} + * An object stream which emits an object representing + * [TimeSeries]{@link TimeSeries} on 'data' event. + * When the callback is specified or streaming is suppressed through options, + * it will return an event emitter to handle the call status and the callback + * will be called with the response object. + * + * @example + * + * var api = monitoringV3.metricServiceApi(); + * var formattedName = api.projectPath("[PROJECT]"); + * var filter = ''; + * var interval = {}; + * var view = TimeSeriesView.FULL; + * // Iterate over all elements. + * api.listTimeSeries(formattedName, filter, interval, view).on('data', function(element) { + * // doThingsWith(element) + * }); + * + * // Or obtain the paged response through the callback. + * function callback(err, response, nextPageToken) { + * if (err) { + * console.error(err); + * return; + * } + * // doThingsWith(response) + * if (nextPageToken) { + * // fetch the next page. + * api.listTimeSeries(formattedName, filter, interval, view, {pageToken: nextPageToken}, callback); + * } + * } + * api.listTimeSeries(formattedName, filter, interval, view, {flattenPages: false}, callback); + */ +MetricServiceApi.prototype.listTimeSeries = function listTimeSeries( + name, + filter, + interval, + view, + options, + callback) { + if (options instanceof Function && callback === undefined) { + callback = options; + options = {}; + } + if (options === undefined) { + options = {}; + } + var req = { + name: name, + filter: filter, + interval: interval, + view: view + }; + if ('aggregation' in options) { + req.aggregation = options.aggregation; + } + if ('orderBy' in options) { + req.orderBy = options.orderBy; + } + if ('pageSize' in options) { + req.pageSize = options.pageSize; + } + return this._listTimeSeries(req, options, callback); +}; + +/** + * Creates or adds data to one or more time series. + * The response is empty if all time series in the request were written. + * If any time series could not be written, a corresponding failure message is + * included in the error response. + * + * @param {string} name + * The project on which to execute the request. The format is + * `"projects/{project_id_or_number}"`. + * @param {Object[]} timeSeries + * The new data to be added to a list of time series. + * Adds at most one data point to each of several time series. The new data + * point must be more recent than any other point in its time series. Each + * `TimeSeries` value must fully specify a unique time series by supplying + * all label values for the metric and the monitored resource. + * + * This object should have the same structure as [TimeSeries]{@link TimeSeries} + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, e.g, timeout, + * retries, paginations, etc. See [gax.CallOptions]{@link https://googleapis.github.io/gax-nodejs/global.html#CallOptions} for the details. + * @param {function(?Error)=} callback + * The function which will be called with the result of the API call. + * @returns {gax.EventEmitter} - the event emitter to handle the call + * status. + * + * @example + * + * var api = monitoringV3.metricServiceApi(); + * var formattedName = api.projectPath("[PROJECT]"); + * var timeSeries = []; + * api.createTimeSeries(formattedName, timeSeries, function(err) { + * if (err) { + * console.error(err); + * } + * }); + */ +MetricServiceApi.prototype.createTimeSeries = function createTimeSeries( + name, + timeSeries, + options, + callback) { + if (options instanceof Function && callback === undefined) { + callback = options; + options = {}; + } + if (options === undefined) { + options = {}; + } + var req = { + name: name, + timeSeries: timeSeries + }; + return this._createTimeSeries(req, options, callback); +}; + +function MetricServiceApiBuilder(gaxGrpc) { + if (!(this instanceof MetricServiceApiBuilder)) { + return new MetricServiceApiBuilder(gaxGrpc); + } + + var metricServiceClient = gaxGrpc.load([{ + root: require('google-proto-files')('..'), + file: 'google/monitoring/v3/metric_service.proto' + }]); + extend(this, metricServiceClient.google.monitoring.v3); + + var grpcClients = { + metricServiceClient: metricServiceClient + }; + + /** + * Build a new instance of {@link MetricServiceApi}. + * + * @param {Object=} opts - The optional parameters. + * @param {String=} opts.servicePath + * The domain name of the API remote host. + * @param {number=} opts.port + * The port on which to connect to the remote host. + * @param {grpc.ClientCredentials=} opts.sslCreds + * A ClientCredentials for use with an SSL-enabled channel. + * @param {Object=} opts.clientConfig + * The customized config to build the call settings. See + * {@link gax.constructSettings} for the format. + * @param {number=} opts.appName + * The codename of the calling service. + * @param {String=} opts.appVersion + * The version of the calling service. + */ + this.metricServiceApi = function(opts) { + return new MetricServiceApi(gaxGrpc, grpcClients, opts); + }; + extend(this.metricServiceApi, MetricServiceApi); +} +module.exports = MetricServiceApiBuilder; +module.exports.SERVICE_ADDRESS = SERVICE_ADDRESS; +module.exports.ALL_SCOPES = ALL_SCOPES; \ No newline at end of file diff --git a/packages/monitoring/src/v3/metric_service_client_config.json b/packages/monitoring/src/v3/metric_service_client_config.json new file mode 100644 index 00000000000..4ec14c73bde --- /dev/null +++ b/packages/monitoring/src/v3/metric_service_client_config.json @@ -0,0 +1,68 @@ +{ + "interfaces": { + "google.monitoring.v3.MetricService": { + "retry_codes": { + "retry_codes_def": { + "idempotent": [ + "DEADLINE_EXCEEDED", + "UNAVAILABLE" + ], + "non_idempotent": [] + } + }, + "retry_params": { + "default": { + "initial_retry_delay_millis": 100, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 60000, + "initial_rpc_timeout_millis": 20000, + "rpc_timeout_multiplier": 1.0, + "max_rpc_timeout_millis": 20000, + "total_timeout_millis": 600000 + } + }, + "methods": { + "ListMonitoredResourceDescriptors": { + "timeout_millis": 60000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "GetMonitoredResourceDescriptor": { + "timeout_millis": 60000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "ListMetricDescriptors": { + "timeout_millis": 60000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "GetMetricDescriptor": { + "timeout_millis": 60000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "CreateMetricDescriptor": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "DeleteMetricDescriptor": { + "timeout_millis": 60000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "ListTimeSeries": { + "timeout_millis": 60000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "CreateTimeSeries": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + } + } + } + } +} From dfa329fc75e43f653e6b725446ab994c8f5d5cb9 Mon Sep 17 00:00:00 2001 From: Ernest Landrito Date: Mon, 3 Oct 2016 14:14:58 -0700 Subject: [PATCH 2/6] Revisions as per review. --- packages/monitoring/LICENSE | 201 ---------------------------- packages/monitoring/README.md | 75 +++++++---- packages/monitoring/package.json | 57 +++++++- packages/monitoring/src/v3/index.js | 6 +- 4 files changed, 101 insertions(+), 238 deletions(-) delete mode 100644 packages/monitoring/LICENSE diff --git a/packages/monitoring/LICENSE b/packages/monitoring/LICENSE deleted file mode 100644 index 724a8807144..00000000000 --- a/packages/monitoring/LICENSE +++ /dev/null @@ -1,201 +0,0 @@ - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. diff --git a/packages/monitoring/README.md b/packages/monitoring/README.md index 68f88201532..55bb3b6fafe 100644 --- a/packages/monitoring/README.md +++ b/packages/monitoring/README.md @@ -1,45 +1,68 @@ -Stackdriver Monitoring API for Node.js -================================================= +# @google-cloud/monitoring +> Stackdriver Monitoring Client Library for Node.js -@google-cloud/monitoring uses [Google API extensions][google-gax] to provide an -easy-to-use client library for the [Stackdriver Monitoring API][] (v3) defined in the [googleapis][] git repository +*Looking for more Google APIs than just Monitoring? You might want to check out [`google-cloud`][google-cloud].* +- [Official Documentation][cloud-monitoring-docs] -[googleapis]: https://github.com/googleapis/googleapis/tree/master/google/google/monitoring/v3 -[google-gax]: https://github.com/googleapis/gax-nodejs -[Stackdriver Monitoring API]: https://developers.google.com/apis-explorer/#p/monitoring/v3/ -Getting started ---------------- +```sh +$ npm install --save @google-cloud/monitoring +``` +```js +var monitoring = require('@google-cloud/monitoring').v3({ + projectId: 'grape-spaceship-123', + keyFilename: '/path/to/keyfile.json' +}); +``` -@google-cloud/monitoring will allow you to connect to the [Stackdriver Monitoring API][] and access all its methods. -In order to do so, you need to set up authentication as well as install the library locally. +## Authentication +It's incredibly easy to get authenticated and start using Google's APIs. You can set your credentials on a global basis as well as on a per-API basis. See each individual API section below to see how you can auth on a per-API-basis. This is useful if you want to use different accounts for different Google Cloud services. -Setup Authentication --------------------- +### On Google Compute Engine -To authenticate all your API calls, first install and setup the [Google Cloud SDK][]. -Once done, you can then run the following command in your terminal: +If you are running this client on Google Compute Engine, we handle authentication for you with no configuration. You just need to make sure that when you [set up the GCE instance][gce-how-to], you add the correct scopes for the APIs you want to access. - $ gcloud beta auth application-default login +``` js +// Authenticating on a global basis. +var projectId = process.env.GCLOUD_PROJECT; // E.g. 'grape-spaceship-123' -or +var monitoring = require('@google-cloud/monitoring').v3({ + projectId: projectId +}); - $ gcloud auth login +// ...you're good to go! +``` -Please see [[gcloud beta auth application-default login][] document for the difference between these commands. +### Elsewhere -[Google Cloud SDK]: https://cloud.google.com/sdk/ -[gcloud beta auth application-default login]: https://cloud.google.com/sdk/gcloud/reference/beta/auth/application-default/login +If you are not running this client on Google Compute Engine, you need a Google Developers service account. To create a service account: +1. Visit the [Google Developers Console][dev-console]. +2. Create a new project or click on an existing project. +3. Navigate to **APIs & auth** > **Credentials** and then: + * If you want to use a new service account, click on **Create new Client ID** and select **Service account**. After the account is created, you will be prompted to download the JSON key file that the library uses to authenticate your requests. + * If you want to generate a new key for an existing service account, click on **Generate new JSON key** and download the JSON key file. -Installation -------------------- +``` js +var projectId = process.env.GCLOUD_PROJECT; // E.g. 'grape-spaceship-123' -Install this library using npm: +var monitoring = require('@google-cloud/monitoring')({ + projectId: projectId, - $ npm install @google-cloud/monitoring + // The path to your key file: + keyFilename: '/path/to/keyfile.json' -At this point you are all set to continue. + // Or the contents of the key file: + credentials: require('./path/to/keyfile.json') +}); + +// ...you're good to go! +``` + +[google-cloud]: https://github.com/GoogleCloudPlatform/google-cloud-node/ +[gce-how-to]: https://cloud.google.com/compute/docs/authentication#using +[dev-console]: https://console.developers.google.com/project +[cloud-monitoring-docs]: https://cloud.google.com/monitoring/docs diff --git a/packages/monitoring/package.json b/packages/monitoring/package.json index a7da28f138d..5b30d530c95 100644 --- a/packages/monitoring/package.json +++ b/packages/monitoring/package.json @@ -1,18 +1,63 @@ { - "url": "https://github.com/googleapis/googleapis", + "repository": "googlecloudplatform/google-cloud-node", "name": "@google-cloud/monitoring", - "version": "0.7.1", + "version": "0.0.0", "author": "Google Inc.", - "description": "Stackdriver Monitoring library for Node.js", + "description": "Stackdriver Monitoring Client Library for Node.js", + "contributors": [ + { + "name": "Burcu Dogan", + "email": "jbd@google.com" + }, + { + "name": "Johan Euphrosine", + "email": "proppy@google.com" + }, + { + "name": "Patrick Costello", + "email": "pcostell@google.com" + }, + { + "name": "Ryan Seys", + "email": "ryan@ryanseys.com" + }, + { + "name": "Silvano Luciani", + "email": "silvano@google.com" + }, + { + "name": "Stephen Sawchuk", + "email": "sawchuk@gmail.com" + } + ], "main": "src/index.js", "files": [ - "src" + "src", + "AUTHORS", + "CONTRIBUTING", + "COPYING" + ], + "keywords": [ + "google apis client", + "google api client", + "google apis", + "google api", + "google", + "google cloud platform", + "google cloud", + "cloud", + "google monitoring", + "monitoring", + "stackdriver monitoring", + "stackdriver" ], "dependencies": { "google-proto-files": "^0.8.2", "google-gax": "^0.7.0", - "extend": "^3.0.0", - "lodash.union": "^4.6.0" + "extend": "^3.0.0" + }, + "scripts": { + "publish-module": "node ../../scripts/publish.js logging" }, "license": "Apache-2.0", "engines": { diff --git a/packages/monitoring/src/v3/index.js b/packages/monitoring/src/v3/index.js index 2bc63917f04..3012e995ff0 100644 --- a/packages/monitoring/src/v3/index.js +++ b/packages/monitoring/src/v3/index.js @@ -19,7 +19,6 @@ var groupServiceApi = require('./group_service_api'); var metricServiceApi = require('./metric_service_api'); var gax = require('google-gax'); var extend = require('extend'); -var union = require('lodash.union'); function v3(options) { options = extend({ @@ -32,8 +31,5 @@ function v3(options) { return result; } v3.SERVICE_ADDRESS = groupServiceApi.SERVICE_ADDRESS; -v3.ALL_SCOPES = union( - groupServiceApi.ALL_SCOPES, - metricServiceApi.ALL_SCOPES -); +v3.ALL_SCOPES = []; module.exports = v3; From c825ff851f6e8c91d91b0e5b14dac4bc9541b58e Mon Sep 17 00:00:00 2001 From: Ernest Landrito Date: Tue, 4 Oct 2016 18:30:06 -0700 Subject: [PATCH 3/6] Regenerated per toolkit revisions --- .../monitoring/src/v3/group_service_api.js | 25 +++---- packages/monitoring/src/v3/index.js | 2 +- .../monitoring/src/v3/metric_service_api.js | 73 +++++++++---------- 3 files changed, 46 insertions(+), 54 deletions(-) diff --git a/packages/monitoring/src/v3/group_service_api.js b/packages/monitoring/src/v3/group_service_api.js index 2db6bbb6bfb..6951426d977 100644 --- a/packages/monitoring/src/v3/group_service_api.js +++ b/packages/monitoring/src/v3/group_service_api.js @@ -140,7 +140,7 @@ var GROUP_PATH_TEMPLATE = new gax.PathTemplate( * @param {String} project * @returns {String} */ -GroupServiceApi.prototype.projectPath = function projectPath(project) { +GroupServiceApi.prototype.projectPath = function(project) { return PROJECT_PATH_TEMPLATE.render({ project: project }); @@ -152,8 +152,7 @@ GroupServiceApi.prototype.projectPath = function projectPath(project) { * A fully-qualified path representing a project resources. * @returns {String} - A string representing the project. */ -GroupServiceApi.prototype.matchProjectFromProjectName = - function matchProjectFromProjectName(projectName) { +GroupServiceApi.prototype.matchProjectFromProjectName = function(projectName) { return PROJECT_PATH_TEMPLATE.match(projectName).project; }; @@ -163,7 +162,7 @@ GroupServiceApi.prototype.matchProjectFromProjectName = * @param {String} group * @returns {String} */ -GroupServiceApi.prototype.groupPath = function groupPath(project, group) { +GroupServiceApi.prototype.groupPath = function(project, group) { return GROUP_PATH_TEMPLATE.render({ project: project, group: group @@ -176,8 +175,7 @@ GroupServiceApi.prototype.groupPath = function groupPath(project, group) { * A fully-qualified path representing a group resources. * @returns {String} - A string representing the project. */ -GroupServiceApi.prototype.matchProjectFromGroupName = - function matchProjectFromGroupName(groupName) { +GroupServiceApi.prototype.matchProjectFromGroupName = function(groupName) { return GROUP_PATH_TEMPLATE.match(groupName).project; }; @@ -187,8 +185,7 @@ GroupServiceApi.prototype.matchProjectFromGroupName = * A fully-qualified path representing a group resources. * @returns {String} - A string representing the group. */ -GroupServiceApi.prototype.matchGroupFromGroupName = - function matchGroupFromGroupName(groupName) { +GroupServiceApi.prototype.matchGroupFromGroupName = function(groupName) { return GROUP_PATH_TEMPLATE.match(groupName).group; }; @@ -262,7 +259,7 @@ GroupServiceApi.prototype.matchGroupFromGroupName = * } * api.listGroups(formattedName, {flattenPages: false}, callback); */ -GroupServiceApi.prototype.listGroups = function listGroups( +GroupServiceApi.prototype.listGroups = function( name, options, callback) { @@ -319,7 +316,7 @@ GroupServiceApi.prototype.listGroups = function listGroups( * // doThingsWith(response) * }); */ -GroupServiceApi.prototype.getGroup = function getGroup( +GroupServiceApi.prototype.getGroup = function( name, options, callback) { @@ -375,7 +372,7 @@ GroupServiceApi.prototype.getGroup = function getGroup( * // doThingsWith(response) * }); */ -GroupServiceApi.prototype.createGroup = function createGroup( +GroupServiceApi.prototype.createGroup = function( name, group, options, @@ -433,7 +430,7 @@ GroupServiceApi.prototype.createGroup = function createGroup( * // doThingsWith(response) * }); */ -GroupServiceApi.prototype.updateGroup = function updateGroup( +GroupServiceApi.prototype.updateGroup = function( group, options, callback) { @@ -477,7 +474,7 @@ GroupServiceApi.prototype.updateGroup = function updateGroup( * } * }); */ -GroupServiceApi.prototype.deleteGroup = function deleteGroup( +GroupServiceApi.prototype.deleteGroup = function( name, options, callback) { @@ -562,7 +559,7 @@ GroupServiceApi.prototype.deleteGroup = function deleteGroup( * } * api.listGroupMembers(formattedName, {flattenPages: false}, callback); */ -GroupServiceApi.prototype.listGroupMembers = function listGroupMembers( +GroupServiceApi.prototype.listGroupMembers = function( name, options, callback) { diff --git a/packages/monitoring/src/v3/index.js b/packages/monitoring/src/v3/index.js index 3012e995ff0..93e0ea10b98 100644 --- a/packages/monitoring/src/v3/index.js +++ b/packages/monitoring/src/v3/index.js @@ -31,5 +31,5 @@ function v3(options) { return result; } v3.SERVICE_ADDRESS = groupServiceApi.SERVICE_ADDRESS; -v3.ALL_SCOPES = []; +v3.ALL_SCOPES = []; module.exports = v3; diff --git a/packages/monitoring/src/v3/metric_service_api.js b/packages/monitoring/src/v3/metric_service_api.js index 4ea7af7febb..cc97a623f6f 100644 --- a/packages/monitoring/src/v3/metric_service_api.js +++ b/packages/monitoring/src/v3/metric_service_api.js @@ -128,8 +128,8 @@ function MetricServiceApi(gaxGrpc, grpcClients, opts) { var PROJECT_PATH_TEMPLATE = new gax.PathTemplate( 'projects/{project}'); -var METRIC_DESCRIPTOR_PATH_PATH_TEMPLATE = new gax.PathTemplate( - 'projects/{project}/metricDescriptors/{metric_descriptor_path=**}'); +var METRIC_DESCRIPTOR_PATH_TEMPLATE = new gax.PathTemplate( + 'projects/{project}/metricDescriptors/{metric_descriptor=**}'); var MONITORED_RESOURCE_DESCRIPTOR_PATH_TEMPLATE = new gax.PathTemplate( 'projects/{project}/monitoredResourceDescriptors/{monitored_resource_descriptor}'); @@ -139,7 +139,7 @@ var MONITORED_RESOURCE_DESCRIPTOR_PATH_TEMPLATE = new gax.PathTemplate( * @param {String} project * @returns {String} */ -MetricServiceApi.prototype.projectPath = function projectPath(project) { +MetricServiceApi.prototype.projectPath = function(project) { return PROJECT_PATH_TEMPLATE.render({ project: project }); @@ -151,44 +151,41 @@ MetricServiceApi.prototype.projectPath = function projectPath(project) { * A fully-qualified path representing a project resources. * @returns {String} - A string representing the project. */ -MetricServiceApi.prototype.matchProjectFromProjectName = - function matchProjectFromProjectName(projectName) { +MetricServiceApi.prototype.matchProjectFromProjectName = function(projectName) { return PROJECT_PATH_TEMPLATE.match(projectName).project; }; /** - * Returns a fully-qualified metric_descriptor_path resource name string. + * Returns a fully-qualified metric_descriptor resource name string. * @param {String} project - * @param {String} metric_descriptor_path + * @param {String} metric_descriptor * @returns {String} */ -MetricServiceApi.prototype.metricDescriptorPathPath = function metricDescriptorPathPath(project, metric_descriptor_path) { - return METRIC_DESCRIPTOR_PATH_PATH_TEMPLATE.render({ +MetricServiceApi.prototype.metricDescriptorPath = function(project, metricDescriptor) { + return METRIC_DESCRIPTOR_PATH_TEMPLATE.render({ project: project, - metric_descriptor_path: metric_descriptor_path + metric_descriptor: metricDescriptor }); }; /** - * Parses the metricDescriptorPathName from a metric_descriptor_path resource. - * @param {String} metricDescriptorPathName - * A fully-qualified path representing a metric_descriptor_path resources. + * Parses the metricDescriptorName from a metric_descriptor resource. + * @param {String} metricDescriptorName + * A fully-qualified path representing a metric_descriptor resources. * @returns {String} - A string representing the project. */ -MetricServiceApi.prototype.matchProjectFromMetricDescriptorPathName = - function matchProjectFromMetricDescriptorPathName(metricDescriptorPathName) { - return METRIC_DESCRIPTOR_PATH_PATH_TEMPLATE.match(metricDescriptorPathName).project; +MetricServiceApi.prototype.matchProjectFromMetricDescriptorName = function(metricDescriptorName) { + return METRIC_DESCRIPTOR_PATH_TEMPLATE.match(metricDescriptorName).project; }; /** - * Parses the metricDescriptorPathName from a metric_descriptor_path resource. - * @param {String} metricDescriptorPathName - * A fully-qualified path representing a metric_descriptor_path resources. - * @returns {String} - A string representing the metric_descriptor_path. + * Parses the metricDescriptorName from a metric_descriptor resource. + * @param {String} metricDescriptorName + * A fully-qualified path representing a metric_descriptor resources. + * @returns {String} - A string representing the metric_descriptor. */ -MetricServiceApi.prototype.matchMetricDescriptorPathFromMetricDescriptorPathName = - function matchMetricDescriptorPathFromMetricDescriptorPathName(metricDescriptorPathName) { - return METRIC_DESCRIPTOR_PATH_PATH_TEMPLATE.match(metricDescriptorPathName).metric_descriptor_path; +MetricServiceApi.prototype.matchMetricDescriptorFromMetricDescriptorName = function(metricDescriptorName) { + return METRIC_DESCRIPTOR_PATH_TEMPLATE.match(metricDescriptorName).metric_descriptor; }; /** @@ -197,10 +194,10 @@ MetricServiceApi.prototype.matchMetricDescriptorPathFromMetricDescriptorPathName * @param {String} monitored_resource_descriptor * @returns {String} */ -MetricServiceApi.prototype.monitoredResourceDescriptorPath = function monitoredResourceDescriptorPath(project, monitored_resource_descriptor) { +MetricServiceApi.prototype.monitoredResourceDescriptorPath = function(project, monitoredResourceDescriptor) { return MONITORED_RESOURCE_DESCRIPTOR_PATH_TEMPLATE.render({ project: project, - monitored_resource_descriptor: monitored_resource_descriptor + monitored_resource_descriptor: monitoredResourceDescriptor }); }; @@ -210,8 +207,7 @@ MetricServiceApi.prototype.monitoredResourceDescriptorPath = function monitoredR * A fully-qualified path representing a monitored_resource_descriptor resources. * @returns {String} - A string representing the project. */ -MetricServiceApi.prototype.matchProjectFromMonitoredResourceDescriptorName = - function matchProjectFromMonitoredResourceDescriptorName(monitoredResourceDescriptorName) { +MetricServiceApi.prototype.matchProjectFromMonitoredResourceDescriptorName = function(monitoredResourceDescriptorName) { return MONITORED_RESOURCE_DESCRIPTOR_PATH_TEMPLATE.match(monitoredResourceDescriptorName).project; }; @@ -221,8 +217,7 @@ MetricServiceApi.prototype.matchProjectFromMonitoredResourceDescriptorName = * A fully-qualified path representing a monitored_resource_descriptor resources. * @returns {String} - A string representing the monitored_resource_descriptor. */ -MetricServiceApi.prototype.matchMonitoredResourceDescriptorFromMonitoredResourceDescriptorName = - function matchMonitoredResourceDescriptorFromMonitoredResourceDescriptorName(monitoredResourceDescriptorName) { +MetricServiceApi.prototype.matchMonitoredResourceDescriptorFromMonitoredResourceDescriptorName = function(monitoredResourceDescriptorName) { return MONITORED_RESOURCE_DESCRIPTOR_PATH_TEMPLATE.match(monitoredResourceDescriptorName).monitored_resource_descriptor; }; @@ -289,7 +284,7 @@ MetricServiceApi.prototype.matchMonitoredResourceDescriptorFromMonitoredResource * } * api.listMonitoredResourceDescriptors(formattedName, {flattenPages: false}, callback); */ -MetricServiceApi.prototype.listMonitoredResourceDescriptors = function listMonitoredResourceDescriptors( +MetricServiceApi.prototype.listMonitoredResourceDescriptors = function( name, options, callback) { @@ -342,7 +337,7 @@ MetricServiceApi.prototype.listMonitoredResourceDescriptors = function listMonit * // doThingsWith(response) * }); */ -MetricServiceApi.prototype.getMonitoredResourceDescriptor = function getMonitoredResourceDescriptor( +MetricServiceApi.prototype.getMonitoredResourceDescriptor = function( name, options, callback) { @@ -421,7 +416,7 @@ MetricServiceApi.prototype.getMonitoredResourceDescriptor = function getMonitore * } * api.listMetricDescriptors(formattedName, {flattenPages: false}, callback); */ -MetricServiceApi.prototype.listMetricDescriptors = function listMetricDescriptors( +MetricServiceApi.prototype.listMetricDescriptors = function( name, options, callback) { @@ -465,7 +460,7 @@ MetricServiceApi.prototype.listMetricDescriptors = function listMetricDescriptor * @example * * var api = monitoringV3.metricServiceApi(); - * var formattedName = api.metricDescriptorPathPath("[PROJECT]", "[METRIC_DESCRIPTOR_PATH]"); + * var formattedName = api.metricDescriptorPath("[PROJECT]", "[METRIC_DESCRIPTOR]"); * api.getMetricDescriptor(formattedName, function(err, response) { * if (err) { * console.error(err); @@ -474,7 +469,7 @@ MetricServiceApi.prototype.listMetricDescriptors = function listMetricDescriptor * // doThingsWith(response) * }); */ -MetricServiceApi.prototype.getMetricDescriptor = function getMetricDescriptor( +MetricServiceApi.prototype.getMetricDescriptor = function( name, options, callback) { @@ -527,7 +522,7 @@ MetricServiceApi.prototype.getMetricDescriptor = function getMetricDescriptor( * // doThingsWith(response) * }); */ -MetricServiceApi.prototype.createMetricDescriptor = function createMetricDescriptor( +MetricServiceApi.prototype.createMetricDescriptor = function( name, metricDescriptor, options, @@ -566,14 +561,14 @@ MetricServiceApi.prototype.createMetricDescriptor = function createMetricDescrip * @example * * var api = monitoringV3.metricServiceApi(); - * var formattedName = api.metricDescriptorPathPath("[PROJECT]", "[METRIC_DESCRIPTOR_PATH]"); + * var formattedName = api.metricDescriptorPath("[PROJECT]", "[METRIC_DESCRIPTOR]"); * api.deleteMetricDescriptor(formattedName, function(err) { * if (err) { * console.error(err); * } * }); */ -MetricServiceApi.prototype.deleteMetricDescriptor = function deleteMetricDescriptor( +MetricServiceApi.prototype.deleteMetricDescriptor = function( name, options, callback) { @@ -674,7 +669,7 @@ MetricServiceApi.prototype.deleteMetricDescriptor = function deleteMetricDescrip * } * api.listTimeSeries(formattedName, filter, interval, view, {flattenPages: false}, callback); */ -MetricServiceApi.prototype.listTimeSeries = function listTimeSeries( +MetricServiceApi.prototype.listTimeSeries = function( name, filter, interval, @@ -742,7 +737,7 @@ MetricServiceApi.prototype.listTimeSeries = function listTimeSeries( * } * }); */ -MetricServiceApi.prototype.createTimeSeries = function createTimeSeries( +MetricServiceApi.prototype.createTimeSeries = function( name, timeSeries, options, From 7402338dd94c1f1853865fec2806b17d9a74a6fe Mon Sep 17 00:00:00 2001 From: Stephen Sawchuk Date: Wed, 12 Oct 2016 13:23:34 -0400 Subject: [PATCH 4/6] add tests & docs --- packages/monitoring/README.md | 7 ++++++ packages/monitoring/package.json | 6 ++++- packages/monitoring/src/index.js | 42 +++++++++++++++++++++++++++++++ packages/monitoring/test/index.js | 37 +++++++++++++++++++++++++++ 4 files changed, 91 insertions(+), 1 deletion(-) create mode 100644 packages/monitoring/test/index.js diff --git a/packages/monitoring/README.md b/packages/monitoring/README.md index 55bb3b6fafe..1f4af9006ee 100644 --- a/packages/monitoring/README.md +++ b/packages/monitoring/README.md @@ -5,6 +5,12 @@ - [Official Documentation][cloud-monitoring-docs] +## This is an auto-generated API + +It does not follow the conventions you're familiar with from other parts of our library. A handwritten layer is not yet available. + +The example below shows you how to instantiate the generated client. For further documentation, please browse the [Monitoring .proto files][cloud-monitoring-protos] on GitHub. + ```sh $ npm install --save @google-cloud/monitoring @@ -66,3 +72,4 @@ var monitoring = require('@google-cloud/monitoring')({ [gce-how-to]: https://cloud.google.com/compute/docs/authentication#using [dev-console]: https://console.developers.google.com/project [cloud-monitoring-docs]: https://cloud.google.com/monitoring/docs +[cloud-monitoring-protos]: https://github.com/googleapis/googleapis/tree/master/google/monitoring/v3 diff --git a/packages/monitoring/package.json b/packages/monitoring/package.json index 5b30d530c95..9228b0ea7ef 100644 --- a/packages/monitoring/package.json +++ b/packages/monitoring/package.json @@ -56,8 +56,12 @@ "google-gax": "^0.7.0", "extend": "^3.0.0" }, + "devDependencies": { + "mocha": "^3.1.2" + }, "scripts": { - "publish-module": "node ../../scripts/publish.js logging" + "publish-module": "node ../../scripts/publish.js monitoring", + "test": "mocha test/*.js" }, "license": "Apache-2.0", "engines": { diff --git a/packages/monitoring/src/index.js b/packages/monitoring/src/index.js index fceafde8de9..54269d4f581 100644 --- a/packages/monitoring/src/index.js +++ b/packages/monitoring/src/index.js @@ -13,6 +13,48 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + +/*! + * @module monitoring + */ + 'use strict'; +/** + *

+ * **This is a Beta release of Stackdriver Monitoring.** This API is not + * covered by any SLA or deprecation policy and may be subject to + * backward-incompatible changes. + *

+ * + * [Stackdriver Monitoring](https://cloud.google.com/monitoring/docs) collects + * metrics, events, and metadata from Google Cloud Platform, Amazon Web Services + * (AWS), hosted uptime probes, application instrumentation, and a variety of + * common application components including Cassandra, Nginx, Apache Web Server, + * Elasticsearch and many others. Stackdriver ingests that data and generates + * insights via dashboards, charts, and alerts. + * + *

This is an auto-generated API

+ * + * It does not follow the conventions you're familiar with from other parts of + * our library. A handwritten layer is not yet available. + * + * The example below shows you how to instantiate the generated client. For + * further documentation, please browse the + * [Monitoring .proto files](https://github.com/googleapis/googleapis/tree/master/google/monitoring/v3) + * on GitHub. + * + * @constructor + * @alias module:monitoring + */ +function Monitoring() { + throw new Error([ + 'Cloud Monitoring must be accessed through the auto-generated client.', + 'See', + 'https://googlecloudplatform.github.io/google-cloud-node/#/docs/monitoring', + 'for more information.' + ].join(' ')); +} + +module.exports = Monitoring; module.exports.v3 = require('./v3'); diff --git a/packages/monitoring/test/index.js b/packages/monitoring/test/index.js new file mode 100644 index 00000000000..24b31285c0c --- /dev/null +++ b/packages/monitoring/test/index.js @@ -0,0 +1,37 @@ +/** + * Copyright 2016 Google Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +'use strict'; + +var assert = require('assert'); + +var Monitoring = require('../src/index.js'); + +describe('Monitoring', function() { + describe('instantiation', function() { + it('should throw if invoked', function() { + var expectedMessage = [ + 'Cloud Monitoring must be accessed through the auto-generated client.', + ' See https://googlecloudplatform.github.io/google-cloud-node/#/docs/', + 'monitoring for more information.' + ].join(''); + + assert.throws(function() { + new Monitoring(); + }, new RegExp(expectedMessage)); + }); + }); +}); From 48e7cecffa8c311096710455fa8bfe4e73eee8ab Mon Sep 17 00:00:00 2001 From: Stephen Sawchuk Date: Tue, 18 Oct 2016 12:44:51 -0400 Subject: [PATCH 5/6] update deps --- packages/monitoring/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/monitoring/package.json b/packages/monitoring/package.json index 9228b0ea7ef..9721bc0d9c4 100644 --- a/packages/monitoring/package.json +++ b/packages/monitoring/package.json @@ -52,8 +52,8 @@ "stackdriver" ], "dependencies": { - "google-proto-files": "^0.8.2", "google-gax": "^0.7.0", + "google-proto-files": "^0.8.3", "extend": "^3.0.0" }, "devDependencies": { From 94b54dbd3f09156f18dc7535bfc880208467a86e Mon Sep 17 00:00:00 2001 From: Stephen Sawchuk Date: Tue, 18 Oct 2016 12:52:41 -0400 Subject: [PATCH 6/6] add Monitoring to config --- scripts/docs/config.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/scripts/docs/config.js b/scripts/docs/config.js index 0608fda49d8..bea5ca240ec 100644 --- a/scripts/docs/config.js +++ b/scripts/docs/config.js @@ -57,6 +57,9 @@ module.exports = { logging: { title: 'Google Cloud Logging' }, + monitoring: { + title: 'Google Cloud Monitoring' + }, prediction: { title: 'Google Prediction API' },