From a6a72f30605a6b316e92be4dd348181c70cf25dc Mon Sep 17 00:00:00 2001 From: Azure SDK for Python bot Date: Thu, 5 Apr 2018 15:31:26 -0700 Subject: [PATCH 1/3] Generated from a480bbd7a62e78214034b6a9ab11c9bd5c1f9c30 (#2666) Add SSN parameter --- lib/services/contentModerator/LICENSE.txt | 42 ++++---- .../lib/contentModeratorAPIClient.d.ts | 5 +- .../lib/contentModeratorAPIClient.js | 3 + .../lib/models/classification.js | 38 +++++--- .../lib/models/classificationCategory1.js | 54 +++++++++++ .../lib/models/classificationCategory2.js | 54 +++++++++++ .../lib/models/classificationCategory3.js | 54 +++++++++++ .../contentModerator/lib/models/index.d.ts | 96 +++++++++++++++++-- .../contentModerator/lib/models/index.js | 4 + .../contentModerator/lib/models/pII.js | 16 ++++ .../contentModerator/lib/models/sSN.js | 61 ++++++++++++ .../contentModerator/lib/models/screen.js | 16 +++- .../lib/operations/index.d.ts | 24 ++--- .../lib/operations/textModeration.js | 60 +++--------- lib/services/contentModerator/package.json | 32 ++----- 15 files changed, 429 insertions(+), 130 deletions(-) create mode 100644 lib/services/contentModerator/lib/models/classificationCategory1.js create mode 100644 lib/services/contentModerator/lib/models/classificationCategory2.js create mode 100644 lib/services/contentModerator/lib/models/classificationCategory3.js create mode 100644 lib/services/contentModerator/lib/models/sSN.js diff --git a/lib/services/contentModerator/LICENSE.txt b/lib/services/contentModerator/LICENSE.txt index 0313a903d7..5431ba98b9 100644 --- a/lib/services/contentModerator/LICENSE.txt +++ b/lib/services/contentModerator/LICENSE.txt @@ -1,21 +1,21 @@ -The MIT License (MIT) - -Copyright (c) 2017 Microsoft - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. \ No newline at end of file +The MIT License (MIT) + +Copyright (c) 2018 Microsoft + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/lib/services/contentModerator/lib/contentModeratorAPIClient.d.ts b/lib/services/contentModerator/lib/contentModeratorAPIClient.d.ts index 859564471e..3a860ba336 100644 --- a/lib/services/contentModerator/lib/contentModeratorAPIClient.d.ts +++ b/lib/services/contentModerator/lib/contentModeratorAPIClient.d.ts @@ -9,9 +9,10 @@ */ import { ServiceClient, ServiceClientOptions, ServiceClientCredentials } from 'ms-rest'; +import * as models from "./models"; import * as operations from "./operations"; -declare class ContentModeratorAPIClient extends ServiceClient { +export default class ContentModeratorAPIClient extends ServiceClient { /** * @class * Initializes a new instance of the ContentModeratorAPIClient class. @@ -47,4 +48,4 @@ declare class ContentModeratorAPIClient extends ServiceClient { reviews: operations.Reviews; } -export = ContentModeratorAPIClient; +export { ContentModeratorAPIClient, models as ContentModeratorAPIModels }; diff --git a/lib/services/contentModerator/lib/contentModeratorAPIClient.js b/lib/services/contentModerator/lib/contentModeratorAPIClient.js index fc4ff34637..b30f454c60 100644 --- a/lib/services/contentModerator/lib/contentModeratorAPIClient.js +++ b/lib/services/contentModerator/lib/contentModeratorAPIClient.js @@ -65,3 +65,6 @@ class ContentModeratorAPIClient extends ServiceClient { } module.exports = ContentModeratorAPIClient; +module.exports['default'] = ContentModeratorAPIClient; +module.exports.ContentModeratorAPIClient = ContentModeratorAPIClient; +module.exports.ContentModeratorAPIModels = models; diff --git a/lib/services/contentModerator/lib/models/classification.js b/lib/services/contentModerator/lib/models/classification.js index c3643ebb5c..13cc16eabb 100644 --- a/lib/services/contentModerator/lib/models/classification.js +++ b/lib/services/contentModerator/lib/models/classification.js @@ -10,6 +10,8 @@ 'use strict'; +const models = require('./index'); + /** * The classification details of the text. * @@ -17,9 +19,18 @@ class Classification { /** * Create a Classification. - * @member {number} [adultScore] The adult score. - * @member {number} [racyScore] The racy score. - * @member {number} [offensiveScore] The offensive score. + * @member {object} [category1] The category1 score details of the text. Click here for more + * details on category classification. + * @member {number} [category1.score] The category1 score. + * @member {object} [category2] The category2 score details of the text. Click here for more + * details on category classification. + * @member {number} [category2.score] The category2 score. + * @member {object} [category3] The category3 score details of the text. Click here for more + * details on category classification. + * @member {number} [category3.score] The category3 score. * @member {boolean} [reviewRecommended] The review recommended flag. */ constructor() { @@ -39,25 +50,28 @@ class Classification { name: 'Composite', className: 'Classification', modelProperties: { - adultScore: { + category1: { required: false, - serializedName: 'AdultScore', + serializedName: 'Category1', type: { - name: 'Number' + name: 'Composite', + className: 'ClassificationCategory1' } }, - racyScore: { + category2: { required: false, - serializedName: 'RacyScore', + serializedName: 'Category2', type: { - name: 'Number' + name: 'Composite', + className: 'ClassificationCategory2' } }, - offensiveScore: { + category3: { required: false, - serializedName: 'OffensiveScore', + serializedName: 'Category3', type: { - name: 'Number' + name: 'Composite', + className: 'ClassificationCategory3' } }, reviewRecommended: { diff --git a/lib/services/contentModerator/lib/models/classificationCategory1.js b/lib/services/contentModerator/lib/models/classificationCategory1.js new file mode 100644 index 0000000000..8584409ba3 --- /dev/null +++ b/lib/services/contentModerator/lib/models/classificationCategory1.js @@ -0,0 +1,54 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +/** + * The category1 score details of the text. Click here for more details + * on category classification. + * + */ +class ClassificationCategory1 { + /** + * Create a ClassificationCategory1. + * @member {number} [score] The category1 score. + */ + constructor() { + } + + /** + * Defines the metadata of ClassificationCategory1 + * + * @returns {object} metadata of ClassificationCategory1 + * + */ + mapper() { + return { + required: false, + serializedName: 'Classification_Category1', + type: { + name: 'Composite', + className: 'ClassificationCategory1', + modelProperties: { + score: { + required: false, + serializedName: 'Score', + type: { + name: 'Number' + } + } + } + } + }; + } +} + +module.exports = ClassificationCategory1; diff --git a/lib/services/contentModerator/lib/models/classificationCategory2.js b/lib/services/contentModerator/lib/models/classificationCategory2.js new file mode 100644 index 0000000000..721f2e84c3 --- /dev/null +++ b/lib/services/contentModerator/lib/models/classificationCategory2.js @@ -0,0 +1,54 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +/** + * The category2 score details of the text. Click here for more details + * on category classification. + * + */ +class ClassificationCategory2 { + /** + * Create a ClassificationCategory2. + * @member {number} [score] The category2 score. + */ + constructor() { + } + + /** + * Defines the metadata of ClassificationCategory2 + * + * @returns {object} metadata of ClassificationCategory2 + * + */ + mapper() { + return { + required: false, + serializedName: 'Classification_Category2', + type: { + name: 'Composite', + className: 'ClassificationCategory2', + modelProperties: { + score: { + required: false, + serializedName: 'Score', + type: { + name: 'Number' + } + } + } + } + }; + } +} + +module.exports = ClassificationCategory2; diff --git a/lib/services/contentModerator/lib/models/classificationCategory3.js b/lib/services/contentModerator/lib/models/classificationCategory3.js new file mode 100644 index 0000000000..7bd7c477d5 --- /dev/null +++ b/lib/services/contentModerator/lib/models/classificationCategory3.js @@ -0,0 +1,54 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +/** + * The category3 score details of the text. Click here for more details + * on category classification. + * + */ +class ClassificationCategory3 { + /** + * Create a ClassificationCategory3. + * @member {number} [score] The category3 score. + */ + constructor() { + } + + /** + * Defines the metadata of ClassificationCategory3 + * + * @returns {object} metadata of ClassificationCategory3 + * + */ + mapper() { + return { + required: false, + serializedName: 'Classification_Category3', + type: { + name: 'Composite', + className: 'ClassificationCategory3', + modelProperties: { + score: { + required: false, + serializedName: 'Score', + type: { + name: 'Number' + } + } + } + } + }; + } +} + +module.exports = ClassificationCategory3; diff --git a/lib/services/contentModerator/lib/models/index.d.ts b/lib/services/contentModerator/lib/models/index.d.ts index b36762536f..9de671bced 100644 --- a/lib/services/contentModerator/lib/models/index.d.ts +++ b/lib/services/contentModerator/lib/models/index.d.ts @@ -71,21 +71,72 @@ export interface Frames { videoFrames?: Frame[]; } +/** + * @class + * Initializes a new instance of the ClassificationCategory1 class. + * @constructor + * The category1 score details of the text. Click here for more details + * on category classification. + * + * @member {number} [score] The category1 score. + */ +export interface ClassificationCategory1 { + score?: number; +} + +/** + * @class + * Initializes a new instance of the ClassificationCategory2 class. + * @constructor + * The category2 score details of the text. Click here for more details + * on category classification. + * + * @member {number} [score] The category2 score. + */ +export interface ClassificationCategory2 { + score?: number; +} + +/** + * @class + * Initializes a new instance of the ClassificationCategory3 class. + * @constructor + * The category3 score details of the text. Click here for more details + * on category classification. + * + * @member {number} [score] The category3 score. + */ +export interface ClassificationCategory3 { + score?: number; +} + /** * @class * Initializes a new instance of the Classification class. * @constructor * The classification details of the text. * - * @member {number} [adultScore] The adult score. - * @member {number} [racyScore] The racy score. - * @member {number} [offensiveScore] The offensive score. + * @member {object} [category1] The category1 score details of the text. Click here for more details + * on category classification. + * @member {number} [category1.score] The category1 score. + * @member {object} [category2] The category2 score details of the text. Click here for more details + * on category classification. + * @member {number} [category2.score] The category2 score. + * @member {object} [category3] The category3 score details of the text. Click here for more details + * on category classification. + * @member {number} [category3.score] The category3 score. * @member {boolean} [reviewRecommended] The review recommended flag. */ export interface Classification { - adultScore?: number; - racyScore?: number; - offensiveScore?: number; + category1?: ClassificationCategory1; + category2?: ClassificationCategory2; + category3?: ClassificationCategory3; reviewRecommended?: boolean; } @@ -125,6 +176,21 @@ export interface Email { index?: number; } +/** + * @class + * Initializes a new instance of the SSN class. + * @constructor + * Detected SSN details. + * + * @member {string} [text] Detected SSN in the input text content. + * @member {number} [index] Index(Location) of the SSN in the input text + * content. + */ +export interface SSN { + text?: string; + index?: number; +} + /** * @class * Initializes a new instance of the IPA class. @@ -181,12 +247,14 @@ export interface Address { * Personal Identifier Information details. * * @member {array} [email] + * @member {array} [sSN] * @member {array} [iPA] * @member {array} [phone] * @member {array} [address] */ export interface PII { email?: Email[]; + sSN?: SSN[]; iPA?: IPA[]; phone?: Phone[]; address?: Address[]; @@ -223,9 +291,18 @@ export interface DetectedTerms { * @member {string} [autoCorrectedText] The autocorrected text * @member {array} [misrepresentation] The misrepresentation text. * @member {object} [classification] The classification details of the text. - * @member {number} [classification.adultScore] The adult score. - * @member {number} [classification.racyScore] The racy score. - * @member {number} [classification.offensiveScore] The offensive score. + * @member {object} [classification.category1] The category1 score details of + * the text. Click here for + * more details on category classification. + * @member {number} [classification.category1.score] The category1 score. + * @member {object} [classification.category2] The category2 score details of + * the text. Click here for + * more details on category classification. + * @member {number} [classification.category2.score] The category2 score. + * @member {object} [classification.category3] The category3 score details of + * the text. Click here for + * more details on category classification. + * @member {number} [classification.category3.score] The category3 score. * @member {boolean} [classification.reviewRecommended] The review recommended * flag. * @member {object} [status] The evaluate status. @@ -234,6 +311,7 @@ export interface DetectedTerms { * @member {string} [status.exception] Exception status. * @member {object} [pII] Personal Identifier Information details. * @member {array} [pII.email] + * @member {array} [pII.sSN] * @member {array} [pII.iPA] * @member {array} [pII.phone] * @member {array} [pII.address] diff --git a/lib/services/contentModerator/lib/models/index.js b/lib/services/contentModerator/lib/models/index.js index feacb8f3cd..58ea462c62 100644 --- a/lib/services/contentModerator/lib/models/index.js +++ b/lib/services/contentModerator/lib/models/index.js @@ -18,9 +18,13 @@ exports.KeyValuePair = require('./keyValuePair'); exports.Tag = require('./tag'); exports.Frame = require('./frame'); exports.Frames = require('./frames'); +exports.ClassificationCategory1 = require('./classificationCategory1'); +exports.ClassificationCategory2 = require('./classificationCategory2'); +exports.ClassificationCategory3 = require('./classificationCategory3'); exports.Classification = require('./classification'); exports.Status = require('./status'); exports.Email = require('./email'); +exports.SSN = require('./sSN'); exports.IPA = require('./iPA'); exports.Phone = require('./phone'); exports.Address = require('./address'); diff --git a/lib/services/contentModerator/lib/models/pII.js b/lib/services/contentModerator/lib/models/pII.js index 9a7e0d936e..1636e48ab9 100644 --- a/lib/services/contentModerator/lib/models/pII.js +++ b/lib/services/contentModerator/lib/models/pII.js @@ -20,6 +20,7 @@ class PII { /** * Create a PII. * @member {array} [email] + * @member {array} [sSN] * @member {array} [iPA] * @member {array} [phone] * @member {array} [address] @@ -56,6 +57,21 @@ class PII { } } }, + sSN: { + required: false, + serializedName: 'SSN', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'SSNElementType', + type: { + name: 'Composite', + className: 'SSN' + } + } + } + }, iPA: { required: false, serializedName: 'IPA', diff --git a/lib/services/contentModerator/lib/models/sSN.js b/lib/services/contentModerator/lib/models/sSN.js new file mode 100644 index 0000000000..f3bd39350b --- /dev/null +++ b/lib/services/contentModerator/lib/models/sSN.js @@ -0,0 +1,61 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +/** + * Detected SSN details. + * + */ +class SSN { + /** + * Create a SSN. + * @member {string} [text] Detected SSN in the input text content. + * @member {number} [index] Index(Location) of the SSN in the input text + * content. + */ + constructor() { + } + + /** + * Defines the metadata of SSN + * + * @returns {object} metadata of SSN + * + */ + mapper() { + return { + required: false, + serializedName: 'SSN', + type: { + name: 'Composite', + className: 'SSN', + modelProperties: { + text: { + required: false, + serializedName: 'Text', + type: { + name: 'String' + } + }, + index: { + required: false, + serializedName: 'Index', + type: { + name: 'Number' + } + } + } + } + }; + } +} + +module.exports = SSN; diff --git a/lib/services/contentModerator/lib/models/screen.js b/lib/services/contentModerator/lib/models/screen.js index 1b130a0083..9515f90a3d 100644 --- a/lib/services/contentModerator/lib/models/screen.js +++ b/lib/services/contentModerator/lib/models/screen.js @@ -24,9 +24,18 @@ class Screen { * @member {string} [autoCorrectedText] The autocorrected text * @member {array} [misrepresentation] The misrepresentation text. * @member {object} [classification] The classification details of the text. - * @member {number} [classification.adultScore] The adult score. - * @member {number} [classification.racyScore] The racy score. - * @member {number} [classification.offensiveScore] The offensive score. + * @member {object} [classification.category1] The category1 score details of + * the text. Click here + * for more details on category classification. + * @member {number} [classification.category1.score] The category1 score. + * @member {object} [classification.category2] The category2 score details of + * the text. Click here + * for more details on category classification. + * @member {number} [classification.category2.score] The category2 score. + * @member {object} [classification.category3] The category3 score details of + * the text. Click here + * for more details on category classification. + * @member {number} [classification.category3.score] The category3 score. * @member {boolean} [classification.reviewRecommended] The review * recommended flag. * @member {object} [status] The evaluate status. @@ -35,6 +44,7 @@ class Screen { * @member {string} [status.exception] Exception status. * @member {object} [pII] Personal Identifier Information details. * @member {array} [pII.email] + * @member {array} [pII.sSN] * @member {array} [pII.iPA] * @member {array} [pII.phone] * @member {array} [pII.address] diff --git a/lib/services/contentModerator/lib/operations/index.d.ts b/lib/services/contentModerator/lib/operations/index.d.ts index ffeb6dc06a..f4ca2edfd1 100644 --- a/lib/services/contentModerator/lib/operations/index.d.ts +++ b/lib/services/contentModerator/lib/operations/index.d.ts @@ -926,7 +926,7 @@ export interface TextModeration { * @param {string} textContentType The content type. Possible values include: * 'text/plain', 'text/html', 'text/xml', 'text/markdown' * - * @param {string} textContent Content to screen. + * @param {object} textContent Content to screen. * * @param {object} [options] Optional Parameters. * @@ -947,7 +947,7 @@ export interface TextModeration { * * @reject {Error|ServiceError} - The error object. */ - screenTextWithHttpOperationResponse(language: string, textContentType: string, textContent: string, options?: { autocorrect? : boolean, pII? : boolean, listId? : string, classify? : boolean, customHeaders? : { [headerName: string]: string; } }): Promise>; + screenTextWithHttpOperationResponse(language: string, textContentType: string, textContent: stream.Readable, options?: { autocorrect? : boolean, pII? : boolean, listId? : string, classify? : boolean, customHeaders? : { [headerName: string]: string; } }): Promise>; /** * @summary Detect profanity and match against custom and shared blacklists @@ -960,7 +960,7 @@ export interface TextModeration { * @param {string} textContentType The content type. Possible values include: * 'text/plain', 'text/html', 'text/xml', 'text/markdown' * - * @param {string} textContent Content to screen. + * @param {object} textContent Content to screen. * * @param {object} [options] Optional Parameters. * @@ -997,9 +997,9 @@ export interface TextModeration { * * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. */ - screenText(language: string, textContentType: string, textContent: string, options?: { autocorrect? : boolean, pII? : boolean, listId? : string, classify? : boolean, customHeaders? : { [headerName: string]: string; } }): Promise; - screenText(language: string, textContentType: string, textContent: string, callback: ServiceCallback): void; - screenText(language: string, textContentType: string, textContent: string, options: { autocorrect? : boolean, pII? : boolean, listId? : string, classify? : boolean, customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + screenText(language: string, textContentType: string, textContent: stream.Readable, options?: { autocorrect? : boolean, pII? : boolean, listId? : string, classify? : boolean, customHeaders? : { [headerName: string]: string; } }): Promise; + screenText(language: string, textContentType: string, textContent: stream.Readable, callback: ServiceCallback): void; + screenText(language: string, textContentType: string, textContent: stream.Readable, options: { autocorrect? : boolean, pII? : boolean, listId? : string, classify? : boolean, customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; /** @@ -1011,7 +1011,7 @@ export interface TextModeration { * @param {string} textContentType The content type. Possible values include: * 'text/plain', 'text/html', 'text/xml', 'text/markdown' * - * @param {string} textContent Content to screen. + * @param {object} textContent Content to screen. * * @param {object} [options] Optional Parameters. * @@ -1024,7 +1024,7 @@ export interface TextModeration { * * @reject {Error|ServiceError} - The error object. */ - detectLanguageWithHttpOperationResponse(textContentType: string, textContent: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + detectLanguageWithHttpOperationResponse(textContentType: string, textContent: stream.Readable, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; /** * This operation will detect the language of given input content. Returns the @@ -1035,7 +1035,7 @@ export interface TextModeration { * @param {string} textContentType The content type. Possible values include: * 'text/plain', 'text/html', 'text/xml', 'text/markdown' * - * @param {string} textContent Content to screen. + * @param {object} textContent Content to screen. * * @param {object} [options] Optional Parameters. * @@ -1064,9 +1064,9 @@ export interface TextModeration { * * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. */ - detectLanguage(textContentType: string, textContent: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; - detectLanguage(textContentType: string, textContent: string, callback: ServiceCallback): void; - detectLanguage(textContentType: string, textContent: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + detectLanguage(textContentType: string, textContent: stream.Readable, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + detectLanguage(textContentType: string, textContent: stream.Readable, callback: ServiceCallback): void; + detectLanguage(textContentType: string, textContent: stream.Readable, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; } /** diff --git a/lib/services/contentModerator/lib/operations/textModeration.js b/lib/services/contentModerator/lib/operations/textModeration.js index ffa5afab78..7e9dcd86ce 100644 --- a/lib/services/contentModerator/lib/operations/textModeration.js +++ b/lib/services/contentModerator/lib/operations/textModeration.js @@ -24,7 +24,7 @@ const WebResource = msRest.WebResource; * @param {string} textContentType The content type. Possible values include: * 'text/plain', 'text/html', 'text/xml', 'text/markdown' * - * @param {string} textContent Content to screen. + * @param {object} textContent Content to screen. * * @param {object} [options] Optional Parameters. * @@ -89,8 +89,8 @@ function _screenText(language, textContentType, textContent, options, callback) if (textContentType === null || textContentType === undefined || typeof textContentType.valueOf() !== 'string') { throw new Error('textContentType cannot be null or undefined and it must be of type string.'); } - if (textContent === null || textContent === undefined || typeof textContent.valueOf() !== 'string') { - throw new Error('textContent cannot be null or undefined and it must be of type string.'); + if (textContent === null || textContent === undefined) { + throw new Error('textContent cannot be null or undefined and it must be of type object.'); } } catch (error) { return callback(error); @@ -136,25 +136,7 @@ function _screenText(language, textContentType, textContent, options, callback) } } // Serialize Request - let requestContent = null; - let requestModel = null; - try { - if (textContent !== null && textContent !== undefined) { - let requestModelMapper = { - required: true, - serializedName: 'Text Content', - type: { - name: 'String' - } - }; - requestModel = client.serialize(requestModelMapper, textContent, 'textContent'); - requestContent = JSON.stringify(requestModel); - } - } catch (error) { - let serializationError = new Error(`Error "${error.message}" occurred in serializing the ` + - `payload - ${JSON.stringify(textContent, null, 2)}.`); - return callback(serializationError); - } + let requestContent = textContent; httpRequest.body = requestContent; // Send Request return client.pipeline(httpRequest, (err, response, responseBody) => { @@ -222,7 +204,7 @@ function _screenText(language, textContentType, textContent, options, callback) * @param {string} textContentType The content type. Possible values include: * 'text/plain', 'text/html', 'text/xml', 'text/markdown' * - * @param {string} textContent Content to screen. + * @param {object} textContent Content to screen. * * @param {object} [options] Optional Parameters. * @@ -260,8 +242,8 @@ function _detectLanguage(textContentType, textContent, options, callback) { if (textContentType === null || textContentType === undefined || typeof textContentType.valueOf() !== 'string') { throw new Error('textContentType cannot be null or undefined and it must be of type string.'); } - if (textContent === null || textContent === undefined || typeof textContent.valueOf() !== 'string') { - throw new Error('textContent cannot be null or undefined and it must be of type string.'); + if (textContent === null || textContent === undefined) { + throw new Error('textContent cannot be null or undefined and it must be of type object.'); } } catch (error) { return callback(error); @@ -290,25 +272,7 @@ function _detectLanguage(textContentType, textContent, options, callback) { } } // Serialize Request - let requestContent = null; - let requestModel = null; - try { - if (textContent !== null && textContent !== undefined) { - let requestModelMapper = { - required: true, - serializedName: 'Text Content', - type: { - name: 'String' - } - }; - requestModel = client.serialize(requestModelMapper, textContent, 'textContent'); - requestContent = JSON.stringify(requestModel); - } - } catch (error) { - let serializationError = new Error(`Error "${error.message}" occurred in serializing the ` + - `payload - ${JSON.stringify(textContent, null, 2)}.`); - return callback(serializationError); - } + let requestContent = textContent; httpRequest.body = requestContent; // Send Request return client.pipeline(httpRequest, (err, response, responseBody) => { @@ -390,7 +354,7 @@ class TextModeration { * @param {string} textContentType The content type. Possible values include: * 'text/plain', 'text/html', 'text/xml', 'text/markdown' * - * @param {string} textContent Content to screen. + * @param {object} textContent Content to screen. * * @param {object} [options] Optional Parameters. * @@ -436,7 +400,7 @@ class TextModeration { * @param {string} textContentType The content type. Possible values include: * 'text/plain', 'text/html', 'text/xml', 'text/markdown' * - * @param {string} textContent Content to screen. + * @param {object} textContent Content to screen. * * @param {object} [options] Optional Parameters. * @@ -502,7 +466,7 @@ class TextModeration { * @param {string} textContentType The content type. Possible values include: * 'text/plain', 'text/html', 'text/xml', 'text/markdown' * - * @param {string} textContent Content to screen. + * @param {object} textContent Content to screen. * * @param {object} [options] Optional Parameters. * @@ -538,7 +502,7 @@ class TextModeration { * @param {string} textContentType The content type. Possible values include: * 'text/plain', 'text/html', 'text/xml', 'text/markdown' * - * @param {string} textContent Content to screen. + * @param {object} textContent Content to screen. * * @param {object} [options] Optional Parameters. * diff --git a/lib/services/contentModerator/package.json b/lib/services/contentModerator/package.json index 24078388fe..dc0072b0fa 100644 --- a/lib/services/contentModerator/package.json +++ b/lib/services/contentModerator/package.json @@ -1,35 +1,21 @@ { "name": "azure-cognitiveservices-contentmoderator", "author": "Microsoft Corporation", - "contributors": [ - "Xu, Willie " - ], + "description": "ContentModeratorAPIClient Library with typescript type definitions for node", "version": "1.0.0-preview", - "description": "Microsoft Azure Cognitive Services Content Moderator API Client Library for Node.js", - "tags": [ - "azure", - "sdk" - ], - "keywords": [ - "node", - "azure" - ], - "main": "./lib/contentModeratorAPIClient.js", - "types": "./lib/contentModeratorAPIClient.d.ts", - "license": "MIT", "dependencies": { - "ms-rest": "^2.2.5", - "ms-rest-azure": "^2.5.0" + "ms-rest": "^2.3.2" }, - "homepage": "http://github.com/Azure/azure-sdk-for-node", + "keywords": [ "node", "azure" ], + "license": "MIT", + "main": "./lib/contentModeratorAPIClient.js", + "types": "./lib/contentModeratorAPIClient.d.ts", + "homepage": "http://github.com/azure/azure-sdk-for-node", "repository": { "type": "git", - "url": "git@github.com:Azure/azure-sdk-for-node.git" + "url": "https://github.com/azure/azure-sdk-for-node.git" }, "bugs": { "url": "http://github.com/Azure/azure-sdk-for-node/issues" - }, - "scripts": { - "test": "npm -s run-script jshint" } -} \ No newline at end of file +} From d0d7e6e73bccb4e12552425af960ec2e654986cb Mon Sep 17 00:00:00 2001 From: Azure SDK for Python bot Date: Mon, 16 Apr 2018 17:54:12 -0700 Subject: [PATCH 2/3] Generated from f03560745b3d5ce46009cb8e9897bf4d6f397bf9 (#2747) Set language non-required parameter --- .../lib/operations/index.d.ts | 16 ++++----- .../lib/operations/textModeration.js | 33 ++++++++++--------- 2 files changed, 26 insertions(+), 23 deletions(-) diff --git a/lib/services/contentModerator/lib/operations/index.d.ts b/lib/services/contentModerator/lib/operations/index.d.ts index f4ca2edfd1..2fbb11143f 100644 --- a/lib/services/contentModerator/lib/operations/index.d.ts +++ b/lib/services/contentModerator/lib/operations/index.d.ts @@ -921,8 +921,6 @@ export interface TextModeration { * Detects profanity in more than 100 languages and match against custom and * shared blacklists. * - * @param {string} language Language of the terms. - * * @param {string} textContentType The content type. Possible values include: * 'text/plain', 'text/html', 'text/xml', 'text/markdown' * @@ -930,6 +928,8 @@ export interface TextModeration { * * @param {object} [options] Optional Parameters. * + * @param {string} [options.language] Language of the text. + * * @param {boolean} [options.autocorrect] Autocorrect text. * * @param {boolean} [options.pII] Detect personal identifiable information. @@ -947,7 +947,7 @@ export interface TextModeration { * * @reject {Error|ServiceError} - The error object. */ - screenTextWithHttpOperationResponse(language: string, textContentType: string, textContent: stream.Readable, options?: { autocorrect? : boolean, pII? : boolean, listId? : string, classify? : boolean, customHeaders? : { [headerName: string]: string; } }): Promise>; + screenTextWithHttpOperationResponse(textContentType: string, textContent: stream.Readable, options?: { language? : string, autocorrect? : boolean, pII? : boolean, listId? : string, classify? : boolean, customHeaders? : { [headerName: string]: string; } }): Promise>; /** * @summary Detect profanity and match against custom and shared blacklists @@ -955,8 +955,6 @@ export interface TextModeration { * Detects profanity in more than 100 languages and match against custom and * shared blacklists. * - * @param {string} language Language of the terms. - * * @param {string} textContentType The content type. Possible values include: * 'text/plain', 'text/html', 'text/xml', 'text/markdown' * @@ -964,6 +962,8 @@ export interface TextModeration { * * @param {object} [options] Optional Parameters. * + * @param {string} [options.language] Language of the text. + * * @param {boolean} [options.autocorrect] Autocorrect text. * * @param {boolean} [options.pII] Detect personal identifiable information. @@ -997,9 +997,9 @@ export interface TextModeration { * * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. */ - screenText(language: string, textContentType: string, textContent: stream.Readable, options?: { autocorrect? : boolean, pII? : boolean, listId? : string, classify? : boolean, customHeaders? : { [headerName: string]: string; } }): Promise; - screenText(language: string, textContentType: string, textContent: stream.Readable, callback: ServiceCallback): void; - screenText(language: string, textContentType: string, textContent: stream.Readable, options: { autocorrect? : boolean, pII? : boolean, listId? : string, classify? : boolean, customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + screenText(textContentType: string, textContent: stream.Readable, options?: { language? : string, autocorrect? : boolean, pII? : boolean, listId? : string, classify? : boolean, customHeaders? : { [headerName: string]: string; } }): Promise; + screenText(textContentType: string, textContent: stream.Readable, callback: ServiceCallback): void; + screenText(textContentType: string, textContent: stream.Readable, options: { language? : string, autocorrect? : boolean, pII? : boolean, listId? : string, classify? : boolean, customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; /** diff --git a/lib/services/contentModerator/lib/operations/textModeration.js b/lib/services/contentModerator/lib/operations/textModeration.js index 7e9dcd86ce..7c1f831658 100644 --- a/lib/services/contentModerator/lib/operations/textModeration.js +++ b/lib/services/contentModerator/lib/operations/textModeration.js @@ -19,8 +19,6 @@ const WebResource = msRest.WebResource; * Detects profanity in more than 100 languages and match against custom and * shared blacklists. * - * @param {string} language Language of the terms. - * * @param {string} textContentType The content type. Possible values include: * 'text/plain', 'text/html', 'text/xml', 'text/markdown' * @@ -28,6 +26,8 @@ const WebResource = msRest.WebResource; * * @param {object} [options] Optional Parameters. * + * @param {string} [options.language] Language of the text. + * * @param {boolean} [options.autocorrect] Autocorrect text. * * @param {boolean} [options.pII] Detect personal identifiable information. @@ -52,7 +52,7 @@ const WebResource = msRest.WebResource; * * {stream} [response] - The HTTP Response stream if an error did not occur. */ -function _screenText(language, textContentType, textContent, options, callback) { +function _screenText(textContentType, textContent, options, callback) { /* jshint validthis: true */ let client = this.client; if(!callback && typeof options === 'function') { @@ -62,6 +62,7 @@ function _screenText(language, textContentType, textContent, options, callback) if (!callback) { throw new Error('callback cannot be null.'); } + let language = (options && options.language !== undefined) ? options.language : undefined; let autocorrect = (options && options.autocorrect !== undefined) ? options.autocorrect : false; let pII = (options && options.pII !== undefined) ? options.pII : false; let listId = (options && options.listId !== undefined) ? options.listId : undefined; @@ -71,8 +72,8 @@ function _screenText(language, textContentType, textContent, options, callback) if (this.client.baseUrl === null || this.client.baseUrl === undefined || typeof this.client.baseUrl.valueOf() !== 'string') { throw new Error('this.client.baseUrl cannot be null or undefined and it must be of type string.'); } - if (language === null || language === undefined || typeof language.valueOf() !== 'string') { - throw new Error('language cannot be null or undefined and it must be of type string.'); + if (language !== null && language !== undefined && typeof language.valueOf() !== 'string') { + throw new Error('language must be of type string.'); } if (autocorrect !== null && autocorrect !== undefined && typeof autocorrect !== 'boolean') { throw new Error('autocorrect must be of type boolean.'); @@ -101,7 +102,9 @@ function _screenText(language, textContentType, textContent, options, callback) let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'contentmoderator/moderate/v1.0/ProcessText/Screen/'; requestUrl = requestUrl.replace('{baseUrl}', this.client.baseUrl); let queryParameters = []; - queryParameters.push('language=' + encodeURIComponent(language)); + if (language !== null && language !== undefined) { + queryParameters.push('language=' + encodeURIComponent(language)); + } if (autocorrect !== null && autocorrect !== undefined) { queryParameters.push('autocorrect=' + encodeURIComponent(autocorrect.toString())); } @@ -349,8 +352,6 @@ class TextModeration { * Detects profanity in more than 100 languages and match against custom and * shared blacklists. * - * @param {string} language Language of the terms. - * * @param {string} textContentType The content type. Possible values include: * 'text/plain', 'text/html', 'text/xml', 'text/markdown' * @@ -358,6 +359,8 @@ class TextModeration { * * @param {object} [options] Optional Parameters. * + * @param {string} [options.language] Language of the text. + * * @param {boolean} [options.autocorrect] Autocorrect text. * * @param {boolean} [options.pII] Detect personal identifiable information. @@ -375,11 +378,11 @@ class TextModeration { * * @reject {Error} - The error object. */ - screenTextWithHttpOperationResponse(language, textContentType, textContent, options) { + screenTextWithHttpOperationResponse(textContentType, textContent, options) { let client = this.client; let self = this; return new Promise((resolve, reject) => { - self._screenText(language, textContentType, textContent, options, (err, result, request, response) => { + self._screenText(textContentType, textContent, options, (err, result, request, response) => { let httpOperationResponse = new msRest.HttpOperationResponse(request, response); httpOperationResponse.body = result; if (err) { reject(err); } @@ -395,8 +398,6 @@ class TextModeration { * Detects profanity in more than 100 languages and match against custom and * shared blacklists. * - * @param {string} language Language of the terms. - * * @param {string} textContentType The content type. Possible values include: * 'text/plain', 'text/html', 'text/xml', 'text/markdown' * @@ -404,6 +405,8 @@ class TextModeration { * * @param {object} [options] Optional Parameters. * + * @param {string} [options.language] Language of the text. + * * @param {boolean} [options.autocorrect] Autocorrect text. * * @param {boolean} [options.pII] Detect personal identifiable information. @@ -437,7 +440,7 @@ class TextModeration { * * {stream} [response] - The HTTP Response stream if an error did not occur. */ - screenText(language, textContentType, textContent, options, optionalCallback) { + screenText(textContentType, textContent, options, optionalCallback) { let client = this.client; let self = this; if (!optionalCallback && typeof options === 'function') { @@ -446,14 +449,14 @@ class TextModeration { } if (!optionalCallback) { return new Promise((resolve, reject) => { - self._screenText(language, textContentType, textContent, options, (err, result, request, response) => { + self._screenText(textContentType, textContent, options, (err, result, request, response) => { if (err) { reject(err); } else { resolve(result); } return; }); }); } else { - return self._screenText(language, textContentType, textContent, options, optionalCallback); + return self._screenText(textContentType, textContent, options, optionalCallback); } } From edcf358164ceea0d1f96af88cd6f85989e8cd8a3 Mon Sep 17 00:00:00 2001 From: Dan Schulte Date: Mon, 30 Jul 2018 14:57:26 -0700 Subject: [PATCH 3/3] Remove language argument from contentmoderator test recording --- ...ontent_Moderator_Screen_Text_should_detect_profanity.nock.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/recordings/contentmoderator-tests/Content_Moderator_Screen_Text_should_detect_profanity.nock.js b/test/recordings/contentmoderator-tests/Content_Moderator_Screen_Text_should_detect_profanity.nock.js index 4ec9634dce..982a4afcda 100644 --- a/test/recordings/contentmoderator-tests/Content_Moderator_Screen_Text_should_detect_profanity.nock.js +++ b/test/recordings/contentmoderator-tests/Content_Moderator_Screen_Text_should_detect_profanity.nock.js @@ -9,7 +9,7 @@ exports.scopes = [[function (nock) { var result = nock('https://westus.api.cognitive.microsoft.com:443') .filteringRequestBody(function (path) { return '*';}) -.post('/contentmoderator/moderate/v1.0/ProcessText/Screen/?language=eng&autocorrect=false&PII=false&classify=false', '*') +.post('/contentmoderator/moderate/v1.0/ProcessText/Screen/?autocorrect=false&PII=false&classify=false', '*') .reply(200, "{\"OriginalText\":\"\\\"Is this a crap email abcdef@abcd.com, phone:\\\\n 6657789887, IP: 255.255.255.255, 1 Microsoft Way, Redmond, WA 98052\\\"\",\"NormalizedText\":\"\\\" Is this a crap email abcdef@ abcd. com, phone: \\\\ n 6657789887, IP: 255. 255. 255. 255, 1 Microsoft Way, Redmond, WA 98052\\\"\",\"Misrepresentation\":null,\"Language\":\"eng\",\"Terms\":[{\"Index\":11,\"OriginalIndex\":11,\"ListId\":0,\"Term\":\"crap\"}],\"Status\":{\"Code\":3000,\"Description\":\"OK\",\"Exception\":null},\"TrackingId\":\"f090117e-5a83-43fb-97a8-dbe58b9d4703\"}", { 'cache-control': 'no-cache', pragma: 'no-cache', 'content-length': '512',