Skip to content

Commit 6fd8af3

Browse files
committed
Merge branch 'v4.0.0-branch' into add-promise-support
2 parents 4db3e4b + 569b1fc commit 6fd8af3

35 files changed

Lines changed: 1859 additions & 1318 deletions

CHANGELOG.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,26 @@
1+
# [3.18.0](https://github.com/watson-developer-cloud/node-sdk/compare/v3.17.0...v3.18.0) (2019-02-06)
2+
3+
4+
### Features
5+
6+
* **compare-comply:** new constants and new model properties added ([d9dc7cc](https://github.com/watson-developer-cloud/node-sdk/commit/d9dc7cc))
7+
* **discovery:** add method `getStopwordListStatus` ([ea9eaf9](https://github.com/watson-developer-cloud/node-sdk/commit/ea9eaf9))
8+
* **speech-to-text:** optional parameter `force` added to the method `upgradeAcousticModel` ([ceaa843](https://github.com/watson-developer-cloud/node-sdk/commit/ceaa843))
9+
10+
# [3.17.0](https://github.com/watson-developer-cloud/node-sdk/compare/v3.16.1...v3.17.0) (2019-02-04)
11+
12+
13+
### Features
14+
15+
* enable reading credentials from ibm-credentials.env file ([ce02aa8](https://github.com/watson-developer-cloud/node-sdk/commit/ce02aa8))
16+
17+
## [3.16.1](https://github.com/watson-developer-cloud/node-sdk/compare/v3.16.0...v3.16.1) (2019-01-19)
18+
19+
20+
### Bug Fixes
21+
22+
* fix `getTransactionId` method for the `RecognizeStream` class ([e5bbe2c](https://github.com/watson-developer-cloud/node-sdk/commit/e5bbe2c))
23+
124
# [3.16.0](https://github.com/watson-developer-cloud/node-sdk/compare/v3.15.4...v3.16.0) (2019-01-17)
225

326

README.md

Lines changed: 48 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -86,14 +86,55 @@ Watson services are migrating to token-based Identity and Access Management (IAM
8686
- In other instances, you authenticate by providing the **[username and password](#username-and-password)** for the service instance.
8787

8888
### Getting credentials
89+
8990
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:
9091

91-
1. Go to the IBM Cloud [Dashboard](https://console.bluemix.net/dashboard/apps?category=ai) page.
92-
1. Either click an existing Watson service instance or click [**Create resource > AI**](https://console.bluemix.net/catalog/?category=ai) and create a service instance.
93-
1. Click **Show** to view your service credentials.
94-
1. Copy the `url` and either `apikey` or `username` and `password`.
92+
1. Go to the IBM Cloud [Dashboard](https://cloud.ibm.com/) page.
93+
2. Either click an existing Watson service instance in your [resource list](https://cloud.ibm.com/resources) or click [**Create resource > AI**](https://cloud.ibm.com/catalog?category=ai) and create a service instance.
94+
3. Click on the **Manage** item in the left nav bar of your service instance.
95+
96+
On this page, you should be able to see your credentials for accessing your service instance.
97+
98+
In your code, you can use these values in the service constructor or with a method call after instantiating your service.
99+
100+
### Supplying credentials
101+
102+
There are two ways to supply the credentials you found above to the SDK for authentication:
103+
104+
#### Credentials file (easier!)
105+
106+
With a credentials file, you just need to put the file in the right place and the SDK will do the work of parsing it and authenticating. You can get this file by clicking the **Download** button for the credentials in the **Manage** tab of your service instance.
107+
108+
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):
109+
110+
- Directory provided by the environment variable `IBM_CREDENTIALS_FILE`
111+
- Your system's home directory
112+
- Your current working directory (the directory Node is executed from)
113+
114+
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:
115+
116+
```js
117+
const DiscoveryV1 = require('watson-developer-cloud/discovery/v1');
118+
const discovery = new DiscoveryV1({ version: '2019-02-01' });
119+
```
120+
121+
And that's it!
122+
123+
If you're using more than one service at a time in your code and get two different `ibm-credentials.env` files, just put the contents together in one `ibm-credentials.env` file and the SDK will handle assigning credentials to their appropriate services.
124+
125+
If you would like to configure the location/name of your credential file, you can set an environment variable called `IBM_CREDENTIALS_FILE`. **This will take precedence over the locations specified above.** Here's how you can do that:
126+
127+
```bash
128+
export IBM_CREDENTIALS_FILE="<path>"
129+
```
130+
131+
where `<path>` is something like `/home/user/Downloads/<file_name>.env`. If you just provide a path to a directory, the SDK will look for a file called `ibm-credentials.env` in that directory.
132+
133+
#### Manually
134+
135+
The SDK also supports setting credentials manually in your code. You will either use IAM credentials or Basic Authentication (username/password) credentials.
95136

96-
### IAM
137+
##### IAM
97138

98139
Some services use token-based Identity and Access Management (IAM) authentication. IAM authentication uses a service API key to get an access token that is passed with the call. Access tokens are valid for approximately one hour and must be regenerated.
99140

@@ -102,7 +143,7 @@ You supply either an IAM service **API key** or an **access token**:
102143
- 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.
103144
- 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). If you want to switch to API key, override your stored IAM credentials with an IAM API key.
104145

105-
#### Supplying the IAM API key
146+
###### Supplying the IAM API key
106147

107148
```js
108149
// in the constructor, letting the SDK manage the IAM token
@@ -114,7 +155,7 @@ const discovery = new DiscoveryV1({
114155
});
115156
```
116157

117-
#### Supplying the access token
158+
###### Supplying the access token
118159

119160
```js
120161
// in the constructor, assuming control of managing IAM token

UPGRADE-4.0.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Upgrading to watson-developer-cloud@4.0
22
- [Breaking changes]
3+
- [Methods no longer return stream]
4+
- [Error Handling Compatibility]
35
- [Removed Services]
46
- [Constructor Compatibility]
57
- [Discovery Compatibility]
@@ -12,6 +14,21 @@
1214

1315

1416
## Breaking changes
17+
### Methods no longer return stream
18+
Previously, if a callback was not provided, each service method would return a pipeable stream. Now, this will no longer happen. This should not affect many users, as authenticating with IAM already prevented methods from returning streams.
19+
20+
### Error Handling Compatibility
21+
The logic that formats errors returned from a service has been changed. That means that the Error object returned now has a different structure. If there is logic in your code that parses the error returned from service methods, this will need to change. The new structure is outlined below.
22+
23+
The object returned is of class `Error` and has the following properties:
24+
- `name`: Short title describing the error. Ex) 'Not Found'
25+
- `code`: HTTP status code. Ex) 404
26+
- `message`: More descriptive error message. Ex) Model not found.
27+
- `body`: Full error object returned by the service, stringified. If the object cannot be stringified due to a circular reference, it will be left as an object
28+
- `headers`: Object containing response headers returned from the service, including the transaction id
29+
30+
If a request is made but no response is received (very rare), `error.body` will be an instance of [HTTP.ClientRequest](https://nodejs.org/api/http.html#http_class_http_clientrequest).
31+
1532
### Removed Services
1633
The following services have been deprecated for an extended period of time and will no longer be supported in the SDK:
1734
- Dialog

0 commit comments

Comments
 (0)