ibm_watson 1.0.0.rc2 → 1.0.0.rc3

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 (44) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +33 -27
  3. data/lib/ibm_watson/assistant_v1.rb +6 -80
  4. data/lib/ibm_watson/assistant_v2.rb +6 -38
  5. data/lib/ibm_watson/compare_comply_v1.rb +6 -47
  6. data/lib/ibm_watson/discovery_v1.rb +12 -297
  7. data/lib/ibm_watson/language_translator_v3.rb +6 -41
  8. data/lib/ibm_watson/natural_language_classifier_v1.rb +6 -35
  9. data/lib/ibm_watson/natural_language_understanding_v1.rb +6 -38
  10. data/lib/ibm_watson/personality_insights_v3.rb +6 -30
  11. data/lib/ibm_watson/speech_to_text_v1.rb +9 -130
  12. data/lib/ibm_watson/text_to_speech_v1.rb +6 -50
  13. data/lib/ibm_watson/tone_analyzer_v3.rb +6 -31
  14. data/lib/ibm_watson/version.rb +1 -1
  15. data/lib/ibm_watson/visual_recognition_v3.rb +8 -103
  16. data/lib/ibm_watson/websocket/speech_to_text_websocket_listener.rb +5 -5
  17. data/lib/ibm_watson.rb +9 -0
  18. data/test/integration/test_assistant_v1.rb +1 -1
  19. data/test/integration/test_assistant_v2.rb +1 -1
  20. data/test/integration/test_compare_comply_v1.rb +1 -1
  21. data/test/integration/test_discovery_v1.rb +1 -4
  22. data/test/integration/test_language_translator_v3.rb +1 -1
  23. data/test/integration/test_natural_language_classifier_v1.rb +1 -1
  24. data/test/integration/test_natural_language_understanding_v1.rb +1 -1
  25. data/test/integration/test_personality_insights_v3.rb +1 -1
  26. data/test/integration/test_speech_to_text_v1.rb +2 -2
  27. data/test/integration/test_text_to_speech_v1.rb +1 -1
  28. data/test/integration/test_tone_analyzer_v3.rb +1 -1
  29. data/test/integration/test_visual_recognition_v3.rb +1 -8
  30. data/test/unit/test_assistant_v1.rb +45 -45
  31. data/test/unit/test_assistant_v2.rb +3 -3
  32. data/test/unit/test_compare_comply_v1.rb +12 -12
  33. data/test/unit/test_configure_http_client.rb +37 -13
  34. data/test/unit/test_discovery_v1.rb +47 -139
  35. data/test/unit/test_language_translator_v3.rb +13 -26
  36. data/test/unit/test_natural_language_classifier_v1.rb +2 -2
  37. data/test/unit/test_natural_language_understanding_v1.rb +5 -5
  38. data/test/unit/test_personality_insights_v3.rb +8 -8
  39. data/test/unit/test_speech_to_text_v1.rb +21 -21
  40. data/test/unit/test_text_to_speech_v1.rb +5 -5
  41. data/test/unit/test_tone_analyzer_v3.rb +9 -9
  42. data/test/unit/test_vcap_using_personality_insights.rb +8 -8
  43. data/test/unit/test_visual_recognition_v3.rb +8 -75
  44. metadata +4 -4
@@ -47,44 +47,21 @@ module IBMWatson
47
47
  # Instead, specify a version date that is compatible with your
48
48
  # application, and don't change it until your application is
49
49
  # ready for a later version.
50
- # @option args url [String] The base url to use when contacting the service (e.g.
51
- # "https://gateway.watsonplatform.net/language-translator/api").
52
- # The base url may differ between IBM Cloud regions.
53
- # @option args username [String] The username used to authenticate with the service.
54
- # Username and password credentials are only required to run your
55
- # application locally or outside of IBM Cloud. When running on
56
- # IBM Cloud, the credentials will be automatically loaded from the
57
- # `VCAP_SERVICES` environment variable.
58
- # @option args password [String] The password used to authenticate with the service.
59
- # Username and password credentials are only required to run your
60
- # application locally or outside of IBM Cloud. When running on
61
- # IBM Cloud, the credentials will be automatically loaded from the
62
- # `VCAP_SERVICES` environment variable.
63
- # @option args iam_apikey [String] An API key that can be used to request IAM tokens. If
64
- # this API key is provided, the SDK will manage the token and handle the
65
- # refreshing.
66
- # @option args iam_access_token [String] An IAM access token is fully managed by the application.
67
- # Responsibility falls on the application to refresh the token, either before
68
- # it expires or reactively upon receiving a 401 from the service as any requests
69
- # made with an expired token will fail.
70
- # @option args iam_url [String] An optional URL for the IAM service API. Defaults to
71
- # 'https://iam.cloud.ibm.com/identity/token'.
72
- # @option args iam_client_id [String] An optional client id for the IAM service API.
73
- # @option args iam_client_secret [String] An optional client secret for the IAM service API.
74
- # @option args authentication_type [STRING] Specifies the authentication pattern to use. Values that it
75
- # takes are basic, iam or icp4d.
50
+ # @option args service_url [String] The base service URL to use when contacting the service.
51
+ # The base service_url may differ between IBM Cloud regions.
52
+ # @option args authenticator [Object] The Authenticator instance to be configured for this service.
76
53
  def initialize(args = {})
