ibm_watson 1.3.1 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +36 -5
  3. data/lib/ibm_watson/assistant_v1.rb +225 -199
  4. data/lib/ibm_watson/assistant_v2.rb +228 -21
  5. data/lib/ibm_watson/compare_comply_v1.rb +43 -24
  6. data/lib/ibm_watson/discovery_v1.rb +144 -19
  7. data/lib/ibm_watson/discovery_v2.rb +742 -23
  8. data/lib/ibm_watson/language_translator_v3.rb +216 -64
  9. data/lib/ibm_watson/natural_language_classifier_v1.rb +11 -3
  10. data/lib/ibm_watson/natural_language_understanding_v1.rb +32 -26
  11. data/lib/ibm_watson/personality_insights_v3.rb +34 -19
  12. data/lib/ibm_watson/speech_to_text_v1.rb +239 -106
  13. data/lib/ibm_watson/text_to_speech_v1.rb +139 -146
  14. data/lib/ibm_watson/tone_analyzer_v3.rb +19 -14
  15. data/lib/ibm_watson/version.rb +1 -1
  16. data/lib/ibm_watson/visual_recognition_v3.rb +40 -17
  17. data/lib/ibm_watson/visual_recognition_v4.rb +110 -18
  18. data/test/integration/test_assistant_v1.rb +9 -0
  19. data/test/integration/test_assistant_v2.rb +34 -0
  20. data/test/integration/test_compare_comply_v1.rb +1 -12
  21. data/test/integration/test_discovery_v2.rb +132 -6
  22. data/test/integration/test_language_translator_v3.rb +5 -0
  23. data/test/integration/test_text_to_speech_v1.rb +3 -3
  24. data/test/integration/test_visual_recognition_v4.rb +9 -0
  25. data/test/unit/test_assistant_v1.rb +149 -98
  26. data/test/unit/test_assistant_v2.rb +153 -8
  27. data/test/unit/test_compare_comply_v1.rb +20 -20
  28. data/test/unit/test_discovery_v1.rb +125 -125
  29. data/test/unit/test_discovery_v2.rb +262 -29
  30. data/test/unit/test_language_translator_v3.rb +85 -24
  31. data/test/unit/test_natural_language_classifier_v1.rb +17 -17
  32. data/test/unit/test_natural_language_understanding_v1.rb +10 -10
  33. data/test/unit/test_personality_insights_v3.rb +14 -14
  34. data/test/unit/test_speech_to_text_v1.rb +97 -97
  35. data/test/unit/test_text_to_speech_v1.rb +48 -48
  36. data/test/unit/test_tone_analyzer_v3.rb +12 -12
  37. data/test/unit/test_visual_recognition_v3.rb +16 -16
  38. data/test/unit/test_visual_recognition_v4.rb +56 -38
  39. metadata +3 -3
@@ -20,7 +20,7 @@ class VisualRecognitionV4Test < Minitest::Test
20
20
 
21
21
  def test_analyze
22
22
  file = File.open(Dir.getwd + "/resources/cnc_test.pdf")
23
- stub_request(:post, "https://gateway.watsonplatform.net/visual-recognition/api/v4/analyze?version=2018-03-19").with do |req|
23
+ stub_request(:post, "https://api.us-south.visual-recognition.watson.cloud.ibm.com/v4/analyze?version=2018-03-19").with do |req|
24
24
  assert_equal(req.headers["Accept"], "application/json")
25
25
  assert_match(%r{\Amultipart/form-data}, req.headers["Content-Type"])
26
26
  assert_match(/Content-Disposition: form-data/, req.body)
@@ -40,7 +40,7 @@ class VisualRecognitionV4Test < Minitest::Test
40
40
  end
41
41
 
42
42
  def test_analyze_url
43
- stub_request(:post, "https://gateway.watsonplatform.net/visual-recognition/api/v4/analyze?version=2018-03-19").with do |req|
43
+ stub_request(:post, "https://api.us-south.visual-recognition.watson.cloud.ibm.com/v4/analyze?version=2018-03-19").with do |req|
44
44
  assert_equal(req.headers["Accept"], "application/json")
45
45
  assert_match(%r{\Amultipart/form-data}, req.headers["Content-Type"])
46
46
  assert_match(/Content-Disposition: form-data; name="image_url"/, req.body)
