Skip to content

Commit 733f13a

Browse files
authored
Merge pull request #77 from watson-developer-cloud/release-candidate-1.0.0.rc1
Release candidate 1.0.0.rc1
2 parents c3d8c94 + 0c55858 commit 733f13a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+1534
-950
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: 46 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -130,49 +130,40 @@ 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+
url: "<iam_url>" # optional - the default value is https://iam.cloud.ibm.com/identity/token
136+
)
133137
discovery = IBMWatson::DiscoveryV1.new(
134138
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
139+
authenticator: authenticator
137140
)
138141
```
139142

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-
146143
#### Supplying the access token
147144

148145
```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>"
146+
authenticator = IBMCloudSdkCore::BearerTokenAuthenticator.new(
147+
bearer_token: "<iam_access_token>"
153148
)
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>")
149+
discovery = IBMWatson::DiscoveryV1.new(version: "2017-10-16", authenticator)
160150
```
161151

162152
### Username and password
163153

164154
```ruby
165155
require "ibm_watson"
156+
require "ibm_cloud_sdk_core"
166157
include IBMWatson
167158
# 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>"
159+
authenticator = IBMCloudSdkCore::BasicAuthenticator.new(
160+
username: "<username>",
161+
password: "<password>"
162+
)
163+
discovery = DiscoveryV1.new(
164+
version: "2017-10-16",
165+
authenticator: authenticator
166+
)
176167
```
177168

178169
## Sending requests asynchronously
@@ -185,9 +176,13 @@ Requests can be sent asynchronously. There are two asynchronous methods availabl
185176
When `await` is used, the request is made synchronously.
186177

187178
```ruby
179+
authenticator = IBMCloudSdkCore::IamAuthenticator.new(
180+
username: "<username>",
181+
password: "<password>"
182+
)
183+
188184
speech_to_text = IBMWatson::SpeechToTextV1.new(
189-
username: "username",
190-
password: "password"
185+
authenticator: authenticator
191186
)
192187
audio_file = File.open(Dir.getwd + "/resources/speech.wav")
193188
future = speech_to_text.await.recognize(
@@ -200,9 +195,13 @@ output = future.value # The response is accessible at future.value
200195
When `async` is used, the request is made asynchronously
201196

202197
```ruby
198+
authenticator = IBMCloudSdkCore::IamAuthenticator.new(
199+
username: "<username>",
200+
password: "<password>"
201+
)
202+
203203
speech_to_text = IBMWatson::SpeechToTextV1.new(
204-
username: "username",
205-
password: "password"
204+
authenticator: authenticator
206205
)
207206
audio_file = File.open(Dir.getwd + "/resources/speech.wav")
208207
future = speech_to_text.async.recognize(
@@ -222,8 +221,7 @@ require "ibm_watson"
222221
include IBMWatson
223222

224223
assistant = AssistantV1.new(
225-
username: "xxx",
226-
password: "yyy",
224+
authenticator: "<authenticator>"
227225
version: "2017-04-21"
228226
)
229227

@@ -241,8 +239,7 @@ require "ibm_watson"
241239
include IBMWatson
242240

243241
assistant = AssistantV1.new(
244-
username: "xxx",
245-
password: "yyy",
242+
authenticator: "<authenticator>"
246243
version: "2017-04-21"
247244
)
248245

@@ -270,8 +267,7 @@ require "ibm_watson/assistant_v1"
270267
include IBMWatson
271268

272269
assistant = AssistantV1.new(
273-
username: "{username}",
274-
password: "{password}",
270+
authenticator: "<authenticator>"
275271
version: "2018-07-10"
276272
)
277273

@@ -307,8 +303,7 @@ include IBMWatson
307303

308304
service = AssistantV1.new(
309305
version: "<version>",
310-
username: "<username>",
311-
password: "<password>",
306+
authenticator: "<authenticator>"
312307
)
313308

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

342337
Note: `recognize_with_websocket` has been **deprecated** in favor of **`recognize_using_websocket`**
343338

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

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

349344
The SDK will manage the token for the user
350345

351346
```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
364347

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
348+
authenticator = IBMCloudSdkCore::CLoudPakForDataAuthenticator.new(
349+
username: "<username>",
350+
password: "<password>",
351+
url: "<authentication url>",
352+
disable_ssl: true
353+
)
354+
assistant = IBMWatson::AssistantV1.new(
355+
version: "<version>",
356+
authenticator: authenticator
357+
)
358+
assistant.configure_http_client(disable_ssl_verification: true) # MAKE SURE SSL VERIFICATION IS DISABLED
373359
```
374360

375361
## 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.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66
module IBMWatson
77
ApiException = IBMCloudSdkCore::ApiException
88
DetailedResponse = IBMCloudSdkCore::DetailedResponse
9-
IAMTokenManager = IBMCloudSdkCore::IAMTokenManager
10-
ICP4DTokenManager = IBMCloudSdkCore::ICP4DTokenManager
119

1210
require_relative("./ibm_watson/personality_insights_v3.rb")
1311
require_relative("./ibm_watson/tone_analyzer_v3.rb")

0 commit comments

Comments
 (0)