77
54
  @__async_initialized__ = false
78
55
  defaults = {}
79
56
  defaults[:version] = nil
80
- defaults[:url] = "https://gateway.watsonplatform.net/language-translator/api"
57
+ defaults[:service_url] = "https://gateway.watsonplatform.net/language-translator/api"
81
58
  defaults[:authenticator] = nil
82
- defaults[:authentication_type] = nil
83
59
  args = defaults.merge(args)
84
60
  @version = args[:version]
85
61
  raise ArgumentError.new("version must be provided") if @version.nil?
86
62
 
87
- args[:display_name] = "Language Translator"
63
+ args[:service_name] = "language_translator"
64
+ args[:authenticator] = IBMCloudSdkCore::ConfigBasedAuthenticatorFactory.new.get_authenticator(service_name: args[:service_name]) if args[:authenticator].nil?
88
65
  super
89
66
  end
90
67
 
@@ -124,7 +101,6 @@ module IBMWatson
124
101
 
125
102
  method_url = "/v3/translate"
126
103
 
127
- headers = authenticator.authenticate(headers)
128
104
  response = request(
129
105
  method: "POST",
130
106
  url: method_url,
@@ -157,7 +133,6 @@ module IBMWatson
157
133
 
158
134
  method_url = "/v3/identifiable_languages"
159
135
 
160
- headers = authenticator.authenticate(headers)
161
136
  response = request(
162
137
  method: "GET",
163
138
  url: method_url,
@@ -191,7 +166,6 @@ module IBMWatson
191
166
 
192
167
  method_url = "/v3/identify"
193
168
 
194
- headers = authenticator.authenticate(headers)
195
169
  response = request(
196
170
  method: "POST",
197
171
  url: method_url,
@@ -232,7 +206,6 @@ module IBMWatson
232
206
 
233
207
  method_url = "/v3/models"
234
208
 
235
- headers = authenticator.authenticate(headers)
236
209
  response = request(
237
210
  method: "GET",
238
211
  url: method_url,
@@ -309,7 +282,6 @@ module IBMWatson
309
282
 
310
283
  method_url = "/v3/models"
311
284
 
312
- headers = authenticator.authenticate(headers)
313
285
  response = request(
314
286
  method: "POST",
315
287
  url: method_url,
@@ -341,7 +313,6 @@ module IBMWatson
341
313
 
342
314
  method_url = "/v3/models/%s" % [ERB::Util.url_encode(model_id)]
343
315
 
344
- headers = authenticator.authenticate(headers)
345
316
  response = request(
346
317
  method: "DELETE",
347
318
  url: method_url,
@@ -374,7 +345,6 @@ module IBMWatson
374
345
 
375
346
  method_url = "/v3/models/%s" % [ERB::Util.url_encode(model_id)]
376
347
 
377
- headers = authenticator.authenticate(headers)
378
348
  response = request(
379
349
  method: "GET",
380
350
  url: method_url,
@@ -405,7 +375,6 @@ module IBMWatson
405
375
 
406
376
  method_url = "/v3/documents"
407
377
 
408
- headers = authenticator.authenticate(headers)
409
378
  response = request(
410
379
  method: "GET",
411
380
  url: method_url,
@@ -467,7 +436,6 @@ module IBMWatson
467
436
 
468
437
  method_url = "/v3/documents"
469
438
 
470
- headers = authenticator.authenticate(headers)
471
439
  response = request(
472
440
  method: "POST",
473
441
  url: method_url,
@@ -499,7 +467,6 @@ module IBMWatson
499
467
 
500
468
  method_url = "/v3/documents/%s" % [ERB::Util.url_encode(document_id)]
501
469
 
502
- headers = authenticator.authenticate(headers)
503
470
  response = request(
504
471
  method: "GET",
505
472
  url: method_url,
@@ -530,7 +497,6 @@ module IBMWatson
530
497
 
531
498
  method_url = "/v3/documents/%s" % [ERB::Util.url_encode(document_id)]
532
499
 
533
- headers = authenticator.authenticate(headers)
534
500
  request(
535
501
  method: "DELETE",
536
502
  url: method_url,
@@ -575,7 +541,6 @@ module IBMWatson
575
541
 
576
542
  method_url = "/v3/documents/%s/translated_document" % [ERB::Util.url_encode(document_id)]
577
543
 
578
- headers = authenticator.authenticate(headers)
579
544
  response = request(
580
545
  method: "GET",
581
546
  url: method_url,
@@ -36,40 +36,17 @@ module IBMWatson
36
36
  # Construct a new client for the Natural Language Classifier service.
37
37
  #
38
38
  # @param args [Hash] The args to initialize with
39
- # @option args url [String] The base url to use when contacting the service (e.g.
40
- # "https://gateway.watsonplatform.net/natural-language-classifier/api").
41
- # The base url may differ between IBM Cloud regions.
42
- # @option args username [String] The username used to authenticate with the service.
43
- # Username and password credentials are only required to run your
44
- # application locally or outside of IBM Cloud. When running on
45
- # IBM Cloud, the credentials will be automatically loaded from the
46
- # `VCAP_SERVICES` environment variable.
47
- # @option args password [String] The password used to authenticate with the service.
48
- # Username and password credentials are only required to run your
49
- # application locally or outside of IBM Cloud. When running on
50
- # IBM Cloud, the credentials will be automatically loaded from the
51
- # `VCAP_SERVICES` environment variable.
52
- # @option args iam_apikey [String] An API key that can be used to request IAM tokens. If
53
- # this API key is provided, the SDK will manage the token and handle the
54
- # refreshing.
55
- # @option args iam_access_token [String] An IAM access token is fully managed by the application.
56
- # Responsibility falls on the application to refresh the token, either before
57
- # it expires or reactively upon receiving a 401 from the service as any requests
58
- # made with an expired token will fail.
59
- # @option args iam_url [String] An optional URL for the IAM service API. Defaults to
60
- # 'https://iam.cloud.ibm.com/identity/token'.
61
- # @option args iam_client_id [String] An optional client id for the IAM service API.
62
- # @option args iam_client_secret [String] An optional client secret for the IAM service API.
63
- # @option args authentication_type [STRING] Specifies the authentication pattern to use. Values that it
64
- # takes are basic, iam or icp4d.
39
+ # @option args service_url [String] The base service URL to use when contacting the service.
40
+ # The base service_url may differ between IBM Cloud regions.
41
+ # @option args authenticator [Object] The Authenticator instance to be configured for this service.
65
42
  def initialize(args = {})
66
43
  @__async_initialized__ = false
67
44
  defaults = {}
68
- defaults[:url] = "https://gateway.watsonplatform.net/natural-language-classifier/api"
45
+ defaults[:service_url] = "https://gateway.watsonplatform.net/natural-language-classifier/api"
69
46
  defaults[:authenticator] = nil
70
- defaults[:authentication_type] = nil
71
47
  args = defaults.merge(args)
72
- args[:display_name] = "Natural Language Classifier"
48
+ args[:service_name] = "natural_language_classifier"
49
+ args[:authenticator] = IBMCloudSdkCore::ConfigBasedAuthenticatorFactory.new.get_authenticator(service_name: args[:service_name]) if args[:authenticator].nil?
73
50
  super
74
51
  end
75
52
 
@@ -101,7 +78,6 @@ module IBMWatson
101
78
 
102
79
  method_url = "/v1/classifiers/%s/classify" % [ERB::Util.url_encode(classifier_id)]
103
80
 
104
- headers = authenticator.authenticate(headers)
105
81
  response = request(
106
82
  method: "POST",
107
83
  url: method_url,
@@ -138,7 +114,6 @@ module IBMWatson
138
114
 
139
115
  method_url = "/v1/classifiers/%s/classify_collection" % [ERB::Util.url_encode(classifier_id)]
140
116
 
141
- headers = authenticator.authenticate(headers)
142
117
  response = request(
143
118
  method: "POST",
144
119
  url: method_url,
@@ -192,7 +167,6 @@ module IBMWatson
192
167
 
193
168
  method_url = "/v1/classifiers"
194
169
 
195
- headers = authenticator.authenticate(headers)
196
170
  response = request(
197
171
  method: "POST",
198
172
  url: method_url,
@@ -216,7 +190,6 @@ module IBMWatson
216
190
 
217
191
  method_url = "/v1/classifiers"
218
192
 
219
- headers = authenticator.authenticate(headers)
220
193
  response = request(
221
194
  method: "GET",
222
195
  url: method_url,
@@ -242,7 +215,6 @@ module IBMWatson
242
215
 
243
216
  method_url = "/v1/classifiers/%s" % [ERB::Util.url_encode(classifier_id)]
244
217
 
245
- headers = authenticator.authenticate(headers)
246
218
  response = request(
247
219
  method: "GET",
248
220
  url: method_url,
@@ -267,7 +239,6 @@ module IBMWatson
267
239
 
268
240
  method_url = "/v1/classifiers/%s" % [ERB::Util.url_encode(classifier_id)]
269
241
 
270
- headers = authenticator.authenticate(headers)
271
242
  request(
272
243
  method: "DELETE",
273
244
  url: method_url,
@@ -51,50 +51,21 @@ module IBMWatson
51
51
  # Instead, specify a version date that is compatible with your
52
52
  # application, and don't change it until your application is
53
53
  # ready for a later version.
54
- # @option args url [String] The base url to use when contacting the service (e.g.
55
- # "https://gateway.watsonplatform.net/natural-language-understanding/api").
56
- # The base url may differ between IBM Cloud regions.
57
- # @option args username [String] The username used to authenticate with the service.
58
- # Username and password credentials are only required to run your
59
- # application locally or outside of IBM Cloud. When running on
60
- # IBM Cloud, the credentials will be automatically loaded from the
61
- # `VCAP_SERVICES` environment variable.
62
- # @option args password [String] The password used to authenticate with the service.
63
- # Username and password credentials are only required to run your
64
- # application locally or outside of IBM Cloud. When running on
65
- # IBM Cloud, the credentials will be automatically loaded from the
66
- # `VCAP_SERVICES` environment variable.
67
- # @option args iam_apikey [String] An API key that can be used to request IAM tokens. If
68
- # this API key is provided, the SDK will manage the token and handle the
69
- # refreshing.
70
- # @option args iam_access_token [String] An IAM access token is fully managed by the application.
71
- # Responsibility falls on the application to refresh the token, either before
72
- # it expires or reactively upon receiving a 401 from the service as any requests
73
- # made with an expired token will fail.
74
- # @option args iam_url [String] An optional URL for the IAM service API. Defaults to
75
- # 'https://iam.cloud.ibm.com/identity/token'.
76
- # @option args iam_client_id [String] An optional client id for the IAM service API.
77
- # @option args iam_client_secret [String] An optional client secret for the IAM service API.
78
- # @option args icp4d_access_token [STRING] A ICP4D(IBM Cloud Pak for Data) access token is
79
- # fully managed by the application. Responsibility falls on the application to
80
- # refresh the token, either before it expires or reactively upon receiving a 401
81
- # from the service as any requests made with an expired token will fail.
82
- # @option args icp4d_url [STRING] In order to use an SDK-managed token with ICP4D authentication, this
83
- # URL must be passed in.
84
- # @option args authentication_type [STRING] Specifies the authentication pattern to use. Values that it
85
- # takes are basic, iam or icp4d.
54
+ # @option args service_url [String] The base service URL to use when contacting the service.
55
+ # The base service_url may differ between IBM Cloud regions.
56
+ # @option args authenticator [Object] The Authenticator instance to be configured for this service.
86
57
  def initialize(args = {})
87
58
  @__async_initialized__ = false
88
59
  defaults = {}
89
60
  defaults[:version] = nil
90
- defaults[:url] = "https://gateway.watsonplatform.net/natural-language-understanding/api"
61
+ defaults[:service_url] = "https://gateway.watsonplatform.net/natural-language-understanding/api"
91
62
  defaults[:authenticator] = nil
92
- defaults[:authentication_type] = nil
93
63
  args = defaults.merge(args)
94
64
  @version = args[:version]
95
65
  raise ArgumentError.new("version must be provided") if @version.nil?
96
66
 
97
- args[:display_name] = "Natural Language Understanding"
67
+ args[:service_name] = "natural_language_understanding"
68
+ args[:authenticator] = IBMCloudSdkCore::ConfigBasedAuthenticatorFactory.new.get_authenticator(service_name: args[:service_name]) if args[:authenticator].nil?
98
69
  super
99
70
  end
100
71
 
@@ -168,7 +139,6 @@ module IBMWatson
168
139
 
169
140
  method_url = "/v1/analyze"
170
141
 
171
- headers = authenticator.authenticate(headers)
172
142
  response = request(
173
143
  method: "POST",
174
144
  url: method_url,
@@ -202,7 +172,6 @@ module IBMWatson
202
172
 
203
173
  method_url = "/v1/models"
204
174
 
205
- headers = authenticator.authenticate(headers)
206
175
  response = request(
207
176
  method: "GET",
208
177
  url: method_url,
@@ -233,7 +202,6 @@ module IBMWatson
233
202
 
234
203
  method_url = "/v1/models/%s" % [ERB::Util.url_encode(model_id)]
235
204
 
236
- headers = authenticator.authenticate(headers)
237
205
  response = request(
238
206
  method: "DELETE",
239
207
  url: method_url,
@@ -62,44 +62,21 @@ module IBMWatson
62
62
  # Instead, specify a version date that is compatible with your
63
63
  # application, and don't change it until your application is
64
64
  # ready for a later version.
65
- # @option args url [String] The base url to use when contacting the service (e.g.
66
- # "https://gateway.watsonplatform.net/personality-insights/api").
67
- # The base url may differ between IBM Cloud regions.
68
- # @option args username [String] The username used to authenticate with the service.
69
- # Username and password credentials are only required to run your
70
- # application locally or outside of IBM Cloud. When running on
71
- # IBM Cloud, the credentials will be automatically loaded from the
72
- # `VCAP_SERVICES` environment variable.
73
- # @option args password [String] The password used to authenticate with the service.
74
- # Username and password credentials are only required to run your
75
- # application locally or outside of IBM Cloud. When running on
76
- # IBM Cloud, the credentials will be automatically loaded from the
77
- # `VCAP_SERVICES` environment variable.
78
- # @option args iam_apikey [String] An API key that can be used to request IAM tokens. If
79
- # this API key is provided, the SDK will manage the token and handle the
80
- # refreshing.
81
- # @option args iam_access_token [String] An IAM access token is fully managed by the application.
82
- # Responsibility falls on the application to refresh the token, either before
83
- # it expires or reactively upon receiving a 401 from the service as any requests
84
- # made with an expired token will fail.
85
- # @option args iam_url [String] An optional URL for the IAM service API. Defaults to
86
- # 'https://iam.cloud.ibm.com/identity/token'.
87
- # @option args iam_client_id [String] An optional client id for the IAM service API.
88
- # @option args iam_client_secret [String] An optional client secret for the IAM service API.
89
- # @option args authentication_type [STRING] Specifies the authentication pattern to use. Values that it
90
- # takes are basic, iam or icp4d.
65
+ # @option args service_url [String] The base service URL to use when contacting the service.
66
+ # The base service_url may differ between IBM Cloud regions.
67
+ # @option args authenticator [Object] The Authenticator instance to be configured for this service.
91
68
  def initialize(args = {})
92
69
  @__async_initialized__ = false
93
70
  defaults = {}
94
71
  defaults[:version] = nil
95
- defaults[:url] = "https://gateway.watsonplatform.net/personality-insights/api"
72
+ defaults[:service_url] = "https://gateway.watsonplatform.net/personality-insights/api"
96
73
  defaults[:authenticator] = nil
97
- defaults[:authentication_type] = nil
98
74
  args = defaults.merge(args)
99
75
  @version = args[:version]
100
76
  raise ArgumentError.new("version must be provided") if @version.nil?
101
77
 
102
- args[:display_name] = "Personality Insights"
78
+ args[:service_name] = "personality_insights"
79
+ args[:authenticator] = IBMCloudSdkCore::ConfigBasedAuthenticatorFactory.new.get_authenticator(service_name: args[:service_name]) if args[:authenticator].nil?
103
80
  super
104
81
  end
105
82
 
@@ -215,7 +192,6 @@ module IBMWatson
215
192
 
216
193
  method_url = "/v3/profile"
217
194
 
218
- headers = authenticator.authenticate(headers)
219
195
  response = request(
220
196
  method: "POST",
221
197
  url: method_url,