ibm_watson 1.0.0.rc3 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -134,11 +134,12 @@ module IBMWatson
134
134
  }
135
135
  sdk_headers = Common.new.get_sdk_headers("tone_analyzer", "V3", "tone")
136
136
  headers.merge!(sdk_headers)
137
+ tones *= "," unless tones.nil?
137
138
 
138
139
  params = {
139
140
  "version" => @version,
140
141
  "sentences" => sentences,
141
- "tones" => tones.to_a
142
+ "tones" => tones
142
143
  }
143
144
 
144
145
  if content_type.start_with?("application/json") && tone_input.instance_of?(Hash)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module IBMWatson
4
- VERSION = "1.0.0.rc3"
4
+ VERSION = "1.0.0"
5
5
  end
@@ -0,0 +1,658 @@
1
+ # frozen_string_literal: true
2
+
3
+ # (C) Copyright IBM Corp. 2019.
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+
17
+ # Provide images to the IBM Watson™ Visual Recognition service for analysis. The
18
+ # service detects objects based on a set of images with training data.
19
+ #
20
+ # **Beta:** The Visual Recognition v4 API and Object Detection model are beta features.
21
+ # For more information about beta features, see the [Release
22
+ # notes](https://cloud.ibm.com/docs/services/visual-recognition?topic=visual-recognition-release-notes#beta).
23
+ # {: important}
24
+
25
+ require "concurrent"
26
+ require "erb"
27
+ require "json"
28
+ require "ibm_cloud_sdk_core"
29
+ require_relative "./common.rb"
30
+
31
+ # Module for the Watson APIs
32
+ module IBMWatson
33
+ ##
34
+ # The Visual Recognition V4 service.
35
+ class VisualRecognitionV4 < IBMCloudSdkCore::BaseService
36
+ include Concurrent::Async
37
+ ##
38
+ # @!method initialize(args)
39
+ # Construct a new client for the Visual Recognition service.
40
+ #
41
+ # @param args [Hash] The args to initialize with
42
+ # @option args version [String] The API version date to use with the service, in
43
+ # "YYYY-MM-DD" format. Whenever the API is changed in a backwards
44
+ # incompatible way, a new minor version of the API is released.
45
+ # The service uses the API version for the date you specify, or
46
+ # the most recent version before that date. Note that you should
47
+ # not programmatically specify the current date at runtime, in
48
+ # case the API has been updated since your application's release.
49
+ # Instead, specify a version date that is compatible with your
50
+ # application, and don't change it until your application is
51
+ # ready for a later version.
52
+ # @option args service_url [String] The base service URL to use when contacting the service.
53
+ # The base service_url may differ between IBM Cloud regions.
54
+ # @option args authenticator [Object] The Authenticator instance to be configured for this service.
55
+ def initialize(args = {})
56
+ @__async_initialized__ = false
57
+ defaults = {}
58
+ defaults[:version] = nil
59
+ defaults[:service_url] = "https://gateway.watsonplatform.net/visual-recognition/api"
60
+ defaults[:authenticator] = nil
61
+ args = defaults.merge(args)
62
+ @version = args[:version]
63
+ raise ArgumentError.new("version must be provided") if @version.nil?
64
+
65
+ args[:service_name] = "visual_recognition"
66
+ args[:authenticator] = IBMCloudSdkCore::ConfigBasedAuthenticatorFactory.new.get_authenticator(service_name: args[:service_name]) if args[:authenticator].nil?
67
+ super
68
+ end
69
+
70
+ #########################
71
+ # Analysis
72
+ #########################
73
+
74
+ ##
75
+ # @!method analyze(collection_ids:, features:, images_file: nil, image_url: nil, threshold: nil)
76
+ # Analyze images.
77
+ # Analyze images by URL, by file, or both against your own collection. Make sure
78
+ # that **training_status.objects.ready** is `true` for the feature before you use a
79
+ # collection to analyze images.
80
+ #
81
+ # Encode the image and .zip file names in UTF-8 if they contain non-ASCII
82
+ # characters. The service assumes UTF-8 encoding if it encounters non-ASCII
83
+ # characters.
84
+ # @param collection_ids [Array[String]] The IDs of the collections to analyze.
85
+ # @param features [Array[String]] The features to analyze.
86
+ # @param images_file [Array[FileWithMetadata]] An array of image files (.jpg or .png) or .zip files with images.
87
+ # - Include a maximum of 20 images in a request.
88
+ # - Limit the .zip file to 100 MB.
89
+ # - Limit each image file to 10 MB.
90
+ #
91
+ # You can also include an image with the **image_url** parameter.
92
+ # @param image_url [Array[String]] An array of URLs of image files (.jpg or .png).
93
+ # - Include a maximum of 20 images in a request.
94
+ # - Limit each image file to 10 MB.
95
+ # - Minimum width and height is 30 pixels, but the service tends to perform better
96
+ # with images that are at least 300 x 300 pixels. Maximum is 5400 pixels for either
97
+ # height or width.
98
+ #
99
+ # You can also include images with the **images_file** parameter.
100
+ # @param threshold [Float] The minimum score a feature must have to be returned.
101
+ # @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
102
+ def analyze(collection_ids:, features:, images_file: nil, image_url: nil, threshold: nil)
103
+ raise ArgumentError.new("collection_ids must be provided") if collection_ids.nil?
104
+
105
+ raise ArgumentError.new("features must be provided") if features.nil?
106
+
107
+ headers = {
108
+ }
109
+ sdk_headers = Common.new.get_sdk_headers("watson_vision_combined", "V4", "analyze")
110
+ headers.merge!(sdk_headers)
111
+
112
+ params = {
113
+ "version" => @version
114
+ }
115
+
116
+ form_data = {}
117
+
118
+ collection_ids *= "," unless collection_ids.nil?
119
+ features *= "," unless features.nil?
120
+
121
+ form_data[:collection_ids] = HTTP::FormData::Part.new(collection_ids.to_s, content_type: "text/plain")
122
+
123
+ form_data[:features] = HTTP::FormData::Part.new(features.to_s, content_type: "text/plain")
124
+
125
+ form_data[:images_file] = []
126
+ images_file&.each do |item|
127
+ unless item[:data].instance_of?(StringIO) || item[:data].instance_of?(File)
128
+ item[:data] = item[:data].respond_to?(:to_json) ? StringIO.new(item[:data].to_json) : StringIO.new(item[:data])
129
+ end
130
+ item[:filename] = item[:data].path if item[:filename].nil? && item[:data].respond_to?(:path)
131
+ form_data[:images_file].push(HTTP::FormData::File.new(item[:data], content_type: item[:content_type], filename: item[:filename]))
132
+ end
133
+
134
+ form_data[:image_url] = []
135
+ image_url&.each do |item|
136
+ form_data[:image_url].push(HTTP::FormData::Part.new(item.to_s, content_type: "text/plain"))
137
+ end
138
+
139
+ form_data[:threshold] = HTTP::FormData::Part.new(threshold.to_s, content_type: "application/json") unless threshold.nil?
140
+
141
+ method_url = "/v4/analyze"
142
+
143
+ response = request(
144
+ method: "POST",
145
+ url: method_url,
146
+ headers: headers,
147
+ params: params,
148
+ form: form_data,
149
+ accept_json: true
150
+ )
151
+ response
152
+ end
153
+ #########################
154
+ # Collections
155
+ #########################
156
+
157
+ ##
158
+ # @!method create_collection(name: nil, description: nil)
159
+ # Create a collection.
160
+ # Create a collection that can be used to store images.
161
+ #
162
+ # To create a collection without specifying a name and description, include an empty
163
+ # JSON object in the request body.
164
+ #
165
+ # Encode the name and description in UTF-8 if they contain non-ASCII characters. The
166
+ # service assumes UTF-8 encoding if it encounters non-ASCII characters.
167
+ # @param name [String] The name of the collection. The name can contain alphanumeric, underscore, hyphen,
168
+ # and dot characters. It cannot begin with the reserved prefix `sys-`.
169
+ # @param description [String] The description of the collection.
170
+ # @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
171
+ def create_collection(name: nil, description: nil)
172
+ headers = {
173
+ }
174
+ sdk_headers = Common.new.get_sdk_headers("watson_vision_combined", "V4", "create_collection")
175
+ headers.merge!(sdk_headers)
176
+
177
+ params = {
178
+ "version" => @version
179
+ }
180
+
181
+ data = {
182
+ "name" => name,
183
+ "description" => description
184
+ }
185
+
186
+ method_url = "/v4/collections"
187
+
188
+ response = request(
189
+ method: "POST",
190
+ url: method_url,
191
+ headers: headers,
192
+ params: params,
193
+ json: data,
194
+ accept_json: true
195
+ )
196
+ response
197
+ end
198
+
199
+ ##
200
+ # @!method list_collections
201
+ # List collections.
202
+ # Retrieves a list of collections for the service instance.
203
+ # @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
204
+ def list_collections
205
+ headers = {
206
+ }
207
+ sdk_headers = Common.new.get_sdk_headers("watson_vision_combined", "V4", "list_collections")
208
+ headers.merge!(sdk_headers)
209
+
210
+ params = {
211
+ "version" => @version
212
+ }
213
+
214
+ method_url = "/v4/collections"
215
+
216
+ response = request(
217
+ method: "GET",
218
+ url: method_url,
219
+ headers: headers,
220
+ params: params,
221
+ accept_json: true
222
+ )
223
+ response
224
+ end
225
+
226
+ ##
227
+ # @!method get_collection(collection_id:)
228
+ # Get collection details.
229
+ # Get details of one collection.
230
+ # @param collection_id [String] The identifier of the collection.
231
+ # @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
232
+ def get_collection(collection_id:)
233
+ raise ArgumentError.new("collection_id must be provided") if collection_id.nil?
234
+
235
+ headers = {
236
+ }
237
+ sdk_headers = Common.new.get_sdk_headers("watson_vision_combined", "V4", "get_collection")
238
+ headers.merge!(sdk_headers)
239
+
240
+ params = {
241
+ "version" => @version
242
+ }
243
+
244
+ method_url = "/v4/collections/%s" % [ERB::Util.url_encode(collection_id)]
245
+
246
+ response = request(
247
+ method: "GET",
248
+ url: method_url,
249
+ headers: headers,
250
+ params: params,
251
+ accept_json: true
252
+ )
253
+ response
254
+ end
255
+
256
+ ##
257
+ # @!method update_collection(collection_id:, name: nil, description: nil)
258
+ # Update a collection.
259
+ # Update the name or description of a collection.
260
+ #
261
+ # Encode the name and description in UTF-8 if they contain non-ASCII characters. The
262
+ # service assumes UTF-8 encoding if it encounters non-ASCII characters.
263
+ # @param collection_id [String] The identifier of the collection.
264
+ # @param name [String] The name of the collection. The name can contain alphanumeric, underscore, hyphen,
265
+ # and dot characters. It cannot begin with the reserved prefix `sys-`.
266
+ # @param description [String] The description of the collection.
267
+ # @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
268
+ def update_collection(collection_id:, name: nil, description: nil)
269
+ raise ArgumentError.new("collection_id must be provided") if collection_id.nil?
270
+
271
+ headers = {
272
+ }
273
+ sdk_headers = Common.new.get_sdk_headers("watson_vision_combined", "V4", "update_collection")
274
+ headers.merge!(sdk_headers)
275
+
276
+ params = {
277
+ "version" => @version
278
+ }
279
+
280
+ data = {
281
+ "name" => name,
282
+ "description" => description
283
+ }
284
+
285
+ method_url = "/v4/collections/%s" % [ERB::Util.url_encode(collection_id)]
286
+
287
+ response = request(
288
+ method: "POST",
289
+ url: method_url,
290
+ headers: headers,
291
+ params: params,
292
+ json: data,
293
+ accept_json: true
294
+ )
295
+ response
296
+ end
297
+
298
+ ##
299
+ # @!method delete_collection(collection_id:)
300
+ # Delete a collection.
301
+ # Delete a collection from the service instance.
302
+ # @param collection_id [String] The identifier of the collection.
303
+ # @return [nil]
304
+ def delete_collection(collection_id:)
305
+ raise ArgumentError.new("collection_id must be provided") if collection_id.nil?
306
+
307
+ headers = {
308
+ }
309
+ sdk_headers = Common.new.get_sdk_headers("watson_vision_combined", "V4", "delete_collection")
310
+ headers.merge!(sdk_headers)
311
+
312
+ params = {
313
+ "version" => @version
314
+ }
315
+
316
+ method_url = "/v4/collections/%s" % [ERB::Util.url_encode(collection_id)]
317
+
318
+ request(
319
+ method: "DELETE",
320
+ url: method_url,
321
+ headers: headers,
322
+ params: params,
323
+ accept_json: true
324
+ )
325
+ nil
326
+ end
327
+ #########################
328
+ # Images
329
+ #########################
330
+
331
+ ##
332
+ # @!method add_images(collection_id:, images_file: nil, image_url: nil, training_data: nil)
333
+ # Add images.
334
+ # Add images to a collection by URL, by file, or both.
335
+ #
336
+ # Encode the image and .zip file names in UTF-8 if they contain non-ASCII
337
+ # characters. The service assumes UTF-8 encoding if it encounters non-ASCII
338
+ # characters.
339
+ # @param collection_id [String] The identifier of the collection.
340
+ # @param images_file [Array[FileWithMetadata]] An array of image files (.jpg or .png) or .zip files with images.
341
+ # - Include a maximum of 20 images in a request.
342
+ # - Limit the .zip file to 100 MB.
343
+ # - Limit each image file to 10 MB.
344
+ #
345
+ # You can also include an image with the **image_url** parameter.
346
+ # @param image_url [Array[String]] The array of URLs of image files (.jpg or .png).
347
+ # - Include a maximum of 20 images in a request.
348
+ # - Limit each image file to 10 MB.
349
+ # - Minimum width and height is 30 pixels, but the service tends to perform better
350
+ # with images that are at least 300 x 300 pixels. Maximum is 5400 pixels for either
351
+ # height or width.
352
+ #
353
+ # You can also include images with the **images_file** parameter.
354
+ # @param training_data [String] Training data for a single image. Include training data only if you add one image
355
+ # with the request.
356
+ #
357
+ # The `object` property can contain alphanumeric, underscore, hyphen, space, and dot
358
+ # characters. It cannot begin with the reserved prefix `sys-` and must be no longer
359
+ # than 32 characters.
360
+ # @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
361
+ def add_images(collection_id:, images_file: nil, image_url: nil, training_data: nil)
362
+ raise ArgumentError.new("collection_id must be provided") if collection_id.nil?
363
+
364
+ headers = {
365
+ }
366
+ sdk_headers = Common.new.get_sdk_headers("watson_vision_combined", "V4", "add_images")
367
+ headers.merge!(sdk_headers)
368
+
369
+ params = {
370
+ "version" => @version
371
+ }
372
+
373
+ form_data = {}
374
+
375
+ form_data[:images_file] = []
376
+ images_file&.each do |item|
377
+ unless item[:data].instance_of?(StringIO) || item[:data].instance_of?(File)
378
+ item[:data] = item[:data].respond_to?(:to_json) ? StringIO.new(item[:data].to_json) : StringIO.new(item[:data])
379
+ end
380
+ item[:filename] = item[:data].path if item[:filename].nil? && item[:data].respond_to?(:path)
381
+ form_data[:images_file].push(HTTP::FormData::File.new(item[:data], content_type: item[:content_type], filename: item[:filename]))
382
+ end
383
+
384
+ form_data[:image_url] = []
385
+ image_url&.each do |item|
386
+ form_data[:image_url].push(HTTP::FormData::Part.new(item.to_s, content_type: "text/plain"))
387
+ end
388
+
389
+ form_data[:training_data] = HTTP::FormData::Part.new(training_data.to_s, content_type: "text/plain") unless training_data.nil?
390
+
391
+ method_url = "/v4/collections/%s/images" % [ERB::Util.url_encode(collection_id)]
392
+
393
+ response = request(
394
+ method: "POST",
395
+ url: method_url,
396
+ headers: headers,
397
+ params: params,
398
+ form: form_data,
399
+ accept_json: true
400
+ )
401
+ response
402
+ end
403
+
404
+ ##
405
+ # @!method list_images(collection_id:)
406
+ # List images.
407
+ # Retrieves a list of images in a collection.
408
+ # @param collection_id [String] The identifier of the collection.
409
+ # @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
410
+ def list_images(collection_id:)
411
+ raise ArgumentError.new("collection_id must be provided") if collection_id.nil?
412
+
413
+ headers = {
414
+ }
415
+ sdk_headers = Common.new.get_sdk_headers("watson_vision_combined", "V4", "list_images")
416
+ headers.merge!(sdk_headers)
417
+
418
+ params = {
419
+ "version" => @version
420
+ }
421
+
422
+ method_url = "/v4/collections/%s/images" % [ERB::Util.url_encode(collection_id)]
423
+
424
+ response = request(
425
+ method: "GET",
426
+ url: method_url,
427
+ headers: headers,
428
+ params: params,
429
+ accept_json: true
430
+ )
431
+ response
432
+ end
433
+
434
+ ##
435
+ # @!method get_image_details(collection_id:, image_id:)
436
+ # Get image details.
437
+ # Get the details of an image in a collection.
438
+ # @param collection_id [String] The identifier of the collection.
439
+ # @param image_id [String] The identifier of the image.
440
+ # @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
441
+ def get_image_details(collection_id:, image_id:)
442
+ raise ArgumentError.new("collection_id must be provided") if collection_id.nil?
443
+
444
+ raise ArgumentError.new("image_id must be provided") if image_id.nil?
445
+
446
+ headers = {
447
+ }
448
+ sdk_headers = Common.new.get_sdk_headers("watson_vision_combined", "V4", "get_image_details")
449
+ headers.merge!(sdk_headers)
450
+
451
+ params = {
452
+ "version" => @version
453
+ }
454
+
455
+ method_url = "/v4/collections/%s/images/%s" % [ERB::Util.url_encode(collection_id), ERB::Util.url_encode(image_id)]
456
+
457
+ response = request(
458
+ method: "GET",
459
+ url: method_url,
460
+ headers: headers,
461
+ params: params,
462
+ accept_json: true
463
+ )
464
+ response
465
+ end
466
+
467
+ ##
468
+ # @!method delete_image(collection_id:, image_id:)
469
+ # Delete an image.
470
+ # Delete one image from a collection.
471
+ # @param collection_id [String] The identifier of the collection.
472
+ # @param image_id [String] The identifier of the image.
473
+ # @return [nil]
474
+ def delete_image(collection_id:, image_id:)
475
+ raise ArgumentError.new("collection_id must be provided") if collection_id.nil?
476
+
477
+ raise ArgumentError.new("image_id must be provided") if image_id.nil?
478
+
479
+ headers = {
480
+ }
481
+ sdk_headers = Common.new.get_sdk_headers("watson_vision_combined", "V4", "delete_image")
482
+ headers.merge!(sdk_headers)
483
+
484
+ params = {
485
+ "version" => @version
486
+ }
487
+
488
+ method_url = "/v4/collections/%s/images/%s" % [ERB::Util.url_encode(collection_id), ERB::Util.url_encode(image_id)]
489
+
490
+ request(
491
+ method: "DELETE",
492
+ url: method_url,
493
+ headers: headers,
494
+ params: params,
495
+ accept_json: true
496
+ )
497
+ nil
498
+ end
499
+
500
+ ##
501
+ # @!method get_jpeg_image(collection_id:, image_id:, size: nil)
502
+ # Get a JPEG file of an image.
503
+ # Download a JPEG representation of an image.
504
+ # @param collection_id [String] The identifier of the collection.
505
+ # @param image_id [String] The identifier of the image.
506
+ # @param size [String] Specify the image size.
507
+ # @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
508
+ def get_jpeg_image(collection_id:, image_id:, size: nil)
509
+ raise ArgumentError.new("collection_id must be provided") if collection_id.nil?
510
+
511
+ raise ArgumentError.new("image_id must be provided") if image_id.nil?
512
+
513
+ headers = {
514
+ }
515
+ sdk_headers = Common.new.get_sdk_headers("watson_vision_combined", "V4", "get_jpeg_image")
516
+ headers.merge!(sdk_headers)
517
+
518
+ params = {
519
+ "version" => @version,
520
+ "size" => size
521
+ }
522
+
523
+ method_url = "/v4/collections/%s/images/%s/jpeg" % [ERB::Util.url_encode(collection_id), ERB::Util.url_encode(image_id)]
524
+
525
+ response = request(
526
+ method: "GET",
527
+ url: method_url,
528
+ headers: headers,
529
+ params: params,
530
+ accept_json: false
531
+ )
532
+ response
533
+ end
534
+ #########################
535
+ # Training
536
+ #########################
537
+
538
+ ##
539
+ # @!method train(collection_id:)
540
+ # Train a collection.
541
+ # Start training on images in a collection. The collection must have enough training
542
+ # data and untrained data (the **training_status.objects.data_changed** is `true`).
543
+ # If training is in progress, the request queues the next training job.
544
+ # @param collection_id [String] The identifier of the collection.
545
+ # @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
546
+ def train(collection_id:)
547
+ raise ArgumentError.new("collection_id must be provided") if collection_id.nil?
548
+
549
+ headers = {
550
+ }
551
+ sdk_headers = Common.new.get_sdk_headers("watson_vision_combined", "V4", "train")
552
+ headers.merge!(sdk_headers)
553
+
554
+ params = {
555
+ "version" => @version
556
+ }
557
+
558
+ method_url = "/v4/collections/%s/train" % [ERB::Util.url_encode(collection_id)]
559
+
560
+ response = request(
561
+ method: "POST",
562
+ url: method_url,
563
+ headers: headers,
564
+ params: params,
565
+ accept_json: true
566
+ )
567
+ response
568
+ end
569
+
570
+ ##
571
+ # @!method add_image_training_data(collection_id:, image_id:, objects: nil)
572
+ # Add training data to an image.
573
+ # Add, update, or delete training data for an image. Encode the object name in UTF-8
574
+ # if it contains non-ASCII characters. The service assumes UTF-8 encoding if it
575
+ # encounters non-ASCII characters.
576
+ #
577
+ # Elements in the request replace the existing elements.
578
+ #
579
+ # - To update the training data, provide both the unchanged and the new or changed
580
+ # values.
581
+ #
582
+ # - To delete the training data, provide an empty value for the training data.
583
+ # @param collection_id [String] The identifier of the collection.
584
+ # @param image_id [String] The identifier of the image.
585
+ # @param objects [Array[TrainingDataObject]] Training data for specific objects.
586
+ # @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
587
+ def add_image_training_data(collection_id:, image_id:, objects: nil)
588
+ raise ArgumentError.new("collection_id must be provided") if collection_id.nil?
589
+
590
+ raise ArgumentError.new("image_id must be provided") if image_id.nil?
591
+
592
+ headers = {
593
+ }
594
+ sdk_headers = Common.new.get_sdk_headers("watson_vision_combined", "V4", "add_image_training_data")
595
+ headers.merge!(sdk_headers)
596
+
597
+ params = {
598
+ "version" => @version
599
+ }
600
+
601
+ data = {
602
+ "objects" => objects
603
+ }
604
+
605
+ method_url = "/v4/collections/%s/images/%s/training_data" % [ERB::Util.url_encode(collection_id), ERB::Util.url_encode(image_id)]
606
+
607
+ response = request(
608
+ method: "POST",
609
+ url: method_url,
610
+ headers: headers,
611
+ params: params,
612
+ json: data,
613
+ accept_json: true
614
+ )
615
+ response
616
+ end
617
+ #########################
618
+ # User data
619
+ #########################
620
+
621
+ ##
622
+ # @!method delete_user_data(customer_id:)
623
+ # Delete labeled data.
624
+ # Deletes all data associated with a specified customer ID. The method has no effect
625
+ # if no data is associated with the customer ID.
626
+ #
627
+ # You associate a customer ID with data by passing the `X-Watson-Metadata` header
628
+ # with a request that passes data. For more information about personal data and
629
+ # customer IDs, see [Information
630
+ # security](https://cloud.ibm.com/docs/services/visual-recognition?topic=visual-recognition-information-security).
631
+ # @param customer_id [String] The customer ID for which all data is to be deleted.
632
+ # @return [nil]
633
+ def delete_user_data(customer_id:)
634
+ raise ArgumentError.new("customer_id must be provided") if customer_id.nil?
635
+
636
+ headers = {
637
+ }
638
+ sdk_headers = Common.new.get_sdk_headers("watson_vision_combined", "V4", "delete_user_data")
639
+ headers.merge!(sdk_headers)
640
+
641
+ params = {
642
+ "version" => @version,
643
+ "customer_id" => customer_id
644
+ }
645
+
646
+ method_url = "/v4/user_data"
647
+
648
+ request(
649
+ method: "DELETE",
650
+ url: method_url,
651
+ headers: headers,
652
+ params: params,
653
+ accept_json: true
654
+ )
655
+ nil
656
+ end
657
+ end
658
+ end