Skip to content

Commit 2047571

Browse files
jmukstephenplusplus
authored andcommitted
Update vision API client autogen. (#2026)
Updates #2019
1 parent ccd9a4b commit 2047571

File tree

4 files changed

+52
-43
lines changed

4 files changed

+52
-43
lines changed

packages/google-cloud-vision/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
"arrify": "^1.0.0",
5656
"async": "^2.0.1",
5757
"extend": "^3.0.0",
58-
"google-gax": "^0.10.0",
58+
"google-gax": "^0.12.0",
5959
"google-proto-files": "^0.9.1",
6060
"is": "^3.0.1",
6161
"propprop": "^0.3.0",

packages/google-cloud-vision/src/v1/image_annotator_client.js

+37-27
Original file line numberDiff line numberDiff line change
@@ -63,44 +63,61 @@ var ALL_SCOPES = [
6363
* @class
6464
*/
6565
function ImageAnnotatorClient(gaxGrpc, grpcClients, opts) {
66-
opts = opts || {};
67-
var servicePath = opts.servicePath || SERVICE_ADDRESS;
68-
var port = opts.port || DEFAULT_SERVICE_PORT;
69-
var sslCreds = opts.sslCreds || null;
70-
var clientConfig = opts.clientConfig || {};
71-
var appName = opts.appName || 'gax';
72-
var appVersion = opts.appVersion || gax.version;
66+
opts = extend({
67+
servicePath: SERVICE_ADDRESS,
68+
port: DEFAULT_SERVICE_PORT,
69+
clientConfig: {}
70+
}, opts);
7371

7472
var googleApiClient = [
75-
appName + '/' + appVersion,
76-
CODE_GEN_NAME_VERSION,
73+
'gl-node/' + process.versions.node,
74+
CODE_GEN_NAME_VERSION
75+
];
76+
if (opts.libName && opts.libVersion) {
77+
googleApiClient.push(opts.libName + '/' + opts.libVersion);
78+
}
79+
googleApiClient.push(
7780
'gax/' + gax.version,
78-
'nodejs/' + process.version].join(' ');
81+
'grpc/' + gaxGrpc.grpcVersion
82+
);
7983

8084
var defaults = gaxGrpc.constructSettings(
8185
'google.cloud.vision.v1.ImageAnnotator',
8286
configData,
83-
clientConfig,
84-
{'x-goog-api-client': googleApiClient});
87+
opts.clientConfig,
88+
{'x-goog-api-client': googleApiClient.join(' ')});
8589

90+
var self = this;
91+
92+
this.auth = gaxGrpc.auth;
8693
var imageAnnotatorStub = gaxGrpc.createStub(
87-
servicePath,
88-
port,
89-
grpcClients.imageAnnotatorClient.google.cloud.vision.v1.ImageAnnotator,
90-
{sslCreds: sslCreds});
94+
grpcClients.google.cloud.vision.v1.ImageAnnotator,
95+
opts);
9196
var imageAnnotatorStubMethods = [
9297
'batchAnnotateImages'
9398
];
9499
imageAnnotatorStubMethods.forEach(function(methodName) {
95-
this['_' + methodName] = gax.createApiCall(
100+
self['_' + methodName] = gax.createApiCall(
96101
imageAnnotatorStub.then(function(imageAnnotatorStub) {
97-
return imageAnnotatorStub[methodName].bind(imageAnnotatorStub);
102+
return function() {
103+
var args = Array.prototype.slice.call(arguments, 0);
104+
return imageAnnotatorStub[methodName].apply(imageAnnotatorStub, args);
105+
};
98106
}),
99107
defaults[methodName],
100108
null);
101-
}.bind(this));
109+
});
102110
}
103111

112+
/**
113+
* Get the project ID used by this class.
114+
* @aram {function(Error, string)} callback - the callback to be called with
115+
* the current project Id.
116+
*/
117+
ImageAnnotatorClient.prototype.getProjectId = function(callback) {
118+
return this.auth.getProjectId(callback);
119+
};
120+
104121
// Service calls
105122

106123
/**
@@ -157,9 +174,6 @@ function ImageAnnotatorClientBuilder(gaxGrpc) {
157174
}]);
158175
extend(this, imageAnnotatorClient.google.cloud.vision.v1);
159176

160-
var grpcClients = {
161-
imageAnnotatorClient: imageAnnotatorClient
162-
};
163177

164178
/**
165179
* Build a new instance of {@link ImageAnnotatorClient}.
@@ -174,13 +188,9 @@ function ImageAnnotatorClientBuilder(gaxGrpc) {
174188
* @param {Object=} opts.clientConfig
175189
* The customized config to build the call settings. See
176190
* {@link gax.constructSettings} for the format.
177-
* @param {number=} opts.appName
178-
* The codename of the calling service.
179-
* @param {String=} opts.appVersion
180-
* The version of the calling service.
181191
*/
182192
this.imageAnnotatorClient = function(opts) {
183-
return new ImageAnnotatorClient(gaxGrpc, grpcClients, opts);
193+
return new ImageAnnotatorClient(gaxGrpc, imageAnnotatorClient, opts);
184194
};
185195
extend(this.imageAnnotatorClient, ImageAnnotatorClient);
186196
}

packages/google-cloud-vision/src/v1/image_annotator_client_config.json

+5-7
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,11 @@
22
"interfaces": {
33
"google.cloud.vision.v1.ImageAnnotator": {
44
"retry_codes": {
5-
"retry_codes_def": {
6-
"idempotent": [
7-
"DEADLINE_EXCEEDED",
8-
"UNAVAILABLE"
9-
],
10-
"non_idempotent": []
11-
}
5+
"idempotent": [
6+
"DEADLINE_EXCEEDED",
7+
"UNAVAILABLE"
8+
],
9+
"non_idempotent": []
1210
},
1311
"retry_params": {
1412
"default": {
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
/*!
2-
* Copyright 2016 Google Inc. All Rights Reserved.
1+
/*
2+
* Copyright 2016 Google Inc. All rights reserved.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
66
* You may obtain a copy of the License at
77
*
8-
* http://www.apache.org/licenses/LICENSE-2.0
8+
* http://www.apache.org/licenses/LICENSE-2.0
99
*
1010
* Unless required by applicable law or agreed to in writing, software
1111
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -15,18 +15,19 @@
1515
*/
1616
'use strict';
1717

18-
var visionClient = require('./image_annotator_client');
19-
var extend = require('extend');
18+
var imageAnnotatorClient = require('./image_annotator_client');
2019
var gax = require('google-gax');
20+
var extend = require('extend');
2121

2222
function v1(options) {
2323
options = extend({
2424
scopes: v1.ALL_SCOPES
2525
}, options);
2626
var gaxGrpc = gax.grpc(options);
27-
return visionClient(gaxGrpc);
27+
return imageAnnotatorClient(gaxGrpc);
2828
}
2929

30-
v1.SERVICE_ADDRESS = visionClient.SERVICE_ADDRESS;
31-
v1.ALL_SCOPES = visionClient.ALL_SCOPES;
30+
v1.SERVICE_ADDRESS = imageAnnotatorClient.SERVICE_ADDRESS;
31+
v1.ALL_SCOPES = imageAnnotatorClient.ALL_SCOPES;
32+
3233
module.exports = v1;

0 commit comments

Comments
 (0)