Skip to content
This repository was archived by the owner on May 5, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 17 additions & 17 deletions lib/services/computerVision/lib/computerVisionClient.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ export default class ComputerVisionClient extends ServiceClient {
*
* @param {object} [options] Optional Parameters.
*
* @param {string} [options.maxCandidates] Maximum number of candidate
* @param {number} [options.maxCandidates] Maximum number of candidate
* descriptions to be returned. The default is 1.
*
* @param {string} [options.language] The desired language for output
Expand All @@ -410,7 +410,7 @@ export default class ComputerVisionClient extends ServiceClient {
*
* @reject {Error|ServiceError} - The error object.
*/
describeImageWithHttpOperationResponse(url: string, options?: { maxCandidates? : string, language? : string, customHeaders? : { [headerName: string]: string; } }): Promise<HttpOperationResponse<models.ImageDescription>>;
describeImageWithHttpOperationResponse(url: string, options?: { maxCandidates? : number, language? : string, customHeaders? : { [headerName: string]: string; } }): Promise<HttpOperationResponse<models.ImageDescription>>;

/**
* This operation generates a description of an image in human readable
Expand All @@ -427,7 +427,7 @@ export default class ComputerVisionClient extends ServiceClient {
*
* @param {object} [options] Optional Parameters.
*
* @param {string} [options.maxCandidates] Maximum number of candidate
* @param {number} [options.maxCandidates] Maximum number of candidate
* descriptions to be returned. The default is 1.
*
* @param {string} [options.language] The desired language for output
Expand Down Expand Up @@ -461,9 +461,9 @@ export default class ComputerVisionClient extends ServiceClient {
*
* {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur.
*/
describeImage(url: string, options?: { maxCandidates? : string, language? : string, customHeaders? : { [headerName: string]: string; } }): Promise<models.ImageDescription>;
describeImage(url: string, options?: { maxCandidates? : number, language? : string, customHeaders? : { [headerName: string]: string; } }): Promise<models.ImageDescription>;
describeImage(url: string, callback: ServiceCallback<models.ImageDescription>): void;
describeImage(url: string, options: { maxCandidates? : string, language? : string, customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback<models.ImageDescription>): void;
describeImage(url: string, options: { maxCandidates? : number, language? : string, customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback<models.ImageDescription>): void;


/**
Expand Down Expand Up @@ -777,10 +777,10 @@ export default class ComputerVisionClient extends ServiceClient {
* black&white.Adult - detects if the image is pornographic in nature (depicts
* nudity or a sex act). Sexually suggestive content is also detected.
*
* @param {string} [options.details] A string indicating which domain-specific
* @param {array} [options.details] A string indicating which domain-specific
* details to return. Multiple values should be comma-separated. Valid visual
* feature types include:Celebrities - identifies celebrities if detected in
* the image. Possible values include: 'Celebrities', 'Landmarks'
* the image.
*
* @param {string} [options.language] The desired language for output
* generation. If this parameter is not specified, the default value is
Expand All @@ -797,7 +797,7 @@ export default class ComputerVisionClient extends ServiceClient {
*
* @reject {Error|ServiceError} - The error object.
*/
analyzeImageInStreamWithHttpOperationResponse(image: stream.Readable, options?: { visualFeatures? : string[], details? : string, language? : string, customHeaders? : { [headerName: string]: string; } }): Promise<HttpOperationResponse<models.ImageAnalysis>>;
analyzeImageInStreamWithHttpOperationResponse(image: stream.Readable, options?: { visualFeatures? : string[], details? : string[], language? : string, customHeaders? : { [headerName: string]: string; } }): Promise<HttpOperationResponse<models.ImageAnalysis>>;

/**
* This operation extracts a rich set of visual features based on the image
Expand All @@ -819,10 +819,10 @@ export default class ComputerVisionClient extends ServiceClient {
* black&white.Adult - detects if the image is pornographic in nature (depicts
* nudity or a sex act). Sexually suggestive content is also detected.
*
* @param {string} [options.details] A string indicating which domain-specific
* @param {array} [options.details] A string indicating which domain-specific
* details to return. Multiple values should be comma-separated. Valid visual
* feature types include:Celebrities - identifies celebrities if detected in
* the image. Possible values include: 'Celebrities', 'Landmarks'
* the image.
*
* @param {string} [options.language] The desired language for output
* generation. If this parameter is not specified, the default value is
Expand Down Expand Up @@ -855,9 +855,9 @@ export default class ComputerVisionClient extends ServiceClient {
*
* {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur.
*/
analyzeImageInStream(image: stream.Readable, options?: { visualFeatures? : string[], details? : string, language? : string, customHeaders? : { [headerName: string]: string; } }): Promise<models.ImageAnalysis>;
analyzeImageInStream(image: stream.Readable, options?: { visualFeatures? : string[], details? : string[], language? : string, customHeaders? : { [headerName: string]: string; } }): Promise<models.ImageAnalysis>;
analyzeImageInStream(image: stream.Readable, callback: ServiceCallback<models.ImageAnalysis>): void;
analyzeImageInStream(image: stream.Readable, options: { visualFeatures? : string[], details? : string, language? : string, customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback<models.ImageAnalysis>): void;
analyzeImageInStream(image: stream.Readable, options: { visualFeatures? : string[], details? : string[], language? : string, customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback<models.ImageAnalysis>): void;


/**
Expand Down Expand Up @@ -1046,7 +1046,7 @@ export default class ComputerVisionClient extends ServiceClient {
*
* @param {object} [options] Optional Parameters.
*
* @param {string} [options.maxCandidates] Maximum number of candidate
* @param {number} [options.maxCandidates] Maximum number of candidate
* descriptions to be returned. The default is 1.
*
* @param {string} [options.language] The desired language for output
Expand All @@ -1064,7 +1064,7 @@ export default class ComputerVisionClient extends ServiceClient {
*
* @reject {Error|ServiceError} - The error object.
*/
describeImageInStreamWithHttpOperationResponse(image: stream.Readable, options?: { maxCandidates? : string, language? : string, customHeaders? : { [headerName: string]: string; } }): Promise<HttpOperationResponse<models.ImageDescription>>;
describeImageInStreamWithHttpOperationResponse(image: stream.Readable, options?: { maxCandidates? : number, language? : string, customHeaders? : { [headerName: string]: string; } }): Promise<HttpOperationResponse<models.ImageDescription>>;

/**
* This operation generates a description of an image in human readable
Expand All @@ -1081,7 +1081,7 @@ export default class ComputerVisionClient extends ServiceClient {
*
* @param {object} [options] Optional Parameters.
*
* @param {string} [options.maxCandidates] Maximum number of candidate
* @param {number} [options.maxCandidates] Maximum number of candidate
* descriptions to be returned. The default is 1.
*
* @param {string} [options.language] The desired language for output
Expand Down Expand Up @@ -1115,9 +1115,9 @@ export default class ComputerVisionClient extends ServiceClient {
*
* {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur.
*/
describeImageInStream(image: stream.Readable, options?: { maxCandidates? : string, language? : string, customHeaders? : { [headerName: string]: string; } }): Promise<models.ImageDescription>;
describeImageInStream(image: stream.Readable, options?: { maxCandidates? : number, language? : string, customHeaders? : { [headerName: string]: string; } }): Promise<models.ImageDescription>;
describeImageInStream(image: stream.Readable, callback: ServiceCallback<models.ImageDescription>): void;
describeImageInStream(image: stream.Readable, options: { maxCandidates? : string, language? : string, customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback<models.ImageDescription>): void;
describeImageInStream(image: stream.Readable, options: { maxCandidates? : number, language? : string, customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback<models.ImageDescription>): void;


/**
Expand Down
53 changes: 30 additions & 23 deletions lib/services/computerVision/lib/computerVisionClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -713,7 +713,7 @@ function _recognizePrintedText(detectOrientation, url, options, callback) {
*
* @param {object} [options] Optional Parameters.
*
* @param {string} [options.maxCandidates] Maximum number of candidate
* @param {number} [options.maxCandidates] Maximum number of candidate
* descriptions to be returned. The default is 1.
*
* @param {string} [options.language] The desired language for output
Expand Down Expand Up @@ -748,15 +748,15 @@ function _describeImage(url, options, callback) {
if (!callback) {
throw new Error('callback cannot be null.');
}
let maxCandidates = (options && options.maxCandidates !== undefined) ? options.maxCandidates : '1';
let maxCandidates = (options && options.maxCandidates !== undefined) ? options.maxCandidates : 1;
let language = (options && options.language !== undefined) ? options.language : 'en';
// Validate
try {
if (this.endpoint === null || this.endpoint === undefined || typeof this.endpoint.valueOf() !== 'string') {
throw new Error('this.endpoint cannot be null or undefined and it must be of type string.');
}
if (maxCandidates !== null && maxCandidates !== undefined && typeof maxCandidates.valueOf() !== 'string') {
throw new Error('maxCandidates must be of type string.');
if (maxCandidates !== null && maxCandidates !== undefined && typeof maxCandidates !== 'number') {
throw new Error('maxCandidates must be of type number.');
}
if (language !== null && language !== undefined && typeof language.valueOf() !== 'string') {
throw new Error('language must be of type string.');
Expand All @@ -779,7 +779,7 @@ function _describeImage(url, options, callback) {
requestUrl = requestUrl.replace('{Endpoint}', this.endpoint);
let queryParameters = [];
if (maxCandidates !== null && maxCandidates !== undefined) {
queryParameters.push('maxCandidates=' + encodeURIComponent(maxCandidates));
queryParameters.push('maxCandidates=' + encodeURIComponent(maxCandidates.toString()));
}
if (language !== null && language !== undefined) {
queryParameters.push('language=' + encodeURIComponent(language));
Expand Down Expand Up @@ -1497,10 +1497,10 @@ function _getTextOperationResult(operationId, options, callback) {
* black&white.Adult - detects if the image is pornographic in nature (depicts
* nudity or a sex act). Sexually suggestive content is also detected.
*
* @param {string} [options.details] A string indicating which domain-specific
* @param {array} [options.details] A string indicating which domain-specific
* details to return. Multiple values should be comma-separated. Valid visual
* feature types include:Celebrities - identifies celebrities if detected in
* the image. Possible values include: 'Celebrities', 'Landmarks'
* the image.
*
* @param {string} [options.language] The desired language for output
* generation. If this parameter is not specified, the default value is
Expand Down Expand Up @@ -1552,8 +1552,15 @@ function _analyzeImageInStream(image, options, callback) {
}
}
}
if (details !== null && details !== undefined && typeof details.valueOf() !== 'string') {
throw new Error('details must be of type string.');
if (Array.isArray(details)) {
for (let i1 = 0; i1 < details.length; i1++) {
if (details[i1]) {
let allowedValues1 = [ 'Celebrities', 'Landmarks' ];
if (!allowedValues1.some( function(item) { return item === details[i1]; })) {
throw new Error(details[i1] + ' is not a valid value. The valid values are: ' + allowedValues1);
}
}
}
}
if (language !== null && language !== undefined && typeof language.valueOf() !== 'string') {
throw new Error('language must be of type string.');
Expand All @@ -1574,7 +1581,7 @@ function _analyzeImageInStream(image, options, callback) {
queryParameters.push('visualFeatures=' + encodeURIComponent(visualFeatures.join(',')));
}
if (details !== null && details !== undefined) {
queryParameters.push('details=' + encodeURIComponent(details));
queryParameters.push('details=' + encodeURIComponent(details.join(',')));
}
if (language !== null && language !== undefined) {
queryParameters.push('language=' + encodeURIComponent(language));
Expand Down Expand Up @@ -1987,7 +1994,7 @@ function _recognizePrintedTextInStream(detectOrientation, image, options, callba
*
* @param {object} [options] Optional Parameters.
*
* @param {string} [options.maxCandidates] Maximum number of candidate
* @param {number} [options.maxCandidates] Maximum number of candidate
* descriptions to be returned. The default is 1.
*
* @param {string} [options.language] The desired language for output
Expand Down Expand Up @@ -2022,15 +2029,15 @@ function _describeImageInStream(image, options, callback) {
if (!callback) {
throw new Error('callback cannot be null.');
}
let maxCandidates = (options && options.maxCandidates !== undefined) ? options.maxCandidates : '1';
let maxCandidates = (options && options.maxCandidates !== undefined) ? options.maxCandidates : 1;
let language = (options && options.language !== undefined) ? options.language : 'en';
// Validate
try {
if (this.endpoint === null || this.endpoint === undefined || typeof this.endpoint.valueOf() !== 'string') {
throw new Error('this.endpoint cannot be null or undefined and it must be of type string.');
}
if (maxCandidates !== null && maxCandidates !== undefined && typeof maxCandidates.valueOf() !== 'string') {
throw new Error('maxCandidates must be of type string.');
if (maxCandidates !== null && maxCandidates !== undefined && typeof maxCandidates !== 'number') {
throw new Error('maxCandidates must be of type number.');
}
if (language !== null && language !== undefined && typeof language.valueOf() !== 'string') {
throw new Error('language must be of type string.');
Expand All @@ -2048,7 +2055,7 @@ function _describeImageInStream(image, options, callback) {
requestUrl = requestUrl.replace('{Endpoint}', this.endpoint);
let queryParameters = [];
if (maxCandidates !== null && maxCandidates !== undefined) {
queryParameters.push('maxCandidates=' + encodeURIComponent(maxCandidates));
queryParameters.push('maxCandidates=' + encodeURIComponent(maxCandidates.toString()));
}
if (language !== null && language !== undefined) {
queryParameters.push('language=' + encodeURIComponent(language));
Expand Down Expand Up @@ -3069,7 +3076,7 @@ class ComputerVisionClient extends ServiceClient {
*
* @param {object} [options] Optional Parameters.
*
* @param {string} [options.maxCandidates] Maximum number of candidate
* @param {number} [options.maxCandidates] Maximum number of candidate
* descriptions to be returned. The default is 1.
*
* @param {string} [options.language] The desired language for output
Expand Down Expand Up @@ -3116,7 +3123,7 @@ class ComputerVisionClient extends ServiceClient {
*
* @param {object} [options] Optional Parameters.
*
* @param {string} [options.maxCandidates] Maximum number of candidate
* @param {number} [options.maxCandidates] Maximum number of candidate
* descriptions to be returned. The default is 1.
*
* @param {string} [options.language] The desired language for output
Expand Down Expand Up @@ -3589,10 +3596,10 @@ class ComputerVisionClient extends ServiceClient {
* black&white.Adult - detects if the image is pornographic in nature (depicts
* nudity or a sex act). Sexually suggestive content is also detected.
*
* @param {string} [options.details] A string indicating which domain-specific
* @param {array} [options.details] A string indicating which domain-specific
* details to return. Multiple values should be comma-separated. Valid visual
* feature types include:Celebrities - identifies celebrities if detected in
* the image. Possible values include: 'Celebrities', 'Landmarks'
* the image.
*
* @param {string} [options.language] The desired language for output
* generation. If this parameter is not specified, the default value is
Expand Down Expand Up @@ -3643,10 +3650,10 @@ class ComputerVisionClient extends ServiceClient {
* black&white.Adult - detects if the image is pornographic in nature (depicts
* nudity or a sex act). Sexually suggestive content is also detected.
*
* @param {string} [options.details] A string indicating which domain-specific
* @param {array} [options.details] A string indicating which domain-specific
* details to return. Multiple values should be comma-separated. Valid visual
* feature types include:Celebrities - identifies celebrities if detected in
* the image. Possible values include: 'Celebrities', 'Landmarks'
* the image.
*
* @param {string} [options.language] The desired language for output
* generation. If this parameter is not specified, the default value is
Expand Down Expand Up @@ -3939,7 +3946,7 @@ class ComputerVisionClient extends ServiceClient {
*
* @param {object} [options] Optional Parameters.
*
* @param {string} [options.maxCandidates] Maximum number of candidate
* @param {number} [options.maxCandidates] Maximum number of candidate
* descriptions to be returned. The default is 1.
*
* @param {string} [options.language] The desired language for output
Expand Down Expand Up @@ -3986,7 +3993,7 @@ class ComputerVisionClient extends ServiceClient {
*
* @param {object} [options] Optional Parameters.
*
* @param {string} [options.maxCandidates] Maximum number of candidate
* @param {number} [options.maxCandidates] Maximum number of candidate
* descriptions to be returned. The default is 1.
*
* @param {string} [options.language] The desired language for output
Expand Down