ibm_watson 1.0.0.rc2 → 1.0.0.rc3

Sign up to get free protection for your applications and to get access to all the features.
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
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: '050885e55bcc8b89fbdb74a10139169ae76b0fe3692019c4910a1b0b4243ff37'
4
- data.tar.gz: 848225557c6df566dbba4fe5cdacccb5c6e42eb98ae3ae82e0e805011d05a329
3
+ metadata.gz: 0b31e9a1c0716de79a3d3414f8fd6f7416e344cbb0bc6e6e10fc1ab65640c7e5
4
+ data.tar.gz: bc1236ce05639ec9c74dc833d3ab1879ec69a5c68f547e9465b53918df1dc5f7
5
5
  SHA512:
6
- metadata.gz: 9b45193ccbea48bc4ac164c73ce88b6b165bedbed511cf61e0c26fdffb4e70a5e217997be7b9bd800096e1ad79ed3f8ed394c92b09406dfa6adf17038044d694
7
- data.tar.gz: 33b8b54b78e74b51e2ffaffbd3fc4e2825b45a16616aca5229d0f4cd85bc6a152a61acfb55fe6732209d8a3f2f09c3946f1db02407c3103efae14fa688c4b518
6
+ metadata.gz: '08bc9c5be324d9104cb530f0b7406f921a74dea49a6ff1cfa9593df4c641fe9b1e8e293fe074ea53a4f246d089fbfb44ffc4ee91cde8212a1508a217049cf745'
7
+ data.tar.gz: 90108045c649d473fe6a8defc62b4033fa86382a37862f96439d1f3b2e7302e34d9abaa45675e3a014b21d872eccde599dc47890eb08a23d730e45d29b45f23f
data/README.md CHANGED
@@ -13,23 +13,23 @@ Ruby gem to quickly get started with the various [IBM Watson][wdc] services.
13
13
  <details>
14
14
  <summary>Table of Contents</summary>
15
15
 
