@@ -74,11 +74,22 @@ var coerceImage = (image, callback) => {
74
74
* asking for the single feature annotation.
75
75
*/
76
76
var _createSingleFeatureMethod = featureValue => {
77
- return function ( image , options ) {
78
- return this . annotateImage ( {
79
- image : image ,
80
- features : [ { type : featureValue } ] ,
81
- } , options ) ;
77
+ return function ( annotateImageRequest , callOptions ) {
78
+ annotateImageRequest . features = annotateImageRequest . features || [ {
79
+ type : featureValue ,
80
+ } ] ;
81
+ // If the user submitted explicit features that do not line up with
82
+ // the precise method called, throw an exception.
83
+ for ( let feature of annotateImageRequest . features ) {
84
+ if ( feature . type !== featureValue ) {
85
+ throw new Error (
86
+ 'Setting explicit features is not supported on this method. ' +
87
+ 'Use the #annotateImage method instead.'
88
+ ) ;
89
+ }
90
+ }
91
+ // Call the underlying #annotateImage method.
92
+ return this . annotateImage ( annotateImageRequest , callOptions ) ;
82
93
} ;
83
94
} ;
84
95
@@ -98,9 +109,10 @@ module.exports = apiVersion => {
98
109
/**
99
110
* Annotate a single image with the requested features.
100
111
*
101
- * @param {Object= } request
112
+ * @param {Object } request
102
113
* A representation of the request being sent to the Vision API.
103
- * @param {Object= } request.image
114
+ * This is an [AnnotateImageRequest]{@link AnnotateImageRequest}.
115
+ * @param {Object } request.image
104
116
* A dictionary-like object representing the image. This should have a
105
117
* single key (`source`, `content`).
106
118
*
@@ -110,7 +122,10 @@ module.exports = apiVersion => {
110
122
* If the key is `content`, the value should be a Buffer.
111
123
* @param {Array } request.features
112
124
* An array of the specific annotation features being requested.
113
- * @param {Object= } options
125
+ * This should take a form such as:
126
+ * [{type: vision.types.Feature.Type.FACE_DETECTION},
127
+ * {type: vision.types.Feature.Type.WEB_DETECTION}]
128
+ * @param {Object= } callOptions
114
129
* Optional parameters. You can override the default settings for this
115
130
* call, e.g, timeout, retries, paginations, etc. See
116
131
* [gax.CallOptions]{@link https://googleapis.github.io/gax-nodejs/global.html#CallOptions}
@@ -137,12 +152,12 @@ module.exports = apiVersion => {
137
152
* console.error(err);
138
153
* });
139
154
*/
140
- methods . annotateImage = promisify ( function ( request , options , callback ) {
155
+ methods . annotateImage = promisify ( function ( request , callOptions , callback ) {
141
156
// If a callback was provided and options were skipped, normalize
142
157
// the argument names.
143
- if ( is . undefined ( callback ) && is . function ( options ) ) {
144
- callback = options ;
145
- options = undefined ;
158
+ if ( is . undefined ( callback ) && is . function ( callOptions ) ) {
159
+ callback = callOptions ;
160
+ callOptions = undefined ;
146
161
}
147
162
148
163
// If there is no image, throw an exception.
@@ -159,7 +174,7 @@ module.exports = apiVersion => {
159
174
request . image = image ;
160
175
161
176
// Call the GAPIC batch annotation function.
162
- return this . batchAnnotateImages ( [ request ] , options , ( err , r ) => {
177
+ return this . batchAnnotateImages ( [ request ] , callOptions , ( err , r ) => {
163
178
// If there is an error, handle it.
164
179
if ( err ) {
165
180
return callback ( err ) ;
@@ -187,15 +202,18 @@ module.exports = apiVersion => {
187
202
/**
188
203
* Annotate a single image with face detection.
189
204
*
190
- * @param {Object= } image
205
+ * @param {Object } request
206
+ * A representation of the request being sent to the Vision API.
207
+ * This is an [AnnotateImageRequest]{@link AnnotateImageRequest}.
208
+ * @param {Object } request.image
191
209
* A dictionary-like object representing the image. This should have a
192
210
* single key (`source`, `content`).
193
211
*
194
212
* If the key is `source`, the value should be another object containing
195
213
* `imageUri` or `filename` as a key and a string as a value.
196
214
*
197
215
* If the key is `content`, the value should be a Buffer.
198
- * @param {Object= } options
216
+ * @param {Object= } callOptions
199
217
* Optional parameters. You can override the default settings for this
200
218
* call, e.g, timeout, retries, paginations, etc. See
201
219
* [gax.CallOptions]{@link https://googleapis.github.io/gax-nodejs/global.html#CallOptions}
@@ -227,15 +245,18 @@ module.exports = apiVersion => {
227
245
/**
228
246
* Annotate a single image with landmark detection.
229
247
*
230
- * @param {Object= } image
248
+ * @param {Object } request
249
+ * A representation of the request being sent to the Vision API.
250
+ * This is an [AnnotateImageRequest]{@link AnnotateImageRequest}.
251
+ * @param {Object } request.image
231
252
* A dictionary-like object representing the image. This should have a
232
253
* single key (`source`, `content`).
233
254
*
234
255
* If the key is `source`, the value should be another object containing
235
256
* `imageUri` or `filename` as a key and a string as a value.
236
257
*
237
258
* If the key is `content`, the value should be a Buffer.
238
- * @param {Object= } options
259
+ * @param {Object= } callOptions
239
260
* Optional parameters. You can override the default settings for this
240
261
* call, e.g, timeout, retries, paginations, etc. See
241
262
* [gax.CallOptions]{@link https://googleapis.github.io/gax-nodejs/global.html#CallOptions}
@@ -267,15 +288,18 @@ module.exports = apiVersion => {
267
288
/**
268
289
* Annotate a single image with logo detection.
269
290
*
270
- * @param {Object= } image
291
+ * @param {Object } request
292
+ * A representation of the request being sent to the Vision API.
293
+ * This is an [AnnotateImageRequest]{@link AnnotateImageRequest}.
294
+ * @param {Object } request.image
271
295
* A dictionary-like object representing the image. This should have a
272
296
* single key (`source`, `content`).
273
297
*
274
298
* If the key is `source`, the value should be another object containing
275
299
* `imageUri` or `filename` as a key and a string as a value.
276
300
*
277
301
* If the key is `content`, the value should be a Buffer.
278
- * @param {Object= } options
302
+ * @param {Object= } callOptions
279
303
* Optional parameters. You can override the default settings for this
280
304
* call, e.g, timeout, retries, paginations, etc. See
281
305
* [gax.CallOptions]{@link https://googleapis.github.io/gax-nodejs/global.html#CallOptions}
@@ -307,15 +331,18 @@ module.exports = apiVersion => {
307
331
/**
308
332
* Annotate a single image with label detection.
309
333
*
310
- * @param {Object= } image
334
+ * @param {Object } request
335
+ * A representation of the request being sent to the Vision API.
336
+ * This is an [AnnotateImageRequest]{@link AnnotateImageRequest}.
337
+ * @param {Object } request.image
311
338
* A dictionary-like object representing the image. This should have a
312
339
* single key (`source`, `content`).
313
340
*
314
341
* If the key is `source`, the value should be another object containing
315
342
* `imageUri` or `filename` as a key and a string as a value.
316
343
*
317
344
* If the key is `content`, the value should be a Buffer.
318
- * @param {Object= } options
345
+ * @param {Object= } callOptions
319
346
* Optional parameters. You can override the default settings for this
320
347
* call, e.g, timeout, retries, paginations, etc. See
321
348
* [gax.CallOptions]{@link https://googleapis.github.io/gax-nodejs/global.html#CallOptions}
@@ -347,15 +374,18 @@ module.exports = apiVersion => {
347
374
/**
348
375
* Annotate a single image with text detection.
349
376
*
350
- * @param {Object= } image
377
+ * @param {Object } request
378
+ * A representation of the request being sent to the Vision API.
379
+ * This is an [AnnotateImageRequest]{@link AnnotateImageRequest}.
380
+ * @param {Object } request.image
351
381
* A dictionary-like object representing the image. This should have a
352
382
* single key (`source`, `content`).
353
383
*
354
384
* If the key is `source`, the value should be another object containing
355
385
* `imageUri` or `filename` as a key and a string as a value.
356
386
*
357
387
* If the key is `content`, the value should be a Buffer.
358
- * @param {Object= } options
388
+ * @param {Object= } callOptions
359
389
* Optional parameters. You can override the default settings for this
360
390
* call, e.g, timeout, retries, paginations, etc. See
361
391
* [gax.CallOptions]{@link https://googleapis.github.io/gax-nodejs/global.html#CallOptions}
@@ -387,15 +417,18 @@ module.exports = apiVersion => {
387
417
/**
388
418
* Annotate a single image with document text detection.
389
419
*
390
- * @param {Object= } image
420
+ * @param {Object } request
421
+ * A representation of the request being sent to the Vision API.
422
+ * This is an [AnnotateImageRequest]{@link AnnotateImageRequest}.
423
+ * @param {Object } request.image
391
424
* A dictionary-like object representing the image. This should have a
392
425
* single key (`source`, `content`).
393
426
*
394
427
* If the key is `source`, the value should be another object containing
395
428
* `imageUri` or `filename` as a key and a string as a value.
396
429
*
397
430
* If the key is `content`, the value should be a Buffer.
398
- * @param {Object= } options
431
+ * @param {Object= } callOptions
399
432
* Optional parameters. You can override the default settings for this
400
433
* call, e.g, timeout, retries, paginations, etc. See
401
434
* [gax.CallOptions]{@link https://googleapis.github.io/gax-nodejs/global.html#CallOptions}
@@ -427,15 +460,18 @@ module.exports = apiVersion => {
427
460
/**
428
461
* Annotate a single image with safe search detection.
429
462
*
430
- * @param {Object= } image
463
+ * @param {Object } request
464
+ * A representation of the request being sent to the Vision API.
465
+ * This is an [AnnotateImageRequest]{@link AnnotateImageRequest}.
466
+ * @param {Object } request.image
431
467
* A dictionary-like object representing the image. This should have a
432
468
* single key (`source`, `content`).
433
469
*
434
470
* If the key is `source`, the value should be another object containing
435
471
* `imageUri` or `filename` as a key and a string as a value.
436
472
*
437
473
* If the key is `content`, the value should be a Buffer.
438
- * @param {Object= } options
474
+ * @param {Object= } callOptions
439
475
* Optional parameters. You can override the default settings for this
440
476
* call, e.g, timeout, retries, paginations, etc. See
441
477
* [gax.CallOptions]{@link https://googleapis.github.io/gax-nodejs/global.html#CallOptions}
@@ -467,15 +503,18 @@ module.exports = apiVersion => {
467
503
/**
468
504
* Annotate a single image with image properties.
469
505
*
470
- * @param {Object= } image
506
+ * @param {Object } request
507
+ * A representation of the request being sent to the Vision API.
508
+ * This is an [AnnotateImageRequest]{@link AnnotateImageRequest}.
509
+ * @param {Object } request.image
471
510
* A dictionary-like object representing the image. This should have a
472
511
* single key (`source`, `content`).
473
512
*
474
513
* If the key is `source`, the value should be another object containing
475
514
* `imageUri` or `filename` as a key and a string as a value.
476
515
*
477
516
* If the key is `content`, the value should be a Buffer.
478
- * @param {Object= } options
517
+ * @param {Object= } callOptions
479
518
* Optional parameters. You can override the default settings for this
480
519
* call, e.g, timeout, retries, paginations, etc. See
481
520
* [gax.CallOptions]{@link https://googleapis.github.io/gax-nodejs/global.html#CallOptions}
@@ -507,15 +546,18 @@ module.exports = apiVersion => {
507
546
/**
508
547
* Annotate a single image with crop hints.
509
548
*
510
- * @param {Object= } image
549
+ * @param {Object } request
550
+ * A representation of the request being sent to the Vision API.
551
+ * This is an [AnnotateImageRequest]{@link AnnotateImageRequest}.
552
+ * @param {Object } request.image
511
553
* A dictionary-like object representing the image. This should have a
512
554
* single key (`source`, `content`).
513
555
*
514
556
* If the key is `source`, the value should be another object containing
515
557
* `imageUri` or `filename` as a key and a string as a value.
516
558
*
517
559
* If the key is `content`, the value should be a Buffer.
518
- * @param {Object= } options
560
+ * @param {Object= } callOptions
519
561
* Optional parameters. You can override the default settings for this
520
562
* call, e.g, timeout, retries, paginations, etc. See
521
563
* [gax.CallOptions]{@link https://googleapis.github.io/gax-nodejs/global.html#CallOptions}
@@ -547,15 +589,18 @@ module.exports = apiVersion => {
547
589
/**
548
590
* Annotate a single image with web detection.
549
591
*
550
- * @param {Object= } image
592
+ * @param {Object } request
593
+ * A representation of the request being sent to the Vision API.
594
+ * This is an [AnnotateImageRequest]{@link AnnotateImageRequest}.
595
+ * @param {Object } request.image
551
596
* A dictionary-like object representing the image. This should have a
552
597
* single key (`source`, `content`).
553
598
*
554
599
* If the key is `source`, the value should be another object containing
555
600
* `imageUri` or `filename` as a key and a string as a value.
556
601
*
557
602
* If the key is `content`, the value should be a Buffer.
558
- * @param {Object= } options
603
+ * @param {Object= } callOptions
559
604
* Optional parameters. You can override the default settings for this
560
605
* call, e.g, timeout, retries, paginations, etc. See
561
606
* [gax.CallOptions]{@link https://googleapis.github.io/gax-nodejs/global.html#CallOptions}
0 commit comments