Skip to content
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 @@ -54,7 +54,7 @@
"arrify": "^1.0.0",
"async": "^2.0.1",
"extend": "^3.0.0",
"google-gax": "^0.9.1",
"google-gax": "^0.10.0",
"google-proto-files": "^0.8.0",
"is": "^3.0.1",
"propprop": "^0.3.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ var DEFAULT_SERVICE_PORT = 443;

var CODE_GEN_NAME_VERSION = 'gapic/0.1.0';


/**
* The scopes needed to make gRPC calls to all of the methods defined in
* this service.
Expand All @@ -53,17 +52,17 @@ var ALL_SCOPES = [
*
* This will be created through a builder function which can be obtained by the module.
* See the following example of how to initialize the module and how to access to the builder.
* @see {@link imageAnnotatorApi}
* @see {@link imageAnnotatorClient}
*
* @example
* var visionV1 = require('@google-cloud/vision').v1({
* // optional auth parameters.
* });
* var api = visionV1.imageAnnotatorApi();
* var client = visionV1.imageAnnotatorClient();
*
* @class
*/
function ImageAnnotatorApi(gaxGrpc, grpcClients, opts) {
function ImageAnnotatorClient(gaxGrpc, grpcClients, opts) {
opts = opts || {};
var servicePath = opts.servicePath || SERVICE_ADDRESS;
var port = opts.port || DEFAULT_SERVICE_PORT;
Expand All @@ -82,8 +81,6 @@ function ImageAnnotatorApi(gaxGrpc, grpcClients, opts) {
'google.cloud.vision.v1.ImageAnnotator',
configData,
clientConfig,
null,
null,
{'x-goog-api-client': googleApiClient});

var imageAnnotatorStub = gaxGrpc.createStub(
Expand All @@ -99,7 +96,8 @@ function ImageAnnotatorApi(gaxGrpc, grpcClients, opts) {
imageAnnotatorStub.then(function(imageAnnotatorStub) {
return imageAnnotatorStub[methodName].bind(imageAnnotatorStub);
}),
defaults[methodName]);
defaults[methodName],
null);
}.bind(this));
}

Expand All @@ -120,34 +118,37 @@ function ImageAnnotatorApi(gaxGrpc, grpcClients, opts) {
* @param {function(?Error, ?Object)=} callback
* The function which will be called with the result of the API call.
*
* The second parameter to the callback is an object representing [BatchAnnotateImagesResponse]{@link BatchAnnotateImagesResponse}
* @returns {Promise} - The promise which resolves to the response object.
* The second parameter to the callback is an object representing [BatchAnnotateImagesResponse]{@link BatchAnnotateImagesResponse}.
* @return {Promise} - The promise which resolves to an array.
* The first element of the array is an object representing [BatchAnnotateImagesResponse]{@link BatchAnnotateImagesResponse}.
* The promise has a method named "cancel" which cancels the ongoing API call.
*
* @example
*
* var api = visionV1.imageAnnotatorApi();
* var client = visionV1.imageAnnotatorClient();
* var requests = [];
* api.batchAnnotateImages({requests: requests}).then(function(response) {
* client.batchAnnotateImages({requests: requests}).then(function(responses) {
* var response = responses[0];
* // doThingsWith(response)
* }).catch(function(err) {
* console.error(err);
* });
*/
ImageAnnotatorApi.prototype.batchAnnotateImages = function(request, options, callback) {
ImageAnnotatorClient.prototype.batchAnnotateImages = function(request, options, callback) {
if (options instanceof Function && callback === undefined) {
callback = options;
options = {};
}
if (options === undefined) {
options = {};
}

return this._batchAnnotateImages(request, options, callback);
};

function ImageAnnotatorApiBuilder(gaxGrpc) {
if (!(this instanceof ImageAnnotatorApiBuilder)) {
return new ImageAnnotatorApiBuilder(gaxGrpc);
function ImageAnnotatorClientBuilder(gaxGrpc) {
if (!(this instanceof ImageAnnotatorClientBuilder)) {
return new ImageAnnotatorClientBuilder(gaxGrpc);
}

var imageAnnotatorClient = gaxGrpc.load([{
Expand All @@ -161,7 +162,7 @@ function ImageAnnotatorApiBuilder(gaxGrpc) {
};

/**
* Build a new instance of {@link ImageAnnotatorApi}.
* Build a new instance of {@link ImageAnnotatorClient}.
*
* @param {Object=} opts - The optional parameters.
* @param {String=} opts.servicePath
Expand All @@ -178,11 +179,11 @@ function ImageAnnotatorApiBuilder(gaxGrpc) {
* @param {String=} opts.appVersion
* The version of the calling service.
*/
this.imageAnnotatorApi = function(opts) {
return new ImageAnnotatorApi(gaxGrpc, grpcClients, opts);
this.imageAnnotatorClient = function(opts) {
return new ImageAnnotatorClient(gaxGrpc, grpcClients, opts);
};
extend(this.imageAnnotatorApi, ImageAnnotatorApi);
extend(this.imageAnnotatorClient, ImageAnnotatorClient);
}
module.exports = ImageAnnotatorApiBuilder;
module.exports = ImageAnnotatorClientBuilder;
module.exports.SERVICE_ADDRESS = SERVICE_ADDRESS;
module.exports.ALL_SCOPES = ALL_SCOPES;
8 changes: 4 additions & 4 deletions packages/vision/src/v1/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/
'use strict';

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

Expand All @@ -24,9 +24,9 @@ function v1(options) {
scopes: v1.ALL_SCOPES
}, options);
var gaxGrpc = gax.grpc(options);
return visionApi(gaxGrpc);
return visionClient(gaxGrpc);
}

v1.SERVICE_ADDRESS = visionApi.SERVICE_ADDRESS;
v1.ALL_SCOPES = visionApi.ALL_SCOPES;
v1.SERVICE_ADDRESS = visionClient.SERVICE_ADDRESS;
v1.ALL_SCOPES = visionClient.ALL_SCOPES;
module.exports = v1;