Skip to content

Commit e05e8ee

Browse files
Mike Kistlergermanattanasio
authored andcommitted
accept version and map version_date to version (#635)
* Change generated service to accept version and translate version_date to version in compact layer * Fix change lost in rebase
1 parent 494f214 commit e05e8ee

File tree

15 files changed

+738
-691
lines changed

15 files changed

+738
-691
lines changed

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ var conversation = new ConversationV1({
151151
username: '<username>',
152152
password: '<password>',
153153
url: 'https://gateway.watsonplatform.net/conversation/api/',
154-
version_date: '2017-05-26'
154+
version: '2017-05-26'
155155
});
156156

157157
conversation.message(
@@ -180,7 +180,7 @@ var discovery = new DiscoveryV1({
180180
username: '<username>',
181181
password: '<password>',
182182
url: 'https://gateway.watsonplatform.net/discovery/api/',
183-
version_date: '2017-09-01'
183+
version: '2017-09-01'
184184
});
185185

186186
discovery.query(
@@ -286,7 +286,7 @@ var NaturalLanguageUnderstandingV1 = require('watson-developer-cloud/natural-lan
286286
var nlu = new NaturalLanguageUnderstandingV1({
287287
username: '<username>',
288288
password: '<password>',
289-
version_date: '2017-02-27',
289+
version: '2017-02-27',
290290
url: 'https://gateway.watsonplatform.net/natural-language-understanding/api/'
291291
});
292292

@@ -320,7 +320,7 @@ var PersonalityInsightsV3 = require('watson-developer-cloud/personality-insights
320320
var personalityInsights = new PersonalityInsightsV3({
321321
username: '<username>',
322322
password: '<password>',
323-
version_date: '2016-10-19',
323+
version: '2016-10-19',
324324
url: 'https://gateway.watsonplatform.net/personality-insights/api/'
325325
});
326326

@@ -420,7 +420,7 @@ var ToneAnalyzerV3 = require('watson-developer-cloud/tone-analyzer/v3');
420420
var toneAnalyzer = new ToneAnalyzerV3({
421421
username: '<username>',
422422
password: '<password>',
423-
version_date: '2016-05-19',
423+
version: '2016-05-19',
424424
url: 'https://gateway.watsonplatform.net/tone-analyzer/api/'
425425
});
426426

@@ -453,7 +453,7 @@ var fs = require('fs');
453453

454454
var visualRecognition = new VisualRecognitionV3({
455455
api_key: '<api_key>',
456-
version_date: '2016-05-20'
456+
version: '2016-05-20'
457457
});
458458

459459
var params = {

conversation/v1-generated.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class ConversationV1 extends BaseService {
3535
* Construct a ConversationV1 object.
3636
*
3737
* @param {Object} options - Options for the service.
38-
* @param {String} options.version_date - The API version date to use with the service, in "YYYY-MM-DD" format. Whenever the API is changed in a backwards incompatible way, a new minor version of the API is released. The service uses the API version for the date you specify, or the most recent version before that date. Note that you should not programmatically specify the current date at runtime, in case the API has been updated since your application's release. Instead, specify a version date that is compatible with your application, and don't change it until your application is ready for a later version.
38+
* @param {String} options.version - The API version date to use with the service, in "YYYY-MM-DD" format. Whenever the API is changed in a backwards incompatible way, a new minor version of the API is released. The service uses the API version for the date you specify, or the most recent version before that date. Note that you should not programmatically specify the current date at runtime, in case the API has been updated since your application's release. Instead, specify a version date that is compatible with your application, and don't change it until your application is ready for a later version.
3939
* @param {String} [options.url] - The base url to use when contacting the service (e.g. 'https://gateway.watsonplatform.net/conversation/api'). The base url may differ between Bluemix regions.
4040
* @param {String} [options.username] - The username used to authenticate with the service. Username and password credentials are only required to run your application locally or outside of Bluemix. When running on Bluemix, the credentials will be automatically loaded from the `VCAP_SERVICES` environment variable.
4141
* @param {String} [options.password] - The password used to authenticate with the service. Username and password credentials are only required to run your application locally or outside of Bluemix. When running on Bluemix, the credentials will be automatically loaded from the `VCAP_SERVICES` environment variable.
@@ -48,11 +48,11 @@ class ConversationV1 extends BaseService {
4848
*/
4949
constructor(options: ConversationV1.Options) {
5050
super(options);
51-
// check if 'version_date' was provided
52-
if (typeof this._options.version_date === 'undefined') {
53-
throw new Error('Argument error: version_date was not specified');
51+
// check if 'version' was provided
52+
if (typeof this._options.version === 'undefined') {
53+
throw new Error('Argument error: version was not specified');
5454
}
55-
this._options.qs.version = options.version_date;
55+
this._options.qs.version = options.version;
5656
}
5757

5858
/*************************
@@ -2240,7 +2240,7 @@ ConversationV1.prototype.serviceVersion = 'v1';
22402240
namespace ConversationV1 {
22412241
/** Options for the `ConversationV1` constructor. **/
22422242
export type Options = {
2243-
version_date: string;
2243+
version: string;
22442244
url?: string;
22452245
username?: string;
22462246
password?: string;

conversation/v1.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,10 @@ class ConversationV1 extends GeneratedConversationV1 {
3131
static VERSION_DATE_2016_07_11: string = '2016-07-11';
3232

3333
constructor(options) {
34-
super(options);
34+
// For backward compatibility, allow version to be passed in version_date.
35+
const _options = extend({}, options);
36+
_options.version = _options.version_date || _options.version;
37+
super(_options);
3538
}
3639

3740
private static removedError: Error = new Error(

discovery/v1-generated.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class DiscoveryV1 extends BaseService {
3535
* Construct a DiscoveryV1 object.
3636
*
3737
* @param {Object} options - Options for the service.
38-
* @param {String} options.version_date - The API version date to use with the service, in "YYYY-MM-DD" format. Whenever the API is changed in a backwards incompatible way, a new minor version of the API is released. The service uses the API version for the date you specify, or the most recent version before that date. Note that you should not programmatically specify the current date at runtime, in case the API has been updated since your application's release. Instead, specify a version date that is compatible with your application, and don't change it until your application is ready for a later version.
38+
* @param {String} options.version - The API version date to use with the service, in "YYYY-MM-DD" format. Whenever the API is changed in a backwards incompatible way, a new minor version of the API is released. The service uses the API version for the date you specify, or the most recent version before that date. Note that you should not programmatically specify the current date at runtime, in case the API has been updated since your application's release. Instead, specify a version date that is compatible with your application, and don't change it until your application is ready for a later version.
3939
* @param {String} [options.url] - The base url to use when contacting the service (e.g. 'https://gateway.watsonplatform.net/discovery/api'). The base url may differ between Bluemix regions.
4040
* @param {String} [options.username] - The username used to authenticate with the service. Username and password credentials are only required to run your application locally or outside of Bluemix. When running on Bluemix, the credentials will be automatically loaded from the `VCAP_SERVICES` environment variable.
4141
* @param {String} [options.password] - The password used to authenticate with the service. Username and password credentials are only required to run your application locally or outside of Bluemix. When running on Bluemix, the credentials will be automatically loaded from the `VCAP_SERVICES` environment variable.
@@ -48,11 +48,11 @@ class DiscoveryV1 extends BaseService {
4848
*/
4949
constructor(options: DiscoveryV1.Options) {
5050
super(options);
51-
// check if 'version_date' was provided
52-
if (typeof this._options.version_date === 'undefined') {
53-
throw new Error('Argument error: version_date was not specified');
51+
// check if 'version' was provided
52+
if (typeof this._options.version === 'undefined') {
53+
throw new Error('Argument error: version was not specified');
5454
}
55-
this._options.qs.version = options.version_date;
55+
this._options.qs.version = options.version;
5656
}
5757

5858
/*************************
@@ -2002,7 +2002,7 @@ DiscoveryV1.prototype.serviceVersion = 'v1';
20022002
namespace DiscoveryV1 {
20032003
/** Options for the `DiscoveryV1` constructor. **/
20042004
export type Options = {
2005-
version_date: string;
2005+
version: string;
20062006
url?: string;
20072007
username?: string;
20082008
password?: string;

discovery/v1.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,13 @@ class DiscoveryV1 extends GeneratedDiscoveryV1 {
2727
static VERSION_DATE_2017_04_27: string = '2017-04-27';
2828
static VERSION_DATE_2016_12_15: string = '2016-12-15';
2929

30+
constructor(options) {
31+
// For backward compatibility, allow version to be passed in version_date.
32+
const _options = extend({}, options);
33+
_options.version = _options.version_date || _options.version;
34+
super(_options);
35+
}
36+
3037
static _ensureFilename(file) {
3138
// no changes needed for streams created by fs.ReadStream (or similar looking streams)
3239
if (isStream.isReadable(file) && file.path) {

lib/base_service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export interface HeaderOptions {
3030

3131
export interface UserOptions {
3232
url?: string;
33-
version_date?: string;
33+
version?: string;
3434
username?: string;
3535
password?: string;
3636
api_key?: string;

0 commit comments

Comments
 (0)