16
- * [Before you begin](#before-you-begin)
17
- * [Installation](#installation)
18
- * [Examples](#examples)
19
- * [Running in IBM Cloud](#running-in-ibm-cloud)
20
- * [Authentication](#authentication)
21
- * [Getting credentials](#getting-credentials)
22
- * [IAM](#iam)
23
- * [Username and password](#username-and-password)
24
- * [Sending requests asynchronously](#sending-requests-asynchronously)
25
- * [Sending request headers](#sending-request-headers)
26
- * [Parsing HTTP response info](#parsing-http-response-info)
27
- * [Configuring the HTTP client](#configuring-the-http-client)
28
- * [Using Websockets](#using-websockets)
29
- * [Ruby version](#ruby-version)
30
- * [Contributing](#contributing)
31
- * [License](#license)
32
- * [Featured Projects](#featured-projects)
16
+ * [Before you begin](#before-you-begin)
17
+ * [Installation](#installation)
18
+ * [Examples](#examples)
19
+ * [Running in IBM Cloud](#running-in-ibm-cloud)
20
+ * [Authentication](#authentication)
21
+ * [Getting credentials](#getting-credentials)
22
+ * [IAM](#iam)
23
+ * [Username and password](#username-and-password)
24
+ * [Sending requests asynchronously](#sending-requests-asynchronously)
25
+ * [Sending request headers](#sending-request-headers)
26
+ * [Parsing HTTP response info](#parsing-http-response-info)
27
+ * [Configuring the HTTP client](#configuring-the-http-client)
28
+ * [Using Websockets](#using-websockets)
29
+ * [Ruby version](#ruby-version)
30
+ * [Contributing](#contributing)
31
+ * [License](#license)
32
+ * [Featured Projects](#featured-projects)
33
33
 
34
34
  </details>
35
35
 
@@ -69,8 +69,8 @@ If you run your app in IBM Cloud, the SDK gets credentials from the [`VCAP_SERVI
69
69
 
70
70
  Watson services are migrating to token-based Identity and Access Management (IAM) authentication.
71
71
 
72
- - With some service instances, you authenticate to the API by using **[IAM](#iam)**.
73
- - In other instances, you authenticate by providing the **[username and password](#username-and-password)** for the service instance.
72
+ * With some service instances, you authenticate to the API by using **[IAM](#iam)**.
73
+ * In other instances, you authenticate by providing the **[username and password](#username-and-password)** for the service instance.
74
74
 
75
75
  ### Getting credentials
76
76
 
@@ -92,8 +92,8 @@ With a credential file, you just need to put the file in the right place and the
92
92
 
93
93
  The file downloaded will be called `ibm-credentials.env`. This is the name the SDK will search for and **must** be preserved unless you want to configure the file path (more on that later). The SDK will look for your `ibm-credentials.env` file in the following places (in order):
94
94
 
95
- - Your system's home directory
96
- - The top-level directory of the project you're using the SDK in
95
+ * Your system's home directory
96
+ * The top-level directory of the project you're using the SDK in
97
97
 
98
98
  As long as you set that up correctly, you don't have to worry about setting any authentication options in your code. So, for example, if you created and downloaded the credential file for your Discovery instance, you just need to do the following:
99
99
 
@@ -123,8 +123,8 @@ IBM Cloud is migrating to token-based Identity and Access Management (IAM) authe
123
123
 
124
124
  You supply either an IAM service **API key** or an **access token**:
125
125
 
126
- - Use the API key to have the SDK manage the lifecycle of the access token. The SDK requests an access token, ensures that the access token is valid, and refreshes it if necessary.
127
- - Use the access token if you want to manage the lifecycle yourself. For details, see [Authenticating with IAM tokens](https://cloud.ibm.com/docs/services/watson?topic=watson-iam).
126
+ * Use the API key to have the SDK manage the lifecycle of the access token. The SDK requests an access token, ensures that the access token is valid, and refreshes it if necessary.
127
+ * Use the access token if you want to manage the lifecycle yourself. For details, see [Authenticating with IAM tokens](https://cloud.ibm.com/docs/services/watson?topic=watson-iam).
128
128
 
129
129
  #### Supplying the IAM API key
130
130
 
@@ -138,13 +138,14 @@ discovery = IBMWatson::DiscoveryV1.new(
138
138
  version: "2017-10-16",
139
139
  authenticator: authenticator
140
140
  )
141
+ discover.service_url = "<service-url>" # setting service url
141
142
  ```
142
143
 
143
144
  #### Supplying the access token
144
145
 
145
146
  ```ruby
146
147
  authenticator = IBMCloudSdkCore::BearerTokenAuthenticator.new(
147
- bearer_token: "<iam_access_token>"
148
+ bearer_token: "<access_token>"
148
149
  )
149
150
  discovery = IBMWatson::DiscoveryV1.new(version: "2017-10-16", authenticator)
150
151
  ```
@@ -176,7 +177,7 @@ Requests can be sent asynchronously. There are two asynchronous methods availabl
176
177
  When `await` is used, the request is made synchronously.
177
178
 
178
179
  ```ruby
179
- authenticator = IBMCloudSdkCore::IamAuthenticator.new(
180
+ authenticator = IBMCloudSdkCore::BasicAuthenticator.new(
180
181
  username: "<username>",
181
182
  password: "<password>"
182
183
  )
@@ -195,7 +196,7 @@ output = future.value # The response is accessible at future.value
195
196
  When `async` is used, the request is made asynchronously
196
197
 
197
198
  ```ruby
198
- authenticator = IBMCloudSdkCore::IamAuthenticator.new(
199
+ authenticator = IBMCloudSdkCore::BasicAuthenticator.new(
199
200
  username: "<username>",
200
201
  password: "<password>"
201
202
  )
@@ -216,6 +217,7 @@ output = future.value
216
217
  ## Sending request headers
217
218
 
218
219
  Custom headers can be passed in any request in the form of a `Hash` as a parameter to the `headers` chainable method. For example, to send a header called `Custom-Header` to a call in Watson Assistant, pass the headers as a parameter to the `headers` chainable method:
220
+
219
221
  ```ruby
220
222
  require "ibm_watson"
221
223
  include IBMWatson
@@ -253,6 +255,7 @@ p "Result: #{response.result}"
253
255
  ```
254
256
 
255
257
  This would give an output of `DetailedResponse` having the structure:
258
+
256
259
  ```ruby
257
260
  Status: 200
258
261
  Headers: "<http response headers>"
@@ -260,6 +263,7 @@ Result: "<response returned by service>"
260
263
  ```
261
264
 
262
265
  ## Configuring the HTTP client
266
+
263
267
  To set client configs like timeout or proxy use the `configure_http_client` function and pass in the configurations.
264
268
 
265
269
  ```ruby
@@ -337,9 +341,10 @@ thr.join # Wait for the thread to finish before ending the program or running ot
337
341
  Note: `recognize_with_websocket` has been **deprecated** in favor of **`recognize_using_websocket`**
338
342
 
339
343
  ## IBM Cloud Pak for Data(CP4D)
344
+
340
345
  If your service instance is of ICP4D, below are two ways of initializing the assistant service.
341
346
 
342
- #### Supplying the `username`, `password`, and `url`
347
+ ### Supplying the `username`, `password`, and `url`
343
348
 
344
349
  The SDK will manage the token for the user
345
350
 
@@ -361,6 +366,7 @@ assistant.configure_http_client(disable_ssl_verification: true) # MAKE SURE SSL
361
366
  ## Ruby version
362
367
 
363
368
  Tested on:
369
+
364
370
  * MRI Ruby (RVM): 2.3.7, 2.4.4, 2.5.1
365
371
  * RubyInstaller (Windows x64): 2.3.3, 2.4.4, 2.5.1
366
372
 
@@ -45,50 +45,21 @@ module IBMWatson
45
45
  # Instead, specify a version date that is compatible with your
46
46
  # application, and don't change it until your application is
47
47
  # ready for a later version.
48
- # @option args url [String] The base url to use when contacting the service (e.g.
49
- # "https://gateway.watsonplatform.net/assistant/api").
50
- # The base url may differ between IBM Cloud regions.
51
- # @option args username [String] The username used to authenticate with the service.
52
- # Username and password credentials are only required to run your
53
- # application locally or outside of IBM Cloud. When running on
54
- # IBM Cloud, the credentials will be automatically loaded from the
55
- # `VCAP_SERVICES` environment variable.
56
- # @option args password [String] The password used to authenticate with the service.
57
- # Username and password credentials are only required to run your
58
- # application locally or outside of IBM Cloud. When running on
59
- # IBM Cloud, the credentials will be automatically loaded from the
60
- # `VCAP_SERVICES` environment variable.
61
- # @option args iam_apikey [String] An API key that can be used to request IAM tokens. If
62
- # this API key is provided, the SDK will manage the token and handle the
63
- # refreshing.
64
- # @option args iam_access_token [String] An IAM access token is fully managed by the application.
65
- # Responsibility falls on the application to refresh the token, either before
66
- # it expires or reactively upon receiving a 401 from the service as any requests
67
- # made with an expired token will fail.
68
- # @option args iam_url [String] An optional URL for the IAM service API. Defaults to
69
- # 'https://iam.cloud.ibm.com/identity/token'.
70
- # @option args iam_client_id [String] An optional client id for the IAM service API.
71
- # @option args iam_client_secret [String] An optional client secret for the IAM service API.
72
- # @option args icp4d_access_token [STRING] A ICP4D(IBM Cloud Pak for Data) access token is
73
- # fully managed by the application. Responsibility falls on the application to
74
- # refresh the token, either before it expires or reactively upon receiving a 401
75
- # from the service as any requests made with an expired token will fail.
76
- # @option args icp4d_url [STRING] In order to use an SDK-managed token with ICP4D authentication, this
77
- # URL must be passed in.
78
- # @option args authentication_type [STRING] Specifies the authentication pattern to use. Values that it
79
- # takes are basic, iam or icp4d.
48
+ # @option args service_url [String] The base service URL to use when contacting the service.
49
+ # The base service_url may differ between IBM Cloud regions.
50
+ # @option args authenticator [Object] The Authenticator instance to be configured for this service.
80
51
  def initialize(args = {})
81
52
  @__async_initialized__ = false
82
53
  defaults = {}
83
54
  defaults[:version] = nil
84
- defaults[:url] = "https://gateway.watsonplatform.net/assistant/api"
55
+ defaults[:service_url] = "https://gateway.watsonplatform.net/assistant/api"
85
56
  defaults[:authenticator] = nil
86
- defaults[:authentication_type] = nil
87
57
  args = defaults.merge(args)
88
58
  @version = args[:version]
89
59
  raise ArgumentError.new("version must be provided") if @version.nil?
90
60
 
91
- args[:display_name] = "Assistant"
61
+ args[:service_name] = "assistant"
62
+ args[:authenticator] = IBMCloudSdkCore::ConfigBasedAuthenticatorFactory.new.get_authenticator(service_name: args[:service_name]) if args[:authenticator].nil?
92
63
  super
93
64
  end
94
65
 
@@ -148,7 +119,6 @@ module IBMWatson
148
119
 
149
120
  method_url = "/v1/workspaces/%s/message" % [ERB::Util.url_encode(workspace_id)]
150
121
 
151
- headers = authenticator.authenticate(headers)
152
122
  response = request(
153
123
  method: "POST",
154
124
  url: method_url,
@@ -193,7 +163,6 @@ module IBMWatson
193
163
 
194
164
  method_url = "/v1/workspaces"
195
165
 
196
- headers = authenticator.authenticate(headers)
197
166
  response = request(
198
167
  method: "GET",
199
168
  url: method_url,
@@ -253,7 +222,6 @@ module IBMWatson
253
222
 
254
223
  method_url = "/v1/workspaces"
255
224
 
256
- headers = authenticator.authenticate(headers)
257
225
  response = request(
258
226
  method: "POST",
259
227
  url: method_url,
@@ -300,7 +268,6 @@ module IBMWatson
300
268
 
301
269
  method_url = "/v1/workspaces/%s" % [ERB::Util.url_encode(workspace_id)]
302
270
 
303
- headers = authenticator.authenticate(headers)
304
271
  response = request(
305
272
  method: "GET",
306
273
  url: method_url,
@@ -373,7 +340,6 @@ module IBMWatson
373
340
 
374
341
  method_url = "/v1/workspaces/%s" % [ERB::Util.url_encode(workspace_id)]
375
342
 
376
- headers = authenticator.authenticate(headers)
377
343
  response = request(
378
344
  method: "POST",
379
345
  url: method_url,
@@ -408,7 +374,6 @@ module IBMWatson
408
374
 
409
375
  method_url = "/v1/workspaces/%s" % [ERB::Util.url_encode(workspace_id)]
410
376
 
411
- headers = authenticator.authenticate(headers)
412
377
  request(
413
378
  method: "DELETE",
414
379
  url: method_url,
@@ -460,7 +425,6 @@ module IBMWatson
460
425
 
461
426
  method_url = "/v1/workspaces/%s/intents" % [ERB::Util.url_encode(workspace_id)]
462
427
 
463
- headers = authenticator.authenticate(headers)
464
428
  response = request(
465
429
  method: "GET",
466
430
  url: method_url,
@@ -512,7 +476,6 @@ module IBMWatson
512
476
 
513
477
  method_url = "/v1/workspaces/%s/intents" % [ERB::Util.url_encode(workspace_id)]
514
478
 
515
- headers = authenticator.authenticate(headers)
516
479
  response = request(
517
480
  method: "POST",
518
481
  url: method_url,
@@ -558,7 +521,6 @@ module IBMWatson
558
521
 
559
522
  method_url = "/v1/workspaces/%s/intents/%s" % [ERB::Util.url_encode(workspace_id), ERB::Util.url_encode(intent)]
560
523
 
561
- headers = authenticator.authenticate(headers)
562
524
  response = request(
563
525
  method: "GET",
564
526
  url: method_url,
@@ -612,7 +574,6 @@ module IBMWatson
612
574
 
613
575
  method_url = "/v1/workspaces/%s/intents/%s" % [ERB::Util.url_encode(workspace_id), ERB::Util.url_encode(intent)]
614
576
 
615
- headers = authenticator.authenticate(headers)
616
577
  response = request(
617
578
  method: "POST",
618
579
  url: method_url,
@@ -650,7 +611,6 @@ module IBMWatson
650
611
 
651
612
  method_url = "/v1/workspaces/%s/intents/%s" % [ERB::Util.url_encode(workspace_id), ERB::Util.url_encode(intent)]
652
613
 
653
- headers = authenticator.authenticate(headers)
654
614
  request(
655
615
  method: "DELETE",
656
616
  url: method_url,
@@ -701,7 +661,6 @@ module IBMWatson
701
661
 
702
662
  method_url = "/v1/workspaces/%s/intents/%s/examples" % [ERB::Util.url_encode(workspace_id), ERB::Util.url_encode(intent)]
703
663
 
704
- headers = authenticator.authenticate(headers)
705
664
  response = request(
706
665
  method: "GET",
707
666
  url: method_url,
@@ -753,7 +712,6 @@ module IBMWatson
753
712
 
754
713
  method_url = "/v1/workspaces/%s/intents/%s/examples" % [ERB::Util.url_encode(workspace_id), ERB::Util.url_encode(intent)]
755
714
 
756
- headers = authenticator.authenticate(headers)
757
715
  response = request(
758
716
  method: "POST",
759
717
  url: method_url,
@@ -797,7 +755,6 @@ module IBMWatson
797
755
 
798
756
  method_url = "/v1/workspaces/%s/intents/%s/examples/%s" % [ERB::Util.url_encode(workspace_id), ERB::Util.url_encode(intent), ERB::Util.url_encode(text)]
799
757
 
800
- headers = authenticator.authenticate(headers)
801
758
  response = request(
802
759
  method: "GET",
803
760
  url: method_url,
@@ -850,7 +807,6 @@ module IBMWatson
850
807
 
851
808
  method_url = "/v1/workspaces/%s/intents/%s/examples/%s" % [ERB::Util.url_encode(workspace_id), ERB::Util.url_encode(intent), ERB::Util.url_encode(text)]
852
809
 
853
- headers = authenticator.authenticate(headers)
854
810
  response = request(
855
811
  method: "POST",
856
812
  url: method_url,
@@ -891,7 +847,6 @@ module IBMWatson
891
847
 
892
848
  method_url = "/v1/workspaces/%s/intents/%s/examples/%s" % [ERB::Util.url_encode(workspace_id), ERB::Util.url_encode(intent), ERB::Util.url_encode(text)]
893
849
 
894
- headers = authenticator.authenticate(headers)
895
850
  request(
896
851
  method: "DELETE",
897
852
  url: method_url,
@@ -939,7 +894,6 @@ module IBMWatson
939
894
 
940
895
  method_url = "/v1/workspaces/%s/counterexamples" % [ERB::Util.url_encode(workspace_id)]
941
896
 
942
- headers = authenticator.authenticate(headers)
943
897
  response = request(
944
898
  method: "GET",
945
899
  url: method_url,
@@ -987,7 +941,6 @@ module IBMWatson
987
941
 
988
942
  method_url = "/v1/workspaces/%s/counterexamples" % [ERB::Util.url_encode(workspace_id)]
989
943
 
990
- headers = authenticator.authenticate(headers)
991
944
  response = request(
992
945
  method: "POST",
993
946
  url: method_url,
@@ -1029,7 +982,6 @@ module IBMWatson
1029
982
 
1030
983
  method_url = "/v1/workspaces/%s/counterexamples/%s" % [ERB::Util.url_encode(workspace_id), ERB::Util.url_encode(text)]
1031
984
 
1032
- headers = authenticator.authenticate(headers)
1033
985
  response = request(
1034
986
  method: "GET",
1035
987
  url: method_url,
@@ -1078,7 +1030,6 @@ module IBMWatson
1078
1030
 
1079
1031
  method_url = "/v1/workspaces/%s/counterexamples/%s" % [ERB::Util.url_encode(workspace_id), ERB::Util.url_encode(text)]
1080
1032
 
1081
- headers = authenticator.authenticate(headers)
1082
1033
  response = request(
1083
1034
  method: "POST",
1084
1035
  url: method_url,
@@ -1117,7 +1068,6 @@ module IBMWatson
1117
1068
 
1118
1069
  method_url = "/v1/workspaces/%s/counterexamples/%s" % [ERB::Util.url_encode(workspace_id), ERB::Util.url_encode(text)]
1119
1070
 
1120
- headers = authenticator.authenticate(headers)
1121
1071
  request(
1122
1072
  method: "DELETE",
1123
1073
  url: method_url,
@@ -1169,7 +1119,6 @@ module IBMWatson
1169
1119
 
1170
1120
  method_url = "/v1/workspaces/%s/entities" % [ERB::Util.url_encode(workspace_id)]
1171
1121
 
1172
- headers = authenticator.authenticate(headers)
1173
1122
  response = request(
1174
1123
  method: "GET",
1175
1124
  url: method_url,
@@ -1226,7 +1175,6 @@ module IBMWatson
1226
1175
 
1227
1176
  method_url = "/v1/workspaces/%s/entities" % [ERB::Util.url_encode(workspace_id)]
1228
1177
 
1229
- headers = authenticator.authenticate(headers)
1230
1178
  response = request(
1231
1179
  method: "POST",
1232
1180
  url: method_url,
@@ -1272,7 +1220,6 @@ module IBMWatson
1272
1220
 
1273
1221
  method_url = "/v1/workspaces/%s/entities/%s" % [ERB::Util.url_encode(workspace_id), ERB::Util.url_encode(entity)]
1274
1222
 
1275
- headers = authenticator.authenticate(headers)
1276
1223
  response = request(
1277
1224
  method: "GET",
1278
1225
  url: method_url,
@@ -1329,7 +1276,6 @@ module IBMWatson
1329
1276
 
1330
1277
  method_url = "/v1/workspaces/%s/entities/%s" % [ERB::Util.url_encode(workspace_id), ERB::Util.url_encode(entity)]
1331
1278
 
1332
- headers = authenticator.authenticate(headers)
1333
1279
  response = request(
1334
1280
  method: "POST",
1335
1281
  url: method_url,
@@ -1367,7 +1313,6 @@ module IBMWatson
1367
1313
 
1368
1314
  method_url = "/v1/workspaces/%s/entities/%s" % [ERB::Util.url_encode(workspace_id), ERB::Util.url_encode(entity)]
1369
1315
 
1370
- headers = authenticator.authenticate(headers)
1371
1316
  request(
1372
1317
  method: "DELETE",
1373
1318
  url: method_url,
@@ -1415,7 +1360,6 @@ module IBMWatson
1415
1360
 
1416
1361
  method_url = "/v1/workspaces/%s/entities/%s/mentions" % [ERB::Util.url_encode(workspace_id), ERB::Util.url_encode(entity)]
1417
1362
 
1418
- headers = authenticator.authenticate(headers)
1419
1363
  response = request(
1420
1364
  method: "GET",
1421
1365
  url: method_url,
@@ -1469,7 +1413,6 @@ module IBMWatson
1469
1413
 
1470
1414
  method_url = "/v1/workspaces/%s/entities/%s/values" % [ERB::Util.url_encode(workspace_id), ERB::Util.url_encode(entity)]
1471
1415
 
1472
- headers = authenticator.authenticate(headers)
1473
1416
  response = request(
1474
1417
  method: "GET",
1475
1418
  url: method_url,
@@ -1534,7 +1477,6 @@ module IBMWatson
1534
1477
 
1535
1478
  method_url = "/v1/workspaces/%s/entities/%s/values" % [ERB::Util.url_encode(workspace_id), ERB::Util.url_encode(entity)]
1536
1479
 
1537
- headers = authenticator.authenticate(headers)
1538
1480
  response = request(
1539
1481
  method: "POST",
1540
1482
  url: method_url,
@@ -1582,7 +1524,6 @@ module IBMWatson
1582
1524
 
1583
1525
  method_url = "/v1/workspaces/%s/entities/%s/values/%s" % [ERB::Util.url_encode(workspace_id), ERB::Util.url_encode(entity), ERB::Util.url_encode(value)]
1584
1526
 
1585
- headers = authenticator.authenticate(headers)
1586
1527
  response = request(
1587
1528
  method: "GET",
1588
1529
  url: method_url,
@@ -1649,7 +1590,6 @@ module IBMWatson
1649
1590
 
1650
1591
  method_url = "/v1/workspaces/%s/entities/%s/values/%s" % [ERB::Util.url_encode(workspace_id), ERB::Util.url_encode(entity), ERB::Util.url_encode(value)]
1651
1592
 
1652
- headers = authenticator.authenticate(headers)
1653
1593
  response = request(
1654
1594
  method: "POST",
1655
1595
  url: method_url,
@@ -1690,7 +1630,6 @@ module IBMWatson
1690
1630
 
1691
1631
  method_url = "/v1/workspaces/%s/entities/%s/values/%s" % [ERB::Util.url_encode(workspace_id), ERB::Util.url_encode(entity), ERB::Util.url_encode(value)]
1692
1632
 
1693
- headers = authenticator.authenticate(headers)
1694
1633
  request(
1695
1634
  method: "DELETE",
1696
1635
  url: method_url,
@@ -1743,7 +1682,6 @@ module IBMWatson
1743
1682
 
1744
1683
  method_url = "/v1/workspaces/%s/entities/%s/values/%s/synonyms" % [ERB::Util.url_encode(workspace_id), ERB::Util.url_encode(entity), ERB::Util.url_encode(value)]
1745
1684
 
1746
- headers = authenticator.authenticate(headers)
1747
1685
  response = request(
1748
1686
  method: "GET",
1749
1687
  url: method_url,
@@ -1796,7 +1734,6 @@ module IBMWatson
1796
1734
 
1797
1735
  method_url = "/v1/workspaces/%s/entities/%s/values/%s/synonyms" % [ERB::Util.url_encode(workspace_id), ERB::Util.url_encode(entity), ERB::Util.url_encode(value)]
1798
1736
 
1799
- headers = authenticator.authenticate(headers)
1800
1737
  response = request(
1801
1738
  method: "POST",
1802
1739
  url: method_url,
@@ -1843,7 +1780,6 @@ module IBMWatson
1843
1780
 
1844
1781
  method_url = "/v1/workspaces/%s/entities/%s/values/%s/synonyms/%s" % [ERB::Util.url_encode(workspace_id), ERB::Util.url_encode(entity), ERB::Util.url_encode(value), ERB::Util.url_encode(synonym)]
1845
1782
 
1846
- headers = authenticator.authenticate(headers)
1847
1783
  response = request(
1848
1784
  method: "GET",
1849
1785
  url: method_url,
@@ -1897,7 +1833,6 @@ module IBMWatson
1897
1833
 
1898
1834
  method_url = "/v1/workspaces/%s/entities/%s/values/%s/synonyms/%s" % [ERB::Util.url_encode(workspace_id), ERB::Util.url_encode(entity), ERB::Util.url_encode(value), ERB::Util.url_encode(synonym)]
1899
1835
 
1900
- headers = authenticator.authenticate(headers)
1901
1836
  response = request(
1902
1837
  method: "POST",
1903
1838
  url: method_url,
@@ -1941,7 +1876,6 @@ module IBMWatson
1941
1876
 
1942
1877
  method_url = "/v1/workspaces/%s/entities/%s/values/%s/synonyms/%s" % [ERB::Util.url_encode(workspace_id), ERB::Util.url_encode(entity), ERB::Util.url_encode(value), ERB::Util.url_encode(synonym)]
1943
1878
 
1944
- headers = authenticator.authenticate(headers)
1945
1879
  request(
1946
1880
  method: "DELETE",
1947
1881
  url: method_url,
@@ -1988,7 +1922,6 @@ module IBMWatson
1988
1922
 
1989
1923
  method_url = "/v1/workspaces/%s/dialog_nodes" % [ERB::Util.url_encode(workspace_id)]
1990
1924
 
1991
- headers = authenticator.authenticate(headers)
1992
1925
  response = request(
1993
1926
  method: "GET",
1994
1927
  url: method_url,
@@ -2078,7 +2011,6 @@ module IBMWatson
2078
2011
 
2079
2012
  method_url = "/v1/workspaces/%s/dialog_nodes" % [ERB::Util.url_encode(workspace_id)]
2080
2013
 
2081
- headers = authenticator.authenticate(headers)
2082
2014
  response = request(
2083
2015
  method: "POST",
2084
2016
  url: method_url,
@@ -2119,7 +2051,6 @@ module IBMWatson
2119
2051
 
2120
2052
  method_url = "/v1/workspaces/%s/dialog_nodes/%s" % [ERB::Util.url_encode(workspace_id), ERB::Util.url_encode(dialog_node)]
2121
2053
 
2122
- headers = authenticator.authenticate(headers)
2123
2054
  response = request(
2124
2055
  method: "GET",
2125
2056
  url: method_url,
@@ -2210,7 +2141,6 @@ module IBMWatson
2210
2141
 
2211
2142
  method_url = "/v1/workspaces/%s/dialog_nodes/%s" % [ERB::Util.url_encode(workspace_id), ERB::Util.url_encode(dialog_node)]
2212
2143
 
2213
- headers = authenticator.authenticate(headers)
2214
2144
  response = request(
2215
2145
  method: "POST",
2216
2146
  url: method_url,
@@ -2248,7 +2178,6 @@ module IBMWatson
2248
2178
 
2249
2179
  method_url = "/v1/workspaces/%s/dialog_nodes/%s" % [ERB::Util.url_encode(workspace_id), ERB::Util.url_encode(dialog_node)]
2250
2180
 
2251
- headers = authenticator.authenticate(headers)
2252
2181
  request(
2253
2182
  method: "DELETE",
2254
2183
  url: method_url,
@@ -2297,7 +2226,6 @@ module IBMWatson
2297
2226
 
2298
2227
  method_url = "/v1/workspaces/%s/logs" % [ERB::Util.url_encode(workspace_id)]
2299
2228
 
2300
- headers = authenticator.authenticate(headers)
2301
2229
  response = request(
2302
2230
  method: "GET",
2303
2231
  url: method_url,
@@ -2344,7 +2272,6 @@ module IBMWatson
2344
2272
 
2345
2273
  method_url = "/v1/logs"
2346
2274
 
2347
- headers = authenticator.authenticate(headers)
2348
2275
  response = request(
2349
2276
  method: "GET",
2350
2277
  url: method_url,
@@ -2385,7 +2312,6 @@ module IBMWatson
2385
2312
 
2386
2313
  method_url = "/v1/user_data"
2387
2314
 
2388
- headers = authenticator.authenticate(headers)
2389
2315
  request(
2390
2316
  method: "DELETE",
2391
2317
  url: method_url,
@@ -45,50 +45,21 @@ module IBMWatson
45
45
  # Instead, specify a version date that is compatible with your
46
46
  # application, and don't change it until your application is
47
47
  # ready for a later version.
48
- # @option args url [String] The base url to use when contacting the service (e.g.
49
- # "https://gateway.watsonplatform.net/assistant/api").
50
- # The base url may differ between IBM Cloud regions.
51
- # @option args username [String] The username used to authenticate with the service.
52
- # Username and password credentials are only required to run your
53
- # application locally or outside of IBM Cloud. When running on
54
- # IBM Cloud, the credentials will be automatically loaded from the
55
- # `VCAP_SERVICES` environment variable.
56
- # @option args password [String] The password used to authenticate with the service.
57
- # Username and password credentials are only required to run your
58
- # application locally or outside of IBM Cloud. When running on
59
- # IBM Cloud, the credentials will be automatically loaded from the
60
- # `VCAP_SERVICES` environment variable.
61
- # @option args iam_apikey [String] An API key that can be used to request IAM tokens. If
62
- # this API key is provided, the SDK will manage the token and handle the
63
- # refreshing.
64
- # @option args iam_access_token [String] An IAM access token is fully managed by the application.
65
- # Responsibility falls on the application to refresh the token, either before
66
- # it expires or reactively upon receiving a 401 from the service as any requests
67
- # made with an expired token will fail.
68
- # @option args iam_url [String] An optional URL for the IAM service API. Defaults to
69
- # 'https://iam.cloud.ibm.com/identity/token'.
70
- # @option args iam_client_id [String] An optional client id for the IAM service API.
71
- # @option args iam_client_secret [String] An optional client secret for the IAM service API.
72
- # @option args icp4d_access_token [STRING] A ICP4D(IBM Cloud Pak for Data) access token is
73
- # fully managed by the application. Responsibility falls on the application to
74
- # refresh the token, either before it expires or reactively upon receiving a 401
75
- # from the service as any requests made with an expired token will fail.
76
- # @option args icp4d_url [STRING] In order to use an SDK-managed token with ICP4D authentication, this
77
- # URL must be passed in.
78
- # @option args authentication_type [STRING] Specifies the authentication pattern to use. Values that it
79
- # takes are basic, iam or icp4d.
48
+ # @option args service_url [String] The base service URL to use when contacting the service.
49
+ # The base service_url may differ between IBM Cloud regions.
50
+ # @option args authenticator [Object] The Authenticator instance to be configured for this service.
80
51
  def initialize(args = {})
81
52
  @__async_initialized__ = false
82
53
  defaults = {}
83
54
  defaults[:version] = nil
84
- defaults[:url] = "https://gateway.watsonplatform.net/assistant/api"
55
+ defaults[:service_url] = "https://gateway.watsonplatform.net/assistant/api"
85
56
  defaults[:authenticator] = nil
86
- defaults[:authentication_type] = nil
87
57
  args = defaults.merge(args)
88
58
  @version = args[:version]
89
59
  raise ArgumentError.new("version must be provided") if @version.nil?
90
60
 
91
- args[:display_name] = "Assistant"
61
+ args[:service_name] = "assistant"
62
+ args[:authenticator] = IBMCloudSdkCore::ConfigBasedAuthenticatorFactory.new.get_authenticator(service_name: args[:service_name]) if args[:authenticator].nil?
92
63
  super
93
64
  end
94
65
 
@@ -122,7 +93,6 @@ module IBMWatson
122
93
 
123
94
  method_url = "/v2/assistants/%s/sessions" % [ERB::Util.url_encode(assistant_id)]
124
95
 
125
- headers = authenticator.authenticate(headers)
126
96
  response = request(
127
97
  method: "POST",
128
98
  url: method_url,
@@ -161,7 +131,6 @@ module IBMWatson
161
131
 
162
132
  method_url = "/v2/assistants/%s/sessions/%s" % [ERB::Util.url_encode(assistant_id), ERB::Util.url_encode(session_id)]
163
133
 
164
- headers = authenticator.authenticate(headers)
165
134
  request(
166
135
  method: "DELETE",
167
136
  url: method_url,
@@ -214,7 +183,6 @@ module IBMWatson
214
183
 
215
184
  method_url = "/v2/assistants/%s/sessions/%s/message" % [ERB::Util.url_encode(assistant_id), ERB::Util.url_encode(session_id)]
216
185
 
217
- headers = authenticator.authenticate(headers)
218
186
  response = request(
219
187
  method: "POST",
220
188
  url: method_url,