Skip to content

Update vision API client autogen. #2026

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 24, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/vision/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
"arrify": "^1.0.0",
"async": "^2.0.1",
"extend": "^3.0.0",
"google-gax": "^0.10.0",
"google-gax": "^0.12.0",
"google-proto-files": "^0.9.1",
"is": "^3.0.1",
"propprop": "^0.3.0",
Expand Down
64 changes: 37 additions & 27 deletions packages/vision/src/v1/image_annotator_client.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,44 +63,61 @@ var ALL_SCOPES = [
* @class
*/
function ImageAnnotatorClient(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,
CODE_GEN_NAME_VERSION,
'gl-node/' + process.versions.node,
CODE_GEN_NAME_VERSION
];
if (opts.libName && opts.libVersion) {
googleApiClient.push(opts.libName + '/' + opts.libVersion);
}
googleApiClient.push(
'gax/' + gax.version,
'nodejs/' + process.version].join(' ');
'grpc/' + gaxGrpc.grpcVersion
);

var defaults = gaxGrpc.constructSettings(
'google.cloud.vision.v1.ImageAnnotator',
configData,
clientConfig,
{'x-goog-api-client': googleApiClient});
opts.clientConfig,
{'x-goog-api-client': googleApiClient.join(' ')});

var self = this;

this.auth = gaxGrpc.auth;
var imageAnnotatorStub = gaxGrpc.createStub(
servicePath,
port,
grpcClients.imageAnnotatorClient.google.cloud.vision.v1.ImageAnnotator,
{sslCreds: sslCreds});
grpcClients.google.cloud.vision.v1.ImageAnnotator,
opts);
var imageAnnotatorStubMethods = [
'batchAnnotateImages'
];
imageAnnotatorStubMethods.forEach(function(methodName) {
this['_' + methodName] = gax.createApiCall(
self['_' + methodName] = gax.createApiCall(
imageAnnotatorStub.then(function(imageAnnotatorStub) {
return imageAnnotatorStub[methodName].bind(imageAnnotatorStub);
return function() {
var args = Array.prototype.slice.call(arguments, 0);
return imageAnnotatorStub[methodName].apply(imageAnnotatorStub, args);
};
}),
defaults[methodName],
null);
}.bind(this));
});
}

/**
* Get the project ID used by this class.
* @aram {function(Error, string)} callback - the callback to be called with
* the current project Id.
*/
ImageAnnotatorClient.prototype.getProjectId = function(callback) {
return this.auth.getProjectId(callback);
};

// Service calls

/**
Expand Down Expand Up @@ -157,9 +174,6 @@ function ImageAnnotatorClientBuilder(gaxGrpc) {
}]);
extend(this, imageAnnotatorClient.google.cloud.vision.v1);

var grpcClients = {
imageAnnotatorClient: imageAnnotatorClient
};

/**
* Build a new instance of {@link ImageAnnotatorClient}.
Expand All @@ -174,13 +188,9 @@ function ImageAnnotatorClientBuilder(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.imageAnnotatorClient = function(opts) {
return new ImageAnnotatorClient(gaxGrpc, grpcClients, opts);
return new ImageAnnotatorClient(gaxGrpc, imageAnnotatorClient, opts);
};
extend(this.imageAnnotatorClient, ImageAnnotatorClient);
}
Expand Down
12 changes: 5 additions & 7 deletions packages/vision/src/v1/image_annotator_client_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,11 @@
"interfaces": {
"google.cloud.vision.v1.ImageAnnotator": {
"retry_codes": {
"retry_codes_def": {
"idempotent": [
"DEADLINE_EXCEEDED",
"UNAVAILABLE"
],
"non_idempotent": []
}
"idempotent": [
"DEADLINE_EXCEEDED",
"UNAVAILABLE"
],
"non_idempotent": []
},
"retry_params": {
"default": {
Expand Down
17 changes: 9 additions & 8 deletions packages/vision/src/v1/index.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
/*!
* 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.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* 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,
Expand All @@ -15,18 +15,19 @@
*/
'use strict';

var visionClient = require('./image_annotator_client');
var extend = require('extend');
var imageAnnotatorClient = require('./image_annotator_client');
var gax = require('google-gax');
var extend = require('extend');

function v1(options) {
options = extend({
scopes: v1.ALL_SCOPES
}, options);
var gaxGrpc = gax.grpc(options);
return visionClient(gaxGrpc);
return imageAnnotatorClient(gaxGrpc);
}

v1.SERVICE_ADDRESS = visionClient.SERVICE_ADDRESS;
v1.ALL_SCOPES = visionClient.ALL_SCOPES;
v1.SERVICE_ADDRESS = imageAnnotatorClient.SERVICE_ADDRESS;
v1.ALL_SCOPES = imageAnnotatorClient.ALL_SCOPES;

module.exports = v1;