From faafaed638e493a16826688556aec53f93648318 Mon Sep 17 00:00:00 2001 From: Azure SDK for Python bot Date: Tue, 31 Jul 2018 04:58:19 +0000 Subject: [PATCH 1/5] Generated from 9b4c21a58071bdaf26a5ced0fa4a283077617af1 Nit fix documentation. --- lib/services/face/lib/faceClient.d.ts | 4 + lib/services/face/lib/faceClient.js | 4 + lib/services/face/lib/models/accessory.js | 2 + lib/services/face/lib/models/blur.js | 2 + lib/services/face/lib/models/emotion.js | 8 + lib/services/face/lib/models/exposure.js | 2 + lib/services/face/lib/models/facialHair.js | 3 + .../face/lib/models/findSimilarRequest.js | 24 +- lib/services/face/lib/models/hair.js | 2 + lib/services/face/lib/models/hairColor.js | 2 + lib/services/face/lib/models/headPose.js | 3 + .../face/lib/models/identifyRequest.js | 42 +- lib/services/face/lib/models/index.d.ts | 106 +- lib/services/face/lib/models/index.js | 4 +- lib/services/face/lib/models/largeFaceList.js | 81 + .../face/lib/models/largePersonGroup.js | 81 + lib/services/face/lib/models/makeup.js | 2 + .../lib/models/nameAndUserDataContract.js | 2 +- lib/services/face/lib/models/noise.js | 2 + lib/services/face/lib/models/occlusion.js | 3 + lib/services/face/lib/models/personGroup.js | 3 +- .../face/lib/models/trainingStatus.js | 25 +- .../face/lib/models/updateFaceRequest.js | 56 + .../lib/models/verifyFaceToFaceRequest.js | 2 +- .../lib/models/verifyFaceToPersonRequest.js | 33 +- lib/services/face/lib/operations/face.js | 264 +- lib/services/face/lib/operations/index.d.ts | 2164 ++++++++++++- lib/services/face/lib/operations/index.js | 4 + .../face/lib/operations/largeFaceListFace.js | 305 ++ .../lib/operations/largeFaceListOperations.js | 2873 +++++++++++++++++ .../operations/largePersonGroupOperations.js | 1648 ++++++++++ .../lib/operations/largePersonGroupPerson.js | 2646 +++++++++++++++ .../lib/operations/personGroupOperations.js | 12 +- .../face/lib/operations/personGroupPerson.js | 28 +- lib/services/face/package.json | 4 +- 35 files changed, 10239 insertions(+), 207 deletions(-) create mode 100644 lib/services/face/lib/models/largeFaceList.js create mode 100644 lib/services/face/lib/models/largePersonGroup.js create mode 100644 lib/services/face/lib/models/updateFaceRequest.js create mode 100644 lib/services/face/lib/operations/largeFaceListFace.js create mode 100644 lib/services/face/lib/operations/largeFaceListOperations.js create mode 100644 lib/services/face/lib/operations/largePersonGroupOperations.js create mode 100644 lib/services/face/lib/operations/largePersonGroupPerson.js diff --git a/lib/services/face/lib/faceClient.d.ts b/lib/services/face/lib/faceClient.d.ts index 164e434ef7..66aa99bcac 100644 --- a/lib/services/face/lib/faceClient.d.ts +++ b/lib/services/face/lib/faceClient.d.ts @@ -43,6 +43,10 @@ export default class FaceClient extends ServiceClient { personGroupPerson: operations.PersonGroupPerson; personGroupOperations: operations.PersonGroupOperations; faceListOperations: operations.FaceListOperations; + largePersonGroupPerson: operations.LargePersonGroupPerson; + largePersonGroupOperations: operations.LargePersonGroupOperations; + largeFaceListOperations: operations.LargeFaceListOperations; + largeFaceListFace: operations.LargeFaceListFace; } export { FaceClient, models as FaceModels }; diff --git a/lib/services/face/lib/faceClient.js b/lib/services/face/lib/faceClient.js index 776554f63f..b32879c45e 100644 --- a/lib/services/face/lib/faceClient.js +++ b/lib/services/face/lib/faceClient.js @@ -55,6 +55,10 @@ class FaceClient extends ServiceClient { this.personGroupPerson = new operations.PersonGroupPerson(this); this.personGroupOperations = new operations.PersonGroupOperations(this); this.faceListOperations = new operations.FaceListOperations(this); + this.largePersonGroupPerson = new operations.LargePersonGroupPerson(this); + this.largePersonGroupOperations = new operations.LargePersonGroupOperations(this); + this.largeFaceListOperations = new operations.LargeFaceListOperations(this); + this.largeFaceListFace = new operations.LargeFaceListFace(this); this.models = models; msRest.addSerializationMixin(this); } diff --git a/lib/services/face/lib/models/accessory.js b/lib/services/face/lib/models/accessory.js index 987d4b86c7..88fd3b5b23 100644 --- a/lib/services/face/lib/models/accessory.js +++ b/lib/services/face/lib/models/accessory.js @@ -40,6 +40,7 @@ class Accessory { modelProperties: { type: { required: false, + nullable: false, serializedName: 'type', type: { name: 'Enum', @@ -48,6 +49,7 @@ class Accessory { }, confidence: { required: false, + nullable: false, serializedName: 'confidence', type: { name: 'Number' diff --git a/lib/services/face/lib/models/blur.js b/lib/services/face/lib/models/blur.js index 76b653cbf8..3ad28ffa01 100644 --- a/lib/services/face/lib/models/blur.js +++ b/lib/services/face/lib/models/blur.js @@ -41,6 +41,7 @@ class Blur { modelProperties: { blurLevel: { required: false, + nullable: false, serializedName: 'blurLevel', type: { name: 'Enum', @@ -49,6 +50,7 @@ class Blur { }, value: { required: false, + nullable: false, serializedName: 'value', type: { name: 'Number' diff --git a/lib/services/face/lib/models/emotion.js b/lib/services/face/lib/models/emotion.js index e5c6d7fdf0..db7508699c 100644 --- a/lib/services/face/lib/models/emotion.js +++ b/lib/services/face/lib/models/emotion.js @@ -46,6 +46,7 @@ class Emotion { modelProperties: { anger: { required: false, + nullable: false, serializedName: 'anger', type: { name: 'Number' @@ -53,6 +54,7 @@ class Emotion { }, contempt: { required: false, + nullable: false, serializedName: 'contempt', type: { name: 'Number' @@ -60,6 +62,7 @@ class Emotion { }, disgust: { required: false, + nullable: false, serializedName: 'disgust', type: { name: 'Number' @@ -67,6 +70,7 @@ class Emotion { }, fear: { required: false, + nullable: false, serializedName: 'fear', type: { name: 'Number' @@ -74,6 +78,7 @@ class Emotion { }, happiness: { required: false, + nullable: false, serializedName: 'happiness', type: { name: 'Number' @@ -81,6 +86,7 @@ class Emotion { }, neutral: { required: false, + nullable: false, serializedName: 'neutral', type: { name: 'Number' @@ -88,6 +94,7 @@ class Emotion { }, sadness: { required: false, + nullable: false, serializedName: 'sadness', type: { name: 'Number' @@ -95,6 +102,7 @@ class Emotion { }, surprise: { required: false, + nullable: false, serializedName: 'surprise', type: { name: 'Number' diff --git a/lib/services/face/lib/models/exposure.js b/lib/services/face/lib/models/exposure.js index 8a29189488..896eafa411 100644 --- a/lib/services/face/lib/models/exposure.js +++ b/lib/services/face/lib/models/exposure.js @@ -43,6 +43,7 @@ class Exposure { modelProperties: { exposureLevel: { required: false, + nullable: false, serializedName: 'exposureLevel', type: { name: 'Enum', @@ -51,6 +52,7 @@ class Exposure { }, value: { required: false, + nullable: false, serializedName: 'value', type: { name: 'Number' diff --git a/lib/services/face/lib/models/facialHair.js b/lib/services/face/lib/models/facialHair.js index c5916bc543..955d990cfa 100644 --- a/lib/services/face/lib/models/facialHair.js +++ b/lib/services/face/lib/models/facialHair.js @@ -40,6 +40,7 @@ class FacialHair { modelProperties: { moustache: { required: false, + nullable: false, serializedName: 'moustache', type: { name: 'Number' @@ -47,6 +48,7 @@ class FacialHair { }, beard: { required: false, + nullable: false, serializedName: 'beard', type: { name: 'Number' @@ -54,6 +56,7 @@ class FacialHair { }, sideburns: { required: false, + nullable: false, serializedName: 'sideburns', type: { name: 'Number' diff --git a/lib/services/face/lib/models/findSimilarRequest.js b/lib/services/face/lib/models/findSimilarRequest.js index 91d6bf1b17..ac1f60d896 100644 --- a/lib/services/face/lib/models/findSimilarRequest.js +++ b/lib/services/face/lib/models/findSimilarRequest.js @@ -23,10 +23,18 @@ class FindSimilarRequest { * @member {string} [faceListId] An existing user-specified unique candidate * face list, created in Face List - Create a Face List. Face list contains a * set of persistedFaceIds which are persisted and will never expire. - * Parameter faceListId and faceIds should not be provided at the same time + * Parameter faceListId, largeFaceListId and faceIds should not be provided + * at the same time。 + * @member {string} [largeFaceListId] An existing user-specified unique + * candidate large face list, created in LargeFaceList - Create. Large face + * list contains a set of persistedFaceIds which are persisted and will never + * expire. Parameter faceListId, largeFaceListId and faceIds should not be + * provided at the same time. * @member {array} [faceIds] An array of candidate faceIds. All of them are * created by Face - Detect and the faceIds will expire 24 hours after the - * detection call. + * detection call. The number of faceIds is limited to 1000. Parameter + * faceListId, largeFaceListId and faceIds should not be provided at the same + * time. * @member {number} [maxNumOfCandidatesReturned] The number of top similar * faces returned. The valid range is [1, 1000]. Default value: 20 . * @member {string} [mode] Similar face searching mode. It can be @@ -68,6 +76,17 @@ class FindSimilarRequest { name: 'String' } }, + largeFaceListId: { + required: false, + serializedName: 'largeFaceListId', + constraints: { + MaxLength: 64, + Pattern: '^[a-z0-9-_]+$' + }, + type: { + name: 'String' + } + }, faceIds: { required: false, serializedName: 'faceIds', @@ -99,6 +118,7 @@ class FindSimilarRequest { }, mode: { required: false, + nullable: false, serializedName: 'mode', defaultValue: 'matchPerson', type: { diff --git a/lib/services/face/lib/models/hair.js b/lib/services/face/lib/models/hair.js index bb7acb1327..465fd193c5 100644 --- a/lib/services/face/lib/models/hair.js +++ b/lib/services/face/lib/models/hair.js @@ -45,6 +45,7 @@ class Hair { modelProperties: { bald: { required: false, + nullable: false, serializedName: 'bald', type: { name: 'Number' @@ -52,6 +53,7 @@ class Hair { }, invisible: { required: false, + nullable: false, serializedName: 'invisible', type: { name: 'Boolean' diff --git a/lib/services/face/lib/models/hairColor.js b/lib/services/face/lib/models/hairColor.js index 948265c835..6076de45cd 100644 --- a/lib/services/face/lib/models/hairColor.js +++ b/lib/services/face/lib/models/hairColor.js @@ -40,6 +40,7 @@ class HairColor { modelProperties: { color: { required: false, + nullable: false, serializedName: 'color', type: { name: 'Enum', @@ -48,6 +49,7 @@ class HairColor { }, confidence: { required: false, + nullable: false, serializedName: 'confidence', type: { name: 'Number' diff --git a/lib/services/face/lib/models/headPose.js b/lib/services/face/lib/models/headPose.js index 4a8c915e9b..ad7e2fbe09 100644 --- a/lib/services/face/lib/models/headPose.js +++ b/lib/services/face/lib/models/headPose.js @@ -40,6 +40,7 @@ class HeadPose { modelProperties: { roll: { required: false, + nullable: false, serializedName: 'roll', type: { name: 'Number' @@ -47,6 +48,7 @@ class HeadPose { }, yaw: { required: false, + nullable: false, serializedName: 'yaw', type: { name: 'Number' @@ -54,6 +56,7 @@ class HeadPose { }, pitch: { required: false, + nullable: false, serializedName: 'pitch', type: { name: 'Number' diff --git a/lib/services/face/lib/models/identifyRequest.js b/lib/services/face/lib/models/identifyRequest.js index 7c10b7d14d..db6bd0215d 100644 --- a/lib/services/face/lib/models/identifyRequest.js +++ b/lib/services/face/lib/models/identifyRequest.js @@ -17,11 +17,16 @@ class IdentifyRequest { /** * Create a IdentifyRequest. - * @member {string} personGroupId PersonGroupId of the target person group, - * created by PersonGroups.Create * @member {array} faceIds Array of query faces faceIds, created by the Face * - Detect. Each of the faces are identified independently. The valid number * of faceIds is between [1, 10]. + * @member {string} [personGroupId] PersonGroupId of the target person group, + * created by PersonGroup - Create. Parameter personGroupId and + * largePersonGroupId should not be provided at the same time. + * @member {string} [largePersonGroupId] LargePersonGroupId of the target + * large person group, created by LargePersonGroup - Create. Parameter + * personGroupId and largePersonGroupId should not be provided at the same + * time. * @member {number} [maxNumOfCandidatesReturned] The range of * maxNumOfCandidatesReturned is between 1 and 5 (default is 1). Default * value: 1 . @@ -46,17 +51,6 @@ class IdentifyRequest { name: 'Composite', className: 'IdentifyRequest', modelProperties: { - personGroupId: { - required: true, - serializedName: 'personGroupId', - constraints: { - MaxLength: 64, - Pattern: '^[a-z0-9-_]+$' - }, - type: { - name: 'String' - } - }, faceIds: { required: true, serializedName: 'faceIds', @@ -74,6 +68,28 @@ class IdentifyRequest { } } }, + personGroupId: { + required: false, + serializedName: 'personGroupId', + constraints: { + MaxLength: 64, + Pattern: '^[a-z0-9-_]+$' + }, + type: { + name: 'String' + } + }, + largePersonGroupId: { + required: false, + serializedName: 'largePersonGroupId', + constraints: { + MaxLength: 64, + Pattern: '^[a-z0-9-_]+$' + }, + type: { + name: 'String' + } + }, maxNumOfCandidatesReturned: { required: false, serializedName: 'maxNumOfCandidatesReturned', diff --git a/lib/services/face/lib/models/index.d.ts b/lib/services/face/lib/models/index.d.ts index ac054fa25f..244dfd4ffd 100644 --- a/lib/services/face/lib/models/index.d.ts +++ b/lib/services/face/lib/models/index.d.ts @@ -726,10 +726,18 @@ export interface DetectedFace { * @member {string} [faceListId] An existing user-specified unique candidate * face list, created in Face List - Create a Face List. Face list contains a * set of persistedFaceIds which are persisted and will never expire. Parameter - * faceListId and faceIds should not be provided at the same time + * faceListId, largeFaceListId and faceIds should not be provided at the same + * time。 + * @member {string} [largeFaceListId] An existing user-specified unique + * candidate large face list, created in LargeFaceList - Create. Large face + * list contains a set of persistedFaceIds which are persisted and will never + * expire. Parameter faceListId, largeFaceListId and faceIds should not be + * provided at the same time. * @member {array} [faceIds] An array of candidate faceIds. All of them are * created by Face - Detect and the faceIds will expire 24 hours after the - * detection call. + * detection call. The number of faceIds is limited to 1000. Parameter + * faceListId, largeFaceListId and faceIds should not be provided at the same + * time. * @member {number} [maxNumOfCandidatesReturned] The number of top similar * faces returned. The valid range is [1, 1000]. Default value: 20 . * @member {string} [mode] Similar face searching mode. It can be "matchPerson" @@ -739,6 +747,7 @@ export interface DetectedFace { export interface FindSimilarRequest { faceId: string; faceListId?: string; + largeFaceListId?: string; faceIds?: string[]; maxNumOfCandidatesReturned?: number; mode?: string; @@ -800,11 +809,15 @@ export interface GroupResult { * @constructor * Request body for identify face operation. * - * @member {string} personGroupId PersonGroupId of the target person group, - * created by PersonGroups.Create * @member {array} faceIds Array of query faces faceIds, created by the Face - * Detect. Each of the faces are identified independently. The valid number of * faceIds is between [1, 10]. + * @member {string} [personGroupId] PersonGroupId of the target person group, + * created by PersonGroup - Create. Parameter personGroupId and + * largePersonGroupId should not be provided at the same time. + * @member {string} [largePersonGroupId] LargePersonGroupId of the target large + * person group, created by LargePersonGroup - Create. Parameter personGroupId + * and largePersonGroupId should not be provided at the same time. * @member {number} [maxNumOfCandidatesReturned] The range of * maxNumOfCandidatesReturned is between 1 and 5 (default is 1). Default value: * 1 . @@ -813,8 +826,9 @@ export interface GroupResult { * range of confidenceThreshold is [0, 1] (default specified by algorithm). */ export interface IdentifyRequest { - personGroupId: string; faceIds: string[]; + personGroupId?: string; + largePersonGroupId?: string; maxNumOfCandidatesReturned?: number; confidenceThreshold?: number; } @@ -856,18 +870,25 @@ export interface IdentifyResult { * @class * Initializes a new instance of the VerifyFaceToPersonRequest class. * @constructor - * Request body for verify operation. + * Request body for face to person verification. * - * @member {uuid} faceId FaceId the face, comes from Face - Detect - * @member {string} personGroupId Using existing personGroupId and personId for - * fast loading a specified person. personGroupId is created in Person - * Groups.Create. - * @member {uuid} personId Specify a certain person in a person group. personId - * is created in Persons.Create. + * @member {uuid} faceId FaceId of the face, comes from Face - Detect + * @member {string} [personGroupId] Using existing personGroupId and personId + * for fast loading a specified person. personGroupId is created in PersonGroup + * - Create. Parameter personGroupId and largePersonGroupId should not be + * provided at the same time. + * @member {string} [largePersonGroupId] Using existing largePersonGroupId and + * personId for fast loading a specified person. largePersonGroupId is created + * in LargePersonGroup - Create. Parameter personGroupId and largePersonGroupId + * should not be provided at the same time. + * @member {uuid} personId Specify a certain person in a person group or a + * large person group. personId is created in PersonGroup Person - Create or + * LargePersonGroup Person - Create. */ export interface VerifyFaceToPersonRequest { faceId: string; - personGroupId: string; + personGroupId?: string; + largePersonGroupId?: string; personId: string; } @@ -875,7 +896,7 @@ export interface VerifyFaceToPersonRequest { * @class * Initializes a new instance of the VerifyFaceToFaceRequest class. * @constructor - * Request body for verify operation. + * Request body for face to face verification. * * @member {uuid} faceId1 FaceId of the first face, comes from Face - Detect * @member {uuid} faceId2 FaceId of the second face, comes from Face - Detect @@ -926,7 +947,7 @@ export interface PersistedFace { * Initializes a new instance of the NameAndUserDataContract class. * @constructor * A combination of user defined name and user specified data for the person, - * personGroup, and faceList + * largePersonGroup/personGroup, and largeFaceList/faceList. * * @member {string} [name] User defined name, maximum length is 128. * @member {string} [userData] User specified data. Length should not exceed @@ -957,7 +978,7 @@ export interface FaceList extends NameAndUserDataContract { * @constructor * Person group object. * - * @member {string} personGroupId PersonGroupId of the existing person groups. + * @member {string} personGroupId PersonGroupId of the target person group. */ export interface PersonGroup extends NameAndUserDataContract { personGroupId: string; @@ -981,14 +1002,40 @@ export interface Person extends NameAndUserDataContract { /** * @class - * Initializes a new instance of the UpdatePersonFaceRequest class. + * Initializes a new instance of the LargeFaceList class. + * @constructor + * Large face list object. + * + * @member {string} largeFaceListId LargeFaceListId of the target large face + * list. + */ +export interface LargeFaceList extends NameAndUserDataContract { + largeFaceListId: string; +} + +/** + * @class + * Initializes a new instance of the LargePersonGroup class. + * @constructor + * Large person group object. + * + * @member {string} largePersonGroupId LargePersonGroupId of the target large + * person groups + */ +export interface LargePersonGroup extends NameAndUserDataContract { + largePersonGroupId: string; +} + +/** + * @class + * Initializes a new instance of the UpdateFaceRequest class. * @constructor - * Request to update person face data. + * Request to update face data. * * @member {string} [userData] User-provided data attached to the face. The * size limit is 1KB. */ -export interface UpdatePersonFaceRequest { +export interface UpdateFaceRequest { userData?: string; } @@ -1001,13 +1048,21 @@ export interface UpdatePersonFaceRequest { * @member {string} status Training status: notstarted, running, succeeded, * failed. If the training process is waiting to perform, the status is * notstarted. If the training is ongoing, the status is running. Status - * succeed means this person group is ready for Face - Identify. Status failed - * is often caused by no person or no persisted face exist in the person group. - * Possible values include: 'nonstarted', 'running', 'succeeded', 'failed' + * succeed means this person group or large person group is ready for Face - + * Identify, or this large face list is ready for Face - Find Similar. Status + * failed is often caused by no person or no persisted face exist in the person + * group or large person group, or no persisted face exist in the large face + * list. Possible values include: 'nonstarted', 'running', 'succeeded', + * 'failed' * @member {date} created A combined UTC date and time string that describes - * person group created time. - * @member {date} [lastAction] Person group last modify time in the UTC, could - * be null value when the person group is not successfully trained. + * the created time of the person group, large person group or large face list. + * @member {date} [lastAction] A combined UTC date and time string that + * describes the last modify time of the person group, large person group or + * large face list, could be null value when the group is not successfully + * trained. + * @member {date} [lastSuccessfulTraining] A combined UTC date and time string + * that describes the last successful training time of the person group, large + * person group or large face list. * @member {string} [message] Show failure message when training failed * (omitted when training succeed). */ @@ -1015,6 +1070,7 @@ export interface TrainingStatus { status: string; created: Date; lastAction?: Date; + lastSuccessfulTraining?: Date; message?: string; } diff --git a/lib/services/face/lib/models/index.js b/lib/services/face/lib/models/index.js index ab6fd3d5b8..f73b1269ae 100644 --- a/lib/services/face/lib/models/index.js +++ b/lib/services/face/lib/models/index.js @@ -47,6 +47,8 @@ exports.NameAndUserDataContract = require('./nameAndUserDataContract'); exports.FaceList = require('./faceList'); exports.PersonGroup = require('./personGroup'); exports.Person = require('./person'); -exports.UpdatePersonFaceRequest = require('./updatePersonFaceRequest'); +exports.LargeFaceList = require('./largeFaceList'); +exports.LargePersonGroup = require('./largePersonGroup'); +exports.UpdateFaceRequest = require('./updateFaceRequest'); exports.TrainingStatus = require('./trainingStatus'); exports.ImageUrl = require('./imageUrl'); diff --git a/lib/services/face/lib/models/largeFaceList.js b/lib/services/face/lib/models/largeFaceList.js new file mode 100644 index 0000000000..d22ab8f652 --- /dev/null +++ b/lib/services/face/lib/models/largeFaceList.js @@ -0,0 +1,81 @@ +/* + * 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'; + +const models = require('./index'); + +/** + * Large face list object. + * + * @extends models['NameAndUserDataContract'] + */ +class LargeFaceList extends models['NameAndUserDataContract'] { + /** + * Create a LargeFaceList. + * @member {string} largeFaceListId LargeFaceListId of the target large face + * list. + */ + constructor() { + super(); + } + + /** + * Defines the metadata of LargeFaceList + * + * @returns {object} metadata of LargeFaceList + * + */ + mapper() { + return { + required: false, + serializedName: 'LargeFaceList', + type: { + name: 'Composite', + className: 'LargeFaceList', + modelProperties: { + name: { + required: false, + serializedName: 'name', + constraints: { + MaxLength: 128 + }, + type: { + name: 'String' + } + }, + userData: { + required: false, + serializedName: 'userData', + constraints: { + MaxLength: 16384 + }, + type: { + name: 'String' + } + }, + largeFaceListId: { + required: true, + serializedName: 'largeFaceListId', + constraints: { + MaxLength: 64, + Pattern: '^[a-z0-9-_]+$' + }, + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = LargeFaceList; diff --git a/lib/services/face/lib/models/largePersonGroup.js b/lib/services/face/lib/models/largePersonGroup.js new file mode 100644 index 0000000000..c2667088d4 --- /dev/null +++ b/lib/services/face/lib/models/largePersonGroup.js @@ -0,0 +1,81 @@ +/* + * 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'; + +const models = require('./index'); + +/** + * Large person group object. + * + * @extends models['NameAndUserDataContract'] + */ +class LargePersonGroup extends models['NameAndUserDataContract'] { + /** + * Create a LargePersonGroup. + * @member {string} largePersonGroupId LargePersonGroupId of the target large + * person groups + */ + constructor() { + super(); + } + + /** + * Defines the metadata of LargePersonGroup + * + * @returns {object} metadata of LargePersonGroup + * + */ + mapper() { + return { + required: false, + serializedName: 'LargePersonGroup', + type: { + name: 'Composite', + className: 'LargePersonGroup', + modelProperties: { + name: { + required: false, + serializedName: 'name', + constraints: { + MaxLength: 128 + }, + type: { + name: 'String' + } + }, + userData: { + required: false, + serializedName: 'userData', + constraints: { + MaxLength: 16384 + }, + type: { + name: 'String' + } + }, + largePersonGroupId: { + required: true, + serializedName: 'largePersonGroupId', + constraints: { + MaxLength: 64, + Pattern: '^[a-z0-9-_]+$' + }, + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = LargePersonGroup; diff --git a/lib/services/face/lib/models/makeup.js b/lib/services/face/lib/models/makeup.js index c142e488ad..a939c0d1cb 100644 --- a/lib/services/face/lib/models/makeup.js +++ b/lib/services/face/lib/models/makeup.js @@ -41,6 +41,7 @@ class Makeup { modelProperties: { eyeMakeup: { required: false, + nullable: false, serializedName: 'eyeMakeup', type: { name: 'Boolean' @@ -48,6 +49,7 @@ class Makeup { }, lipMakeup: { required: false, + nullable: false, serializedName: 'lipMakeup', type: { name: 'Boolean' diff --git a/lib/services/face/lib/models/nameAndUserDataContract.js b/lib/services/face/lib/models/nameAndUserDataContract.js index a4f0946a26..0d760e5036 100644 --- a/lib/services/face/lib/models/nameAndUserDataContract.js +++ b/lib/services/face/lib/models/nameAndUserDataContract.js @@ -12,7 +12,7 @@ /** * A combination of user defined name and user specified data for the person, - * personGroup, and faceList + * largePersonGroup/personGroup, and largeFaceList/faceList. * */ class NameAndUserDataContract { diff --git a/lib/services/face/lib/models/noise.js b/lib/services/face/lib/models/noise.js index 952a76345c..db0e1b1ff6 100644 --- a/lib/services/face/lib/models/noise.js +++ b/lib/services/face/lib/models/noise.js @@ -43,6 +43,7 @@ class Noise { modelProperties: { noiseLevel: { required: false, + nullable: false, serializedName: 'noiseLevel', type: { name: 'Enum', @@ -51,6 +52,7 @@ class Noise { }, value: { required: false, + nullable: false, serializedName: 'value', type: { name: 'Number' diff --git a/lib/services/face/lib/models/occlusion.js b/lib/services/face/lib/models/occlusion.js index 9a2493e202..edf5287eb6 100644 --- a/lib/services/face/lib/models/occlusion.js +++ b/lib/services/face/lib/models/occlusion.js @@ -43,6 +43,7 @@ class Occlusion { modelProperties: { foreheadOccluded: { required: false, + nullable: false, serializedName: 'foreheadOccluded', type: { name: 'Boolean' @@ -50,6 +51,7 @@ class Occlusion { }, eyeOccluded: { required: false, + nullable: false, serializedName: 'eyeOccluded', type: { name: 'Boolean' @@ -57,6 +59,7 @@ class Occlusion { }, mouthOccluded: { required: false, + nullable: false, serializedName: 'mouthOccluded', type: { name: 'Boolean' diff --git a/lib/services/face/lib/models/personGroup.js b/lib/services/face/lib/models/personGroup.js index 6bcc60b369..bdad8230fa 100644 --- a/lib/services/face/lib/models/personGroup.js +++ b/lib/services/face/lib/models/personGroup.js @@ -20,8 +20,7 @@ const models = require('./index'); class PersonGroup extends models['NameAndUserDataContract'] { /** * Create a PersonGroup. - * @member {string} personGroupId PersonGroupId of the existing person - * groups. + * @member {string} personGroupId PersonGroupId of the target person group. */ constructor() { super(); diff --git a/lib/services/face/lib/models/trainingStatus.js b/lib/services/face/lib/models/trainingStatus.js index 9b71f28137..4051e2493c 100644 --- a/lib/services/face/lib/models/trainingStatus.js +++ b/lib/services/face/lib/models/trainingStatus.js @@ -20,14 +20,22 @@ class TrainingStatus { * @member {string} status Training status: notstarted, running, succeeded, * failed. If the training process is waiting to perform, the status is * notstarted. If the training is ongoing, the status is running. Status - * succeed means this person group is ready for Face - Identify. Status + * succeed means this person group or large person group is ready for Face - + * Identify, or this large face list is ready for Face - Find Similar. Status * failed is often caused by no person or no persisted face exist in the - * person group. Possible values include: 'nonstarted', 'running', + * person group or large person group, or no persisted face exist in the + * large face list. Possible values include: 'nonstarted', 'running', * 'succeeded', 'failed' * @member {date} created A combined UTC date and time string that describes - * person group created time. - * @member {date} [lastAction] Person group last modify time in the UTC, - * could be null value when the person group is not successfully trained. + * the created time of the person group, large person group or large face + * list. + * @member {date} [lastAction] A combined UTC date and time string that + * describes the last modify time of the person group, large person group or + * large face list, could be null value when the group is not successfully + * trained. + * @member {date} [lastSuccessfulTraining] A combined UTC date and time + * string that describes the last successful training time of the person + * group, large person group or large face list. * @member {string} [message] Show failure message when training failed * (omitted when training succeed). */ @@ -70,6 +78,13 @@ class TrainingStatus { name: 'DateTime' } }, + lastSuccessfulTraining: { + required: false, + serializedName: 'lastSuccessfulTrainingDateTime', + type: { + name: 'DateTime' + } + }, message: { required: false, serializedName: 'message', diff --git a/lib/services/face/lib/models/updateFaceRequest.js b/lib/services/face/lib/models/updateFaceRequest.js new file mode 100644 index 0000000000..1579262356 --- /dev/null +++ b/lib/services/face/lib/models/updateFaceRequest.js @@ -0,0 +1,56 @@ +/* + * 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'; + +/** + * Request to update face data. + * + */ +class UpdateFaceRequest { + /** + * Create a UpdateFaceRequest. + * @member {string} [userData] User-provided data attached to the face. The + * size limit is 1KB. + */ + constructor() { + } + + /** + * Defines the metadata of UpdateFaceRequest + * + * @returns {object} metadata of UpdateFaceRequest + * + */ + mapper() { + return { + required: false, + serializedName: 'UpdateFaceRequest', + type: { + name: 'Composite', + className: 'UpdateFaceRequest', + modelProperties: { + userData: { + required: false, + serializedName: 'userData', + constraints: { + MaxLength: 1024 + }, + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = UpdateFaceRequest; diff --git a/lib/services/face/lib/models/verifyFaceToFaceRequest.js b/lib/services/face/lib/models/verifyFaceToFaceRequest.js index cbc3534599..f67c749a41 100644 --- a/lib/services/face/lib/models/verifyFaceToFaceRequest.js +++ b/lib/services/face/lib/models/verifyFaceToFaceRequest.js @@ -11,7 +11,7 @@ 'use strict'; /** - * Request body for verify operation. + * Request body for face to face verification. * */ class VerifyFaceToFaceRequest { diff --git a/lib/services/face/lib/models/verifyFaceToPersonRequest.js b/lib/services/face/lib/models/verifyFaceToPersonRequest.js index 04b4e51e1e..88bb30a6a9 100644 --- a/lib/services/face/lib/models/verifyFaceToPersonRequest.js +++ b/lib/services/face/lib/models/verifyFaceToPersonRequest.js @@ -11,18 +11,24 @@ 'use strict'; /** - * Request body for verify operation. + * Request body for face to person verification. * */ class VerifyFaceToPersonRequest { /** * Create a VerifyFaceToPersonRequest. - * @member {uuid} faceId FaceId the face, comes from Face - Detect - * @member {string} personGroupId Using existing personGroupId and personId - * for fast loading a specified person. personGroupId is created in Person - * Groups.Create. - * @member {uuid} personId Specify a certain person in a person group. - * personId is created in Persons.Create. + * @member {uuid} faceId FaceId of the face, comes from Face - Detect + * @member {string} [personGroupId] Using existing personGroupId and personId + * for fast loading a specified person. personGroupId is created in + * PersonGroup - Create. Parameter personGroupId and largePersonGroupId + * should not be provided at the same time. + * @member {string} [largePersonGroupId] Using existing largePersonGroupId + * and personId for fast loading a specified person. largePersonGroupId is + * created in LargePersonGroup - Create. Parameter personGroupId and + * largePersonGroupId should not be provided at the same time. + * @member {uuid} personId Specify a certain person in a person group or a + * large person group. personId is created in PersonGroup Person - Create or + * LargePersonGroup Person - Create. */ constructor() { } @@ -49,7 +55,7 @@ class VerifyFaceToPersonRequest { } }, personGroupId: { - required: true, + required: false, serializedName: 'personGroupId', constraints: { MaxLength: 64, @@ -59,6 +65,17 @@ class VerifyFaceToPersonRequest { name: 'String' } }, + largePersonGroupId: { + required: false, + serializedName: 'largePersonGroupId', + constraints: { + MaxLength: 64, + Pattern: '^[a-z0-9-_]+$' + }, + type: { + name: 'String' + } + }, personId: { required: true, serializedName: 'personId', diff --git a/lib/services/face/lib/operations/face.js b/lib/services/face/lib/operations/face.js index f1f9a07708..12399e2440 100644 --- a/lib/services/face/lib/operations/face.js +++ b/lib/services/face/lib/operations/face.js @@ -15,7 +15,7 @@ const WebResource = msRest.WebResource; /** * Given query face's faceId, find the similar-looking faces from a faceId - * array or a faceListId. + * array, a face list or a large face list. * * @param {uuid} faceId FaceId of the query face. User needs to call Face - * Detect first to get a valid faceId. Note that this faceId is not persisted @@ -26,12 +26,20 @@ const WebResource = msRest.WebResource; * @param {string} [options.faceListId] An existing user-specified unique * candidate face list, created in Face List - Create a Face List. Face list * contains a set of persistedFaceIds which are persisted and will never - * expire. Parameter faceListId and faceIds should not be provided at the same - * time + * expire. Parameter faceListId, largeFaceListId and faceIds should not be + * provided at the same time。 + * + * @param {string} [options.largeFaceListId] An existing user-specified unique + * candidate large face list, created in LargeFaceList - Create. Large face + * list contains a set of persistedFaceIds which are persisted and will never + * expire. Parameter faceListId, largeFaceListId and faceIds should not be + * provided at the same time. * * @param {array} [options.faceIds] An array of candidate faceIds. All of them * are created by Face - Detect and the faceIds will expire 24 hours after the - * detection call. + * detection call. The number of faceIds is limited to 1000. Parameter + * faceListId, largeFaceListId and faceIds should not be provided at the same + * time. * * @param {number} [options.maxNumOfCandidatesReturned] The number of top * similar faces returned. The valid range is [1, 1000]. @@ -66,6 +74,7 @@ function _findSimilar(faceId, options, callback) { throw new Error('callback cannot be null.'); } let faceListId = (options && options.faceListId !== undefined) ? options.faceListId : undefined; + let largeFaceListId = (options && options.largeFaceListId !== undefined) ? options.largeFaceListId : undefined; let faceIds = (options && options.faceIds !== undefined) ? options.faceIds : undefined; let maxNumOfCandidatesReturned = (options && options.maxNumOfCandidatesReturned !== undefined) ? options.maxNumOfCandidatesReturned : 20; let mode = (options && options.mode !== undefined) ? options.mode : 'matchPerson'; @@ -90,6 +99,19 @@ function _findSimilar(faceId, options, callback) { throw new Error('"faceListId" should satisfy the constraint - "Pattern": /^[a-z0-9-_]+$/'); } } + if (largeFaceListId !== null && largeFaceListId !== undefined && typeof largeFaceListId.valueOf() !== 'string') { + throw new Error('largeFaceListId must be of type string.'); + } + if (largeFaceListId !== null && largeFaceListId !== undefined) { + if (largeFaceListId.length > 64) + { + throw new Error('"largeFaceListId" should satisfy the constraint - "MaxLength": 64'); + } + if (largeFaceListId.match(/^[a-z0-9-_]+$/) === null) + { + throw new Error('"largeFaceListId" should satisfy the constraint - "Pattern": /^[a-z0-9-_]+$/'); + } + } if (Array.isArray(faceIds)) { for (let i = 0; i < faceIds.length; i++) { if (faceIds[i] !== null && faceIds[i] !== undefined && !(typeof faceIds[i].valueOf() === 'string' && msRest.isValidUuid(faceIds[i]))) { @@ -126,10 +148,11 @@ function _findSimilar(faceId, options, callback) { return callback(error); } let body; - if ((faceId !== null && faceId !== undefined) || (faceListId !== null && faceListId !== undefined) || (faceIds !== null && faceIds !== undefined) || (maxNumOfCandidatesReturned !== null && maxNumOfCandidatesReturned !== undefined) || (mode !== null && mode !== undefined)) { + if ((faceId !== null && faceId !== undefined) || (faceListId !== null && faceListId !== undefined) || (largeFaceListId !== null && largeFaceListId !== undefined) || (faceIds !== null && faceIds !== undefined) || (maxNumOfCandidatesReturned !== null && maxNumOfCandidatesReturned !== undefined) || (mode !== null && mode !== undefined)) { body = new client.models['FindSimilarRequest'](); body.faceId = faceId; body.faceListId = faceListId; + body.largeFaceListId = largeFaceListId; body.faceIds = faceIds; body.maxNumOfCandidatesReturned = maxNumOfCandidatesReturned; body.mode = mode; @@ -394,10 +417,8 @@ function _group(faceIds, options, callback) { } /** - * Identify unknown faces from a person group. - * - * @param {string} personGroupId PersonGroupId of the target person group, - * created by PersonGroups.Create + * 1-to-many identification to find the closest matches of the specific query + * person face from a person group or large person group. * * @param {array} faceIds Array of query faces faceIds, created by the Face - * Detect. Each of the faces are identified independently. The valid number of @@ -405,6 +426,15 @@ function _group(faceIds, options, callback) { * * @param {object} [options] Optional Parameters. * + * @param {string} [options.personGroupId] PersonGroupId of the target person + * group, created by PersonGroup - Create. Parameter personGroupId and + * largePersonGroupId should not be provided at the same time. + * + * @param {string} [options.largePersonGroupId] LargePersonGroupId of the + * target large person group, created by LargePersonGroup - Create. Parameter + * personGroupId and largePersonGroupId should not be provided at the same + * time. + * * @param {number} [options.maxNumOfCandidatesReturned] The range of * maxNumOfCandidatesReturned is between 1 and 5 (default is 1). * @@ -427,7 +457,7 @@ function _group(faceIds, options, callback) { * * {stream} [response] - The HTTP Response stream if an error did not occur. */ -function _identify(personGroupId, faceIds, options, callback) { +function _identify(faceIds, options, callback) { /* jshint validthis: true */ let client = this.client; if(!callback && typeof options === 'function') { @@ -437,6 +467,8 @@ function _identify(personGroupId, faceIds, options, callback) { if (!callback) { throw new Error('callback cannot be null.'); } + let personGroupId = (options && options.personGroupId !== undefined) ? options.personGroupId : undefined; + let largePersonGroupId = (options && options.largePersonGroupId !== undefined) ? options.largePersonGroupId : undefined; let maxNumOfCandidatesReturned = (options && options.maxNumOfCandidatesReturned !== undefined) ? options.maxNumOfCandidatesReturned : 1; let confidenceThreshold = (options && options.confidenceThreshold !== undefined) ? options.confidenceThreshold : undefined; // Validate @@ -444,8 +476,22 @@ function _identify(personGroupId, faceIds, options, callback) { if (this.client.endpoint === null || this.client.endpoint === undefined || typeof this.client.endpoint.valueOf() !== 'string') { throw new Error('this.client.endpoint cannot be null or undefined and it must be of type string.'); } - if (personGroupId === null || personGroupId === undefined || typeof personGroupId.valueOf() !== 'string') { - throw new Error('personGroupId cannot be null or undefined and it must be of type string.'); + if (!Array.isArray(faceIds)) { + throw new Error('faceIds cannot be null or undefined and it must be of type array.'); + } + for (let i = 0; i < faceIds.length; i++) { + if (faceIds[i] !== null && faceIds[i] !== undefined && !(typeof faceIds[i].valueOf() === 'string' && msRest.isValidUuid(faceIds[i]))) { + throw new Error('faceIds[i] must be of type string and must be a valid uuid.'); + } + } + if (faceIds !== null && faceIds !== undefined) { + if (faceIds.length > 10) + { + throw new Error('"faceIds" should satisfy the constraint - "MaxItems": 10'); + } + } + if (personGroupId !== null && personGroupId !== undefined && typeof personGroupId.valueOf() !== 'string') { + throw new Error('personGroupId must be of type string.'); } if (personGroupId !== null && personGroupId !== undefined) { if (personGroupId.length > 64) @@ -457,18 +503,17 @@ function _identify(personGroupId, faceIds, options, callback) { throw new Error('"personGroupId" should satisfy the constraint - "Pattern": /^[a-z0-9-_]+$/'); } } - if (!Array.isArray(faceIds)) { - throw new Error('faceIds cannot be null or undefined and it must be of type array.'); + if (largePersonGroupId !== null && largePersonGroupId !== undefined && typeof largePersonGroupId.valueOf() !== 'string') { + throw new Error('largePersonGroupId must be of type string.'); } - for (let i = 0; i < faceIds.length; i++) { - if (faceIds[i] !== null && faceIds[i] !== undefined && !(typeof faceIds[i].valueOf() === 'string' && msRest.isValidUuid(faceIds[i]))) { - throw new Error('faceIds[i] must be of type string and must be a valid uuid.'); + if (largePersonGroupId !== null && largePersonGroupId !== undefined) { + if (largePersonGroupId.length > 64) + { + throw new Error('"largePersonGroupId" should satisfy the constraint - "MaxLength": 64'); } - } - if (faceIds !== null && faceIds !== undefined) { - if (faceIds.length > 10) + if (largePersonGroupId.match(/^[a-z0-9-_]+$/) === null) { - throw new Error('"faceIds" should satisfy the constraint - "MaxItems": 10'); + throw new Error('"largePersonGroupId" should satisfy the constraint - "Pattern": /^[a-z0-9-_]+$/'); } } if (maxNumOfCandidatesReturned !== null && maxNumOfCandidatesReturned !== undefined && typeof maxNumOfCandidatesReturned !== 'number') { @@ -491,10 +536,11 @@ function _identify(personGroupId, faceIds, options, callback) { return callback(error); } let body; - if ((personGroupId !== null && personGroupId !== undefined) || (faceIds !== null && faceIds !== undefined) || (maxNumOfCandidatesReturned !== null && maxNumOfCandidatesReturned !== undefined) || (confidenceThreshold !== null && confidenceThreshold !== undefined)) { + if ((faceIds !== null && faceIds !== undefined) || (personGroupId !== null && personGroupId !== undefined) || (largePersonGroupId !== null && largePersonGroupId !== undefined) || (maxNumOfCandidatesReturned !== null && maxNumOfCandidatesReturned !== undefined) || (confidenceThreshold !== null && confidenceThreshold !== undefined)) { body = new client.models['IdentifyRequest'](); - body.personGroupId = personGroupId; body.faceIds = faceIds; + body.personGroupId = personGroupId; + body.largePersonGroupId = largePersonGroupId; body.maxNumOfCandidatesReturned = maxNumOfCandidatesReturned; body.confidenceThreshold = confidenceThreshold; } @@ -955,17 +1001,25 @@ function _detectWithUrl(url, options, callback) { * Verify whether two faces belong to a same person. Compares a face Id with a * Person Id * - * @param {uuid} faceId FaceId the face, comes from Face - Detect + * @param {uuid} faceId FaceId of the face, comes from Face - Detect * - * @param {string} personGroupId Using existing personGroupId and personId for - * fast loading a specified person. personGroupId is created in Person - * Groups.Create. - * - * @param {uuid} personId Specify a certain person in a person group. personId - * is created in Persons.Create. + * @param {uuid} personId Specify a certain person in a person group or a large + * person group. personId is created in PersonGroup Person - Create or + * LargePersonGroup Person - Create. * * @param {object} [options] Optional Parameters. * + * @param {string} [options.personGroupId] Using existing personGroupId and + * personId for fast loading a specified person. personGroupId is created in + * PersonGroup - Create. Parameter personGroupId and largePersonGroupId should + * not be provided at the same time. + * + * @param {string} [options.largePersonGroupId] Using existing + * largePersonGroupId and personId for fast loading a specified person. + * largePersonGroupId is created in LargePersonGroup - Create. Parameter + * personGroupId and largePersonGroupId should not be provided at the same + * time. + * * @param {object} [options.customHeaders] Headers that will be added to the * request * @@ -982,7 +1036,7 @@ function _detectWithUrl(url, options, callback) { * * {stream} [response] - The HTTP Response stream if an error did not occur. */ -function _verifyFaceToPerson(faceId, personGroupId, personId, options, callback) { +function _verifyFaceToPerson(faceId, personId, options, callback) { /* jshint validthis: true */ let client = this.client; if(!callback && typeof options === 'function') { @@ -992,6 +1046,8 @@ function _verifyFaceToPerson(faceId, personGroupId, personId, options, callback) if (!callback) { throw new Error('callback cannot be null.'); } + let personGroupId = (options && options.personGroupId !== undefined) ? options.personGroupId : undefined; + let largePersonGroupId = (options && options.largePersonGroupId !== undefined) ? options.largePersonGroupId : undefined; // Validate try { if (this.client.endpoint === null || this.client.endpoint === undefined || typeof this.client.endpoint.valueOf() !== 'string') { @@ -1000,8 +1056,8 @@ function _verifyFaceToPerson(faceId, personGroupId, personId, options, callback) if (faceId === null || faceId === undefined || typeof faceId.valueOf() !== 'string' || !msRest.isValidUuid(faceId)) { throw new Error('faceId cannot be null or undefined and it must be of type string and must be a valid uuid.'); } - if (personGroupId === null || personGroupId === undefined || typeof personGroupId.valueOf() !== 'string') { - throw new Error('personGroupId cannot be null or undefined and it must be of type string.'); + if (personGroupId !== null && personGroupId !== undefined && typeof personGroupId.valueOf() !== 'string') { + throw new Error('personGroupId must be of type string.'); } if (personGroupId !== null && personGroupId !== undefined) { if (personGroupId.length > 64) @@ -1013,6 +1069,19 @@ function _verifyFaceToPerson(faceId, personGroupId, personId, options, callback) throw new Error('"personGroupId" should satisfy the constraint - "Pattern": /^[a-z0-9-_]+$/'); } } + if (largePersonGroupId !== null && largePersonGroupId !== undefined && typeof largePersonGroupId.valueOf() !== 'string') { + throw new Error('largePersonGroupId must be of type string.'); + } + if (largePersonGroupId !== null && largePersonGroupId !== undefined) { + if (largePersonGroupId.length > 64) + { + throw new Error('"largePersonGroupId" should satisfy the constraint - "MaxLength": 64'); + } + if (largePersonGroupId.match(/^[a-z0-9-_]+$/) === null) + { + throw new Error('"largePersonGroupId" should satisfy the constraint - "Pattern": /^[a-z0-9-_]+$/'); + } + } if (personId === null || personId === undefined || typeof personId.valueOf() !== 'string' || !msRest.isValidUuid(personId)) { throw new Error('personId cannot be null or undefined and it must be of type string and must be a valid uuid.'); } @@ -1020,10 +1089,11 @@ function _verifyFaceToPerson(faceId, personGroupId, personId, options, callback) return callback(error); } let body; - if ((faceId !== null && faceId !== undefined) || (personGroupId !== null && personGroupId !== undefined) || (personId !== null && personId !== undefined)) { + if ((faceId !== null && faceId !== undefined) || (personGroupId !== null && personGroupId !== undefined) || (largePersonGroupId !== null && largePersonGroupId !== undefined) || (personId !== null && personId !== undefined)) { body = new client.models['VerifyFaceToPersonRequest'](); body.faceId = faceId; body.personGroupId = personGroupId; + body.largePersonGroupId = largePersonGroupId; body.personId = personId; } @@ -1319,7 +1389,7 @@ class Face { /** * Given query face's faceId, find the similar-looking faces from a faceId - * array or a faceListId. + * array, a face list or a large face list. * * @param {uuid} faceId FaceId of the query face. User needs to call Face - * Detect first to get a valid faceId. Note that this faceId is not persisted @@ -1330,12 +1400,20 @@ class Face { * @param {string} [options.faceListId] An existing user-specified unique * candidate face list, created in Face List - Create a Face List. Face list * contains a set of persistedFaceIds which are persisted and will never - * expire. Parameter faceListId and faceIds should not be provided at the same - * time + * expire. Parameter faceListId, largeFaceListId and faceIds should not be + * provided at the same time。 + * + * @param {string} [options.largeFaceListId] An existing user-specified unique + * candidate large face list, created in LargeFaceList - Create. Large face + * list contains a set of persistedFaceIds which are persisted and will never + * expire. Parameter faceListId, largeFaceListId and faceIds should not be + * provided at the same time. * * @param {array} [options.faceIds] An array of candidate faceIds. All of them * are created by Face - Detect and the faceIds will expire 24 hours after the - * detection call. + * detection call. The number of faceIds is limited to 1000. Parameter + * faceListId, largeFaceListId and faceIds should not be provided at the same + * time. * * @param {number} [options.maxNumOfCandidatesReturned] The number of top * similar faces returned. The valid range is [1, 1000]. @@ -1369,7 +1447,7 @@ class Face { /** * Given query face's faceId, find the similar-looking faces from a faceId - * array or a faceListId. + * array, a face list or a large face list. * * @param {uuid} faceId FaceId of the query face. User needs to call Face - * Detect first to get a valid faceId. Note that this faceId is not persisted @@ -1380,12 +1458,20 @@ class Face { * @param {string} [options.faceListId] An existing user-specified unique * candidate face list, created in Face List - Create a Face List. Face list * contains a set of persistedFaceIds which are persisted and will never - * expire. Parameter faceListId and faceIds should not be provided at the same - * time + * expire. Parameter faceListId, largeFaceListId and faceIds should not be + * provided at the same time。 + * + * @param {string} [options.largeFaceListId] An existing user-specified unique + * candidate large face list, created in LargeFaceList - Create. Large face + * list contains a set of persistedFaceIds which are persisted and will never + * expire. Parameter faceListId, largeFaceListId and faceIds should not be + * provided at the same time. * * @param {array} [options.faceIds] An array of candidate faceIds. All of them * are created by Face - Detect and the faceIds will expire 24 hours after the - * detection call. + * detection call. The number of faceIds is limited to 1000. Parameter + * faceListId, largeFaceListId and faceIds should not be provided at the same + * time. * * @param {number} [options.maxNumOfCandidatesReturned] The number of top * similar faces returned. The valid range is [1, 1000]. @@ -1523,10 +1609,8 @@ class Face { } /** - * Identify unknown faces from a person group. - * - * @param {string} personGroupId PersonGroupId of the target person group, - * created by PersonGroups.Create + * 1-to-many identification to find the closest matches of the specific query + * person face from a person group or large person group. * * @param {array} faceIds Array of query faces faceIds, created by the Face - * Detect. Each of the faces are identified independently. The valid number of @@ -1534,6 +1618,15 @@ class Face { * * @param {object} [options] Optional Parameters. * + * @param {string} [options.personGroupId] PersonGroupId of the target person + * group, created by PersonGroup - Create. Parameter personGroupId and + * largePersonGroupId should not be provided at the same time. + * + * @param {string} [options.largePersonGroupId] LargePersonGroupId of the + * target large person group, created by LargePersonGroup - Create. Parameter + * personGroupId and largePersonGroupId should not be provided at the same + * time. + * * @param {number} [options.maxNumOfCandidatesReturned] The range of * maxNumOfCandidatesReturned is between 1 and 5 (default is 1). * @@ -1550,11 +1643,11 @@ class Face { * * @reject {Error} - The error object. */ - identifyWithHttpOperationResponse(personGroupId, faceIds, options) { + identifyWithHttpOperationResponse(faceIds, options) { let client = this.client; let self = this; return new Promise((resolve, reject) => { - self._identify(personGroupId, faceIds, options, (err, result, request, response) => { + self._identify(faceIds, options, (err, result, request, response) => { let httpOperationResponse = new msRest.HttpOperationResponse(request, response); httpOperationResponse.body = result; if (err) { reject(err); } @@ -1565,10 +1658,8 @@ class Face { } /** - * Identify unknown faces from a person group. - * - * @param {string} personGroupId PersonGroupId of the target person group, - * created by PersonGroups.Create + * 1-to-many identification to find the closest matches of the specific query + * person face from a person group or large person group. * * @param {array} faceIds Array of query faces faceIds, created by the Face - * Detect. Each of the faces are identified independently. The valid number of @@ -1576,6 +1667,15 @@ class Face { * * @param {object} [options] Optional Parameters. * + * @param {string} [options.personGroupId] PersonGroupId of the target person + * group, created by PersonGroup - Create. Parameter personGroupId and + * largePersonGroupId should not be provided at the same time. + * + * @param {string} [options.largePersonGroupId] LargePersonGroupId of the + * target large person group, created by LargePersonGroup - Create. Parameter + * personGroupId and largePersonGroupId should not be provided at the same + * time. + * * @param {number} [options.maxNumOfCandidatesReturned] The range of * maxNumOfCandidatesReturned is between 1 and 5 (default is 1). * @@ -1607,7 +1707,7 @@ class Face { * * {stream} [response] - The HTTP Response stream if an error did not occur. */ - identify(personGroupId, faceIds, options, optionalCallback) { + identify(faceIds, options, optionalCallback) { let client = this.client; let self = this; if (!optionalCallback && typeof options === 'function') { @@ -1616,14 +1716,14 @@ class Face { } if (!optionalCallback) { return new Promise((resolve, reject) => { - self._identify(personGroupId, faceIds, options, (err, result, request, response) => { + self._identify(faceIds, options, (err, result, request, response) => { if (err) { reject(err); } else { resolve(result); } return; }); }); } else { - return self._identify(personGroupId, faceIds, options, optionalCallback); + return self._identify(faceIds, options, optionalCallback); } } @@ -1826,17 +1926,25 @@ class Face { * Verify whether two faces belong to a same person. Compares a face Id with a * Person Id * - * @param {uuid} faceId FaceId the face, comes from Face - Detect - * - * @param {string} personGroupId Using existing personGroupId and personId for - * fast loading a specified person. personGroupId is created in Person - * Groups.Create. + * @param {uuid} faceId FaceId of the face, comes from Face - Detect * - * @param {uuid} personId Specify a certain person in a person group. personId - * is created in Persons.Create. + * @param {uuid} personId Specify a certain person in a person group or a large + * person group. personId is created in PersonGroup Person - Create or + * LargePersonGroup Person - Create. * * @param {object} [options] Optional Parameters. * + * @param {string} [options.personGroupId] Using existing personGroupId and + * personId for fast loading a specified person. personGroupId is created in + * PersonGroup - Create. Parameter personGroupId and largePersonGroupId should + * not be provided at the same time. + * + * @param {string} [options.largePersonGroupId] Using existing + * largePersonGroupId and personId for fast loading a specified person. + * largePersonGroupId is created in LargePersonGroup - Create. Parameter + * personGroupId and largePersonGroupId should not be provided at the same + * time. + * * @param {object} [options.customHeaders] Headers that will be added to the * request * @@ -1846,11 +1954,11 @@ class Face { * * @reject {Error} - The error object. */ - verifyFaceToPersonWithHttpOperationResponse(faceId, personGroupId, personId, options) { + verifyFaceToPersonWithHttpOperationResponse(faceId, personId, options) { let client = this.client; let self = this; return new Promise((resolve, reject) => { - self._verifyFaceToPerson(faceId, personGroupId, personId, options, (err, result, request, response) => { + self._verifyFaceToPerson(faceId, personId, options, (err, result, request, response) => { let httpOperationResponse = new msRest.HttpOperationResponse(request, response); httpOperationResponse.body = result; if (err) { reject(err); } @@ -1864,17 +1972,25 @@ class Face { * Verify whether two faces belong to a same person. Compares a face Id with a * Person Id * - * @param {uuid} faceId FaceId the face, comes from Face - Detect + * @param {uuid} faceId FaceId of the face, comes from Face - Detect * - * @param {string} personGroupId Using existing personGroupId and personId for - * fast loading a specified person. personGroupId is created in Person - * Groups.Create. - * - * @param {uuid} personId Specify a certain person in a person group. personId - * is created in Persons.Create. + * @param {uuid} personId Specify a certain person in a person group or a large + * person group. personId is created in PersonGroup Person - Create or + * LargePersonGroup Person - Create. * * @param {object} [options] Optional Parameters. * + * @param {string} [options.personGroupId] Using existing personGroupId and + * personId for fast loading a specified person. personGroupId is created in + * PersonGroup - Create. Parameter personGroupId and largePersonGroupId should + * not be provided at the same time. + * + * @param {string} [options.largePersonGroupId] Using existing + * largePersonGroupId and personId for fast loading a specified person. + * largePersonGroupId is created in LargePersonGroup - Create. Parameter + * personGroupId and largePersonGroupId should not be provided at the same + * time. + * * @param {object} [options.customHeaders] Headers that will be added to the * request * @@ -1900,7 +2016,7 @@ class Face { * * {stream} [response] - The HTTP Response stream if an error did not occur. */ - verifyFaceToPerson(faceId, personGroupId, personId, options, optionalCallback) { + verifyFaceToPerson(faceId, personId, options, optionalCallback) { let client = this.client; let self = this; if (!optionalCallback && typeof options === 'function') { @@ -1909,14 +2025,14 @@ class Face { } if (!optionalCallback) { return new Promise((resolve, reject) => { - self._verifyFaceToPerson(faceId, personGroupId, personId, options, (err, result, request, response) => { + self._verifyFaceToPerson(faceId, personId, options, (err, result, request, response) => { if (err) { reject(err); } else { resolve(result); } return; }); }); } else { - return self._verifyFaceToPerson(faceId, personGroupId, personId, options, optionalCallback); + return self._verifyFaceToPerson(faceId, personId, options, optionalCallback); } } diff --git a/lib/services/face/lib/operations/index.d.ts b/lib/services/face/lib/operations/index.d.ts index ff57e7336e..1578827d29 100644 --- a/lib/services/face/lib/operations/index.d.ts +++ b/lib/services/face/lib/operations/index.d.ts @@ -24,7 +24,7 @@ export interface Face { /** * Given query face's faceId, find the similar-looking faces from a faceId - * array or a faceListId. + * array, a face list or a large face list. * * @param {uuid} faceId FaceId of the query face. User needs to call Face - * Detect first to get a valid faceId. Note that this faceId is not persisted @@ -35,12 +35,20 @@ export interface Face { * @param {string} [options.faceListId] An existing user-specified unique * candidate face list, created in Face List - Create a Face List. Face list * contains a set of persistedFaceIds which are persisted and will never - * expire. Parameter faceListId and faceIds should not be provided at the same - * time + * expire. Parameter faceListId, largeFaceListId and faceIds should not be + * provided at the same time。 + * + * @param {string} [options.largeFaceListId] An existing user-specified unique + * candidate large face list, created in LargeFaceList - Create. Large face + * list contains a set of persistedFaceIds which are persisted and will never + * expire. Parameter faceListId, largeFaceListId and faceIds should not be + * provided at the same time. * * @param {array} [options.faceIds] An array of candidate faceIds. All of them * are created by Face - Detect and the faceIds will expire 24 hours after the - * detection call. + * detection call. The number of faceIds is limited to 1000. Parameter + * faceListId, largeFaceListId and faceIds should not be provided at the same + * time. * * @param {number} [options.maxNumOfCandidatesReturned] The number of top * similar faces returned. The valid range is [1, 1000]. @@ -58,11 +66,11 @@ export interface Face { * * @reject {Error|ServiceError} - The error object. */ - findSimilarWithHttpOperationResponse(faceId: string, options?: { faceListId? : string, faceIds? : string[], maxNumOfCandidatesReturned? : number, mode? : string, customHeaders? : { [headerName: string]: string; } }): Promise>; + findSimilarWithHttpOperationResponse(faceId: string, options?: { faceListId? : string, largeFaceListId? : string, faceIds? : string[], maxNumOfCandidatesReturned? : number, mode? : string, customHeaders? : { [headerName: string]: string; } }): Promise>; /** * Given query face's faceId, find the similar-looking faces from a faceId - * array or a faceListId. + * array, a face list or a large face list. * * @param {uuid} faceId FaceId of the query face. User needs to call Face - * Detect first to get a valid faceId. Note that this faceId is not persisted @@ -73,12 +81,20 @@ export interface Face { * @param {string} [options.faceListId] An existing user-specified unique * candidate face list, created in Face List - Create a Face List. Face list * contains a set of persistedFaceIds which are persisted and will never - * expire. Parameter faceListId and faceIds should not be provided at the same - * time + * expire. Parameter faceListId, largeFaceListId and faceIds should not be + * provided at the same time。 + * + * @param {string} [options.largeFaceListId] An existing user-specified unique + * candidate large face list, created in LargeFaceList - Create. Large face + * list contains a set of persistedFaceIds which are persisted and will never + * expire. Parameter faceListId, largeFaceListId and faceIds should not be + * provided at the same time. * * @param {array} [options.faceIds] An array of candidate faceIds. All of them * are created by Face - Detect and the faceIds will expire 24 hours after the - * detection call. + * detection call. The number of faceIds is limited to 1000. Parameter + * faceListId, largeFaceListId and faceIds should not be provided at the same + * time. * * @param {number} [options.maxNumOfCandidatesReturned] The number of top * similar faces returned. The valid range is [1, 1000]. @@ -111,9 +127,9 @@ export interface Face { * * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. */ - findSimilar(faceId: string, options?: { faceListId? : string, faceIds? : string[], maxNumOfCandidatesReturned? : number, mode? : string, customHeaders? : { [headerName: string]: string; } }): Promise; + findSimilar(faceId: string, options?: { faceListId? : string, largeFaceListId? : string, faceIds? : string[], maxNumOfCandidatesReturned? : number, mode? : string, customHeaders? : { [headerName: string]: string; } }): Promise; findSimilar(faceId: string, callback: ServiceCallback): void; - findSimilar(faceId: string, options: { faceListId? : string, faceIds? : string[], maxNumOfCandidatesReturned? : number, mode? : string, customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + findSimilar(faceId: string, options: { faceListId? : string, largeFaceListId? : string, faceIds? : string[], maxNumOfCandidatesReturned? : number, mode? : string, customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; /** @@ -174,10 +190,8 @@ export interface Face { /** - * Identify unknown faces from a person group. - * - * @param {string} personGroupId PersonGroupId of the target person group, - * created by PersonGroups.Create + * 1-to-many identification to find the closest matches of the specific query + * person face from a person group or large person group. * * @param {array} faceIds Array of query faces faceIds, created by the Face - * Detect. Each of the faces are identified independently. The valid number of @@ -185,6 +199,15 @@ export interface Face { * * @param {object} [options] Optional Parameters. * + * @param {string} [options.personGroupId] PersonGroupId of the target person + * group, created by PersonGroup - Create. Parameter personGroupId and + * largePersonGroupId should not be provided at the same time. + * + * @param {string} [options.largePersonGroupId] LargePersonGroupId of the + * target large person group, created by LargePersonGroup - Create. Parameter + * personGroupId and largePersonGroupId should not be provided at the same + * time. + * * @param {number} [options.maxNumOfCandidatesReturned] The range of * maxNumOfCandidatesReturned is between 1 and 5 (default is 1). * @@ -201,13 +224,11 @@ export interface Face { * * @reject {Error|ServiceError} - The error object. */ - identifyWithHttpOperationResponse(personGroupId: string, faceIds: string[], options?: { maxNumOfCandidatesReturned? : number, confidenceThreshold? : number, customHeaders? : { [headerName: string]: string; } }): Promise>; + identifyWithHttpOperationResponse(faceIds: string[], options?: { personGroupId? : string, largePersonGroupId? : string, maxNumOfCandidatesReturned? : number, confidenceThreshold? : number, customHeaders? : { [headerName: string]: string; } }): Promise>; /** - * Identify unknown faces from a person group. - * - * @param {string} personGroupId PersonGroupId of the target person group, - * created by PersonGroups.Create + * 1-to-many identification to find the closest matches of the specific query + * person face from a person group or large person group. * * @param {array} faceIds Array of query faces faceIds, created by the Face - * Detect. Each of the faces are identified independently. The valid number of @@ -215,6 +236,15 @@ export interface Face { * * @param {object} [options] Optional Parameters. * + * @param {string} [options.personGroupId] PersonGroupId of the target person + * group, created by PersonGroup - Create. Parameter personGroupId and + * largePersonGroupId should not be provided at the same time. + * + * @param {string} [options.largePersonGroupId] LargePersonGroupId of the + * target large person group, created by LargePersonGroup - Create. Parameter + * personGroupId and largePersonGroupId should not be provided at the same + * time. + * * @param {number} [options.maxNumOfCandidatesReturned] The range of * maxNumOfCandidatesReturned is between 1 and 5 (default is 1). * @@ -246,9 +276,9 @@ export interface Face { * * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. */ - identify(personGroupId: string, faceIds: string[], options?: { maxNumOfCandidatesReturned? : number, confidenceThreshold? : number, customHeaders? : { [headerName: string]: string; } }): Promise; - identify(personGroupId: string, faceIds: string[], callback: ServiceCallback): void; - identify(personGroupId: string, faceIds: string[], options: { maxNumOfCandidatesReturned? : number, confidenceThreshold? : number, customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + identify(faceIds: string[], options?: { personGroupId? : string, largePersonGroupId? : string, maxNumOfCandidatesReturned? : number, confidenceThreshold? : number, customHeaders? : { [headerName: string]: string; } }): Promise; + identify(faceIds: string[], callback: ServiceCallback): void; + identify(faceIds: string[], options: { personGroupId? : string, largePersonGroupId? : string, maxNumOfCandidatesReturned? : number, confidenceThreshold? : number, customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; /** @@ -396,17 +426,25 @@ export interface Face { * Verify whether two faces belong to a same person. Compares a face Id with a * Person Id * - * @param {uuid} faceId FaceId the face, comes from Face - Detect + * @param {uuid} faceId FaceId of the face, comes from Face - Detect * - * @param {string} personGroupId Using existing personGroupId and personId for - * fast loading a specified person. personGroupId is created in Person - * Groups.Create. - * - * @param {uuid} personId Specify a certain person in a person group. personId - * is created in Persons.Create. + * @param {uuid} personId Specify a certain person in a person group or a large + * person group. personId is created in PersonGroup Person - Create or + * LargePersonGroup Person - Create. * * @param {object} [options] Optional Parameters. * + * @param {string} [options.personGroupId] Using existing personGroupId and + * personId for fast loading a specified person. personGroupId is created in + * PersonGroup - Create. Parameter personGroupId and largePersonGroupId should + * not be provided at the same time. + * + * @param {string} [options.largePersonGroupId] Using existing + * largePersonGroupId and personId for fast loading a specified person. + * largePersonGroupId is created in LargePersonGroup - Create. Parameter + * personGroupId and largePersonGroupId should not be provided at the same + * time. + * * @param {object} [options.customHeaders] Headers that will be added to the * request * @@ -416,23 +454,31 @@ export interface Face { * * @reject {Error|ServiceError} - The error object. */ - verifyFaceToPersonWithHttpOperationResponse(faceId: string, personGroupId: string, personId: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + verifyFaceToPersonWithHttpOperationResponse(faceId: string, personId: string, options?: { personGroupId? : string, largePersonGroupId? : string, customHeaders? : { [headerName: string]: string; } }): Promise>; /** * Verify whether two faces belong to a same person. Compares a face Id with a * Person Id * - * @param {uuid} faceId FaceId the face, comes from Face - Detect - * - * @param {string} personGroupId Using existing personGroupId and personId for - * fast loading a specified person. personGroupId is created in Person - * Groups.Create. + * @param {uuid} faceId FaceId of the face, comes from Face - Detect * - * @param {uuid} personId Specify a certain person in a person group. personId - * is created in Persons.Create. + * @param {uuid} personId Specify a certain person in a person group or a large + * person group. personId is created in PersonGroup Person - Create or + * LargePersonGroup Person - Create. * * @param {object} [options] Optional Parameters. * + * @param {string} [options.personGroupId] Using existing personGroupId and + * personId for fast loading a specified person. personGroupId is created in + * PersonGroup - Create. Parameter personGroupId and largePersonGroupId should + * not be provided at the same time. + * + * @param {string} [options.largePersonGroupId] Using existing + * largePersonGroupId and personId for fast loading a specified person. + * largePersonGroupId is created in LargePersonGroup - Create. Parameter + * personGroupId and largePersonGroupId should not be provided at the same + * time. + * * @param {object} [options.customHeaders] Headers that will be added to the * request * @@ -458,9 +504,9 @@ export interface Face { * * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. */ - verifyFaceToPerson(faceId: string, personGroupId: string, personId: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; - verifyFaceToPerson(faceId: string, personGroupId: string, personId: string, callback: ServiceCallback): void; - verifyFaceToPerson(faceId: string, personGroupId: string, personId: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + verifyFaceToPerson(faceId: string, personId: string, options?: { personGroupId? : string, largePersonGroupId? : string, customHeaders? : { [headerName: string]: string; } }): Promise; + verifyFaceToPerson(faceId: string, personId: string, callback: ServiceCallback): void; + verifyFaceToPerson(faceId: string, personId: string, options: { personGroupId? : string, largePersonGroupId? : string, customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; /** @@ -688,8 +734,8 @@ export interface PersonGroupPerson { /** - * Delete an existing person from a person group. Persisted face images of the - * person will also be deleted. + * Delete an existing person from a person group. All stored person data, and + * face features in the person entry will be deleted. * * @param {string} personGroupId Id referencing a particular person group. * @@ -709,8 +755,8 @@ export interface PersonGroupPerson { deleteMethodWithHttpOperationResponse(personGroupId: string, personId: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; /** - * Delete an existing person from a person group. Persisted face images of the - * person will also be deleted. + * Delete an existing person from a person group. All stored person data, and + * face features in the person entry will be deleted. * * @param {string} personGroupId Id referencing a particular person group. * @@ -877,8 +923,8 @@ export interface PersonGroupPerson { /** - * Delete a face from a person. Relative image for the persisted face will also - * be deleted. + * Delete a face from a person. Relative feature for the persisted face will + * also be deleted. * * @param {string} personGroupId Id referencing a particular person group. * @@ -901,8 +947,8 @@ export interface PersonGroupPerson { deleteFaceWithHttpOperationResponse(personGroupId: string, personId: string, persistedFaceId: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; /** - * Delete a face from a person. Relative image for the persisted face will also - * be deleted. + * Delete a face from a person. Relative feature for the persisted face will + * also be deleted. * * @param {string} personGroupId Id referencing a particular person group. * @@ -1325,8 +1371,8 @@ export interface PersonGroupOperations { /** - * Delete an existing person group. Persisted face images of all people in the - * person group will also be deleted. + * Delete an existing person group. Persisted face features of all people in + * the person group will also be deleted. * * @param {string} personGroupId Id referencing a particular person group. * @@ -1344,8 +1390,8 @@ export interface PersonGroupOperations { deleteMethodWithHttpOperationResponse(personGroupId: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; /** - * Delete an existing person group. Persisted face images of all people in the - * person group will also be deleted. + * Delete an existing person group. Persisted face features of all people in + * the person group will also be deleted. * * @param {string} personGroupId Id referencing a particular person group. * @@ -2201,3 +2247,2015 @@ export interface FaceListOperations { addFaceFromStream(faceListId: string, image: stream.Readable, callback: ServiceCallback): void; addFaceFromStream(faceListId: string, image: stream.Readable, options: { userData? : string, targetFace? : number[], customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; } + +/** + * @class + * LargePersonGroupPerson + * __NOTE__: An instance of this class is automatically created for an + * instance of the FaceClient. + */ +export interface LargePersonGroupPerson { + + + /** + * Create a new person in a specified large person group. + * + * @param {string} largePersonGroupId Id referencing a particular large person + * group. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.name] User defined name, maximum length is 128. + * + * @param {string} [options.userData] User specified data. Length should not + * exceed 16KB. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + createWithHttpOperationResponse(largePersonGroupId: string, options?: { name? : string, userData? : string, customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Create a new person in a specified large person group. + * + * @param {string} largePersonGroupId Id referencing a particular large person + * group. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.name] User defined name, maximum length is 128. + * + * @param {string} [options.userData] User specified data. Length should not + * exceed 16KB. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {Person} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {Person} [result] - The deserialized result object if an error did not occur. + * See {@link Person} for more information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + create(largePersonGroupId: string, options?: { name? : string, userData? : string, customHeaders? : { [headerName: string]: string; } }): Promise; + create(largePersonGroupId: string, callback: ServiceCallback): void; + create(largePersonGroupId: string, options: { name? : string, userData? : string, customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * List all persons in a large person group, and retrieve person information + * (including personId, name, userData and persistedFaceIds of registered faces + * of the person). + * + * @param {string} largePersonGroupId Id referencing a particular large person + * group. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.start] Starting person id to return (used to list a + * range of persons). + * + * @param {number} [options.top] Number of persons to return starting with the + * person id indicated by the 'start' parameter. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + listWithHttpOperationResponse(largePersonGroupId: string, options?: { start? : string, top? : number, customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * List all persons in a large person group, and retrieve person information + * (including personId, name, userData and persistedFaceIds of registered faces + * of the person). + * + * @param {string} largePersonGroupId Id referencing a particular large person + * group. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.start] Starting person id to return (used to list a + * range of persons). + * + * @param {number} [options.top] Number of persons to return starting with the + * person id indicated by the 'start' parameter. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {Array} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {Array} [result] - The deserialized result object if an error did not occur. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + list(largePersonGroupId: string, options?: { start? : string, top? : number, customHeaders? : { [headerName: string]: string; } }): Promise; + list(largePersonGroupId: string, callback: ServiceCallback): void; + list(largePersonGroupId: string, options: { start? : string, top? : number, customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Delete an existing person from a large person group. All stored person data, + * and face features in the person entry will be deleted. + * + * @param {string} largePersonGroupId Id referencing a particular large person + * group. + * + * @param {uuid} personId Id referencing a particular person. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + deleteMethodWithHttpOperationResponse(largePersonGroupId: string, personId: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Delete an existing person from a large person group. All stored person data, + * and face features in the person entry will be deleted. + * + * @param {string} largePersonGroupId Id referencing a particular large person + * group. + * + * @param {uuid} personId Id referencing a particular person. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {null} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {null} [result] - The deserialized result object if an error did not occur. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + deleteMethod(largePersonGroupId: string, personId: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + deleteMethod(largePersonGroupId: string, personId: string, callback: ServiceCallback): void; + deleteMethod(largePersonGroupId: string, personId: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Retrieve a person's information, including registered persisted faces, name + * and userData. + * + * @param {string} largePersonGroupId Id referencing a particular large person + * group. + * + * @param {uuid} personId Id referencing a particular person. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + getWithHttpOperationResponse(largePersonGroupId: string, personId: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Retrieve a person's information, including registered persisted faces, name + * and userData. + * + * @param {string} largePersonGroupId Id referencing a particular large person + * group. + * + * @param {uuid} personId Id referencing a particular person. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {Person} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {Person} [result] - The deserialized result object if an error did not occur. + * See {@link Person} for more information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + get(largePersonGroupId: string, personId: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + get(largePersonGroupId: string, personId: string, callback: ServiceCallback): void; + get(largePersonGroupId: string, personId: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Update name or userData of a person. + * + * @param {string} largePersonGroupId Id referencing a particular large person + * group. + * + * @param {uuid} personId Id referencing a particular person. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.name] User defined name, maximum length is 128. + * + * @param {string} [options.userData] User specified data. Length should not + * exceed 16KB. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + updateWithHttpOperationResponse(largePersonGroupId: string, personId: string, options?: { name? : string, userData? : string, customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Update name or userData of a person. + * + * @param {string} largePersonGroupId Id referencing a particular large person + * group. + * + * @param {uuid} personId Id referencing a particular person. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.name] User defined name, maximum length is 128. + * + * @param {string} [options.userData] User specified data. Length should not + * exceed 16KB. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {null} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {null} [result] - The deserialized result object if an error did not occur. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + update(largePersonGroupId: string, personId: string, options?: { name? : string, userData? : string, customHeaders? : { [headerName: string]: string; } }): Promise; + update(largePersonGroupId: string, personId: string, callback: ServiceCallback): void; + update(largePersonGroupId: string, personId: string, options: { name? : string, userData? : string, customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Delete a face from a person. Relative feature for the persisted face will + * also be deleted. + * + * @param {string} largePersonGroupId Id referencing a particular large person + * group. + * + * @param {uuid} personId Id referencing a particular person. + * + * @param {uuid} persistedFaceId Id referencing a particular persistedFaceId of + * an existing face. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + deleteFaceWithHttpOperationResponse(largePersonGroupId: string, personId: string, persistedFaceId: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Delete a face from a person. Relative feature for the persisted face will + * also be deleted. + * + * @param {string} largePersonGroupId Id referencing a particular large person + * group. + * + * @param {uuid} personId Id referencing a particular person. + * + * @param {uuid} persistedFaceId Id referencing a particular persistedFaceId of + * an existing face. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {null} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {null} [result] - The deserialized result object if an error did not occur. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + deleteFace(largePersonGroupId: string, personId: string, persistedFaceId: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + deleteFace(largePersonGroupId: string, personId: string, persistedFaceId: string, callback: ServiceCallback): void; + deleteFace(largePersonGroupId: string, personId: string, persistedFaceId: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Retrieve information about a persisted face (specified by persistedFaceId, + * personId and its belonging largePersonGroupId). + * + * @param {string} largePersonGroupId Id referencing a particular large person + * group. + * + * @param {uuid} personId Id referencing a particular person. + * + * @param {uuid} persistedFaceId Id referencing a particular persistedFaceId of + * an existing face. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + getFaceWithHttpOperationResponse(largePersonGroupId: string, personId: string, persistedFaceId: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Retrieve information about a persisted face (specified by persistedFaceId, + * personId and its belonging largePersonGroupId). + * + * @param {string} largePersonGroupId Id referencing a particular large person + * group. + * + * @param {uuid} personId Id referencing a particular person. + * + * @param {uuid} persistedFaceId Id referencing a particular persistedFaceId of + * an existing face. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {PersistedFace} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {PersistedFace} [result] - The deserialized result object if an error did not occur. + * See {@link PersistedFace} for more information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + getFace(largePersonGroupId: string, personId: string, persistedFaceId: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + getFace(largePersonGroupId: string, personId: string, persistedFaceId: string, callback: ServiceCallback): void; + getFace(largePersonGroupId: string, personId: string, persistedFaceId: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Update a person persisted face's userData field. + * + * @param {string} largePersonGroupId Id referencing a particular large person + * group. + * + * @param {uuid} personId Id referencing a particular person. + * + * @param {uuid} persistedFaceId Id referencing a particular persistedFaceId of + * an existing face. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.userData] User-provided data attached to the face. + * The size limit is 1KB. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + updateFaceWithHttpOperationResponse(largePersonGroupId: string, personId: string, persistedFaceId: string, options?: { userData? : string, customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Update a person persisted face's userData field. + * + * @param {string} largePersonGroupId Id referencing a particular large person + * group. + * + * @param {uuid} personId Id referencing a particular person. + * + * @param {uuid} persistedFaceId Id referencing a particular persistedFaceId of + * an existing face. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.userData] User-provided data attached to the face. + * The size limit is 1KB. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {null} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {null} [result] - The deserialized result object if an error did not occur. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + updateFace(largePersonGroupId: string, personId: string, persistedFaceId: string, options?: { userData? : string, customHeaders? : { [headerName: string]: string; } }): Promise; + updateFace(largePersonGroupId: string, personId: string, persistedFaceId: string, callback: ServiceCallback): void; + updateFace(largePersonGroupId: string, personId: string, persistedFaceId: string, options: { userData? : string, customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Add a representative face to a person for identification. The input face is + * specified as an image with a targetFace rectangle. + * + * @param {string} largePersonGroupId Id referencing a particular large person + * group. + * + * @param {uuid} personId Id referencing a particular person. + * + * @param {string} url Publicly reachable URL of an image + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.userData] User-specified data about the face for + * any purpose. The maximum length is 1KB. + * + * @param {array} [options.targetFace] A face rectangle to specify the target + * face to be added to a person in the format of + * "targetFace=left,top,width,height". E.g. "targetFace=10,10,100,100". If + * there is more than one face in the image, targetFace is required to specify + * which face to add. No targetFace means there is only one face detected in + * the entire image. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + addPersonFaceFromUrlWithHttpOperationResponse(largePersonGroupId: string, personId: string, url: string, options?: { userData? : string, targetFace? : number[], customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Add a representative face to a person for identification. The input face is + * specified as an image with a targetFace rectangle. + * + * @param {string} largePersonGroupId Id referencing a particular large person + * group. + * + * @param {uuid} personId Id referencing a particular person. + * + * @param {string} url Publicly reachable URL of an image + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.userData] User-specified data about the face for + * any purpose. The maximum length is 1KB. + * + * @param {array} [options.targetFace] A face rectangle to specify the target + * face to be added to a person in the format of + * "targetFace=left,top,width,height". E.g. "targetFace=10,10,100,100". If + * there is more than one face in the image, targetFace is required to specify + * which face to add. No targetFace means there is only one face detected in + * the entire image. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {PersistedFace} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {PersistedFace} [result] - The deserialized result object if an error did not occur. + * See {@link PersistedFace} for more information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + addPersonFaceFromUrl(largePersonGroupId: string, personId: string, url: string, options?: { userData? : string, targetFace? : number[], customHeaders? : { [headerName: string]: string; } }): Promise; + addPersonFaceFromUrl(largePersonGroupId: string, personId: string, url: string, callback: ServiceCallback): void; + addPersonFaceFromUrl(largePersonGroupId: string, personId: string, url: string, options: { userData? : string, targetFace? : number[], customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Add a representative face to a person for identification. The input face is + * specified as an image with a targetFace rectangle. + * + * @param {string} largePersonGroupId Id referencing a particular large person + * group. + * + * @param {uuid} personId Id referencing a particular person. + * + * @param {object} image An image stream. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.userData] User-specified data about the face for + * any purpose. The maximum length is 1KB. + * + * @param {array} [options.targetFace] A face rectangle to specify the target + * face to be added to a person in the format of + * "targetFace=left,top,width,height". E.g. "targetFace=10,10,100,100". If + * there is more than one face in the image, targetFace is required to specify + * which face to add. No targetFace means there is only one face detected in + * the entire image. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + addPersonFaceFromStreamWithHttpOperationResponse(largePersonGroupId: string, personId: string, image: stream.Readable, options?: { userData? : string, targetFace? : number[], customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Add a representative face to a person for identification. The input face is + * specified as an image with a targetFace rectangle. + * + * @param {string} largePersonGroupId Id referencing a particular large person + * group. + * + * @param {uuid} personId Id referencing a particular person. + * + * @param {object} image An image stream. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.userData] User-specified data about the face for + * any purpose. The maximum length is 1KB. + * + * @param {array} [options.targetFace] A face rectangle to specify the target + * face to be added to a person in the format of + * "targetFace=left,top,width,height". E.g. "targetFace=10,10,100,100". If + * there is more than one face in the image, targetFace is required to specify + * which face to add. No targetFace means there is only one face detected in + * the entire image. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {PersistedFace} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {PersistedFace} [result] - The deserialized result object if an error did not occur. + * See {@link PersistedFace} for more information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + addPersonFaceFromStream(largePersonGroupId: string, personId: string, image: stream.Readable, options?: { userData? : string, targetFace? : number[], customHeaders? : { [headerName: string]: string; } }): Promise; + addPersonFaceFromStream(largePersonGroupId: string, personId: string, image: stream.Readable, callback: ServiceCallback): void; + addPersonFaceFromStream(largePersonGroupId: string, personId: string, image: stream.Readable, options: { userData? : string, targetFace? : number[], customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; +} + +/** + * @class + * LargePersonGroupOperations + * __NOTE__: An instance of this class is automatically created for an + * instance of the FaceClient. + */ +export interface LargePersonGroupOperations { + + + /** + * Create a new large person group with specified largePersonGroupId, name and + * user-provided userData. + * + * @param {string} largePersonGroupId Id referencing a particular large person + * group. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.name] User defined name, maximum length is 128. + * + * @param {string} [options.userData] User specified data. Length should not + * exceed 16KB. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + createWithHttpOperationResponse(largePersonGroupId: string, options?: { name? : string, userData? : string, customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Create a new large person group with specified largePersonGroupId, name and + * user-provided userData. + * + * @param {string} largePersonGroupId Id referencing a particular large person + * group. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.name] User defined name, maximum length is 128. + * + * @param {string} [options.userData] User specified data. Length should not + * exceed 16KB. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {null} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {null} [result] - The deserialized result object if an error did not occur. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + create(largePersonGroupId: string, options?: { name? : string, userData? : string, customHeaders? : { [headerName: string]: string; } }): Promise; + create(largePersonGroupId: string, callback: ServiceCallback): void; + create(largePersonGroupId: string, options: { name? : string, userData? : string, customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Delete an existing large person group. Persisted face features of all people + * in the large person group will also be deleted. + * + * @param {string} largePersonGroupId Id referencing a particular large person + * group. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + deleteMethodWithHttpOperationResponse(largePersonGroupId: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Delete an existing large person group. Persisted face features of all people + * in the large person group will also be deleted. + * + * @param {string} largePersonGroupId Id referencing a particular large person + * group. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {null} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {null} [result] - The deserialized result object if an error did not occur. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + deleteMethod(largePersonGroupId: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + deleteMethod(largePersonGroupId: string, callback: ServiceCallback): void; + deleteMethod(largePersonGroupId: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Retrieve the information of a large person group, including its name and + * userData. + * + * @param {string} largePersonGroupId Id referencing a particular large person + * group. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + getWithHttpOperationResponse(largePersonGroupId: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Retrieve the information of a large person group, including its name and + * userData. + * + * @param {string} largePersonGroupId Id referencing a particular large person + * group. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {LargePersonGroup} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {LargePersonGroup} [result] - The deserialized result object if an error did not occur. + * See {@link LargePersonGroup} for more information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + get(largePersonGroupId: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + get(largePersonGroupId: string, callback: ServiceCallback): void; + get(largePersonGroupId: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Update an existing large person group's display name and userData. The + * properties which does not appear in request body will not be updated. + * + * @param {string} largePersonGroupId Id referencing a particular large person + * group. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.name] User defined name, maximum length is 128. + * + * @param {string} [options.userData] User specified data. Length should not + * exceed 16KB. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + updateWithHttpOperationResponse(largePersonGroupId: string, options?: { name? : string, userData? : string, customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Update an existing large person group's display name and userData. The + * properties which does not appear in request body will not be updated. + * + * @param {string} largePersonGroupId Id referencing a particular large person + * group. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.name] User defined name, maximum length is 128. + * + * @param {string} [options.userData] User specified data. Length should not + * exceed 16KB. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {null} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {null} [result] - The deserialized result object if an error did not occur. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + update(largePersonGroupId: string, options?: { name? : string, userData? : string, customHeaders? : { [headerName: string]: string; } }): Promise; + update(largePersonGroupId: string, callback: ServiceCallback): void; + update(largePersonGroupId: string, options: { name? : string, userData? : string, customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Retrieve the training status of a large person group (completed or ongoing). + * + * @param {string} largePersonGroupId Id referencing a particular large person + * group. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + getTrainingStatusWithHttpOperationResponse(largePersonGroupId: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Retrieve the training status of a large person group (completed or ongoing). + * + * @param {string} largePersonGroupId Id referencing a particular large person + * group. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {TrainingStatus} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {TrainingStatus} [result] - The deserialized result object if an error did not occur. + * See {@link TrainingStatus} for more information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + getTrainingStatus(largePersonGroupId: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + getTrainingStatus(largePersonGroupId: string, callback: ServiceCallback): void; + getTrainingStatus(largePersonGroupId: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * List large person groups and their information. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.start] List large person groups from the least + * largePersonGroupId greater than the "start". + * + * @param {number} [options.top] The number of large person groups to list. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + listWithHttpOperationResponse(options?: { start? : string, top? : number, customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * List large person groups and their information. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.start] List large person groups from the least + * largePersonGroupId greater than the "start". + * + * @param {number} [options.top] The number of large person groups to list. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {Array} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {Array} [result] - The deserialized result object if an error did not occur. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + list(options?: { start? : string, top? : number, customHeaders? : { [headerName: string]: string; } }): Promise; + list(callback: ServiceCallback): void; + list(options: { start? : string, top? : number, customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Queue a large person group training task, the training task may not be + * started immediately. + * + * @param {string} largePersonGroupId Id referencing a particular large person + * group. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + trainWithHttpOperationResponse(largePersonGroupId: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Queue a large person group training task, the training task may not be + * started immediately. + * + * @param {string} largePersonGroupId Id referencing a particular large person + * group. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {null} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {null} [result] - The deserialized result object if an error did not occur. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + train(largePersonGroupId: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + train(largePersonGroupId: string, callback: ServiceCallback): void; + train(largePersonGroupId: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; +} + +/** + * @class + * LargeFaceListOperations + * __NOTE__: An instance of this class is automatically created for an + * instance of the FaceClient. + */ +export interface LargeFaceListOperations { + + + /** + * Create an empty large face list. Up to 64 large face lists are allowed to + * exist in one subscription. + * + * @param {string} largeFaceListId Id referencing a particular large face list. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.name] User defined name, maximum length is 128. + * + * @param {string} [options.userData] User specified data. Length should not + * exceed 16KB. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + createWithHttpOperationResponse(largeFaceListId: string, options?: { name? : string, userData? : string, customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Create an empty large face list. Up to 64 large face lists are allowed to + * exist in one subscription. + * + * @param {string} largeFaceListId Id referencing a particular large face list. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.name] User defined name, maximum length is 128. + * + * @param {string} [options.userData] User specified data. Length should not + * exceed 16KB. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {null} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {null} [result] - The deserialized result object if an error did not occur. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + create(largeFaceListId: string, options?: { name? : string, userData? : string, customHeaders? : { [headerName: string]: string; } }): Promise; + create(largeFaceListId: string, callback: ServiceCallback): void; + create(largeFaceListId: string, options: { name? : string, userData? : string, customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Retrieve a large face list's information. + * + * @param {string} largeFaceListId Id referencing a particular large face list. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + getWithHttpOperationResponse(largeFaceListId: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Retrieve a large face list's information. + * + * @param {string} largeFaceListId Id referencing a particular large face list. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {LargeFaceList} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {LargeFaceList} [result] - The deserialized result object if an error did not occur. + * See {@link LargeFaceList} for more information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + get(largeFaceListId: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + get(largeFaceListId: string, callback: ServiceCallback): void; + get(largeFaceListId: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Update information of a large face list. + * + * @param {string} largeFaceListId Id referencing a particular large face list. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.name] User defined name, maximum length is 128. + * + * @param {string} [options.userData] User specified data. Length should not + * exceed 16KB. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + updateWithHttpOperationResponse(largeFaceListId: string, options?: { name? : string, userData? : string, customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Update information of a large face list. + * + * @param {string} largeFaceListId Id referencing a particular large face list. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.name] User defined name, maximum length is 128. + * + * @param {string} [options.userData] User specified data. Length should not + * exceed 16KB. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {null} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {null} [result] - The deserialized result object if an error did not occur. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + update(largeFaceListId: string, options?: { name? : string, userData? : string, customHeaders? : { [headerName: string]: string; } }): Promise; + update(largeFaceListId: string, callback: ServiceCallback): void; + update(largeFaceListId: string, options: { name? : string, userData? : string, customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Delete an existing large face list according to faceListId. Persisted face + * images in the large face list will also be deleted. + * + * @param {string} largeFaceListId Id referencing a particular large face list. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + deleteMethodWithHttpOperationResponse(largeFaceListId: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Delete an existing large face list according to faceListId. Persisted face + * images in the large face list will also be deleted. + * + * @param {string} largeFaceListId Id referencing a particular large face list. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {null} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {null} [result] - The deserialized result object if an error did not occur. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + deleteMethod(largeFaceListId: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + deleteMethod(largeFaceListId: string, callback: ServiceCallback): void; + deleteMethod(largeFaceListId: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Retrieve the training status of a large face list (completed or ongoing). + * + * @param {string} largeFaceListId Id referencing a particular large face list. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + getTrainingStatusWithHttpOperationResponse(largeFaceListId: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Retrieve the training status of a large face list (completed or ongoing). + * + * @param {string} largeFaceListId Id referencing a particular large face list. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {TrainingStatus} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {TrainingStatus} [result] - The deserialized result object if an error did not occur. + * See {@link TrainingStatus} for more information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + getTrainingStatus(largeFaceListId: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + getTrainingStatus(largeFaceListId: string, callback: ServiceCallback): void; + getTrainingStatus(largeFaceListId: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Retrieve information about all existing large face lists. Only + * largeFaceListId, name and userData will be returned. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + listWithHttpOperationResponse(options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Retrieve information about all existing large face lists. Only + * largeFaceListId, name and userData will be returned. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {Array} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {Array} [result] - The deserialized result object if an error did not occur. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + list(options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + list(callback: ServiceCallback): void; + list(options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Queue a large face list training task, the training task may not be started + * immediately. + * + * @param {string} largeFaceListId Id referencing a particular large face list. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + trainWithHttpOperationResponse(largeFaceListId: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Queue a large face list training task, the training task may not be started + * immediately. + * + * @param {string} largeFaceListId Id referencing a particular large face list. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {null} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {null} [result] - The deserialized result object if an error did not occur. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + train(largeFaceListId: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + train(largeFaceListId: string, callback: ServiceCallback): void; + train(largeFaceListId: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Delete an existing face from a large face list (given by a persisitedFaceId + * and a largeFaceListId). Persisted image related to the face will also be + * deleted. + * + * @param {string} largeFaceListId Id referencing a particular large face list. + * + * @param {uuid} persistedFaceId Id referencing a particular persistedFaceId of + * an existing face. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + deleteFaceWithHttpOperationResponse(largeFaceListId: string, persistedFaceId: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Delete an existing face from a large face list (given by a persisitedFaceId + * and a largeFaceListId). Persisted image related to the face will also be + * deleted. + * + * @param {string} largeFaceListId Id referencing a particular large face list. + * + * @param {uuid} persistedFaceId Id referencing a particular persistedFaceId of + * an existing face. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {null} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {null} [result] - The deserialized result object if an error did not occur. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + deleteFace(largeFaceListId: string, persistedFaceId: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + deleteFace(largeFaceListId: string, persistedFaceId: string, callback: ServiceCallback): void; + deleteFace(largeFaceListId: string, persistedFaceId: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Retrieve information about a persisted face (specified by persistedFaceId + * and its belonging largeFaceListId). + * + * @param {string} largeFaceListId Id referencing a particular large face list. + * + * @param {uuid} persistedFaceId Id referencing a particular persistedFaceId of + * an existing face. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + getFaceWithHttpOperationResponse(largeFaceListId: string, persistedFaceId: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Retrieve information about a persisted face (specified by persistedFaceId + * and its belonging largeFaceListId). + * + * @param {string} largeFaceListId Id referencing a particular large face list. + * + * @param {uuid} persistedFaceId Id referencing a particular persistedFaceId of + * an existing face. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {PersistedFace} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {PersistedFace} [result] - The deserialized result object if an error did not occur. + * See {@link PersistedFace} for more information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + getFace(largeFaceListId: string, persistedFaceId: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + getFace(largeFaceListId: string, persistedFaceId: string, callback: ServiceCallback): void; + getFace(largeFaceListId: string, persistedFaceId: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Update a persisted face's userData field. + * + * @param {string} largeFaceListId Id referencing a particular large face list. + * + * @param {uuid} persistedFaceId Id referencing a particular persistedFaceId of + * an existing face. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.userData] User-provided data attached to the face. + * The size limit is 1KB. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + updateFaceWithHttpOperationResponse(largeFaceListId: string, persistedFaceId: string, options?: { userData? : string, customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Update a persisted face's userData field. + * + * @param {string} largeFaceListId Id referencing a particular large face list. + * + * @param {uuid} persistedFaceId Id referencing a particular persistedFaceId of + * an existing face. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.userData] User-provided data attached to the face. + * The size limit is 1KB. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {null} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {null} [result] - The deserialized result object if an error did not occur. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + updateFace(largeFaceListId: string, persistedFaceId: string, options?: { userData? : string, customHeaders? : { [headerName: string]: string; } }): Promise; + updateFace(largeFaceListId: string, persistedFaceId: string, callback: ServiceCallback): void; + updateFace(largeFaceListId: string, persistedFaceId: string, options: { userData? : string, customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Add a face to a large face list. The input face is specified as an image + * with a targetFace rectangle. It returns a persistedFaceId representing the + * added face, and persistedFaceId will not expire. + * + * @param {string} largeFaceListId Id referencing a particular large face list. + * + * @param {string} url Publicly reachable URL of an image + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.userData] User-specified data about the face for + * any purpose. The maximum length is 1KB. + * + * @param {array} [options.targetFace] A face rectangle to specify the target + * face to be added to a person in the format of + * "targetFace=left,top,width,height". E.g. "targetFace=10,10,100,100". If + * there is more than one face in the image, targetFace is required to specify + * which face to add. No targetFace means there is only one face detected in + * the entire image. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + addFaceFromUrlWithHttpOperationResponse(largeFaceListId: string, url: string, options?: { userData? : string, targetFace? : number[], customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Add a face to a large face list. The input face is specified as an image + * with a targetFace rectangle. It returns a persistedFaceId representing the + * added face, and persistedFaceId will not expire. + * + * @param {string} largeFaceListId Id referencing a particular large face list. + * + * @param {string} url Publicly reachable URL of an image + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.userData] User-specified data about the face for + * any purpose. The maximum length is 1KB. + * + * @param {array} [options.targetFace] A face rectangle to specify the target + * face to be added to a person in the format of + * "targetFace=left,top,width,height". E.g. "targetFace=10,10,100,100". If + * there is more than one face in the image, targetFace is required to specify + * which face to add. No targetFace means there is only one face detected in + * the entire image. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {PersistedFace} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {PersistedFace} [result] - The deserialized result object if an error did not occur. + * See {@link PersistedFace} for more information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + addFaceFromUrl(largeFaceListId: string, url: string, options?: { userData? : string, targetFace? : number[], customHeaders? : { [headerName: string]: string; } }): Promise; + addFaceFromUrl(largeFaceListId: string, url: string, callback: ServiceCallback): void; + addFaceFromUrl(largeFaceListId: string, url: string, options: { userData? : string, targetFace? : number[], customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Add a face to a large face list. The input face is specified as an image + * with a targetFace rectangle. It returns a persistedFaceId representing the + * added face, and persistedFaceId will not expire. + * + * @param {string} largeFaceListId Id referencing a particular large face list. + * + * @param {object} image An image stream. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.userData] User-specified data about the face for + * any purpose. The maximum length is 1KB. + * + * @param {array} [options.targetFace] A face rectangle to specify the target + * face to be added to a person in the format of + * "targetFace=left,top,width,height". E.g. "targetFace=10,10,100,100". If + * there is more than one face in the image, targetFace is required to specify + * which face to add. No targetFace means there is only one face detected in + * the entire image. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + addFaceFromStreamWithHttpOperationResponse(largeFaceListId: string, image: stream.Readable, options?: { userData? : string, targetFace? : number[], customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Add a face to a large face list. The input face is specified as an image + * with a targetFace rectangle. It returns a persistedFaceId representing the + * added face, and persistedFaceId will not expire. + * + * @param {string} largeFaceListId Id referencing a particular large face list. + * + * @param {object} image An image stream. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.userData] User-specified data about the face for + * any purpose. The maximum length is 1KB. + * + * @param {array} [options.targetFace] A face rectangle to specify the target + * face to be added to a person in the format of + * "targetFace=left,top,width,height". E.g. "targetFace=10,10,100,100". If + * there is more than one face in the image, targetFace is required to specify + * which face to add. No targetFace means there is only one face detected in + * the entire image. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {PersistedFace} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {PersistedFace} [result] - The deserialized result object if an error did not occur. + * See {@link PersistedFace} for more information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + addFaceFromStream(largeFaceListId: string, image: stream.Readable, options?: { userData? : string, targetFace? : number[], customHeaders? : { [headerName: string]: string; } }): Promise; + addFaceFromStream(largeFaceListId: string, image: stream.Readable, callback: ServiceCallback): void; + addFaceFromStream(largeFaceListId: string, image: stream.Readable, options: { userData? : string, targetFace? : number[], customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; +} + +/** + * @class + * LargeFaceListFace + * __NOTE__: An instance of this class is automatically created for an + * instance of the FaceClient. + */ +export interface LargeFaceListFace { + + + /** + * List all faces in a large face list, and retrieve face information + * (including userData and persistedFaceIds of registered faces of the face). + * + * @param {string} largeFaceListId Id referencing a particular large face list. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.start] Starting face id to return (used to list a + * range of faces). + * + * @param {number} [options.top] Number of faces to return starting with the + * face id indicated by the 'start' parameter. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + listWithHttpOperationResponse(largeFaceListId: string, options?: { start? : string, top? : number, customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * List all faces in a large face list, and retrieve face information + * (including userData and persistedFaceIds of registered faces of the face). + * + * @param {string} largeFaceListId Id referencing a particular large face list. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.start] Starting face id to return (used to list a + * range of faces). + * + * @param {number} [options.top] Number of faces to return starting with the + * face id indicated by the 'start' parameter. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {Array} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {Array} [result] - The deserialized result object if an error did not occur. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + list(largeFaceListId: string, options?: { start? : string, top? : number, customHeaders? : { [headerName: string]: string; } }): Promise; + list(largeFaceListId: string, callback: ServiceCallback): void; + list(largeFaceListId: string, options: { start? : string, top? : number, customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; +} diff --git a/lib/services/face/lib/operations/index.js b/lib/services/face/lib/operations/index.js index d3ce008a0a..032c687225 100644 --- a/lib/services/face/lib/operations/index.js +++ b/lib/services/face/lib/operations/index.js @@ -18,3 +18,7 @@ exports.Face = require('./face'); exports.PersonGroupPerson = require('./personGroupPerson'); exports.PersonGroupOperations = require('./personGroupOperations'); exports.FaceListOperations = require('./faceListOperations'); +exports.LargePersonGroupPerson = require('./largePersonGroupPerson'); +exports.LargePersonGroupOperations = require('./largePersonGroupOperations'); +exports.LargeFaceListOperations = require('./largeFaceListOperations'); +exports.LargeFaceListFace = require('./largeFaceListFace'); diff --git a/lib/services/face/lib/operations/largeFaceListFace.js b/lib/services/face/lib/operations/largeFaceListFace.js new file mode 100644 index 0000000000..ab6abd4743 --- /dev/null +++ b/lib/services/face/lib/operations/largeFaceListFace.js @@ -0,0 +1,305 @@ +/* + * 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'; + +const msRest = require('ms-rest'); +const WebResource = msRest.WebResource; + +/** + * List all faces in a large face list, and retrieve face information + * (including userData and persistedFaceIds of registered faces of the face). + * + * @param {string} largeFaceListId Id referencing a particular large face list. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.start] Starting face id to return (used to list a + * range of faces). + * + * @param {number} [options.top] Number of faces to return starting with the + * face id indicated by the 'start' parameter. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {array} [result] - The deserialized result object if an error did not occur. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _list(largeFaceListId, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + let start = (options && options.start !== undefined) ? options.start : undefined; + let top = (options && options.top !== undefined) ? options.top : undefined; + // Validate + try { + if (this.client.endpoint === null || this.client.endpoint === undefined || typeof this.client.endpoint.valueOf() !== 'string') { + throw new Error('this.client.endpoint cannot be null or undefined and it must be of type string.'); + } + if (largeFaceListId === null || largeFaceListId === undefined || typeof largeFaceListId.valueOf() !== 'string') { + throw new Error('largeFaceListId cannot be null or undefined and it must be of type string.'); + } + if (largeFaceListId !== null && largeFaceListId !== undefined) { + if (largeFaceListId.length > 64) + { + throw new Error('"largeFaceListId" should satisfy the constraint - "MaxLength": 64'); + } + if (largeFaceListId.match(/^[a-z0-9-_]+$/) === null) + { + throw new Error('"largeFaceListId" should satisfy the constraint - "Pattern": /^[a-z0-9-_]+$/'); + } + } + if (start !== null && start !== undefined && typeof start.valueOf() !== 'string') { + throw new Error('start must be of type string.'); + } + if (top !== null && top !== undefined && typeof top !== 'number') { + throw new Error('top must be of type number.'); + } + if (top !== null && top !== undefined) { + if (top > 1000) + { + throw new Error('"top" should satisfy the constraint - "InclusiveMaximum": 1000'); + } + if (top < 1) + { + throw new Error('"top" should satisfy the constraint - "InclusiveMinimum": 1'); + } + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'largefacelists/{largeFaceListId}/persistedFaces'; + requestUrl = requestUrl.replace('{Endpoint}', this.client.endpoint); + requestUrl = requestUrl.replace('{largeFaceListId}', encodeURIComponent(largeFaceListId)); + let queryParameters = []; + if (start !== null && start !== undefined) { + queryParameters.push('start=' + encodeURIComponent(start)); + } + if (top !== null && top !== undefined) { + queryParameters.push('top=' + encodeURIComponent(top.toString())); + } + if (queryParameters.length > 0) { + requestUrl += '?' + queryParameters.join('&'); + } + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'GET'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['APIError']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + // Deserialize Response + if (statusCode === 200) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = { + required: false, + serializedName: 'parsedResponse', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'PersistedFaceElementType', + type: { + name: 'Composite', + className: 'PersistedFace' + } + } + } + }; + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** Class representing a LargeFaceListFace. */ +class LargeFaceListFace { + /** + * Create a LargeFaceListFace. + * @param {FaceClient} client Reference to the service client. + */ + constructor(client) { + this.client = client; + this._list = _list; + } + + /** + * List all faces in a large face list, and retrieve face information + * (including userData and persistedFaceIds of registered faces of the face). + * + * @param {string} largeFaceListId Id referencing a particular large face list. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.start] Starting face id to return (used to list a + * range of faces). + * + * @param {number} [options.top] Number of faces to return starting with the + * face id indicated by the 'start' parameter. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + listWithHttpOperationResponse(largeFaceListId, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._list(largeFaceListId, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * List all faces in a large face list, and retrieve face information + * (including userData and persistedFaceIds of registered faces of the face). + * + * @param {string} largeFaceListId Id referencing a particular large face list. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.start] Starting face id to return (used to list a + * range of faces). + * + * @param {number} [options.top] Number of faces to return starting with the + * face id indicated by the 'start' parameter. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {Array} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {array} [result] - The deserialized result object if an error did not occur. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + list(largeFaceListId, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._list(largeFaceListId, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._list(largeFaceListId, options, optionalCallback); + } + } + +} + +module.exports = LargeFaceListFace; diff --git a/lib/services/face/lib/operations/largeFaceListOperations.js b/lib/services/face/lib/operations/largeFaceListOperations.js new file mode 100644 index 0000000000..e500e306aa --- /dev/null +++ b/lib/services/face/lib/operations/largeFaceListOperations.js @@ -0,0 +1,2873 @@ +/* + * 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'; + +const msRest = require('ms-rest'); +const WebResource = msRest.WebResource; + +/** + * Create an empty large face list. Up to 64 large face lists are allowed to + * exist in one subscription. + * + * @param {string} largeFaceListId Id referencing a particular large face list. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.name] User defined name, maximum length is 128. + * + * @param {string} [options.userData] User specified data. Length should not + * exceed 16KB. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {null} [result] - The deserialized result object if an error did not occur. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _create(largeFaceListId, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + let name = (options && options.name !== undefined) ? options.name : undefined; + let userData = (options && options.userData !== undefined) ? options.userData : undefined; + // Validate + try { + if (this.client.endpoint === null || this.client.endpoint === undefined || typeof this.client.endpoint.valueOf() !== 'string') { + throw new Error('this.client.endpoint cannot be null or undefined and it must be of type string.'); + } + if (largeFaceListId === null || largeFaceListId === undefined || typeof largeFaceListId.valueOf() !== 'string') { + throw new Error('largeFaceListId cannot be null or undefined and it must be of type string.'); + } + if (largeFaceListId !== null && largeFaceListId !== undefined) { + if (largeFaceListId.length > 64) + { + throw new Error('"largeFaceListId" should satisfy the constraint - "MaxLength": 64'); + } + if (largeFaceListId.match(/^[a-z0-9-_]+$/) === null) + { + throw new Error('"largeFaceListId" should satisfy the constraint - "Pattern": /^[a-z0-9-_]+$/'); + } + } + if (name !== null && name !== undefined && typeof name.valueOf() !== 'string') { + throw new Error('name must be of type string.'); + } + if (name !== null && name !== undefined) { + if (name.length > 128) + { + throw new Error('"name" should satisfy the constraint - "MaxLength": 128'); + } + } + if (userData !== null && userData !== undefined && typeof userData.valueOf() !== 'string') { + throw new Error('userData must be of type string.'); + } + if (userData !== null && userData !== undefined) { + if (userData.length > 16384) + { + throw new Error('"userData" should satisfy the constraint - "MaxLength": 16384'); + } + } + } catch (error) { + return callback(error); + } + let body; + if ((name !== null && name !== undefined) || (userData !== null && userData !== undefined)) { + body = new client.models['NameAndUserDataContract'](); + body.name = name; + body.userData = userData; + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'largefacelists/{largeFaceListId}'; + requestUrl = requestUrl.replace('{Endpoint}', this.client.endpoint); + requestUrl = requestUrl.replace('{largeFaceListId}', encodeURIComponent(largeFaceListId)); + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'PUT'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + // Serialize Request + let requestContent = null; + let requestModel = null; + try { + if (body !== null && body !== undefined) { + let requestModelMapper = new client.models['NameAndUserDataContract']().mapper(); + requestModel = client.serialize(requestModelMapper, body, 'body'); + requestContent = JSON.stringify(requestModel); + } + } catch (error) { + let serializationError = new Error(`Error "${error.message}" occurred in serializing the ` + + `payload - ${JSON.stringify(body, null, 2)}.`); + return callback(serializationError); + } + httpRequest.body = requestContent; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['APIError']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + + return callback(null, result, httpRequest, response); + }); +} + +/** + * Retrieve a large face list's information. + * + * @param {string} largeFaceListId Id referencing a particular large face list. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link LargeFaceList} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _get(largeFaceListId, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + // Validate + try { + if (this.client.endpoint === null || this.client.endpoint === undefined || typeof this.client.endpoint.valueOf() !== 'string') { + throw new Error('this.client.endpoint cannot be null or undefined and it must be of type string.'); + } + if (largeFaceListId === null || largeFaceListId === undefined || typeof largeFaceListId.valueOf() !== 'string') { + throw new Error('largeFaceListId cannot be null or undefined and it must be of type string.'); + } + if (largeFaceListId !== null && largeFaceListId !== undefined) { + if (largeFaceListId.length > 64) + { + throw new Error('"largeFaceListId" should satisfy the constraint - "MaxLength": 64'); + } + if (largeFaceListId.match(/^[a-z0-9-_]+$/) === null) + { + throw new Error('"largeFaceListId" should satisfy the constraint - "Pattern": /^[a-z0-9-_]+$/'); + } + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'largefacelists/{largeFaceListId}'; + requestUrl = requestUrl.replace('{Endpoint}', this.client.endpoint); + requestUrl = requestUrl.replace('{largeFaceListId}', encodeURIComponent(largeFaceListId)); + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'GET'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['APIError']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + // Deserialize Response + if (statusCode === 200) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['LargeFaceList']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** + * Update information of a large face list. + * + * @param {string} largeFaceListId Id referencing a particular large face list. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.name] User defined name, maximum length is 128. + * + * @param {string} [options.userData] User specified data. Length should not + * exceed 16KB. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {null} [result] - The deserialized result object if an error did not occur. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _update(largeFaceListId, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + let name = (options && options.name !== undefined) ? options.name : undefined; + let userData = (options && options.userData !== undefined) ? options.userData : undefined; + // Validate + try { + if (this.client.endpoint === null || this.client.endpoint === undefined || typeof this.client.endpoint.valueOf() !== 'string') { + throw new Error('this.client.endpoint cannot be null or undefined and it must be of type string.'); + } + if (largeFaceListId === null || largeFaceListId === undefined || typeof largeFaceListId.valueOf() !== 'string') { + throw new Error('largeFaceListId cannot be null or undefined and it must be of type string.'); + } + if (largeFaceListId !== null && largeFaceListId !== undefined) { + if (largeFaceListId.length > 64) + { + throw new Error('"largeFaceListId" should satisfy the constraint - "MaxLength": 64'); + } + if (largeFaceListId.match(/^[a-z0-9-_]+$/) === null) + { + throw new Error('"largeFaceListId" should satisfy the constraint - "Pattern": /^[a-z0-9-_]+$/'); + } + } + if (name !== null && name !== undefined && typeof name.valueOf() !== 'string') { + throw new Error('name must be of type string.'); + } + if (name !== null && name !== undefined) { + if (name.length > 128) + { + throw new Error('"name" should satisfy the constraint - "MaxLength": 128'); + } + } + if (userData !== null && userData !== undefined && typeof userData.valueOf() !== 'string') { + throw new Error('userData must be of type string.'); + } + if (userData !== null && userData !== undefined) { + if (userData.length > 16384) + { + throw new Error('"userData" should satisfy the constraint - "MaxLength": 16384'); + } + } + } catch (error) { + return callback(error); + } + let body; + if ((name !== null && name !== undefined) || (userData !== null && userData !== undefined)) { + body = new client.models['NameAndUserDataContract'](); + body.name = name; + body.userData = userData; + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'largefacelists/{largeFaceListId}'; + requestUrl = requestUrl.replace('{Endpoint}', this.client.endpoint); + requestUrl = requestUrl.replace('{largeFaceListId}', encodeURIComponent(largeFaceListId)); + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'PATCH'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + // Serialize Request + let requestContent = null; + let requestModel = null; + try { + if (body !== null && body !== undefined) { + let requestModelMapper = new client.models['NameAndUserDataContract']().mapper(); + requestModel = client.serialize(requestModelMapper, body, 'body'); + requestContent = JSON.stringify(requestModel); + } + } catch (error) { + let serializationError = new Error(`Error "${error.message}" occurred in serializing the ` + + `payload - ${JSON.stringify(body, null, 2)}.`); + return callback(serializationError); + } + httpRequest.body = requestContent; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['APIError']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + + return callback(null, result, httpRequest, response); + }); +} + +/** + * Delete an existing large face list according to faceListId. Persisted face + * images in the large face list will also be deleted. + * + * @param {string} largeFaceListId Id referencing a particular large face list. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {null} [result] - The deserialized result object if an error did not occur. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _deleteMethod(largeFaceListId, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + // Validate + try { + if (this.client.endpoint === null || this.client.endpoint === undefined || typeof this.client.endpoint.valueOf() !== 'string') { + throw new Error('this.client.endpoint cannot be null or undefined and it must be of type string.'); + } + if (largeFaceListId === null || largeFaceListId === undefined || typeof largeFaceListId.valueOf() !== 'string') { + throw new Error('largeFaceListId cannot be null or undefined and it must be of type string.'); + } + if (largeFaceListId !== null && largeFaceListId !== undefined) { + if (largeFaceListId.length > 64) + { + throw new Error('"largeFaceListId" should satisfy the constraint - "MaxLength": 64'); + } + if (largeFaceListId.match(/^[a-z0-9-_]+$/) === null) + { + throw new Error('"largeFaceListId" should satisfy the constraint - "Pattern": /^[a-z0-9-_]+$/'); + } + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'largefacelists/{largeFaceListId}'; + requestUrl = requestUrl.replace('{Endpoint}', this.client.endpoint); + requestUrl = requestUrl.replace('{largeFaceListId}', encodeURIComponent(largeFaceListId)); + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'DELETE'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['APIError']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + + return callback(null, result, httpRequest, response); + }); +} + +/** + * Retrieve the training status of a large face list (completed or ongoing). + * + * @param {string} largeFaceListId Id referencing a particular large face list. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link TrainingStatus} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _getTrainingStatus(largeFaceListId, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + // Validate + try { + if (this.client.endpoint === null || this.client.endpoint === undefined || typeof this.client.endpoint.valueOf() !== 'string') { + throw new Error('this.client.endpoint cannot be null or undefined and it must be of type string.'); + } + if (largeFaceListId === null || largeFaceListId === undefined || typeof largeFaceListId.valueOf() !== 'string') { + throw new Error('largeFaceListId cannot be null or undefined and it must be of type string.'); + } + if (largeFaceListId !== null && largeFaceListId !== undefined) { + if (largeFaceListId.length > 64) + { + throw new Error('"largeFaceListId" should satisfy the constraint - "MaxLength": 64'); + } + if (largeFaceListId.match(/^[a-z0-9-_]+$/) === null) + { + throw new Error('"largeFaceListId" should satisfy the constraint - "Pattern": /^[a-z0-9-_]+$/'); + } + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'largefacelists/{largeFaceListId}/training'; + requestUrl = requestUrl.replace('{Endpoint}', this.client.endpoint); + requestUrl = requestUrl.replace('{largeFaceListId}', encodeURIComponent(largeFaceListId)); + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'GET'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['APIError']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + // Deserialize Response + if (statusCode === 200) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['TrainingStatus']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** + * Retrieve information about all existing large face lists. Only + * largeFaceListId, name and userData will be returned. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {array} [result] - The deserialized result object if an error did not occur. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _list(options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + // Validate + try { + if (this.client.endpoint === null || this.client.endpoint === undefined || typeof this.client.endpoint.valueOf() !== 'string') { + throw new Error('this.client.endpoint cannot be null or undefined and it must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'largefacelists'; + requestUrl = requestUrl.replace('{Endpoint}', this.client.endpoint); + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'GET'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['APIError']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + // Deserialize Response + if (statusCode === 200) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = { + required: false, + serializedName: 'parsedResponse', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'LargeFaceListElementType', + type: { + name: 'Composite', + className: 'LargeFaceList' + } + } + } + }; + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** + * Queue a large face list training task, the training task may not be started + * immediately. + * + * @param {string} largeFaceListId Id referencing a particular large face list. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {null} [result] - The deserialized result object if an error did not occur. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _train(largeFaceListId, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + // Validate + try { + if (this.client.endpoint === null || this.client.endpoint === undefined || typeof this.client.endpoint.valueOf() !== 'string') { + throw new Error('this.client.endpoint cannot be null or undefined and it must be of type string.'); + } + if (largeFaceListId === null || largeFaceListId === undefined || typeof largeFaceListId.valueOf() !== 'string') { + throw new Error('largeFaceListId cannot be null or undefined and it must be of type string.'); + } + if (largeFaceListId !== null && largeFaceListId !== undefined) { + if (largeFaceListId.length > 64) + { + throw new Error('"largeFaceListId" should satisfy the constraint - "MaxLength": 64'); + } + if (largeFaceListId.match(/^[a-z0-9-_]+$/) === null) + { + throw new Error('"largeFaceListId" should satisfy the constraint - "Pattern": /^[a-z0-9-_]+$/'); + } + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'largefacelists/{largeFaceListId}/train'; + requestUrl = requestUrl.replace('{Endpoint}', this.client.endpoint); + requestUrl = requestUrl.replace('{largeFaceListId}', encodeURIComponent(largeFaceListId)); + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'POST'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 202) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['APIError']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + + return callback(null, result, httpRequest, response); + }); +} + +/** + * Delete an existing face from a large face list (given by a persisitedFaceId + * and a largeFaceListId). Persisted image related to the face will also be + * deleted. + * + * @param {string} largeFaceListId Id referencing a particular large face list. + * + * @param {uuid} persistedFaceId Id referencing a particular persistedFaceId of + * an existing face. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {null} [result] - The deserialized result object if an error did not occur. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _deleteFace(largeFaceListId, persistedFaceId, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + // Validate + try { + if (this.client.endpoint === null || this.client.endpoint === undefined || typeof this.client.endpoint.valueOf() !== 'string') { + throw new Error('this.client.endpoint cannot be null or undefined and it must be of type string.'); + } + if (largeFaceListId === null || largeFaceListId === undefined || typeof largeFaceListId.valueOf() !== 'string') { + throw new Error('largeFaceListId cannot be null or undefined and it must be of type string.'); + } + if (largeFaceListId !== null && largeFaceListId !== undefined) { + if (largeFaceListId.length > 64) + { + throw new Error('"largeFaceListId" should satisfy the constraint - "MaxLength": 64'); + } + if (largeFaceListId.match(/^[a-z0-9-_]+$/) === null) + { + throw new Error('"largeFaceListId" should satisfy the constraint - "Pattern": /^[a-z0-9-_]+$/'); + } + } + if (persistedFaceId === null || persistedFaceId === undefined || typeof persistedFaceId.valueOf() !== 'string' || !msRest.isValidUuid(persistedFaceId)) { + throw new Error('persistedFaceId cannot be null or undefined and it must be of type string and must be a valid uuid.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'largefacelists/{largeFaceListId}/persistedFaces/{persistedFaceId}'; + requestUrl = requestUrl.replace('{Endpoint}', this.client.endpoint); + requestUrl = requestUrl.replace('{largeFaceListId}', encodeURIComponent(largeFaceListId)); + requestUrl = requestUrl.replace('{persistedFaceId}', encodeURIComponent(persistedFaceId.toString())); + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'DELETE'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['APIError']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + + return callback(null, result, httpRequest, response); + }); +} + +/** + * Retrieve information about a persisted face (specified by persistedFaceId + * and its belonging largeFaceListId). + * + * @param {string} largeFaceListId Id referencing a particular large face list. + * + * @param {uuid} persistedFaceId Id referencing a particular persistedFaceId of + * an existing face. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link PersistedFace} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _getFace(largeFaceListId, persistedFaceId, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + // Validate + try { + if (this.client.endpoint === null || this.client.endpoint === undefined || typeof this.client.endpoint.valueOf() !== 'string') { + throw new Error('this.client.endpoint cannot be null or undefined and it must be of type string.'); + } + if (largeFaceListId === null || largeFaceListId === undefined || typeof largeFaceListId.valueOf() !== 'string') { + throw new Error('largeFaceListId cannot be null or undefined and it must be of type string.'); + } + if (largeFaceListId !== null && largeFaceListId !== undefined) { + if (largeFaceListId.length > 64) + { + throw new Error('"largeFaceListId" should satisfy the constraint - "MaxLength": 64'); + } + if (largeFaceListId.match(/^[a-z0-9-_]+$/) === null) + { + throw new Error('"largeFaceListId" should satisfy the constraint - "Pattern": /^[a-z0-9-_]+$/'); + } + } + if (persistedFaceId === null || persistedFaceId === undefined || typeof persistedFaceId.valueOf() !== 'string' || !msRest.isValidUuid(persistedFaceId)) { + throw new Error('persistedFaceId cannot be null or undefined and it must be of type string and must be a valid uuid.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'largefacelists/{largeFaceListId}/persistedFaces/{persistedFaceId}'; + requestUrl = requestUrl.replace('{Endpoint}', this.client.endpoint); + requestUrl = requestUrl.replace('{largeFaceListId}', encodeURIComponent(largeFaceListId)); + requestUrl = requestUrl.replace('{persistedFaceId}', encodeURIComponent(persistedFaceId.toString())); + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'GET'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['APIError']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + // Deserialize Response + if (statusCode === 200) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['PersistedFace']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** + * Update a persisted face's userData field. + * + * @param {string} largeFaceListId Id referencing a particular large face list. + * + * @param {uuid} persistedFaceId Id referencing a particular persistedFaceId of + * an existing face. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.userData] User-provided data attached to the face. + * The size limit is 1KB. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {null} [result] - The deserialized result object if an error did not occur. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _updateFace(largeFaceListId, persistedFaceId, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + let userData = (options && options.userData !== undefined) ? options.userData : undefined; + // Validate + try { + if (this.client.endpoint === null || this.client.endpoint === undefined || typeof this.client.endpoint.valueOf() !== 'string') { + throw new Error('this.client.endpoint cannot be null or undefined and it must be of type string.'); + } + if (largeFaceListId === null || largeFaceListId === undefined || typeof largeFaceListId.valueOf() !== 'string') { + throw new Error('largeFaceListId cannot be null or undefined and it must be of type string.'); + } + if (largeFaceListId !== null && largeFaceListId !== undefined) { + if (largeFaceListId.length > 64) + { + throw new Error('"largeFaceListId" should satisfy the constraint - "MaxLength": 64'); + } + if (largeFaceListId.match(/^[a-z0-9-_]+$/) === null) + { + throw new Error('"largeFaceListId" should satisfy the constraint - "Pattern": /^[a-z0-9-_]+$/'); + } + } + if (persistedFaceId === null || persistedFaceId === undefined || typeof persistedFaceId.valueOf() !== 'string' || !msRest.isValidUuid(persistedFaceId)) { + throw new Error('persistedFaceId cannot be null or undefined and it must be of type string and must be a valid uuid.'); + } + if (userData !== null && userData !== undefined && typeof userData.valueOf() !== 'string') { + throw new Error('userData must be of type string.'); + } + if (userData !== null && userData !== undefined) { + if (userData.length > 1024) + { + throw new Error('"userData" should satisfy the constraint - "MaxLength": 1024'); + } + } + } catch (error) { + return callback(error); + } + let body; + if (userData !== null && userData !== undefined) { + body = new client.models['UpdateFaceRequest'](); + body.userData = userData; + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'largefacelists/{largeFaceListId}/persistedFaces/{persistedFaceId}'; + requestUrl = requestUrl.replace('{Endpoint}', this.client.endpoint); + requestUrl = requestUrl.replace('{largeFaceListId}', encodeURIComponent(largeFaceListId)); + requestUrl = requestUrl.replace('{persistedFaceId}', encodeURIComponent(persistedFaceId.toString())); + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'PATCH'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + // Serialize Request + let requestContent = null; + let requestModel = null; + try { + if (body !== null && body !== undefined) { + let requestModelMapper = new client.models['UpdateFaceRequest']().mapper(); + requestModel = client.serialize(requestModelMapper, body, 'body'); + requestContent = JSON.stringify(requestModel); + } + } catch (error) { + let serializationError = new Error(`Error "${error.message}" occurred in serializing the ` + + `payload - ${JSON.stringify(body, null, 2)}.`); + return callback(serializationError); + } + httpRequest.body = requestContent; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['APIError']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + + return callback(null, result, httpRequest, response); + }); +} + +/** + * Add a face to a large face list. The input face is specified as an image + * with a targetFace rectangle. It returns a persistedFaceId representing the + * added face, and persistedFaceId will not expire. + * + * @param {string} largeFaceListId Id referencing a particular large face list. + * + * @param {string} url Publicly reachable URL of an image + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.userData] User-specified data about the face for + * any purpose. The maximum length is 1KB. + * + * @param {array} [options.targetFace] A face rectangle to specify the target + * face to be added to a person in the format of + * "targetFace=left,top,width,height". E.g. "targetFace=10,10,100,100". If + * there is more than one face in the image, targetFace is required to specify + * which face to add. No targetFace means there is only one face detected in + * the entire image. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link PersistedFace} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _addFaceFromUrl(largeFaceListId, url, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + let userData = (options && options.userData !== undefined) ? options.userData : undefined; + let targetFace = (options && options.targetFace !== undefined) ? options.targetFace : undefined; + // Validate + try { + if (this.client.endpoint === null || this.client.endpoint === undefined || typeof this.client.endpoint.valueOf() !== 'string') { + throw new Error('this.client.endpoint cannot be null or undefined and it must be of type string.'); + } + if (largeFaceListId === null || largeFaceListId === undefined || typeof largeFaceListId.valueOf() !== 'string') { + throw new Error('largeFaceListId cannot be null or undefined and it must be of type string.'); + } + if (largeFaceListId !== null && largeFaceListId !== undefined) { + if (largeFaceListId.length > 64) + { + throw new Error('"largeFaceListId" should satisfy the constraint - "MaxLength": 64'); + } + if (largeFaceListId.match(/^[a-z0-9-_]+$/) === null) + { + throw new Error('"largeFaceListId" should satisfy the constraint - "Pattern": /^[a-z0-9-_]+$/'); + } + } + if (userData !== null && userData !== undefined && typeof userData.valueOf() !== 'string') { + throw new Error('userData must be of type string.'); + } + if (userData !== null && userData !== undefined) { + if (userData.length > 1024) + { + throw new Error('"userData" should satisfy the constraint - "MaxLength": 1024'); + } + } + if (Array.isArray(targetFace)) { + for (let i = 0; i < targetFace.length; i++) { + if (targetFace[i] !== null && targetFace[i] !== undefined && typeof targetFace[i] !== 'number') { + throw new Error('targetFace[i] must be of type number.'); + } + } + } + if (url === null || url === undefined || typeof url.valueOf() !== 'string') { + throw new Error('url cannot be null or undefined and it must be of type string.'); + } + } catch (error) { + return callback(error); + } + let imageUrl; + if (url !== null && url !== undefined) { + imageUrl = new client.models['ImageUrl'](); + imageUrl.url = url; + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'largefacelists/{largeFaceListId}/persistedFaces'; + requestUrl = requestUrl.replace('{Endpoint}', this.client.endpoint); + requestUrl = requestUrl.replace('{largeFaceListId}', encodeURIComponent(largeFaceListId)); + let queryParameters = []; + if (userData !== null && userData !== undefined) { + queryParameters.push('userData=' + encodeURIComponent(userData)); + } + if (targetFace !== null && targetFace !== undefined) { + queryParameters.push('targetFace=' + encodeURIComponent(targetFace.join(','))); + } + if (queryParameters.length > 0) { + requestUrl += '?' + queryParameters.join('&'); + } + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'POST'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + // Serialize Request + let requestContent = null; + let requestModel = null; + try { + if (imageUrl !== null && imageUrl !== undefined) { + let requestModelMapper = new client.models['ImageUrl']().mapper(); + requestModel = client.serialize(requestModelMapper, imageUrl, 'imageUrl'); + requestContent = JSON.stringify(requestModel); + } + } catch (error) { + let serializationError = new Error(`Error "${error.message}" occurred in serializing the ` + + `payload - ${JSON.stringify(imageUrl, null, 2)}.`); + return callback(serializationError); + } + httpRequest.body = requestContent; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['APIError']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + // Deserialize Response + if (statusCode === 200) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['PersistedFace']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** + * Add a face to a large face list. The input face is specified as an image + * with a targetFace rectangle. It returns a persistedFaceId representing the + * added face, and persistedFaceId will not expire. + * + * @param {string} largeFaceListId Id referencing a particular large face list. + * + * @param {object} image An image stream. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.userData] User-specified data about the face for + * any purpose. The maximum length is 1KB. + * + * @param {array} [options.targetFace] A face rectangle to specify the target + * face to be added to a person in the format of + * "targetFace=left,top,width,height". E.g. "targetFace=10,10,100,100". If + * there is more than one face in the image, targetFace is required to specify + * which face to add. No targetFace means there is only one face detected in + * the entire image. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link PersistedFace} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _addFaceFromStream(largeFaceListId, image, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + let userData = (options && options.userData !== undefined) ? options.userData : undefined; + let targetFace = (options && options.targetFace !== undefined) ? options.targetFace : undefined; + // Validate + try { + if (this.client.endpoint === null || this.client.endpoint === undefined || typeof this.client.endpoint.valueOf() !== 'string') { + throw new Error('this.client.endpoint cannot be null or undefined and it must be of type string.'); + } + if (largeFaceListId === null || largeFaceListId === undefined || typeof largeFaceListId.valueOf() !== 'string') { + throw new Error('largeFaceListId cannot be null or undefined and it must be of type string.'); + } + if (largeFaceListId !== null && largeFaceListId !== undefined) { + if (largeFaceListId.length > 64) + { + throw new Error('"largeFaceListId" should satisfy the constraint - "MaxLength": 64'); + } + if (largeFaceListId.match(/^[a-z0-9-_]+$/) === null) + { + throw new Error('"largeFaceListId" should satisfy the constraint - "Pattern": /^[a-z0-9-_]+$/'); + } + } + if (userData !== null && userData !== undefined && typeof userData.valueOf() !== 'string') { + throw new Error('userData must be of type string.'); + } + if (userData !== null && userData !== undefined) { + if (userData.length > 1024) + { + throw new Error('"userData" should satisfy the constraint - "MaxLength": 1024'); + } + } + if (Array.isArray(targetFace)) { + for (let i = 0; i < targetFace.length; i++) { + if (targetFace[i] !== null && targetFace[i] !== undefined && typeof targetFace[i] !== 'number') { + throw new Error('targetFace[i] must be of type number.'); + } + } + } + if (image === null || image === undefined) { + throw new Error('image cannot be null or undefined and it must be of type object.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'largefacelists/{largeFaceListId}/persistedFaces'; + requestUrl = requestUrl.replace('{Endpoint}', this.client.endpoint); + requestUrl = requestUrl.replace('{largeFaceListId}', encodeURIComponent(largeFaceListId)); + let queryParameters = []; + if (userData !== null && userData !== undefined) { + queryParameters.push('userData=' + encodeURIComponent(userData)); + } + if (targetFace !== null && targetFace !== undefined) { + queryParameters.push('targetFace=' + encodeURIComponent(targetFace.join(','))); + } + if (queryParameters.length > 0) { + requestUrl += '?' + queryParameters.join('&'); + } + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'POST'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/octet-stream'; + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + // Serialize Request + let requestContent = image; + httpRequest.body = requestContent; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['APIError']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + // Deserialize Response + if (statusCode === 200) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['PersistedFace']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** Class representing a LargeFaceListOperations. */ +class LargeFaceListOperations { + /** + * Create a LargeFaceListOperations. + * @param {FaceClient} client Reference to the service client. + */ + constructor(client) { + this.client = client; + this._create = _create; + this._get = _get; + this._update = _update; + this._deleteMethod = _deleteMethod; + this._getTrainingStatus = _getTrainingStatus; + this._list = _list; + this._train = _train; + this._deleteFace = _deleteFace; + this._getFace = _getFace; + this._updateFace = _updateFace; + this._addFaceFromUrl = _addFaceFromUrl; + this._addFaceFromStream = _addFaceFromStream; + } + + /** + * Create an empty large face list. Up to 64 large face lists are allowed to + * exist in one subscription. + * + * @param {string} largeFaceListId Id referencing a particular large face list. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.name] User defined name, maximum length is 128. + * + * @param {string} [options.userData] User specified data. Length should not + * exceed 16KB. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + createWithHttpOperationResponse(largeFaceListId, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._create(largeFaceListId, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Create an empty large face list. Up to 64 large face lists are allowed to + * exist in one subscription. + * + * @param {string} largeFaceListId Id referencing a particular large face list. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.name] User defined name, maximum length is 128. + * + * @param {string} [options.userData] User specified data. Length should not + * exceed 16KB. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {null} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {null} [result] - The deserialized result object if an error did not occur. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + create(largeFaceListId, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._create(largeFaceListId, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._create(largeFaceListId, options, optionalCallback); + } + } + + /** + * Retrieve a large face list's information. + * + * @param {string} largeFaceListId Id referencing a particular large face list. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + getWithHttpOperationResponse(largeFaceListId, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._get(largeFaceListId, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Retrieve a large face list's information. + * + * @param {string} largeFaceListId Id referencing a particular large face list. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {LargeFaceList} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link LargeFaceList} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + get(largeFaceListId, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._get(largeFaceListId, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._get(largeFaceListId, options, optionalCallback); + } + } + + /** + * Update information of a large face list. + * + * @param {string} largeFaceListId Id referencing a particular large face list. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.name] User defined name, maximum length is 128. + * + * @param {string} [options.userData] User specified data. Length should not + * exceed 16KB. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + updateWithHttpOperationResponse(largeFaceListId, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._update(largeFaceListId, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Update information of a large face list. + * + * @param {string} largeFaceListId Id referencing a particular large face list. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.name] User defined name, maximum length is 128. + * + * @param {string} [options.userData] User specified data. Length should not + * exceed 16KB. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {null} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {null} [result] - The deserialized result object if an error did not occur. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + update(largeFaceListId, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._update(largeFaceListId, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._update(largeFaceListId, options, optionalCallback); + } + } + + /** + * Delete an existing large face list according to faceListId. Persisted face + * images in the large face list will also be deleted. + * + * @param {string} largeFaceListId Id referencing a particular large face list. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + deleteMethodWithHttpOperationResponse(largeFaceListId, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._deleteMethod(largeFaceListId, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Delete an existing large face list according to faceListId. Persisted face + * images in the large face list will also be deleted. + * + * @param {string} largeFaceListId Id referencing a particular large face list. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {null} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {null} [result] - The deserialized result object if an error did not occur. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + deleteMethod(largeFaceListId, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._deleteMethod(largeFaceListId, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._deleteMethod(largeFaceListId, options, optionalCallback); + } + } + + /** + * Retrieve the training status of a large face list (completed or ongoing). + * + * @param {string} largeFaceListId Id referencing a particular large face list. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + getTrainingStatusWithHttpOperationResponse(largeFaceListId, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._getTrainingStatus(largeFaceListId, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Retrieve the training status of a large face list (completed or ongoing). + * + * @param {string} largeFaceListId Id referencing a particular large face list. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {TrainingStatus} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link TrainingStatus} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + getTrainingStatus(largeFaceListId, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._getTrainingStatus(largeFaceListId, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._getTrainingStatus(largeFaceListId, options, optionalCallback); + } + } + + /** + * Retrieve information about all existing large face lists. Only + * largeFaceListId, name and userData will be returned. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + listWithHttpOperationResponse(options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._list(options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Retrieve information about all existing large face lists. Only + * largeFaceListId, name and userData will be returned. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {Array} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {array} [result] - The deserialized result object if an error did not occur. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + list(options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._list(options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._list(options, optionalCallback); + } + } + + /** + * Queue a large face list training task, the training task may not be started + * immediately. + * + * @param {string} largeFaceListId Id referencing a particular large face list. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + trainWithHttpOperationResponse(largeFaceListId, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._train(largeFaceListId, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Queue a large face list training task, the training task may not be started + * immediately. + * + * @param {string} largeFaceListId Id referencing a particular large face list. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {null} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {null} [result] - The deserialized result object if an error did not occur. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + train(largeFaceListId, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._train(largeFaceListId, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._train(largeFaceListId, options, optionalCallback); + } + } + + /** + * Delete an existing face from a large face list (given by a persisitedFaceId + * and a largeFaceListId). Persisted image related to the face will also be + * deleted. + * + * @param {string} largeFaceListId Id referencing a particular large face list. + * + * @param {uuid} persistedFaceId Id referencing a particular persistedFaceId of + * an existing face. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + deleteFaceWithHttpOperationResponse(largeFaceListId, persistedFaceId, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._deleteFace(largeFaceListId, persistedFaceId, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Delete an existing face from a large face list (given by a persisitedFaceId + * and a largeFaceListId). Persisted image related to the face will also be + * deleted. + * + * @param {string} largeFaceListId Id referencing a particular large face list. + * + * @param {uuid} persistedFaceId Id referencing a particular persistedFaceId of + * an existing face. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {null} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {null} [result] - The deserialized result object if an error did not occur. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + deleteFace(largeFaceListId, persistedFaceId, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._deleteFace(largeFaceListId, persistedFaceId, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._deleteFace(largeFaceListId, persistedFaceId, options, optionalCallback); + } + } + + /** + * Retrieve information about a persisted face (specified by persistedFaceId + * and its belonging largeFaceListId). + * + * @param {string} largeFaceListId Id referencing a particular large face list. + * + * @param {uuid} persistedFaceId Id referencing a particular persistedFaceId of + * an existing face. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + getFaceWithHttpOperationResponse(largeFaceListId, persistedFaceId, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._getFace(largeFaceListId, persistedFaceId, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Retrieve information about a persisted face (specified by persistedFaceId + * and its belonging largeFaceListId). + * + * @param {string} largeFaceListId Id referencing a particular large face list. + * + * @param {uuid} persistedFaceId Id referencing a particular persistedFaceId of + * an existing face. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {PersistedFace} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link PersistedFace} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + getFace(largeFaceListId, persistedFaceId, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._getFace(largeFaceListId, persistedFaceId, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._getFace(largeFaceListId, persistedFaceId, options, optionalCallback); + } + } + + /** + * Update a persisted face's userData field. + * + * @param {string} largeFaceListId Id referencing a particular large face list. + * + * @param {uuid} persistedFaceId Id referencing a particular persistedFaceId of + * an existing face. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.userData] User-provided data attached to the face. + * The size limit is 1KB. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + updateFaceWithHttpOperationResponse(largeFaceListId, persistedFaceId, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._updateFace(largeFaceListId, persistedFaceId, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Update a persisted face's userData field. + * + * @param {string} largeFaceListId Id referencing a particular large face list. + * + * @param {uuid} persistedFaceId Id referencing a particular persistedFaceId of + * an existing face. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.userData] User-provided data attached to the face. + * The size limit is 1KB. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {null} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {null} [result] - The deserialized result object if an error did not occur. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + updateFace(largeFaceListId, persistedFaceId, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._updateFace(largeFaceListId, persistedFaceId, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._updateFace(largeFaceListId, persistedFaceId, options, optionalCallback); + } + } + + /** + * Add a face to a large face list. The input face is specified as an image + * with a targetFace rectangle. It returns a persistedFaceId representing the + * added face, and persistedFaceId will not expire. + * + * @param {string} largeFaceListId Id referencing a particular large face list. + * + * @param {string} url Publicly reachable URL of an image + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.userData] User-specified data about the face for + * any purpose. The maximum length is 1KB. + * + * @param {array} [options.targetFace] A face rectangle to specify the target + * face to be added to a person in the format of + * "targetFace=left,top,width,height". E.g. "targetFace=10,10,100,100". If + * there is more than one face in the image, targetFace is required to specify + * which face to add. No targetFace means there is only one face detected in + * the entire image. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + addFaceFromUrlWithHttpOperationResponse(largeFaceListId, url, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._addFaceFromUrl(largeFaceListId, url, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Add a face to a large face list. The input face is specified as an image + * with a targetFace rectangle. It returns a persistedFaceId representing the + * added face, and persistedFaceId will not expire. + * + * @param {string} largeFaceListId Id referencing a particular large face list. + * + * @param {string} url Publicly reachable URL of an image + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.userData] User-specified data about the face for + * any purpose. The maximum length is 1KB. + * + * @param {array} [options.targetFace] A face rectangle to specify the target + * face to be added to a person in the format of + * "targetFace=left,top,width,height". E.g. "targetFace=10,10,100,100". If + * there is more than one face in the image, targetFace is required to specify + * which face to add. No targetFace means there is only one face detected in + * the entire image. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {PersistedFace} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link PersistedFace} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + addFaceFromUrl(largeFaceListId, url, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._addFaceFromUrl(largeFaceListId, url, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._addFaceFromUrl(largeFaceListId, url, options, optionalCallback); + } + } + + /** + * Add a face to a large face list. The input face is specified as an image + * with a targetFace rectangle. It returns a persistedFaceId representing the + * added face, and persistedFaceId will not expire. + * + * @param {string} largeFaceListId Id referencing a particular large face list. + * + * @param {object} image An image stream. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.userData] User-specified data about the face for + * any purpose. The maximum length is 1KB. + * + * @param {array} [options.targetFace] A face rectangle to specify the target + * face to be added to a person in the format of + * "targetFace=left,top,width,height". E.g. "targetFace=10,10,100,100". If + * there is more than one face in the image, targetFace is required to specify + * which face to add. No targetFace means there is only one face detected in + * the entire image. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + addFaceFromStreamWithHttpOperationResponse(largeFaceListId, image, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._addFaceFromStream(largeFaceListId, image, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Add a face to a large face list. The input face is specified as an image + * with a targetFace rectangle. It returns a persistedFaceId representing the + * added face, and persistedFaceId will not expire. + * + * @param {string} largeFaceListId Id referencing a particular large face list. + * + * @param {object} image An image stream. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.userData] User-specified data about the face for + * any purpose. The maximum length is 1KB. + * + * @param {array} [options.targetFace] A face rectangle to specify the target + * face to be added to a person in the format of + * "targetFace=left,top,width,height". E.g. "targetFace=10,10,100,100". If + * there is more than one face in the image, targetFace is required to specify + * which face to add. No targetFace means there is only one face detected in + * the entire image. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {PersistedFace} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link PersistedFace} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + addFaceFromStream(largeFaceListId, image, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._addFaceFromStream(largeFaceListId, image, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._addFaceFromStream(largeFaceListId, image, options, optionalCallback); + } + } + +} + +module.exports = LargeFaceListOperations; diff --git a/lib/services/face/lib/operations/largePersonGroupOperations.js b/lib/services/face/lib/operations/largePersonGroupOperations.js new file mode 100644 index 0000000000..9d3ce8f6f0 --- /dev/null +++ b/lib/services/face/lib/operations/largePersonGroupOperations.js @@ -0,0 +1,1648 @@ +/* + * 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'; + +const msRest = require('ms-rest'); +const WebResource = msRest.WebResource; + +/** + * Create a new large person group with specified largePersonGroupId, name and + * user-provided userData. + * + * @param {string} largePersonGroupId Id referencing a particular large person + * group. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.name] User defined name, maximum length is 128. + * + * @param {string} [options.userData] User specified data. Length should not + * exceed 16KB. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {null} [result] - The deserialized result object if an error did not occur. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _create(largePersonGroupId, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + let name = (options && options.name !== undefined) ? options.name : undefined; + let userData = (options && options.userData !== undefined) ? options.userData : undefined; + // Validate + try { + if (this.client.endpoint === null || this.client.endpoint === undefined || typeof this.client.endpoint.valueOf() !== 'string') { + throw new Error('this.client.endpoint cannot be null or undefined and it must be of type string.'); + } + if (largePersonGroupId === null || largePersonGroupId === undefined || typeof largePersonGroupId.valueOf() !== 'string') { + throw new Error('largePersonGroupId cannot be null or undefined and it must be of type string.'); + } + if (largePersonGroupId !== null && largePersonGroupId !== undefined) { + if (largePersonGroupId.length > 64) + { + throw new Error('"largePersonGroupId" should satisfy the constraint - "MaxLength": 64'); + } + if (largePersonGroupId.match(/^[a-z0-9-_]+$/) === null) + { + throw new Error('"largePersonGroupId" should satisfy the constraint - "Pattern": /^[a-z0-9-_]+$/'); + } + } + if (name !== null && name !== undefined && typeof name.valueOf() !== 'string') { + throw new Error('name must be of type string.'); + } + if (name !== null && name !== undefined) { + if (name.length > 128) + { + throw new Error('"name" should satisfy the constraint - "MaxLength": 128'); + } + } + if (userData !== null && userData !== undefined && typeof userData.valueOf() !== 'string') { + throw new Error('userData must be of type string.'); + } + if (userData !== null && userData !== undefined) { + if (userData.length > 16384) + { + throw new Error('"userData" should satisfy the constraint - "MaxLength": 16384'); + } + } + } catch (error) { + return callback(error); + } + let body; + if ((name !== null && name !== undefined) || (userData !== null && userData !== undefined)) { + body = new client.models['NameAndUserDataContract'](); + body.name = name; + body.userData = userData; + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'largepersongroups/{largePersonGroupId}'; + requestUrl = requestUrl.replace('{Endpoint}', this.client.endpoint); + requestUrl = requestUrl.replace('{largePersonGroupId}', encodeURIComponent(largePersonGroupId)); + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'PUT'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + // Serialize Request + let requestContent = null; + let requestModel = null; + try { + if (body !== null && body !== undefined) { + let requestModelMapper = new client.models['NameAndUserDataContract']().mapper(); + requestModel = client.serialize(requestModelMapper, body, 'body'); + requestContent = JSON.stringify(requestModel); + } + } catch (error) { + let serializationError = new Error(`Error "${error.message}" occurred in serializing the ` + + `payload - ${JSON.stringify(body, null, 2)}.`); + return callback(serializationError); + } + httpRequest.body = requestContent; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['APIError']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + + return callback(null, result, httpRequest, response); + }); +} + +/** + * Delete an existing large person group. Persisted face features of all people + * in the large person group will also be deleted. + * + * @param {string} largePersonGroupId Id referencing a particular large person + * group. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {null} [result] - The deserialized result object if an error did not occur. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _deleteMethod(largePersonGroupId, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + // Validate + try { + if (this.client.endpoint === null || this.client.endpoint === undefined || typeof this.client.endpoint.valueOf() !== 'string') { + throw new Error('this.client.endpoint cannot be null or undefined and it must be of type string.'); + } + if (largePersonGroupId === null || largePersonGroupId === undefined || typeof largePersonGroupId.valueOf() !== 'string') { + throw new Error('largePersonGroupId cannot be null or undefined and it must be of type string.'); + } + if (largePersonGroupId !== null && largePersonGroupId !== undefined) { + if (largePersonGroupId.length > 64) + { + throw new Error('"largePersonGroupId" should satisfy the constraint - "MaxLength": 64'); + } + if (largePersonGroupId.match(/^[a-z0-9-_]+$/) === null) + { + throw new Error('"largePersonGroupId" should satisfy the constraint - "Pattern": /^[a-z0-9-_]+$/'); + } + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'largepersongroups/{largePersonGroupId}'; + requestUrl = requestUrl.replace('{Endpoint}', this.client.endpoint); + requestUrl = requestUrl.replace('{largePersonGroupId}', encodeURIComponent(largePersonGroupId)); + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'DELETE'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['APIError']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + + return callback(null, result, httpRequest, response); + }); +} + +/** + * Retrieve the information of a large person group, including its name and + * userData. + * + * @param {string} largePersonGroupId Id referencing a particular large person + * group. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link LargePersonGroup} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _get(largePersonGroupId, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + // Validate + try { + if (this.client.endpoint === null || this.client.endpoint === undefined || typeof this.client.endpoint.valueOf() !== 'string') { + throw new Error('this.client.endpoint cannot be null or undefined and it must be of type string.'); + } + if (largePersonGroupId === null || largePersonGroupId === undefined || typeof largePersonGroupId.valueOf() !== 'string') { + throw new Error('largePersonGroupId cannot be null or undefined and it must be of type string.'); + } + if (largePersonGroupId !== null && largePersonGroupId !== undefined) { + if (largePersonGroupId.length > 64) + { + throw new Error('"largePersonGroupId" should satisfy the constraint - "MaxLength": 64'); + } + if (largePersonGroupId.match(/^[a-z0-9-_]+$/) === null) + { + throw new Error('"largePersonGroupId" should satisfy the constraint - "Pattern": /^[a-z0-9-_]+$/'); + } + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'largepersongroups/{largePersonGroupId}'; + requestUrl = requestUrl.replace('{Endpoint}', this.client.endpoint); + requestUrl = requestUrl.replace('{largePersonGroupId}', encodeURIComponent(largePersonGroupId)); + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'GET'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['APIError']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + // Deserialize Response + if (statusCode === 200) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['LargePersonGroup']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** + * Update an existing large person group's display name and userData. The + * properties which does not appear in request body will not be updated. + * + * @param {string} largePersonGroupId Id referencing a particular large person + * group. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.name] User defined name, maximum length is 128. + * + * @param {string} [options.userData] User specified data. Length should not + * exceed 16KB. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {null} [result] - The deserialized result object if an error did not occur. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _update(largePersonGroupId, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + let name = (options && options.name !== undefined) ? options.name : undefined; + let userData = (options && options.userData !== undefined) ? options.userData : undefined; + // Validate + try { + if (this.client.endpoint === null || this.client.endpoint === undefined || typeof this.client.endpoint.valueOf() !== 'string') { + throw new Error('this.client.endpoint cannot be null or undefined and it must be of type string.'); + } + if (largePersonGroupId === null || largePersonGroupId === undefined || typeof largePersonGroupId.valueOf() !== 'string') { + throw new Error('largePersonGroupId cannot be null or undefined and it must be of type string.'); + } + if (largePersonGroupId !== null && largePersonGroupId !== undefined) { + if (largePersonGroupId.length > 64) + { + throw new Error('"largePersonGroupId" should satisfy the constraint - "MaxLength": 64'); + } + if (largePersonGroupId.match(/^[a-z0-9-_]+$/) === null) + { + throw new Error('"largePersonGroupId" should satisfy the constraint - "Pattern": /^[a-z0-9-_]+$/'); + } + } + if (name !== null && name !== undefined && typeof name.valueOf() !== 'string') { + throw new Error('name must be of type string.'); + } + if (name !== null && name !== undefined) { + if (name.length > 128) + { + throw new Error('"name" should satisfy the constraint - "MaxLength": 128'); + } + } + if (userData !== null && userData !== undefined && typeof userData.valueOf() !== 'string') { + throw new Error('userData must be of type string.'); + } + if (userData !== null && userData !== undefined) { + if (userData.length > 16384) + { + throw new Error('"userData" should satisfy the constraint - "MaxLength": 16384'); + } + } + } catch (error) { + return callback(error); + } + let body; + if ((name !== null && name !== undefined) || (userData !== null && userData !== undefined)) { + body = new client.models['NameAndUserDataContract'](); + body.name = name; + body.userData = userData; + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'largepersongroups/{largePersonGroupId}'; + requestUrl = requestUrl.replace('{Endpoint}', this.client.endpoint); + requestUrl = requestUrl.replace('{largePersonGroupId}', encodeURIComponent(largePersonGroupId)); + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'PATCH'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + // Serialize Request + let requestContent = null; + let requestModel = null; + try { + if (body !== null && body !== undefined) { + let requestModelMapper = new client.models['NameAndUserDataContract']().mapper(); + requestModel = client.serialize(requestModelMapper, body, 'body'); + requestContent = JSON.stringify(requestModel); + } + } catch (error) { + let serializationError = new Error(`Error "${error.message}" occurred in serializing the ` + + `payload - ${JSON.stringify(body, null, 2)}.`); + return callback(serializationError); + } + httpRequest.body = requestContent; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['APIError']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + + return callback(null, result, httpRequest, response); + }); +} + +/** + * Retrieve the training status of a large person group (completed or ongoing). + * + * @param {string} largePersonGroupId Id referencing a particular large person + * group. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link TrainingStatus} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _getTrainingStatus(largePersonGroupId, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + // Validate + try { + if (this.client.endpoint === null || this.client.endpoint === undefined || typeof this.client.endpoint.valueOf() !== 'string') { + throw new Error('this.client.endpoint cannot be null or undefined and it must be of type string.'); + } + if (largePersonGroupId === null || largePersonGroupId === undefined || typeof largePersonGroupId.valueOf() !== 'string') { + throw new Error('largePersonGroupId cannot be null or undefined and it must be of type string.'); + } + if (largePersonGroupId !== null && largePersonGroupId !== undefined) { + if (largePersonGroupId.length > 64) + { + throw new Error('"largePersonGroupId" should satisfy the constraint - "MaxLength": 64'); + } + if (largePersonGroupId.match(/^[a-z0-9-_]+$/) === null) + { + throw new Error('"largePersonGroupId" should satisfy the constraint - "Pattern": /^[a-z0-9-_]+$/'); + } + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'largepersongroups/{largePersonGroupId}/training'; + requestUrl = requestUrl.replace('{Endpoint}', this.client.endpoint); + requestUrl = requestUrl.replace('{largePersonGroupId}', encodeURIComponent(largePersonGroupId)); + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'GET'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['APIError']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + // Deserialize Response + if (statusCode === 200) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['TrainingStatus']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** + * List large person groups and their information. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.start] List large person groups from the least + * largePersonGroupId greater than the "start". + * + * @param {number} [options.top] The number of large person groups to list. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {array} [result] - The deserialized result object if an error did not occur. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _list(options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + let start = (options && options.start !== undefined) ? options.start : undefined; + let top = (options && options.top !== undefined) ? options.top : 1000; + // Validate + try { + if (this.client.endpoint === null || this.client.endpoint === undefined || typeof this.client.endpoint.valueOf() !== 'string') { + throw new Error('this.client.endpoint cannot be null or undefined and it must be of type string.'); + } + if (start !== null && start !== undefined && typeof start.valueOf() !== 'string') { + throw new Error('start must be of type string.'); + } + if (start !== null && start !== undefined) { + if (start.length > 64) + { + throw new Error('"start" should satisfy the constraint - "MaxLength": 64'); + } + } + if (top !== null && top !== undefined && typeof top !== 'number') { + throw new Error('top must be of type number.'); + } + if (top !== null && top !== undefined) { + if (top > 1000) + { + throw new Error('"top" should satisfy the constraint - "InclusiveMaximum": 1000'); + } + if (top < 1) + { + throw new Error('"top" should satisfy the constraint - "InclusiveMinimum": 1'); + } + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'largepersongroups'; + requestUrl = requestUrl.replace('{Endpoint}', this.client.endpoint); + let queryParameters = []; + if (start !== null && start !== undefined) { + queryParameters.push('start=' + encodeURIComponent(start)); + } + if (top !== null && top !== undefined) { + queryParameters.push('top=' + encodeURIComponent(top.toString())); + } + if (queryParameters.length > 0) { + requestUrl += '?' + queryParameters.join('&'); + } + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'GET'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['APIError']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + // Deserialize Response + if (statusCode === 200) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = { + required: false, + serializedName: 'parsedResponse', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'LargePersonGroupElementType', + type: { + name: 'Composite', + className: 'LargePersonGroup' + } + } + } + }; + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** + * Queue a large person group training task, the training task may not be + * started immediately. + * + * @param {string} largePersonGroupId Id referencing a particular large person + * group. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {null} [result] - The deserialized result object if an error did not occur. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _train(largePersonGroupId, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + // Validate + try { + if (this.client.endpoint === null || this.client.endpoint === undefined || typeof this.client.endpoint.valueOf() !== 'string') { + throw new Error('this.client.endpoint cannot be null or undefined and it must be of type string.'); + } + if (largePersonGroupId === null || largePersonGroupId === undefined || typeof largePersonGroupId.valueOf() !== 'string') { + throw new Error('largePersonGroupId cannot be null or undefined and it must be of type string.'); + } + if (largePersonGroupId !== null && largePersonGroupId !== undefined) { + if (largePersonGroupId.length > 64) + { + throw new Error('"largePersonGroupId" should satisfy the constraint - "MaxLength": 64'); + } + if (largePersonGroupId.match(/^[a-z0-9-_]+$/) === null) + { + throw new Error('"largePersonGroupId" should satisfy the constraint - "Pattern": /^[a-z0-9-_]+$/'); + } + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'largepersongroups/{largePersonGroupId}/train'; + requestUrl = requestUrl.replace('{Endpoint}', this.client.endpoint); + requestUrl = requestUrl.replace('{largePersonGroupId}', encodeURIComponent(largePersonGroupId)); + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'POST'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 202) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['APIError']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + + return callback(null, result, httpRequest, response); + }); +} + +/** Class representing a LargePersonGroupOperations. */ +class LargePersonGroupOperations { + /** + * Create a LargePersonGroupOperations. + * @param {FaceClient} client Reference to the service client. + */ + constructor(client) { + this.client = client; + this._create = _create; + this._deleteMethod = _deleteMethod; + this._get = _get; + this._update = _update; + this._getTrainingStatus = _getTrainingStatus; + this._list = _list; + this._train = _train; + } + + /** + * Create a new large person group with specified largePersonGroupId, name and + * user-provided userData. + * + * @param {string} largePersonGroupId Id referencing a particular large person + * group. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.name] User defined name, maximum length is 128. + * + * @param {string} [options.userData] User specified data. Length should not + * exceed 16KB. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + createWithHttpOperationResponse(largePersonGroupId, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._create(largePersonGroupId, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Create a new large person group with specified largePersonGroupId, name and + * user-provided userData. + * + * @param {string} largePersonGroupId Id referencing a particular large person + * group. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.name] User defined name, maximum length is 128. + * + * @param {string} [options.userData] User specified data. Length should not + * exceed 16KB. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {null} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {null} [result] - The deserialized result object if an error did not occur. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + create(largePersonGroupId, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._create(largePersonGroupId, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._create(largePersonGroupId, options, optionalCallback); + } + } + + /** + * Delete an existing large person group. Persisted face features of all people + * in the large person group will also be deleted. + * + * @param {string} largePersonGroupId Id referencing a particular large person + * group. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + deleteMethodWithHttpOperationResponse(largePersonGroupId, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._deleteMethod(largePersonGroupId, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Delete an existing large person group. Persisted face features of all people + * in the large person group will also be deleted. + * + * @param {string} largePersonGroupId Id referencing a particular large person + * group. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {null} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {null} [result] - The deserialized result object if an error did not occur. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + deleteMethod(largePersonGroupId, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._deleteMethod(largePersonGroupId, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._deleteMethod(largePersonGroupId, options, optionalCallback); + } + } + + /** + * Retrieve the information of a large person group, including its name and + * userData. + * + * @param {string} largePersonGroupId Id referencing a particular large person + * group. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + getWithHttpOperationResponse(largePersonGroupId, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._get(largePersonGroupId, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Retrieve the information of a large person group, including its name and + * userData. + * + * @param {string} largePersonGroupId Id referencing a particular large person + * group. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {LargePersonGroup} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link LargePersonGroup} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + get(largePersonGroupId, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._get(largePersonGroupId, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._get(largePersonGroupId, options, optionalCallback); + } + } + + /** + * Update an existing large person group's display name and userData. The + * properties which does not appear in request body will not be updated. + * + * @param {string} largePersonGroupId Id referencing a particular large person + * group. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.name] User defined name, maximum length is 128. + * + * @param {string} [options.userData] User specified data. Length should not + * exceed 16KB. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + updateWithHttpOperationResponse(largePersonGroupId, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._update(largePersonGroupId, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Update an existing large person group's display name and userData. The + * properties which does not appear in request body will not be updated. + * + * @param {string} largePersonGroupId Id referencing a particular large person + * group. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.name] User defined name, maximum length is 128. + * + * @param {string} [options.userData] User specified data. Length should not + * exceed 16KB. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {null} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {null} [result] - The deserialized result object if an error did not occur. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + update(largePersonGroupId, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._update(largePersonGroupId, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._update(largePersonGroupId, options, optionalCallback); + } + } + + /** + * Retrieve the training status of a large person group (completed or ongoing). + * + * @param {string} largePersonGroupId Id referencing a particular large person + * group. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + getTrainingStatusWithHttpOperationResponse(largePersonGroupId, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._getTrainingStatus(largePersonGroupId, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Retrieve the training status of a large person group (completed or ongoing). + * + * @param {string} largePersonGroupId Id referencing a particular large person + * group. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {TrainingStatus} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link TrainingStatus} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + getTrainingStatus(largePersonGroupId, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._getTrainingStatus(largePersonGroupId, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._getTrainingStatus(largePersonGroupId, options, optionalCallback); + } + } + + /** + * List large person groups and their information. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.start] List large person groups from the least + * largePersonGroupId greater than the "start". + * + * @param {number} [options.top] The number of large person groups to list. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + listWithHttpOperationResponse(options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._list(options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * List large person groups and their information. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.start] List large person groups from the least + * largePersonGroupId greater than the "start". + * + * @param {number} [options.top] The number of large person groups to list. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {Array} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {array} [result] - The deserialized result object if an error did not occur. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + list(options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._list(options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._list(options, optionalCallback); + } + } + + /** + * Queue a large person group training task, the training task may not be + * started immediately. + * + * @param {string} largePersonGroupId Id referencing a particular large person + * group. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + trainWithHttpOperationResponse(largePersonGroupId, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._train(largePersonGroupId, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Queue a large person group training task, the training task may not be + * started immediately. + * + * @param {string} largePersonGroupId Id referencing a particular large person + * group. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {null} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {null} [result] - The deserialized result object if an error did not occur. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + train(largePersonGroupId, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._train(largePersonGroupId, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._train(largePersonGroupId, options, optionalCallback); + } + } + +} + +module.exports = LargePersonGroupOperations; diff --git a/lib/services/face/lib/operations/largePersonGroupPerson.js b/lib/services/face/lib/operations/largePersonGroupPerson.js new file mode 100644 index 0000000000..fe5d3e7439 --- /dev/null +++ b/lib/services/face/lib/operations/largePersonGroupPerson.js @@ -0,0 +1,2646 @@ +/* + * 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'; + +const msRest = require('ms-rest'); +const WebResource = msRest.WebResource; + +/** + * Create a new person in a specified large person group. + * + * @param {string} largePersonGroupId Id referencing a particular large person + * group. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.name] User defined name, maximum length is 128. + * + * @param {string} [options.userData] User specified data. Length should not + * exceed 16KB. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link Person} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _create(largePersonGroupId, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + let name = (options && options.name !== undefined) ? options.name : undefined; + let userData = (options && options.userData !== undefined) ? options.userData : undefined; + // Validate + try { + if (this.client.endpoint === null || this.client.endpoint === undefined || typeof this.client.endpoint.valueOf() !== 'string') { + throw new Error('this.client.endpoint cannot be null or undefined and it must be of type string.'); + } + if (largePersonGroupId === null || largePersonGroupId === undefined || typeof largePersonGroupId.valueOf() !== 'string') { + throw new Error('largePersonGroupId cannot be null or undefined and it must be of type string.'); + } + if (largePersonGroupId !== null && largePersonGroupId !== undefined) { + if (largePersonGroupId.length > 64) + { + throw new Error('"largePersonGroupId" should satisfy the constraint - "MaxLength": 64'); + } + if (largePersonGroupId.match(/^[a-z0-9-_]+$/) === null) + { + throw new Error('"largePersonGroupId" should satisfy the constraint - "Pattern": /^[a-z0-9-_]+$/'); + } + } + if (name !== null && name !== undefined && typeof name.valueOf() !== 'string') { + throw new Error('name must be of type string.'); + } + if (name !== null && name !== undefined) { + if (name.length > 128) + { + throw new Error('"name" should satisfy the constraint - "MaxLength": 128'); + } + } + if (userData !== null && userData !== undefined && typeof userData.valueOf() !== 'string') { + throw new Error('userData must be of type string.'); + } + if (userData !== null && userData !== undefined) { + if (userData.length > 16384) + { + throw new Error('"userData" should satisfy the constraint - "MaxLength": 16384'); + } + } + } catch (error) { + return callback(error); + } + let body; + if ((name !== null && name !== undefined) || (userData !== null && userData !== undefined)) { + body = new client.models['NameAndUserDataContract'](); + body.name = name; + body.userData = userData; + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'largepersongroups/{largePersonGroupId}/persons'; + requestUrl = requestUrl.replace('{Endpoint}', this.client.endpoint); + requestUrl = requestUrl.replace('{largePersonGroupId}', encodeURIComponent(largePersonGroupId)); + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'POST'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + // Serialize Request + let requestContent = null; + let requestModel = null; + try { + if (body !== null && body !== undefined) { + let requestModelMapper = new client.models['NameAndUserDataContract']().mapper(); + requestModel = client.serialize(requestModelMapper, body, 'body'); + requestContent = JSON.stringify(requestModel); + } + } catch (error) { + let serializationError = new Error(`Error "${error.message}" occurred in serializing the ` + + `payload - ${JSON.stringify(body, null, 2)}.`); + return callback(serializationError); + } + httpRequest.body = requestContent; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['APIError']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + // Deserialize Response + if (statusCode === 200) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['Person']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** + * List all persons in a large person group, and retrieve person information + * (including personId, name, userData and persistedFaceIds of registered faces + * of the person). + * + * @param {string} largePersonGroupId Id referencing a particular large person + * group. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.start] Starting person id to return (used to list a + * range of persons). + * + * @param {number} [options.top] Number of persons to return starting with the + * person id indicated by the 'start' parameter. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {array} [result] - The deserialized result object if an error did not occur. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _list(largePersonGroupId, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + let start = (options && options.start !== undefined) ? options.start : undefined; + let top = (options && options.top !== undefined) ? options.top : undefined; + // Validate + try { + if (this.client.endpoint === null || this.client.endpoint === undefined || typeof this.client.endpoint.valueOf() !== 'string') { + throw new Error('this.client.endpoint cannot be null or undefined and it must be of type string.'); + } + if (largePersonGroupId === null || largePersonGroupId === undefined || typeof largePersonGroupId.valueOf() !== 'string') { + throw new Error('largePersonGroupId cannot be null or undefined and it must be of type string.'); + } + if (largePersonGroupId !== null && largePersonGroupId !== undefined) { + if (largePersonGroupId.length > 64) + { + throw new Error('"largePersonGroupId" should satisfy the constraint - "MaxLength": 64'); + } + if (largePersonGroupId.match(/^[a-z0-9-_]+$/) === null) + { + throw new Error('"largePersonGroupId" should satisfy the constraint - "Pattern": /^[a-z0-9-_]+$/'); + } + } + if (start !== null && start !== undefined && typeof start.valueOf() !== 'string') { + throw new Error('start must be of type string.'); + } + if (top !== null && top !== undefined && typeof top !== 'number') { + throw new Error('top must be of type number.'); + } + if (top !== null && top !== undefined) { + if (top > 1000) + { + throw new Error('"top" should satisfy the constraint - "InclusiveMaximum": 1000'); + } + if (top < 1) + { + throw new Error('"top" should satisfy the constraint - "InclusiveMinimum": 1'); + } + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'largepersongroups/{largePersonGroupId}/persons'; + requestUrl = requestUrl.replace('{Endpoint}', this.client.endpoint); + requestUrl = requestUrl.replace('{largePersonGroupId}', encodeURIComponent(largePersonGroupId)); + let queryParameters = []; + if (start !== null && start !== undefined) { + queryParameters.push('start=' + encodeURIComponent(start)); + } + if (top !== null && top !== undefined) { + queryParameters.push('top=' + encodeURIComponent(top.toString())); + } + if (queryParameters.length > 0) { + requestUrl += '?' + queryParameters.join('&'); + } + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'GET'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['APIError']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + // Deserialize Response + if (statusCode === 200) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = { + required: false, + serializedName: 'parsedResponse', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'PersonElementType', + type: { + name: 'Composite', + className: 'Person' + } + } + } + }; + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** + * Delete an existing person from a large person group. All stored person data, + * and face features in the person entry will be deleted. + * + * @param {string} largePersonGroupId Id referencing a particular large person + * group. + * + * @param {uuid} personId Id referencing a particular person. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {null} [result] - The deserialized result object if an error did not occur. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _deleteMethod(largePersonGroupId, personId, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + // Validate + try { + if (this.client.endpoint === null || this.client.endpoint === undefined || typeof this.client.endpoint.valueOf() !== 'string') { + throw new Error('this.client.endpoint cannot be null or undefined and it must be of type string.'); + } + if (largePersonGroupId === null || largePersonGroupId === undefined || typeof largePersonGroupId.valueOf() !== 'string') { + throw new Error('largePersonGroupId cannot be null or undefined and it must be of type string.'); + } + if (largePersonGroupId !== null && largePersonGroupId !== undefined) { + if (largePersonGroupId.length > 64) + { + throw new Error('"largePersonGroupId" should satisfy the constraint - "MaxLength": 64'); + } + if (largePersonGroupId.match(/^[a-z0-9-_]+$/) === null) + { + throw new Error('"largePersonGroupId" should satisfy the constraint - "Pattern": /^[a-z0-9-_]+$/'); + } + } + if (personId === null || personId === undefined || typeof personId.valueOf() !== 'string' || !msRest.isValidUuid(personId)) { + throw new Error('personId cannot be null or undefined and it must be of type string and must be a valid uuid.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'largepersongroups/{largePersonGroupId}/persons/{personId}'; + requestUrl = requestUrl.replace('{Endpoint}', this.client.endpoint); + requestUrl = requestUrl.replace('{largePersonGroupId}', encodeURIComponent(largePersonGroupId)); + requestUrl = requestUrl.replace('{personId}', encodeURIComponent(personId.toString())); + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'DELETE'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['APIError']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + + return callback(null, result, httpRequest, response); + }); +} + +/** + * Retrieve a person's information, including registered persisted faces, name + * and userData. + * + * @param {string} largePersonGroupId Id referencing a particular large person + * group. + * + * @param {uuid} personId Id referencing a particular person. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link Person} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _get(largePersonGroupId, personId, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + // Validate + try { + if (this.client.endpoint === null || this.client.endpoint === undefined || typeof this.client.endpoint.valueOf() !== 'string') { + throw new Error('this.client.endpoint cannot be null or undefined and it must be of type string.'); + } + if (largePersonGroupId === null || largePersonGroupId === undefined || typeof largePersonGroupId.valueOf() !== 'string') { + throw new Error('largePersonGroupId cannot be null or undefined and it must be of type string.'); + } + if (largePersonGroupId !== null && largePersonGroupId !== undefined) { + if (largePersonGroupId.length > 64) + { + throw new Error('"largePersonGroupId" should satisfy the constraint - "MaxLength": 64'); + } + if (largePersonGroupId.match(/^[a-z0-9-_]+$/) === null) + { + throw new Error('"largePersonGroupId" should satisfy the constraint - "Pattern": /^[a-z0-9-_]+$/'); + } + } + if (personId === null || personId === undefined || typeof personId.valueOf() !== 'string' || !msRest.isValidUuid(personId)) { + throw new Error('personId cannot be null or undefined and it must be of type string and must be a valid uuid.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'largepersongroups/{largePersonGroupId}/persons/{personId}'; + requestUrl = requestUrl.replace('{Endpoint}', this.client.endpoint); + requestUrl = requestUrl.replace('{largePersonGroupId}', encodeURIComponent(largePersonGroupId)); + requestUrl = requestUrl.replace('{personId}', encodeURIComponent(personId.toString())); + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'GET'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['APIError']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + // Deserialize Response + if (statusCode === 200) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['Person']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** + * Update name or userData of a person. + * + * @param {string} largePersonGroupId Id referencing a particular large person + * group. + * + * @param {uuid} personId Id referencing a particular person. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.name] User defined name, maximum length is 128. + * + * @param {string} [options.userData] User specified data. Length should not + * exceed 16KB. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {null} [result] - The deserialized result object if an error did not occur. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _update(largePersonGroupId, personId, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + let name = (options && options.name !== undefined) ? options.name : undefined; + let userData = (options && options.userData !== undefined) ? options.userData : undefined; + // Validate + try { + if (this.client.endpoint === null || this.client.endpoint === undefined || typeof this.client.endpoint.valueOf() !== 'string') { + throw new Error('this.client.endpoint cannot be null or undefined and it must be of type string.'); + } + if (largePersonGroupId === null || largePersonGroupId === undefined || typeof largePersonGroupId.valueOf() !== 'string') { + throw new Error('largePersonGroupId cannot be null or undefined and it must be of type string.'); + } + if (largePersonGroupId !== null && largePersonGroupId !== undefined) { + if (largePersonGroupId.length > 64) + { + throw new Error('"largePersonGroupId" should satisfy the constraint - "MaxLength": 64'); + } + if (largePersonGroupId.match(/^[a-z0-9-_]+$/) === null) + { + throw new Error('"largePersonGroupId" should satisfy the constraint - "Pattern": /^[a-z0-9-_]+$/'); + } + } + if (personId === null || personId === undefined || typeof personId.valueOf() !== 'string' || !msRest.isValidUuid(personId)) { + throw new Error('personId cannot be null or undefined and it must be of type string and must be a valid uuid.'); + } + if (name !== null && name !== undefined && typeof name.valueOf() !== 'string') { + throw new Error('name must be of type string.'); + } + if (name !== null && name !== undefined) { + if (name.length > 128) + { + throw new Error('"name" should satisfy the constraint - "MaxLength": 128'); + } + } + if (userData !== null && userData !== undefined && typeof userData.valueOf() !== 'string') { + throw new Error('userData must be of type string.'); + } + if (userData !== null && userData !== undefined) { + if (userData.length > 16384) + { + throw new Error('"userData" should satisfy the constraint - "MaxLength": 16384'); + } + } + } catch (error) { + return callback(error); + } + let body; + if ((name !== null && name !== undefined) || (userData !== null && userData !== undefined)) { + body = new client.models['NameAndUserDataContract'](); + body.name = name; + body.userData = userData; + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'largepersongroups/{largePersonGroupId}/persons/{personId}'; + requestUrl = requestUrl.replace('{Endpoint}', this.client.endpoint); + requestUrl = requestUrl.replace('{largePersonGroupId}', encodeURIComponent(largePersonGroupId)); + requestUrl = requestUrl.replace('{personId}', encodeURIComponent(personId.toString())); + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'PATCH'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + // Serialize Request + let requestContent = null; + let requestModel = null; + try { + if (body !== null && body !== undefined) { + let requestModelMapper = new client.models['NameAndUserDataContract']().mapper(); + requestModel = client.serialize(requestModelMapper, body, 'body'); + requestContent = JSON.stringify(requestModel); + } + } catch (error) { + let serializationError = new Error(`Error "${error.message}" occurred in serializing the ` + + `payload - ${JSON.stringify(body, null, 2)}.`); + return callback(serializationError); + } + httpRequest.body = requestContent; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['APIError']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + + return callback(null, result, httpRequest, response); + }); +} + +/** + * Delete a face from a person. Relative feature for the persisted face will + * also be deleted. + * + * @param {string} largePersonGroupId Id referencing a particular large person + * group. + * + * @param {uuid} personId Id referencing a particular person. + * + * @param {uuid} persistedFaceId Id referencing a particular persistedFaceId of + * an existing face. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {null} [result] - The deserialized result object if an error did not occur. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _deleteFace(largePersonGroupId, personId, persistedFaceId, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + // Validate + try { + if (this.client.endpoint === null || this.client.endpoint === undefined || typeof this.client.endpoint.valueOf() !== 'string') { + throw new Error('this.client.endpoint cannot be null or undefined and it must be of type string.'); + } + if (largePersonGroupId === null || largePersonGroupId === undefined || typeof largePersonGroupId.valueOf() !== 'string') { + throw new Error('largePersonGroupId cannot be null or undefined and it must be of type string.'); + } + if (largePersonGroupId !== null && largePersonGroupId !== undefined) { + if (largePersonGroupId.length > 64) + { + throw new Error('"largePersonGroupId" should satisfy the constraint - "MaxLength": 64'); + } + if (largePersonGroupId.match(/^[a-z0-9-_]+$/) === null) + { + throw new Error('"largePersonGroupId" should satisfy the constraint - "Pattern": /^[a-z0-9-_]+$/'); + } + } + if (personId === null || personId === undefined || typeof personId.valueOf() !== 'string' || !msRest.isValidUuid(personId)) { + throw new Error('personId cannot be null or undefined and it must be of type string and must be a valid uuid.'); + } + if (persistedFaceId === null || persistedFaceId === undefined || typeof persistedFaceId.valueOf() !== 'string' || !msRest.isValidUuid(persistedFaceId)) { + throw new Error('persistedFaceId cannot be null or undefined and it must be of type string and must be a valid uuid.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'largepersongroups/{largePersonGroupId}/persons/{personId}/persistedFaces/{persistedFaceId}'; + requestUrl = requestUrl.replace('{Endpoint}', this.client.endpoint); + requestUrl = requestUrl.replace('{largePersonGroupId}', encodeURIComponent(largePersonGroupId)); + requestUrl = requestUrl.replace('{personId}', encodeURIComponent(personId.toString())); + requestUrl = requestUrl.replace('{persistedFaceId}', encodeURIComponent(persistedFaceId.toString())); + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'DELETE'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['APIError']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + + return callback(null, result, httpRequest, response); + }); +} + +/** + * Retrieve information about a persisted face (specified by persistedFaceId, + * personId and its belonging largePersonGroupId). + * + * @param {string} largePersonGroupId Id referencing a particular large person + * group. + * + * @param {uuid} personId Id referencing a particular person. + * + * @param {uuid} persistedFaceId Id referencing a particular persistedFaceId of + * an existing face. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link PersistedFace} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _getFace(largePersonGroupId, personId, persistedFaceId, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + // Validate + try { + if (this.client.endpoint === null || this.client.endpoint === undefined || typeof this.client.endpoint.valueOf() !== 'string') { + throw new Error('this.client.endpoint cannot be null or undefined and it must be of type string.'); + } + if (largePersonGroupId === null || largePersonGroupId === undefined || typeof largePersonGroupId.valueOf() !== 'string') { + throw new Error('largePersonGroupId cannot be null or undefined and it must be of type string.'); + } + if (largePersonGroupId !== null && largePersonGroupId !== undefined) { + if (largePersonGroupId.length > 64) + { + throw new Error('"largePersonGroupId" should satisfy the constraint - "MaxLength": 64'); + } + if (largePersonGroupId.match(/^[a-z0-9-_]+$/) === null) + { + throw new Error('"largePersonGroupId" should satisfy the constraint - "Pattern": /^[a-z0-9-_]+$/'); + } + } + if (personId === null || personId === undefined || typeof personId.valueOf() !== 'string' || !msRest.isValidUuid(personId)) { + throw new Error('personId cannot be null or undefined and it must be of type string and must be a valid uuid.'); + } + if (persistedFaceId === null || persistedFaceId === undefined || typeof persistedFaceId.valueOf() !== 'string' || !msRest.isValidUuid(persistedFaceId)) { + throw new Error('persistedFaceId cannot be null or undefined and it must be of type string and must be a valid uuid.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'largepersongroups/{largePersonGroupId}/persons/{personId}/persistedFaces/{persistedFaceId}'; + requestUrl = requestUrl.replace('{Endpoint}', this.client.endpoint); + requestUrl = requestUrl.replace('{largePersonGroupId}', encodeURIComponent(largePersonGroupId)); + requestUrl = requestUrl.replace('{personId}', encodeURIComponent(personId.toString())); + requestUrl = requestUrl.replace('{persistedFaceId}', encodeURIComponent(persistedFaceId.toString())); + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'GET'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['APIError']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + // Deserialize Response + if (statusCode === 200) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['PersistedFace']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** + * Update a person persisted face's userData field. + * + * @param {string} largePersonGroupId Id referencing a particular large person + * group. + * + * @param {uuid} personId Id referencing a particular person. + * + * @param {uuid} persistedFaceId Id referencing a particular persistedFaceId of + * an existing face. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.userData] User-provided data attached to the face. + * The size limit is 1KB. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {null} [result] - The deserialized result object if an error did not occur. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _updateFace(largePersonGroupId, personId, persistedFaceId, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + let userData = (options && options.userData !== undefined) ? options.userData : undefined; + // Validate + try { + if (this.client.endpoint === null || this.client.endpoint === undefined || typeof this.client.endpoint.valueOf() !== 'string') { + throw new Error('this.client.endpoint cannot be null or undefined and it must be of type string.'); + } + if (largePersonGroupId === null || largePersonGroupId === undefined || typeof largePersonGroupId.valueOf() !== 'string') { + throw new Error('largePersonGroupId cannot be null or undefined and it must be of type string.'); + } + if (largePersonGroupId !== null && largePersonGroupId !== undefined) { + if (largePersonGroupId.length > 64) + { + throw new Error('"largePersonGroupId" should satisfy the constraint - "MaxLength": 64'); + } + if (largePersonGroupId.match(/^[a-z0-9-_]+$/) === null) + { + throw new Error('"largePersonGroupId" should satisfy the constraint - "Pattern": /^[a-z0-9-_]+$/'); + } + } + if (personId === null || personId === undefined || typeof personId.valueOf() !== 'string' || !msRest.isValidUuid(personId)) { + throw new Error('personId cannot be null or undefined and it must be of type string and must be a valid uuid.'); + } + if (persistedFaceId === null || persistedFaceId === undefined || typeof persistedFaceId.valueOf() !== 'string' || !msRest.isValidUuid(persistedFaceId)) { + throw new Error('persistedFaceId cannot be null or undefined and it must be of type string and must be a valid uuid.'); + } + if (userData !== null && userData !== undefined && typeof userData.valueOf() !== 'string') { + throw new Error('userData must be of type string.'); + } + if (userData !== null && userData !== undefined) { + if (userData.length > 1024) + { + throw new Error('"userData" should satisfy the constraint - "MaxLength": 1024'); + } + } + } catch (error) { + return callback(error); + } + let body; + if (userData !== null && userData !== undefined) { + body = new client.models['UpdateFaceRequest'](); + body.userData = userData; + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'largepersongroups/{largePersonGroupId}/persons/{personId}/persistedFaces/{persistedFaceId}'; + requestUrl = requestUrl.replace('{Endpoint}', this.client.endpoint); + requestUrl = requestUrl.replace('{largePersonGroupId}', encodeURIComponent(largePersonGroupId)); + requestUrl = requestUrl.replace('{personId}', encodeURIComponent(personId.toString())); + requestUrl = requestUrl.replace('{persistedFaceId}', encodeURIComponent(persistedFaceId.toString())); + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'PATCH'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + // Serialize Request + let requestContent = null; + let requestModel = null; + try { + if (body !== null && body !== undefined) { + let requestModelMapper = new client.models['UpdateFaceRequest']().mapper(); + requestModel = client.serialize(requestModelMapper, body, 'body'); + requestContent = JSON.stringify(requestModel); + } + } catch (error) { + let serializationError = new Error(`Error "${error.message}" occurred in serializing the ` + + `payload - ${JSON.stringify(body, null, 2)}.`); + return callback(serializationError); + } + httpRequest.body = requestContent; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['APIError']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + + return callback(null, result, httpRequest, response); + }); +} + +/** + * Add a representative face to a person for identification. The input face is + * specified as an image with a targetFace rectangle. + * + * @param {string} largePersonGroupId Id referencing a particular large person + * group. + * + * @param {uuid} personId Id referencing a particular person. + * + * @param {string} url Publicly reachable URL of an image + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.userData] User-specified data about the face for + * any purpose. The maximum length is 1KB. + * + * @param {array} [options.targetFace] A face rectangle to specify the target + * face to be added to a person in the format of + * "targetFace=left,top,width,height". E.g. "targetFace=10,10,100,100". If + * there is more than one face in the image, targetFace is required to specify + * which face to add. No targetFace means there is only one face detected in + * the entire image. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link PersistedFace} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _addPersonFaceFromUrl(largePersonGroupId, personId, url, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + let userData = (options && options.userData !== undefined) ? options.userData : undefined; + let targetFace = (options && options.targetFace !== undefined) ? options.targetFace : undefined; + // Validate + try { + if (this.client.endpoint === null || this.client.endpoint === undefined || typeof this.client.endpoint.valueOf() !== 'string') { + throw new Error('this.client.endpoint cannot be null or undefined and it must be of type string.'); + } + if (largePersonGroupId === null || largePersonGroupId === undefined || typeof largePersonGroupId.valueOf() !== 'string') { + throw new Error('largePersonGroupId cannot be null or undefined and it must be of type string.'); + } + if (largePersonGroupId !== null && largePersonGroupId !== undefined) { + if (largePersonGroupId.length > 64) + { + throw new Error('"largePersonGroupId" should satisfy the constraint - "MaxLength": 64'); + } + if (largePersonGroupId.match(/^[a-z0-9-_]+$/) === null) + { + throw new Error('"largePersonGroupId" should satisfy the constraint - "Pattern": /^[a-z0-9-_]+$/'); + } + } + if (personId === null || personId === undefined || typeof personId.valueOf() !== 'string' || !msRest.isValidUuid(personId)) { + throw new Error('personId cannot be null or undefined and it must be of type string and must be a valid uuid.'); + } + if (userData !== null && userData !== undefined && typeof userData.valueOf() !== 'string') { + throw new Error('userData must be of type string.'); + } + if (userData !== null && userData !== undefined) { + if (userData.length > 1024) + { + throw new Error('"userData" should satisfy the constraint - "MaxLength": 1024'); + } + } + if (Array.isArray(targetFace)) { + for (let i = 0; i < targetFace.length; i++) { + if (targetFace[i] !== null && targetFace[i] !== undefined && typeof targetFace[i] !== 'number') { + throw new Error('targetFace[i] must be of type number.'); + } + } + } + if (url === null || url === undefined || typeof url.valueOf() !== 'string') { + throw new Error('url cannot be null or undefined and it must be of type string.'); + } + } catch (error) { + return callback(error); + } + let imageUrl; + if (url !== null && url !== undefined) { + imageUrl = new client.models['ImageUrl'](); + imageUrl.url = url; + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'largepersongroups/{largePersonGroupId}/persons/{personId}/persistedFaces'; + requestUrl = requestUrl.replace('{Endpoint}', this.client.endpoint); + requestUrl = requestUrl.replace('{largePersonGroupId}', encodeURIComponent(largePersonGroupId)); + requestUrl = requestUrl.replace('{personId}', encodeURIComponent(personId.toString())); + let queryParameters = []; + if (userData !== null && userData !== undefined) { + queryParameters.push('userData=' + encodeURIComponent(userData)); + } + if (targetFace !== null && targetFace !== undefined) { + queryParameters.push('targetFace=' + encodeURIComponent(targetFace.join(','))); + } + if (queryParameters.length > 0) { + requestUrl += '?' + queryParameters.join('&'); + } + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'POST'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + // Serialize Request + let requestContent = null; + let requestModel = null; + try { + if (imageUrl !== null && imageUrl !== undefined) { + let requestModelMapper = new client.models['ImageUrl']().mapper(); + requestModel = client.serialize(requestModelMapper, imageUrl, 'imageUrl'); + requestContent = JSON.stringify(requestModel); + } + } catch (error) { + let serializationError = new Error(`Error "${error.message}" occurred in serializing the ` + + `payload - ${JSON.stringify(imageUrl, null, 2)}.`); + return callback(serializationError); + } + httpRequest.body = requestContent; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['APIError']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + // Deserialize Response + if (statusCode === 200) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['PersistedFace']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** + * Add a representative face to a person for identification. The input face is + * specified as an image with a targetFace rectangle. + * + * @param {string} largePersonGroupId Id referencing a particular large person + * group. + * + * @param {uuid} personId Id referencing a particular person. + * + * @param {object} image An image stream. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.userData] User-specified data about the face for + * any purpose. The maximum length is 1KB. + * + * @param {array} [options.targetFace] A face rectangle to specify the target + * face to be added to a person in the format of + * "targetFace=left,top,width,height". E.g. "targetFace=10,10,100,100". If + * there is more than one face in the image, targetFace is required to specify + * which face to add. No targetFace means there is only one face detected in + * the entire image. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link PersistedFace} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _addPersonFaceFromStream(largePersonGroupId, personId, image, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + let userData = (options && options.userData !== undefined) ? options.userData : undefined; + let targetFace = (options && options.targetFace !== undefined) ? options.targetFace : undefined; + // Validate + try { + if (this.client.endpoint === null || this.client.endpoint === undefined || typeof this.client.endpoint.valueOf() !== 'string') { + throw new Error('this.client.endpoint cannot be null or undefined and it must be of type string.'); + } + if (largePersonGroupId === null || largePersonGroupId === undefined || typeof largePersonGroupId.valueOf() !== 'string') { + throw new Error('largePersonGroupId cannot be null or undefined and it must be of type string.'); + } + if (largePersonGroupId !== null && largePersonGroupId !== undefined) { + if (largePersonGroupId.length > 64) + { + throw new Error('"largePersonGroupId" should satisfy the constraint - "MaxLength": 64'); + } + if (largePersonGroupId.match(/^[a-z0-9-_]+$/) === null) + { + throw new Error('"largePersonGroupId" should satisfy the constraint - "Pattern": /^[a-z0-9-_]+$/'); + } + } + if (personId === null || personId === undefined || typeof personId.valueOf() !== 'string' || !msRest.isValidUuid(personId)) { + throw new Error('personId cannot be null or undefined and it must be of type string and must be a valid uuid.'); + } + if (userData !== null && userData !== undefined && typeof userData.valueOf() !== 'string') { + throw new Error('userData must be of type string.'); + } + if (userData !== null && userData !== undefined) { + if (userData.length > 1024) + { + throw new Error('"userData" should satisfy the constraint - "MaxLength": 1024'); + } + } + if (Array.isArray(targetFace)) { + for (let i = 0; i < targetFace.length; i++) { + if (targetFace[i] !== null && targetFace[i] !== undefined && typeof targetFace[i] !== 'number') { + throw new Error('targetFace[i] must be of type number.'); + } + } + } + if (image === null || image === undefined) { + throw new Error('image cannot be null or undefined and it must be of type object.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'largepersongroups/{largePersonGroupId}/persons/{personId}/persistedFaces'; + requestUrl = requestUrl.replace('{Endpoint}', this.client.endpoint); + requestUrl = requestUrl.replace('{largePersonGroupId}', encodeURIComponent(largePersonGroupId)); + requestUrl = requestUrl.replace('{personId}', encodeURIComponent(personId.toString())); + let queryParameters = []; + if (userData !== null && userData !== undefined) { + queryParameters.push('userData=' + encodeURIComponent(userData)); + } + if (targetFace !== null && targetFace !== undefined) { + queryParameters.push('targetFace=' + encodeURIComponent(targetFace.join(','))); + } + if (queryParameters.length > 0) { + requestUrl += '?' + queryParameters.join('&'); + } + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'POST'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/octet-stream'; + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + // Serialize Request + let requestContent = image; + httpRequest.body = requestContent; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['APIError']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + // Deserialize Response + if (statusCode === 200) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['PersistedFace']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** Class representing a LargePersonGroupPerson. */ +class LargePersonGroupPerson { + /** + * Create a LargePersonGroupPerson. + * @param {FaceClient} client Reference to the service client. + */ + constructor(client) { + this.client = client; + this._create = _create; + this._list = _list; + this._deleteMethod = _deleteMethod; + this._get = _get; + this._update = _update; + this._deleteFace = _deleteFace; + this._getFace = _getFace; + this._updateFace = _updateFace; + this._addPersonFaceFromUrl = _addPersonFaceFromUrl; + this._addPersonFaceFromStream = _addPersonFaceFromStream; + } + + /** + * Create a new person in a specified large person group. + * + * @param {string} largePersonGroupId Id referencing a particular large person + * group. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.name] User defined name, maximum length is 128. + * + * @param {string} [options.userData] User specified data. Length should not + * exceed 16KB. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + createWithHttpOperationResponse(largePersonGroupId, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._create(largePersonGroupId, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Create a new person in a specified large person group. + * + * @param {string} largePersonGroupId Id referencing a particular large person + * group. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.name] User defined name, maximum length is 128. + * + * @param {string} [options.userData] User specified data. Length should not + * exceed 16KB. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {Person} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link Person} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + create(largePersonGroupId, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._create(largePersonGroupId, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._create(largePersonGroupId, options, optionalCallback); + } + } + + /** + * List all persons in a large person group, and retrieve person information + * (including personId, name, userData and persistedFaceIds of registered faces + * of the person). + * + * @param {string} largePersonGroupId Id referencing a particular large person + * group. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.start] Starting person id to return (used to list a + * range of persons). + * + * @param {number} [options.top] Number of persons to return starting with the + * person id indicated by the 'start' parameter. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + listWithHttpOperationResponse(largePersonGroupId, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._list(largePersonGroupId, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * List all persons in a large person group, and retrieve person information + * (including personId, name, userData and persistedFaceIds of registered faces + * of the person). + * + * @param {string} largePersonGroupId Id referencing a particular large person + * group. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.start] Starting person id to return (used to list a + * range of persons). + * + * @param {number} [options.top] Number of persons to return starting with the + * person id indicated by the 'start' parameter. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {Array} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {array} [result] - The deserialized result object if an error did not occur. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + list(largePersonGroupId, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._list(largePersonGroupId, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._list(largePersonGroupId, options, optionalCallback); + } + } + + /** + * Delete an existing person from a large person group. All stored person data, + * and face features in the person entry will be deleted. + * + * @param {string} largePersonGroupId Id referencing a particular large person + * group. + * + * @param {uuid} personId Id referencing a particular person. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + deleteMethodWithHttpOperationResponse(largePersonGroupId, personId, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._deleteMethod(largePersonGroupId, personId, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Delete an existing person from a large person group. All stored person data, + * and face features in the person entry will be deleted. + * + * @param {string} largePersonGroupId Id referencing a particular large person + * group. + * + * @param {uuid} personId Id referencing a particular person. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {null} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {null} [result] - The deserialized result object if an error did not occur. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + deleteMethod(largePersonGroupId, personId, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._deleteMethod(largePersonGroupId, personId, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._deleteMethod(largePersonGroupId, personId, options, optionalCallback); + } + } + + /** + * Retrieve a person's information, including registered persisted faces, name + * and userData. + * + * @param {string} largePersonGroupId Id referencing a particular large person + * group. + * + * @param {uuid} personId Id referencing a particular person. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + getWithHttpOperationResponse(largePersonGroupId, personId, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._get(largePersonGroupId, personId, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Retrieve a person's information, including registered persisted faces, name + * and userData. + * + * @param {string} largePersonGroupId Id referencing a particular large person + * group. + * + * @param {uuid} personId Id referencing a particular person. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {Person} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link Person} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + get(largePersonGroupId, personId, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._get(largePersonGroupId, personId, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._get(largePersonGroupId, personId, options, optionalCallback); + } + } + + /** + * Update name or userData of a person. + * + * @param {string} largePersonGroupId Id referencing a particular large person + * group. + * + * @param {uuid} personId Id referencing a particular person. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.name] User defined name, maximum length is 128. + * + * @param {string} [options.userData] User specified data. Length should not + * exceed 16KB. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + updateWithHttpOperationResponse(largePersonGroupId, personId, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._update(largePersonGroupId, personId, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Update name or userData of a person. + * + * @param {string} largePersonGroupId Id referencing a particular large person + * group. + * + * @param {uuid} personId Id referencing a particular person. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.name] User defined name, maximum length is 128. + * + * @param {string} [options.userData] User specified data. Length should not + * exceed 16KB. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {null} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {null} [result] - The deserialized result object if an error did not occur. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + update(largePersonGroupId, personId, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._update(largePersonGroupId, personId, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._update(largePersonGroupId, personId, options, optionalCallback); + } + } + + /** + * Delete a face from a person. Relative feature for the persisted face will + * also be deleted. + * + * @param {string} largePersonGroupId Id referencing a particular large person + * group. + * + * @param {uuid} personId Id referencing a particular person. + * + * @param {uuid} persistedFaceId Id referencing a particular persistedFaceId of + * an existing face. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + deleteFaceWithHttpOperationResponse(largePersonGroupId, personId, persistedFaceId, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._deleteFace(largePersonGroupId, personId, persistedFaceId, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Delete a face from a person. Relative feature for the persisted face will + * also be deleted. + * + * @param {string} largePersonGroupId Id referencing a particular large person + * group. + * + * @param {uuid} personId Id referencing a particular person. + * + * @param {uuid} persistedFaceId Id referencing a particular persistedFaceId of + * an existing face. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {null} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {null} [result] - The deserialized result object if an error did not occur. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + deleteFace(largePersonGroupId, personId, persistedFaceId, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._deleteFace(largePersonGroupId, personId, persistedFaceId, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._deleteFace(largePersonGroupId, personId, persistedFaceId, options, optionalCallback); + } + } + + /** + * Retrieve information about a persisted face (specified by persistedFaceId, + * personId and its belonging largePersonGroupId). + * + * @param {string} largePersonGroupId Id referencing a particular large person + * group. + * + * @param {uuid} personId Id referencing a particular person. + * + * @param {uuid} persistedFaceId Id referencing a particular persistedFaceId of + * an existing face. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + getFaceWithHttpOperationResponse(largePersonGroupId, personId, persistedFaceId, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._getFace(largePersonGroupId, personId, persistedFaceId, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Retrieve information about a persisted face (specified by persistedFaceId, + * personId and its belonging largePersonGroupId). + * + * @param {string} largePersonGroupId Id referencing a particular large person + * group. + * + * @param {uuid} personId Id referencing a particular person. + * + * @param {uuid} persistedFaceId Id referencing a particular persistedFaceId of + * an existing face. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {PersistedFace} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link PersistedFace} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + getFace(largePersonGroupId, personId, persistedFaceId, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._getFace(largePersonGroupId, personId, persistedFaceId, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._getFace(largePersonGroupId, personId, persistedFaceId, options, optionalCallback); + } + } + + /** + * Update a person persisted face's userData field. + * + * @param {string} largePersonGroupId Id referencing a particular large person + * group. + * + * @param {uuid} personId Id referencing a particular person. + * + * @param {uuid} persistedFaceId Id referencing a particular persistedFaceId of + * an existing face. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.userData] User-provided data attached to the face. + * The size limit is 1KB. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + updateFaceWithHttpOperationResponse(largePersonGroupId, personId, persistedFaceId, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._updateFace(largePersonGroupId, personId, persistedFaceId, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Update a person persisted face's userData field. + * + * @param {string} largePersonGroupId Id referencing a particular large person + * group. + * + * @param {uuid} personId Id referencing a particular person. + * + * @param {uuid} persistedFaceId Id referencing a particular persistedFaceId of + * an existing face. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.userData] User-provided data attached to the face. + * The size limit is 1KB. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {null} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {null} [result] - The deserialized result object if an error did not occur. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + updateFace(largePersonGroupId, personId, persistedFaceId, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._updateFace(largePersonGroupId, personId, persistedFaceId, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._updateFace(largePersonGroupId, personId, persistedFaceId, options, optionalCallback); + } + } + + /** + * Add a representative face to a person for identification. The input face is + * specified as an image with a targetFace rectangle. + * + * @param {string} largePersonGroupId Id referencing a particular large person + * group. + * + * @param {uuid} personId Id referencing a particular person. + * + * @param {string} url Publicly reachable URL of an image + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.userData] User-specified data about the face for + * any purpose. The maximum length is 1KB. + * + * @param {array} [options.targetFace] A face rectangle to specify the target + * face to be added to a person in the format of + * "targetFace=left,top,width,height". E.g. "targetFace=10,10,100,100". If + * there is more than one face in the image, targetFace is required to specify + * which face to add. No targetFace means there is only one face detected in + * the entire image. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + addPersonFaceFromUrlWithHttpOperationResponse(largePersonGroupId, personId, url, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._addPersonFaceFromUrl(largePersonGroupId, personId, url, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Add a representative face to a person for identification. The input face is + * specified as an image with a targetFace rectangle. + * + * @param {string} largePersonGroupId Id referencing a particular large person + * group. + * + * @param {uuid} personId Id referencing a particular person. + * + * @param {string} url Publicly reachable URL of an image + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.userData] User-specified data about the face for + * any purpose. The maximum length is 1KB. + * + * @param {array} [options.targetFace] A face rectangle to specify the target + * face to be added to a person in the format of + * "targetFace=left,top,width,height". E.g. "targetFace=10,10,100,100". If + * there is more than one face in the image, targetFace is required to specify + * which face to add. No targetFace means there is only one face detected in + * the entire image. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {PersistedFace} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link PersistedFace} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + addPersonFaceFromUrl(largePersonGroupId, personId, url, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._addPersonFaceFromUrl(largePersonGroupId, personId, url, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._addPersonFaceFromUrl(largePersonGroupId, personId, url, options, optionalCallback); + } + } + + /** + * Add a representative face to a person for identification. The input face is + * specified as an image with a targetFace rectangle. + * + * @param {string} largePersonGroupId Id referencing a particular large person + * group. + * + * @param {uuid} personId Id referencing a particular person. + * + * @param {object} image An image stream. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.userData] User-specified data about the face for + * any purpose. The maximum length is 1KB. + * + * @param {array} [options.targetFace] A face rectangle to specify the target + * face to be added to a person in the format of + * "targetFace=left,top,width,height". E.g. "targetFace=10,10,100,100". If + * there is more than one face in the image, targetFace is required to specify + * which face to add. No targetFace means there is only one face detected in + * the entire image. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + addPersonFaceFromStreamWithHttpOperationResponse(largePersonGroupId, personId, image, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._addPersonFaceFromStream(largePersonGroupId, personId, image, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Add a representative face to a person for identification. The input face is + * specified as an image with a targetFace rectangle. + * + * @param {string} largePersonGroupId Id referencing a particular large person + * group. + * + * @param {uuid} personId Id referencing a particular person. + * + * @param {object} image An image stream. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.userData] User-specified data about the face for + * any purpose. The maximum length is 1KB. + * + * @param {array} [options.targetFace] A face rectangle to specify the target + * face to be added to a person in the format of + * "targetFace=left,top,width,height". E.g. "targetFace=10,10,100,100". If + * there is more than one face in the image, targetFace is required to specify + * which face to add. No targetFace means there is only one face detected in + * the entire image. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {PersistedFace} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link PersistedFace} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + addPersonFaceFromStream(largePersonGroupId, personId, image, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._addPersonFaceFromStream(largePersonGroupId, personId, image, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._addPersonFaceFromStream(largePersonGroupId, personId, image, options, optionalCallback); + } + } + +} + +module.exports = LargePersonGroupPerson; diff --git a/lib/services/face/lib/operations/personGroupOperations.js b/lib/services/face/lib/operations/personGroupOperations.js index 32beb1cc70..f71b0b8eba 100644 --- a/lib/services/face/lib/operations/personGroupOperations.js +++ b/lib/services/face/lib/operations/personGroupOperations.js @@ -175,8 +175,8 @@ function _create(personGroupId, options, callback) { } /** - * Delete an existing person group. Persisted face images of all people in the - * person group will also be deleted. + * Delete an existing person group. Persisted face features of all people in + * the person group will also be deleted. * * @param {string} personGroupId Id referencing a particular person group. * @@ -1113,8 +1113,8 @@ class PersonGroupOperations { } /** - * Delete an existing person group. Persisted face images of all people in the - * person group will also be deleted. + * Delete an existing person group. Persisted face features of all people in + * the person group will also be deleted. * * @param {string} personGroupId Id referencing a particular person group. * @@ -1144,8 +1144,8 @@ class PersonGroupOperations { } /** - * Delete an existing person group. Persisted face images of all people in the - * person group will also be deleted. + * Delete an existing person group. Persisted face features of all people in + * the person group will also be deleted. * * @param {string} personGroupId Id referencing a particular person group. * diff --git a/lib/services/face/lib/operations/personGroupPerson.js b/lib/services/face/lib/operations/personGroupPerson.js index 92f012e710..8c1b3ee14e 100644 --- a/lib/services/face/lib/operations/personGroupPerson.js +++ b/lib/services/face/lib/operations/personGroupPerson.js @@ -374,8 +374,8 @@ function _list(personGroupId, options, callback) { } /** - * Delete an existing person from a person group. Persisted face images of the - * person will also be deleted. + * Delete an existing person from a person group. All stored person data, and + * face features in the person entry will be deleted. * * @param {string} personGroupId Id referencing a particular person group. * @@ -802,8 +802,8 @@ function _update(personGroupId, personId, options, callback) { } /** - * Delete a face from a person. Relative image for the persisted face will also - * be deleted. + * Delete a face from a person. Relative feature for the persisted face will + * also be deleted. * * @param {string} personGroupId Id referencing a particular person group. * @@ -1156,7 +1156,7 @@ function _updateFace(personGroupId, personId, persistedFaceId, options, callback } let body; if (userData !== null && userData !== undefined) { - body = new client.models['UpdatePersonFaceRequest'](); + body = new client.models['UpdateFaceRequest'](); body.userData = userData; } @@ -1187,7 +1187,7 @@ function _updateFace(personGroupId, personId, persistedFaceId, options, callback let requestModel = null; try { if (body !== null && body !== undefined) { - let requestModelMapper = new client.models['UpdatePersonFaceRequest']().mapper(); + let requestModelMapper = new client.models['UpdateFaceRequest']().mapper(); requestModel = client.serialize(requestModelMapper, body, 'body'); requestContent = JSON.stringify(requestModel); } @@ -1834,8 +1834,8 @@ class PersonGroupPerson { } /** - * Delete an existing person from a person group. Persisted face images of the - * person will also be deleted. + * Delete an existing person from a person group. All stored person data, and + * face features in the person entry will be deleted. * * @param {string} personGroupId Id referencing a particular person group. * @@ -1867,8 +1867,8 @@ class PersonGroupPerson { } /** - * Delete an existing person from a person group. Persisted face images of the - * person will also be deleted. + * Delete an existing person from a person group. All stored person data, and + * face features in the person entry will be deleted. * * @param {string} personGroupId Id referencing a particular person group. * @@ -2104,8 +2104,8 @@ class PersonGroupPerson { } /** - * Delete a face from a person. Relative image for the persisted face will also - * be deleted. + * Delete a face from a person. Relative feature for the persisted face will + * also be deleted. * * @param {string} personGroupId Id referencing a particular person group. * @@ -2140,8 +2140,8 @@ class PersonGroupPerson { } /** - * Delete a face from a person. Relative image for the persisted face will also - * be deleted. + * Delete a face from a person. Relative feature for the persisted face will + * also be deleted. * * @param {string} personGroupId Id referencing a particular person group. * diff --git a/lib/services/face/package.json b/lib/services/face/package.json index 0742ce3b32..1971205c35 100644 --- a/lib/services/face/package.json +++ b/lib/services/face/package.json @@ -13,12 +13,12 @@ "license": "MIT", "main": "./lib/faceClient.js", "types": "./lib/faceClient.d.ts", - "homepage": "http://github.com/azure/azure-sdk-for-node", + "homepage": "https://github.com/azure/azure-sdk-for-node", "repository": { "type": "git", "url": "https://github.com/azure/azure-sdk-for-node.git" }, "bugs": { - "url": "http://github.com/Azure/azure-sdk-for-node/issues" + "url": "https://github.com/azure/azure-sdk-for-node/issues" } } From e23ca1ddaf94b0d2f51a790868c420907a23cd2e Mon Sep 17 00:00:00 2001 From: Azure SDK for Python bot Date: Tue, 31 Jul 2018 06:58:50 +0000 Subject: [PATCH 2/5] Generated from a2c9e881121ab738c6142713fd66d08629b7a475 Nit path case refinement. --- lib/services/face/lib/operations/faceListOperations.js | 6 +++--- lib/services/face/lib/operations/largeFaceListFace.js | 2 +- .../face/lib/operations/largeFaceListOperations.js | 10 +++++----- .../face/lib/operations/largePersonGroupPerson.js | 10 +++++----- lib/services/face/lib/operations/personGroupPerson.js | 10 +++++----- 5 files changed, 19 insertions(+), 19 deletions(-) diff --git a/lib/services/face/lib/operations/faceListOperations.js b/lib/services/face/lib/operations/faceListOperations.js index e7a71f8a6a..4a07e8019a 100644 --- a/lib/services/face/lib/operations/faceListOperations.js +++ b/lib/services/face/lib/operations/faceListOperations.js @@ -777,7 +777,7 @@ function _deleteFace(faceListId, persistedFaceId, options, callback) { // Construct URL let baseUrl = this.client.baseUri; - let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'facelists/{faceListId}/persistedFaces/{persistedFaceId}'; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'facelists/{faceListId}/persistedfaces/{persistedFaceId}'; requestUrl = requestUrl.replace('{Endpoint}', this.client.endpoint); requestUrl = requestUrl.replace('{faceListId}', encodeURIComponent(faceListId)); requestUrl = requestUrl.replace('{persistedFaceId}', encodeURIComponent(persistedFaceId.toString())); @@ -934,7 +934,7 @@ function _addFaceFromUrl(faceListId, url, options, callback) { // Construct URL let baseUrl = this.client.baseUri; - let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'facelists/{faceListId}/persistedFaces'; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'facelists/{faceListId}/persistedfaces'; requestUrl = requestUrl.replace('{Endpoint}', this.client.endpoint); requestUrl = requestUrl.replace('{faceListId}', encodeURIComponent(faceListId)); let queryParameters = []; @@ -1126,7 +1126,7 @@ function _addFaceFromStream(faceListId, image, options, callback) { // Construct URL let baseUrl = this.client.baseUri; - let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'facelists/{faceListId}/persistedFaces'; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'facelists/{faceListId}/persistedfaces'; requestUrl = requestUrl.replace('{Endpoint}', this.client.endpoint); requestUrl = requestUrl.replace('{faceListId}', encodeURIComponent(faceListId)); let queryParameters = []; diff --git a/lib/services/face/lib/operations/largeFaceListFace.js b/lib/services/face/lib/operations/largeFaceListFace.js index ab6abd4743..ce715aeb43 100644 --- a/lib/services/face/lib/operations/largeFaceListFace.js +++ b/lib/services/face/lib/operations/largeFaceListFace.js @@ -94,7 +94,7 @@ function _list(largeFaceListId, options, callback) { // Construct URL let baseUrl = this.client.baseUri; - let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'largefacelists/{largeFaceListId}/persistedFaces'; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'largefacelists/{largeFaceListId}/persistedfaces'; requestUrl = requestUrl.replace('{Endpoint}', this.client.endpoint); requestUrl = requestUrl.replace('{largeFaceListId}', encodeURIComponent(largeFaceListId)); let queryParameters = []; diff --git a/lib/services/face/lib/operations/largeFaceListOperations.js b/lib/services/face/lib/operations/largeFaceListOperations.js index e500e306aa..6ae6367512 100644 --- a/lib/services/face/lib/operations/largeFaceListOperations.js +++ b/lib/services/face/lib/operations/largeFaceListOperations.js @@ -1027,7 +1027,7 @@ function _deleteFace(largeFaceListId, persistedFaceId, options, callback) { // Construct URL let baseUrl = this.client.baseUri; - let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'largefacelists/{largeFaceListId}/persistedFaces/{persistedFaceId}'; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'largefacelists/{largeFaceListId}/persistedfaces/{persistedFaceId}'; requestUrl = requestUrl.replace('{Endpoint}', this.client.endpoint); requestUrl = requestUrl.replace('{largeFaceListId}', encodeURIComponent(largeFaceListId)); requestUrl = requestUrl.replace('{persistedFaceId}', encodeURIComponent(persistedFaceId.toString())); @@ -1151,7 +1151,7 @@ function _getFace(largeFaceListId, persistedFaceId, options, callback) { // Construct URL let baseUrl = this.client.baseUri; - let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'largefacelists/{largeFaceListId}/persistedFaces/{persistedFaceId}'; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'largefacelists/{largeFaceListId}/persistedfaces/{persistedFaceId}'; requestUrl = requestUrl.replace('{Endpoint}', this.client.endpoint); requestUrl = requestUrl.replace('{largeFaceListId}', encodeURIComponent(largeFaceListId)); requestUrl = requestUrl.replace('{persistedFaceId}', encodeURIComponent(persistedFaceId.toString())); @@ -1308,7 +1308,7 @@ function _updateFace(largeFaceListId, persistedFaceId, options, callback) { // Construct URL let baseUrl = this.client.baseUri; - let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'largefacelists/{largeFaceListId}/persistedFaces/{persistedFaceId}'; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'largefacelists/{largeFaceListId}/persistedfaces/{persistedFaceId}'; requestUrl = requestUrl.replace('{Endpoint}', this.client.endpoint); requestUrl = requestUrl.replace('{largeFaceListId}', encodeURIComponent(largeFaceListId)); requestUrl = requestUrl.replace('{persistedFaceId}', encodeURIComponent(persistedFaceId.toString())); @@ -1479,7 +1479,7 @@ function _addFaceFromUrl(largeFaceListId, url, options, callback) { // Construct URL let baseUrl = this.client.baseUri; - let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'largefacelists/{largeFaceListId}/persistedFaces'; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'largefacelists/{largeFaceListId}/persistedfaces'; requestUrl = requestUrl.replace('{Endpoint}', this.client.endpoint); requestUrl = requestUrl.replace('{largeFaceListId}', encodeURIComponent(largeFaceListId)); let queryParameters = []; @@ -1671,7 +1671,7 @@ function _addFaceFromStream(largeFaceListId, image, options, callback) { // Construct URL let baseUrl = this.client.baseUri; - let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'largefacelists/{largeFaceListId}/persistedFaces'; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'largefacelists/{largeFaceListId}/persistedfaces'; requestUrl = requestUrl.replace('{Endpoint}', this.client.endpoint); requestUrl = requestUrl.replace('{largeFaceListId}', encodeURIComponent(largeFaceListId)); let queryParameters = []; diff --git a/lib/services/face/lib/operations/largePersonGroupPerson.js b/lib/services/face/lib/operations/largePersonGroupPerson.js index fe5d3e7439..aad1737238 100644 --- a/lib/services/face/lib/operations/largePersonGroupPerson.js +++ b/lib/services/face/lib/operations/largePersonGroupPerson.js @@ -875,7 +875,7 @@ function _deleteFace(largePersonGroupId, personId, persistedFaceId, options, cal // Construct URL let baseUrl = this.client.baseUri; - let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'largepersongroups/{largePersonGroupId}/persons/{personId}/persistedFaces/{persistedFaceId}'; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'largepersongroups/{largePersonGroupId}/persons/{personId}/persistedfaces/{persistedFaceId}'; requestUrl = requestUrl.replace('{Endpoint}', this.client.endpoint); requestUrl = requestUrl.replace('{largePersonGroupId}', encodeURIComponent(largePersonGroupId)); requestUrl = requestUrl.replace('{personId}', encodeURIComponent(personId.toString())); @@ -1006,7 +1006,7 @@ function _getFace(largePersonGroupId, personId, persistedFaceId, options, callba // Construct URL let baseUrl = this.client.baseUri; - let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'largepersongroups/{largePersonGroupId}/persons/{personId}/persistedFaces/{persistedFaceId}'; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'largepersongroups/{largePersonGroupId}/persons/{personId}/persistedfaces/{persistedFaceId}'; requestUrl = requestUrl.replace('{Endpoint}', this.client.endpoint); requestUrl = requestUrl.replace('{largePersonGroupId}', encodeURIComponent(largePersonGroupId)); requestUrl = requestUrl.replace('{personId}', encodeURIComponent(personId.toString())); @@ -1170,7 +1170,7 @@ function _updateFace(largePersonGroupId, personId, persistedFaceId, options, cal // Construct URL let baseUrl = this.client.baseUri; - let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'largepersongroups/{largePersonGroupId}/persons/{personId}/persistedFaces/{persistedFaceId}'; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'largepersongroups/{largePersonGroupId}/persons/{personId}/persistedfaces/{persistedFaceId}'; requestUrl = requestUrl.replace('{Endpoint}', this.client.endpoint); requestUrl = requestUrl.replace('{largePersonGroupId}', encodeURIComponent(largePersonGroupId)); requestUrl = requestUrl.replace('{personId}', encodeURIComponent(personId.toString())); @@ -1347,7 +1347,7 @@ function _addPersonFaceFromUrl(largePersonGroupId, personId, url, options, callb // Construct URL let baseUrl = this.client.baseUri; - let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'largepersongroups/{largePersonGroupId}/persons/{personId}/persistedFaces'; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'largepersongroups/{largePersonGroupId}/persons/{personId}/persistedfaces'; requestUrl = requestUrl.replace('{Endpoint}', this.client.endpoint); requestUrl = requestUrl.replace('{largePersonGroupId}', encodeURIComponent(largePersonGroupId)); requestUrl = requestUrl.replace('{personId}', encodeURIComponent(personId.toString())); @@ -1545,7 +1545,7 @@ function _addPersonFaceFromStream(largePersonGroupId, personId, image, options, // Construct URL let baseUrl = this.client.baseUri; - let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'largepersongroups/{largePersonGroupId}/persons/{personId}/persistedFaces'; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'largepersongroups/{largePersonGroupId}/persons/{personId}/persistedfaces'; requestUrl = requestUrl.replace('{Endpoint}', this.client.endpoint); requestUrl = requestUrl.replace('{largePersonGroupId}', encodeURIComponent(largePersonGroupId)); requestUrl = requestUrl.replace('{personId}', encodeURIComponent(personId.toString())); diff --git a/lib/services/face/lib/operations/personGroupPerson.js b/lib/services/face/lib/operations/personGroupPerson.js index 8c1b3ee14e..b9ef0d9bf9 100644 --- a/lib/services/face/lib/operations/personGroupPerson.js +++ b/lib/services/face/lib/operations/personGroupPerson.js @@ -869,7 +869,7 @@ function _deleteFace(personGroupId, personId, persistedFaceId, options, callback // Construct URL let baseUrl = this.client.baseUri; - let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'persongroups/{personGroupId}/persons/{personId}/persistedFaces/{persistedFaceId}'; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'persongroups/{personGroupId}/persons/{personId}/persistedfaces/{persistedFaceId}'; requestUrl = requestUrl.replace('{Endpoint}', this.client.endpoint); requestUrl = requestUrl.replace('{personGroupId}', encodeURIComponent(personGroupId)); requestUrl = requestUrl.replace('{personId}', encodeURIComponent(personId.toString())); @@ -999,7 +999,7 @@ function _getFace(personGroupId, personId, persistedFaceId, options, callback) { // Construct URL let baseUrl = this.client.baseUri; - let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'persongroups/{personGroupId}/persons/{personId}/persistedFaces/{persistedFaceId}'; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'persongroups/{personGroupId}/persons/{personId}/persistedfaces/{persistedFaceId}'; requestUrl = requestUrl.replace('{Endpoint}', this.client.endpoint); requestUrl = requestUrl.replace('{personGroupId}', encodeURIComponent(personGroupId)); requestUrl = requestUrl.replace('{personId}', encodeURIComponent(personId.toString())); @@ -1162,7 +1162,7 @@ function _updateFace(personGroupId, personId, persistedFaceId, options, callback // Construct URL let baseUrl = this.client.baseUri; - let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'persongroups/{personGroupId}/persons/{personId}/persistedFaces/{persistedFaceId}'; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'persongroups/{personGroupId}/persons/{personId}/persistedfaces/{persistedFaceId}'; requestUrl = requestUrl.replace('{Endpoint}', this.client.endpoint); requestUrl = requestUrl.replace('{personGroupId}', encodeURIComponent(personGroupId)); requestUrl = requestUrl.replace('{personId}', encodeURIComponent(personId.toString())); @@ -1338,7 +1338,7 @@ function _addPersonFaceFromUrl(personGroupId, personId, url, options, callback) // Construct URL let baseUrl = this.client.baseUri; - let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'persongroups/{personGroupId}/persons/{personId}/persistedFaces'; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'persongroups/{personGroupId}/persons/{personId}/persistedfaces'; requestUrl = requestUrl.replace('{Endpoint}', this.client.endpoint); requestUrl = requestUrl.replace('{personGroupId}', encodeURIComponent(personGroupId)); requestUrl = requestUrl.replace('{personId}', encodeURIComponent(personId.toString())); @@ -1535,7 +1535,7 @@ function _addPersonFaceFromStream(personGroupId, personId, image, options, callb // Construct URL let baseUrl = this.client.baseUri; - let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'persongroups/{personGroupId}/persons/{personId}/persistedFaces'; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'persongroups/{personGroupId}/persons/{personId}/persistedfaces'; requestUrl = requestUrl.replace('{Endpoint}', this.client.endpoint); requestUrl = requestUrl.replace('{personGroupId}', encodeURIComponent(personGroupId)); requestUrl = requestUrl.replace('{personId}', encodeURIComponent(personId.toString())); From fb3573932b191764c16abbba514719c16a57df7e Mon Sep 17 00:00:00 2001 From: Azure SDK for Python bot Date: Wed, 1 Aug 2018 00:37:30 +0000 Subject: [PATCH 3/5] Generated from 40abfc7205d1bf373e19dca40394598fa9da4843 Fix LargeFaceListFace_List to LargeFaceList_ListFaces and refine example naming. --- lib/services/face/lib/faceClient.d.ts | 1 - lib/services/face/lib/faceClient.js | 1 - lib/services/face/lib/operations/index.d.ts | 115 ++++---- lib/services/face/lib/operations/index.js | 1 - .../lib/operations/largeFaceListOperations.js | 277 ++++++++++++++++++ 5 files changed, 330 insertions(+), 65 deletions(-) diff --git a/lib/services/face/lib/faceClient.d.ts b/lib/services/face/lib/faceClient.d.ts index 66aa99bcac..6485fa976a 100644 --- a/lib/services/face/lib/faceClient.d.ts +++ b/lib/services/face/lib/faceClient.d.ts @@ -46,7 +46,6 @@ export default class FaceClient extends ServiceClient { largePersonGroupPerson: operations.LargePersonGroupPerson; largePersonGroupOperations: operations.LargePersonGroupOperations; largeFaceListOperations: operations.LargeFaceListOperations; - largeFaceListFace: operations.LargeFaceListFace; } export { FaceClient, models as FaceModels }; diff --git a/lib/services/face/lib/faceClient.js b/lib/services/face/lib/faceClient.js index b32879c45e..b8403a3e8a 100644 --- a/lib/services/face/lib/faceClient.js +++ b/lib/services/face/lib/faceClient.js @@ -58,7 +58,6 @@ class FaceClient extends ServiceClient { this.largePersonGroupPerson = new operations.LargePersonGroupPerson(this); this.largePersonGroupOperations = new operations.LargePersonGroupOperations(this); this.largeFaceListOperations = new operations.LargeFaceListOperations(this); - this.largeFaceListFace = new operations.LargeFaceListFace(this); this.models = models; msRest.addSerializationMixin(this); } diff --git a/lib/services/face/lib/operations/index.d.ts b/lib/services/face/lib/operations/index.d.ts index 1578827d29..39f04221bf 100644 --- a/lib/services/face/lib/operations/index.d.ts +++ b/lib/services/face/lib/operations/index.d.ts @@ -4101,57 +4101,43 @@ export interface LargeFaceListOperations { /** - * Add a face to a large face list. The input face is specified as an image - * with a targetFace rectangle. It returns a persistedFaceId representing the - * added face, and persistedFaceId will not expire. + * List all faces in a large face list, and retrieve face information + * (including userData and persistedFaceIds of registered faces of the face). * * @param {string} largeFaceListId Id referencing a particular large face list. * - * @param {object} image An image stream. - * * @param {object} [options] Optional Parameters. * - * @param {string} [options.userData] User-specified data about the face for - * any purpose. The maximum length is 1KB. + * @param {string} [options.start] Starting face id to return (used to list a + * range of faces). * - * @param {array} [options.targetFace] A face rectangle to specify the target - * face to be added to a person in the format of - * "targetFace=left,top,width,height". E.g. "targetFace=10,10,100,100". If - * there is more than one face in the image, targetFace is required to specify - * which face to add. No targetFace means there is only one face detected in - * the entire image. + * @param {number} [options.top] Number of faces to return starting with the + * face id indicated by the 'start' parameter. * * @param {object} [options.customHeaders] Headers that will be added to the * request * * @returns {Promise} A promise is returned * - * @resolve {HttpOperationResponse} - The deserialized result object. + * @resolve {HttpOperationResponse} - The deserialized result object. * * @reject {Error|ServiceError} - The error object. */ - addFaceFromStreamWithHttpOperationResponse(largeFaceListId: string, image: stream.Readable, options?: { userData? : string, targetFace? : number[], customHeaders? : { [headerName: string]: string; } }): Promise>; + listFacesWithHttpOperationResponse(largeFaceListId: string, options?: { start? : string, top? : number, customHeaders? : { [headerName: string]: string; } }): Promise>; /** - * Add a face to a large face list. The input face is specified as an image - * with a targetFace rectangle. It returns a persistedFaceId representing the - * added face, and persistedFaceId will not expire. + * List all faces in a large face list, and retrieve face information + * (including userData and persistedFaceIds of registered faces of the face). * * @param {string} largeFaceListId Id referencing a particular large face list. * - * @param {object} image An image stream. - * * @param {object} [options] Optional Parameters. * - * @param {string} [options.userData] User-specified data about the face for - * any purpose. The maximum length is 1KB. + * @param {string} [options.start] Starting face id to return (used to list a + * range of faces). * - * @param {array} [options.targetFace] A face rectangle to specify the target - * face to be added to a person in the format of - * "targetFace=left,top,width,height". E.g. "targetFace=10,10,100,100". If - * there is more than one face in the image, targetFace is required to specify - * which face to add. No targetFace means there is only one face detected in - * the entire image. + * @param {number} [options.top] Number of faces to return starting with the + * face id indicated by the 'start' parameter. * * @param {object} [options.customHeaders] Headers that will be added to the * request @@ -4163,7 +4149,7 @@ export interface LargeFaceListOperations { * * {Promise} A promise is returned. * - * @resolve {PersistedFace} - The deserialized result object. + * @resolve {Array} - The deserialized result object. * * @reject {Error|ServiceError} - The error object. * @@ -4171,65 +4157,69 @@ export interface LargeFaceListOperations { * * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. * - * {PersistedFace} [result] - The deserialized result object if an error did not occur. - * See {@link PersistedFace} for more information. + * {Array} [result] - The deserialized result object if an error did not occur. * * {WebResource} [request] - The HTTP Request object if an error did not occur. * * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. */ - addFaceFromStream(largeFaceListId: string, image: stream.Readable, options?: { userData? : string, targetFace? : number[], customHeaders? : { [headerName: string]: string; } }): Promise; - addFaceFromStream(largeFaceListId: string, image: stream.Readable, callback: ServiceCallback): void; - addFaceFromStream(largeFaceListId: string, image: stream.Readable, options: { userData? : string, targetFace? : number[], customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; -} - -/** - * @class - * LargeFaceListFace - * __NOTE__: An instance of this class is automatically created for an - * instance of the FaceClient. - */ -export interface LargeFaceListFace { + listFaces(largeFaceListId: string, options?: { start? : string, top? : number, customHeaders? : { [headerName: string]: string; } }): Promise; + listFaces(largeFaceListId: string, callback: ServiceCallback): void; + listFaces(largeFaceListId: string, options: { start? : string, top? : number, customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; /** - * List all faces in a large face list, and retrieve face information - * (including userData and persistedFaceIds of registered faces of the face). + * Add a face to a large face list. The input face is specified as an image + * with a targetFace rectangle. It returns a persistedFaceId representing the + * added face, and persistedFaceId will not expire. * * @param {string} largeFaceListId Id referencing a particular large face list. * + * @param {object} image An image stream. + * * @param {object} [options] Optional Parameters. * - * @param {string} [options.start] Starting face id to return (used to list a - * range of faces). + * @param {string} [options.userData] User-specified data about the face for + * any purpose. The maximum length is 1KB. * - * @param {number} [options.top] Number of faces to return starting with the - * face id indicated by the 'start' parameter. + * @param {array} [options.targetFace] A face rectangle to specify the target + * face to be added to a person in the format of + * "targetFace=left,top,width,height". E.g. "targetFace=10,10,100,100". If + * there is more than one face in the image, targetFace is required to specify + * which face to add. No targetFace means there is only one face detected in + * the entire image. * * @param {object} [options.customHeaders] Headers that will be added to the * request * * @returns {Promise} A promise is returned * - * @resolve {HttpOperationResponse} - The deserialized result object. + * @resolve {HttpOperationResponse} - The deserialized result object. * * @reject {Error|ServiceError} - The error object. */ - listWithHttpOperationResponse(largeFaceListId: string, options?: { start? : string, top? : number, customHeaders? : { [headerName: string]: string; } }): Promise>; + addFaceFromStreamWithHttpOperationResponse(largeFaceListId: string, image: stream.Readable, options?: { userData? : string, targetFace? : number[], customHeaders? : { [headerName: string]: string; } }): Promise>; /** - * List all faces in a large face list, and retrieve face information - * (including userData and persistedFaceIds of registered faces of the face). + * Add a face to a large face list. The input face is specified as an image + * with a targetFace rectangle. It returns a persistedFaceId representing the + * added face, and persistedFaceId will not expire. * * @param {string} largeFaceListId Id referencing a particular large face list. * + * @param {object} image An image stream. + * * @param {object} [options] Optional Parameters. * - * @param {string} [options.start] Starting face id to return (used to list a - * range of faces). + * @param {string} [options.userData] User-specified data about the face for + * any purpose. The maximum length is 1KB. * - * @param {number} [options.top] Number of faces to return starting with the - * face id indicated by the 'start' parameter. + * @param {array} [options.targetFace] A face rectangle to specify the target + * face to be added to a person in the format of + * "targetFace=left,top,width,height". E.g. "targetFace=10,10,100,100". If + * there is more than one face in the image, targetFace is required to specify + * which face to add. No targetFace means there is only one face detected in + * the entire image. * * @param {object} [options.customHeaders] Headers that will be added to the * request @@ -4241,7 +4231,7 @@ export interface LargeFaceListFace { * * {Promise} A promise is returned. * - * @resolve {Array} - The deserialized result object. + * @resolve {PersistedFace} - The deserialized result object. * * @reject {Error|ServiceError} - The error object. * @@ -4249,13 +4239,14 @@ export interface LargeFaceListFace { * * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. * - * {Array} [result] - The deserialized result object if an error did not occur. + * {PersistedFace} [result] - The deserialized result object if an error did not occur. + * See {@link PersistedFace} for more information. * * {WebResource} [request] - The HTTP Request object if an error did not occur. * * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. */ - list(largeFaceListId: string, options?: { start? : string, top? : number, customHeaders? : { [headerName: string]: string; } }): Promise; - list(largeFaceListId: string, callback: ServiceCallback): void; - list(largeFaceListId: string, options: { start? : string, top? : number, customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + addFaceFromStream(largeFaceListId: string, image: stream.Readable, options?: { userData? : string, targetFace? : number[], customHeaders? : { [headerName: string]: string; } }): Promise; + addFaceFromStream(largeFaceListId: string, image: stream.Readable, callback: ServiceCallback): void; + addFaceFromStream(largeFaceListId: string, image: stream.Readable, options: { userData? : string, targetFace? : number[], customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; } diff --git a/lib/services/face/lib/operations/index.js b/lib/services/face/lib/operations/index.js index 032c687225..afc063bbab 100644 --- a/lib/services/face/lib/operations/index.js +++ b/lib/services/face/lib/operations/index.js @@ -21,4 +21,3 @@ exports.FaceListOperations = require('./faceListOperations'); exports.LargePersonGroupPerson = require('./largePersonGroupPerson'); exports.LargePersonGroupOperations = require('./largePersonGroupOperations'); exports.LargeFaceListOperations = require('./largeFaceListOperations'); -exports.LargeFaceListFace = require('./largeFaceListFace'); diff --git a/lib/services/face/lib/operations/largeFaceListOperations.js b/lib/services/face/lib/operations/largeFaceListOperations.js index 6ae6367512..f263e3e763 100644 --- a/lib/services/face/lib/operations/largeFaceListOperations.js +++ b/lib/services/face/lib/operations/largeFaceListOperations.js @@ -1579,6 +1579,187 @@ function _addFaceFromUrl(largeFaceListId, url, options, callback) { }); } +/** + * List all faces in a large face list, and retrieve face information + * (including userData and persistedFaceIds of registered faces of the face). + * + * @param {string} largeFaceListId Id referencing a particular large face list. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.start] Starting face id to return (used to list a + * range of faces). + * + * @param {number} [options.top] Number of faces to return starting with the + * face id indicated by the 'start' parameter. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {array} [result] - The deserialized result object if an error did not occur. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _listFaces(largeFaceListId, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + let start = (options && options.start !== undefined) ? options.start : undefined; + let top = (options && options.top !== undefined) ? options.top : undefined; + // Validate + try { + if (this.client.endpoint === null || this.client.endpoint === undefined || typeof this.client.endpoint.valueOf() !== 'string') { + throw new Error('this.client.endpoint cannot be null or undefined and it must be of type string.'); + } + if (largeFaceListId === null || largeFaceListId === undefined || typeof largeFaceListId.valueOf() !== 'string') { + throw new Error('largeFaceListId cannot be null or undefined and it must be of type string.'); + } + if (largeFaceListId !== null && largeFaceListId !== undefined) { + if (largeFaceListId.length > 64) + { + throw new Error('"largeFaceListId" should satisfy the constraint - "MaxLength": 64'); + } + if (largeFaceListId.match(/^[a-z0-9-_]+$/) === null) + { + throw new Error('"largeFaceListId" should satisfy the constraint - "Pattern": /^[a-z0-9-_]+$/'); + } + } + if (start !== null && start !== undefined && typeof start.valueOf() !== 'string') { + throw new Error('start must be of type string.'); + } + if (top !== null && top !== undefined && typeof top !== 'number') { + throw new Error('top must be of type number.'); + } + if (top !== null && top !== undefined) { + if (top > 1000) + { + throw new Error('"top" should satisfy the constraint - "InclusiveMaximum": 1000'); + } + if (top < 1) + { + throw new Error('"top" should satisfy the constraint - "InclusiveMinimum": 1'); + } + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'largefacelists/{largeFaceListId}/persistedfaces'; + requestUrl = requestUrl.replace('{Endpoint}', this.client.endpoint); + requestUrl = requestUrl.replace('{largeFaceListId}', encodeURIComponent(largeFaceListId)); + let queryParameters = []; + if (start !== null && start !== undefined) { + queryParameters.push('start=' + encodeURIComponent(start)); + } + if (top !== null && top !== undefined) { + queryParameters.push('top=' + encodeURIComponent(top.toString())); + } + if (queryParameters.length > 0) { + requestUrl += '?' + queryParameters.join('&'); + } + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'GET'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['APIError']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + // Deserialize Response + if (statusCode === 200) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = { + required: false, + serializedName: 'parsedResponse', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'PersistedFaceElementType', + type: { + name: 'Composite', + className: 'PersistedFace' + } + } + } + }; + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + /** * Add a face to a large face list. The input face is specified as an image * with a targetFace rectangle. It returns a persistedFaceId representing the @@ -1778,6 +1959,7 @@ class LargeFaceListOperations { this._getFace = _getFace; this._updateFace = _updateFace; this._addFaceFromUrl = _addFaceFromUrl; + this._listFaces = _listFaces; this._addFaceFromStream = _addFaceFromStream; } @@ -2758,6 +2940,101 @@ class LargeFaceListOperations { } } + /** + * List all faces in a large face list, and retrieve face information + * (including userData and persistedFaceIds of registered faces of the face). + * + * @param {string} largeFaceListId Id referencing a particular large face list. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.start] Starting face id to return (used to list a + * range of faces). + * + * @param {number} [options.top] Number of faces to return starting with the + * face id indicated by the 'start' parameter. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + listFacesWithHttpOperationResponse(largeFaceListId, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._listFaces(largeFaceListId, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * List all faces in a large face list, and retrieve face information + * (including userData and persistedFaceIds of registered faces of the face). + * + * @param {string} largeFaceListId Id referencing a particular large face list. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.start] Starting face id to return (used to list a + * range of faces). + * + * @param {number} [options.top] Number of faces to return starting with the + * face id indicated by the 'start' parameter. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {Array} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {array} [result] - The deserialized result object if an error did not occur. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + listFaces(largeFaceListId, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._listFaces(largeFaceListId, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._listFaces(largeFaceListId, options, optionalCallback); + } + } + /** * Add a face to a large face list. The input face is specified as an image * with a targetFace rectangle. It returns a persistedFaceId representing the From 0f61ae5feee5bc99fe860804c9b7e4c9a10ce9a0 Mon Sep 17 00:00:00 2001 From: Azure SDK for Python bot Date: Wed, 1 Aug 2018 08:15:50 +0000 Subject: [PATCH 4/5] Generated from 6019c551df19f24b8a70a2c9d8f691b43cf7f195 [Minor] Person_AddPersonFace to Person_AddFace. --- lib/services/face/lib/operations/index.d.ts | 16 ++++++++-------- .../lib/operations/largePersonGroupPerson.js | 14 +++++++------- .../face/lib/operations/personGroupPerson.js | 14 +++++++------- 3 files changed, 22 insertions(+), 22 deletions(-) diff --git a/lib/services/face/lib/operations/index.d.ts b/lib/services/face/lib/operations/index.d.ts index 39f04221bf..bd10b95d55 100644 --- a/lib/services/face/lib/operations/index.d.ts +++ b/lib/services/face/lib/operations/index.d.ts @@ -1156,7 +1156,7 @@ export interface PersonGroupPerson { * * @reject {Error|ServiceError} - The error object. */ - addPersonFaceFromUrlWithHttpOperationResponse(personGroupId: string, personId: string, url: string, options?: { userData? : string, targetFace? : number[], customHeaders? : { [headerName: string]: string; } }): Promise>; + addFaceFromUrlWithHttpOperationResponse(personGroupId: string, personId: string, url: string, options?: { userData? : string, targetFace? : number[], customHeaders? : { [headerName: string]: string; } }): Promise>; /** * Add a representative face to a person for identification. The input face is @@ -1205,9 +1205,9 @@ export interface PersonGroupPerson { * * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. */ - addPersonFaceFromUrl(personGroupId: string, personId: string, url: string, options?: { userData? : string, targetFace? : number[], customHeaders? : { [headerName: string]: string; } }): Promise; - addPersonFaceFromUrl(personGroupId: string, personId: string, url: string, callback: ServiceCallback): void; - addPersonFaceFromUrl(personGroupId: string, personId: string, url: string, options: { userData? : string, targetFace? : number[], customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + addFaceFromUrl(personGroupId: string, personId: string, url: string, options?: { userData? : string, targetFace? : number[], customHeaders? : { [headerName: string]: string; } }): Promise; + addFaceFromUrl(personGroupId: string, personId: string, url: string, callback: ServiceCallback): void; + addFaceFromUrl(personGroupId: string, personId: string, url: string, options: { userData? : string, targetFace? : number[], customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; /** @@ -2832,7 +2832,7 @@ export interface LargePersonGroupPerson { * * @reject {Error|ServiceError} - The error object. */ - addPersonFaceFromUrlWithHttpOperationResponse(largePersonGroupId: string, personId: string, url: string, options?: { userData? : string, targetFace? : number[], customHeaders? : { [headerName: string]: string; } }): Promise>; + addFaceFromUrlWithHttpOperationResponse(largePersonGroupId: string, personId: string, url: string, options?: { userData? : string, targetFace? : number[], customHeaders? : { [headerName: string]: string; } }): Promise>; /** * Add a representative face to a person for identification. The input face is @@ -2882,9 +2882,9 @@ export interface LargePersonGroupPerson { * * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. */ - addPersonFaceFromUrl(largePersonGroupId: string, personId: string, url: string, options?: { userData? : string, targetFace? : number[], customHeaders? : { [headerName: string]: string; } }): Promise; - addPersonFaceFromUrl(largePersonGroupId: string, personId: string, url: string, callback: ServiceCallback): void; - addPersonFaceFromUrl(largePersonGroupId: string, personId: string, url: string, options: { userData? : string, targetFace? : number[], customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + addFaceFromUrl(largePersonGroupId: string, personId: string, url: string, options?: { userData? : string, targetFace? : number[], customHeaders? : { [headerName: string]: string; } }): Promise; + addFaceFromUrl(largePersonGroupId: string, personId: string, url: string, callback: ServiceCallback): void; + addFaceFromUrl(largePersonGroupId: string, personId: string, url: string, options: { userData? : string, targetFace? : number[], customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; /** diff --git a/lib/services/face/lib/operations/largePersonGroupPerson.js b/lib/services/face/lib/operations/largePersonGroupPerson.js index aad1737238..372dfdd155 100644 --- a/lib/services/face/lib/operations/largePersonGroupPerson.js +++ b/lib/services/face/lib/operations/largePersonGroupPerson.js @@ -1284,7 +1284,7 @@ function _updateFace(largePersonGroupId, personId, persistedFaceId, options, cal * * {stream} [response] - The HTTP Response stream if an error did not occur. */ -function _addPersonFaceFromUrl(largePersonGroupId, personId, url, options, callback) { +function _addFaceFromUrl(largePersonGroupId, personId, url, options, callback) { /* jshint validthis: true */ let client = this.client; if(!callback && typeof options === 'function') { @@ -1650,7 +1650,7 @@ class LargePersonGroupPerson { this._deleteFace = _deleteFace; this._getFace = _getFace; this._updateFace = _updateFace; - this._addPersonFaceFromUrl = _addPersonFaceFromUrl; + this._addFaceFromUrl = _addFaceFromUrl; this._addPersonFaceFromStream = _addPersonFaceFromStream; } @@ -2445,11 +2445,11 @@ class LargePersonGroupPerson { * * @reject {Error} - The error object. */ - addPersonFaceFromUrlWithHttpOperationResponse(largePersonGroupId, personId, url, options) { + addFaceFromUrlWithHttpOperationResponse(largePersonGroupId, personId, url, options) { let client = this.client; let self = this; return new Promise((resolve, reject) => { - self._addPersonFaceFromUrl(largePersonGroupId, personId, url, options, (err, result, request, response) => { + self._addFaceFromUrl(largePersonGroupId, personId, url, options, (err, result, request, response) => { let httpOperationResponse = new msRest.HttpOperationResponse(request, response); httpOperationResponse.body = result; if (err) { reject(err); } @@ -2507,7 +2507,7 @@ class LargePersonGroupPerson { * * {stream} [response] - The HTTP Response stream if an error did not occur. */ - addPersonFaceFromUrl(largePersonGroupId, personId, url, options, optionalCallback) { + addFaceFromUrl(largePersonGroupId, personId, url, options, optionalCallback) { let client = this.client; let self = this; if (!optionalCallback && typeof options === 'function') { @@ -2516,14 +2516,14 @@ class LargePersonGroupPerson { } if (!optionalCallback) { return new Promise((resolve, reject) => { - self._addPersonFaceFromUrl(largePersonGroupId, personId, url, options, (err, result, request, response) => { + self._addFaceFromUrl(largePersonGroupId, personId, url, options, (err, result, request, response) => { if (err) { reject(err); } else { resolve(result); } return; }); }); } else { - return self._addPersonFaceFromUrl(largePersonGroupId, personId, url, options, optionalCallback); + return self._addFaceFromUrl(largePersonGroupId, personId, url, options, optionalCallback); } } diff --git a/lib/services/face/lib/operations/personGroupPerson.js b/lib/services/face/lib/operations/personGroupPerson.js index b9ef0d9bf9..f3d22a55df 100644 --- a/lib/services/face/lib/operations/personGroupPerson.js +++ b/lib/services/face/lib/operations/personGroupPerson.js @@ -1275,7 +1275,7 @@ function _updateFace(personGroupId, personId, persistedFaceId, options, callback * * {stream} [response] - The HTTP Response stream if an error did not occur. */ -function _addPersonFaceFromUrl(personGroupId, personId, url, options, callback) { +function _addFaceFromUrl(personGroupId, personId, url, options, callback) { /* jshint validthis: true */ let client = this.client; if(!callback && typeof options === 'function') { @@ -1640,7 +1640,7 @@ class PersonGroupPerson { this._deleteFace = _deleteFace; this._getFace = _getFace; this._updateFace = _updateFace; - this._addPersonFaceFromUrl = _addPersonFaceFromUrl; + this._addFaceFromUrl = _addFaceFromUrl; this._addPersonFaceFromStream = _addPersonFaceFromStream; } @@ -2418,11 +2418,11 @@ class PersonGroupPerson { * * @reject {Error} - The error object. */ - addPersonFaceFromUrlWithHttpOperationResponse(personGroupId, personId, url, options) { + addFaceFromUrlWithHttpOperationResponse(personGroupId, personId, url, options) { let client = this.client; let self = this; return new Promise((resolve, reject) => { - self._addPersonFaceFromUrl(personGroupId, personId, url, options, (err, result, request, response) => { + self._addFaceFromUrl(personGroupId, personId, url, options, (err, result, request, response) => { let httpOperationResponse = new msRest.HttpOperationResponse(request, response); httpOperationResponse.body = result; if (err) { reject(err); } @@ -2479,7 +2479,7 @@ class PersonGroupPerson { * * {stream} [response] - The HTTP Response stream if an error did not occur. */ - addPersonFaceFromUrl(personGroupId, personId, url, options, optionalCallback) { + addFaceFromUrl(personGroupId, personId, url, options, optionalCallback) { let client = this.client; let self = this; if (!optionalCallback && typeof options === 'function') { @@ -2488,14 +2488,14 @@ class PersonGroupPerson { } if (!optionalCallback) { return new Promise((resolve, reject) => { - self._addPersonFaceFromUrl(personGroupId, personId, url, options, (err, result, request, response) => { + self._addFaceFromUrl(personGroupId, personId, url, options, (err, result, request, response) => { if (err) { reject(err); } else { resolve(result); } return; }); }); } else { - return self._addPersonFaceFromUrl(personGroupId, personId, url, options, optionalCallback); + return self._addFaceFromUrl(personGroupId, personId, url, options, optionalCallback); } } From 2d92bf8b011123551e9b0fdd8e2d34c5156baf84 Mon Sep 17 00:00:00 2001 From: Azure SDK for Python bot Date: Wed, 1 Aug 2018 08:20:52 +0000 Subject: [PATCH 5/5] Generated from a43b96d1f8ebea7d96449c4fa459519b0c48335e [Minor] Amend last commit of Person_AddPersonFace to Person_AddFace. --- lib/services/face/lib/operations/index.d.ts | 16 ++++++++-------- .../lib/operations/largePersonGroupPerson.js | 14 +++++++------- .../face/lib/operations/personGroupPerson.js | 14 +++++++------- 3 files changed, 22 insertions(+), 22 deletions(-) diff --git a/lib/services/face/lib/operations/index.d.ts b/lib/services/face/lib/operations/index.d.ts index bd10b95d55..2533bf0007 100644 --- a/lib/services/face/lib/operations/index.d.ts +++ b/lib/services/face/lib/operations/index.d.ts @@ -1241,7 +1241,7 @@ export interface PersonGroupPerson { * * @reject {Error|ServiceError} - The error object. */ - addPersonFaceFromStreamWithHttpOperationResponse(personGroupId: string, personId: string, image: stream.Readable, options?: { userData? : string, targetFace? : number[], customHeaders? : { [headerName: string]: string; } }): Promise>; + addFaceFromStreamWithHttpOperationResponse(personGroupId: string, personId: string, image: stream.Readable, options?: { userData? : string, targetFace? : number[], customHeaders? : { [headerName: string]: string; } }): Promise>; /** * Add a representative face to a person for identification. The input face is @@ -1290,9 +1290,9 @@ export interface PersonGroupPerson { * * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. */ - addPersonFaceFromStream(personGroupId: string, personId: string, image: stream.Readable, options?: { userData? : string, targetFace? : number[], customHeaders? : { [headerName: string]: string; } }): Promise; - addPersonFaceFromStream(personGroupId: string, personId: string, image: stream.Readable, callback: ServiceCallback): void; - addPersonFaceFromStream(personGroupId: string, personId: string, image: stream.Readable, options: { userData? : string, targetFace? : number[], customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + addFaceFromStream(personGroupId: string, personId: string, image: stream.Readable, options?: { userData? : string, targetFace? : number[], customHeaders? : { [headerName: string]: string; } }): Promise; + addFaceFromStream(personGroupId: string, personId: string, image: stream.Readable, callback: ServiceCallback): void; + addFaceFromStream(personGroupId: string, personId: string, image: stream.Readable, options: { userData? : string, targetFace? : number[], customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; } /** @@ -2919,7 +2919,7 @@ export interface LargePersonGroupPerson { * * @reject {Error|ServiceError} - The error object. */ - addPersonFaceFromStreamWithHttpOperationResponse(largePersonGroupId: string, personId: string, image: stream.Readable, options?: { userData? : string, targetFace? : number[], customHeaders? : { [headerName: string]: string; } }): Promise>; + addFaceFromStreamWithHttpOperationResponse(largePersonGroupId: string, personId: string, image: stream.Readable, options?: { userData? : string, targetFace? : number[], customHeaders? : { [headerName: string]: string; } }): Promise>; /** * Add a representative face to a person for identification. The input face is @@ -2969,9 +2969,9 @@ export interface LargePersonGroupPerson { * * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. */ - addPersonFaceFromStream(largePersonGroupId: string, personId: string, image: stream.Readable, options?: { userData? : string, targetFace? : number[], customHeaders? : { [headerName: string]: string; } }): Promise; - addPersonFaceFromStream(largePersonGroupId: string, personId: string, image: stream.Readable, callback: ServiceCallback): void; - addPersonFaceFromStream(largePersonGroupId: string, personId: string, image: stream.Readable, options: { userData? : string, targetFace? : number[], customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + addFaceFromStream(largePersonGroupId: string, personId: string, image: stream.Readable, options?: { userData? : string, targetFace? : number[], customHeaders? : { [headerName: string]: string; } }): Promise; + addFaceFromStream(largePersonGroupId: string, personId: string, image: stream.Readable, callback: ServiceCallback): void; + addFaceFromStream(largePersonGroupId: string, personId: string, image: stream.Readable, options: { userData? : string, targetFace? : number[], customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; } /** diff --git a/lib/services/face/lib/operations/largePersonGroupPerson.js b/lib/services/face/lib/operations/largePersonGroupPerson.js index 372dfdd155..0c762900fb 100644 --- a/lib/services/face/lib/operations/largePersonGroupPerson.js +++ b/lib/services/face/lib/operations/largePersonGroupPerson.js @@ -1487,7 +1487,7 @@ function _addFaceFromUrl(largePersonGroupId, personId, url, options, callback) { * * {stream} [response] - The HTTP Response stream if an error did not occur. */ -function _addPersonFaceFromStream(largePersonGroupId, personId, image, options, callback) { +function _addFaceFromStream(largePersonGroupId, personId, image, options, callback) { /* jshint validthis: true */ let client = this.client; if(!callback && typeof options === 'function') { @@ -1651,7 +1651,7 @@ class LargePersonGroupPerson { this._getFace = _getFace; this._updateFace = _updateFace; this._addFaceFromUrl = _addFaceFromUrl; - this._addPersonFaceFromStream = _addPersonFaceFromStream; + this._addFaceFromStream = _addFaceFromStream; } /** @@ -2559,11 +2559,11 @@ class LargePersonGroupPerson { * * @reject {Error} - The error object. */ - addPersonFaceFromStreamWithHttpOperationResponse(largePersonGroupId, personId, image, options) { + addFaceFromStreamWithHttpOperationResponse(largePersonGroupId, personId, image, options) { let client = this.client; let self = this; return new Promise((resolve, reject) => { - self._addPersonFaceFromStream(largePersonGroupId, personId, image, options, (err, result, request, response) => { + self._addFaceFromStream(largePersonGroupId, personId, image, options, (err, result, request, response) => { let httpOperationResponse = new msRest.HttpOperationResponse(request, response); httpOperationResponse.body = result; if (err) { reject(err); } @@ -2621,7 +2621,7 @@ class LargePersonGroupPerson { * * {stream} [response] - The HTTP Response stream if an error did not occur. */ - addPersonFaceFromStream(largePersonGroupId, personId, image, options, optionalCallback) { + addFaceFromStream(largePersonGroupId, personId, image, options, optionalCallback) { let client = this.client; let self = this; if (!optionalCallback && typeof options === 'function') { @@ -2630,14 +2630,14 @@ class LargePersonGroupPerson { } if (!optionalCallback) { return new Promise((resolve, reject) => { - self._addPersonFaceFromStream(largePersonGroupId, personId, image, options, (err, result, request, response) => { + self._addFaceFromStream(largePersonGroupId, personId, image, options, (err, result, request, response) => { if (err) { reject(err); } else { resolve(result); } return; }); }); } else { - return self._addPersonFaceFromStream(largePersonGroupId, personId, image, options, optionalCallback); + return self._addFaceFromStream(largePersonGroupId, personId, image, options, optionalCallback); } } diff --git a/lib/services/face/lib/operations/personGroupPerson.js b/lib/services/face/lib/operations/personGroupPerson.js index f3d22a55df..dad69f9ef3 100644 --- a/lib/services/face/lib/operations/personGroupPerson.js +++ b/lib/services/face/lib/operations/personGroupPerson.js @@ -1477,7 +1477,7 @@ function _addFaceFromUrl(personGroupId, personId, url, options, callback) { * * {stream} [response] - The HTTP Response stream if an error did not occur. */ -function _addPersonFaceFromStream(personGroupId, personId, image, options, callback) { +function _addFaceFromStream(personGroupId, personId, image, options, callback) { /* jshint validthis: true */ let client = this.client; if(!callback && typeof options === 'function') { @@ -1641,7 +1641,7 @@ class PersonGroupPerson { this._getFace = _getFace; this._updateFace = _updateFace; this._addFaceFromUrl = _addFaceFromUrl; - this._addPersonFaceFromStream = _addPersonFaceFromStream; + this._addFaceFromStream = _addFaceFromStream; } /** @@ -2530,11 +2530,11 @@ class PersonGroupPerson { * * @reject {Error} - The error object. */ - addPersonFaceFromStreamWithHttpOperationResponse(personGroupId, personId, image, options) { + addFaceFromStreamWithHttpOperationResponse(personGroupId, personId, image, options) { let client = this.client; let self = this; return new Promise((resolve, reject) => { - self._addPersonFaceFromStream(personGroupId, personId, image, options, (err, result, request, response) => { + self._addFaceFromStream(personGroupId, personId, image, options, (err, result, request, response) => { let httpOperationResponse = new msRest.HttpOperationResponse(request, response); httpOperationResponse.body = result; if (err) { reject(err); } @@ -2591,7 +2591,7 @@ class PersonGroupPerson { * * {stream} [response] - The HTTP Response stream if an error did not occur. */ - addPersonFaceFromStream(personGroupId, personId, image, options, optionalCallback) { + addFaceFromStream(personGroupId, personId, image, options, optionalCallback) { let client = this.client; let self = this; if (!optionalCallback && typeof options === 'function') { @@ -2600,14 +2600,14 @@ class PersonGroupPerson { } if (!optionalCallback) { return new Promise((resolve, reject) => { - self._addPersonFaceFromStream(personGroupId, personId, image, options, (err, result, request, response) => { + self._addFaceFromStream(personGroupId, personId, image, options, (err, result, request, response) => { if (err) { reject(err); } else { resolve(result); } return; }); }); } else { - return self._addPersonFaceFromStream(personGroupId, personId, image, options, optionalCallback); + return self._addFaceFromStream(personGroupId, personId, image, options, optionalCallback); } }