Skip to content

Commit

Permalink
Regenerates all services
Browse files Browse the repository at this point in the history
  • Loading branch information
Anwesha Naskar authored and Anwesha Naskar committed Mar 6, 2018
1 parent 98969e4 commit c18663c
Show file tree
Hide file tree
Showing 56 changed files with 543 additions and 551 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Expand Up @@ -33,4 +33,5 @@ index.js
**/*.d.ts
!*/blob.d.ts
**/*.js.map
coverage.lcov
coverage.lcov
.swagger-codegen-ignore
3 changes: 1 addition & 2 deletions conversation/v1-generated.ts
Expand Up @@ -14,7 +14,6 @@
* limitations under the License.
*/


import * as extend from 'extend';
import { RequestResponse } from 'request';
import { BaseService } from '../lib/base_service';
Expand Down Expand Up @@ -3419,4 +3418,4 @@ namespace ConversationV1 {

}

export = ConversationV1;
export = ConversationV1;
8 changes: 4 additions & 4 deletions conversation/v1.ts
Expand Up @@ -30,17 +30,17 @@ class ConversationV1 extends GeneratedConversationV1 {

static VERSION_DATE_2016_07_11: string = '2016-07-11';

private static removedError: Error = new Error(
'This endpoint has been deprecated.'
);

constructor(options) {
// For backward compatibility, allow version to be passed in version_date.
const _options = extend({}, options);
_options.version = _options.version_date || _options.version;
super(_options);
}

private static removedError: Error = new Error(
'This endpoint has been deprecated.'
);

workspaceStatus(params, callback) {
console.warn(ConversationV1.removedError);
}
Expand Down
5 changes: 2 additions & 3 deletions discovery/v1-generated.ts
Expand Up @@ -14,12 +14,11 @@
* limitations under the License.
*/


import * as extend from 'extend';
import { RequestResponse } from 'request';
import { BaseService } from '../lib/base_service';
import { FileObject } from '../lib/helper';
import { getMissingParams } from '../lib/helper';
import { FileObject } from '../lib/helper';
import { createRequest } from '../lib/requestwrapper';

/**
Expand Down Expand Up @@ -3280,4 +3279,4 @@ namespace DiscoveryV1 {

}

export = DiscoveryV1;
export = DiscoveryV1;
14 changes: 7 additions & 7 deletions discovery/v1.ts
Expand Up @@ -27,13 +27,6 @@ class DiscoveryV1 extends GeneratedDiscoveryV1 {
static VERSION_DATE_2017_04_27: string = '2017-04-27';
static VERSION_DATE_2016_12_15: string = '2016-12-15';

constructor(options) {
// For backward compatibility, allow version to be passed in version_date.
const _options = extend({}, options);
_options.version = _options.version_date || _options.version;
super(_options);
}

static _ensureFilename(file) {
// no changes needed for streams created by fs.ReadStream (or similar looking streams)
if (isStream.isReadable(file) && file.path) {
Expand Down Expand Up @@ -64,6 +57,13 @@ class DiscoveryV1 extends GeneratedDiscoveryV1 {
};
}

constructor(options) {
// For backward compatibility, allow version to be passed in version_date.
const _options = extend({}, options);
_options.version = _options.version_date || _options.version;
super(_options);
}

getEnvironments(params, callback) {
return super.listEnvironments(params, callback);
}
Expand Down
4 changes: 2 additions & 2 deletions examples/browserify/public/client.js
Expand Up @@ -28,11 +28,11 @@ function getToken() {
function analyze(token) {
var toneAnalyzer = new ToneAnalyzerV3({
token: token,
version: '2016-05-19'
version: '2016-05-19',
});
toneAnalyzer.tone(
{
text: input.value
text: input.value,
},
function(err, result) {
if (err) {
Expand Down
Expand Up @@ -23,7 +23,7 @@ var Promise = require('bluebird');
*/
module.exports = {
updateUserTone: updateUserTone,
invokeToneAsync: invokeToneAsync
invokeToneAsync: invokeToneAsync,
};

/**
Expand Down Expand Up @@ -85,9 +85,9 @@ function initUser() {
return {
user: {
tone: {
current: null
}
}
current: null,
},
},
};
}

Expand Down Expand Up @@ -118,7 +118,7 @@ function updateTone(user, tones, maintainHistory) {
}
user.tone.history.push({
tone_name: primaryTone,
score: primaryToneScore
score: primaryToneScore,
});
}
}
Expand Up @@ -15,11 +15,11 @@ var lineIn = new LineIn(); // 2-channel 16-bit little-endian signed integer pcm

var wavStream = new wav.Writer({
sampleRate: 44100,
channels: 2
channels: 2,
});

var recognizeStream = speechToText.createRecognizeStream({
content_type: 'audio/wav'
content_type: 'audio/wav',
});

lineIn.pipe(wavStream);
Expand Down
Expand Up @@ -15,18 +15,18 @@ var speechToText = new SpeechToText({
var micInstance = mic({
rate: '48000',
channels: '1',
debug: false
debug: false,
});

var micInputStream = micInstance.getAudioStream();

var wavStream = new wav.FileWriter('./audio.wav', {
sampleRate: 48000,
channels: 1
channels: 1,
});

var recognizeStream = speechToText.createRecognizeStream({
content_type: 'audio/wav'
content_type: 'audio/wav',
});

micInputStream.pipe(wavStream);
Expand Down
2 changes: 1 addition & 1 deletion examples/text_to_speech_synthesize_handle_errors.js
Expand Up @@ -18,7 +18,7 @@ var stream = textToSpeech
{
text: 'Hello from IBM Watson',
voice: 'INVALID_VOICE', // comment this line to show the example working correctly
accept: 'audio/wav' // default is audio/ogg; codec=opus
accept: 'audio/wav', // default is audio/ogg; codec=opus
},
function(error) {
if (error) {
Expand Down
4 changes: 2 additions & 2 deletions examples/webpack/public/client.js
Expand Up @@ -28,11 +28,11 @@ function getToken() {
function analyze(token) {
var toneAnalyzer = new ToneAnalyzerV3({
token: token,
version: '2016-05-19'
version: '2016-05-19',
});
toneAnalyzer.tone(
{
text: input.value
text: input.value,
},
function(err, result) {
if (err) {
Expand Down
12 changes: 6 additions & 6 deletions examples/webpack/webpack.config.js
Expand Up @@ -3,13 +3,13 @@
module.exports = {
entry: './public/client.js',
output: {
filename: 'bundle.js'
filename: 'bundle.js',
},
// http://webpack.github.io/docs/configuration.html#node
node: {
fs: 'empty',
net: 'empty',
tls: 'empty'
tls: 'empty',
},
// Loader for Retrieve & Rank
// Retrieve & Rank depends on solr-client, which depends on JSONStream, which starts with a shebang line, which
Expand All @@ -23,8 +23,8 @@ module.exports = {
rules: [
{
test: /JSONStream/,
use: 'shebang-loader'
}
]
}
use: 'shebang-loader',
},
],
},
};
14 changes: 7 additions & 7 deletions index.ts
Expand Up @@ -50,11 +50,11 @@ export import VisualRecognitionV3 = require('./visual-recognition/v3');
// e.g. servicesByVersion.text_to_speech.v1 === export import TextToSpeechV1;
const servicesByVersion = {};
Object.keys(exports).forEach(key => {
const Service = exports[key];
const name = Service.prototype.name;
const version = Service.prototype.serviceVersion;
const service = exports[key];
const name = service.prototype.name;
const version = service.prototype.serviceVersion;
servicesByVersion[name] = servicesByVersion[name] || {};
servicesByVersion[name][version] = Service;
servicesByVersion[name][version] = service;
});

Object.keys(servicesByVersion).forEach(serviceName => {
Expand All @@ -79,15 +79,15 @@ Object.keys(servicesByVersion).forEach(serviceName => {
options.version = 'v1';
}

const Service = servicesByVersion[serviceName][options.version];
const service = servicesByVersion[serviceName][options.version];

if (!Service) {
if (!service) {
throw new Error(
'Unable to find ' + serviceName + ' version ' + options.version
);
}

return new Service({
return new service({
...options,
serviceVersion: options.version,
version: options.version_date,
Expand Down
2 changes: 1 addition & 1 deletion lib/querystring.ts
Expand Up @@ -10,7 +10,7 @@
*/
const stringify = (queryParams: Object): string => {
return Object.keys(queryParams)
.map(function(key) {
.map((key) => {
return (
key +
'=' +
Expand Down
7 changes: 7 additions & 0 deletions lib/requestwrapper.ts
Expand Up @@ -216,6 +216,13 @@ export function createRequest(parameters, _callback) {
typeof formData[key] === 'object' &&
(formData[key] = JSON.stringify(formData[key]))
);

// Stringify arrays
Object.keys(options.formData).forEach(
key =>
Array.isArray(options.formData[key]) &&
(options.formData[key] = options.formData[key].join(','))
);
}

// Path params
Expand Down
6 changes: 2 additions & 4 deletions natural-language-classifier/v1-generated.ts
Expand Up @@ -14,15 +14,13 @@
* limitations under the License.
*/


import * as extend from 'extend';
import { RequestResponse } from 'request';
import { BaseService } from '../lib/base_service';
import { FileObject } from '../lib/helper';
import { getMissingParams } from '../lib/helper';
import { FileObject } from '../lib/helper';
import { createRequest } from '../lib/requestwrapper';


/**
* IBM Watson Natural Language Classifier uses machine learning algorithms to return the top matching predefined classes for short text input. You create and train a classifier to connect predefined classes to example texts so that the service can apply those classes to new inputs.
*/
Expand Down Expand Up @@ -361,4 +359,4 @@ namespace NaturalLanguageClassifierV1 {

}

export = NaturalLanguageClassifierV1;
export = NaturalLanguageClassifierV1;
3 changes: 1 addition & 2 deletions natural-language-understanding/v1-generated.ts
Expand Up @@ -14,7 +14,6 @@
* limitations under the License.
*/


import * as extend from 'extend';
import { RequestResponse } from 'request';
import { BaseService } from '../lib/base_service';
Expand Down Expand Up @@ -658,4 +657,4 @@ namespace NaturalLanguageUnderstandingV1 {

}

export = NaturalLanguageUnderstandingV1;
export = NaturalLanguageUnderstandingV1;
8 changes: 4 additions & 4 deletions personality-insights/v2.ts
Expand Up @@ -66,14 +66,14 @@ class PersonalityInsightsV2 extends BaseService {
return;
}
// Content-Type
let content_type = null;
let contentType = null;
if (_params.text) {
content_type = isHTML(_params.text) ? 'text/html' : 'text/plain';
contentType = isHTML(_params.text) ? 'text/html' : 'text/plain';
} else {
content_type = 'application/json';
contentType = 'application/json';
}
const headers = {
'Content-type': content_type,
'Content-type': contentType,
'Accept-language':
_params.accept_language || _params.acceptLanguage || 'en',
Accept: undefined
Expand Down
10 changes: 5 additions & 5 deletions personality-insights/v3.ts
Expand Up @@ -44,16 +44,16 @@ class PersonalityInsightsV3 extends GeneratedPersonalityInsightsV3 {
return;
}

let content_type = null;
let contentType = null;
if (params.text) {
content_type = isHTML(params.text) ? 'text/html' : 'text/plain';
contentType = isHTML(params.text) ? 'text/html' : 'text/plain';
} else {
content_type = 'application/json';
contentType = 'application/json';
}

const _params: GeneratedPersonalityInsightsV3.ProfileParams = {
content: params.text || pick(params, ['contentItems']),
content_type,
content_type: contentType,
raw_scores: params.raw_scores,
csv_headers: params.csv_headers,
consumption_preferences: params.consumption_preferences
Expand Down Expand Up @@ -100,7 +100,7 @@ class PersonalityInsightsV3 extends GeneratedPersonalityInsightsV3 {
>
): NodeJS.ReadableStream | void {
const _params = extend({}, params);
const _callback = callback ? callback : () => {};
const _callback = callback ? callback : () => { /*noop*/ };
const requiredParams = ['content', 'content_type'];
const missingParams = getMissingParams(_params, requiredParams);
if (missingParams) {
Expand Down

0 comments on commit c18663c

Please sign in to comment.