Skip to content

Commit

Permalink
Regenerate monitoring APIs (#2059)
Browse files Browse the repository at this point in the history
Updates #2019
  • Loading branch information
jmuk authored and stephenplusplus committed Mar 7, 2017
1 parent 52ac850 commit 7f40ab0
Show file tree
Hide file tree
Showing 6 changed files with 93 additions and 71 deletions.
2 changes: 1 addition & 1 deletion packages/google-cloud-monitoring/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
64 changes: 37 additions & 27 deletions packages/google-cloud-monitoring/src/v3/group_service_client.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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',
Expand All @@ -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
Expand Down Expand Up @@ -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

/**
Expand Down Expand Up @@ -711,9 +728,6 @@ function GroupServiceClientBuilder(gaxGrpc) {
}]);
extend(this, groupServiceClient.google.monitoring.v3);

var grpcClients = {
groupServiceClient: groupServiceClient
};

/**
* Build a new instance of {@link GroupServiceClient}.
Expand All @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
6 changes: 4 additions & 2 deletions packages/google-cloud-monitoring/src/v3/index.js
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -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;
64 changes: 37 additions & 27 deletions packages/google-cloud-monitoring/src/v3/metric_service_client.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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',
Expand All @@ -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
Expand Down Expand Up @@ -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

/**
Expand Down Expand Up @@ -979,9 +996,6 @@ function MetricServiceClientBuilder(gaxGrpc) {
}]);
extend(this, metricServiceClient.google.monitoring.v3);

var grpcClients = {
metricServiceClient: metricServiceClient
};

/**
* Build a new instance of {@link MetricServiceClient}.
Expand All @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down

0 comments on commit 7f40ab0

Please sign in to comment.