From 74c8f0d78de0a9107ce5799562ca2c168b98236d Mon Sep 17 00:00:00 2001 From: Jun Mukai Date: Tue, 7 Mar 2017 12:24:38 -0800 Subject: [PATCH] Regenerate monitoring APIs (#2059) Updates #2019 --- packages/monitoring/package.json | 2 +- .../monitoring/src/v3/group_service_client.js | 64 +++++++++++-------- .../src/v3/group_service_client_config.json | 14 ++-- packages/monitoring/src/v3/index.js | 6 +- .../src/v3/metric_service_client.js | 64 +++++++++++-------- .../src/v3/metric_service_client_config.json | 14 ++-- 6 files changed, 93 insertions(+), 71 deletions(-) diff --git a/packages/monitoring/package.json b/packages/monitoring/package.json index 29dd40b1fef..e95b50a4ee1 100644 --- a/packages/monitoring/package.json +++ b/packages/monitoring/package.json @@ -53,7 +53,7 @@ ], "dependencies": { "extend": "^3.0.0", - "google-gax": "^0.12.2", + "google-gax": "^0.12.3", "google-proto-files": "^0.10.0" }, "devDependencies": { diff --git a/packages/monitoring/src/v3/group_service_client.js b/packages/monitoring/src/v3/group_service_client.js index 8cd73812c3f..1cab7077adf 100644 --- a/packages/monitoring/src/v3/group_service_client.js +++ b/packages/monitoring/src/v3/group_service_client.js @@ -35,7 +35,7 @@ var SERVICE_ADDRESS = 'monitoring.googleapis.com'; var DEFAULT_SERVICE_PORT = 443; -var CODE_GEN_NAME_VERSION = 'gapic/0.1.0'; +var CODE_GEN_NAME_VERSION = 'gapic/0.7.1'; var PAGE_DESCRIPTORS = { listGroups: new gax.PageDescriptor( @@ -86,31 +86,36 @@ var ALL_SCOPES = [ * @class */ function GroupServiceClient(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; + opts = extend({ + servicePath: SERVICE_ADDRESS, + port: DEFAULT_SERVICE_PORT, + clientConfig: {} + }, opts); var googleApiClient = [ - appName + '/' + appVersion, + 'gl-node/' + process.versions.node + ]; + if (opts.libName && opts.libVersion) { + googleApiClient.push(opts.libName + '/' + opts.libVersion); + } + googleApiClient.push( CODE_GEN_NAME_VERSION, 'gax/' + gax.version, - 'nodejs/' + process.version].join(' '); + 'grpc/' + gaxGrpc.grpcVersion + ); var defaults = gaxGrpc.constructSettings( 'google.monitoring.v3.GroupService', configData, - clientConfig, - {'x-goog-api-client': googleApiClient}); + opts.clientConfig, + {'x-goog-api-client': googleApiClient.join(' ')}); + + var self = this; + this.auth = gaxGrpc.auth; var groupServiceStub = gaxGrpc.createStub( - servicePath, - port, - grpcClients.groupServiceClient.google.monitoring.v3.GroupService, - {sslCreds: sslCreds}); + grpcClients.google.monitoring.v3.GroupService, + opts); var groupServiceStubMethods = [ 'listGroups', 'getGroup', @@ -120,13 +125,16 @@ function GroupServiceClient(gaxGrpc, grpcClients, opts) { 'listGroupMembers' ]; groupServiceStubMethods.forEach(function(methodName) { - this['_' + methodName] = gax.createApiCall( + self['_' + methodName] = gax.createApiCall( groupServiceStub.then(function(groupServiceStub) { - return groupServiceStub[methodName].bind(groupServiceStub); + return function() { + var args = Array.prototype.slice.call(arguments, 0); + return groupServiceStub[methodName].apply(groupServiceStub, args); + }; }), defaults[methodName], PAGE_DESCRIPTORS[methodName]); - }.bind(this)); + }); } // Path templates @@ -191,6 +199,15 @@ GroupServiceClient.prototype.matchGroupFromGroupName = function(groupName) { return GROUP_PATH_TEMPLATE.match(groupName).group; }; +/** + * Get the project ID used by this class. + * @aram {function(Error, string)} callback - the callback to be called with + * the current project Id. + */ +GroupServiceClient.prototype.getProjectId = function(callback) { + return this.auth.getProjectId(callback); +}; + // Service calls /** @@ -711,9 +728,6 @@ function GroupServiceClientBuilder(gaxGrpc) { }]); extend(this, groupServiceClient.google.monitoring.v3); - var grpcClients = { - groupServiceClient: groupServiceClient - }; /** * Build a new instance of {@link GroupServiceClient}. @@ -728,13 +742,9 @@ function GroupServiceClientBuilder(gaxGrpc) { * @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.groupServiceClient = function(opts) { - return new GroupServiceClient(gaxGrpc, grpcClients, opts); + return new GroupServiceClient(gaxGrpc, groupServiceClient, opts); }; extend(this.groupServiceClient, GroupServiceClient); } diff --git a/packages/monitoring/src/v3/group_service_client_config.json b/packages/monitoring/src/v3/group_service_client_config.json index c1d5d808d10..825193b3a41 100644 --- a/packages/monitoring/src/v3/group_service_client_config.json +++ b/packages/monitoring/src/v3/group_service_client_config.json @@ -2,13 +2,13 @@ "interfaces": { "google.monitoring.v3.GroupService": { "retry_codes": { - "retry_codes_def": { - "idempotent": [ - "DEADLINE_EXCEEDED", - "UNAVAILABLE" - ], - "non_idempotent": [] - } + "idempotent": [ + "DEADLINE_EXCEEDED", + "UNAVAILABLE" + ], + "non_idempotent": [ + "UNAVAILABLE" + ] }, "retry_params": { "default": { diff --git a/packages/monitoring/src/v3/index.js b/packages/monitoring/src/v3/index.js index ca79c93644c..e26eedb2776 100644 --- a/packages/monitoring/src/v3/index.js +++ b/packages/monitoring/src/v3/index.js @@ -1,5 +1,5 @@ -/*! - * Copyright 2016 Google Inc. All Rights Reserved. +/* + * 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. @@ -30,6 +30,8 @@ function v3(options) { extend(result, metricServiceClient(gaxGrpc)); return result; } + v3.SERVICE_ADDRESS = groupServiceClient.SERVICE_ADDRESS; v3.ALL_SCOPES = groupServiceClient.ALL_SCOPES; + module.exports = v3; diff --git a/packages/monitoring/src/v3/metric_service_client.js b/packages/monitoring/src/v3/metric_service_client.js index b73f64c2fa7..62706b2ffbd 100644 --- a/packages/monitoring/src/v3/metric_service_client.js +++ b/packages/monitoring/src/v3/metric_service_client.js @@ -35,7 +35,7 @@ var SERVICE_ADDRESS = 'monitoring.googleapis.com'; var DEFAULT_SERVICE_PORT = 443; -var CODE_GEN_NAME_VERSION = 'gapic/0.1.0'; +var CODE_GEN_NAME_VERSION = 'gapic/0.7.1'; var PAGE_DESCRIPTORS = { listMonitoredResourceDescriptors: new gax.PageDescriptor( @@ -80,31 +80,36 @@ var ALL_SCOPES = [ * @class */ function MetricServiceClient(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; + opts = extend({ + servicePath: SERVICE_ADDRESS, + port: DEFAULT_SERVICE_PORT, + clientConfig: {} + }, opts); var googleApiClient = [ - appName + '/' + appVersion, + 'gl-node/' + process.versions.node + ]; + if (opts.libName && opts.libVersion) { + googleApiClient.push(opts.libName + '/' + opts.libVersion); + } + googleApiClient.push( CODE_GEN_NAME_VERSION, 'gax/' + gax.version, - 'nodejs/' + process.version].join(' '); + 'grpc/' + gaxGrpc.grpcVersion + ); var defaults = gaxGrpc.constructSettings( 'google.monitoring.v3.MetricService', configData, - clientConfig, - {'x-goog-api-client': googleApiClient}); + opts.clientConfig, + {'x-goog-api-client': googleApiClient.join(' ')}); + + var self = this; + this.auth = gaxGrpc.auth; var metricServiceStub = gaxGrpc.createStub( - servicePath, - port, - grpcClients.metricServiceClient.google.monitoring.v3.MetricService, - {sslCreds: sslCreds}); + grpcClients.google.monitoring.v3.MetricService, + opts); var metricServiceStubMethods = [ 'listMonitoredResourceDescriptors', 'getMonitoredResourceDescriptor', @@ -116,13 +121,16 @@ function MetricServiceClient(gaxGrpc, grpcClients, opts) { 'createTimeSeries' ]; metricServiceStubMethods.forEach(function(methodName) { - this['_' + methodName] = gax.createApiCall( + self['_' + methodName] = gax.createApiCall( metricServiceStub.then(function(metricServiceStub) { - return metricServiceStub[methodName].bind(metricServiceStub); + return function() { + var args = Array.prototype.slice.call(arguments, 0); + return metricServiceStub[methodName].apply(metricServiceStub, args); + }; }), defaults[methodName], PAGE_DESCRIPTORS[methodName]); - }.bind(this)); + }); } // Path templates @@ -223,6 +231,15 @@ MetricServiceClient.prototype.matchMonitoredResourceDescriptorFromMonitoredResou return MONITORED_RESOURCE_DESCRIPTOR_PATH_TEMPLATE.match(monitoredResourceDescriptorName).monitored_resource_descriptor; }; +/** + * Get the project ID used by this class. + * @aram {function(Error, string)} callback - the callback to be called with + * the current project Id. + */ +MetricServiceClient.prototype.getProjectId = function(callback) { + return this.auth.getProjectId(callback); +}; + // Service calls /** @@ -979,9 +996,6 @@ function MetricServiceClientBuilder(gaxGrpc) { }]); extend(this, metricServiceClient.google.monitoring.v3); - var grpcClients = { - metricServiceClient: metricServiceClient - }; /** * Build a new instance of {@link MetricServiceClient}. @@ -996,13 +1010,9 @@ function MetricServiceClientBuilder(gaxGrpc) { * @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.metricServiceClient = function(opts) { - return new MetricServiceClient(gaxGrpc, grpcClients, opts); + return new MetricServiceClient(gaxGrpc, metricServiceClient, opts); }; extend(this.metricServiceClient, MetricServiceClient); } diff --git a/packages/monitoring/src/v3/metric_service_client_config.json b/packages/monitoring/src/v3/metric_service_client_config.json index 4ec14c73bde..b04f7227700 100644 --- a/packages/monitoring/src/v3/metric_service_client_config.json +++ b/packages/monitoring/src/v3/metric_service_client_config.json @@ -2,13 +2,13 @@ "interfaces": { "google.monitoring.v3.MetricService": { "retry_codes": { - "retry_codes_def": { - "idempotent": [ - "DEADLINE_EXCEEDED", - "UNAVAILABLE" - ], - "non_idempotent": [] - } + "idempotent": [ + "DEADLINE_EXCEEDED", + "UNAVAILABLE" + ], + "non_idempotent": [ + "UNAVAILABLE" + ] }, "retry_params": { "default": {