@@ -67,11 +67,11 @@ class VisualRecognitionV4Test < Minitest::Test
67
67
  }
68
68
  ]
69
69
  }
70
- stub_request(:post, "https://gateway.watsonplatform.net/visual-recognition/api/v4/collections?version=2018-03-19")
70
+ stub_request(:post, "https://api.us-south.visual-recognition.watson.cloud.ibm.com/v4/collections?version=2018-03-19")
71
71
  .with(
72
72
  headers: {
73
73
  "Accept" => "application/json",
74
- "Host" => "gateway.watsonplatform.net"
74
+ "Host" => "api.us-south.visual-recognition.watson.cloud.ibm.com"
75
75
  }
76
76
  ).to_return(status: 200, body: response.to_json, headers: { "Content-Type" => "application/json" })
77
77
  service_response = service.create_collection(
@@ -85,11 +85,11 @@ class VisualRecognitionV4Test < Minitest::Test
85
85
  response = {
86
86
  "collections" => []
87
87
  }
88
- stub_request(:get, "https://gateway.watsonplatform.net/visual-recognition/api/v4/collections?version=2018-03-19")
88
+ stub_request(:get, "https://api.us-south.visual-recognition.watson.cloud.ibm.com/v4/collections?version=2018-03-19")
89
89
  .with(
90
90
  headers: {
91
91
  "Accept" => "application/json",
92
- "Host" => "gateway.watsonplatform.net"
92
+ "Host" => "api.us-south.visual-recognition.watson.cloud.ibm.com"
93
93
  }
94
94
  ).to_return(status: 200, body: response.to_json, headers: { "Content-Type" => "application/json" })
95
95
  service_response = service.list_collections
@@ -109,11 +109,11 @@ class VisualRecognitionV4Test < Minitest::Test
109
109
  }
110
110
  ]
111
111
  }
112
- stub_request(:get, "https://gateway.watsonplatform.net/visual-recognition/api/v4/collections/collid?version=2018-03-19")
112
+ stub_request(:get, "https://api.us-south.visual-recognition.watson.cloud.ibm.com/v4/collections/collid?version=2018-03-19")
113
113
  .with(
114
114
  headers: {
115
115
  "Accept" => "application/json",
116
- "Host" => "gateway.watsonplatform.net"
116
+ "Host" => "api.us-south.visual-recognition.watson.cloud.ibm.com"
117
117
  }
118
118
  ).to_return(status: 200, body: response.to_json, headers: { "Content-Type" => "application/json" })
119
119
  service_response = service.get_collection(
@@ -135,11 +135,11 @@ class VisualRecognitionV4Test < Minitest::Test
135
135
  }
136
136
  ]
137
137
  }
138
- stub_request(:post, "https://gateway.watsonplatform.net/visual-recognition/api/v4/collections/collid?version=2018-03-19")
138
+ stub_request(:post, "https://api.us-south.visual-recognition.watson.cloud.ibm.com/v4/collections/collid?version=2018-03-19")
139
139
  .with(
140
140
  headers: {
141
141
  "Accept" => "application/json",
142
- "Host" => "gateway.watsonplatform.net"
142
+ "Host" => "api.us-south.visual-recognition.watson.cloud.ibm.com"
143
143
  }
144
144
  ).to_return(status: 200, body: response.to_json, headers: { "Content-Type" => "application/json" })
