diff --git a/packages/vision/package.json b/packages/vision/package.json index 887d7465527..f1cbe9e6d1a 100644 --- a/packages/vision/package.json +++ b/packages/vision/package.json @@ -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", diff --git a/packages/vision/src/v1/image_annotator_client.js b/packages/vision/src/v1/image_annotator_client.js index 1a6e4b4c8f6..213be636675 100644 --- a/packages/vision/src/v1/image_annotator_client.js +++ b/packages/vision/src/v1/image_annotator_client.js @@ -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 /** @@ -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}. @@ -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); } diff --git a/packages/vision/src/v1/image_annotator_client_config.json b/packages/vision/src/v1/image_annotator_client_config.json index 12676ae8e70..a5623731dc0 100644 --- a/packages/vision/src/v1/image_annotator_client_config.json +++ b/packages/vision/src/v1/image_annotator_client_config.json @@ -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": { diff --git a/packages/vision/src/v1/index.js b/packages/vision/src/v1/index.js index 3e6ed933593..22d87db6661 100644 --- a/packages/vision/src/v1/index.js +++ b/packages/vision/src/v1/index.js @@ -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, @@ -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;