Skip to content

Commit e550cf5

Browse files
committed
docs: update readme, rubocop and gemspec for new auth changes
1 parent 1cef126 commit e550cf5

File tree

5 files changed

+53
-63
lines changed

5 files changed

+53
-63
lines changed

.bumpversion.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[bumpversion]
2-
current_version = 0.20.1
2+
current_version = 1.0.0.rc1
33
commit = True
44
message = [skip ci] Bump version: {current_version} -> {new_version}
55

.rubocop.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,9 @@ Layout/EmptyLinesAroundModuleBody:
274274
- empty_lines_special
275275
- no_empty_lines
276276

277+
Lint/UnderscorePrefixedVariableName:
278+
Enabled: false
279+
277280
# Align ends correctly.
278281
Layout/EndAlignment:
279282
# The value `keyword` means that `end` should be aligned with the matching

README.md

Lines changed: 47 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -130,49 +130,41 @@ You supply either an IAM service **API key** or an **access token**:
130130

131131
```ruby
132132
# In the constructor, letting the SDK manage the IAM token
133+
authenticator = IBMCloudSdkCore::IamAuthenticator.new(
134+
apikey: "<iam_apikey>",
135+
version: "2018-02-16",
136+
url: "<iam_url>" # optional - the default value is https://iam.cloud.ibm.com/identity/token
137+
)
133138
discovery = IBMWatson::DiscoveryV1.new(
134139
version: "2017-10-16",
135-
iam_apikey: "<iam_apikey>",
136-
iam_url: "<iam_url>" # optional - the default value is https://iam.cloud.ibm.com/identity/token
140+
authenticator: authenticator
137141
)
138142
```
139143

140-
```ruby
141-
# after instantiation, letting the SDK manage the IAM token
142-
discovery = IBMWatson::DiscoveryV1.new(version: "2017-10-16")
143-
discovery.iam_apikey(iam_apikey: "<iam_apikey>")
144-
```
145-
146144
#### Supplying the access token
147145

148146
```ruby
149-
# in the constructor, assuming control of managing IAM token
150-
discovery = IBMWatson::DiscoveryV1.new(
151-
version: "2017-10-16",
152-
iam_access_token: "<iam_access_token>"
147+
authenticator = IBMCloudSdkCore::BearerTokenAuthenticator.new(
148+
bearer_token: "<iam_access_token>"
153149
)
154-
```
155-
156-
```ruby
157-
# after instantiation, assuming control of managing IAM token
158-
discovery = IBMWatson::DiscoveryV1.new(version: "2017-10-16")
159-
discovery.iam_access_token(iam_access_token: "<access_token>")
150+
discovery = IBMWatson::DiscoveryV1.new(version: "2017-10-16", authenticator)
160151
```
161152

162153
### Username and password
163154

164155
```ruby
165156
require "ibm_watson"
157+
require "ibm_cloud_sdk_core"
166158
include IBMWatson
167159
# In the constructor
168-
discovery = DiscoveryV1.new(version: "2017-10-16", username: "<username>", password: "<password>")
169-
```
170-
171-
```ruby
172-
# After instantiation
173-
discovery = DiscoveryV1.new(version: "2017-10-16")
174-
discovery.username = "<username>"
175-
discovery.password = "<password>"
160+
authenticator = IBMCloudSdkCore::BasicAuthenticator.new(
161+
username: "<username>",
162+
password: "<password>"
163+
)
164+
discovery = DiscoveryV1.new(
165+
version: "2017-10-16",
166+
authenticator: authenticator
167+
)
176168
```
177169

178170
## Sending requests asynchronously
@@ -185,9 +177,13 @@ Requests can be sent asynchronously. There are two asynchronous methods availabl
185177
When `await` is used, the request is made synchronously.
186178

