Skip to content

Commit d45ad92

Browse files
authored
Regenerate sdk release 3 2019
2 parents 289a62b + 300305b commit d45ad92

33 files changed

+9510
-1748
lines changed

README.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,9 @@ Watson services are migrating to token-based Identity and Access Management (IAM
9393

9494
- With some service instances, you authenticate to the API by using **[IAM](#iam)**.
9595
- In other instances, you authenticate by providing the **[username and password](#username-and-password)** for the service instance.
96+
- If you're using a Watson service on ICP, you'll need to authenticate in [a specific way](icp).
97+
98+
To specify the type of authentication to use, there is an optional parameter called `authentication_type`. Possible values are `iam`, `basic`, and `icp4d`.
9699

97100
### Getting credentials
98101

@@ -152,6 +155,39 @@ You supply either an IAM service **API key** or an **access token**:
152155
- 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.
153156
- 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/getting-started-iam.html). If you want to switch to API key, override your stored IAM credentials with an IAM API key.
154157

158+
##### ICP
159+
160+
Like IAM, you can pass in credentials to let the SDK manage an access token for you or directly supply an access token to do it yourself.
161+
162+
If you choose to let the SDK manage the token, `authentication_type` must be set to `icp4d`.
163+
164+
```js
165+
const AssistantV1 = require('ibm-watson/assistant/v1');
166+
167+
// letting the SDK manage the token
168+
const assistant = new AssistantV1({
169+
url: '<Service ICP URL>',
170+
icp4d_url: '<ICP token exchange base URL>',
171+
username: '<username>',
172+
password: '<password>',
173+
authentication_type: 'icp4d',
174+
disable_ssl_verification: true,
175+
});
176+
```
177+
178+
```js
179+
const AssistantV1 = require('ibm-watson/assistant/v1');
180+
181+
// assuming control of managing the access token
182+
const assistant = new AssistantV1({
183+
url: '<Service ICP URL>',
184+
icp4d_access_token: '<User-managed access token>',
185+
disable_ssl_verification: true,
186+
});
187+
```
188+
189+
Be sure to both disable SSL verification when authenticating and set the endpoint explicitly to the URL given in ICP.
190+
155191
###### Supplying the IAM API key
156192

157193
```js

assistant/v1.ts

Lines changed: 306 additions & 250 deletions
Large diffs are not rendered by default.

assistant/v2.ts

Lines changed: 69 additions & 31 deletions
Large diffs are not rendered by default.

compare-comply/v1.ts

Lines changed: 74 additions & 45 deletions
Large diffs are not rendered by default.

discovery/v1.ts

Lines changed: 284 additions & 207 deletions
Large diffs are not rendered by default.

language-translator/v3.ts

Lines changed: 471 additions & 23 deletions
Large diffs are not rendered by default.

lib/recognize-stream.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,10 @@ const QUERY_PARAMS_ALLOWED = [
4747
'language_customization_id',
4848
'customization_id',
4949
'acoustic_customization_id',
50-
'access_token'
50+
'access_token',
51+
'processing_metrics',
52+
'processing_metrics_interval',
53+
'audio_metrics'
5154
];
5255

5356
interface RecognizeStream extends Duplex {

natural-language-classifier/v1.ts

Lines changed: 52 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright 2018 IBM All Rights Reserved.
2+
* Copyright 2019 IBM All Rights Reserved.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -14,10 +14,9 @@
1414
* limitations under the License.
1515
*/
1616

17-
import { AxiosResponse } from 'axios';
1817
import * as extend from 'extend';
19-
import { BaseService, getMissingParams } from 'ibm-cloud-sdk-core';
20-
import { FileObject } from 'ibm-cloud-sdk-core';
18+
import { IncomingHttpHeaders, OutgoingHttpHeaders } from 'http';
19+
import { BaseService, FileObject, getMissingParams } from 'ibm-cloud-sdk-core';
2120
import { getSdkHeaders } from '../lib/common';
2221

2322
/**
@@ -40,9 +39,18 @@ class NaturalLanguageClassifierV1 extends BaseService {
4039
* @param {string} [options.iam_access_token] - An IAM access token fully managed by the application. Responsibility falls on the application to refresh the token, either before it expires or reactively upon receiving a 401 from the service, as any requests made with an expired token will fail.
4140
* @param {string} [options.iam_apikey] - An API key that can be used to request IAM tokens. If this API key is provided, the SDK will manage the token and handle the refreshing.
4241
* @param {string} [options.iam_url] - An optional URL for the IAM service API. Defaults to 'https://iam.cloud.ibm.com/identity/token'.
43-
* @param {boolean} [options.use_unauthenticated] - Set to `true` to avoid including an authorization header. This option may be useful for requests that are proxied.
44-
* @param {Object} [options.headers] - Default headers that shall be included with every request to the service.
45-
* @param {boolean} [options.headers.X-Watson-Learning-Opt-Out] - Set to `true` to opt-out of data collection. By default, all IBM Watson services log requests and their results. Logging is done only to improve the services for future users. The logged data is not shared or made public. If you are concerned with protecting the privacy of users' personal information or otherwise do not want your requests to be logged, you can opt out of logging.
42+
* @param {string} [options.iam_client_id] - client id (username) for request to iam service
43+
* @param {string} [options.iam_client_secret] - client secret (password) for request to iam service
44+
* @param {string} [options.icp4d_access_token] - icp for data access token provided and managed by user
45+
* @param {string} [options.icp4d_url] - icp for data base url - used for authentication
46+
* @param {string} [options.authentication_type] - authentication pattern to be used. can be iam, basic, or icp4d
47+
* @param {boolean} [options.use_unauthenticated] - Set to `true` to avoid including an authorization header. This
48+
* option may be useful for requests that are proxied.
49+
* @param {OutgoingHttpHeaders} [options.headers] - Default headers that shall be included with every request to the service.
50+
* @param {boolean} [options.headers.X-Watson-Learning-Opt-Out] - Set to `true` to opt-out of data collection. By
51+
* default, all IBM Watson services log requests and their results. Logging is done only to improve the services for
52+
* future users. The logged data is not shared or made public. If you are concerned with protecting the privacy of
53+
* users' personal information or otherwise do not want your requests to be logged, you can opt out of logging.
4654
* @constructor
4755
* @returns {NaturalLanguageClassifierV1}
4856
*/
@@ -63,7 +71,7 @@ class NaturalLanguageClassifierV1 extends BaseService {
6371
* @param {Object} params - The parameters to send to the service.
6472
* @param {string} params.classifier_id - Classifier ID to use.
6573
* @param {string} params.text - The submitted phrase. The maximum length is 2048 characters.
66-
* @param {Object} [params.headers] - Custom request headers
74+
* @param {OutgoingHttpHeaders} [params.headers] - Custom request headers
6775
* @param {Function} [callback] - The callback that handles the response.
6876
* @returns {Promise<any>|void}
6977
*/
@@ -124,7 +132,7 @@ class NaturalLanguageClassifierV1 extends BaseService {
124132
* @param {Object} params - The parameters to send to the service.
125133
* @param {string} params.classifier_id - Classifier ID to use.
126134
* @param {ClassifyInput[]} params.collection - The submitted phrases.
127-
* @param {Object} [params.headers] - Custom request headers
135+
* @param {OutgoingHttpHeaders} [params.headers] - Custom request headers
128136
* @param {Function} [callback] - The callback that handles the response.
129137
* @returns {Promise<any>|void}
130138
*/
@@ -192,8 +200,9 @@ class NaturalLanguageClassifierV1 extends BaseService {
192200
* (`ja`), Korean (`ko`), Brazilian Portuguese (`pt`), and Spanish (`es`).
193201
* @param {NodeJS.ReadableStream|FileObject|Buffer} params.training_data - Training data in CSV format. Each text
194202
* value must have at least one class. The data can include up to 3,000 classes and 20,000 records. For details, see
195-
* [Data preparation](https://cloud.ibm.com/docs/services/natural-language-classifier/using-your-data.html).
196-
* @param {Object} [params.headers] - Custom request headers
203+
* [Data
204+
* preparation](https://cloud.ibm.com/docs/services/natural-language-classifier?topic=natural-language-classifier-using-your-data).
205+
* @param {OutgoingHttpHeaders} [params.headers] - Custom request headers
197206
* @param {Function} [callback] - The callback that handles the response.
198207
* @returns {Promise<any>|void}
199208
*/
@@ -249,7 +258,7 @@ class NaturalLanguageClassifierV1 extends BaseService {
249258
*
250259
* @param {Object} params - The parameters to send to the service.
251260
* @param {string} params.classifier_id - Classifier ID to delete.
252-
* @param {Object} [params.headers] - Custom request headers
261+
* @param {OutgoingHttpHeaders} [params.headers] - Custom request headers
253262
* @param {Function} [callback] - The callback that handles the response.
254263
* @returns {Promise<any>|void}
255264
*/
@@ -300,7 +309,7 @@ class NaturalLanguageClassifierV1 extends BaseService {
300309
*
301310
* @param {Object} params - The parameters to send to the service.
302311
* @param {string} params.classifier_id - Classifier ID to query.
303-
* @param {Object} [params.headers] - Custom request headers
312+
* @param {OutgoingHttpHeaders} [params.headers] - Custom request headers
304313
* @param {Function} [callback] - The callback that handles the response.
305314
* @returns {Promise<any>|void}
306315
*/
@@ -350,7 +359,7 @@ class NaturalLanguageClassifierV1 extends BaseService {
350359
* Returns an empty array if no classifiers are available.
351360
*
352361
* @param {Object} [params] - The parameters to send to the service.
353-
* @param {Object} [params.headers] - Custom request headers
362+
* @param {OutgoingHttpHeaders} [params.headers] - Custom request headers
354363
* @param {Function} [callback] - The callback that handles the response.
355364
* @returns {Promise<any>|void}
356365
*/
@@ -400,18 +409,38 @@ namespace NaturalLanguageClassifierV1 {
400409
iam_access_token?: string;
401410
iam_apikey?: string;
402411
iam_url?: string;
412+
iam_client_id?: string;
413+
iam_client_secret?: string;
414+
icp4d_access_token?: string;
415+
icp4d_url?: string;
403416
username?: string;
404417
password?: string;
418+
token?: string;
419+
authentication_type?: string;
420+
disable_ssl_verification?: boolean;
405421
use_unauthenticated?: boolean;
406-
headers?: object;
422+
headers?: OutgoingHttpHeaders;
423+
}
424+
425+
export interface Response<T = any> {
426+
result: T;
427+
data: T; // for compatibility
428+
status: number;
429+
statusText: string;
430+
headers: IncomingHttpHeaders;
407431
}
408432

409433
/** The callback for a service request. */
410-
export type Callback<T> = (error: any, body?: T, response?: AxiosResponse<T>) => void;
434+
export type Callback<T> = (error: any, body?: T, response?: Response<T>) => void;
411435

412436
/** The body of a service request that returns no response data. */
413437
export interface Empty { }
414438

439+
/** A standard JS object, defined to avoid the limitations of `Object` and `object` */
440+
export interface JsonObject {
441+
[key: string]: any;
442+
}
443+
415444
/*************************
416445
* request interfaces
417446
************************/
@@ -422,7 +451,7 @@ namespace NaturalLanguageClassifierV1 {
422451
classifier_id: string;
423452
/** The submitted phrase. The maximum length is 2048 characters. */
424453
text: string;
425-
headers?: Object;
454+
headers?: OutgoingHttpHeaders;
426455
return_response?: boolean;
427456
}
428457

@@ -432,39 +461,39 @@ namespace NaturalLanguageClassifierV1 {
432461
classifier_id: string;
433462
/** The submitted phrases. */
434463
collection: ClassifyInput[];
435-
headers?: Object;
464+
headers?: OutgoingHttpHeaders;
436465
return_response?: boolean;
437466
}
438467

439468
/** Parameters for the `createClassifier` operation. */
440469
export interface CreateClassifierParams {
441470
/** Metadata in JSON format. The metadata identifies the language of the data, and an optional name to identify the classifier. Specify the language with the 2-letter primary language code as assigned in ISO standard 639. Supported languages are English (`en`), Arabic (`ar`), French (`fr`), German, (`de`), Italian (`it`), Japanese (`ja`), Korean (`ko`), Brazilian Portuguese (`pt`), and Spanish (`es`). */
442471
metadata: NodeJS.ReadableStream|FileObject|Buffer;
443-
/** Training data in CSV format. Each text value must have at least one class. The data can include up to 3,000 classes and 20,000 records. For details, see [Data preparation](https://cloud.ibm.com/docs/services/natural-language-classifier/using-your-data.html). */
472+
/** Training data in CSV format. Each text value must have at least one class. The data can include up to 3,000 classes and 20,000 records. For details, see [Data preparation](https://cloud.ibm.com/docs/services/natural-language-classifier?topic=natural-language-classifier-using-your-data). */
444473
training_data: NodeJS.ReadableStream|FileObject|Buffer;
445-
headers?: Object;
474+
headers?: OutgoingHttpHeaders;
446475
return_response?: boolean;
447476
}
448477

449478
/** Parameters for the `deleteClassifier` operation. */
450479
export interface DeleteClassifierParams {
451480
/** Classifier ID to delete. */
452481
classifier_id: string;
453-
headers?: Object;
482+
headers?: OutgoingHttpHeaders;
454483
return_response?: boolean;
455484
}
456485

457486
/** Parameters for the `getClassifier` operation. */
458487
export interface GetClassifierParams {
459488
/** Classifier ID to query. */
460489
classifier_id: string;
461-
headers?: Object;
490+
headers?: OutgoingHttpHeaders;
462491
return_response?: boolean;
463492
}
464493

465494
/** Parameters for the `listClassifiers` operation. */
466495
export interface ListClassifiersParams {
467-
headers?: Object;
496+
headers?: OutgoingHttpHeaders;
468497
return_response?: boolean;
469498
}
470499

0 commit comments

Comments
 (0)