27
27
/* jscs: disable maximumLineLength */
28
28
'use strict' ;
29
29
30
- var arguejs = require ( 'arguejs' ) ;
31
30
var configData = require ( './image_annotator_client_config' ) ;
32
31
var extend = require ( 'extend' ) ;
33
32
var gax = require ( 'google-gax' ) ;
@@ -38,7 +37,6 @@ var DEFAULT_SERVICE_PORT = 443;
38
37
39
38
var CODE_GEN_NAME_VERSION = 'gapic/0.1.0' ;
40
39
41
- var DEFAULT_TIMEOUT = 30 ;
42
40
43
41
/**
44
42
* The scopes needed to make gRPC calls to all of the methods defined in
@@ -65,42 +63,43 @@ var ALL_SCOPES = [
65
63
*
66
64
* @class
67
65
*/
68
- function ImageAnnotatorApi ( gaxGrpc , grpcClient , opts ) {
66
+ function ImageAnnotatorApi ( gaxGrpc , grpcClients , opts ) {
69
67
opts = opts || { } ;
70
68
var servicePath = opts . servicePath || SERVICE_ADDRESS ;
71
69
var port = opts . port || DEFAULT_SERVICE_PORT ;
72
70
var sslCreds = opts . sslCreds || null ;
73
71
var clientConfig = opts . clientConfig || { } ;
74
- var timeout = opts . timeout || DEFAULT_TIMEOUT ;
75
72
var appName = opts . appName || 'gax' ;
76
- var appVersion = opts . appVersion || gax . Version ;
73
+ var appVersion = opts . appVersion || gax . version ;
77
74
78
75
var googleApiClient = [
79
76
appName + '/' + appVersion ,
80
77
CODE_GEN_NAME_VERSION ,
78
+ 'gax/' + gax . version ,
81
79
'nodejs/' + process . version ] . join ( ' ' ) ;
82
80
83
81
var defaults = gaxGrpc . constructSettings (
84
82
'google.cloud.vision.v1.ImageAnnotator' ,
85
83
configData ,
86
84
clientConfig ,
87
- timeout ,
88
85
null ,
89
86
null ,
90
87
{ 'x-goog-api-client' : googleApiClient } ) ;
91
88
92
- var stub = gaxGrpc . createStub (
89
+ var imageAnnotatorStub = gaxGrpc . createStub (
93
90
servicePath ,
94
91
port ,
95
- grpcClient . google . cloud . vision . v1 . ImageAnnotator ,
92
+ grpcClients . imageAnnotatorClient . google . cloud . vision . v1 . ImageAnnotator ,
96
93
{ sslCreds : sslCreds } ) ;
97
- var methods = [
94
+ var imageAnnotatorStubMethods = [
98
95
'batchAnnotateImages'
99
96
] ;
100
- methods . forEach ( function ( methodName ) {
97
+ imageAnnotatorStubMethods . forEach ( function ( methodName ) {
101
98
this [ '_' + methodName ] = gax . createApiCall (
102
- stub . then ( function ( stub ) { return stub [ methodName ] . bind ( stub ) ; } ) ,
103
- defaults [ methodName ] ) ;
99
+ imageAnnotatorStub . then ( function ( imageAnnotatorStub ) {
100
+ return imageAnnotatorStub [ methodName ] . bind ( imageAnnotatorStub ) ;
101
+ } ) ,
102
+ defaults [ methodName ] ) ;
104
103
} . bind ( this ) ) ;
105
104
}
106
105
@@ -113,9 +112,9 @@ function ImageAnnotatorApi(gaxGrpc, grpcClient, opts) {
113
112
* Individual image annotation requests for this batch.
114
113
*
115
114
* This object should have the same structure as [AnnotateImageRequest]{@link AnnotateImageRequest}
116
- * @param {gax.CallOptions = } options
117
- * Overrides the default settings for this call, e.g, timeout,
118
- * retries, etc.
115
+ * @param {Object = } options
116
+ * Optional parameters. You can override the default settings for this call, e.g, timeout,
117
+ * retries, paginations, etc. See [gax.CallOptions]{ @link https://googleapis.github.io/gax-nodejs/global.html#CallOptions} for the details .
119
118
* @param {function(?Error, ?Object)= } callback
120
119
* The function which will be called with the result of the API call.
121
120
*
@@ -135,28 +134,37 @@ function ImageAnnotatorApi(gaxGrpc, grpcClient, opts) {
135
134
* // doThingsWith(response)
136
135
* });
137
136
*/
138
- ImageAnnotatorApi . prototype . batchAnnotateImages = function batchAnnotateImages ( ) {
139
- var args = arguejs ( {
140
- requests : Array ,
141
- options : [ gax . CallOptions ] ,
142
- callback : [ Function ]
143
- } , arguments ) ;
137
+ ImageAnnotatorApi . prototype . batchAnnotateImages = function batchAnnotateImages (
138
+ requests ,
139
+ options ,
140
+ callback ) {
141
+ if ( options instanceof Function && callback === undefined ) {
142
+ callback = options ;
143
+ options = { } ;
144
+ }
145
+ if ( options === undefined ) {
146
+ options = { } ;
147
+ }
144
148
var req = {
145
- requests : args . requests
149
+ requests : requests
146
150
} ;
147
- return this . _batchAnnotateImages ( req , args . options , args . callback ) ;
151
+ return this . _batchAnnotateImages ( req , options , callback ) ;
148
152
} ;
149
153
150
154
function ImageAnnotatorApiBuilder ( gaxGrpc ) {
151
155
if ( ! ( this instanceof ImageAnnotatorApiBuilder ) ) {
152
156
return new ImageAnnotatorApiBuilder ( gaxGrpc ) ;
153
157
}
154
158
155
- var grpcClient = gaxGrpc . load ( [ {
159
+ var imageAnnotatorClient = gaxGrpc . load ( [ {
156
160
root : require ( 'google-proto-files' ) ( '..' ) ,
157
161
file : 'google/cloud/vision/v1/image_annotator.proto'
158
162
} ] ) ;
159
- extend ( this , grpcClient . google . cloud . vision . v1 ) ;
163
+ extend ( this , imageAnnotatorClient . google . cloud . vision . v1 ) ;
164
+
165
+ var grpcClients = {
166
+ imageAnnotatorClient : imageAnnotatorClient
167
+ } ;
160
168
161
169
/**
162
170
* Build a new instance of {@link ImageAnnotatorApi}.
@@ -171,15 +179,13 @@ function ImageAnnotatorApiBuilder(gaxGrpc) {
171
179
* @param {Object= } opts.clientConfig
172
180
* The customized config to build the call settings. See
173
181
* {@link gax.constructSettings} for the format.
174
- * @param {number= } opts.timeout
175
- * The default timeout, in seconds, for calls made through this client.
176
182
* @param {number= } opts.appName
177
183
* The codename of the calling service.
178
184
* @param {String= } opts.appVersion
179
185
* The version of the calling service.
180
186
*/
181
187
this . imageAnnotatorApi = function ( opts ) {
182
- return new ImageAnnotatorApi ( gaxGrpc , grpcClient , opts ) ;
188
+ return new ImageAnnotatorApi ( gaxGrpc , grpcClients , opts ) ;
183
189
} ;
184
190
extend ( this . imageAnnotatorApi , ImageAnnotatorApi ) ;
185
191
}
0 commit comments