187179
```ruby
180+
authenticator = IBMCloudSdkCore::IamAuthenticator.new(
181+
username: "<username>",
182+
password: "<password>"
183+
)
184+
188185
speech_to_text = IBMWatson::SpeechToTextV1.new(
189-
username: "username",
190-
password: "password"
186+
authenticator: authenticator
191187
)
192188
audio_file = File.open(Dir.getwd + "/resources/speech.wav")
193189
future = speech_to_text.await.recognize(
@@ -200,9 +196,13 @@ output = future.value # The response is accessible at future.value
200196
When `async` is used, the request is made asynchronously
201197

202198
```ruby
199+
authenticator = IBMCloudSdkCore::IamAuthenticator.new(
200+
username: "<username>",
201+
password: "<password>"
202+
)
203+
203204
speech_to_text = IBMWatson::SpeechToTextV1.new(
204-
username: "username",
205-
password: "password"
205+
authenticator: authenticator
206206
)
207207
audio_file = File.open(Dir.getwd + "/resources/speech.wav")
208208
future = speech_to_text.async.recognize(
@@ -222,8 +222,7 @@ require "ibm_watson"
222222
include IBMWatson
223223

224224
assistant = AssistantV1.new(
225-
username: "xxx",
226-
password: "yyy",
225+
authenticator: "<authenticator>"
227226
version: "2017-04-21"
228227
)
229228

@@ -241,8 +240,7 @@ require "ibm_watson"
241240
include IBMWatson
242241

243242
assistant = AssistantV1.new(
244-
username: "xxx",
245-
password: "yyy",
243+
authenticator: "<authenticator>"
246244
version: "2017-04-21"
247245
)
248246

@@ -270,8 +268,7 @@ require "ibm_watson/assistant_v1"
270268
include IBMWatson
271269

272270
assistant = AssistantV1.new(
273-
username: "{username}",
274-
password: "{password}",
271+
authenticator: "<authenticator>"
275272
version: "2018-07-10"
276273
)
277274

@@ -307,8 +304,7 @@ include IBMWatson
307304

308305
service = AssistantV1.new(
309306
version: "<version>",
310-
username: "<username>",
311-
password: "<password>",
307+
authenticator: "<authenticator>"
312308
)
313309

314310
service.configure_http_client(disable_ssl_verification: true)
@@ -341,35 +337,26 @@ thr.join # Wait for the thread to finish before ending the program or running ot
341337

342338
Note: `recognize_with_websocket` has been **deprecated** in favor of **`recognize_using_websocket`**
343339

344-
## IBM Cloud Pak for Data(ICP4D)
340+
## IBM Cloud Pak for Data(CP4D)
345341
If your service instance is of ICP4D, below are two ways of initializing the assistant service.
346342

347-
#### 1) Supplying the `username`, `password`, `icp4d_url` and `authentication_type`
343+
#### Supplying the `username`, `password`, and `url`
348344

349345
The SDK will manage the token for the user
350346

351347
```ruby
352-
assistant = IBMWatson::AssistantV1.new(
353-
version: "<version>",
354-
username: "<username>",
355-
password: "<password>",
356-
url: "<service url>",
357-
icp4d_url: "<authentication url>",
358-
authentication_type: "icp4d"
359-
)
360-
assistant.configure_http_client(disable_ssl_verification: true) # MAKE SURE SSL VERIFICATION IS DISABLED
361-
```
362-
363-
#### 2) Supplying the access token
364348

365-
```ruby
366-
assistant = IBMWatson::AssistantV1.new(
367-
version: "<version>",
368-
url: "<service url>",
369-
icp4d_token: "<your managed access token>",
370-
authentication_type: "icp4d"
371-
)
372-
assistant.configure_http_client(disable_ssl_verification: true) # MAKE SURE SSL VERIFICATION IS DISABLED
349+
authenticator = IBMCloudSdkCore::CLoudPakForDataAuthenticator.new(
350+
username: "<username>",
351+
password: "<password>",
352+
url: "<authentication url>",
353+
disable_ssl: true
354+
)
355+
assistant = IBMWatson::AssistantV1.new(
356+
version: "<version>",
357+
authenticator: authenticator
358+
)
359+
assistant.configure_http_client(disable_ssl_verification: true) # MAKE SURE SSL VERIFICATION IS DISABLED
373360
```
374361

375362
## Ruby version

ibm_watson.gemspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ Gem::Specification.new do |spec|
3636
spec.add_runtime_dependency "eventmachine", "~> 1.2"
3737
spec.add_runtime_dependency "faye-websocket", "~> 0.10"
3838
spec.add_runtime_dependency "http", "~> 4.1.0"
39-
spec.add_runtime_dependency "ibm_cloud_sdk_core", "~> 0.3.3"
39+
spec.add_runtime_dependency "ibm_cloud_sdk_core", "~> 1.0.0.rc2"
4040
spec.add_runtime_dependency "jwt", "~> 2.2.1"
4141

4242
spec.add_development_dependency "bundler", "~> 1.16"

lib/ibm_watson/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# frozen_string_literal: true
22

33
module IBMWatson
4-
VERSION = "0.20.1"
4+
VERSION = "1.0.0.rc1"
55
end

0 commit comments

Comments
 (0)