Skip to content

Commit fb7025a

Browse files
committed
chore: apply handwritten changes
1 parent 737e212 commit fb7025a

File tree

2 files changed

+39
-12
lines changed

2 files changed

+39
-12
lines changed

language-translator/v2-generated.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import { getMissingParams } from '../lib/helper';
2121
import { FileObject } from '../lib/helper';
2222

2323
/**
24-
* --- Language Translator v3 is [available](https://www.ibm.com/watson/developercloud/language-translator/api/v3/). See the [migration guide](https://console.bluemix.net/docs/services/language-translator/migrating.html). --- IBM Watson™ Language Translator translates text from one language to another. The service offers multiple domain-specific models that you can customize based on your unique terminology and language. Use Language Translator to take news from across the globe and present it in your language, communicate with your customers in their own language, and more.
24+
* @deprecated Language Translator v3 is [available](https://www.ibm.com/watson/developercloud/language-translator/api/v3/). See the [migration guide](https://console.bluemix.net/docs/services/language-translator/migrating.html). --- IBM Watson™ Language Translator translates text from one language to another. The service offers multiple domain-specific models that you can customize based on your unique terminology and language. Use Language Translator to take news from across the globe and present it in your language, communicate with your customers in their own language, and more.
2525
*/
2626

2727
class LanguageTranslatorV2 extends BaseService {

visual-recognition/v3-generated.ts

Lines changed: 38 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,10 @@ class VisualRecognitionV3 extends BaseService {
233233
*
234234
* Encode special characters in the file name in UTF-8.
235235
* @param {string} [params.classname_positive_examples_filename] - The filename for classname_positive_examples.
236+
*
237+
* Specify the filename by appending `_positive_examples_filename` to the class name. For example,
238+
* the filename parameter for `goldenretriever_positive_examples` would be `goldenretriever_positive_examples_filename`
239+
*
236240
* @param {string} [params.negative_examples_filename] - The filename for negative_examples.
237241
* @param {Object} [params.headers] - Custom request headers
238242
* @param {Function} [callback] - The callback that handles the response.
@@ -241,16 +245,14 @@ class VisualRecognitionV3 extends BaseService {
241245
public createClassifier(params: VisualRecognitionV3.CreateClassifierParams, callback?: VisualRecognitionV3.Callback<VisualRecognitionV3.Classifier>): NodeJS.ReadableStream | void {
242246
const _params = extend({}, params);
243247
const _callback = (callback) ? callback : () => { /* noop */ };
244-
const requiredParams = ['name', 'classname_positive_examples'];
248+
const positiveExampleClasses = Object.keys(_params).filter(key => {
249+
return key.match(/^.+positive_examples$/);
250+
}) || ['<classname>_positive_examples'];
251+
const requiredParams = ['name', ...positiveExampleClasses];
245252
const missingParams = getMissingParams(_params, requiredParams);
246253
if (missingParams) {
247254
return _callback(missingParams);
248255
}
249-
if (_params.classname_positive_examples && !_params.classname_positive_examples_filename) {
250-
console.warn(
251-
'WARNING: `classname_positive_examples_filename` should be provided if `classname_positive_examples` is not null. This will be REQUIRED in the next major release.'
252-
);
253-
}
254256
if (_params.negative_examples && !_params.negative_examples_filename) {
255257
console.warn(
256258
'WARNING: `negative_examples_filename` should be provided if `negative_examples` is not null. This will be REQUIRED in the next major release.'
@@ -269,6 +271,18 @@ class VisualRecognitionV3 extends BaseService {
269271
contentType: 'application/octet-stream'
270272
}
271273
};
274+
positiveExampleClasses.forEach(positiveExampleClass => {
275+
if (!_params[`${positiveExampleClass}_filename`]) {
276+
console.warn(
277+
`WARNING: \`${positiveExampleClass}_filename\` should be provided if \`${positiveExampleClass}\` is not null. This will be REQUIRED in the next major release.`
278+
);
279+
}
280+
formData[positiveExampleClass] = {
281+
data: _params[positiveExampleClass],
282+
filename: _params[`${positiveExampleClass}_filename`],
283+
contentType: 'application/octet-stream',
284+
};
285+
});
272286
const parameters = {
273287
options: {
274288
url: '/v3/classifiers',
@@ -424,6 +438,9 @@ class VisualRecognitionV3 extends BaseService {
424438
*
425439
* Encode special characters in the file name in UTF-8.
426440
* @param {string} [params.classname_positive_examples_filename] - The filename for classname_positive_examples.
441+
*
442+
* Specify the filename by appending `_positive_examples_filename` to the class name. For example,
443+
* the filename parameter for `goldenretriever_positive_examples` would be `goldenretriever_positive_examples_filename`
427444
* @param {string} [params.negative_examples_filename] - The filename for negative_examples.
428445
* @param {Object} [params.headers] - Custom request headers
429446
* @param {Function} [callback] - The callback that handles the response.
@@ -432,16 +449,14 @@ class VisualRecognitionV3 extends BaseService {
432449
public updateClassifier(params: VisualRecognitionV3.UpdateClassifierParams, callback?: VisualRecognitionV3.Callback<VisualRecognitionV3.Classifier>): NodeJS.ReadableStream | void {
433450
const _params = extend({}, params);
434451
const _callback = (callback) ? callback : () => { /* noop */ };
452+
const positiveExampleClasses = Object.keys(_params).filter(key => {
453+
return key.match(/^.+positive_examples$/);
454+
});
435455
const requiredParams = ['classifier_id'];
436456
const missingParams = getMissingParams(_params, requiredParams);
437457
if (missingParams) {
438458
return _callback(missingParams);
439459
}
440-
if (_params.classname_positive_examples && !_params.classname_positive_examples_filename) {
441-
console.warn(
442-
'WARNING: `classname_positive_examples_filename` should be provided if `classname_positive_examples` is not null. This will be REQUIRED in the next major release.'
443-
);
444-
}
445460
if (_params.negative_examples && !_params.negative_examples_filename) {
446461
console.warn(
447462
'WARNING: `negative_examples_filename` should be provided if `negative_examples` is not null. This will be REQUIRED in the next major release.'
@@ -462,6 +477,18 @@ class VisualRecognitionV3 extends BaseService {
462477
const path = {
463478
'classifier_id': _params.classifier_id
464479
};
480+
positiveExampleClasses.forEach(positiveExampleClass => {
481+
if (!_params[`${positiveExampleClass}_filename`]) {
482+
console.warn(
483+
`WARNING: \`${positiveExampleClass}_filename\` should be provided if \`${positiveExampleClass}\` is not null. This will be REQUIRED in the next major release.`
484+
);
485+
}
486+
formData[positiveExampleClass] = {
487+
data: _params[positiveExampleClass],
488+
filename: _params[`${positiveExampleClass}_filename`],
489+
contentType: 'application/octet-stream',
490+
};
491+
});
465492
const parameters = {
466493
options: {
467494
url: '/v3/classifiers/{classifier_id}',

0 commit comments

Comments
 (0)