145
145
  service_response = service.update_collection(
@@ -150,11 +150,11 @@ class VisualRecognitionV4Test < Minitest::Test
150
150
 
151
151
  def test_delete_collection
152
152
  response = {}
153
- stub_request(:delete, "https://gateway.watsonplatform.net/visual-recognition/api/v4/collections/collid?version=2018-03-19")
153
+ stub_request(:delete, "https://api.us-south.visual-recognition.watson.cloud.ibm.com/v4/collections/collid?version=2018-03-19")
154
154
  .with(
155
155
  headers: {
156
156
  "Accept" => "application/json",
157
- "Host" => "gateway.watsonplatform.net"
157
+ "Host" => "api.us-south.visual-recognition.watson.cloud.ibm.com"
158
158
  }
159
159
  ).to_return(status: 200, body: response.to_json, headers: { "Content-Type" => "application/json" })
160
160
  service_response = service.delete_collection(
@@ -168,11 +168,11 @@ class VisualRecognitionV4Test < Minitest::Test
168
168
  "collection_id" => "collid"
169
169
  }
170
170
  file = File.open(Dir.getwd + "/resources/cnc_test.pdf")
171
- stub_request(:post, "https://gateway.watsonplatform.net/visual-recognition/api/v4/collections/collid/images?version=2018-03-19")
171
+ stub_request(:post, "https://api.us-south.visual-recognition.watson.cloud.ibm.com/v4/collections/collid/images?version=2018-03-19")
172
172
  .with(
173
173
  headers: {
174
174
  "Accept" => "application/json",
175
- "Host" => "gateway.watsonplatform.net"
175
+ "Host" => "api.us-south.visual-recognition.watson.cloud.ibm.com"
176
176
  }
177
177
  ).to_return(status: 200, body: response.to_json, headers: { "Content-Type" => "application/json" })
178
178
  service_response = service.add_images(
@@ -192,11 +192,11 @@ class VisualRecognitionV4Test < Minitest::Test
192
192
  response = {
193
193
  "collections" => []
194
194
  }
195
- stub_request(:get, "https://gateway.watsonplatform.net/visual-recognition/api/v4/collections/collid/images?version=2018-03-19")
195
+ stub_request(:get, "https://api.us-south.visual-recognition.watson.cloud.ibm.com/v4/collections/collid/images?version=2018-03-19")
196
196
  .with(
197
197
  headers: {
198
198
  "Accept" => "application/json",
199
- "Host" => "gateway.watsonplatform.net"
199
+ "Host" => "api.us-south.visual-recognition.watson.cloud.ibm.com"
200
200
  }
201
201
  ).to_return(status: 200, body: response.to_json, headers: { "Content-Type" => "application/json" })
202
202
  service_response = service.list_images(
@@ -209,11 +209,11 @@ class VisualRecognitionV4Test < Minitest::Test
209
209
  response = {
210
210
  "collection_id" => "collid"
211
211
  }
212
- stub_request(:get, "https://gateway.watsonplatform.net/visual-recognition/api/v4/collections/collid/images/imageid?version=2018-03-19")
212
+ stub_request(:get, "https://api.us-south.visual-recognition.watson.cloud.ibm.com/v4/collections/collid/images/imageid?version=2018-03-19")
213
213
  .with(
214
214
  headers: {
215
215
  "Accept" => "application/json",
216
- "Host" => "gateway.watsonplatform.net"
216
+ "Host" => "api.us-south.visual-recognition.watson.cloud.ibm.com"
217
217
  }
218
218
  ).to_return(status: 200, body: response.to_json, headers: { "Content-Type" => "application/json" })
219
219
  service_response = service.get_image_details(
@@ -225,11 +225,11 @@ class VisualRecognitionV4Test < Minitest::Test
225
225
 
226
226
  def test_delete_image
227
227
  response = {}
228
- stub_request(:delete, "https://gateway.watsonplatform.net/visual-recognition/api/v4/collections/collid/images/imageid?version=2018-03-19")
228
+ stub_request(:delete, "https://api.us-south.visual-recognition.watson.cloud.ibm.com/v4/collections/collid/images/imageid?version=2018-03-19")
229
229
  .with(
230
230
  headers: {
231
231
  "Accept" => "application/json",
232
- "Host" => "gateway.watsonplatform.net"
232
+ "Host" => "api.us-south.visual-recognition.watson.cloud.ibm.com"
233
233
  }
234
234
  ).to_return(status: 200, body: response.to_json, headers: { "Content-Type" => "application/json" })
235
235
  service_response = service.delete_image(
@@ -243,10 +243,10 @@ class VisualRecognitionV4Test < Minitest::Test
243
243
  response = {
244
244
  "collection_id" => "collid"
245
245
  }
246
- stub_request(:get, "https://gateway.watsonplatform.net/visual-recognition/api/v4/collections/collid/images/imageid/jpeg?version=2018-03-19")
246
+ stub_request(:get, "https://api.us-south.visual-recognition.watson.cloud.ibm.com/v4/collections/collid/images/imageid/jpeg?version=2018-03-19")
247
247
  .with(
248
248
  headers: {
249
- "Host" => "gateway.watsonplatform.net"
249
+ "Host" => "api.us-south.visual-recognition.watson.cloud.ibm.com"
250
250
  }
251
251
  ).to_return(status: 200, body: response.to_json, headers: { "Content-Type" => "application/json" })
252
252
  service_response = service.get_jpeg_image(
@@ -260,10 +260,10 @@ class VisualRecognitionV4Test < Minitest::Test
260
260
  response = {
261
261
  "collection_id" => "collid"
262
262
  }
263
- stub_request(:post, "https://gateway.watsonplatform.net/visual-recognition/api/v4/collections/collid/train?version=2018-03-19")
263
+ stub_request(:post, "https://api.us-south.visual-recognition.watson.cloud.ibm.com/v4/collections/collid/train?version=2018-03-19")
264
264
  .with(
265
265
  headers: {
266
- "Host" => "gateway.watsonplatform.net"
266
+ "Host" => "api.us-south.visual-recognition.watson.cloud.ibm.com"
267
267
  }
268
268
  ).to_return(status: 200, body: response.to_json, headers: { "Content-Type" => "application/json" })
269
269
  service_response = service.train(
@@ -276,11 +276,11 @@ class VisualRecognitionV4Test < Minitest::Test
276
276
  response = {
277
277
  "collection_id" => "collid"
278
278
  }
279
- stub_request(:post, "https://gateway.watsonplatform.net/visual-recognition/api/v4/collections/collid/images/imageid/training_data?version=2018-03-19")
279
+ stub_request(:post, "https://api.us-south.visual-recognition.watson.cloud.ibm.com/v4/collections/collid/images/imageid/training_data?version=2018-03-19")
280
280
  .with(
281
281
  headers: {
282
282
  "Accept" => "application/json",
283
- "Host" => "gateway.watsonplatform.net"
283
+ "Host" => "api.us-south.visual-recognition.watson.cloud.ibm.com"
284
284
  }
285
285
  ).to_return(status: 200, body: response.to_json, headers: { "Content-Type" => "application/json" })
286
286
  service_response = service.add_image_training_data(
@@ -303,11 +303,11 @@ class VisualRecognitionV4Test < Minitest::Test
303
303
 
304
304
  def test_delete_user_data
305
305
  response = {}
306
- stub_request(:delete, "https://gateway.watsonplatform.net/visual-recognition/api/v4/user_data?version=2018-03-19&customer_id=customer")
306
+ stub_request(:delete, "https://api.us-south.visual-recognition.watson.cloud.ibm.com/v4/user_data?version=2018-03-19&customer_id=customer")
307
307
  .with(
308
308
  headers: {
309
309
  "Accept" => "application/json",
310
- "Host" => "gateway.watsonplatform.net"
310
+ "Host" => "api.us-south.visual-recognition.watson.cloud.ibm.com"
311
311
  }
312
312
  ).to_return(status: 200, body: response.to_json, headers: { "Content-Type" => "application/json" })
313
313
  service_response = service.delete_user_data(
@@ -320,10 +320,10 @@ class VisualRecognitionV4Test < Minitest::Test
320
320
  response = {
321
321
  "usage" => "usage"
322
322
  }
323
- stub_request(:get, "https://gateway.watsonplatform.net/visual-recognition/api/v4/training_usage?end_time=end&start_time=start&version=2018-03-19")
323
+ stub_request(:get, "https://api.us-south.visual-recognition.watson.cloud.ibm.com/v4/training_usage?end_time=end&start_time=start&version=2018-03-19")
324
324
  .with(
325
325
  headers: {
326
- "Host" => "gateway.watsonplatform.net"
326
+ "Host" => "api.us-south.visual-recognition.watson.cloud.ibm.com"
327
327
  }
328
328
  ).to_return(status: 200, body: response.to_json, headers: { "Content-Type" => "application/json" })
329
329
  service_response = service.get_training_usage(
@@ -337,11 +337,11 @@ class VisualRecognitionV4Test < Minitest::Test
337
337
  response = {
338
338
  "objects" => []
339
339
  }
340
- stub_request(:get, "https://gateway.watsonplatform.net/visual-recognition/api/v4/collections/collid/objects?version=2018-03-19")
340
+ stub_request(:get, "https://api.us-south.visual-recognition.watson.cloud.ibm.com/v4/collections/collid/objects?version=2018-03-19")
341
341
  .with(
342
342
  headers: {
343
343
  "Accept" => "application/json",
344
- "Host" => "gateway.watsonplatform.net"
344
+ "Host" => "api.us-south.visual-recognition.watson.cloud.ibm.com"
345
345
  }
346
346
  ).to_return(status: 200, body: response.to_json, headers: { "Content-Type" => "application/json" })
347
347
  service_response = service.list_object_metadata(
@@ -354,11 +354,11 @@ class VisualRecognitionV4Test < Minitest::Test
354
354
  response = {
355
355
  "objects" => []
356
356
  }
357
- stub_request(:post, "https://gateway.watsonplatform.net/visual-recognition/api/v4/collections/collid/objects/old_object?version=2018-03-19")
357
+ stub_request(:post, "https://api.us-south.visual-recognition.watson.cloud.ibm.com/v4/collections/collid/objects/old_object?version=2018-03-19")
358
358
  .with(
359
359
  headers: {
360
360
  "Accept" => "application/json",
361
- "Host" => "gateway.watsonplatform.net"
361
+ "Host" => "api.us-south.visual-recognition.watson.cloud.ibm.com"
362
362
  }
363
363
  ).to_return(status: 200, body: response.to_json, headers: { "Content-Type" => "application/json" })
364
364
  service_response = service.update_object_metadata(
@@ -373,11 +373,11 @@ class VisualRecognitionV4Test < Minitest::Test
373
373
  response = {
374
374
  "objects" => []
375
375
  }
376
- stub_request(:get, "https://gateway.watsonplatform.net/visual-recognition/api/v4/collections/collid/objects/object?version=2018-03-19")
376
+ stub_request(:get, "https://api.us-south.visual-recognition.watson.cloud.ibm.com/v4/collections/collid/objects/object?version=2018-03-19")
377
377
  .with(
378
378
  headers: {
379
379
  "Accept" => "application/json",
380
- "Host" => "gateway.watsonplatform.net"
380
+ "Host" => "api.us-south.visual-recognition.watson.cloud.ibm.com"
381
381
  }
382
382
  ).to_return(status: 200, body: response.to_json, headers: { "Content-Type" => "application/json" })
383
383
  service_response = service.get_object_metadata(
@@ -388,11 +388,11 @@ class VisualRecognitionV4Test < Minitest::Test
388
388
  end
389
389
 
390
390
  def test_delete_object
391
- stub_request(:delete, "https://gateway.watsonplatform.net/visual-recognition/api/v4/collections/collid/objects/object?version=2018-03-19")
391
+ stub_request(:delete, "https://api.us-south.visual-recognition.watson.cloud.ibm.com/v4/collections/collid/objects/object?version=2018-03-19")
392
392
  .with(
393
393
  headers: {
394
394
  "Accept" => "application/json",
395
- "Host" => "gateway.watsonplatform.net"
395
+ "Host" => "api.us-south.visual-recognition.watson.cloud.ibm.com"
396
396
  }
397
397
  ).to_return(status: 200, body: {}.to_json, headers: { "Content-Type" => "application/json" })
398
398
  service_response = service.delete_object(
@@ -401,4 +401,22 @@ class VisualRecognitionV4Test < Minitest::Test
401
401
  )
402
402
  assert_nil(service_response)
403
403
  end
404
+
405
+ def test_get_model_file
406
+ response = {
407
+ "binary" => []
408
+ }
409
+ stub_request(:get, "https://api.us-south.visual-recognition.watson.cloud.ibm.com/v4/collections/collid/model?feature=objects&model_format=rscnn_ready&version=2018-03-19")
410
+ .with(
411
+ headers: {
412
+ "Host" => "api.us-south.visual-recognition.watson.cloud.ibm.com"
413
+ }
414
+ ).to_return(status: 200, body: response.to_json, headers: { "Content-Type" => "application/json" })
415
+ service_response = service.get_model_file(
416
+ collection_id: "collid",
417
+ feature: "objects",
418
+ model_format: "rscnn_ready"
419
+ )
420
+ assert_equal(response, service_response.result)
421
+ end
404
422
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ibm_watson
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.1
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Max Nussbaum
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-03-20 00:00:00.000000000 Z
11
+ date: 2020-12-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: concurrent-ruby
@@ -346,7 +346,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
346
346
  - !ruby/object:Gem::Version
347
347
  version: '0'
348
348
  requirements: []
349
- rubygems_version: 3.1.2
349
+ rubygems_version: 3.1.5
350
350
  signing_key:
351
351
  specification_version: 4
352
352
  summary: Official client library to use the IBM Watson Services