diff --git a/lib/services/cognitiveServicesFace/LICENSE.txt b/lib/services/cognitiveServicesFace/LICENSE.txt index 5431ba98b9..8f3d856145 100644 --- a/lib/services/cognitiveServicesFace/LICENSE.txt +++ b/lib/services/cognitiveServicesFace/LICENSE.txt @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) 2018 Microsoft +Copyright (c) 2019 Microsoft Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/lib/services/cognitiveServicesFace/README.md b/lib/services/cognitiveServicesFace/README.md index 1208c39903..da9031227c 100644 --- a/lib/services/cognitiveServicesFace/README.md +++ b/lib/services/cognitiveServicesFace/README.md @@ -5,6 +5,7 @@ summary: *content --- **This SDK will be deprecated next year and will be replaced by a new TypeScript-based isomorphic SDK (found at https://github.com/Azure/azure-sdk-for-js) which works on Node.js and browsers.** ## Microsoft Azure SDK for Node.js - FaceClient + This project provides a Node.js package for accessing Azure. Right now it supports: - **Node.js version 6.x.x or higher** @@ -19,7 +20,7 @@ npm install azure-cognitiveservices-face ### How to use -#### Authentication, client creation and list personGroupPerson as an example. +#### Authentication, client creation, and list personGroupPerson as an example. ```javascript const msRest = require("ms-rest"); @@ -31,6 +32,7 @@ const client = new FaceClient(creds, subscriptionId); const personGroupId = "testpersonGroupId"; const start = "teststart"; const top = 1; + client.personGroupPerson.list(personGroupId, start, top).then((result) => { console.log("The result is:"); console.log(result); @@ -38,6 +40,7 @@ client.personGroupPerson.list(personGroupId, start, top).then((result) => { console.log('An error occurred:'); console.dir(err, {depth: null, colors: true}); }); +``` ### Related projects diff --git a/lib/services/cognitiveServicesFace/lib/faceClient.d.ts b/lib/services/cognitiveServicesFace/lib/faceClient.d.ts index 6485fa976a..55da26bbcf 100644 --- a/lib/services/cognitiveServicesFace/lib/faceClient.d.ts +++ b/lib/services/cognitiveServicesFace/lib/faceClient.d.ts @@ -46,6 +46,7 @@ export default class FaceClient extends ServiceClient { largePersonGroupPerson: operations.LargePersonGroupPerson; largePersonGroupOperations: operations.LargePersonGroupOperations; largeFaceListOperations: operations.LargeFaceListOperations; + snapshotOperations: operations.SnapshotOperations; } export { FaceClient, models as FaceModels }; diff --git a/lib/services/cognitiveServicesFace/lib/faceClient.js b/lib/services/cognitiveServicesFace/lib/faceClient.js index b8403a3e8a..37f792b756 100644 --- a/lib/services/cognitiveServicesFace/lib/faceClient.js +++ b/lib/services/cognitiveServicesFace/lib/faceClient.js @@ -58,6 +58,7 @@ class FaceClient extends ServiceClient { this.largePersonGroupPerson = new operations.LargePersonGroupPerson(this); this.largePersonGroupOperations = new operations.LargePersonGroupOperations(this); this.largeFaceListOperations = new operations.LargeFaceListOperations(this); + this.snapshotOperations = new operations.SnapshotOperations(this); this.models = models; msRest.addSerializationMixin(this); } diff --git a/lib/services/cognitiveServicesFace/lib/models/applySnapshotRequest.js b/lib/services/cognitiveServicesFace/lib/models/applySnapshotRequest.js new file mode 100644 index 0000000000..da01c5823a --- /dev/null +++ b/lib/services/cognitiveServicesFace/lib/models/applySnapshotRequest.js @@ -0,0 +1,73 @@ +/* + * 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 body for applying snapshot operation. + * + */ +class ApplySnapshotRequest { + /** + * Create a ApplySnapshotRequest. + * @property {string} objectId User specified target object id to be created + * from the snapshot. + * @property {string} [mode] Snapshot applying mode. Currently only CreateNew + * is supported, which means the apply operation will fail if target + * subscription already contains an object of same type and using the same + * objectId. Users can specify the "objectId" in request body to avoid such + * conflicts. Possible values include: 'CreateNew'. Default value: + * 'CreateNew' . + */ + constructor() { + } + + /** + * Defines the metadata of ApplySnapshotRequest + * + * @returns {object} metadata of ApplySnapshotRequest + * + */ + mapper() { + return { + required: false, + serializedName: 'ApplySnapshotRequest', + type: { + name: 'Composite', + className: 'ApplySnapshotRequest', + modelProperties: { + objectId: { + required: true, + serializedName: 'objectId', + constraints: { + MaxLength: 64, + Pattern: /^[a-z0-9-_]+$/ + }, + type: { + name: 'String' + } + }, + mode: { + required: false, + nullable: false, + serializedName: 'mode', + defaultValue: 'CreateNew', + type: { + name: 'Enum', + allowedValues: [ 'CreateNew' ] + } + } + } + } + }; + } +} + +module.exports = ApplySnapshotRequest; diff --git a/lib/services/cognitiveServicesFace/lib/models/detectedFace.js b/lib/services/cognitiveServicesFace/lib/models/detectedFace.js index 896a81c062..dcd43423c4 100644 --- a/lib/services/cognitiveServicesFace/lib/models/detectedFace.js +++ b/lib/services/cognitiveServicesFace/lib/models/detectedFace.js @@ -166,7 +166,7 @@ class DetectedFace { * @property {object} [faceAttributes] * @property {number} [faceAttributes.age] Age in years * @property {string} [faceAttributes.gender] Possible gender of the face. - * Possible values include: 'male', 'female', 'genderless' + * Possible values include: 'male', 'female' * @property {number} [faceAttributes.smile] Smile intensity, a number * between [0,1] * @property {object} [faceAttributes.facialHair] Properties describing diff --git a/lib/services/cognitiveServicesFace/lib/models/faceAttributes.js b/lib/services/cognitiveServicesFace/lib/models/faceAttributes.js index feb621698c..b63d6d1431 100644 --- a/lib/services/cognitiveServicesFace/lib/models/faceAttributes.js +++ b/lib/services/cognitiveServicesFace/lib/models/faceAttributes.js @@ -19,7 +19,7 @@ class FaceAttributes { * Create a FaceAttributes. * @property {number} [age] Age in years * @property {string} [gender] Possible gender of the face. Possible values - * include: 'male', 'female', 'genderless' + * include: 'male', 'female' * @property {number} [smile] Smile intensity, a number between [0,1] * @property {object} [facialHair] Properties describing facial hair * attributes. @@ -117,7 +117,7 @@ class FaceAttributes { serializedName: 'gender', type: { name: 'Enum', - allowedValues: [ 'male', 'female', 'genderless' ] + allowedValues: [ 'male', 'female' ] } }, smile: { diff --git a/lib/services/cognitiveServicesFace/lib/models/faceList.js b/lib/services/cognitiveServicesFace/lib/models/faceList.js index 3bb30f696e..bcf45cbb04 100644 --- a/lib/services/cognitiveServicesFace/lib/models/faceList.js +++ b/lib/services/cognitiveServicesFace/lib/models/faceList.js @@ -66,7 +66,7 @@ class FaceList extends models['NameAndUserDataContract'] { serializedName: 'faceListId', constraints: { MaxLength: 64, - Pattern: '^[a-z0-9-_]+$' + Pattern: /^[a-z0-9-_]+$/ }, type: { name: 'String' diff --git a/lib/services/cognitiveServicesFace/lib/models/findSimilarRequest.js b/lib/services/cognitiveServicesFace/lib/models/findSimilarRequest.js index d9dfa71b0f..ccdb66b252 100644 --- a/lib/services/cognitiveServicesFace/lib/models/findSimilarRequest.js +++ b/lib/services/cognitiveServicesFace/lib/models/findSimilarRequest.js @@ -24,7 +24,7 @@ class FindSimilarRequest { * 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, largeFaceListId and faceIds should not be - * provided at the same time。 + * provided at the same time. * @property {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 @@ -70,7 +70,7 @@ class FindSimilarRequest { serializedName: 'faceListId', constraints: { MaxLength: 64, - Pattern: '^[a-z0-9-_]+$' + Pattern: /^[a-z0-9-_]+$/ }, type: { name: 'String' @@ -81,7 +81,7 @@ class FindSimilarRequest { serializedName: 'largeFaceListId', constraints: { MaxLength: 64, - Pattern: '^[a-z0-9-_]+$' + Pattern: /^[a-z0-9-_]+$/ }, type: { name: 'String' diff --git a/lib/services/cognitiveServicesFace/lib/models/identifyRequest.js b/lib/services/cognitiveServicesFace/lib/models/identifyRequest.js index 03012c7dd8..637690d711 100644 --- a/lib/services/cognitiveServicesFace/lib/models/identifyRequest.js +++ b/lib/services/cognitiveServicesFace/lib/models/identifyRequest.js @@ -73,7 +73,7 @@ class IdentifyRequest { serializedName: 'personGroupId', constraints: { MaxLength: 64, - Pattern: '^[a-z0-9-_]+$' + Pattern: /^[a-z0-9-_]+$/ }, type: { name: 'String' @@ -84,7 +84,7 @@ class IdentifyRequest { serializedName: 'largePersonGroupId', constraints: { MaxLength: 64, - Pattern: '^[a-z0-9-_]+$' + Pattern: /^[a-z0-9-_]+$/ }, type: { name: 'String' diff --git a/lib/services/cognitiveServicesFace/lib/models/index.d.ts b/lib/services/cognitiveServicesFace/lib/models/index.d.ts index 2e7cfaa3b1..d7806ea9c9 100644 --- a/lib/services/cognitiveServicesFace/lib/models/index.d.ts +++ b/lib/services/cognitiveServicesFace/lib/models/index.d.ts @@ -1,24 +1,15 @@ /* * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. See License.txt in the project root for - * license information. + * 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. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. */ import * as moment from "moment"; - /** - * @class - * Initializes a new instance of the ErrorModel class. - * @constructor * Error body. - * - * @property {string} [code] - * @property {string} [message] */ export interface ErrorModel { code?: string; @@ -26,147 +17,51 @@ export interface ErrorModel { } /** - * @class - * Initializes a new instance of the APIError class. - * @constructor * Error information returned by the API - * - * @property {object} [error] - * @property {string} [error.code] - * @property {string} [error.message] - */ +*/ export interface APIError { error?: ErrorModel; } /** - * @class - * Initializes a new instance of the FaceRectangle class. - * @constructor * A rectangle within which a face can be found - * - * @property {number} width The width of the rectangle, in pixels. - * @property {number} height The height of the rectangle, in pixels. - * @property {number} left The distance from the left edge if the image to the - * left edge of the rectangle, in pixels. - * @property {number} top The distance from the top edge if the image to the - * top edge of the rectangle, in pixels. - */ +*/ export interface FaceRectangle { + /** + * The width of the rectangle, in pixels. + */ width: number; + /** + * The height of the rectangle, in pixels. + */ height: number; + /** + * The distance from the left edge if the image to the left edge of the rectangle, in pixels. + */ left: number; + /** + * The distance from the top edge if the image to the top edge of the rectangle, in pixels. + */ top: number; } /** - * @class - * Initializes a new instance of the Coordinate class. - * @constructor * Coordinates within an image - * - * @property {number} x The horizontal component, in pixels. - * @property {number} y The vertical component, in pixels. - */ +*/ export interface Coordinate { + /** + * The horizontal component, in pixels. + */ x: number; + /** + * The vertical component, in pixels. + */ y: number; } /** - * @class - * Initializes a new instance of the FaceLandmarks class. - * @constructor - * A collection of 27-point face landmarks pointing to the important positions - * of face components. - * - * @property {object} [pupilLeft] - * @property {number} [pupilLeft.x] The horizontal component, in pixels. - * @property {number} [pupilLeft.y] The vertical component, in pixels. - * @property {object} [pupilRight] - * @property {number} [pupilRight.x] The horizontal component, in pixels. - * @property {number} [pupilRight.y] The vertical component, in pixels. - * @property {object} [noseTip] - * @property {number} [noseTip.x] The horizontal component, in pixels. - * @property {number} [noseTip.y] The vertical component, in pixels. - * @property {object} [mouthLeft] - * @property {number} [mouthLeft.x] The horizontal component, in pixels. - * @property {number} [mouthLeft.y] The vertical component, in pixels. - * @property {object} [mouthRight] - * @property {number} [mouthRight.x] The horizontal component, in pixels. - * @property {number} [mouthRight.y] The vertical component, in pixels. - * @property {object} [eyebrowLeftOuter] - * @property {number} [eyebrowLeftOuter.x] The horizontal component, in pixels. - * @property {number} [eyebrowLeftOuter.y] The vertical component, in pixels. - * @property {object} [eyebrowLeftInner] - * @property {number} [eyebrowLeftInner.x] The horizontal component, in pixels. - * @property {number} [eyebrowLeftInner.y] The vertical component, in pixels. - * @property {object} [eyeLeftOuter] - * @property {number} [eyeLeftOuter.x] The horizontal component, in pixels. - * @property {number} [eyeLeftOuter.y] The vertical component, in pixels. - * @property {object} [eyeLeftTop] - * @property {number} [eyeLeftTop.x] The horizontal component, in pixels. - * @property {number} [eyeLeftTop.y] The vertical component, in pixels. - * @property {object} [eyeLeftBottom] - * @property {number} [eyeLeftBottom.x] The horizontal component, in pixels. - * @property {number} [eyeLeftBottom.y] The vertical component, in pixels. - * @property {object} [eyeLeftInner] - * @property {number} [eyeLeftInner.x] The horizontal component, in pixels. - * @property {number} [eyeLeftInner.y] The vertical component, in pixels. - * @property {object} [eyebrowRightInner] - * @property {number} [eyebrowRightInner.x] The horizontal component, in - * pixels. - * @property {number} [eyebrowRightInner.y] The vertical component, in pixels. - * @property {object} [eyebrowRightOuter] - * @property {number} [eyebrowRightOuter.x] The horizontal component, in - * pixels. - * @property {number} [eyebrowRightOuter.y] The vertical component, in pixels. - * @property {object} [eyeRightInner] - * @property {number} [eyeRightInner.x] The horizontal component, in pixels. - * @property {number} [eyeRightInner.y] The vertical component, in pixels. - * @property {object} [eyeRightTop] - * @property {number} [eyeRightTop.x] The horizontal component, in pixels. - * @property {number} [eyeRightTop.y] The vertical component, in pixels. - * @property {object} [eyeRightBottom] - * @property {number} [eyeRightBottom.x] The horizontal component, in pixels. - * @property {number} [eyeRightBottom.y] The vertical component, in pixels. - * @property {object} [eyeRightOuter] - * @property {number} [eyeRightOuter.x] The horizontal component, in pixels. - * @property {number} [eyeRightOuter.y] The vertical component, in pixels. - * @property {object} [noseRootLeft] - * @property {number} [noseRootLeft.x] The horizontal component, in pixels. - * @property {number} [noseRootLeft.y] The vertical component, in pixels. - * @property {object} [noseRootRight] - * @property {number} [noseRootRight.x] The horizontal component, in pixels. - * @property {number} [noseRootRight.y] The vertical component, in pixels. - * @property {object} [noseLeftAlarTop] - * @property {number} [noseLeftAlarTop.x] The horizontal component, in pixels. - * @property {number} [noseLeftAlarTop.y] The vertical component, in pixels. - * @property {object} [noseRightAlarTop] - * @property {number} [noseRightAlarTop.x] The horizontal component, in pixels. - * @property {number} [noseRightAlarTop.y] The vertical component, in pixels. - * @property {object} [noseLeftAlarOutTip] - * @property {number} [noseLeftAlarOutTip.x] The horizontal component, in - * pixels. - * @property {number} [noseLeftAlarOutTip.y] The vertical component, in pixels. - * @property {object} [noseRightAlarOutTip] - * @property {number} [noseRightAlarOutTip.x] The horizontal component, in - * pixels. - * @property {number} [noseRightAlarOutTip.y] The vertical component, in - * pixels. - * @property {object} [upperLipTop] - * @property {number} [upperLipTop.x] The horizontal component, in pixels. - * @property {number} [upperLipTop.y] The vertical component, in pixels. - * @property {object} [upperLipBottom] - * @property {number} [upperLipBottom.x] The horizontal component, in pixels. - * @property {number} [upperLipBottom.y] The vertical component, in pixels. - * @property {object} [underLipTop] - * @property {number} [underLipTop.x] The horizontal component, in pixels. - * @property {number} [underLipTop.y] The vertical component, in pixels. - * @property {object} [underLipBottom] - * @property {number} [underLipBottom.x] The horizontal component, in pixels. - * @property {number} [underLipBottom.y] The vertical component, in pixels. - */ + * A collection of 27-point face landmarks pointing to the important positions of face components. +*/ export interface FaceLandmarks { pupilLeft?: Coordinate; pupilRight?: Coordinate; @@ -198,15 +93,8 @@ export interface FaceLandmarks { } /** - * @class - * Initializes a new instance of the FacialHair class. - * @constructor * Properties describing facial hair attributes. - * - * @property {number} [moustache] - * @property {number} [beard] - * @property {number} [sideburns] - */ +*/ export interface FacialHair { moustache?: number; beard?: number; @@ -214,15 +102,8 @@ export interface FacialHair { } /** - * @class - * Initializes a new instance of the HeadPose class. - * @constructor * Properties indicating head pose of the face. - * - * @property {number} [roll] - * @property {number} [yaw] - * @property {number} [pitch] - */ +*/ export interface HeadPose { roll?: number; yaw?: number; @@ -230,21 +111,8 @@ export interface HeadPose { } /** - * @class - * Initializes a new instance of the Emotion class. - * @constructor - * Properties describing facial emotion in form of confidence ranging from 0 to - * 1. - * - * @property {number} [anger] - * @property {number} [contempt] - * @property {number} [disgust] - * @property {number} [fear] - * @property {number} [happiness] - * @property {number} [neutral] - * @property {number} [sadness] - * @property {number} [surprise] - */ + * Properties describing facial emotion in form of confidence ranging from 0 to 1. +*/ export interface Emotion { anger?: number; contempt?: number; @@ -257,463 +125,196 @@ export interface Emotion { } /** - * @class - * Initializes a new instance of the HairColor class. - * @constructor * Hair color and associated confidence - * - * @property {string} [color] Name of the hair color. Possible values include: - * 'unknown', 'white', 'gray', 'blond', 'brown', 'red', 'black', 'other' - * @property {number} [confidence] Confidence level of the color - */ +*/ export interface HairColor { + /** + * Name of the hair color. Possible values include: 'unknown', 'white', 'gray', 'blond', 'brown', + * 'red', 'black', 'other' + */ color?: string; + /** + * Confidence level of the color + */ confidence?: number; } /** - * @class - * Initializes a new instance of the Hair class. - * @constructor * Properties describing hair attributes. - * - * @property {number} [bald] A number describing confidence level of whether - * the person is bald. - * @property {boolean} [invisible] A boolean value describing whether the hair - * is visible in the image. - * @property {array} [hairColor] An array of candidate colors and confidence - * level in the presence of each. - */ +*/ export interface Hair { + /** + * A number describing confidence level of whether the person is bald. + */ bald?: number; + /** + * A boolean value describing whether the hair is visible in the image. + */ invisible?: boolean; + /** + * An array of candidate colors and confidence level in the presence of each. + */ hairColor?: HairColor[]; } /** - * @class - * Initializes a new instance of the Makeup class. - * @constructor * Properties describing present makeups on a given face. - * - * @property {boolean} [eyeMakeup] A boolean value describing whether eye - * makeup is present on a face. - * @property {boolean} [lipMakeup] A boolean value describing whether lip - * makeup is present on a face. - */ +*/ export interface Makeup { + /** + * A boolean value describing whether eye makeup is present on a face. + */ eyeMakeup?: boolean; + /** + * A boolean value describing whether lip makeup is present on a face. + */ lipMakeup?: boolean; } /** - * @class - * Initializes a new instance of the Occlusion class. - * @constructor * Properties describing occlusions on a given face. - * - * @property {boolean} [foreheadOccluded] A boolean value indicating whether - * forehead is occluded. - * @property {boolean} [eyeOccluded] A boolean value indicating whether eyes - * are occluded. - * @property {boolean} [mouthOccluded] A boolean value indicating whether the - * mouth is occluded. - */ +*/ export interface Occlusion { + /** + * A boolean value indicating whether forehead is occluded. + */ foreheadOccluded?: boolean; + /** + * A boolean value indicating whether eyes are occluded. + */ eyeOccluded?: boolean; + /** + * A boolean value indicating whether the mouth is occluded. + */ mouthOccluded?: boolean; } /** - * @class - * Initializes a new instance of the Accessory class. - * @constructor * Accessory item and corresponding confidence level. - * - * @property {string} [type] Type of an accessory. Possible values include: - * 'headWear', 'glasses', 'mask' - * @property {number} [confidence] Confidence level of an accessory - */ +*/ export interface Accessory { + /** + * Type of an accessory. Possible values include: 'headWear', 'glasses', 'mask' + */ type?: string; + /** + * Confidence level of an accessory + */ confidence?: number; } /** - * @class - * Initializes a new instance of the Blur class. - * @constructor * Properties describing any presence of blur within the image. - * - * @property {string} [blurLevel] An enum value indicating level of blurriness. - * Possible values include: 'Low', 'Medium', 'High' - * @property {number} [value] A number indicating level of blurriness ranging - * from 0 to 1. - */ +*/ export interface Blur { + /** + * An enum value indicating level of blurriness. Possible values include: 'Low', 'Medium', 'High' + */ blurLevel?: string; + /** + * A number indicating level of blurriness ranging from 0 to 1. + */ value?: number; } /** - * @class - * Initializes a new instance of the Exposure class. - * @constructor * Properties describing exposure level of the image. - * - * @property {string} [exposureLevel] An enum value indicating level of - * exposure. Possible values include: 'UnderExposure', 'GoodExposure', - * 'OverExposure' - * @property {number} [value] A number indicating level of exposure level - * ranging from 0 to 1. [0, 0.25) is under exposure. [0.25, 0.75) is good - * exposure. [0.75, 1] is over exposure. - */ +*/ export interface Exposure { + /** + * An enum value indicating level of exposure. Possible values include: 'UnderExposure', + * 'GoodExposure', 'OverExposure' + */ exposureLevel?: string; + /** + * A number indicating level of exposure level ranging from 0 to 1. [0, 0.25) is under exposure. + * [0.25, 0.75) is good exposure. [0.75, 1] is over exposure. + */ value?: number; } /** - * @class - * Initializes a new instance of the Noise class. - * @constructor * Properties describing noise level of the image. - * - * @property {string} [noiseLevel] An enum value indicating level of noise. - * Possible values include: 'Low', 'Medium', 'High' - * @property {number} [value] A number indicating level of noise level ranging - * from 0 to 1. [0, 0.25) is under exposure. [0.25, 0.75) is good exposure. - * [0.75, 1] is over exposure. [0, 0.3) is low noise level. [0.3, 0.7) is - * medium noise level. [0.7, 1] is high noise level. - */ +*/ export interface Noise { + /** + * An enum value indicating level of noise. Possible values include: 'Low', 'Medium', 'High' + */ noiseLevel?: string; + /** + * A number indicating level of noise level ranging from 0 to 1. [0, 0.25) is under exposure. + * [0.25, 0.75) is good exposure. [0.75, 1] is over exposure. [0, 0.3) is low noise level. [0.3, + * 0.7) is medium noise level. [0.7, 1] is high noise level. + */ value?: number; } /** - * @class - * Initializes a new instance of the FaceAttributes class. - * @constructor * Face Attributes - * - * @property {number} [age] Age in years - * @property {string} [gender] Possible gender of the face. Possible values - * include: 'male', 'female', 'genderless' - * @property {number} [smile] Smile intensity, a number between [0,1] - * @property {object} [facialHair] Properties describing facial hair - * attributes. - * @property {number} [facialHair.moustache] - * @property {number} [facialHair.beard] - * @property {number} [facialHair.sideburns] - * @property {string} [glasses] Glasses type if any of the face. Possible - * values include: 'noGlasses', 'readingGlasses', 'sunglasses', - * 'swimmingGoggles' - * @property {object} [headPose] Properties indicating head pose of the face. - * @property {number} [headPose.roll] - * @property {number} [headPose.yaw] - * @property {number} [headPose.pitch] - * @property {object} [emotion] Properties describing facial emotion in form of - * confidence ranging from 0 to 1. - * @property {number} [emotion.anger] - * @property {number} [emotion.contempt] - * @property {number} [emotion.disgust] - * @property {number} [emotion.fear] - * @property {number} [emotion.happiness] - * @property {number} [emotion.neutral] - * @property {number} [emotion.sadness] - * @property {number} [emotion.surprise] - * @property {object} [hair] Properties describing hair attributes. - * @property {number} [hair.bald] A number describing confidence level of - * whether the person is bald. - * @property {boolean} [hair.invisible] A boolean value describing whether the - * hair is visible in the image. - * @property {array} [hair.hairColor] An array of candidate colors and - * confidence level in the presence of each. - * @property {object} [makeup] Properties describing present makeups on a given - * face. - * @property {boolean} [makeup.eyeMakeup] A boolean value describing whether - * eye makeup is present on a face. - * @property {boolean} [makeup.lipMakeup] A boolean value describing whether - * lip makeup is present on a face. - * @property {object} [occlusion] Properties describing occlusions on a given - * face. - * @property {boolean} [occlusion.foreheadOccluded] A boolean value indicating - * whether forehead is occluded. - * @property {boolean} [occlusion.eyeOccluded] A boolean value indicating - * whether eyes are occluded. - * @property {boolean} [occlusion.mouthOccluded] A boolean value indicating - * whether the mouth is occluded. - * @property {array} [accessories] Properties describing any accessories on a - * given face. - * @property {object} [blur] Properties describing any presence of blur within - * the image. - * @property {string} [blur.blurLevel] An enum value indicating level of - * blurriness. Possible values include: 'Low', 'Medium', 'High' - * @property {number} [blur.value] A number indicating level of blurriness - * ranging from 0 to 1. - * @property {object} [exposure] Properties describing exposure level of the - * image. - * @property {string} [exposure.exposureLevel] An enum value indicating level - * of exposure. Possible values include: 'UnderExposure', 'GoodExposure', - * 'OverExposure' - * @property {number} [exposure.value] A number indicating level of exposure - * level ranging from 0 to 1. [0, 0.25) is under exposure. [0.25, 0.75) is good - * exposure. [0.75, 1] is over exposure. - * @property {object} [noise] Properties describing noise level of the image. - * @property {string} [noise.noiseLevel] An enum value indicating level of - * noise. Possible values include: 'Low', 'Medium', 'High' - * @property {number} [noise.value] A number indicating level of noise level - * ranging from 0 to 1. [0, 0.25) is under exposure. [0.25, 0.75) is good - * exposure. [0.75, 1] is over exposure. [0, 0.3) is low noise level. [0.3, - * 0.7) is medium noise level. [0.7, 1] is high noise level. - */ +*/ export interface FaceAttributes { + /** + * Age in years + */ age?: number; + /** + * Possible gender of the face. Possible values include: 'male', 'female' + */ gender?: string; + /** + * Smile intensity, a number between [0,1] + */ smile?: number; + /** + * Properties describing facial hair attributes. + */ facialHair?: FacialHair; + /** + * Glasses type if any of the face. Possible values include: 'noGlasses', 'readingGlasses', + * 'sunglasses', 'swimmingGoggles' + */ glasses?: string; + /** + * Properties indicating head pose of the face. + */ headPose?: HeadPose; + /** + * Properties describing facial emotion in form of confidence ranging from 0 to 1. + */ emotion?: Emotion; + /** + * Properties describing hair attributes. + */ hair?: Hair; + /** + * Properties describing present makeups on a given face. + */ makeup?: Makeup; + /** + * Properties describing occlusions on a given face. + */ occlusion?: Occlusion; + /** + * Properties describing any accessories on a given face. + */ accessories?: Accessory[]; + /** + * Properties describing any presence of blur within the image. + */ blur?: Blur; + /** + * Properties describing exposure level of the image. + */ exposure?: Exposure; + /** + * Properties describing noise level of the image. + */ noise?: Noise; } /** - * @class - * Initializes a new instance of the DetectedFace class. - * @constructor * Detected Face object. - * - * @property {uuid} [faceId] - * @property {object} faceRectangle - * @property {number} [faceRectangle.width] The width of the rectangle, in - * pixels. - * @property {number} [faceRectangle.height] The height of the rectangle, in - * pixels. - * @property {number} [faceRectangle.left] The distance from the left edge if - * the image to the left edge of the rectangle, in pixels. - * @property {number} [faceRectangle.top] The distance from the top edge if the - * image to the top edge of the rectangle, in pixels. - * @property {object} [faceLandmarks] - * @property {object} [faceLandmarks.pupilLeft] - * @property {number} [faceLandmarks.pupilLeft.x] The horizontal component, in - * pixels. - * @property {number} [faceLandmarks.pupilLeft.y] The vertical component, in - * pixels. - * @property {object} [faceLandmarks.pupilRight] - * @property {number} [faceLandmarks.pupilRight.x] The horizontal component, in - * pixels. - * @property {number} [faceLandmarks.pupilRight.y] The vertical component, in - * pixels. - * @property {object} [faceLandmarks.noseTip] - * @property {number} [faceLandmarks.noseTip.x] The horizontal component, in - * pixels. - * @property {number} [faceLandmarks.noseTip.y] The vertical component, in - * pixels. - * @property {object} [faceLandmarks.mouthLeft] - * @property {number} [faceLandmarks.mouthLeft.x] The horizontal component, in - * pixels. - * @property {number} [faceLandmarks.mouthLeft.y] The vertical component, in - * pixels. - * @property {object} [faceLandmarks.mouthRight] - * @property {number} [faceLandmarks.mouthRight.x] The horizontal component, in - * pixels. - * @property {number} [faceLandmarks.mouthRight.y] The vertical component, in - * pixels. - * @property {object} [faceLandmarks.eyebrowLeftOuter] - * @property {number} [faceLandmarks.eyebrowLeftOuter.x] The horizontal - * component, in pixels. - * @property {number} [faceLandmarks.eyebrowLeftOuter.y] The vertical - * component, in pixels. - * @property {object} [faceLandmarks.eyebrowLeftInner] - * @property {number} [faceLandmarks.eyebrowLeftInner.x] The horizontal - * component, in pixels. - * @property {number} [faceLandmarks.eyebrowLeftInner.y] The vertical - * component, in pixels. - * @property {object} [faceLandmarks.eyeLeftOuter] - * @property {number} [faceLandmarks.eyeLeftOuter.x] The horizontal component, - * in pixels. - * @property {number} [faceLandmarks.eyeLeftOuter.y] The vertical component, in - * pixels. - * @property {object} [faceLandmarks.eyeLeftTop] - * @property {number} [faceLandmarks.eyeLeftTop.x] The horizontal component, in - * pixels. - * @property {number} [faceLandmarks.eyeLeftTop.y] The vertical component, in - * pixels. - * @property {object} [faceLandmarks.eyeLeftBottom] - * @property {number} [faceLandmarks.eyeLeftBottom.x] The horizontal component, - * in pixels. - * @property {number} [faceLandmarks.eyeLeftBottom.y] The vertical component, - * in pixels. - * @property {object} [faceLandmarks.eyeLeftInner] - * @property {number} [faceLandmarks.eyeLeftInner.x] The horizontal component, - * in pixels. - * @property {number} [faceLandmarks.eyeLeftInner.y] The vertical component, in - * pixels. - * @property {object} [faceLandmarks.eyebrowRightInner] - * @property {number} [faceLandmarks.eyebrowRightInner.x] The horizontal - * component, in pixels. - * @property {number} [faceLandmarks.eyebrowRightInner.y] The vertical - * component, in pixels. - * @property {object} [faceLandmarks.eyebrowRightOuter] - * @property {number} [faceLandmarks.eyebrowRightOuter.x] The horizontal - * component, in pixels. - * @property {number} [faceLandmarks.eyebrowRightOuter.y] The vertical - * component, in pixels. - * @property {object} [faceLandmarks.eyeRightInner] - * @property {number} [faceLandmarks.eyeRightInner.x] The horizontal component, - * in pixels. - * @property {number} [faceLandmarks.eyeRightInner.y] The vertical component, - * in pixels. - * @property {object} [faceLandmarks.eyeRightTop] - * @property {number} [faceLandmarks.eyeRightTop.x] The horizontal component, - * in pixels. - * @property {number} [faceLandmarks.eyeRightTop.y] The vertical component, in - * pixels. - * @property {object} [faceLandmarks.eyeRightBottom] - * @property {number} [faceLandmarks.eyeRightBottom.x] The horizontal - * component, in pixels. - * @property {number} [faceLandmarks.eyeRightBottom.y] The vertical component, - * in pixels. - * @property {object} [faceLandmarks.eyeRightOuter] - * @property {number} [faceLandmarks.eyeRightOuter.x] The horizontal component, - * in pixels. - * @property {number} [faceLandmarks.eyeRightOuter.y] The vertical component, - * in pixels. - * @property {object} [faceLandmarks.noseRootLeft] - * @property {number} [faceLandmarks.noseRootLeft.x] The horizontal component, - * in pixels. - * @property {number} [faceLandmarks.noseRootLeft.y] The vertical component, in - * pixels. - * @property {object} [faceLandmarks.noseRootRight] - * @property {number} [faceLandmarks.noseRootRight.x] The horizontal component, - * in pixels. - * @property {number} [faceLandmarks.noseRootRight.y] The vertical component, - * in pixels. - * @property {object} [faceLandmarks.noseLeftAlarTop] - * @property {number} [faceLandmarks.noseLeftAlarTop.x] The horizontal - * component, in pixels. - * @property {number} [faceLandmarks.noseLeftAlarTop.y] The vertical component, - * in pixels. - * @property {object} [faceLandmarks.noseRightAlarTop] - * @property {number} [faceLandmarks.noseRightAlarTop.x] The horizontal - * component, in pixels. - * @property {number} [faceLandmarks.noseRightAlarTop.y] The vertical - * component, in pixels. - * @property {object} [faceLandmarks.noseLeftAlarOutTip] - * @property {number} [faceLandmarks.noseLeftAlarOutTip.x] The horizontal - * component, in pixels. - * @property {number} [faceLandmarks.noseLeftAlarOutTip.y] The vertical - * component, in pixels. - * @property {object} [faceLandmarks.noseRightAlarOutTip] - * @property {number} [faceLandmarks.noseRightAlarOutTip.x] The horizontal - * component, in pixels. - * @property {number} [faceLandmarks.noseRightAlarOutTip.y] The vertical - * component, in pixels. - * @property {object} [faceLandmarks.upperLipTop] - * @property {number} [faceLandmarks.upperLipTop.x] The horizontal component, - * in pixels. - * @property {number} [faceLandmarks.upperLipTop.y] The vertical component, in - * pixels. - * @property {object} [faceLandmarks.upperLipBottom] - * @property {number} [faceLandmarks.upperLipBottom.x] The horizontal - * component, in pixels. - * @property {number} [faceLandmarks.upperLipBottom.y] The vertical component, - * in pixels. - * @property {object} [faceLandmarks.underLipTop] - * @property {number} [faceLandmarks.underLipTop.x] The horizontal component, - * in pixels. - * @property {number} [faceLandmarks.underLipTop.y] The vertical component, in - * pixels. - * @property {object} [faceLandmarks.underLipBottom] - * @property {number} [faceLandmarks.underLipBottom.x] The horizontal - * component, in pixels. - * @property {number} [faceLandmarks.underLipBottom.y] The vertical component, - * in pixels. - * @property {object} [faceAttributes] - * @property {number} [faceAttributes.age] Age in years - * @property {string} [faceAttributes.gender] Possible gender of the face. - * Possible values include: 'male', 'female', 'genderless' - * @property {number} [faceAttributes.smile] Smile intensity, a number between - * [0,1] - * @property {object} [faceAttributes.facialHair] Properties describing facial - * hair attributes. - * @property {number} [faceAttributes.facialHair.moustache] - * @property {number} [faceAttributes.facialHair.beard] - * @property {number} [faceAttributes.facialHair.sideburns] - * @property {string} [faceAttributes.glasses] Glasses type if any of the face. - * Possible values include: 'noGlasses', 'readingGlasses', 'sunglasses', - * 'swimmingGoggles' - * @property {object} [faceAttributes.headPose] Properties indicating head pose - * of the face. - * @property {number} [faceAttributes.headPose.roll] - * @property {number} [faceAttributes.headPose.yaw] - * @property {number} [faceAttributes.headPose.pitch] - * @property {object} [faceAttributes.emotion] Properties describing facial - * emotion in form of confidence ranging from 0 to 1. - * @property {number} [faceAttributes.emotion.anger] - * @property {number} [faceAttributes.emotion.contempt] - * @property {number} [faceAttributes.emotion.disgust] - * @property {number} [faceAttributes.emotion.fear] - * @property {number} [faceAttributes.emotion.happiness] - * @property {number} [faceAttributes.emotion.neutral] - * @property {number} [faceAttributes.emotion.sadness] - * @property {number} [faceAttributes.emotion.surprise] - * @property {object} [faceAttributes.hair] Properties describing hair - * attributes. - * @property {number} [faceAttributes.hair.bald] A number describing confidence - * level of whether the person is bald. - * @property {boolean} [faceAttributes.hair.invisible] A boolean value - * describing whether the hair is visible in the image. - * @property {array} [faceAttributes.hair.hairColor] An array of candidate - * colors and confidence level in the presence of each. - * @property {object} [faceAttributes.makeup] Properties describing present - * makeups on a given face. - * @property {boolean} [faceAttributes.makeup.eyeMakeup] A boolean value - * describing whether eye makeup is present on a face. - * @property {boolean} [faceAttributes.makeup.lipMakeup] A boolean value - * describing whether lip makeup is present on a face. - * @property {object} [faceAttributes.occlusion] Properties describing - * occlusions on a given face. - * @property {boolean} [faceAttributes.occlusion.foreheadOccluded] A boolean - * value indicating whether forehead is occluded. - * @property {boolean} [faceAttributes.occlusion.eyeOccluded] A boolean value - * indicating whether eyes are occluded. - * @property {boolean} [faceAttributes.occlusion.mouthOccluded] A boolean value - * indicating whether the mouth is occluded. - * @property {array} [faceAttributes.accessories] Properties describing any - * accessories on a given face. - * @property {object} [faceAttributes.blur] Properties describing any presence - * of blur within the image. - * @property {string} [faceAttributes.blur.blurLevel] An enum value indicating - * level of blurriness. Possible values include: 'Low', 'Medium', 'High' - * @property {number} [faceAttributes.blur.value] A number indicating level of - * blurriness ranging from 0 to 1. - * @property {object} [faceAttributes.exposure] Properties describing exposure - * level of the image. - * @property {string} [faceAttributes.exposure.exposureLevel] An enum value - * indicating level of exposure. Possible values include: 'UnderExposure', - * 'GoodExposure', 'OverExposure' - * @property {number} [faceAttributes.exposure.value] A number indicating level - * of exposure level ranging from 0 to 1. [0, 0.25) is under exposure. [0.25, - * 0.75) is good exposure. [0.75, 1] is over exposure. - * @property {object} [faceAttributes.noise] Properties describing noise level - * of the image. - * @property {string} [faceAttributes.noise.noiseLevel] An enum value - * indicating level of noise. Possible values include: 'Low', 'Medium', 'High' - * @property {number} [faceAttributes.noise.value] A number indicating level of - * noise level ranging from 0 to 1. [0, 0.25) is under exposure. [0.25, 0.75) - * is good exposure. [0.75, 1] is over exposure. [0, 0.3) is low noise level. - * [0.3, 0.7) is medium noise level. [0.7, 1] is high noise level. - */ +*/ export interface DetectedFace { faceId?: string; faceRectangle: FaceRectangle; @@ -722,372 +323,489 @@ export interface DetectedFace { } /** - * @class - * Initializes a new instance of the FindSimilarRequest class. - * @constructor * Request body for find similar operation. - * - * @property {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 - * and will expire 24 hours after the detection call - * @property {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, largeFaceListId and faceIds should not be provided at the same - * time。 - * @property {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. - * @property {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. The number of faceIds is limited to 1000. Parameter - * faceListId, largeFaceListId and faceIds should not be provided at the same - * time. - * @property {number} [maxNumOfCandidatesReturned] The number of top similar - * faces returned. The valid range is [1, 1000]. Default value: 20 . - * @property {string} [mode] Similar face searching mode. It can be - * "matchPerson" or "matchFace". Possible values include: 'matchPerson', - * 'matchFace'. Default value: 'matchPerson' . - */ +*/ export interface FindSimilarRequest { + /** + * FaceId of the query face. User needs to call Face - Detect first to get a valid faceId. Note + * that this faceId is not persisted and will expire 24 hours after the detection call + */ faceId: string; + /** + * 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, largeFaceListId and faceIds should not be provided at the same time. + */ faceListId?: string; + /** + * 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. + */ largeFaceListId?: string; + /** + * An array of candidate faceIds. All of them are created by Face - Detect and the faceIds will + * expire 24 hours after the detection call. The number of faceIds is limited to 1000. Parameter + * faceListId, largeFaceListId and faceIds should not be provided at the same time. + */ faceIds?: string[]; + /** + * The number of top similar faces returned. The valid range is [1, 1000]. + */ maxNumOfCandidatesReturned?: number; + /** + * Similar face searching mode. It can be "matchPerson" or "matchFace". Possible values include: + * 'matchPerson', 'matchFace' + */ mode?: string; } /** - * @class - * Initializes a new instance of the SimilarFace class. - * @constructor * Response body for find similar face operation. - * - * @property {uuid} [faceId] FaceId of candidate face when find by faceIds. - * faceId is created by Face - Detect and will expire 24 hours after the - * detection call - * @property {uuid} [persistedFaceId] PersistedFaceId of candidate face when - * find by faceListId. persistedFaceId in face list is persisted and will not - * expire. As showed in below response - * @property {number} confidence Similarity confidence of the candidate face. - * The higher confidence, the more similar. Range between [0,1]. - */ +*/ export interface SimilarFace { + /** + * FaceId of candidate face when find by faceIds. faceId is created by Face - Detect and will + * expire 24 hours after the detection call + */ faceId?: string; + /** + * PersistedFaceId of candidate face when find by faceListId. persistedFaceId in face list is + * persisted and will not expire. As showed in below response + */ persistedFaceId?: string; + /** + * Similarity confidence of the candidate face. The higher confidence, the more similar. Range + * between [0,1]. + */ confidence: number; } /** - * @class - * Initializes a new instance of the GroupRequest class. - * @constructor * Request body for group request. - * - * @property {array} faceIds Array of candidate faceId created by Face - - * Detect. The maximum is 1000 faces - */ +*/ export interface GroupRequest { + /** + * Array of candidate faceId created by Face - Detect. The maximum is 1000 faces + */ faceIds: string[]; } /** - * @class - * Initializes a new instance of the GroupResult class. - * @constructor * An array of face groups based on face similarity. - * - * @property {array} groups A partition of the original faces based on face - * similarity. Groups are ranked by number of faces - * @property {array} [messyGroup] Face ids array of faces that cannot find any - * similar faces from original faces. - */ +*/ export interface GroupResult { + /** + * A partition of the original faces based on face similarity. Groups are ranked by number of + * faces + */ groups: string[][]; + /** + * Face ids array of faces that cannot find any similar faces from original faces. + */ messyGroup?: string[]; } /** - * @class - * Initializes a new instance of the IdentifyRequest class. - * @constructor * Request body for identify face operation. - * - * @property {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]. - * @property {string} [personGroupId] PersonGroupId of the target person group, - * created by PersonGroup - Create. Parameter personGroupId and - * largePersonGroupId should not be provided at the same time. - * @property {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. - * @property {number} [maxNumOfCandidatesReturned] The range of - * maxNumOfCandidatesReturned is between 1 and 5 (default is 1). Default value: - * 1 . - * @property {number} [confidenceThreshold] Confidence threshold of - * identification, used to judge whether one face belong to one person. The - * range of confidenceThreshold is [0, 1] (default specified by algorithm). - */ +*/ export interface IdentifyRequest { + /** + * 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]. + */ faceIds: string[]; + /** + * PersonGroupId of the target person group, created by PersonGroup - Create. Parameter + * personGroupId and largePersonGroupId should not be provided at the same time. + */ personGroupId?: string; + /** + * LargePersonGroupId of the target large person group, created by LargePersonGroup - Create. + * Parameter personGroupId and largePersonGroupId should not be provided at the same time. + */ largePersonGroupId?: string; + /** + * The range of maxNumOfCandidatesReturned is between 1 and 5 (default is 1). + */ maxNumOfCandidatesReturned?: number; + /** + * Confidence threshold of identification, used to judge whether one face belong to one person. + * The range of confidenceThreshold is [0, 1] (default specified by algorithm). + */ confidenceThreshold?: number; } /** - * @class - * Initializes a new instance of the IdentifyCandidate class. - * @constructor * All possible faces that may qualify. - * - * @property {uuid} personId Id of candidate - * @property {number} confidence Confidence threshold of identification, used - * to judge whether one face belong to one person. The range of - * confidenceThreshold is [0, 1] (default specified by algorithm). - */ +*/ export interface IdentifyCandidate { + /** + * Id of candidate + */ personId: string; + /** + * Confidence threshold of identification, used to judge whether one face belong to one person. + * The range of confidenceThreshold is [0, 1] (default specified by algorithm). + */ confidence: number; } /** - * @class - * Initializes a new instance of the IdentifyResult class. - * @constructor * Response body for identify face operation. - * - * @property {uuid} faceId FaceId of the query face - * @property {array} candidates Identified person candidates for that face - * (ranked by confidence). Array size should be no larger than input - * maxNumOfCandidatesReturned. If no person is identified, will return an empty - * array. - */ +*/ export interface IdentifyResult { + /** + * FaceId of the query face + */ faceId: string; + /** + * Identified person candidates for that face (ranked by confidence). Array size should be no + * larger than input maxNumOfCandidatesReturned. If no person is identified, will return an empty + * array. + */ candidates: IdentifyCandidate[]; } /** - * @class - * Initializes a new instance of the VerifyFaceToPersonRequest class. - * @constructor * Request body for face to person verification. - * - * @property {uuid} faceId FaceId of the face, comes from Face - Detect - * @property {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. - * @property {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. - * @property {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 of the face, comes from Face - Detect + */ faceId: string; + /** + * 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. + */ personGroupId?: string; + /** + * 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. + */ largePersonGroupId?: string; + /** + * Specify a certain person in a person group or a large person group. personId is created in + * PersonGroup Person - Create or LargePersonGroup Person - Create. + */ personId: string; } /** - * @class - * Initializes a new instance of the VerifyFaceToFaceRequest class. - * @constructor * Request body for face to face verification. - * - * @property {uuid} faceId1 FaceId of the first face, comes from Face - Detect - * @property {uuid} faceId2 FaceId of the second face, comes from Face - Detect - */ +*/ export interface VerifyFaceToFaceRequest { + /** + * FaceId of the first face, comes from Face - Detect + */ faceId1: string; + /** + * FaceId of the second face, comes from Face - Detect + */ faceId2: string; } /** - * @class - * Initializes a new instance of the VerifyResult class. - * @constructor * Result of the verify operation. - * - * @property {boolean} isIdentical True if the two faces belong to the same - * person or the face belongs to the person, otherwise false. - * @property {number} confidence A number indicates the similarity confidence - * of whether two faces belong to the same person, or whether the face belongs - * to the person. By default, isIdentical is set to True if similarity - * confidence is greater than or equal to 0.5. This is useful for advanced - * users to override "isIdentical" and fine-tune the result on their own data. - */ +*/ export interface VerifyResult { + /** + * True if the two faces belong to the same person or the face belongs to the person, otherwise + * false. + */ isIdentical: boolean; + /** + * A number indicates the similarity confidence of whether two faces belong to the same person, + * or whether the face belongs to the person. By default, isIdentical is set to True if + * similarity confidence is greater than or equal to 0.5. This is useful for advanced users to + * override "isIdentical" and fine-tune the result on their own data. + */ confidence: number; } /** - * @class - * Initializes a new instance of the PersistedFace class. - * @constructor * PersonFace object. - * - * @property {uuid} persistedFaceId The persistedFaceId of the target face, - * which is persisted and will not expire. Different from faceId created by - * Face - Detect and will expire in 24 hours after the detection call. - * @property {string} [userData] User-provided data attached to the face. The - * size limit is 1KB. - */ +*/ export interface PersistedFace { + /** + * The persistedFaceId of the target face, which is persisted and will not expire. Different from + * faceId created by Face - Detect and will expire in 24 hours after the detection call. + */ persistedFaceId: string; + /** + * User-provided data attached to the face. The size limit is 1KB. + */ userData?: string; } /** - * @class - * Initializes a new instance of the NameAndUserDataContract class. - * @constructor * A combination of user defined name and user specified data for the person, * largePersonGroup/personGroup, and largeFaceList/faceList. - * - * @property {string} [name] User defined name, maximum length is 128. - * @property {string} [userData] User specified data. Length should not exceed - * 16KB. - */ +*/ export interface NameAndUserDataContract { + /** + * User defined name, maximum length is 128. + */ name?: string; + /** + * User specified data. Length should not exceed 16KB. + */ userData?: string; } /** - * @class - * Initializes a new instance of the FaceList class. - * @constructor * Face list object. - * - * @property {string} faceListId FaceListId of the target face list. - * @property {array} [persistedFaces] Persisted faces within the face list. - */ +*/ export interface FaceList extends NameAndUserDataContract { + /** + * FaceListId of the target face list. + */ faceListId: string; + /** + * Persisted faces within the face list. + */ persistedFaces?: PersistedFace[]; } /** - * @class - * Initializes a new instance of the PersonGroup class. - * @constructor * Person group object. - * - * @property {string} personGroupId PersonGroupId of the target person group. - */ +*/ export interface PersonGroup extends NameAndUserDataContract { + /** + * PersonGroupId of the target person group. + */ personGroupId: string; } /** - * @class - * Initializes a new instance of the Person class. - * @constructor * Person object. - * - * @property {uuid} personId PersonId of the target face list. - * @property {array} [persistedFaceIds] PersistedFaceIds of registered faces in - * the person. These persistedFaceIds are returned from Person - Add a Person - * Face, and will not expire. - */ +*/ export interface Person extends NameAndUserDataContract { + /** + * PersonId of the target face list. + */ personId: string; + /** + * PersistedFaceIds of registered faces in the person. These persistedFaceIds are returned from + * Person - Add a Person Face, and will not expire. + */ persistedFaceIds?: string[]; } /** - * @class - * Initializes a new instance of the LargeFaceList class. - * @constructor * Large face list object. - * - * @property {string} largeFaceListId LargeFaceListId of the target large face - * list. - */ +*/ export interface LargeFaceList extends NameAndUserDataContract { + /** + * LargeFaceListId of the target large face list. + */ largeFaceListId: string; } /** - * @class - * Initializes a new instance of the LargePersonGroup class. - * @constructor * Large person group object. - * - * @property {string} largePersonGroupId LargePersonGroupId of the target large - * person groups - */ +*/ export interface LargePersonGroup extends NameAndUserDataContract { + /** + * LargePersonGroupId of the target large person groups + */ largePersonGroupId: string; } /** - * @class - * Initializes a new instance of the UpdateFaceRequest class. - * @constructor * Request to update face data. - * - * @property {string} [userData] User-provided data attached to the face. The - * size limit is 1KB. - */ +*/ export interface UpdateFaceRequest { + /** + * User-provided data attached to the face. The size limit is 1KB. + */ userData?: string; } /** - * @class - * Initializes a new instance of the TrainingStatus class. - * @constructor * Training status object. - * - * @property {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 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' - * @property {date} created A combined UTC date and time string that describes - * the created time of the person group, large person group or large face list. - * @property {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. - * @property {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. - * @property {string} [message] Show failure message when training failed - * (omitted when training succeed). - */ +*/ export interface TrainingStatus { + /** + * 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 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' + */ status: string; + /** + * A combined UTC date and time string that describes the created time of the person group, large + * person group or large face list. + */ created: Date; + /** + * 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. + */ lastAction?: Date; + /** + * 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. + */ lastSuccessfulTraining?: Date; + /** + * Show failure message when training failed (omitted when training succeed). + */ message?: string; } /** - * @class - * Initializes a new instance of the ImageUrl class. - * @constructor - * @property {string} url Publicly reachable URL of an image - */ + * Request body for applying snapshot operation. +*/ +export interface ApplySnapshotRequest { + /** + * User specified target object id to be created from the snapshot. + */ + objectId: string; + /** + * Snapshot applying mode. Currently only CreateNew is supported, which means the apply operation + * will fail if target subscription already contains an object of same type and using the same + * objectId. Users can specify the "objectId" in request body to avoid such conflicts. Possible + * values include: 'CreateNew' + */ + mode?: string; +} + +/** + * Snapshot object. +*/ +export interface Snapshot { + /** + * Snapshot id. + */ + id: string; + /** + * Azure Cognitive Service Face account id of the subscriber who created the snapshot by Snapshot + * - Take. + */ + account: string; + /** + * Type of the source object in the snapshot, specified by the subscriber who created the + * snapshot when calling Snapshot - Take. Currently FaceList, PersonGroup, LargeFaceList and + * LargePersonGroup are supported. Possible values include: 'FaceList', 'LargeFaceList', + * 'LargePersonGroup', 'PersonGroup' + */ + type: string; + /** + * Array of the target Face subscription ids for the snapshot, specified by the user who created + * the snapshot when calling Snapshot - Take. For each snapshot, only subscriptions included in + * the applyScope of Snapshot - Take can apply it. + */ + applyScope: string[]; + /** + * User specified data about the snapshot for any purpose. Length should not exceed 16KB. + */ + userData?: string; + /** + * A combined UTC date and time string that describes the created time of the snapshot. E.g. + * 2018-12-25T11:41:02.2331413Z. + */ + createdTime: Date; + /** + * A combined UTC date and time string that describes the last time when the snapshot was created + * or updated by Snapshot - Update. E.g. 2018-12-25T11:51:27.8705696Z. + */ + lastUpdateTime: Date; +} + +/** + * Request body for taking snapshot operation. +*/ +export interface TakeSnapshotRequest { + /** + * User specified type for the source object to take snapshot from. Currently FaceList, + * PersonGroup, LargeFaceList and LargePersonGroup are supported. Possible values include: + * 'FaceList', 'LargeFaceList', 'LargePersonGroup', 'PersonGroup' + */ + type: string; + /** + * User specified source object id to take snapshot from. + */ + objectId: string; + /** + * User specified array of target Face subscription ids for the snapshot. For each snapshot, only + * subscriptions included in the applyScope of Snapshot - Take can apply it. + */ + applyScope: string[]; + /** + * User specified data about the snapshot for any purpose. Length should not exceed 16KB. + */ + userData?: string; +} + +/** + * Request body for updating a snapshot, with a combination of user defined apply scope and user + * specified data. +*/ +export interface UpdateSnapshotRequest { + /** + * Array of the target Face subscription ids for the snapshot, specified by the user who created + * the snapshot when calling Snapshot - Take. For each snapshot, only subscriptions included in + * the applyScope of Snapshot - Take can apply it. + */ + applyScope?: string[]; + /** + * User specified data about the snapshot for any purpose. Length should not exceed 16KB. + */ + userData?: string; +} + +/** + * Operation status object. Operation refers to the asynchronous backend task including taking a + * snapshot and applying a snapshot. +*/ +export interface OperationStatus { + /** + * Operation status: notstarted, running, succeeded, failed. If the operation is requested and + * waiting to perform, the status is notstarted. If the operation is ongoing in backend, the + * status is running. Status succeeded means the operation is completed successfully, + * specifically for snapshot taking operation, it illustrates the snapshot is well taken and + * ready to apply, and for snapshot applying operation, it presents the target object has + * finished creating by the snapshot and ready to be used. Status failed is often caused by + * editing the source object while taking the snapshot or editing the target object while + * applying the snapshot before completion, see the field "message" to check the failure reason. + * Possible values include: 'notstarted', 'running', 'succeeded', 'failed' + */ + status: string; + /** + * A combined UTC date and time string that describes the time when the operation (take or apply + * a snapshot) is requested. E.g. 2018-12-25T11:41:02.2331413Z. + */ + createdTime: Date; + /** + * A combined UTC date and time string that describes the last time the operation (take or apply + * a snapshot) is actively migrating data. The lastActionTime will keep increasing until the + * operation finishes. E.g. 2018-12-25T11:51:27.8705696Z. + */ + lastActionTime?: Date; + /** + * When the operation succeeds successfully, for snapshot taking operation the snapshot id will + * be included in this field, and for snapshot applying operation, the path to get the target + * object will be returned in this field. + */ + resourceLocation?: string; + /** + * Show failure message when operation fails (omitted when operation succeeds). + */ + message?: string; +} + export interface ImageUrl { + /** + * Publicly reachable URL of an image + */ url: string; } diff --git a/lib/services/cognitiveServicesFace/lib/models/index.js b/lib/services/cognitiveServicesFace/lib/models/index.js index f73b1269ae..6f9811ab8f 100644 --- a/lib/services/cognitiveServicesFace/lib/models/index.js +++ b/lib/services/cognitiveServicesFace/lib/models/index.js @@ -51,4 +51,9 @@ exports.LargeFaceList = require('./largeFaceList'); exports.LargePersonGroup = require('./largePersonGroup'); exports.UpdateFaceRequest = require('./updateFaceRequest'); exports.TrainingStatus = require('./trainingStatus'); +exports.ApplySnapshotRequest = require('./applySnapshotRequest'); +exports.Snapshot = require('./snapshot'); +exports.TakeSnapshotRequest = require('./takeSnapshotRequest'); +exports.UpdateSnapshotRequest = require('./updateSnapshotRequest'); +exports.OperationStatus = require('./operationStatus'); exports.ImageUrl = require('./imageUrl'); diff --git a/lib/services/cognitiveServicesFace/lib/models/largeFaceList.js b/lib/services/cognitiveServicesFace/lib/models/largeFaceList.js index 8daaacfdf5..6869490bcc 100644 --- a/lib/services/cognitiveServicesFace/lib/models/largeFaceList.js +++ b/lib/services/cognitiveServicesFace/lib/models/largeFaceList.js @@ -66,7 +66,7 @@ class LargeFaceList extends models['NameAndUserDataContract'] { serializedName: 'largeFaceListId', constraints: { MaxLength: 64, - Pattern: '^[a-z0-9-_]+$' + Pattern: /^[a-z0-9-_]+$/ }, type: { name: 'String' diff --git a/lib/services/cognitiveServicesFace/lib/models/largePersonGroup.js b/lib/services/cognitiveServicesFace/lib/models/largePersonGroup.js index fb03f2fef2..85ea84d0e3 100644 --- a/lib/services/cognitiveServicesFace/lib/models/largePersonGroup.js +++ b/lib/services/cognitiveServicesFace/lib/models/largePersonGroup.js @@ -66,7 +66,7 @@ class LargePersonGroup extends models['NameAndUserDataContract'] { serializedName: 'largePersonGroupId', constraints: { MaxLength: 64, - Pattern: '^[a-z0-9-_]+$' + Pattern: /^[a-z0-9-_]+$/ }, type: { name: 'String' diff --git a/lib/services/cognitiveServicesFace/lib/models/operationStatus.js b/lib/services/cognitiveServicesFace/lib/models/operationStatus.js new file mode 100644 index 0000000000..a811558b74 --- /dev/null +++ b/lib/services/cognitiveServicesFace/lib/models/operationStatus.js @@ -0,0 +1,106 @@ +/* + * 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'; + +/** + * Operation status object. Operation refers to the asynchronous backend task + * including taking a snapshot and applying a snapshot. + * + */ +class OperationStatus { + /** + * Create a OperationStatus. + * @property {string} status Operation status: notstarted, running, + * succeeded, failed. If the operation is requested and waiting to perform, + * the status is notstarted. If the operation is ongoing in backend, the + * status is running. Status succeeded means the operation is completed + * successfully, specifically for snapshot taking operation, it illustrates + * the snapshot is well taken and ready to apply, and for snapshot applying + * operation, it presents the target object has finished creating by the + * snapshot and ready to be used. Status failed is often caused by editing + * the source object while taking the snapshot or editing the target object + * while applying the snapshot before completion, see the field "message" to + * check the failure reason. Possible values include: 'notstarted', + * 'running', 'succeeded', 'failed' + * @property {date} createdTime A combined UTC date and time string that + * describes the time when the operation (take or apply a snapshot) is + * requested. E.g. 2018-12-25T11:41:02.2331413Z. + * @property {date} [lastActionTime] A combined UTC date and time string that + * describes the last time the operation (take or apply a snapshot) is + * actively migrating data. The lastActionTime will keep increasing until the + * operation finishes. E.g. 2018-12-25T11:51:27.8705696Z. + * @property {string} [resourceLocation] When the operation succeeds + * successfully, for snapshot taking operation the snapshot id will be + * included in this field, and for snapshot applying operation, the path to + * get the target object will be returned in this field. + * @property {string} [message] Show failure message when operation fails + * (omitted when operation succeeds). + */ + constructor() { + } + + /** + * Defines the metadata of OperationStatus + * + * @returns {object} metadata of OperationStatus + * + */ + mapper() { + return { + required: false, + serializedName: 'OperationStatus', + type: { + name: 'Composite', + className: 'OperationStatus', + modelProperties: { + status: { + required: true, + serializedName: 'status', + type: { + name: 'Enum', + allowedValues: [ 'notstarted', 'running', 'succeeded', 'failed' ] + } + }, + createdTime: { + required: true, + serializedName: 'createdTime', + type: { + name: 'DateTime' + } + }, + lastActionTime: { + required: false, + serializedName: 'lastActionTime', + type: { + name: 'DateTime' + } + }, + resourceLocation: { + required: false, + serializedName: 'resourceLocation', + type: { + name: 'String' + } + }, + message: { + required: false, + serializedName: 'message', + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = OperationStatus; diff --git a/lib/services/cognitiveServicesFace/lib/models/personGroup.js b/lib/services/cognitiveServicesFace/lib/models/personGroup.js index 8a29bb25d3..4b04ac0dbd 100644 --- a/lib/services/cognitiveServicesFace/lib/models/personGroup.js +++ b/lib/services/cognitiveServicesFace/lib/models/personGroup.js @@ -65,7 +65,7 @@ class PersonGroup extends models['NameAndUserDataContract'] { serializedName: 'personGroupId', constraints: { MaxLength: 64, - Pattern: '^[a-z0-9-_]+$' + Pattern: /^[a-z0-9-_]+$/ }, type: { name: 'String' diff --git a/lib/services/cognitiveServicesFace/lib/models/snapshot.js b/lib/services/cognitiveServicesFace/lib/models/snapshot.js new file mode 100644 index 0000000000..e89c5249ee --- /dev/null +++ b/lib/services/cognitiveServicesFace/lib/models/snapshot.js @@ -0,0 +1,124 @@ +/* + * 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'; + +/** + * Snapshot object. + * + */ +class Snapshot { + /** + * Create a Snapshot. + * @property {uuid} id Snapshot id. + * @property {string} account Azure Cognitive Service Face account id of the + * subscriber who created the snapshot by Snapshot - Take. + * @property {string} type Type of the source object in the snapshot, + * specified by the subscriber who created the snapshot when calling Snapshot + * - Take. Currently FaceList, PersonGroup, LargeFaceList and + * LargePersonGroup are supported. Possible values include: 'FaceList', + * 'LargeFaceList', 'LargePersonGroup', 'PersonGroup' + * @property {array} applyScope Array of the target Face subscription ids for + * the snapshot, specified by the user who created the snapshot when calling + * Snapshot - Take. For each snapshot, only subscriptions included in the + * applyScope of Snapshot - Take can apply it. + * @property {string} [userData] User specified data about the snapshot for + * any purpose. Length should not exceed 16KB. + * @property {date} createdTime A combined UTC date and time string that + * describes the created time of the snapshot. E.g. + * 2018-12-25T11:41:02.2331413Z. + * @property {date} lastUpdateTime A combined UTC date and time string that + * describes the last time when the snapshot was created or updated by + * Snapshot - Update. E.g. 2018-12-25T11:51:27.8705696Z. + */ + constructor() { + } + + /** + * Defines the metadata of Snapshot + * + * @returns {object} metadata of Snapshot + * + */ + mapper() { + return { + required: false, + serializedName: 'Snapshot', + type: { + name: 'Composite', + className: 'Snapshot', + modelProperties: { + id: { + required: true, + serializedName: 'id', + type: { + name: 'String' + } + }, + account: { + required: true, + serializedName: 'account', + type: { + name: 'String' + } + }, + type: { + required: true, + serializedName: 'type', + type: { + name: 'Enum', + allowedValues: [ 'FaceList', 'LargeFaceList', 'LargePersonGroup', 'PersonGroup' ] + } + }, + applyScope: { + required: true, + serializedName: 'applyScope', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'UuidElementType', + type: { + name: 'String' + } + } + } + }, + userData: { + required: false, + serializedName: 'userData', + constraints: { + MaxLength: 16384 + }, + type: { + name: 'String' + } + }, + createdTime: { + required: true, + serializedName: 'createdTime', + type: { + name: 'DateTime' + } + }, + lastUpdateTime: { + required: true, + serializedName: 'lastUpdateTime', + type: { + name: 'DateTime' + } + } + } + } + }; + } +} + +module.exports = Snapshot; diff --git a/lib/services/cognitiveServicesFace/lib/models/takeSnapshotRequest.js b/lib/services/cognitiveServicesFace/lib/models/takeSnapshotRequest.js new file mode 100644 index 0000000000..d0de06dbe7 --- /dev/null +++ b/lib/services/cognitiveServicesFace/lib/models/takeSnapshotRequest.js @@ -0,0 +1,98 @@ +/* + * 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 body for taking snapshot operation. + * + */ +class TakeSnapshotRequest { + /** + * Create a TakeSnapshotRequest. + * @property {string} type User specified type for the source object to take + * snapshot from. Currently FaceList, PersonGroup, LargeFaceList and + * LargePersonGroup are supported. Possible values include: 'FaceList', + * 'LargeFaceList', 'LargePersonGroup', 'PersonGroup' + * @property {string} objectId User specified source object id to take + * snapshot from. + * @property {array} applyScope User specified array of target Face + * subscription ids for the snapshot. For each snapshot, only subscriptions + * included in the applyScope of Snapshot - Take can apply it. + * @property {string} [userData] User specified data about the snapshot for + * any purpose. Length should not exceed 16KB. + */ + constructor() { + } + + /** + * Defines the metadata of TakeSnapshotRequest + * + * @returns {object} metadata of TakeSnapshotRequest + * + */ + mapper() { + return { + required: false, + serializedName: 'TakeSnapshotRequest', + type: { + name: 'Composite', + className: 'TakeSnapshotRequest', + modelProperties: { + type: { + required: true, + serializedName: 'type', + type: { + name: 'Enum', + allowedValues: [ 'FaceList', 'LargeFaceList', 'LargePersonGroup', 'PersonGroup' ] + } + }, + objectId: { + required: true, + serializedName: 'objectId', + constraints: { + MaxLength: 64, + Pattern: /^[a-z0-9-_]+$/ + }, + type: { + name: 'String' + } + }, + applyScope: { + required: true, + serializedName: 'applyScope', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'UuidElementType', + type: { + name: 'String' + } + } + } + }, + userData: { + required: false, + serializedName: 'userData', + constraints: { + MaxLength: 16384 + }, + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = TakeSnapshotRequest; diff --git a/lib/services/cognitiveServicesFace/lib/models/updateSnapshotRequest.js b/lib/services/cognitiveServicesFace/lib/models/updateSnapshotRequest.js new file mode 100644 index 0000000000..52ba76b0a8 --- /dev/null +++ b/lib/services/cognitiveServicesFace/lib/models/updateSnapshotRequest.js @@ -0,0 +1,75 @@ +/* + * 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 body for updating a snapshot, with a combination of user defined + * apply scope and user specified data. + * + */ +class UpdateSnapshotRequest { + /** + * Create a UpdateSnapshotRequest. + * @property {array} [applyScope] Array of the target Face subscription ids + * for the snapshot, specified by the user who created the snapshot when + * calling Snapshot - Take. For each snapshot, only subscriptions included in + * the applyScope of Snapshot - Take can apply it. + * @property {string} [userData] User specified data about the snapshot for + * any purpose. Length should not exceed 16KB. + */ + constructor() { + } + + /** + * Defines the metadata of UpdateSnapshotRequest + * + * @returns {object} metadata of UpdateSnapshotRequest + * + */ + mapper() { + return { + required: false, + serializedName: 'UpdateSnapshotRequest', + type: { + name: 'Composite', + className: 'UpdateSnapshotRequest', + modelProperties: { + applyScope: { + required: false, + serializedName: 'applyScope', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'UuidElementType', + type: { + name: 'String' + } + } + } + }, + userData: { + required: false, + serializedName: 'userData', + constraints: { + MaxLength: 16384 + }, + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = UpdateSnapshotRequest; diff --git a/lib/services/cognitiveServicesFace/lib/models/verifyFaceToPersonRequest.js b/lib/services/cognitiveServicesFace/lib/models/verifyFaceToPersonRequest.js index 8893e5bcf0..250e68a9ec 100644 --- a/lib/services/cognitiveServicesFace/lib/models/verifyFaceToPersonRequest.js +++ b/lib/services/cognitiveServicesFace/lib/models/verifyFaceToPersonRequest.js @@ -59,7 +59,7 @@ class VerifyFaceToPersonRequest { serializedName: 'personGroupId', constraints: { MaxLength: 64, - Pattern: '^[a-z0-9-_]+$' + Pattern: /^[a-z0-9-_]+$/ }, type: { name: 'String' @@ -70,7 +70,7 @@ class VerifyFaceToPersonRequest { serializedName: 'largePersonGroupId', constraints: { MaxLength: 64, - Pattern: '^[a-z0-9-_]+$' + Pattern: /^[a-z0-9-_]+$/ }, type: { name: 'String' diff --git a/lib/services/cognitiveServicesFace/lib/operations/face.js b/lib/services/cognitiveServicesFace/lib/operations/face.js index 12399e2440..e73b5d0bcb 100644 --- a/lib/services/cognitiveServicesFace/lib/operations/face.js +++ b/lib/services/cognitiveServicesFace/lib/operations/face.js @@ -27,7 +27,7 @@ const WebResource = msRest.WebResource; * 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, largeFaceListId and faceIds should not be - * provided at the same time。 + * provided at the same time. * * @param {string} [options.largeFaceListId] An existing user-specified unique * candidate large face list, created in LargeFaceList - Create. Large face @@ -1401,7 +1401,7 @@ class Face { * 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, largeFaceListId and faceIds should not be - * provided at the same time。 + * provided at the same time. * * @param {string} [options.largeFaceListId] An existing user-specified unique * candidate large face list, created in LargeFaceList - Create. Large face @@ -1459,7 +1459,7 @@ class Face { * 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, largeFaceListId and faceIds should not be - * provided at the same time。 + * provided at the same time. * * @param {string} [options.largeFaceListId] An existing user-specified unique * candidate large face list, created in LargeFaceList - Create. Large face diff --git a/lib/services/cognitiveServicesFace/lib/operations/faceListOperations.js b/lib/services/cognitiveServicesFace/lib/operations/faceListOperations.js index 4a07e8019a..0aec0bad7e 100644 --- a/lib/services/cognitiveServicesFace/lib/operations/faceListOperations.js +++ b/lib/services/cognitiveServicesFace/lib/operations/faceListOperations.js @@ -715,7 +715,7 @@ function _list(options, callback) { } /** - * Delete an existing face from a face list (given by a persisitedFaceId and a + * Delete an existing face from a face list (given by a persistedFaceId and a * faceListId). Persisted image related to the face will also be deleted. * * @param {string} faceListId Id referencing a particular face list. @@ -1661,7 +1661,7 @@ class FaceListOperations { } /** - * Delete an existing face from a face list (given by a persisitedFaceId and a + * Delete an existing face from a face list (given by a persistedFaceId and a * faceListId). Persisted image related to the face will also be deleted. * * @param {string} faceListId Id referencing a particular face list. @@ -1695,7 +1695,7 @@ class FaceListOperations { } /** - * Delete an existing face from a face list (given by a persisitedFaceId and a + * Delete an existing face from a face list (given by a persistedFaceId and a * faceListId). Persisted image related to the face will also be deleted. * * @param {string} faceListId Id referencing a particular face list. diff --git a/lib/services/cognitiveServicesFace/lib/operations/index.d.ts b/lib/services/cognitiveServicesFace/lib/operations/index.d.ts index 2533bf0007..78239060ad 100644 --- a/lib/services/cognitiveServicesFace/lib/operations/index.d.ts +++ b/lib/services/cognitiveServicesFace/lib/operations/index.d.ts @@ -36,7 +36,7 @@ export interface Face { * 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, largeFaceListId and faceIds should not be - * provided at the same time。 + * provided at the same time. * * @param {string} [options.largeFaceListId] An existing user-specified unique * candidate large face list, created in LargeFaceList - Create. Large face @@ -82,7 +82,7 @@ export interface Face { * 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, largeFaceListId and faceIds should not be - * provided at the same time。 + * provided at the same time. * * @param {string} [options.largeFaceListId] An existing user-specified unique * candidate large face list, created in LargeFaceList - Create. Large face @@ -2021,7 +2021,7 @@ export interface FaceListOperations { /** - * Delete an existing face from a face list (given by a persisitedFaceId and a + * Delete an existing face from a face list (given by a persistedFaceId and a * faceListId). Persisted image related to the face will also be deleted. * * @param {string} faceListId Id referencing a particular face list. @@ -2043,7 +2043,7 @@ export interface FaceListOperations { deleteFaceWithHttpOperationResponse(faceListId: string, persistedFaceId: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; /** - * Delete an existing face from a face list (given by a persisitedFaceId and a + * Delete an existing face from a face list (given by a persistedFaceId and a * faceListId). Persisted image related to the face will also be deleted. * * @param {string} faceListId Id referencing a particular face list. @@ -3825,7 +3825,7 @@ export interface LargeFaceListOperations { /** - * Delete an existing face from a large face list (given by a persisitedFaceId + * Delete an existing face from a large face list (given by a persistedFaceId * and a largeFaceListId). Persisted image related to the face will also be * deleted. * @@ -3848,7 +3848,7 @@ export interface LargeFaceListOperations { deleteFaceWithHttpOperationResponse(largeFaceListId: string, persistedFaceId: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; /** - * Delete an existing face from a large face list (given by a persisitedFaceId + * Delete an existing face from a large face list (given by a persistedFaceId * and a largeFaceListId). Persisted image related to the face will also be * deleted. * @@ -4250,3 +4250,624 @@ export interface LargeFaceListOperations { 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 + * SnapshotOperations + * __NOTE__: An instance of this class is automatically created for an + * instance of the FaceClient. + */ +export interface SnapshotOperations { + + + /** + * Submit an operation to take a snapshot of face list, large face list, person + * group or large person group, with user-specified snapshot type, source + * object id, apply scope and an optional user data.
+ * The snapshot interfaces are for users to backup and restore their face data + * from one face subscription to another, inside same region or across regions. + * The workflow contains two phases, user first calls Snapshot - Take to create + * a copy of the source object and store it as a snapshot, then calls Snapshot + * - Apply to paste the snapshot to target subscription. The snapshots are + * stored in a centralized location (per Azure instance), so that they can be + * applied cross accounts and regions.
+ * Taking snapshot is an asynchronous operation. An operation id can be + * obtained from the "Operation-Location" field in response header, to be used + * in OperationStatus - Get for tracking the progress of creating the snapshot. + * The snapshot id will be included in the "resourceLocation" field in + * OperationStatus - Get response when the operation status is "succeeded".
+ * Snapshot taking time depends on the number of person and face entries in the + * source object. It could be in seconds, or up to several hours for 1,000,000 + * persons with multiple faces.
+ * Snapshots will be automatically expired and cleaned in 48 hours after it is + * created by Snapshot - Take. User can delete the snapshot using Snapshot - + * Delete by themselves any time before expiration.
+ * Taking snapshot for a certain object will not block any other operations + * against the object. All read-only operations (Get/List and + * Identify/FindSimilar/Verify) can be conducted as usual. For all writable + * operations, including Add/Update/Delete the source object or its + * persons/faces and Train, they are not blocked but not recommended because + * writable updates may not be reflected on the snapshot during its taking. + * After snapshot taking is completed, all readable and writable operations can + * work as normal. Snapshot will also include the training results of the + * source object, which means target subscription the snapshot applied to does + * not need re-train the target object before calling Identify/FindSimilar.
+ * * Free-tier subscription quota: 100 take operations per month. + * * S0-tier subscription quota: 100 take operations per day. + * + * @param {string} type User specified type for the source object to take + * snapshot from. Currently FaceList, PersonGroup, LargeFaceList and + * LargePersonGroup are supported. Possible values include: 'FaceList', + * 'LargeFaceList', 'LargePersonGroup', 'PersonGroup' + * + * @param {string} objectId User specified source object id to take snapshot + * from. + * + * @param {array} applyScope User specified array of target Face subscription + * ids for the snapshot. For each snapshot, only subscriptions included in the + * applyScope of Snapshot - Take can apply it. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.userData] User specified data about the snapshot + * for any purpose. 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. + */ + takeWithHttpOperationResponse(type: string, objectId: string, applyScope: string[], options?: { userData? : string, customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Submit an operation to take a snapshot of face list, large face list, person + * group or large person group, with user-specified snapshot type, source + * object id, apply scope and an optional user data.
+ * The snapshot interfaces are for users to backup and restore their face data + * from one face subscription to another, inside same region or across regions. + * The workflow contains two phases, user first calls Snapshot - Take to create + * a copy of the source object and store it as a snapshot, then calls Snapshot + * - Apply to paste the snapshot to target subscription. The snapshots are + * stored in a centralized location (per Azure instance), so that they can be + * applied cross accounts and regions.
+ * Taking snapshot is an asynchronous operation. An operation id can be + * obtained from the "Operation-Location" field in response header, to be used + * in OperationStatus - Get for tracking the progress of creating the snapshot. + * The snapshot id will be included in the "resourceLocation" field in + * OperationStatus - Get response when the operation status is "succeeded".
+ * Snapshot taking time depends on the number of person and face entries in the + * source object. It could be in seconds, or up to several hours for 1,000,000 + * persons with multiple faces.
+ * Snapshots will be automatically expired and cleaned in 48 hours after it is + * created by Snapshot - Take. User can delete the snapshot using Snapshot - + * Delete by themselves any time before expiration.
+ * Taking snapshot for a certain object will not block any other operations + * against the object. All read-only operations (Get/List and + * Identify/FindSimilar/Verify) can be conducted as usual. For all writable + * operations, including Add/Update/Delete the source object or its + * persons/faces and Train, they are not blocked but not recommended because + * writable updates may not be reflected on the snapshot during its taking. + * After snapshot taking is completed, all readable and writable operations can + * work as normal. Snapshot will also include the training results of the + * source object, which means target subscription the snapshot applied to does + * not need re-train the target object before calling Identify/FindSimilar.
+ * * Free-tier subscription quota: 100 take operations per month. + * * S0-tier subscription quota: 100 take operations per day. + * + * @param {string} type User specified type for the source object to take + * snapshot from. Currently FaceList, PersonGroup, LargeFaceList and + * LargePersonGroup are supported. Possible values include: 'FaceList', + * 'LargeFaceList', 'LargePersonGroup', 'PersonGroup' + * + * @param {string} objectId User specified source object id to take snapshot + * from. + * + * @param {array} applyScope User specified array of target Face subscription + * ids for the snapshot. For each snapshot, only subscriptions included in the + * applyScope of Snapshot - Take can apply it. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.userData] User specified data about the snapshot + * for any purpose. 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. + */ + take(type: string, objectId: string, applyScope: string[], options?: { userData? : string, customHeaders? : { [headerName: string]: string; } }): Promise; + take(type: string, objectId: string, applyScope: string[], callback: ServiceCallback): void; + take(type: string, objectId: string, applyScope: string[], options: { userData? : string, customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * List all accessible snapshots with related information, including snapshots + * that were taken by the user, or snapshots to be applied to the user + * (subscription id was included in the applyScope in Snapshot - Take). + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.type] User specified object type as a search + * filter. Possible values include: 'FaceList', 'LargeFaceList', + * 'LargePersonGroup', 'PersonGroup' + * + * @param {array} [options.applyScope] User specified snapshot apply scopes as + * a search filter. ApplyScope is an array of the target Azure subscription ids + * for the snapshot, specified by the user who created the snapshot by Snapshot + * - Take. + * + * @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?: { type? : string, applyScope? : string[], customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * List all accessible snapshots with related information, including snapshots + * that were taken by the user, or snapshots to be applied to the user + * (subscription id was included in the applyScope in Snapshot - Take). + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.type] User specified object type as a search + * filter. Possible values include: 'FaceList', 'LargeFaceList', + * 'LargePersonGroup', 'PersonGroup' + * + * @param {array} [options.applyScope] User specified snapshot apply scopes as + * a search filter. ApplyScope is an array of the target Azure subscription ids + * for the snapshot, specified by the user who created the snapshot by Snapshot + * - Take. + * + * @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?: { type? : string, applyScope? : string[], customHeaders? : { [headerName: string]: string; } }): Promise; + list(callback: ServiceCallback): void; + list(options: { type? : string, applyScope? : string[], customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Retrieve information about a snapshot. Snapshot is only accessible to the + * source subscription who took it, and target subscriptions included in the + * applyScope in Snapshot - Take. + * + * @param {uuid} snapshotId Id referencing a particular snapshot. + * + * @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(snapshotId: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Retrieve information about a snapshot. Snapshot is only accessible to the + * source subscription who took it, and target subscriptions included in the + * applyScope in Snapshot - Take. + * + * @param {uuid} snapshotId Id referencing a particular snapshot. + * + * @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 {Snapshot} - 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. + * + * {Snapshot} [result] - The deserialized result object if an error did not occur. + * See {@link Snapshot} 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(snapshotId: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + get(snapshotId: string, callback: ServiceCallback): void; + get(snapshotId: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Update the information of a snapshot. Only the source subscription who took + * the snapshot can update the snapshot. + * + * @param {uuid} snapshotId Id referencing a particular snapshot. + * + * @param {object} [options] Optional Parameters. + * + * @param {array} [options.applyScope] Array of the target Face subscription + * ids for the snapshot, specified by the user who created the snapshot when + * calling Snapshot - Take. For each snapshot, only subscriptions included in + * the applyScope of Snapshot - Take can apply it. + * + * @param {string} [options.userData] User specified data about the snapshot + * for any purpose. 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(snapshotId: string, options?: { applyScope? : string[], userData? : string, customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Update the information of a snapshot. Only the source subscription who took + * the snapshot can update the snapshot. + * + * @param {uuid} snapshotId Id referencing a particular snapshot. + * + * @param {object} [options] Optional Parameters. + * + * @param {array} [options.applyScope] Array of the target Face subscription + * ids for the snapshot, specified by the user who created the snapshot when + * calling Snapshot - Take. For each snapshot, only subscriptions included in + * the applyScope of Snapshot - Take can apply it. + * + * @param {string} [options.userData] User specified data about the snapshot + * for any purpose. 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(snapshotId: string, options?: { applyScope? : string[], userData? : string, customHeaders? : { [headerName: string]: string; } }): Promise; + update(snapshotId: string, callback: ServiceCallback): void; + update(snapshotId: string, options: { applyScope? : string[], userData? : string, customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Delete an existing snapshot according to the snapshotId. All object data and + * information in the snapshot will also be deleted. Only the source + * subscription who took the snapshot can delete the snapshot. If the user does + * not delete a snapshot with this API, the snapshot will still be + * automatically deleted in 48 hours after creation. + * + * @param {uuid} snapshotId Id referencing a particular snapshot. + * + * @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(snapshotId: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Delete an existing snapshot according to the snapshotId. All object data and + * information in the snapshot will also be deleted. Only the source + * subscription who took the snapshot can delete the snapshot. If the user does + * not delete a snapshot with this API, the snapshot will still be + * automatically deleted in 48 hours after creation. + * + * @param {uuid} snapshotId Id referencing a particular snapshot. + * + * @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(snapshotId: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + deleteMethod(snapshotId: string, callback: ServiceCallback): void; + deleteMethod(snapshotId: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Submit an operation to apply a snapshot to current subscription. For each + * snapshot, only subscriptions included in the applyScope of Snapshot - Take + * can apply it.
+ * The snapshot interfaces are for users to backup and restore their face data + * from one face subscription to another, inside same region or across regions. + * The workflow contains two phases, user first calls Snapshot - Take to create + * a copy of the source object and store it as a snapshot, then calls Snapshot + * - Apply to paste the snapshot to target subscription. The snapshots are + * stored in a centralized location (per Azure instance), so that they can be + * applied cross accounts and regions.
+ * Applying snapshot is an asynchronous operation. An operation id can be + * obtained from the "Operation-Location" field in response header, to be used + * in OperationStatus - Get for tracking the progress of applying the snapshot. + * The target object id will be included in the "resourceLocation" field in + * OperationStatus - Get response when the operation status is "succeeded".
+ * Snapshot applying time depends on the number of person and face entries in + * the snapshot object. It could be in seconds, or up to 1 hour for 1,000,000 + * persons with multiple faces.
+ * Snapshots will be automatically expired and cleaned in 48 hours after it is + * created by Snapshot - Take. So the target subscription is required to apply + * the snapshot in 48 hours since its creation.
+ * Applying a snapshot will not block any other operations against the target + * object, however it is not recommended because the correctness cannot be + * guaranteed during snapshot applying. After snapshot applying is completed, + * all operations towards the target object can work as normal. Snapshot also + * includes the training results of the source object, which means target + * subscription the snapshot applied to does not need re-train the target + * object before calling Identify/FindSimilar.
+ * One snapshot can be applied multiple times in parallel, while currently only + * CreateNew apply mode is supported, which means the apply operation will fail + * if target subscription already contains an object of same type and using the + * same objectId. Users can specify the "objectId" in request body to avoid + * such conflicts.
+ * * Free-tier subscription quota: 100 apply operations per month. + * * S0-tier subscription quota: 100 apply operations per day. + * + * @param {uuid} snapshotId Id referencing a particular snapshot. + * + * @param {string} objectId User specified target object id to be created from + * the snapshot. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.mode] Snapshot applying mode. Currently only + * CreateNew is supported, which means the apply operation will fail if target + * subscription already contains an object of same type and using the same + * objectId. Users can specify the "objectId" in request body to avoid such + * conflicts. Possible values include: 'CreateNew' + * + * @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. + */ + applyWithHttpOperationResponse(snapshotId: string, objectId: string, options?: { mode? : string, customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Submit an operation to apply a snapshot to current subscription. For each + * snapshot, only subscriptions included in the applyScope of Snapshot - Take + * can apply it.
+ * The snapshot interfaces are for users to backup and restore their face data + * from one face subscription to another, inside same region or across regions. + * The workflow contains two phases, user first calls Snapshot - Take to create + * a copy of the source object and store it as a snapshot, then calls Snapshot + * - Apply to paste the snapshot to target subscription. The snapshots are + * stored in a centralized location (per Azure instance), so that they can be + * applied cross accounts and regions.
+ * Applying snapshot is an asynchronous operation. An operation id can be + * obtained from the "Operation-Location" field in response header, to be used + * in OperationStatus - Get for tracking the progress of applying the snapshot. + * The target object id will be included in the "resourceLocation" field in + * OperationStatus - Get response when the operation status is "succeeded".
+ * Snapshot applying time depends on the number of person and face entries in + * the snapshot object. It could be in seconds, or up to 1 hour for 1,000,000 + * persons with multiple faces.
+ * Snapshots will be automatically expired and cleaned in 48 hours after it is + * created by Snapshot - Take. So the target subscription is required to apply + * the snapshot in 48 hours since its creation.
+ * Applying a snapshot will not block any other operations against the target + * object, however it is not recommended because the correctness cannot be + * guaranteed during snapshot applying. After snapshot applying is completed, + * all operations towards the target object can work as normal. Snapshot also + * includes the training results of the source object, which means target + * subscription the snapshot applied to does not need re-train the target + * object before calling Identify/FindSimilar.
+ * One snapshot can be applied multiple times in parallel, while currently only + * CreateNew apply mode is supported, which means the apply operation will fail + * if target subscription already contains an object of same type and using the + * same objectId. Users can specify the "objectId" in request body to avoid + * such conflicts.
+ * * Free-tier subscription quota: 100 apply operations per month. + * * S0-tier subscription quota: 100 apply operations per day. + * + * @param {uuid} snapshotId Id referencing a particular snapshot. + * + * @param {string} objectId User specified target object id to be created from + * the snapshot. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.mode] Snapshot applying mode. Currently only + * CreateNew is supported, which means the apply operation will fail if target + * subscription already contains an object of same type and using the same + * objectId. Users can specify the "objectId" in request body to avoid such + * conflicts. Possible values include: 'CreateNew' + * + * @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. + */ + apply(snapshotId: string, objectId: string, options?: { mode? : string, customHeaders? : { [headerName: string]: string; } }): Promise; + apply(snapshotId: string, objectId: string, callback: ServiceCallback): void; + apply(snapshotId: string, objectId: string, options: { mode? : string, customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Retrieve the status of a take/apply snapshot operation. + * + * @param {uuid} operationId Id referencing a particular take/apply snapshot + * operation. + * + * @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. + */ + getOperationStatusWithHttpOperationResponse(operationId: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Retrieve the status of a take/apply snapshot operation. + * + * @param {uuid} operationId Id referencing a particular take/apply snapshot + * operation. + * + * @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 {OperationStatus} - 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. + * + * {OperationStatus} [result] - The deserialized result object if an error did not occur. + * See {@link OperationStatus} 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. + */ + getOperationStatus(operationId: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + getOperationStatus(operationId: string, callback: ServiceCallback): void; + getOperationStatus(operationId: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; +} diff --git a/lib/services/cognitiveServicesFace/lib/operations/index.js b/lib/services/cognitiveServicesFace/lib/operations/index.js index afc063bbab..02881c0832 100644 --- a/lib/services/cognitiveServicesFace/lib/operations/index.js +++ b/lib/services/cognitiveServicesFace/lib/operations/index.js @@ -21,3 +21,4 @@ exports.FaceListOperations = require('./faceListOperations'); exports.LargePersonGroupPerson = require('./largePersonGroupPerson'); exports.LargePersonGroupOperations = require('./largePersonGroupOperations'); exports.LargeFaceListOperations = require('./largeFaceListOperations'); +exports.SnapshotOperations = require('./snapshotOperations'); diff --git a/lib/services/cognitiveServicesFace/lib/operations/largeFaceListOperations.js b/lib/services/cognitiveServicesFace/lib/operations/largeFaceListOperations.js index f263e3e763..0f91439d76 100644 --- a/lib/services/cognitiveServicesFace/lib/operations/largeFaceListOperations.js +++ b/lib/services/cognitiveServicesFace/lib/operations/largeFaceListOperations.js @@ -964,7 +964,7 @@ function _train(largeFaceListId, options, callback) { } /** - * Delete an existing face from a large face list (given by a persisitedFaceId + * Delete an existing face from a large face list (given by a persistedFaceId * and a largeFaceListId). Persisted image related to the face will also be * deleted. * @@ -2557,7 +2557,7 @@ class LargeFaceListOperations { } /** - * Delete an existing face from a large face list (given by a persisitedFaceId + * Delete an existing face from a large face list (given by a persistedFaceId * and a largeFaceListId). Persisted image related to the face will also be * deleted. * @@ -2592,7 +2592,7 @@ class LargeFaceListOperations { } /** - * Delete an existing face from a large face list (given by a persisitedFaceId + * Delete an existing face from a large face list (given by a persistedFaceId * and a largeFaceListId). Persisted image related to the face will also be * deleted. * diff --git a/lib/services/cognitiveServicesFace/lib/operations/snapshotOperations.js b/lib/services/cognitiveServicesFace/lib/operations/snapshotOperations.js new file mode 100644 index 0000000000..a117c6bbdc --- /dev/null +++ b/lib/services/cognitiveServicesFace/lib/operations/snapshotOperations.js @@ -0,0 +1,1910 @@ +/* + * 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; + +/** + * Submit an operation to take a snapshot of face list, large face list, person + * group or large person group, with user-specified snapshot type, source + * object id, apply scope and an optional user data.
+ * The snapshot interfaces are for users to backup and restore their face data + * from one face subscription to another, inside same region or across regions. + * The workflow contains two phases, user first calls Snapshot - Take to create + * a copy of the source object and store it as a snapshot, then calls Snapshot + * - Apply to paste the snapshot to target subscription. The snapshots are + * stored in a centralized location (per Azure instance), so that they can be + * applied cross accounts and regions.
+ * Taking snapshot is an asynchronous operation. An operation id can be + * obtained from the "Operation-Location" field in response header, to be used + * in OperationStatus - Get for tracking the progress of creating the snapshot. + * The snapshot id will be included in the "resourceLocation" field in + * OperationStatus - Get response when the operation status is "succeeded".
+ * Snapshot taking time depends on the number of person and face entries in the + * source object. It could be in seconds, or up to several hours for 1,000,000 + * persons with multiple faces.
+ * Snapshots will be automatically expired and cleaned in 48 hours after it is + * created by Snapshot - Take. User can delete the snapshot using Snapshot - + * Delete by themselves any time before expiration.
+ * Taking snapshot for a certain object will not block any other operations + * against the object. All read-only operations (Get/List and + * Identify/FindSimilar/Verify) can be conducted as usual. For all writable + * operations, including Add/Update/Delete the source object or its + * persons/faces and Train, they are not blocked but not recommended because + * writable updates may not be reflected on the snapshot during its taking. + * After snapshot taking is completed, all readable and writable operations can + * work as normal. Snapshot will also include the training results of the + * source object, which means target subscription the snapshot applied to does + * not need re-train the target object before calling Identify/FindSimilar.
+ * * Free-tier subscription quota: 100 take operations per month. + * * S0-tier subscription quota: 100 take operations per day. + * + * @param {string} type User specified type for the source object to take + * snapshot from. Currently FaceList, PersonGroup, LargeFaceList and + * LargePersonGroup are supported. Possible values include: 'FaceList', + * 'LargeFaceList', 'LargePersonGroup', 'PersonGroup' + * + * @param {string} objectId User specified source object id to take snapshot + * from. + * + * @param {array} applyScope User specified array of target Face subscription + * ids for the snapshot. For each snapshot, only subscriptions included in the + * applyScope of Snapshot - Take can apply it. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.userData] User specified data about the snapshot + * for any purpose. 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 _take(type, objectId, applyScope, 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 (type) { + let allowedValues = [ 'FaceList', 'LargeFaceList', 'LargePersonGroup', 'PersonGroup' ]; + if (!allowedValues.some( function(item) { return item === type; })) { + throw new Error(type + ' is not a valid value. The valid values are: ' + allowedValues); + } + } else { + throw new Error('type cannot be null or undefined.'); + } + if (objectId === null || objectId === undefined || typeof objectId.valueOf() !== 'string') { + throw new Error('objectId cannot be null or undefined and it must be of type string.'); + } + if (objectId !== null && objectId !== undefined) { + if (objectId.length > 64) + { + throw new Error('"objectId" should satisfy the constraint - "MaxLength": 64'); + } + if (objectId.match(/^[a-z0-9-_]+$/) === null) + { + throw new Error('"objectId" should satisfy the constraint - "Pattern": /^[a-z0-9-_]+$/'); + } + } + if (!Array.isArray(applyScope)) { + throw new Error('applyScope cannot be null or undefined and it must be of type array.'); + } + for (let i = 0; i < applyScope.length; i++) { + if (applyScope[i] !== null && applyScope[i] !== undefined && !(typeof applyScope[i].valueOf() === 'string' && msRest.isValidUuid(applyScope[i]))) { + throw new Error('applyScope[i] 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 > 16384) + { + throw new Error('"userData" should satisfy the constraint - "MaxLength": 16384'); + } + } + } catch (error) { + return callback(error); + } + let body; + if ((type !== null && type !== undefined) || (objectId !== null && objectId !== undefined) || (applyScope !== null && applyScope !== undefined) || (userData !== null && userData !== undefined)) { + body = new client.models['TakeSnapshotRequest'](); + body.type = type; + body.objectId = objectId; + body.applyScope = applyScope; + body.userData = userData; + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'snapshots'; + requestUrl = requestUrl.replace('{Endpoint}', this.client.endpoint); + + // 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['TakeSnapshotRequest']().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 !== 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); + }); +} + +/** + * List all accessible snapshots with related information, including snapshots + * that were taken by the user, or snapshots to be applied to the user + * (subscription id was included in the applyScope in Snapshot - Take). + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.type] User specified object type as a search + * filter. Possible values include: 'FaceList', 'LargeFaceList', + * 'LargePersonGroup', 'PersonGroup' + * + * @param {array} [options.applyScope] User specified snapshot apply scopes as + * a search filter. ApplyScope is an array of the target Azure subscription ids + * for the snapshot, specified by the user who created the snapshot by Snapshot + * - Take. + * + * @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 type = (options && options.type !== undefined) ? options.type : undefined; + let applyScope = (options && options.applyScope !== undefined) ? options.applyScope : 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 (type) { + let allowedValues = [ 'FaceList', 'LargeFaceList', 'LargePersonGroup', 'PersonGroup' ]; + if (!allowedValues.some( function(item) { return item === type; })) { + throw new Error(type + ' is not a valid value. The valid values are: ' + allowedValues); + } + } + if (Array.isArray(applyScope)) { + for (let i = 0; i < applyScope.length; i++) { + if (applyScope[i] !== null && applyScope[i] !== undefined && !(typeof applyScope[i].valueOf() === 'string' && msRest.isValidUuid(applyScope[i]))) { + throw new Error('applyScope[i] 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('/') ? '' : '/') + 'snapshots'; + requestUrl = requestUrl.replace('{Endpoint}', this.client.endpoint); + let queryParameters = []; + if (type !== null && type !== undefined) { + queryParameters.push('type=' + encodeURIComponent(type)); + } + if (applyScope !== null && applyScope !== undefined) { + queryParameters.push('applyScope=' + encodeURIComponent(applyScope.join(','))); + } + 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: 'SnapshotElementType', + type: { + name: 'Composite', + className: 'Snapshot' + } + } + } + }; + 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 a snapshot. Snapshot is only accessible to the + * source subscription who took it, and target subscriptions included in the + * applyScope in Snapshot - Take. + * + * @param {uuid} snapshotId Id referencing a particular snapshot. + * + * @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 Snapshot} 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(snapshotId, 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 (snapshotId === null || snapshotId === undefined || typeof snapshotId.valueOf() !== 'string' || !msRest.isValidUuid(snapshotId)) { + throw new Error('snapshotId 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('/') ? '' : '/') + 'snapshots/{snapshotId}'; + requestUrl = requestUrl.replace('{Endpoint}', this.client.endpoint); + requestUrl = requestUrl.replace('{snapshotId}', encodeURIComponent(snapshotId.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['Snapshot']().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 the information of a snapshot. Only the source subscription who took + * the snapshot can update the snapshot. + * + * @param {uuid} snapshotId Id referencing a particular snapshot. + * + * @param {object} [options] Optional Parameters. + * + * @param {array} [options.applyScope] Array of the target Face subscription + * ids for the snapshot, specified by the user who created the snapshot when + * calling Snapshot - Take. For each snapshot, only subscriptions included in + * the applyScope of Snapshot - Take can apply it. + * + * @param {string} [options.userData] User specified data about the snapshot + * for any purpose. 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(snapshotId, 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 applyScope = (options && options.applyScope !== undefined) ? options.applyScope : 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 (snapshotId === null || snapshotId === undefined || typeof snapshotId.valueOf() !== 'string' || !msRest.isValidUuid(snapshotId)) { + throw new Error('snapshotId cannot be null or undefined and it must be of type string and must be a valid uuid.'); + } + if (Array.isArray(applyScope)) { + for (let i = 0; i < applyScope.length; i++) { + if (applyScope[i] !== null && applyScope[i] !== undefined && !(typeof applyScope[i].valueOf() === 'string' && msRest.isValidUuid(applyScope[i]))) { + throw new Error('applyScope[i] 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 > 16384) + { + throw new Error('"userData" should satisfy the constraint - "MaxLength": 16384'); + } + } + } catch (error) { + return callback(error); + } + let body; + if ((applyScope !== null && applyScope !== undefined) || (userData !== null && userData !== undefined)) { + body = new client.models['UpdateSnapshotRequest'](); + body.applyScope = applyScope; + body.userData = userData; + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'snapshots/{snapshotId}'; + requestUrl = requestUrl.replace('{Endpoint}', this.client.endpoint); + requestUrl = requestUrl.replace('{snapshotId}', encodeURIComponent(snapshotId.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['UpdateSnapshotRequest']().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 snapshot according to the snapshotId. All object data and + * information in the snapshot will also be deleted. Only the source + * subscription who took the snapshot can delete the snapshot. If the user does + * not delete a snapshot with this API, the snapshot will still be + * automatically deleted in 48 hours after creation. + * + * @param {uuid} snapshotId Id referencing a particular snapshot. + * + * @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(snapshotId, 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 (snapshotId === null || snapshotId === undefined || typeof snapshotId.valueOf() !== 'string' || !msRest.isValidUuid(snapshotId)) { + throw new Error('snapshotId 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('/') ? '' : '/') + 'snapshots/{snapshotId}'; + requestUrl = requestUrl.replace('{Endpoint}', this.client.endpoint); + requestUrl = requestUrl.replace('{snapshotId}', encodeURIComponent(snapshotId.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); + }); +} + +/** + * Submit an operation to apply a snapshot to current subscription. For each + * snapshot, only subscriptions included in the applyScope of Snapshot - Take + * can apply it.
+ * The snapshot interfaces are for users to backup and restore their face data + * from one face subscription to another, inside same region or across regions. + * The workflow contains two phases, user first calls Snapshot - Take to create + * a copy of the source object and store it as a snapshot, then calls Snapshot + * - Apply to paste the snapshot to target subscription. The snapshots are + * stored in a centralized location (per Azure instance), so that they can be + * applied cross accounts and regions.
+ * Applying snapshot is an asynchronous operation. An operation id can be + * obtained from the "Operation-Location" field in response header, to be used + * in OperationStatus - Get for tracking the progress of applying the snapshot. + * The target object id will be included in the "resourceLocation" field in + * OperationStatus - Get response when the operation status is "succeeded".
+ * Snapshot applying time depends on the number of person and face entries in + * the snapshot object. It could be in seconds, or up to 1 hour for 1,000,000 + * persons with multiple faces.
+ * Snapshots will be automatically expired and cleaned in 48 hours after it is + * created by Snapshot - Take. So the target subscription is required to apply + * the snapshot in 48 hours since its creation.
+ * Applying a snapshot will not block any other operations against the target + * object, however it is not recommended because the correctness cannot be + * guaranteed during snapshot applying. After snapshot applying is completed, + * all operations towards the target object can work as normal. Snapshot also + * includes the training results of the source object, which means target + * subscription the snapshot applied to does not need re-train the target + * object before calling Identify/FindSimilar.
+ * One snapshot can be applied multiple times in parallel, while currently only + * CreateNew apply mode is supported, which means the apply operation will fail + * if target subscription already contains an object of same type and using the + * same objectId. Users can specify the "objectId" in request body to avoid + * such conflicts.
+ * * Free-tier subscription quota: 100 apply operations per month. + * * S0-tier subscription quota: 100 apply operations per day. + * + * @param {uuid} snapshotId Id referencing a particular snapshot. + * + * @param {string} objectId User specified target object id to be created from + * the snapshot. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.mode] Snapshot applying mode. Currently only + * CreateNew is supported, which means the apply operation will fail if target + * subscription already contains an object of same type and using the same + * objectId. Users can specify the "objectId" in request body to avoid such + * conflicts. Possible values include: 'CreateNew' + * + * @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 _apply(snapshotId, objectId, 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 mode = (options && options.mode !== undefined) ? options.mode : 'CreateNew'; + // 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 (snapshotId === null || snapshotId === undefined || typeof snapshotId.valueOf() !== 'string' || !msRest.isValidUuid(snapshotId)) { + throw new Error('snapshotId cannot be null or undefined and it must be of type string and must be a valid uuid.'); + } + if (objectId === null || objectId === undefined || typeof objectId.valueOf() !== 'string') { + throw new Error('objectId cannot be null or undefined and it must be of type string.'); + } + if (objectId !== null && objectId !== undefined) { + if (objectId.length > 64) + { + throw new Error('"objectId" should satisfy the constraint - "MaxLength": 64'); + } + if (objectId.match(/^[a-z0-9-_]+$/) === null) + { + throw new Error('"objectId" should satisfy the constraint - "Pattern": /^[a-z0-9-_]+$/'); + } + } + if (mode) { + let allowedValues = [ 'CreateNew' ]; + if (!allowedValues.some( function(item) { return item === mode; })) { + throw new Error(mode + ' is not a valid value. The valid values are: ' + allowedValues); + } + } + } catch (error) { + return callback(error); + } + let body; + if ((objectId !== null && objectId !== undefined) || (mode !== null && mode !== undefined)) { + body = new client.models['ApplySnapshotRequest'](); + body.objectId = objectId; + body.mode = mode; + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'snapshots/{snapshotId}/apply'; + requestUrl = requestUrl.replace('{Endpoint}', this.client.endpoint); + requestUrl = requestUrl.replace('{snapshotId}', encodeURIComponent(snapshotId.toString())); + + // 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['ApplySnapshotRequest']().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 !== 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); + }); +} + +/** + * Retrieve the status of a take/apply snapshot operation. + * + * @param {uuid} operationId Id referencing a particular take/apply snapshot + * operation. + * + * @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 OperationStatus} 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 _getOperationStatus(operationId, 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 (operationId === null || operationId === undefined || typeof operationId.valueOf() !== 'string' || !msRest.isValidUuid(operationId)) { + throw new Error('operationId 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('/') ? '' : '/') + 'operations/{operationId}'; + requestUrl = requestUrl.replace('{Endpoint}', this.client.endpoint); + requestUrl = requestUrl.replace('{operationId}', encodeURIComponent(operationId.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['OperationStatus']().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 SnapshotOperations. */ +class SnapshotOperations { + /** + * Create a SnapshotOperations. + * @param {FaceClient} client Reference to the service client. + */ + constructor(client) { + this.client = client; + this._take = _take; + this._list = _list; + this._get = _get; + this._update = _update; + this._deleteMethod = _deleteMethod; + this._apply = _apply; + this._getOperationStatus = _getOperationStatus; + } + + /** + * Submit an operation to take a snapshot of face list, large face list, person + * group or large person group, with user-specified snapshot type, source + * object id, apply scope and an optional user data.
+ * The snapshot interfaces are for users to backup and restore their face data + * from one face subscription to another, inside same region or across regions. + * The workflow contains two phases, user first calls Snapshot - Take to create + * a copy of the source object and store it as a snapshot, then calls Snapshot + * - Apply to paste the snapshot to target subscription. The snapshots are + * stored in a centralized location (per Azure instance), so that they can be + * applied cross accounts and regions.
+ * Taking snapshot is an asynchronous operation. An operation id can be + * obtained from the "Operation-Location" field in response header, to be used + * in OperationStatus - Get for tracking the progress of creating the snapshot. + * The snapshot id will be included in the "resourceLocation" field in + * OperationStatus - Get response when the operation status is "succeeded".
+ * Snapshot taking time depends on the number of person and face entries in the + * source object. It could be in seconds, or up to several hours for 1,000,000 + * persons with multiple faces.
+ * Snapshots will be automatically expired and cleaned in 48 hours after it is + * created by Snapshot - Take. User can delete the snapshot using Snapshot - + * Delete by themselves any time before expiration.
+ * Taking snapshot for a certain object will not block any other operations + * against the object. All read-only operations (Get/List and + * Identify/FindSimilar/Verify) can be conducted as usual. For all writable + * operations, including Add/Update/Delete the source object or its + * persons/faces and Train, they are not blocked but not recommended because + * writable updates may not be reflected on the snapshot during its taking. + * After snapshot taking is completed, all readable and writable operations can + * work as normal. Snapshot will also include the training results of the + * source object, which means target subscription the snapshot applied to does + * not need re-train the target object before calling Identify/FindSimilar.
+ * * Free-tier subscription quota: 100 take operations per month. + * * S0-tier subscription quota: 100 take operations per day. + * + * @param {string} type User specified type for the source object to take + * snapshot from. Currently FaceList, PersonGroup, LargeFaceList and + * LargePersonGroup are supported. Possible values include: 'FaceList', + * 'LargeFaceList', 'LargePersonGroup', 'PersonGroup' + * + * @param {string} objectId User specified source object id to take snapshot + * from. + * + * @param {array} applyScope User specified array of target Face subscription + * ids for the snapshot. For each snapshot, only subscriptions included in the + * applyScope of Snapshot - Take can apply it. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.userData] User specified data about the snapshot + * for any purpose. 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. + */ + takeWithHttpOperationResponse(type, objectId, applyScope, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._take(type, objectId, applyScope, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Submit an operation to take a snapshot of face list, large face list, person + * group or large person group, with user-specified snapshot type, source + * object id, apply scope and an optional user data.
+ * The snapshot interfaces are for users to backup and restore their face data + * from one face subscription to another, inside same region or across regions. + * The workflow contains two phases, user first calls Snapshot - Take to create + * a copy of the source object and store it as a snapshot, then calls Snapshot + * - Apply to paste the snapshot to target subscription. The snapshots are + * stored in a centralized location (per Azure instance), so that they can be + * applied cross accounts and regions.
+ * Taking snapshot is an asynchronous operation. An operation id can be + * obtained from the "Operation-Location" field in response header, to be used + * in OperationStatus - Get for tracking the progress of creating the snapshot. + * The snapshot id will be included in the "resourceLocation" field in + * OperationStatus - Get response when the operation status is "succeeded".
+ * Snapshot taking time depends on the number of person and face entries in the + * source object. It could be in seconds, or up to several hours for 1,000,000 + * persons with multiple faces.
+ * Snapshots will be automatically expired and cleaned in 48 hours after it is + * created by Snapshot - Take. User can delete the snapshot using Snapshot - + * Delete by themselves any time before expiration.
+ * Taking snapshot for a certain object will not block any other operations + * against the object. All read-only operations (Get/List and + * Identify/FindSimilar/Verify) can be conducted as usual. For all writable + * operations, including Add/Update/Delete the source object or its + * persons/faces and Train, they are not blocked but not recommended because + * writable updates may not be reflected on the snapshot during its taking. + * After snapshot taking is completed, all readable and writable operations can + * work as normal. Snapshot will also include the training results of the + * source object, which means target subscription the snapshot applied to does + * not need re-train the target object before calling Identify/FindSimilar.
+ * * Free-tier subscription quota: 100 take operations per month. + * * S0-tier subscription quota: 100 take operations per day. + * + * @param {string} type User specified type for the source object to take + * snapshot from. Currently FaceList, PersonGroup, LargeFaceList and + * LargePersonGroup are supported. Possible values include: 'FaceList', + * 'LargeFaceList', 'LargePersonGroup', 'PersonGroup' + * + * @param {string} objectId User specified source object id to take snapshot + * from. + * + * @param {array} applyScope User specified array of target Face subscription + * ids for the snapshot. For each snapshot, only subscriptions included in the + * applyScope of Snapshot - Take can apply it. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.userData] User specified data about the snapshot + * for any purpose. 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. + */ + take(type, objectId, applyScope, 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._take(type, objectId, applyScope, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._take(type, objectId, applyScope, options, optionalCallback); + } + } + + /** + * List all accessible snapshots with related information, including snapshots + * that were taken by the user, or snapshots to be applied to the user + * (subscription id was included in the applyScope in Snapshot - Take). + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.type] User specified object type as a search + * filter. Possible values include: 'FaceList', 'LargeFaceList', + * 'LargePersonGroup', 'PersonGroup' + * + * @param {array} [options.applyScope] User specified snapshot apply scopes as + * a search filter. ApplyScope is an array of the target Azure subscription ids + * for the snapshot, specified by the user who created the snapshot by Snapshot + * - Take. + * + * @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 all accessible snapshots with related information, including snapshots + * that were taken by the user, or snapshots to be applied to the user + * (subscription id was included in the applyScope in Snapshot - Take). + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.type] User specified object type as a search + * filter. Possible values include: 'FaceList', 'LargeFaceList', + * 'LargePersonGroup', 'PersonGroup' + * + * @param {array} [options.applyScope] User specified snapshot apply scopes as + * a search filter. ApplyScope is an array of the target Azure subscription ids + * for the snapshot, specified by the user who created the snapshot by Snapshot + * - Take. + * + * @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); + } + } + + /** + * Retrieve information about a snapshot. Snapshot is only accessible to the + * source subscription who took it, and target subscriptions included in the + * applyScope in Snapshot - Take. + * + * @param {uuid} snapshotId Id referencing a particular snapshot. + * + * @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(snapshotId, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._get(snapshotId, 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 snapshot. Snapshot is only accessible to the + * source subscription who took it, and target subscriptions included in the + * applyScope in Snapshot - Take. + * + * @param {uuid} snapshotId Id referencing a particular snapshot. + * + * @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 {Snapshot} - 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 Snapshot} 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(snapshotId, 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(snapshotId, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._get(snapshotId, options, optionalCallback); + } + } + + /** + * Update the information of a snapshot. Only the source subscription who took + * the snapshot can update the snapshot. + * + * @param {uuid} snapshotId Id referencing a particular snapshot. + * + * @param {object} [options] Optional Parameters. + * + * @param {array} [options.applyScope] Array of the target Face subscription + * ids for the snapshot, specified by the user who created the snapshot when + * calling Snapshot - Take. For each snapshot, only subscriptions included in + * the applyScope of Snapshot - Take can apply it. + * + * @param {string} [options.userData] User specified data about the snapshot + * for any purpose. 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(snapshotId, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._update(snapshotId, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Update the information of a snapshot. Only the source subscription who took + * the snapshot can update the snapshot. + * + * @param {uuid} snapshotId Id referencing a particular snapshot. + * + * @param {object} [options] Optional Parameters. + * + * @param {array} [options.applyScope] Array of the target Face subscription + * ids for the snapshot, specified by the user who created the snapshot when + * calling Snapshot - Take. For each snapshot, only subscriptions included in + * the applyScope of Snapshot - Take can apply it. + * + * @param {string} [options.userData] User specified data about the snapshot + * for any purpose. 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(snapshotId, 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(snapshotId, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._update(snapshotId, options, optionalCallback); + } + } + + /** + * Delete an existing snapshot according to the snapshotId. All object data and + * information in the snapshot will also be deleted. Only the source + * subscription who took the snapshot can delete the snapshot. If the user does + * not delete a snapshot with this API, the snapshot will still be + * automatically deleted in 48 hours after creation. + * + * @param {uuid} snapshotId Id referencing a particular snapshot. + * + * @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(snapshotId, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._deleteMethod(snapshotId, 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 snapshot according to the snapshotId. All object data and + * information in the snapshot will also be deleted. Only the source + * subscription who took the snapshot can delete the snapshot. If the user does + * not delete a snapshot with this API, the snapshot will still be + * automatically deleted in 48 hours after creation. + * + * @param {uuid} snapshotId Id referencing a particular snapshot. + * + * @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(snapshotId, 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(snapshotId, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._deleteMethod(snapshotId, options, optionalCallback); + } + } + + /** + * Submit an operation to apply a snapshot to current subscription. For each + * snapshot, only subscriptions included in the applyScope of Snapshot - Take + * can apply it.
+ * The snapshot interfaces are for users to backup and restore their face data + * from one face subscription to another, inside same region or across regions. + * The workflow contains two phases, user first calls Snapshot - Take to create + * a copy of the source object and store it as a snapshot, then calls Snapshot + * - Apply to paste the snapshot to target subscription. The snapshots are + * stored in a centralized location (per Azure instance), so that they can be + * applied cross accounts and regions.
+ * Applying snapshot is an asynchronous operation. An operation id can be + * obtained from the "Operation-Location" field in response header, to be used + * in OperationStatus - Get for tracking the progress of applying the snapshot. + * The target object id will be included in the "resourceLocation" field in + * OperationStatus - Get response when the operation status is "succeeded".
+ * Snapshot applying time depends on the number of person and face entries in + * the snapshot object. It could be in seconds, or up to 1 hour for 1,000,000 + * persons with multiple faces.
+ * Snapshots will be automatically expired and cleaned in 48 hours after it is + * created by Snapshot - Take. So the target subscription is required to apply + * the snapshot in 48 hours since its creation.
+ * Applying a snapshot will not block any other operations against the target + * object, however it is not recommended because the correctness cannot be + * guaranteed during snapshot applying. After snapshot applying is completed, + * all operations towards the target object can work as normal. Snapshot also + * includes the training results of the source object, which means target + * subscription the snapshot applied to does not need re-train the target + * object before calling Identify/FindSimilar.
+ * One snapshot can be applied multiple times in parallel, while currently only + * CreateNew apply mode is supported, which means the apply operation will fail + * if target subscription already contains an object of same type and using the + * same objectId. Users can specify the "objectId" in request body to avoid + * such conflicts.
+ * * Free-tier subscription quota: 100 apply operations per month. + * * S0-tier subscription quota: 100 apply operations per day. + * + * @param {uuid} snapshotId Id referencing a particular snapshot. + * + * @param {string} objectId User specified target object id to be created from + * the snapshot. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.mode] Snapshot applying mode. Currently only + * CreateNew is supported, which means the apply operation will fail if target + * subscription already contains an object of same type and using the same + * objectId. Users can specify the "objectId" in request body to avoid such + * conflicts. Possible values include: 'CreateNew' + * + * @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. + */ + applyWithHttpOperationResponse(snapshotId, objectId, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._apply(snapshotId, objectId, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Submit an operation to apply a snapshot to current subscription. For each + * snapshot, only subscriptions included in the applyScope of Snapshot - Take + * can apply it.
+ * The snapshot interfaces are for users to backup and restore their face data + * from one face subscription to another, inside same region or across regions. + * The workflow contains two phases, user first calls Snapshot - Take to create + * a copy of the source object and store it as a snapshot, then calls Snapshot + * - Apply to paste the snapshot to target subscription. The snapshots are + * stored in a centralized location (per Azure instance), so that they can be + * applied cross accounts and regions.
+ * Applying snapshot is an asynchronous operation. An operation id can be + * obtained from the "Operation-Location" field in response header, to be used + * in OperationStatus - Get for tracking the progress of applying the snapshot. + * The target object id will be included in the "resourceLocation" field in + * OperationStatus - Get response when the operation status is "succeeded".
+ * Snapshot applying time depends on the number of person and face entries in + * the snapshot object. It could be in seconds, or up to 1 hour for 1,000,000 + * persons with multiple faces.
+ * Snapshots will be automatically expired and cleaned in 48 hours after it is + * created by Snapshot - Take. So the target subscription is required to apply + * the snapshot in 48 hours since its creation.
+ * Applying a snapshot will not block any other operations against the target + * object, however it is not recommended because the correctness cannot be + * guaranteed during snapshot applying. After snapshot applying is completed, + * all operations towards the target object can work as normal. Snapshot also + * includes the training results of the source object, which means target + * subscription the snapshot applied to does not need re-train the target + * object before calling Identify/FindSimilar.
+ * One snapshot can be applied multiple times in parallel, while currently only + * CreateNew apply mode is supported, which means the apply operation will fail + * if target subscription already contains an object of same type and using the + * same objectId. Users can specify the "objectId" in request body to avoid + * such conflicts.
+ * * Free-tier subscription quota: 100 apply operations per month. + * * S0-tier subscription quota: 100 apply operations per day. + * + * @param {uuid} snapshotId Id referencing a particular snapshot. + * + * @param {string} objectId User specified target object id to be created from + * the snapshot. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.mode] Snapshot applying mode. Currently only + * CreateNew is supported, which means the apply operation will fail if target + * subscription already contains an object of same type and using the same + * objectId. Users can specify the "objectId" in request body to avoid such + * conflicts. Possible values include: 'CreateNew' + * + * @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. + */ + apply(snapshotId, objectId, 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._apply(snapshotId, objectId, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._apply(snapshotId, objectId, options, optionalCallback); + } + } + + /** + * Retrieve the status of a take/apply snapshot operation. + * + * @param {uuid} operationId Id referencing a particular take/apply snapshot + * operation. + * + * @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. + */ + getOperationStatusWithHttpOperationResponse(operationId, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._getOperationStatus(operationId, 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 status of a take/apply snapshot operation. + * + * @param {uuid} operationId Id referencing a particular take/apply snapshot + * operation. + * + * @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 {OperationStatus} - 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 OperationStatus} 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. + */ + getOperationStatus(operationId, 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._getOperationStatus(operationId, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._getOperationStatus(operationId, options, optionalCallback); + } + } + +} + +module.exports = SnapshotOperations;