ibm_watson 0.16.1 → 0.17.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9d2c9980960aa7f5e93261dfd84391198197f4191ee2864507e184ee834a0b88
4
- data.tar.gz: 987566c62ec16426e87ed44bd7b72bc30950b9ff4118b93c855822ced185f188
3
+ metadata.gz: 39527e09ad94eb91baf66ef1539c84bb1189e3f716fe9a331d87b8d3718be34d
4
+ data.tar.gz: dc8dea01d68683c4b4274b42c7d87e79818423ba9b6cfd643e4734de22136e61
5
5
  SHA512:
6
- metadata.gz: aef365e17e9e0eded4dc83e61284921de703d958f7ecc4748765804b160a1ef1980bbb45cf01bb008649cc05bf4b96269cfa0de4d8da3e5259dc064d90312704
7
- data.tar.gz: c2ab26dfd878aeea7873a44d7dab5e0827b89af49f58a060b03e939303d39d3dfe63007278b0f40b9bb379551c75f689bfcfbbaf71553672c9b160792137a678
6
+ metadata.gz: cff3d3cc8cc96b4be31731ccd030d36f2e4ca519a4952ae53d9f4195a78982e262c443d190fabbca5c515bf4cd2bf225ce4f77c7459fae923e021ddb3aaa1a5f
7
+ data.tar.gz: e2ca88a6ec674b1b853146cbb01521a61bad2cde784db37172387413ba0722e30df0e3b6690839e06351feba9d14cb4c19ee7b257fbea7ff5b6609c8aea0af6b
data/README.md CHANGED
@@ -29,10 +29,12 @@ Ruby gem to quickly get started with the various [IBM Watson][wdc] services.
29
29
  * [Ruby version](#ruby-version)
30
30
  * [Contributing](#contributing)
31
31
  * [License](#license)
32
+ * [Featured Projects](#featured-projects)
32
33
 
33
34
  </details>
34
35
 
35
36
  ## Before you begin
37
+
36
38
  * You need an [IBM Cloud][ibm-cloud-onboarding] account.
37
39
 
38
40
  ## Installation
@@ -71,6 +73,7 @@ Watson services are migrating to token-based Identity and Access Management (IAM
71
73
  - In other instances, you authenticate by providing the **[username and password](#username-and-password)** for the service instance.
72
74
 
73
75
  ### Getting credentials
76
+
74
77
  To find out which authentication to use, view the service credentials. You find the service credentials for authentication the same way for all Watson services:
75
78
 
76
79
  1. Go to the IBM Cloud [Dashboard](https://cloud.ibm.com/) page.
@@ -79,17 +82,17 @@ To find out which authentication to use, view the service credentials. You find
79
82
 
80
83
  On this page, you should be able to see your credentials for accessing your service instance.
81
84
 
82
- ### Supplying credentials
85
+ ### Supplying credentials
83
86
 
84
87
  There are two ways to supply the credentials you found above to the SDK for authentication.
85
88
 
86
- #### Credential file (easier!)
89
+ #### Credential file (easier!)
87
90
 
88
- With a credential file, you just need to put the file in the right place and the SDK will do the work of parsing and authenticating. You can get this file by clicking the **Download** button for the credentials in the **Manage** tab of your service instance.
91
+ With a credential file, you just need to put the file in the right place and the SDK will do the work of parsing and authenticating. You can get this file by clicking the **Download** button for the credentials in the **Manage** tab of your service instance.
89
92
 
90
- 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):
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):
91
94
 
92
- - Your system's home directory
95
+ - Your system's home directory
93
96
  - The top-level directory of the project you're using the SDK in
94
97
 
95
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:
@@ -110,7 +113,8 @@ export IBM_CREDENTIALS_FILE="<path>"
110
113
 
111
114
  where `<path>` is something like `/home/user/Downloads/<file_name>.env`.
112
115
 
113
- #### Manually
116
+ #### Manually
117
+
114
118
  If you'd prefer to set authentication values manually in your code, the SDK supports that as well. The way you'll do this depends on what type of credentials your service instance gives you.
115
119
 
116
120
  ### IAM
@@ -120,7 +124,7 @@ IBM Cloud is migrating to token-based Identity and Access Management (IAM) authe
120
124
  You supply either an IAM service **API key** or an **access token**:
121
125
 
122
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.
123
- - Use the access token if you want to manage the lifecycle yourself. For details, see [Authenticating with IAM tokens](https://console.bluemix.net/docs/services/watson/getting-started-iam.html).
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).
124
128
 
125
129
  #### Supplying the IAM API key
126
130
 
@@ -129,7 +133,7 @@ You supply either an IAM service **API key** or an **access token**:
129
133
  discovery = IBMWatson::DiscoveryV1.new(
130
134
  version: "2017-10-16",
131
135
  iam_apikey: "<iam_apikey>",
132
- iam_url: "<iam_url>" # optional - the default value is https://iam.ng.bluemix.net/identity/token
136
+ iam_url: "<iam_url>" # optional - the default value is https://iam.cloud.ibm.com/identity/token
133
137
  )
134
138
  ```
135
139
 
@@ -140,6 +144,7 @@ discovery.iam_apikey(iam_apikey: "<iam_apikey>")
140
144
  ```
141
145
 
142
146
  #### Supplying the access token
147
+
143
148
  ```ruby
144
149
  # in the constructor, assuming control of managing IAM token
145
150
  discovery = IBMWatson::DiscoveryV1.new(
@@ -155,6 +160,7 @@ discovery.iam_access_token(iam_access_token: "<access_token>")
155
160
  ```
156
161
 
157
162
  ### Username and password
163
+
158
164
  ```ruby
159
165
  require "ibm_watson"
160
166
  include IBMWatson
@@ -170,11 +176,14 @@ discovery.password = "<password>"
170
176
  ```
171
177
 
172
178
  ## Sending requests asynchronously
179
+
173
180
  Requests can be sent asynchronously. There are two asynchronous methods available for the user, `async` & `await`. When used, these methods return an [Ivar][ivar] object.
181
+
174
182
  * To call a method asynchronously, simply insert `.await` or `.async` into the call: `service.translate` would be `service.async.translate`
175
183
  * To access the response from an [Ivar][ivar] object called `future`, simply call `future.value`
176
184
 
177
185
  When `await` is used, the request is made synchronously.
186
+
178
187
  ```ruby
179
188
  speech_to_text = IBMWatson::SpeechToTextV1.new(
180
189
  username: "username",
@@ -189,6 +198,7 @@ output = future.value # The response is accessible at future.value
189
198
  ```
190
199
 
191
200
  When `async` is used, the request is made asynchronously
201
+
192
202
  ```ruby
193
203
  speech_to_text = IBMWatson::SpeechToTextV1.new(
194
204
  username: "username",
@@ -205,6 +215,7 @@ output = future.value
205
215
  ```
206
216
 
207
217
  ## Sending request headers
218
+
208
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:
209
220
  ```ruby
210
221
  require "ibm_watson"
@@ -222,7 +233,9 @@ response = assistant.headers(
222
233
  ```
223
234
 
224
235
  ## Parsing HTTP response info
236
+
225
237
  HTTP requests all return `DetailedResponse` objects that have a `result`, `status`, and `headers`
238
+
226
239
  ```ruby
227
240
  require "ibm_watson"
228
241
  include IBMWatson
@@ -325,6 +338,7 @@ thr = Thread.new do # Start the websocket inside of a thread
325
338
  end
326
339
  thr.join # Wait for the thread to finish before ending the program or running other code
327
340
  ```
341
+
328
342
  Note: `recognize_with_websocket` has been **deprecated** in favor of **`recognize_using_websocket`**
329
343
 
330
344
  ## Ruby version
@@ -341,12 +355,20 @@ See [CONTRIBUTING.md][CONTRIBUTING].
341
355
 
342
356
  This library is licensed under the [Apache 2.0 license][license].
343
357
 
358
+ ## Featured projects
359
+
360
+ Here are some projects that have been using the SDK:
361
+
362
+ * [GuardianCity](https://github.com/TalentoBogotaFedesoft/ULIBRE-061-grupo-2)
363
+
364
+ We'd love to highlight cool open-source projects that use this SDK! If you'd like to get your project added to the list, feel free to make an issue linking us to it.
365
+
344
366
  [wdc]: http://www.ibm.com/watson/developercloud/
345
- [ibm_cloud]: https://console.bluemix.net
346
- [watson-dashboard]: https://console.bluemix.net/dashboard/apps?category=ai
367
+ [ibm_cloud]: https://cloud.ibm.com/
368
+ [watson-dashboard]: https://cloud.ibm.com/catalog?category=ai
347
369
  [examples]: https://github.com/watson-developer-cloud/ruby-sdk/tree/master/examples
348
370
  [CONTRIBUTING]: https://github.com/watson-developer-cloud/ruby-sdk/blob/master/CONTRIBUTING.md
349
371
  [license]: http://www.apache.org/licenses/LICENSE-2.0
350
- [vcap_services]: https://console.bluemix.net/docs/services/watson/getting-started-variables.html
351
- [ibm-cloud-onboarding]: http://console.bluemix.net/registration?target=/developer/watson&cm_sp=WatsonPlatform-WatsonServices-_-OnPageNavLink-IBMWatson_SDKs-_-Ruby
372
+ [vcap_services]: https://cloud.ibm.com/docs/services/watson?topic=watson-vcapServices
373
+ [ibm-cloud-onboarding]: http://cloud.ibm.com/registration?target=/developer/watson&cm_sp=WatsonPlatform-WatsonServices-_-OnPageNavLink-IBMWatson_SDKs-_-Ruby
352
374
  [ivar]: http://ruby-concurrency.github.io/concurrent-ruby/Concurrent/IVar.html