diff --git a/Gopkg.lock b/Gopkg.lock index b3b5c0683f15..3127e1299afe 100644 --- a/Gopkg.lock +++ b/Gopkg.lock @@ -2,6 +2,7 @@ [[projects]] + digest = "1:e222cbd536d9e0850e7297290c431aea75ba087c70d6f98525e95b9f2d02a627" name = "github.com/Azure/go-autorest" packages = [ "autorest", @@ -11,52 +12,64 @@ "autorest/date", "autorest/to", "autorest/validation", - "version" + "version", ] + pruneopts = "" revision = "bca49d5b51a50dc5bb17bbf6204c711c6dbded06" version = "v10.14.0" [[projects]] + digest = "1:6098222470fe0172157ce9bbef5d2200df4edde17ee649c5d6e48330e4afa4c6" name = "github.com/dgrijalva/jwt-go" packages = ["."] + pruneopts = "" revision = "06ea1031745cb8b3dab3f6a236daf2b0aa468b7e" version = "v3.2.0" [[projects]] + branch = "master" + digest = "1:7f175a633086a933d1940a7e7dc2154a0070a7c25fb4a2f671f3eef1a34d1fd7" name = "github.com/dimchansky/utfbom" packages = ["."] + pruneopts = "" revision = "5448fe645cb1964ba70ac8f9f2ffe975e61a536c" - version = "v1.0.0" [[projects]] branch = "master" + digest = "1:e736daced8bc48a910e0634540bc5cd63f1eea1b20fed65f8d82c8ad65eb10b2" name = "github.com/dnaeon/go-vcr" packages = [ "cassette", - "recorder" + "recorder", ] + pruneopts = "" revision = "8b144be0744f013a1b44386058f1fcb3ba98177d" [[projects]] + digest = "1:eb53021a8aa3f599d29c7102e65026242bdedce998a54837dc67f14b6a97c5fd" name = "github.com/fsnotify/fsnotify" packages = ["."] + pruneopts = "" revision = "c2828203cd70a50dcccfb2761f8b1f8ceef9a8e9" version = "v1.4.7" [[projects]] branch = "master" + digest = "1:c1e35087694b689ce1cf4f4277612b6ac0b55725fa791271ae0e3ddcd1cc0c7b" name = "github.com/globalsign/mgo" packages = [ ".", "bson", "internal/json", "internal/sasl", - "internal/scram" + "internal/scram", ] + pruneopts = "" revision = "113d3961e7311526535a1ef7042196563d442761" [[projects]] branch = "master" + digest = "1:9b7c5846d70f425d7fe279595e32a20994c6075e87be03b5c367ed07280877c5" name = "github.com/hashicorp/hcl" packages = [ ".", @@ -68,143 +81,187 @@ "hcl/token", "json/parser", "json/scanner", - "json/token" + "json/token", ] + pruneopts = "" revision = "ef8a98b0bbce4a65b5aa4c368430a80ddc533168" [[projects]] + digest = "1:870d441fe217b8e689d7949fef6e43efbc787e50f200cb1e70dbca9204a1d6be" name = "github.com/inconshreveable/mousetrap" packages = ["."] + pruneopts = "" revision = "76626ae9c91c4f2a10f34cad8ce83ea42c93bb75" version = "v1.0" [[projects]] + digest = "1:3108ec0946181c60040ff51b811908f89d03e521e2b4ade5ef5c65b3c0e911ae" name = "github.com/kr/pretty" packages = ["."] + pruneopts = "" revision = "73f6ac0b30a98e433b289500d779f50c1a6f0712" version = "v0.1.0" [[projects]] + digest = "1:11b056b4421396ab14e384ab8ab8c2079b03f1e51aa5eb4d9b81f9e0d1aa8fbf" name = "github.com/kr/text" packages = ["."] + pruneopts = "" revision = "e2ffdb16a802fe2bb95e2e35ff34f0e53aeef34f" version = "v0.1.0" [[projects]] + digest = "1:961dc3b1d11f969370533390fdf203813162980c858e1dabe827b60940c909a5" name = "github.com/magiconair/properties" packages = ["."] + pruneopts = "" revision = "c2353362d570a7bfa228149c62842019201cfb71" version = "v1.8.0" [[projects]] + digest = "1:71a28fe7d86ace8e51192c97eb4fd376c27ae0ed3a6ff46b41a6da76a0785d78" name = "github.com/marstr/collection" packages = ["."] + pruneopts = "" revision = "871b1cfa2ab97d3d8f54a034280907896190c346" version = "v0.3.3" [[projects]] branch = "master" + digest = "1:5a07891ac7651f2b0db3ca615f88ca80e38a41c0c9f60a6fb123b8cbe3d8d386" name = "github.com/marstr/goalias" packages = ["model"] + pruneopts = "" revision = "8dff9a14db648bfdd58d45515d3eaaee23aad078" [[projects]] + digest = "1:f95025d583786875a71183888acc9d0987fc96f12d4f5afab3d7558797ea1c5a" name = "github.com/marstr/guid" packages = ["."] + pruneopts = "" revision = "8bd9a64bf37eb297b492a4101fb28e80ac0b290f" version = "v1.1.0" [[projects]] branch = "master" + digest = "1:72da3dc7eddc1f4695da12df937debc7dcf027b1c0f57ec415fdad097cef7c43" name = "github.com/marstr/randname" packages = ["."] + pruneopts = "" revision = "48a63b6052f1f9373db9388a658da30c6ab53db1" [[projects]] branch = "master" + digest = "1:99651e95333755cbe5c9768c1b80031300acca64a80870b40309202b32585a5a" name = "github.com/mitchellh/go-homedir" packages = ["."] + pruneopts = "" revision = "3864e76763d94a6df2f9960b16a20a33da9f9a66" [[projects]] branch = "master" + digest = "1:f43ed2c836208c14f45158fd01577c985688a4d11cf9fd475a939819fef3b321" name = "github.com/mitchellh/mapstructure" packages = ["."] + pruneopts = "" revision = "f15292f7a699fcc1a38a80977f80a046874ba8ac" [[projects]] + digest = "1:894aef961c056b6d85d12bac890bf60c44e99b46292888bfa66caf529f804457" name = "github.com/pelletier/go-toml" packages = ["."] + pruneopts = "" revision = "c01d1270ff3e442a8a57cddc1c92dc1138598194" version = "v1.2.0" [[projects]] + digest = "1:7f569d906bdd20d906b606415b7d794f798f91a62fcfb6a4daa6d50690fb7a3f" name = "github.com/satori/go.uuid" packages = ["."] + pruneopts = "" revision = "f58768cc1a7a7e77a3bd49e98cdd21419399b6a3" version = "v1.2.0" [[projects]] + digest = "1:615c827f6a892973a587c754ae5fad7acfc4352657aff23d0238fe0ba2a154df" name = "github.com/shopspring/decimal" packages = ["."] + pruneopts = "" revision = "cd690d0c9e2447b1ef2a129a6b7b49077da89b8e" version = "1.1.0" [[projects]] + digest = "1:7ba2551c9a8de293bc575dbe2c0d862c52252d26f267f784547f059f512471c8" name = "github.com/spf13/afero" packages = [ ".", - "mem" + "mem", ] + pruneopts = "" revision = "787d034dfe70e44075ccc060d346146ef53270ad" version = "v1.1.1" [[projects]] + digest = "1:d0b38ba6da419a6d4380700218eeec8623841d44a856bb57369c172fbf692ab4" name = "github.com/spf13/cast" packages = ["."] + pruneopts = "" revision = "8965335b8c7107321228e3e3702cab9832751bac" version = "v1.2.0" [[projects]] + digest = "1:a1403cc8a94b8d7956ee5e9694badef0e7b051af289caad1cf668331e3ffa4f6" name = "github.com/spf13/cobra" packages = ["."] + pruneopts = "" revision = "ef82de70bb3f60c65fb8eebacbb2d122ef517385" version = "v0.0.3" [[projects]] branch = "master" + digest = "1:104517520aab91164020ab6524a5d6b7cafc641b2e42ac6236f6ac1deac4f66a" name = "github.com/spf13/jwalterweatherman" packages = ["."] + pruneopts = "" revision = "7c0cea34c8ece3fbeb2b27ab9b59511d360fb394" [[projects]] + digest = "1:8e243c568f36b09031ec18dff5f7d2769dcf5ca4d624ea511c8e3197dc3d352d" name = "github.com/spf13/pflag" packages = ["."] + pruneopts = "" revision = "583c0c0531f06d5278b7d917446061adc344b5cd" version = "v1.0.1" [[projects]] + digest = "1:3dab237cd3263a290d771d133fed777bb56c22e380b00ebe92e6531d5c8d3d0c" name = "github.com/spf13/viper" packages = ["."] + pruneopts = "" revision = "b5e8006cbee93ec955a89ab31e0e3ce3204f3736" version = "v1.0.2" [[projects]] branch = "master" + digest = "1:cae234a803b78380e4d769db6036b9fcc8c08ed4ff862571ffc1a958edc1f629" name = "golang.org/x/crypto" packages = [ "pkcs12", - "pkcs12/internal/rc2" + "pkcs12/internal/rc2", ] + pruneopts = "" revision = "c126467f60eb25f8f27e5a981f32a87e3965053f" [[projects]] branch = "master" + digest = "1:677e38cad6833ad266ec843739d167755eda1e6f2d8af1c63102b0426ad820db" name = "golang.org/x/sys" packages = ["unix"] + pruneopts = "" revision = "ac767d655b305d4e9612f5f6e33120b9176c4ad4" [[projects]] + digest = "1:5acd3512b047305d49e8763eef7ba423901e85d5dd2fd1e71778a0ea8de10bd4" name = "golang.org/x/text" packages = [ "internal/gen", @@ -212,36 +269,66 @@ "internal/ucd", "transform", "unicode/cldr", - "unicode/norm" + "unicode/norm", ] + pruneopts = "" revision = "f21a4dfb5e38f5895301dc265a8def02365cc3d0" version = "v0.3.0" [[projects]] branch = "master" + digest = "1:0a7c4519ae77a3efda26ca65984efe97392362bc3c6591f23775178f785d1d59" name = "golang.org/x/tools" packages = [ "go/ast/astutil", "imports", - "internal/fastwalk" + "internal/fastwalk", ] + pruneopts = "" revision = "ded554d0681e0cba3cf074977cdc12e2c0906fe6" [[projects]] branch = "v1" + digest = "1:1d01f96bc2293b56c3dec797b8f976d7613fb30ce92bfbc994130404f7f7f031" name = "gopkg.in/check.v1" packages = ["."] + pruneopts = "" revision = "788fd78401277ebd861206a03c884797c6ec5541" [[projects]] + digest = "1:f0620375dd1f6251d9973b5f2596228cc8042e887cd7f827e4220bc1ce8c30e2" name = "gopkg.in/yaml.v2" packages = ["."] + pruneopts = "" revision = "5420a8b6744d3b0345ab293f6fcba19c978f1183" version = "v2.2.1" [solve-meta] analyzer-name = "dep" analyzer-version = 1 - inputs-digest = "d76b8f370cdfbf2fbf0d0999210fb1fed0794d980a88da3df57112d5f5a439dc" + input-imports = [ + "github.com/Azure/go-autorest/autorest", + "github.com/Azure/go-autorest/autorest/adal", + "github.com/Azure/go-autorest/autorest/azure", + "github.com/Azure/go-autorest/autorest/azure/auth", + "github.com/Azure/go-autorest/autorest/date", + "github.com/Azure/go-autorest/autorest/to", + "github.com/Azure/go-autorest/autorest/validation", + "github.com/dnaeon/go-vcr/cassette", + "github.com/dnaeon/go-vcr/recorder", + "github.com/globalsign/mgo", + "github.com/marstr/collection", + "github.com/marstr/goalias/model", + "github.com/marstr/guid", + "github.com/marstr/randname", + "github.com/mitchellh/go-homedir", + "github.com/satori/go.uuid", + "github.com/shopspring/decimal", + "github.com/spf13/cobra", + "github.com/spf13/viper", + "golang.org/x/crypto/pkcs12", + "golang.org/x/tools/imports", + "gopkg.in/check.v1", + ] solver-name = "gps-cdcl" solver-version = 1 diff --git a/profiles/latest/cognitiveservices/face/models.go b/profiles/latest/cognitiveservices/face/models.go index 5546f0223432..19b11398a644 100644 --- a/profiles/latest/cognitiveservices/face/models.go +++ b/profiles/latest/cognitiveservices/face/models.go @@ -23,6 +23,9 @@ import original "github.com/Azure/azure-sdk-for-go/services/cognitiveservices/v1 type BaseClient = original.BaseClient type Client = original.Client +type LargeFaceListClient = original.LargeFaceListClient +type LargePersonGroupClient = original.LargePersonGroupClient +type LargePersonGroupPersonClient = original.LargePersonGroupPersonClient type ListClient = original.ListClient type AccessoryType = original.AccessoryType @@ -142,10 +145,15 @@ type IdentifyRequest = original.IdentifyRequest type IdentifyResult = original.IdentifyResult type ImageURL = original.ImageURL type Landmarks = original.Landmarks +type LargeFaceList = original.LargeFaceList +type LargePersonGroup = original.LargePersonGroup type List = original.List type ListDetectedFace = original.ListDetectedFace type ListIdentifyResult = original.ListIdentifyResult +type ListLargeFaceList = original.ListLargeFaceList +type ListLargePersonGroup = original.ListLargePersonGroup type ListList = original.ListList +type ListPersistedFace = original.ListPersistedFace type ListPerson = original.ListPerson type ListPersonGroup = original.ListPersonGroup type ListSimilarFace = original.ListSimilarFace @@ -159,7 +167,7 @@ type PersonGroup = original.PersonGroup type Rectangle = original.Rectangle type SimilarFace = original.SimilarFace type TrainingStatus = original.TrainingStatus -type UpdatePersonFaceRequest = original.UpdatePersonFaceRequest +type UpdateFaceRequest = original.UpdateFaceRequest type VerifyFaceToFaceRequest = original.VerifyFaceToFaceRequest type VerifyFaceToPersonRequest = original.VerifyFaceToPersonRequest type VerifyResult = original.VerifyResult @@ -175,6 +183,15 @@ func NewWithoutDefaults(endpoint string) BaseClient { func NewClient(endpoint string) Client { return original.NewClient(endpoint) } +func NewLargeFaceListClient(endpoint string) LargeFaceListClient { + return original.NewLargeFaceListClient(endpoint) +} +func NewLargePersonGroupClient(endpoint string) LargePersonGroupClient { + return original.NewLargePersonGroupClient(endpoint) +} +func NewLargePersonGroupPersonClient(endpoint string) LargePersonGroupPersonClient { + return original.NewLargePersonGroupPersonClient(endpoint) +} func NewListClient(endpoint string) ListClient { return original.NewListClient(endpoint) } diff --git a/profiles/preview/cognitiveservices/face/models.go b/profiles/preview/cognitiveservices/face/models.go index 879aa5bd927f..30d402313d25 100644 --- a/profiles/preview/cognitiveservices/face/models.go +++ b/profiles/preview/cognitiveservices/face/models.go @@ -23,6 +23,9 @@ import original "github.com/Azure/azure-sdk-for-go/services/cognitiveservices/v1 type BaseClient = original.BaseClient type Client = original.Client +type LargeFaceListClient = original.LargeFaceListClient +type LargePersonGroupClient = original.LargePersonGroupClient +type LargePersonGroupPersonClient = original.LargePersonGroupPersonClient type ListClient = original.ListClient type AccessoryType = original.AccessoryType @@ -142,10 +145,15 @@ type IdentifyRequest = original.IdentifyRequest type IdentifyResult = original.IdentifyResult type ImageURL = original.ImageURL type Landmarks = original.Landmarks +type LargeFaceList = original.LargeFaceList +type LargePersonGroup = original.LargePersonGroup type List = original.List type ListDetectedFace = original.ListDetectedFace type ListIdentifyResult = original.ListIdentifyResult +type ListLargeFaceList = original.ListLargeFaceList +type ListLargePersonGroup = original.ListLargePersonGroup type ListList = original.ListList +type ListPersistedFace = original.ListPersistedFace type ListPerson = original.ListPerson type ListPersonGroup = original.ListPersonGroup type ListSimilarFace = original.ListSimilarFace @@ -159,7 +167,7 @@ type PersonGroup = original.PersonGroup type Rectangle = original.Rectangle type SimilarFace = original.SimilarFace type TrainingStatus = original.TrainingStatus -type UpdatePersonFaceRequest = original.UpdatePersonFaceRequest +type UpdateFaceRequest = original.UpdateFaceRequest type VerifyFaceToFaceRequest = original.VerifyFaceToFaceRequest type VerifyFaceToPersonRequest = original.VerifyFaceToPersonRequest type VerifyResult = original.VerifyResult @@ -175,6 +183,15 @@ func NewWithoutDefaults(endpoint string) BaseClient { func NewClient(endpoint string) Client { return original.NewClient(endpoint) } +func NewLargeFaceListClient(endpoint string) LargeFaceListClient { + return original.NewLargeFaceListClient(endpoint) +} +func NewLargePersonGroupClient(endpoint string) LargePersonGroupClient { + return original.NewLargePersonGroupClient(endpoint) +} +func NewLargePersonGroupPersonClient(endpoint string) LargePersonGroupPersonClient { + return original.NewLargePersonGroupPersonClient(endpoint) +} func NewListClient(endpoint string) ListClient { return original.NewListClient(endpoint) } diff --git a/services/cognitiveservices/v1.0/face/face.go b/services/cognitiveservices/v1.0/face/face.go index 0315dcb3e9b1..6144507b9ef1 100644 --- a/services/cognitiveservices/v1.0/face/face.go +++ b/services/cognitiveservices/v1.0/face/face.go @@ -210,7 +210,8 @@ func (client Client) DetectWithURLResponder(resp *http.Response) (result ListDet return } -// FindSimilar given query face's faceId, find the similar-looking faces from a faceId array or a faceListId. +// FindSimilar given query face's faceId, find the similar-looking faces from a faceId array, a face list or a large +// face list. // Parameters: // body - request body for Find Similar. func (client Client) FindSimilar(ctx context.Context, body FindSimilarRequest) (result ListSimilarFace, err error) { @@ -221,6 +222,10 @@ func (client Client) FindSimilar(ctx context.Context, body FindSimilarRequest) ( Chain: []validation.Constraint{{Target: "body.FaceListID", Name: validation.MaxLength, Rule: 64, Chain: nil}, {Target: "body.FaceListID", Name: validation.Pattern, Rule: `^[a-z0-9-_]+$`, Chain: nil}, }}, + {Target: "body.LargeFaceListID", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "body.LargeFaceListID", Name: validation.MaxLength, Rule: 64, Chain: nil}, + {Target: "body.LargeFaceListID", Name: validation.Pattern, Rule: `^[a-z0-9-_]+$`, Chain: nil}, + }}, {Target: "body.FaceIds", Name: validation.Null, Rule: false, Chain: []validation.Constraint{{Target: "body.FaceIds", Name: validation.MaxItems, Rule: 1000, Chain: nil}}}, {Target: "body.MaxNumOfCandidatesReturned", Name: validation.Null, Rule: false, @@ -353,18 +358,23 @@ func (client Client) GroupResponder(resp *http.Response) (result GroupResult, er return } -// Identify identify unknown faces from a person group. +// Identify 1-to-many identification to find the closest matches of the specific query person face from a person group +// or large person group. // Parameters: // body - request body for identify operation. func (client Client) Identify(ctx context.Context, body IdentifyRequest) (result ListIdentifyResult, err error) { if err := validation.Validate([]validation.Validation{ {TargetValue: body, - Constraints: []validation.Constraint{{Target: "body.PersonGroupID", Name: validation.Null, Rule: true, - Chain: []validation.Constraint{{Target: "body.PersonGroupID", Name: validation.MaxLength, Rule: 64, Chain: nil}, - {Target: "body.PersonGroupID", Name: validation.Pattern, Rule: `^[a-z0-9-_]+$`, Chain: nil}, - }}, - {Target: "body.FaceIds", Name: validation.Null, Rule: true, - Chain: []validation.Constraint{{Target: "body.FaceIds", Name: validation.MaxItems, Rule: 10, Chain: nil}}}, + Constraints: []validation.Constraint{{Target: "body.FaceIds", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "body.FaceIds", Name: validation.MaxItems, Rule: 10, Chain: nil}}}, + {Target: "body.PersonGroupID", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "body.PersonGroupID", Name: validation.MaxLength, Rule: 64, Chain: nil}, + {Target: "body.PersonGroupID", Name: validation.Pattern, Rule: `^[a-z0-9-_]+$`, Chain: nil}, + }}, + {Target: "body.LargePersonGroupID", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "body.LargePersonGroupID", Name: validation.MaxLength, Rule: 64, Chain: nil}, + {Target: "body.LargePersonGroupID", Name: validation.Pattern, Rule: `^[a-z0-9-_]+$`, Chain: nil}, + }}, {Target: "body.MaxNumOfCandidatesReturned", Name: validation.Null, Rule: false, Chain: []validation.Constraint{{Target: "body.MaxNumOfCandidatesReturned", Name: validation.InclusiveMaximum, Rule: int64(5), Chain: nil}, {Target: "body.MaxNumOfCandidatesReturned", Name: validation.InclusiveMinimum, Rule: 1, Chain: nil}, @@ -430,7 +440,7 @@ func (client Client) IdentifyResponder(resp *http.Response) (result ListIdentify // VerifyFaceToFace verify whether two faces belong to a same person or whether one face belongs to a person. // Parameters: -// body - request body for verify operation. +// body - request body for face to face verification. func (client Client) VerifyFaceToFace(ctx context.Context, body VerifyFaceToFaceRequest) (result VerifyResult, err error) { if err := validation.Validate([]validation.Validation{ {TargetValue: body, @@ -497,15 +507,19 @@ func (client Client) VerifyFaceToFaceResponder(resp *http.Response) (result Veri // VerifyFaceToPerson verify whether two faces belong to a same person. Compares a face Id with a Person Id // Parameters: -// body - request body for verifying two faces in a person group +// body - request body for face to person verification. func (client Client) VerifyFaceToPerson(ctx context.Context, body VerifyFaceToPersonRequest) (result VerifyResult, err error) { if err := validation.Validate([]validation.Validation{ {TargetValue: body, Constraints: []validation.Constraint{{Target: "body.FaceID", Name: validation.Null, Rule: true, Chain: nil}, - {Target: "body.PersonGroupID", Name: validation.Null, Rule: true, + {Target: "body.PersonGroupID", Name: validation.Null, Rule: false, Chain: []validation.Constraint{{Target: "body.PersonGroupID", Name: validation.MaxLength, Rule: 64, Chain: nil}, {Target: "body.PersonGroupID", Name: validation.Pattern, Rule: `^[a-z0-9-_]+$`, Chain: nil}, }}, + {Target: "body.LargePersonGroupID", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "body.LargePersonGroupID", Name: validation.MaxLength, Rule: 64, Chain: nil}, + {Target: "body.LargePersonGroupID", Name: validation.Pattern, Rule: `^[a-z0-9-_]+$`, Chain: nil}, + }}, {Target: "body.PersonID", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { return result, validation.NewError("face.Client", "VerifyFaceToPerson", err.Error()) } diff --git a/services/cognitiveservices/v1.0/face/largefacelist.go b/services/cognitiveservices/v1.0/face/largefacelist.go new file mode 100644 index 000000000000..425ebac300db --- /dev/null +++ b/services/cognitiveservices/v1.0/face/largefacelist.go @@ -0,0 +1,999 @@ +package face + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/satori/go.uuid" + "io" + "net/http" +) + +// LargeFaceListClient is the an API for face detection, verification, and identification. +type LargeFaceListClient struct { + BaseClient +} + +// NewLargeFaceListClient creates an instance of the LargeFaceListClient client. +func NewLargeFaceListClient(endpoint string) LargeFaceListClient { + return LargeFaceListClient{New(endpoint)} +} + +// AddFaceFromStream add a face to a large face list. The input face is specified as an image with a targetFace +// rectangle. It returns a persistedFaceId representing the added face, and persistedFaceId will not expire. +// Parameters: +// largeFaceListID - id referencing a particular large face list. +// imageParameter - an image stream. +// userData - user-specified data about the face for any purpose. The maximum length is 1KB. +// targetFace - a face rectangle to specify the target face to be added to a person in the format of +// "targetFace=left,top,width,height". E.g. "targetFace=10,10,100,100". If there is more than one face in the +// image, targetFace is required to specify which face to add. No targetFace means there is only one face +// detected in the entire image. +func (client LargeFaceListClient) AddFaceFromStream(ctx context.Context, largeFaceListID string, imageParameter io.ReadCloser, userData string, targetFace []int32) (result PersistedFace, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: largeFaceListID, + Constraints: []validation.Constraint{{Target: "largeFaceListID", Name: validation.MaxLength, Rule: 64, Chain: nil}, + {Target: "largeFaceListID", Name: validation.Pattern, Rule: `^[a-z0-9-_]+$`, Chain: nil}}}, + {TargetValue: userData, + Constraints: []validation.Constraint{{Target: "userData", Name: validation.MaxLength, Rule: 1024, Chain: nil}}}}); err != nil { + return result, validation.NewError("face.LargeFaceListClient", "AddFaceFromStream", err.Error()) + } + + req, err := client.AddFaceFromStreamPreparer(ctx, largeFaceListID, imageParameter, userData, targetFace) + if err != nil { + err = autorest.NewErrorWithError(err, "face.LargeFaceListClient", "AddFaceFromStream", nil, "Failure preparing request") + return + } + + resp, err := client.AddFaceFromStreamSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "face.LargeFaceListClient", "AddFaceFromStream", resp, "Failure sending request") + return + } + + result, err = client.AddFaceFromStreamResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "face.LargeFaceListClient", "AddFaceFromStream", resp, "Failure responding to request") + } + + return +} + +// AddFaceFromStreamPreparer prepares the AddFaceFromStream request. +func (client LargeFaceListClient) AddFaceFromStreamPreparer(ctx context.Context, largeFaceListID string, imageParameter io.ReadCloser, userData string, targetFace []int32) (*http.Request, error) { + urlParameters := map[string]interface{}{ + "Endpoint": client.Endpoint, + } + + pathParameters := map[string]interface{}{ + "largeFaceListId": autorest.Encode("path", largeFaceListID), + } + + queryParameters := map[string]interface{}{} + if len(userData) > 0 { + queryParameters["userData"] = autorest.Encode("query", userData) + } + if targetFace != nil && len(targetFace) > 0 { + queryParameters["targetFace"] = autorest.Encode("query", targetFace, ",") + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/octet-stream"), + autorest.AsPost(), + autorest.WithCustomBaseURL("{Endpoint}/face/v1.0", urlParameters), + autorest.WithPathParameters("/largefacelists/{largeFaceListId}/persistedfaces", pathParameters), + autorest.WithFile(imageParameter), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// AddFaceFromStreamSender sends the AddFaceFromStream request. The method will close the +// http.Response Body if it receives an error. +func (client LargeFaceListClient) AddFaceFromStreamSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// AddFaceFromStreamResponder handles the response to the AddFaceFromStream request. The method always +// closes the http.Response Body. +func (client LargeFaceListClient) AddFaceFromStreamResponder(resp *http.Response) (result PersistedFace, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// AddFaceFromURL add a face to a large face list. The input face is specified as an image with a targetFace rectangle. +// It returns a persistedFaceId representing the added face, and persistedFaceId will not expire. +// Parameters: +// largeFaceListID - id referencing a particular large face list. +// imageURL - a JSON document with a URL pointing to the image that is to be analyzed. +// userData - user-specified data about the face for any purpose. The maximum length is 1KB. +// targetFace - a face rectangle to specify the target face to be added to a person in the format of +// "targetFace=left,top,width,height". E.g. "targetFace=10,10,100,100". If there is more than one face in the +// image, targetFace is required to specify which face to add. No targetFace means there is only one face +// detected in the entire image. +func (client LargeFaceListClient) AddFaceFromURL(ctx context.Context, largeFaceListID string, imageURL ImageURL, userData string, targetFace []int32) (result PersistedFace, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: largeFaceListID, + Constraints: []validation.Constraint{{Target: "largeFaceListID", Name: validation.MaxLength, Rule: 64, Chain: nil}, + {Target: "largeFaceListID", Name: validation.Pattern, Rule: `^[a-z0-9-_]+$`, Chain: nil}}}, + {TargetValue: userData, + Constraints: []validation.Constraint{{Target: "userData", Name: validation.MaxLength, Rule: 1024, Chain: nil}}}, + {TargetValue: imageURL, + Constraints: []validation.Constraint{{Target: "imageURL.URL", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { + return result, validation.NewError("face.LargeFaceListClient", "AddFaceFromURL", err.Error()) + } + + req, err := client.AddFaceFromURLPreparer(ctx, largeFaceListID, imageURL, userData, targetFace) + if err != nil { + err = autorest.NewErrorWithError(err, "face.LargeFaceListClient", "AddFaceFromURL", nil, "Failure preparing request") + return + } + + resp, err := client.AddFaceFromURLSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "face.LargeFaceListClient", "AddFaceFromURL", resp, "Failure sending request") + return + } + + result, err = client.AddFaceFromURLResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "face.LargeFaceListClient", "AddFaceFromURL", resp, "Failure responding to request") + } + + return +} + +// AddFaceFromURLPreparer prepares the AddFaceFromURL request. +func (client LargeFaceListClient) AddFaceFromURLPreparer(ctx context.Context, largeFaceListID string, imageURL ImageURL, userData string, targetFace []int32) (*http.Request, error) { + urlParameters := map[string]interface{}{ + "Endpoint": client.Endpoint, + } + + pathParameters := map[string]interface{}{ + "largeFaceListId": autorest.Encode("path", largeFaceListID), + } + + queryParameters := map[string]interface{}{} + if len(userData) > 0 { + queryParameters["userData"] = autorest.Encode("query", userData) + } + if targetFace != nil && len(targetFace) > 0 { + queryParameters["targetFace"] = autorest.Encode("query", targetFace, ",") + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPost(), + autorest.WithCustomBaseURL("{Endpoint}/face/v1.0", urlParameters), + autorest.WithPathParameters("/largefacelists/{largeFaceListId}/persistedfaces", pathParameters), + autorest.WithJSON(imageURL), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// AddFaceFromURLSender sends the AddFaceFromURL request. The method will close the +// http.Response Body if it receives an error. +func (client LargeFaceListClient) AddFaceFromURLSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// AddFaceFromURLResponder handles the response to the AddFaceFromURL request. The method always +// closes the http.Response Body. +func (client LargeFaceListClient) AddFaceFromURLResponder(resp *http.Response) (result PersistedFace, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Create create an empty large face list. Up to 64 large face lists are allowed to exist in one subscription. +// Parameters: +// largeFaceListID - id referencing a particular large face list. +// body - request body for creating a large face list. +func (client LargeFaceListClient) Create(ctx context.Context, largeFaceListID string, body NameAndUserDataContract) (result autorest.Response, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: largeFaceListID, + Constraints: []validation.Constraint{{Target: "largeFaceListID", Name: validation.MaxLength, Rule: 64, Chain: nil}, + {Target: "largeFaceListID", Name: validation.Pattern, Rule: `^[a-z0-9-_]+$`, Chain: nil}}}, + {TargetValue: body, + Constraints: []validation.Constraint{{Target: "body.Name", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "body.Name", Name: validation.MaxLength, Rule: 128, Chain: nil}}}, + {Target: "body.UserData", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "body.UserData", Name: validation.MaxLength, Rule: 16384, Chain: nil}}}}}}); err != nil { + return result, validation.NewError("face.LargeFaceListClient", "Create", err.Error()) + } + + req, err := client.CreatePreparer(ctx, largeFaceListID, body) + if err != nil { + err = autorest.NewErrorWithError(err, "face.LargeFaceListClient", "Create", nil, "Failure preparing request") + return + } + + resp, err := client.CreateSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "face.LargeFaceListClient", "Create", resp, "Failure sending request") + return + } + + result, err = client.CreateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "face.LargeFaceListClient", "Create", resp, "Failure responding to request") + } + + return +} + +// CreatePreparer prepares the Create request. +func (client LargeFaceListClient) CreatePreparer(ctx context.Context, largeFaceListID string, body NameAndUserDataContract) (*http.Request, error) { + urlParameters := map[string]interface{}{ + "Endpoint": client.Endpoint, + } + + pathParameters := map[string]interface{}{ + "largeFaceListId": autorest.Encode("path", largeFaceListID), + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithCustomBaseURL("{Endpoint}/face/v1.0", urlParameters), + autorest.WithPathParameters("/largefacelists/{largeFaceListId}", pathParameters), + autorest.WithJSON(body)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateSender sends the Create request. The method will close the +// http.Response Body if it receives an error. +func (client LargeFaceListClient) CreateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// CreateResponder handles the response to the Create request. The method always +// closes the http.Response Body. +func (client LargeFaceListClient) CreateResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} + +// Delete delete an existing large face list according to faceListId. Persisted face images in the large face list will +// also be deleted. +// Parameters: +// largeFaceListID - id referencing a particular large face list. +func (client LargeFaceListClient) Delete(ctx context.Context, largeFaceListID string) (result autorest.Response, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: largeFaceListID, + Constraints: []validation.Constraint{{Target: "largeFaceListID", Name: validation.MaxLength, Rule: 64, Chain: nil}, + {Target: "largeFaceListID", Name: validation.Pattern, Rule: `^[a-z0-9-_]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("face.LargeFaceListClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, largeFaceListID) + if err != nil { + err = autorest.NewErrorWithError(err, "face.LargeFaceListClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "face.LargeFaceListClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "face.LargeFaceListClient", "Delete", resp, "Failure responding to request") + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client LargeFaceListClient) DeletePreparer(ctx context.Context, largeFaceListID string) (*http.Request, error) { + urlParameters := map[string]interface{}{ + "Endpoint": client.Endpoint, + } + + pathParameters := map[string]interface{}{ + "largeFaceListId": autorest.Encode("path", largeFaceListID), + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithCustomBaseURL("{Endpoint}/face/v1.0", urlParameters), + autorest.WithPathParameters("/largefacelists/{largeFaceListId}", pathParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client LargeFaceListClient) DeleteSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client LargeFaceListClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} + +// DeleteFace delete an existing face from a large face list (given by a persisitedFaceId and a largeFaceListId). +// Persisted image related to the face will also be deleted. +// Parameters: +// largeFaceListID - id referencing a particular large face list. +// persistedFaceID - id referencing a particular persistedFaceId of an existing face. +func (client LargeFaceListClient) DeleteFace(ctx context.Context, largeFaceListID string, persistedFaceID uuid.UUID) (result autorest.Response, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: largeFaceListID, + Constraints: []validation.Constraint{{Target: "largeFaceListID", Name: validation.MaxLength, Rule: 64, Chain: nil}, + {Target: "largeFaceListID", Name: validation.Pattern, Rule: `^[a-z0-9-_]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("face.LargeFaceListClient", "DeleteFace", err.Error()) + } + + req, err := client.DeleteFacePreparer(ctx, largeFaceListID, persistedFaceID) + if err != nil { + err = autorest.NewErrorWithError(err, "face.LargeFaceListClient", "DeleteFace", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteFaceSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "face.LargeFaceListClient", "DeleteFace", resp, "Failure sending request") + return + } + + result, err = client.DeleteFaceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "face.LargeFaceListClient", "DeleteFace", resp, "Failure responding to request") + } + + return +} + +// DeleteFacePreparer prepares the DeleteFace request. +func (client LargeFaceListClient) DeleteFacePreparer(ctx context.Context, largeFaceListID string, persistedFaceID uuid.UUID) (*http.Request, error) { + urlParameters := map[string]interface{}{ + "Endpoint": client.Endpoint, + } + + pathParameters := map[string]interface{}{ + "largeFaceListId": autorest.Encode("path", largeFaceListID), + "persistedFaceId": autorest.Encode("path", persistedFaceID), + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithCustomBaseURL("{Endpoint}/face/v1.0", urlParameters), + autorest.WithPathParameters("/largefacelists/{largeFaceListId}/persistedfaces/{persistedFaceId}", pathParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteFaceSender sends the DeleteFace request. The method will close the +// http.Response Body if it receives an error. +func (client LargeFaceListClient) DeleteFaceSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// DeleteFaceResponder handles the response to the DeleteFace request. The method always +// closes the http.Response Body. +func (client LargeFaceListClient) DeleteFaceResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get retrieve a large face list's information. +// Parameters: +// largeFaceListID - id referencing a particular large face list. +func (client LargeFaceListClient) Get(ctx context.Context, largeFaceListID string) (result LargeFaceList, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: largeFaceListID, + Constraints: []validation.Constraint{{Target: "largeFaceListID", Name: validation.MaxLength, Rule: 64, Chain: nil}, + {Target: "largeFaceListID", Name: validation.Pattern, Rule: `^[a-z0-9-_]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("face.LargeFaceListClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, largeFaceListID) + if err != nil { + err = autorest.NewErrorWithError(err, "face.LargeFaceListClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "face.LargeFaceListClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "face.LargeFaceListClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client LargeFaceListClient) GetPreparer(ctx context.Context, largeFaceListID string) (*http.Request, error) { + urlParameters := map[string]interface{}{ + "Endpoint": client.Endpoint, + } + + pathParameters := map[string]interface{}{ + "largeFaceListId": autorest.Encode("path", largeFaceListID), + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithCustomBaseURL("{Endpoint}/face/v1.0", urlParameters), + autorest.WithPathParameters("/largefacelists/{largeFaceListId}", pathParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client LargeFaceListClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client LargeFaceListClient) GetResponder(resp *http.Response) (result LargeFaceList, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// GetFace retrieve information about a persisted face (specified by persistedFaceId and its belonging +// largeFaceListId). +// Parameters: +// largeFaceListID - id referencing a particular large face list. +// persistedFaceID - id referencing a particular persistedFaceId of an existing face. +func (client LargeFaceListClient) GetFace(ctx context.Context, largeFaceListID string, persistedFaceID uuid.UUID) (result PersistedFace, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: largeFaceListID, + Constraints: []validation.Constraint{{Target: "largeFaceListID", Name: validation.MaxLength, Rule: 64, Chain: nil}, + {Target: "largeFaceListID", Name: validation.Pattern, Rule: `^[a-z0-9-_]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("face.LargeFaceListClient", "GetFace", err.Error()) + } + + req, err := client.GetFacePreparer(ctx, largeFaceListID, persistedFaceID) + if err != nil { + err = autorest.NewErrorWithError(err, "face.LargeFaceListClient", "GetFace", nil, "Failure preparing request") + return + } + + resp, err := client.GetFaceSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "face.LargeFaceListClient", "GetFace", resp, "Failure sending request") + return + } + + result, err = client.GetFaceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "face.LargeFaceListClient", "GetFace", resp, "Failure responding to request") + } + + return +} + +// GetFacePreparer prepares the GetFace request. +func (client LargeFaceListClient) GetFacePreparer(ctx context.Context, largeFaceListID string, persistedFaceID uuid.UUID) (*http.Request, error) { + urlParameters := map[string]interface{}{ + "Endpoint": client.Endpoint, + } + + pathParameters := map[string]interface{}{ + "largeFaceListId": autorest.Encode("path", largeFaceListID), + "persistedFaceId": autorest.Encode("path", persistedFaceID), + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithCustomBaseURL("{Endpoint}/face/v1.0", urlParameters), + autorest.WithPathParameters("/largefacelists/{largeFaceListId}/persistedfaces/{persistedFaceId}", pathParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetFaceSender sends the GetFace request. The method will close the +// http.Response Body if it receives an error. +func (client LargeFaceListClient) GetFaceSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// GetFaceResponder handles the response to the GetFace request. The method always +// closes the http.Response Body. +func (client LargeFaceListClient) GetFaceResponder(resp *http.Response) (result PersistedFace, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// GetTrainingStatus retrieve the training status of a large face list (completed or ongoing). +// Parameters: +// largeFaceListID - id referencing a particular large face list. +func (client LargeFaceListClient) GetTrainingStatus(ctx context.Context, largeFaceListID string) (result TrainingStatus, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: largeFaceListID, + Constraints: []validation.Constraint{{Target: "largeFaceListID", Name: validation.MaxLength, Rule: 64, Chain: nil}, + {Target: "largeFaceListID", Name: validation.Pattern, Rule: `^[a-z0-9-_]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("face.LargeFaceListClient", "GetTrainingStatus", err.Error()) + } + + req, err := client.GetTrainingStatusPreparer(ctx, largeFaceListID) + if err != nil { + err = autorest.NewErrorWithError(err, "face.LargeFaceListClient", "GetTrainingStatus", nil, "Failure preparing request") + return + } + + resp, err := client.GetTrainingStatusSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "face.LargeFaceListClient", "GetTrainingStatus", resp, "Failure sending request") + return + } + + result, err = client.GetTrainingStatusResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "face.LargeFaceListClient", "GetTrainingStatus", resp, "Failure responding to request") + } + + return +} + +// GetTrainingStatusPreparer prepares the GetTrainingStatus request. +func (client LargeFaceListClient) GetTrainingStatusPreparer(ctx context.Context, largeFaceListID string) (*http.Request, error) { + urlParameters := map[string]interface{}{ + "Endpoint": client.Endpoint, + } + + pathParameters := map[string]interface{}{ + "largeFaceListId": autorest.Encode("path", largeFaceListID), + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithCustomBaseURL("{Endpoint}/face/v1.0", urlParameters), + autorest.WithPathParameters("/largefacelists/{largeFaceListId}/training", pathParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetTrainingStatusSender sends the GetTrainingStatus request. The method will close the +// http.Response Body if it receives an error. +func (client LargeFaceListClient) GetTrainingStatusSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// GetTrainingStatusResponder handles the response to the GetTrainingStatus request. The method always +// closes the http.Response Body. +func (client LargeFaceListClient) GetTrainingStatusResponder(resp *http.Response) (result TrainingStatus, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List retrieve information about all existing large face lists. Only largeFaceListId, name and userData will be +// returned. +func (client LargeFaceListClient) List(ctx context.Context) (result ListLargeFaceList, err error) { + req, err := client.ListPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "face.LargeFaceListClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "face.LargeFaceListClient", "List", resp, "Failure sending request") + return + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "face.LargeFaceListClient", "List", resp, "Failure responding to request") + } + + return +} + +// ListPreparer prepares the List request. +func (client LargeFaceListClient) ListPreparer(ctx context.Context) (*http.Request, error) { + urlParameters := map[string]interface{}{ + "Endpoint": client.Endpoint, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithCustomBaseURL("{Endpoint}/face/v1.0", urlParameters), + autorest.WithPath("/largefacelists")) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client LargeFaceListClient) ListSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client LargeFaceListClient) ListResponder(resp *http.Response) (result ListLargeFaceList, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result.Value), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListFaces list all faces in a large face list, and retrieve face information (including userData and +// persistedFaceIds of registered faces of the face). +// Parameters: +// largeFaceListID - id referencing a particular large face list. +// start - starting face id to return (used to list a range of faces). +// top - number of faces to return starting with the face id indicated by the 'start' parameter. +func (client LargeFaceListClient) ListFaces(ctx context.Context, largeFaceListID string, start string, top *int32) (result ListPersistedFace, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: largeFaceListID, + Constraints: []validation.Constraint{{Target: "largeFaceListID", Name: validation.MaxLength, Rule: 64, Chain: nil}, + {Target: "largeFaceListID", Name: validation.Pattern, Rule: `^[a-z0-9-_]+$`, Chain: nil}}}, + {TargetValue: top, + Constraints: []validation.Constraint{{Target: "top", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "top", Name: validation.InclusiveMaximum, Rule: int64(1000), Chain: nil}, + {Target: "top", Name: validation.InclusiveMinimum, Rule: 1, Chain: nil}, + }}}}}); err != nil { + return result, validation.NewError("face.LargeFaceListClient", "ListFaces", err.Error()) + } + + req, err := client.ListFacesPreparer(ctx, largeFaceListID, start, top) + if err != nil { + err = autorest.NewErrorWithError(err, "face.LargeFaceListClient", "ListFaces", nil, "Failure preparing request") + return + } + + resp, err := client.ListFacesSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "face.LargeFaceListClient", "ListFaces", resp, "Failure sending request") + return + } + + result, err = client.ListFacesResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "face.LargeFaceListClient", "ListFaces", resp, "Failure responding to request") + } + + return +} + +// ListFacesPreparer prepares the ListFaces request. +func (client LargeFaceListClient) ListFacesPreparer(ctx context.Context, largeFaceListID string, start string, top *int32) (*http.Request, error) { + urlParameters := map[string]interface{}{ + "Endpoint": client.Endpoint, + } + + pathParameters := map[string]interface{}{ + "largeFaceListId": autorest.Encode("path", largeFaceListID), + } + + queryParameters := map[string]interface{}{} + if len(start) > 0 { + queryParameters["start"] = autorest.Encode("query", start) + } + if top != nil { + queryParameters["top"] = autorest.Encode("query", *top) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithCustomBaseURL("{Endpoint}/face/v1.0", urlParameters), + autorest.WithPathParameters("/largefacelists/{largeFaceListId}/persistedfaces", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListFacesSender sends the ListFaces request. The method will close the +// http.Response Body if it receives an error. +func (client LargeFaceListClient) ListFacesSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// ListFacesResponder handles the response to the ListFaces request. The method always +// closes the http.Response Body. +func (client LargeFaceListClient) ListFacesResponder(resp *http.Response) (result ListPersistedFace, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result.Value), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Train queue a large face list training task, the training task may not be started immediately. +// Parameters: +// largeFaceListID - id referencing a particular large face list. +func (client LargeFaceListClient) Train(ctx context.Context, largeFaceListID string) (result autorest.Response, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: largeFaceListID, + Constraints: []validation.Constraint{{Target: "largeFaceListID", Name: validation.MaxLength, Rule: 64, Chain: nil}, + {Target: "largeFaceListID", Name: validation.Pattern, Rule: `^[a-z0-9-_]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("face.LargeFaceListClient", "Train", err.Error()) + } + + req, err := client.TrainPreparer(ctx, largeFaceListID) + if err != nil { + err = autorest.NewErrorWithError(err, "face.LargeFaceListClient", "Train", nil, "Failure preparing request") + return + } + + resp, err := client.TrainSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "face.LargeFaceListClient", "Train", resp, "Failure sending request") + return + } + + result, err = client.TrainResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "face.LargeFaceListClient", "Train", resp, "Failure responding to request") + } + + return +} + +// TrainPreparer prepares the Train request. +func (client LargeFaceListClient) TrainPreparer(ctx context.Context, largeFaceListID string) (*http.Request, error) { + urlParameters := map[string]interface{}{ + "Endpoint": client.Endpoint, + } + + pathParameters := map[string]interface{}{ + "largeFaceListId": autorest.Encode("path", largeFaceListID), + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithCustomBaseURL("{Endpoint}/face/v1.0", urlParameters), + autorest.WithPathParameters("/largefacelists/{largeFaceListId}/train", pathParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// TrainSender sends the Train request. The method will close the +// http.Response Body if it receives an error. +func (client LargeFaceListClient) TrainSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// TrainResponder handles the response to the Train request. The method always +// closes the http.Response Body. +func (client LargeFaceListClient) TrainResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByClosing()) + result.Response = resp + return +} + +// Update update information of a large face list. +// Parameters: +// largeFaceListID - id referencing a particular large face list. +// body - request body for updating a large face list. +func (client LargeFaceListClient) Update(ctx context.Context, largeFaceListID string, body NameAndUserDataContract) (result autorest.Response, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: largeFaceListID, + Constraints: []validation.Constraint{{Target: "largeFaceListID", Name: validation.MaxLength, Rule: 64, Chain: nil}, + {Target: "largeFaceListID", Name: validation.Pattern, Rule: `^[a-z0-9-_]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("face.LargeFaceListClient", "Update", err.Error()) + } + + req, err := client.UpdatePreparer(ctx, largeFaceListID, body) + if err != nil { + err = autorest.NewErrorWithError(err, "face.LargeFaceListClient", "Update", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "face.LargeFaceListClient", "Update", resp, "Failure sending request") + return + } + + result, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "face.LargeFaceListClient", "Update", resp, "Failure responding to request") + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client LargeFaceListClient) UpdatePreparer(ctx context.Context, largeFaceListID string, body NameAndUserDataContract) (*http.Request, error) { + urlParameters := map[string]interface{}{ + "Endpoint": client.Endpoint, + } + + pathParameters := map[string]interface{}{ + "largeFaceListId": autorest.Encode("path", largeFaceListID), + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithCustomBaseURL("{Endpoint}/face/v1.0", urlParameters), + autorest.WithPathParameters("/largefacelists/{largeFaceListId}", pathParameters), + autorest.WithJSON(body)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateSender sends the Update request. The method will close the +// http.Response Body if it receives an error. +func (client LargeFaceListClient) UpdateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client LargeFaceListClient) UpdateResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} + +// UpdateFace update a persisted face's userData field. +// Parameters: +// largeFaceListID - id referencing a particular large face list. +// persistedFaceID - id referencing a particular persistedFaceId of an existing face. +// body - request body for updating persisted face. +func (client LargeFaceListClient) UpdateFace(ctx context.Context, largeFaceListID string, persistedFaceID uuid.UUID, body UpdateFaceRequest) (result autorest.Response, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: largeFaceListID, + Constraints: []validation.Constraint{{Target: "largeFaceListID", Name: validation.MaxLength, Rule: 64, Chain: nil}, + {Target: "largeFaceListID", Name: validation.Pattern, Rule: `^[a-z0-9-_]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("face.LargeFaceListClient", "UpdateFace", err.Error()) + } + + req, err := client.UpdateFacePreparer(ctx, largeFaceListID, persistedFaceID, body) + if err != nil { + err = autorest.NewErrorWithError(err, "face.LargeFaceListClient", "UpdateFace", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateFaceSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "face.LargeFaceListClient", "UpdateFace", resp, "Failure sending request") + return + } + + result, err = client.UpdateFaceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "face.LargeFaceListClient", "UpdateFace", resp, "Failure responding to request") + } + + return +} + +// UpdateFacePreparer prepares the UpdateFace request. +func (client LargeFaceListClient) UpdateFacePreparer(ctx context.Context, largeFaceListID string, persistedFaceID uuid.UUID, body UpdateFaceRequest) (*http.Request, error) { + urlParameters := map[string]interface{}{ + "Endpoint": client.Endpoint, + } + + pathParameters := map[string]interface{}{ + "largeFaceListId": autorest.Encode("path", largeFaceListID), + "persistedFaceId": autorest.Encode("path", persistedFaceID), + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithCustomBaseURL("{Endpoint}/face/v1.0", urlParameters), + autorest.WithPathParameters("/largefacelists/{largeFaceListId}/persistedfaces/{persistedFaceId}", pathParameters), + autorest.WithJSON(body)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateFaceSender sends the UpdateFace request. The method will close the +// http.Response Body if it receives an error. +func (client LargeFaceListClient) UpdateFaceSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// UpdateFaceResponder handles the response to the UpdateFace request. The method always +// closes the http.Response Body. +func (client LargeFaceListClient) UpdateFaceResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} diff --git a/services/cognitiveservices/v1.0/face/largepersongroup.go b/services/cognitiveservices/v1.0/face/largepersongroup.go new file mode 100644 index 000000000000..9080d2f7e2a1 --- /dev/null +++ b/services/cognitiveservices/v1.0/face/largepersongroup.go @@ -0,0 +1,540 @@ +package face + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "net/http" +) + +// LargePersonGroupClient is the an API for face detection, verification, and identification. +type LargePersonGroupClient struct { + BaseClient +} + +// NewLargePersonGroupClient creates an instance of the LargePersonGroupClient client. +func NewLargePersonGroupClient(endpoint string) LargePersonGroupClient { + return LargePersonGroupClient{New(endpoint)} +} + +// Create create a new large person group with specified largePersonGroupId, name and user-provided userData. +// Parameters: +// largePersonGroupID - id referencing a particular large person group. +// body - request body for creating new large person group. +func (client LargePersonGroupClient) Create(ctx context.Context, largePersonGroupID string, body NameAndUserDataContract) (result autorest.Response, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: largePersonGroupID, + Constraints: []validation.Constraint{{Target: "largePersonGroupID", Name: validation.MaxLength, Rule: 64, Chain: nil}, + {Target: "largePersonGroupID", Name: validation.Pattern, Rule: `^[a-z0-9-_]+$`, Chain: nil}}}, + {TargetValue: body, + Constraints: []validation.Constraint{{Target: "body.Name", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "body.Name", Name: validation.MaxLength, Rule: 128, Chain: nil}}}, + {Target: "body.UserData", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "body.UserData", Name: validation.MaxLength, Rule: 16384, Chain: nil}}}}}}); err != nil { + return result, validation.NewError("face.LargePersonGroupClient", "Create", err.Error()) + } + + req, err := client.CreatePreparer(ctx, largePersonGroupID, body) + if err != nil { + err = autorest.NewErrorWithError(err, "face.LargePersonGroupClient", "Create", nil, "Failure preparing request") + return + } + + resp, err := client.CreateSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "face.LargePersonGroupClient", "Create", resp, "Failure sending request") + return + } + + result, err = client.CreateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "face.LargePersonGroupClient", "Create", resp, "Failure responding to request") + } + + return +} + +// CreatePreparer prepares the Create request. +func (client LargePersonGroupClient) CreatePreparer(ctx context.Context, largePersonGroupID string, body NameAndUserDataContract) (*http.Request, error) { + urlParameters := map[string]interface{}{ + "Endpoint": client.Endpoint, + } + + pathParameters := map[string]interface{}{ + "largePersonGroupId": autorest.Encode("path", largePersonGroupID), + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithCustomBaseURL("{Endpoint}/face/v1.0", urlParameters), + autorest.WithPathParameters("/largepersongroups/{largePersonGroupId}", pathParameters), + autorest.WithJSON(body)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateSender sends the Create request. The method will close the +// http.Response Body if it receives an error. +func (client LargePersonGroupClient) CreateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// CreateResponder handles the response to the Create request. The method always +// closes the http.Response Body. +func (client LargePersonGroupClient) CreateResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} + +// Delete delete an existing large person group. Persisted face features of all people in the large person group will +// also be deleted. +// Parameters: +// largePersonGroupID - id referencing a particular large person group. +func (client LargePersonGroupClient) Delete(ctx context.Context, largePersonGroupID string) (result autorest.Response, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: largePersonGroupID, + Constraints: []validation.Constraint{{Target: "largePersonGroupID", Name: validation.MaxLength, Rule: 64, Chain: nil}, + {Target: "largePersonGroupID", Name: validation.Pattern, Rule: `^[a-z0-9-_]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("face.LargePersonGroupClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, largePersonGroupID) + if err != nil { + err = autorest.NewErrorWithError(err, "face.LargePersonGroupClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "face.LargePersonGroupClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "face.LargePersonGroupClient", "Delete", resp, "Failure responding to request") + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client LargePersonGroupClient) DeletePreparer(ctx context.Context, largePersonGroupID string) (*http.Request, error) { + urlParameters := map[string]interface{}{ + "Endpoint": client.Endpoint, + } + + pathParameters := map[string]interface{}{ + "largePersonGroupId": autorest.Encode("path", largePersonGroupID), + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithCustomBaseURL("{Endpoint}/face/v1.0", urlParameters), + autorest.WithPathParameters("/largepersongroups/{largePersonGroupId}", pathParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client LargePersonGroupClient) DeleteSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client LargePersonGroupClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get retrieve the information of a large person group, including its name and userData. +// Parameters: +// largePersonGroupID - id referencing a particular large person group. +func (client LargePersonGroupClient) Get(ctx context.Context, largePersonGroupID string) (result LargePersonGroup, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: largePersonGroupID, + Constraints: []validation.Constraint{{Target: "largePersonGroupID", Name: validation.MaxLength, Rule: 64, Chain: nil}, + {Target: "largePersonGroupID", Name: validation.Pattern, Rule: `^[a-z0-9-_]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("face.LargePersonGroupClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, largePersonGroupID) + if err != nil { + err = autorest.NewErrorWithError(err, "face.LargePersonGroupClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "face.LargePersonGroupClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "face.LargePersonGroupClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client LargePersonGroupClient) GetPreparer(ctx context.Context, largePersonGroupID string) (*http.Request, error) { + urlParameters := map[string]interface{}{ + "Endpoint": client.Endpoint, + } + + pathParameters := map[string]interface{}{ + "largePersonGroupId": autorest.Encode("path", largePersonGroupID), + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithCustomBaseURL("{Endpoint}/face/v1.0", urlParameters), + autorest.WithPathParameters("/largepersongroups/{largePersonGroupId}", pathParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client LargePersonGroupClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client LargePersonGroupClient) GetResponder(resp *http.Response) (result LargePersonGroup, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// GetTrainingStatus retrieve the training status of a large person group (completed or ongoing). +// Parameters: +// largePersonGroupID - id referencing a particular large person group. +func (client LargePersonGroupClient) GetTrainingStatus(ctx context.Context, largePersonGroupID string) (result TrainingStatus, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: largePersonGroupID, + Constraints: []validation.Constraint{{Target: "largePersonGroupID", Name: validation.MaxLength, Rule: 64, Chain: nil}, + {Target: "largePersonGroupID", Name: validation.Pattern, Rule: `^[a-z0-9-_]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("face.LargePersonGroupClient", "GetTrainingStatus", err.Error()) + } + + req, err := client.GetTrainingStatusPreparer(ctx, largePersonGroupID) + if err != nil { + err = autorest.NewErrorWithError(err, "face.LargePersonGroupClient", "GetTrainingStatus", nil, "Failure preparing request") + return + } + + resp, err := client.GetTrainingStatusSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "face.LargePersonGroupClient", "GetTrainingStatus", resp, "Failure sending request") + return + } + + result, err = client.GetTrainingStatusResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "face.LargePersonGroupClient", "GetTrainingStatus", resp, "Failure responding to request") + } + + return +} + +// GetTrainingStatusPreparer prepares the GetTrainingStatus request. +func (client LargePersonGroupClient) GetTrainingStatusPreparer(ctx context.Context, largePersonGroupID string) (*http.Request, error) { + urlParameters := map[string]interface{}{ + "Endpoint": client.Endpoint, + } + + pathParameters := map[string]interface{}{ + "largePersonGroupId": autorest.Encode("path", largePersonGroupID), + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithCustomBaseURL("{Endpoint}/face/v1.0", urlParameters), + autorest.WithPathParameters("/largepersongroups/{largePersonGroupId}/training", pathParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetTrainingStatusSender sends the GetTrainingStatus request. The method will close the +// http.Response Body if it receives an error. +func (client LargePersonGroupClient) GetTrainingStatusSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// GetTrainingStatusResponder handles the response to the GetTrainingStatus request. The method always +// closes the http.Response Body. +func (client LargePersonGroupClient) GetTrainingStatusResponder(resp *http.Response) (result TrainingStatus, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List list large person groups and their information. +// Parameters: +// start - list large person groups from the least largePersonGroupId greater than the "start". +// top - the number of large person groups to list. +func (client LargePersonGroupClient) List(ctx context.Context, start string, top *int32) (result ListLargePersonGroup, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: start, + Constraints: []validation.Constraint{{Target: "start", Name: validation.MaxLength, Rule: 64, Chain: nil}}}, + {TargetValue: top, + Constraints: []validation.Constraint{{Target: "top", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "top", Name: validation.InclusiveMaximum, Rule: int64(1000), Chain: nil}, + {Target: "top", Name: validation.InclusiveMinimum, Rule: 1, Chain: nil}, + }}}}}); err != nil { + return result, validation.NewError("face.LargePersonGroupClient", "List", err.Error()) + } + + req, err := client.ListPreparer(ctx, start, top) + if err != nil { + err = autorest.NewErrorWithError(err, "face.LargePersonGroupClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "face.LargePersonGroupClient", "List", resp, "Failure sending request") + return + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "face.LargePersonGroupClient", "List", resp, "Failure responding to request") + } + + return +} + +// ListPreparer prepares the List request. +func (client LargePersonGroupClient) ListPreparer(ctx context.Context, start string, top *int32) (*http.Request, error) { + urlParameters := map[string]interface{}{ + "Endpoint": client.Endpoint, + } + + queryParameters := map[string]interface{}{} + if len(start) > 0 { + queryParameters["start"] = autorest.Encode("query", start) + } + if top != nil { + queryParameters["top"] = autorest.Encode("query", *top) + } else { + queryParameters["top"] = autorest.Encode("query", 1000) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithCustomBaseURL("{Endpoint}/face/v1.0", urlParameters), + autorest.WithPath("/largepersongroups"), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client LargePersonGroupClient) ListSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client LargePersonGroupClient) ListResponder(resp *http.Response) (result ListLargePersonGroup, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result.Value), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Train queue a large person group training task, the training task may not be started immediately. +// Parameters: +// largePersonGroupID - id referencing a particular large person group. +func (client LargePersonGroupClient) Train(ctx context.Context, largePersonGroupID string) (result autorest.Response, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: largePersonGroupID, + Constraints: []validation.Constraint{{Target: "largePersonGroupID", Name: validation.MaxLength, Rule: 64, Chain: nil}, + {Target: "largePersonGroupID", Name: validation.Pattern, Rule: `^[a-z0-9-_]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("face.LargePersonGroupClient", "Train", err.Error()) + } + + req, err := client.TrainPreparer(ctx, largePersonGroupID) + if err != nil { + err = autorest.NewErrorWithError(err, "face.LargePersonGroupClient", "Train", nil, "Failure preparing request") + return + } + + resp, err := client.TrainSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "face.LargePersonGroupClient", "Train", resp, "Failure sending request") + return + } + + result, err = client.TrainResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "face.LargePersonGroupClient", "Train", resp, "Failure responding to request") + } + + return +} + +// TrainPreparer prepares the Train request. +func (client LargePersonGroupClient) TrainPreparer(ctx context.Context, largePersonGroupID string) (*http.Request, error) { + urlParameters := map[string]interface{}{ + "Endpoint": client.Endpoint, + } + + pathParameters := map[string]interface{}{ + "largePersonGroupId": autorest.Encode("path", largePersonGroupID), + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithCustomBaseURL("{Endpoint}/face/v1.0", urlParameters), + autorest.WithPathParameters("/largepersongroups/{largePersonGroupId}/train", pathParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// TrainSender sends the Train request. The method will close the +// http.Response Body if it receives an error. +func (client LargePersonGroupClient) TrainSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// TrainResponder handles the response to the Train request. The method always +// closes the http.Response Body. +func (client LargePersonGroupClient) TrainResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByClosing()) + result.Response = resp + return +} + +// Update update an existing large person group's display name and userData. The properties which does not appear in +// request body will not be updated. +// Parameters: +// largePersonGroupID - id referencing a particular large person group. +// body - request body for updating large person group. +func (client LargePersonGroupClient) Update(ctx context.Context, largePersonGroupID string, body NameAndUserDataContract) (result autorest.Response, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: largePersonGroupID, + Constraints: []validation.Constraint{{Target: "largePersonGroupID", Name: validation.MaxLength, Rule: 64, Chain: nil}, + {Target: "largePersonGroupID", Name: validation.Pattern, Rule: `^[a-z0-9-_]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("face.LargePersonGroupClient", "Update", err.Error()) + } + + req, err := client.UpdatePreparer(ctx, largePersonGroupID, body) + if err != nil { + err = autorest.NewErrorWithError(err, "face.LargePersonGroupClient", "Update", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "face.LargePersonGroupClient", "Update", resp, "Failure sending request") + return + } + + result, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "face.LargePersonGroupClient", "Update", resp, "Failure responding to request") + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client LargePersonGroupClient) UpdatePreparer(ctx context.Context, largePersonGroupID string, body NameAndUserDataContract) (*http.Request, error) { + urlParameters := map[string]interface{}{ + "Endpoint": client.Endpoint, + } + + pathParameters := map[string]interface{}{ + "largePersonGroupId": autorest.Encode("path", largePersonGroupID), + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithCustomBaseURL("{Endpoint}/face/v1.0", urlParameters), + autorest.WithPathParameters("/largepersongroups/{largePersonGroupId}", pathParameters), + autorest.WithJSON(body)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateSender sends the Update request. The method will close the +// http.Response Body if it receives an error. +func (client LargePersonGroupClient) UpdateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client LargePersonGroupClient) UpdateResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} diff --git a/services/cognitiveservices/v1.0/face/largepersongroupperson.go b/services/cognitiveservices/v1.0/face/largepersongroupperson.go new file mode 100644 index 000000000000..b2ca1636a9e8 --- /dev/null +++ b/services/cognitiveservices/v1.0/face/largepersongroupperson.go @@ -0,0 +1,821 @@ +package face + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/satori/go.uuid" + "io" + "net/http" +) + +// LargePersonGroupPersonClient is the an API for face detection, verification, and identification. +type LargePersonGroupPersonClient struct { + BaseClient +} + +// NewLargePersonGroupPersonClient creates an instance of the LargePersonGroupPersonClient client. +func NewLargePersonGroupPersonClient(endpoint string) LargePersonGroupPersonClient { + return LargePersonGroupPersonClient{New(endpoint)} +} + +// AddFaceFromStream add a representative face to a person for identification. The input face is specified as an image +// with a targetFace rectangle. +// Parameters: +// largePersonGroupID - id referencing a particular large person group. +// personID - id referencing a particular person. +// imageParameter - an image stream. +// userData - user-specified data about the face for any purpose. The maximum length is 1KB. +// targetFace - a face rectangle to specify the target face to be added to a person in the format of +// "targetFace=left,top,width,height". E.g. "targetFace=10,10,100,100". If there is more than one face in the +// image, targetFace is required to specify which face to add. No targetFace means there is only one face +// detected in the entire image. +func (client LargePersonGroupPersonClient) AddFaceFromStream(ctx context.Context, largePersonGroupID string, personID uuid.UUID, imageParameter io.ReadCloser, userData string, targetFace []int32) (result PersistedFace, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: largePersonGroupID, + Constraints: []validation.Constraint{{Target: "largePersonGroupID", Name: validation.MaxLength, Rule: 64, Chain: nil}, + {Target: "largePersonGroupID", Name: validation.Pattern, Rule: `^[a-z0-9-_]+$`, Chain: nil}}}, + {TargetValue: userData, + Constraints: []validation.Constraint{{Target: "userData", Name: validation.MaxLength, Rule: 1024, Chain: nil}}}}); err != nil { + return result, validation.NewError("face.LargePersonGroupPersonClient", "AddFaceFromStream", err.Error()) + } + + req, err := client.AddFaceFromStreamPreparer(ctx, largePersonGroupID, personID, imageParameter, userData, targetFace) + if err != nil { + err = autorest.NewErrorWithError(err, "face.LargePersonGroupPersonClient", "AddFaceFromStream", nil, "Failure preparing request") + return + } + + resp, err := client.AddFaceFromStreamSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "face.LargePersonGroupPersonClient", "AddFaceFromStream", resp, "Failure sending request") + return + } + + result, err = client.AddFaceFromStreamResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "face.LargePersonGroupPersonClient", "AddFaceFromStream", resp, "Failure responding to request") + } + + return +} + +// AddFaceFromStreamPreparer prepares the AddFaceFromStream request. +func (client LargePersonGroupPersonClient) AddFaceFromStreamPreparer(ctx context.Context, largePersonGroupID string, personID uuid.UUID, imageParameter io.ReadCloser, userData string, targetFace []int32) (*http.Request, error) { + urlParameters := map[string]interface{}{ + "Endpoint": client.Endpoint, + } + + pathParameters := map[string]interface{}{ + "largePersonGroupId": autorest.Encode("path", largePersonGroupID), + "personId": autorest.Encode("path", personID), + } + + queryParameters := map[string]interface{}{} + if len(userData) > 0 { + queryParameters["userData"] = autorest.Encode("query", userData) + } + if targetFace != nil && len(targetFace) > 0 { + queryParameters["targetFace"] = autorest.Encode("query", targetFace, ",") + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/octet-stream"), + autorest.AsPost(), + autorest.WithCustomBaseURL("{Endpoint}/face/v1.0", urlParameters), + autorest.WithPathParameters("/largepersongroups/{largePersonGroupId}/persons/{personId}/persistedfaces", pathParameters), + autorest.WithFile(imageParameter), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// AddFaceFromStreamSender sends the AddFaceFromStream request. The method will close the +// http.Response Body if it receives an error. +func (client LargePersonGroupPersonClient) AddFaceFromStreamSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// AddFaceFromStreamResponder handles the response to the AddFaceFromStream request. The method always +// closes the http.Response Body. +func (client LargePersonGroupPersonClient) AddFaceFromStreamResponder(resp *http.Response) (result PersistedFace, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// AddFaceFromURL add a representative face to a person for identification. The input face is specified as an image +// with a targetFace rectangle. +// Parameters: +// largePersonGroupID - id referencing a particular large person group. +// personID - id referencing a particular person. +// imageURL - a JSON document with a URL pointing to the image that is to be analyzed. +// userData - user-specified data about the face for any purpose. The maximum length is 1KB. +// targetFace - a face rectangle to specify the target face to be added to a person in the format of +// "targetFace=left,top,width,height". E.g. "targetFace=10,10,100,100". If there is more than one face in the +// image, targetFace is required to specify which face to add. No targetFace means there is only one face +// detected in the entire image. +func (client LargePersonGroupPersonClient) AddFaceFromURL(ctx context.Context, largePersonGroupID string, personID uuid.UUID, imageURL ImageURL, userData string, targetFace []int32) (result PersistedFace, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: largePersonGroupID, + Constraints: []validation.Constraint{{Target: "largePersonGroupID", Name: validation.MaxLength, Rule: 64, Chain: nil}, + {Target: "largePersonGroupID", Name: validation.Pattern, Rule: `^[a-z0-9-_]+$`, Chain: nil}}}, + {TargetValue: userData, + Constraints: []validation.Constraint{{Target: "userData", Name: validation.MaxLength, Rule: 1024, Chain: nil}}}, + {TargetValue: imageURL, + Constraints: []validation.Constraint{{Target: "imageURL.URL", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { + return result, validation.NewError("face.LargePersonGroupPersonClient", "AddFaceFromURL", err.Error()) + } + + req, err := client.AddFaceFromURLPreparer(ctx, largePersonGroupID, personID, imageURL, userData, targetFace) + if err != nil { + err = autorest.NewErrorWithError(err, "face.LargePersonGroupPersonClient", "AddFaceFromURL", nil, "Failure preparing request") + return + } + + resp, err := client.AddFaceFromURLSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "face.LargePersonGroupPersonClient", "AddFaceFromURL", resp, "Failure sending request") + return + } + + result, err = client.AddFaceFromURLResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "face.LargePersonGroupPersonClient", "AddFaceFromURL", resp, "Failure responding to request") + } + + return +} + +// AddFaceFromURLPreparer prepares the AddFaceFromURL request. +func (client LargePersonGroupPersonClient) AddFaceFromURLPreparer(ctx context.Context, largePersonGroupID string, personID uuid.UUID, imageURL ImageURL, userData string, targetFace []int32) (*http.Request, error) { + urlParameters := map[string]interface{}{ + "Endpoint": client.Endpoint, + } + + pathParameters := map[string]interface{}{ + "largePersonGroupId": autorest.Encode("path", largePersonGroupID), + "personId": autorest.Encode("path", personID), + } + + queryParameters := map[string]interface{}{} + if len(userData) > 0 { + queryParameters["userData"] = autorest.Encode("query", userData) + } + if targetFace != nil && len(targetFace) > 0 { + queryParameters["targetFace"] = autorest.Encode("query", targetFace, ",") + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPost(), + autorest.WithCustomBaseURL("{Endpoint}/face/v1.0", urlParameters), + autorest.WithPathParameters("/largepersongroups/{largePersonGroupId}/persons/{personId}/persistedfaces", pathParameters), + autorest.WithJSON(imageURL), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// AddFaceFromURLSender sends the AddFaceFromURL request. The method will close the +// http.Response Body if it receives an error. +func (client LargePersonGroupPersonClient) AddFaceFromURLSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// AddFaceFromURLResponder handles the response to the AddFaceFromURL request. The method always +// closes the http.Response Body. +func (client LargePersonGroupPersonClient) AddFaceFromURLResponder(resp *http.Response) (result PersistedFace, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Create create a new person in a specified large person group. +// Parameters: +// largePersonGroupID - id referencing a particular large person group. +// body - request body for creating new person. +func (client LargePersonGroupPersonClient) Create(ctx context.Context, largePersonGroupID string, body NameAndUserDataContract) (result Person, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: largePersonGroupID, + Constraints: []validation.Constraint{{Target: "largePersonGroupID", Name: validation.MaxLength, Rule: 64, Chain: nil}, + {Target: "largePersonGroupID", Name: validation.Pattern, Rule: `^[a-z0-9-_]+$`, Chain: nil}}}, + {TargetValue: body, + Constraints: []validation.Constraint{{Target: "body.Name", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "body.Name", Name: validation.MaxLength, Rule: 128, Chain: nil}}}, + {Target: "body.UserData", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "body.UserData", Name: validation.MaxLength, Rule: 16384, Chain: nil}}}}}}); err != nil { + return result, validation.NewError("face.LargePersonGroupPersonClient", "Create", err.Error()) + } + + req, err := client.CreatePreparer(ctx, largePersonGroupID, body) + if err != nil { + err = autorest.NewErrorWithError(err, "face.LargePersonGroupPersonClient", "Create", nil, "Failure preparing request") + return + } + + resp, err := client.CreateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "face.LargePersonGroupPersonClient", "Create", resp, "Failure sending request") + return + } + + result, err = client.CreateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "face.LargePersonGroupPersonClient", "Create", resp, "Failure responding to request") + } + + return +} + +// CreatePreparer prepares the Create request. +func (client LargePersonGroupPersonClient) CreatePreparer(ctx context.Context, largePersonGroupID string, body NameAndUserDataContract) (*http.Request, error) { + urlParameters := map[string]interface{}{ + "Endpoint": client.Endpoint, + } + + pathParameters := map[string]interface{}{ + "largePersonGroupId": autorest.Encode("path", largePersonGroupID), + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPost(), + autorest.WithCustomBaseURL("{Endpoint}/face/v1.0", urlParameters), + autorest.WithPathParameters("/largepersongroups/{largePersonGroupId}/persons", pathParameters), + autorest.WithJSON(body)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateSender sends the Create request. The method will close the +// http.Response Body if it receives an error. +func (client LargePersonGroupPersonClient) CreateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// CreateResponder handles the response to the Create request. The method always +// closes the http.Response Body. +func (client LargePersonGroupPersonClient) CreateResponder(resp *http.Response) (result Person, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete delete an existing person from a large person group. All stored person data, and face features in the person +// entry will be deleted. +// Parameters: +// largePersonGroupID - id referencing a particular large person group. +// personID - id referencing a particular person. +func (client LargePersonGroupPersonClient) Delete(ctx context.Context, largePersonGroupID string, personID uuid.UUID) (result autorest.Response, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: largePersonGroupID, + Constraints: []validation.Constraint{{Target: "largePersonGroupID", Name: validation.MaxLength, Rule: 64, Chain: nil}, + {Target: "largePersonGroupID", Name: validation.Pattern, Rule: `^[a-z0-9-_]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("face.LargePersonGroupPersonClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, largePersonGroupID, personID) + if err != nil { + err = autorest.NewErrorWithError(err, "face.LargePersonGroupPersonClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "face.LargePersonGroupPersonClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "face.LargePersonGroupPersonClient", "Delete", resp, "Failure responding to request") + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client LargePersonGroupPersonClient) DeletePreparer(ctx context.Context, largePersonGroupID string, personID uuid.UUID) (*http.Request, error) { + urlParameters := map[string]interface{}{ + "Endpoint": client.Endpoint, + } + + pathParameters := map[string]interface{}{ + "largePersonGroupId": autorest.Encode("path", largePersonGroupID), + "personId": autorest.Encode("path", personID), + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithCustomBaseURL("{Endpoint}/face/v1.0", urlParameters), + autorest.WithPathParameters("/largepersongroups/{largePersonGroupId}/persons/{personId}", pathParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client LargePersonGroupPersonClient) DeleteSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client LargePersonGroupPersonClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} + +// DeleteFace delete a face from a person. Relative feature for the persisted face will also be deleted. +// Parameters: +// largePersonGroupID - id referencing a particular large person group. +// personID - id referencing a particular person. +// persistedFaceID - id referencing a particular persistedFaceId of an existing face. +func (client LargePersonGroupPersonClient) DeleteFace(ctx context.Context, largePersonGroupID string, personID uuid.UUID, persistedFaceID uuid.UUID) (result autorest.Response, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: largePersonGroupID, + Constraints: []validation.Constraint{{Target: "largePersonGroupID", Name: validation.MaxLength, Rule: 64, Chain: nil}, + {Target: "largePersonGroupID", Name: validation.Pattern, Rule: `^[a-z0-9-_]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("face.LargePersonGroupPersonClient", "DeleteFace", err.Error()) + } + + req, err := client.DeleteFacePreparer(ctx, largePersonGroupID, personID, persistedFaceID) + if err != nil { + err = autorest.NewErrorWithError(err, "face.LargePersonGroupPersonClient", "DeleteFace", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteFaceSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "face.LargePersonGroupPersonClient", "DeleteFace", resp, "Failure sending request") + return + } + + result, err = client.DeleteFaceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "face.LargePersonGroupPersonClient", "DeleteFace", resp, "Failure responding to request") + } + + return +} + +// DeleteFacePreparer prepares the DeleteFace request. +func (client LargePersonGroupPersonClient) DeleteFacePreparer(ctx context.Context, largePersonGroupID string, personID uuid.UUID, persistedFaceID uuid.UUID) (*http.Request, error) { + urlParameters := map[string]interface{}{ + "Endpoint": client.Endpoint, + } + + pathParameters := map[string]interface{}{ + "largePersonGroupId": autorest.Encode("path", largePersonGroupID), + "persistedFaceId": autorest.Encode("path", persistedFaceID), + "personId": autorest.Encode("path", personID), + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithCustomBaseURL("{Endpoint}/face/v1.0", urlParameters), + autorest.WithPathParameters("/largepersongroups/{largePersonGroupId}/persons/{personId}/persistedfaces/{persistedFaceId}", pathParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteFaceSender sends the DeleteFace request. The method will close the +// http.Response Body if it receives an error. +func (client LargePersonGroupPersonClient) DeleteFaceSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// DeleteFaceResponder handles the response to the DeleteFace request. The method always +// closes the http.Response Body. +func (client LargePersonGroupPersonClient) DeleteFaceResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get retrieve a person's information, including registered persisted faces, name and userData. +// Parameters: +// largePersonGroupID - id referencing a particular large person group. +// personID - id referencing a particular person. +func (client LargePersonGroupPersonClient) Get(ctx context.Context, largePersonGroupID string, personID uuid.UUID) (result Person, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: largePersonGroupID, + Constraints: []validation.Constraint{{Target: "largePersonGroupID", Name: validation.MaxLength, Rule: 64, Chain: nil}, + {Target: "largePersonGroupID", Name: validation.Pattern, Rule: `^[a-z0-9-_]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("face.LargePersonGroupPersonClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, largePersonGroupID, personID) + if err != nil { + err = autorest.NewErrorWithError(err, "face.LargePersonGroupPersonClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "face.LargePersonGroupPersonClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "face.LargePersonGroupPersonClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client LargePersonGroupPersonClient) GetPreparer(ctx context.Context, largePersonGroupID string, personID uuid.UUID) (*http.Request, error) { + urlParameters := map[string]interface{}{ + "Endpoint": client.Endpoint, + } + + pathParameters := map[string]interface{}{ + "largePersonGroupId": autorest.Encode("path", largePersonGroupID), + "personId": autorest.Encode("path", personID), + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithCustomBaseURL("{Endpoint}/face/v1.0", urlParameters), + autorest.WithPathParameters("/largepersongroups/{largePersonGroupId}/persons/{personId}", pathParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client LargePersonGroupPersonClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client LargePersonGroupPersonClient) GetResponder(resp *http.Response) (result Person, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// GetFace retrieve information about a persisted face (specified by persistedFaceId, personId and its belonging +// largePersonGroupId). +// Parameters: +// largePersonGroupID - id referencing a particular large person group. +// personID - id referencing a particular person. +// persistedFaceID - id referencing a particular persistedFaceId of an existing face. +func (client LargePersonGroupPersonClient) GetFace(ctx context.Context, largePersonGroupID string, personID uuid.UUID, persistedFaceID uuid.UUID) (result PersistedFace, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: largePersonGroupID, + Constraints: []validation.Constraint{{Target: "largePersonGroupID", Name: validation.MaxLength, Rule: 64, Chain: nil}, + {Target: "largePersonGroupID", Name: validation.Pattern, Rule: `^[a-z0-9-_]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("face.LargePersonGroupPersonClient", "GetFace", err.Error()) + } + + req, err := client.GetFacePreparer(ctx, largePersonGroupID, personID, persistedFaceID) + if err != nil { + err = autorest.NewErrorWithError(err, "face.LargePersonGroupPersonClient", "GetFace", nil, "Failure preparing request") + return + } + + resp, err := client.GetFaceSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "face.LargePersonGroupPersonClient", "GetFace", resp, "Failure sending request") + return + } + + result, err = client.GetFaceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "face.LargePersonGroupPersonClient", "GetFace", resp, "Failure responding to request") + } + + return +} + +// GetFacePreparer prepares the GetFace request. +func (client LargePersonGroupPersonClient) GetFacePreparer(ctx context.Context, largePersonGroupID string, personID uuid.UUID, persistedFaceID uuid.UUID) (*http.Request, error) { + urlParameters := map[string]interface{}{ + "Endpoint": client.Endpoint, + } + + pathParameters := map[string]interface{}{ + "largePersonGroupId": autorest.Encode("path", largePersonGroupID), + "persistedFaceId": autorest.Encode("path", persistedFaceID), + "personId": autorest.Encode("path", personID), + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithCustomBaseURL("{Endpoint}/face/v1.0", urlParameters), + autorest.WithPathParameters("/largepersongroups/{largePersonGroupId}/persons/{personId}/persistedfaces/{persistedFaceId}", pathParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetFaceSender sends the GetFace request. The method will close the +// http.Response Body if it receives an error. +func (client LargePersonGroupPersonClient) GetFaceSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// GetFaceResponder handles the response to the GetFace request. The method always +// closes the http.Response Body. +func (client LargePersonGroupPersonClient) GetFaceResponder(resp *http.Response) (result PersistedFace, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List list all persons in a large person group, and retrieve person information (including personId, name, userData +// and persistedFaceIds of registered faces of the person). +// Parameters: +// largePersonGroupID - id referencing a particular large person group. +// start - starting person id to return (used to list a range of persons). +// top - number of persons to return starting with the person id indicated by the 'start' parameter. +func (client LargePersonGroupPersonClient) List(ctx context.Context, largePersonGroupID string, start string, top *int32) (result ListPerson, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: largePersonGroupID, + Constraints: []validation.Constraint{{Target: "largePersonGroupID", Name: validation.MaxLength, Rule: 64, Chain: nil}, + {Target: "largePersonGroupID", Name: validation.Pattern, Rule: `^[a-z0-9-_]+$`, Chain: nil}}}, + {TargetValue: top, + Constraints: []validation.Constraint{{Target: "top", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "top", Name: validation.InclusiveMaximum, Rule: int64(1000), Chain: nil}, + {Target: "top", Name: validation.InclusiveMinimum, Rule: 1, Chain: nil}, + }}}}}); err != nil { + return result, validation.NewError("face.LargePersonGroupPersonClient", "List", err.Error()) + } + + req, err := client.ListPreparer(ctx, largePersonGroupID, start, top) + if err != nil { + err = autorest.NewErrorWithError(err, "face.LargePersonGroupPersonClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "face.LargePersonGroupPersonClient", "List", resp, "Failure sending request") + return + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "face.LargePersonGroupPersonClient", "List", resp, "Failure responding to request") + } + + return +} + +// ListPreparer prepares the List request. +func (client LargePersonGroupPersonClient) ListPreparer(ctx context.Context, largePersonGroupID string, start string, top *int32) (*http.Request, error) { + urlParameters := map[string]interface{}{ + "Endpoint": client.Endpoint, + } + + pathParameters := map[string]interface{}{ + "largePersonGroupId": autorest.Encode("path", largePersonGroupID), + } + + queryParameters := map[string]interface{}{} + if len(start) > 0 { + queryParameters["start"] = autorest.Encode("query", start) + } + if top != nil { + queryParameters["top"] = autorest.Encode("query", *top) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithCustomBaseURL("{Endpoint}/face/v1.0", urlParameters), + autorest.WithPathParameters("/largepersongroups/{largePersonGroupId}/persons", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client LargePersonGroupPersonClient) ListSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client LargePersonGroupPersonClient) ListResponder(resp *http.Response) (result ListPerson, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result.Value), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Update update name or userData of a person. +// Parameters: +// largePersonGroupID - id referencing a particular large person group. +// personID - id referencing a particular person. +// body - request body for person update operation. +func (client LargePersonGroupPersonClient) Update(ctx context.Context, largePersonGroupID string, personID uuid.UUID, body NameAndUserDataContract) (result autorest.Response, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: largePersonGroupID, + Constraints: []validation.Constraint{{Target: "largePersonGroupID", Name: validation.MaxLength, Rule: 64, Chain: nil}, + {Target: "largePersonGroupID", Name: validation.Pattern, Rule: `^[a-z0-9-_]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("face.LargePersonGroupPersonClient", "Update", err.Error()) + } + + req, err := client.UpdatePreparer(ctx, largePersonGroupID, personID, body) + if err != nil { + err = autorest.NewErrorWithError(err, "face.LargePersonGroupPersonClient", "Update", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "face.LargePersonGroupPersonClient", "Update", resp, "Failure sending request") + return + } + + result, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "face.LargePersonGroupPersonClient", "Update", resp, "Failure responding to request") + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client LargePersonGroupPersonClient) UpdatePreparer(ctx context.Context, largePersonGroupID string, personID uuid.UUID, body NameAndUserDataContract) (*http.Request, error) { + urlParameters := map[string]interface{}{ + "Endpoint": client.Endpoint, + } + + pathParameters := map[string]interface{}{ + "largePersonGroupId": autorest.Encode("path", largePersonGroupID), + "personId": autorest.Encode("path", personID), + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithCustomBaseURL("{Endpoint}/face/v1.0", urlParameters), + autorest.WithPathParameters("/largepersongroups/{largePersonGroupId}/persons/{personId}", pathParameters), + autorest.WithJSON(body)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateSender sends the Update request. The method will close the +// http.Response Body if it receives an error. +func (client LargePersonGroupPersonClient) UpdateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client LargePersonGroupPersonClient) UpdateResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} + +// UpdateFace update a person persisted face's userData field. +// Parameters: +// largePersonGroupID - id referencing a particular large person group. +// personID - id referencing a particular person. +// persistedFaceID - id referencing a particular persistedFaceId of an existing face. +// body - request body for updating persisted face. +func (client LargePersonGroupPersonClient) UpdateFace(ctx context.Context, largePersonGroupID string, personID uuid.UUID, persistedFaceID uuid.UUID, body UpdateFaceRequest) (result autorest.Response, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: largePersonGroupID, + Constraints: []validation.Constraint{{Target: "largePersonGroupID", Name: validation.MaxLength, Rule: 64, Chain: nil}, + {Target: "largePersonGroupID", Name: validation.Pattern, Rule: `^[a-z0-9-_]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("face.LargePersonGroupPersonClient", "UpdateFace", err.Error()) + } + + req, err := client.UpdateFacePreparer(ctx, largePersonGroupID, personID, persistedFaceID, body) + if err != nil { + err = autorest.NewErrorWithError(err, "face.LargePersonGroupPersonClient", "UpdateFace", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateFaceSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "face.LargePersonGroupPersonClient", "UpdateFace", resp, "Failure sending request") + return + } + + result, err = client.UpdateFaceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "face.LargePersonGroupPersonClient", "UpdateFace", resp, "Failure responding to request") + } + + return +} + +// UpdateFacePreparer prepares the UpdateFace request. +func (client LargePersonGroupPersonClient) UpdateFacePreparer(ctx context.Context, largePersonGroupID string, personID uuid.UUID, persistedFaceID uuid.UUID, body UpdateFaceRequest) (*http.Request, error) { + urlParameters := map[string]interface{}{ + "Endpoint": client.Endpoint, + } + + pathParameters := map[string]interface{}{ + "largePersonGroupId": autorest.Encode("path", largePersonGroupID), + "persistedFaceId": autorest.Encode("path", persistedFaceID), + "personId": autorest.Encode("path", personID), + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithCustomBaseURL("{Endpoint}/face/v1.0", urlParameters), + autorest.WithPathParameters("/largepersongroups/{largePersonGroupId}/persons/{personId}/persistedfaces/{persistedFaceId}", pathParameters), + autorest.WithJSON(body)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateFaceSender sends the UpdateFace request. The method will close the +// http.Response Body if it receives an error. +func (client LargePersonGroupPersonClient) UpdateFaceSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// UpdateFaceResponder handles the response to the UpdateFace request. The method always +// closes the http.Response Body. +func (client LargePersonGroupPersonClient) UpdateFaceResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} diff --git a/services/cognitiveservices/v1.0/face/list.go b/services/cognitiveservices/v1.0/face/list.go index 27362c844411..4c1837006008 100644 --- a/services/cognitiveservices/v1.0/face/list.go +++ b/services/cognitiveservices/v1.0/face/list.go @@ -100,7 +100,7 @@ func (client ListClient) AddFaceFromStreamPreparer(ctx context.Context, faceList autorest.AsContentType("application/octet-stream"), autorest.AsPost(), autorest.WithCustomBaseURL("{Endpoint}/face/v1.0", urlParameters), - autorest.WithPathParameters("/facelists/{faceListId}/persistedFaces", pathParameters), + autorest.WithPathParameters("/facelists/{faceListId}/persistedfaces", pathParameters), autorest.WithFile(imageParameter), autorest.WithQueryParameters(queryParameters)) return preparer.Prepare((&http.Request{}).WithContext(ctx)) @@ -191,7 +191,7 @@ func (client ListClient) AddFaceFromURLPreparer(ctx context.Context, faceListID autorest.AsContentType("application/json; charset=utf-8"), autorest.AsPost(), autorest.WithCustomBaseURL("{Endpoint}/face/v1.0", urlParameters), - autorest.WithPathParameters("/facelists/{faceListId}/persistedFaces", pathParameters), + autorest.WithPathParameters("/facelists/{faceListId}/persistedfaces", pathParameters), autorest.WithJSON(imageURL), autorest.WithQueryParameters(queryParameters)) return preparer.Prepare((&http.Request{}).WithContext(ctx)) @@ -410,7 +410,7 @@ func (client ListClient) DeleteFacePreparer(ctx context.Context, faceListID stri preparer := autorest.CreatePreparer( autorest.AsDelete(), autorest.WithCustomBaseURL("{Endpoint}/face/v1.0", urlParameters), - autorest.WithPathParameters("/facelists/{faceListId}/persistedFaces/{persistedFaceId}", pathParameters)) + autorest.WithPathParameters("/facelists/{faceListId}/persistedfaces/{persistedFaceId}", pathParameters)) return preparer.Prepare((&http.Request{}).WithContext(ctx)) } diff --git a/services/cognitiveservices/v1.0/face/models.go b/services/cognitiveservices/v1.0/face/models.go index eb817d3afd09..2a7653dccec0 100644 --- a/services/cognitiveservices/v1.0/face/models.go +++ b/services/cognitiveservices/v1.0/face/models.go @@ -333,9 +333,11 @@ type FacialHair struct { type FindSimilarRequest struct { // 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 FaceID *uuid.UUID `json:"faceId,omitempty"` - // FaceListID - An existing user-specified unique candidate face list, created in Face List - Create a Face List. Face list contains a set of persistedFaceIds which are persisted and will never expire. Parameter faceListId and faceIds should not be provided at the same time + // FaceListID - 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 `json:"faceListId,omitempty"` - // 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. + // 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. + LargeFaceListID *string `json:"largeFaceListId,omitempty"` + // 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. FaceIds *[]uuid.UUID `json:"faceIds,omitempty"` // MaxNumOfCandidatesReturned - The number of top similar faces returned. The valid range is [1, 1000]. MaxNumOfCandidatesReturned *int32 `json:"maxNumOfCandidatesReturned,omitempty"` @@ -393,10 +395,12 @@ type IdentifyCandidate struct { // IdentifyRequest request body for identify face operation. type IdentifyRequest struct { - // PersonGroupID - PersonGroupId of the target person group, created by PersonGroups.Create - PersonGroupID *string `json:"personGroupId,omitempty"` // 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]. FaceIds *[]uuid.UUID `json:"faceIds,omitempty"` + // PersonGroupID - PersonGroupId of the target person group, created by PersonGroup - Create. Parameter personGroupId and largePersonGroupId should not be provided at the same time. + PersonGroupID *string `json:"personGroupId,omitempty"` + // LargePersonGroupID - 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 `json:"largePersonGroupId,omitempty"` // MaxNumOfCandidatesReturned - The range of maxNumOfCandidatesReturned is between 1 and 5 (default is 1). MaxNumOfCandidatesReturned *int32 `json:"maxNumOfCandidatesReturned,omitempty"` // 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). @@ -448,6 +452,28 @@ type Landmarks struct { UnderLipBottom *Coordinate `json:"underLipBottom,omitempty"` } +// LargeFaceList large face list object. +type LargeFaceList struct { + autorest.Response `json:"-"` + // LargeFaceListID - LargeFaceListId of the target large face list. + LargeFaceListID *string `json:"largeFaceListId,omitempty"` + // Name - User defined name, maximum length is 128. + Name *string `json:"name,omitempty"` + // UserData - User specified data. Length should not exceed 16KB. + UserData *string `json:"userData,omitempty"` +} + +// LargePersonGroup large person group object. +type LargePersonGroup struct { + autorest.Response `json:"-"` + // LargePersonGroupID - LargePersonGroupId of the target large person groups + LargePersonGroupID *string `json:"largePersonGroupId,omitempty"` + // Name - User defined name, maximum length is 128. + Name *string `json:"name,omitempty"` + // UserData - User specified data. Length should not exceed 16KB. + UserData *string `json:"userData,omitempty"` +} + // List face list object. type List struct { autorest.Response `json:"-"` @@ -473,12 +499,30 @@ type ListIdentifyResult struct { Value *[]IdentifyResult `json:"value,omitempty"` } +// ListLargeFaceList ... +type ListLargeFaceList struct { + autorest.Response `json:"-"` + Value *[]LargeFaceList `json:"value,omitempty"` +} + +// ListLargePersonGroup ... +type ListLargePersonGroup struct { + autorest.Response `json:"-"` + Value *[]LargePersonGroup `json:"value,omitempty"` +} + // ListList ... type ListList struct { autorest.Response `json:"-"` Value *[]List `json:"value,omitempty"` } +// ListPersistedFace ... +type ListPersistedFace struct { + autorest.Response `json:"-"` + Value *[]PersistedFace `json:"value,omitempty"` +} + // ListPerson ... type ListPerson struct { autorest.Response `json:"-"` @@ -505,8 +549,8 @@ type Makeup struct { LipMakeup *bool `json:"lipMakeup,omitempty"` } -// NameAndUserDataContract a combination of user defined name and user specified data for the person, personGroup, -// and faceList +// NameAndUserDataContract a combination of user defined name and user specified data for the person, +// largePersonGroup/personGroup, and largeFaceList/faceList. type NameAndUserDataContract struct { // Name - User defined name, maximum length is 128. Name *string `json:"name,omitempty"` @@ -557,7 +601,7 @@ type Person struct { // PersonGroup person group object. type PersonGroup struct { autorest.Response `json:"-"` - // PersonGroupID - PersonGroupId of the existing person groups. + // PersonGroupID - PersonGroupId of the target person group. PersonGroupID *string `json:"personGroupId,omitempty"` // Name - User defined name, maximum length is 128. Name *string `json:"name,omitempty"` @@ -590,23 +634,25 @@ type SimilarFace struct { // TrainingStatus training status object. type TrainingStatus struct { autorest.Response `json:"-"` - // Status - Training status: notstarted, running, succeeded, failed. If the training process is waiting to perform, the status is notstarted. If the training is ongoing, the status is running. Status succeed means this person group is ready for Face - Identify. Status failed is often caused by no person or no persisted face exist in the person group. Possible values include: 'Nonstarted', 'Running', 'Succeeded', 'Failed' + // 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' Status TrainingStatusType `json:"status,omitempty"` - // Created - A combined UTC date and time string that describes person group created time. + // Created - 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.Time `json:"createdDateTime,omitempty"` - // LastAction - Person group last modify time in the UTC, could be null value when the person group is not successfully trained. + // 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. LastAction *date.Time `json:"lastActionDateTime,omitempty"` + // 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. + LastSuccessfulTraining *date.Time `json:"lastSuccessfulTrainingDateTime,omitempty"` // Message - Show failure message when training failed (omitted when training succeed). Message *string `json:"message,omitempty"` } -// UpdatePersonFaceRequest request to update person face data. -type UpdatePersonFaceRequest struct { +// UpdateFaceRequest request to update face data. +type UpdateFaceRequest struct { // UserData - User-provided data attached to the face. The size limit is 1KB. UserData *string `json:"userData,omitempty"` } -// VerifyFaceToFaceRequest request body for verify operation. +// VerifyFaceToFaceRequest request body for face to face verification. type VerifyFaceToFaceRequest struct { // FaceID1 - FaceId of the first face, comes from Face - Detect FaceID1 *uuid.UUID `json:"faceId1,omitempty"` @@ -614,13 +660,15 @@ type VerifyFaceToFaceRequest struct { FaceID2 *uuid.UUID `json:"faceId2,omitempty"` } -// VerifyFaceToPersonRequest request body for verify operation. +// VerifyFaceToPersonRequest request body for face to person verification. type VerifyFaceToPersonRequest struct { - // FaceID - FaceId the face, comes from Face - Detect + // FaceID - FaceId of the face, comes from Face - Detect FaceID *uuid.UUID `json:"faceId,omitempty"` - // PersonGroupID - Using existing personGroupId and personId for fast loading a specified person. personGroupId is created in Person Groups.Create. + // 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. PersonGroupID *string `json:"personGroupId,omitempty"` - // PersonID - Specify a certain person in a person group. personId is created in Persons.Create. + // 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. + LargePersonGroupID *string `json:"largePersonGroupId,omitempty"` + // 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. PersonID *uuid.UUID `json:"personId,omitempty"` } diff --git a/services/cognitiveservices/v1.0/face/persongroup.go b/services/cognitiveservices/v1.0/face/persongroup.go index 187995bd22d1..63d22d2202eb 100644 --- a/services/cognitiveservices/v1.0/face/persongroup.go +++ b/services/cognitiveservices/v1.0/face/persongroup.go @@ -111,7 +111,7 @@ func (client PersonGroupClient) CreateResponder(resp *http.Response) (result aut return } -// Delete delete an existing person group. Persisted face images of all people in the person group will also be +// Delete delete an existing person group. Persisted face features of all people in the person group will also be // deleted. // Parameters: // personGroupID - id referencing a particular person group. diff --git a/services/cognitiveservices/v1.0/face/persongroupperson.go b/services/cognitiveservices/v1.0/face/persongroupperson.go index 9f4e6430a33c..763f5666c022 100644 --- a/services/cognitiveservices/v1.0/face/persongroupperson.go +++ b/services/cognitiveservices/v1.0/face/persongroupperson.go @@ -37,8 +37,8 @@ func NewPersonGroupPersonClient(endpoint string) PersonGroupPersonClient { return PersonGroupPersonClient{New(endpoint)} } -// AddPersonFaceFromStream add a representative face to a person for identification. The input face is specified as an -// image with a targetFace rectangle. +// AddFaceFromStream add a representative face to a person for identification. The input face is specified as an image +// with a targetFace rectangle. // Parameters: // personGroupID - id referencing a particular person group. // personID - id referencing a particular person. @@ -48,39 +48,39 @@ func NewPersonGroupPersonClient(endpoint string) PersonGroupPersonClient { // "targetFace=left,top,width,height". E.g. "targetFace=10,10,100,100". If there is more than one face in the // image, targetFace is required to specify which face to add. No targetFace means there is only one face // detected in the entire image. -func (client PersonGroupPersonClient) AddPersonFaceFromStream(ctx context.Context, personGroupID string, personID uuid.UUID, imageParameter io.ReadCloser, userData string, targetFace []int32) (result PersistedFace, err error) { +func (client PersonGroupPersonClient) AddFaceFromStream(ctx context.Context, personGroupID string, personID uuid.UUID, imageParameter io.ReadCloser, userData string, targetFace []int32) (result PersistedFace, err error) { if err := validation.Validate([]validation.Validation{ {TargetValue: personGroupID, Constraints: []validation.Constraint{{Target: "personGroupID", Name: validation.MaxLength, Rule: 64, Chain: nil}, {Target: "personGroupID", Name: validation.Pattern, Rule: `^[a-z0-9-_]+$`, Chain: nil}}}, {TargetValue: userData, Constraints: []validation.Constraint{{Target: "userData", Name: validation.MaxLength, Rule: 1024, Chain: nil}}}}); err != nil { - return result, validation.NewError("face.PersonGroupPersonClient", "AddPersonFaceFromStream", err.Error()) + return result, validation.NewError("face.PersonGroupPersonClient", "AddFaceFromStream", err.Error()) } - req, err := client.AddPersonFaceFromStreamPreparer(ctx, personGroupID, personID, imageParameter, userData, targetFace) + req, err := client.AddFaceFromStreamPreparer(ctx, personGroupID, personID, imageParameter, userData, targetFace) if err != nil { - err = autorest.NewErrorWithError(err, "face.PersonGroupPersonClient", "AddPersonFaceFromStream", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "face.PersonGroupPersonClient", "AddFaceFromStream", nil, "Failure preparing request") return } - resp, err := client.AddPersonFaceFromStreamSender(req) + resp, err := client.AddFaceFromStreamSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "face.PersonGroupPersonClient", "AddPersonFaceFromStream", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "face.PersonGroupPersonClient", "AddFaceFromStream", resp, "Failure sending request") return } - result, err = client.AddPersonFaceFromStreamResponder(resp) + result, err = client.AddFaceFromStreamResponder(resp) if err != nil { - err = autorest.NewErrorWithError(err, "face.PersonGroupPersonClient", "AddPersonFaceFromStream", resp, "Failure responding to request") + err = autorest.NewErrorWithError(err, "face.PersonGroupPersonClient", "AddFaceFromStream", resp, "Failure responding to request") } return } -// AddPersonFaceFromStreamPreparer prepares the AddPersonFaceFromStream request. -func (client PersonGroupPersonClient) AddPersonFaceFromStreamPreparer(ctx context.Context, personGroupID string, personID uuid.UUID, imageParameter io.ReadCloser, userData string, targetFace []int32) (*http.Request, error) { +// AddFaceFromStreamPreparer prepares the AddFaceFromStream request. +func (client PersonGroupPersonClient) AddFaceFromStreamPreparer(ctx context.Context, personGroupID string, personID uuid.UUID, imageParameter io.ReadCloser, userData string, targetFace []int32) (*http.Request, error) { urlParameters := map[string]interface{}{ "Endpoint": client.Endpoint, } @@ -102,22 +102,22 @@ func (client PersonGroupPersonClient) AddPersonFaceFromStreamPreparer(ctx contex autorest.AsContentType("application/octet-stream"), autorest.AsPost(), autorest.WithCustomBaseURL("{Endpoint}/face/v1.0", urlParameters), - autorest.WithPathParameters("/persongroups/{personGroupId}/persons/{personId}/persistedFaces", pathParameters), + autorest.WithPathParameters("/persongroups/{personGroupId}/persons/{personId}/persistedfaces", pathParameters), autorest.WithFile(imageParameter), autorest.WithQueryParameters(queryParameters)) return preparer.Prepare((&http.Request{}).WithContext(ctx)) } -// AddPersonFaceFromStreamSender sends the AddPersonFaceFromStream request. The method will close the +// AddFaceFromStreamSender sends the AddFaceFromStream request. The method will close the // http.Response Body if it receives an error. -func (client PersonGroupPersonClient) AddPersonFaceFromStreamSender(req *http.Request) (*http.Response, error) { +func (client PersonGroupPersonClient) AddFaceFromStreamSender(req *http.Request) (*http.Response, error) { return autorest.SendWithSender(client, req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) } -// AddPersonFaceFromStreamResponder handles the response to the AddPersonFaceFromStream request. The method always +// AddFaceFromStreamResponder handles the response to the AddFaceFromStream request. The method always // closes the http.Response Body. -func (client PersonGroupPersonClient) AddPersonFaceFromStreamResponder(resp *http.Response) (result PersistedFace, err error) { +func (client PersonGroupPersonClient) AddFaceFromStreamResponder(resp *http.Response) (result PersistedFace, err error) { err = autorest.Respond( resp, client.ByInspecting(), @@ -128,8 +128,8 @@ func (client PersonGroupPersonClient) AddPersonFaceFromStreamResponder(resp *htt return } -// AddPersonFaceFromURL add a representative face to a person for identification. The input face is specified as an -// image with a targetFace rectangle. +// AddFaceFromURL add a representative face to a person for identification. The input face is specified as an image +// with a targetFace rectangle. // Parameters: // personGroupID - id referencing a particular person group. // personID - id referencing a particular person. @@ -139,7 +139,7 @@ func (client PersonGroupPersonClient) AddPersonFaceFromStreamResponder(resp *htt // "targetFace=left,top,width,height". E.g. "targetFace=10,10,100,100". If there is more than one face in the // image, targetFace is required to specify which face to add. No targetFace means there is only one face // detected in the entire image. -func (client PersonGroupPersonClient) AddPersonFaceFromURL(ctx context.Context, personGroupID string, personID uuid.UUID, imageURL ImageURL, userData string, targetFace []int32) (result PersistedFace, err error) { +func (client PersonGroupPersonClient) AddFaceFromURL(ctx context.Context, personGroupID string, personID uuid.UUID, imageURL ImageURL, userData string, targetFace []int32) (result PersistedFace, err error) { if err := validation.Validate([]validation.Validation{ {TargetValue: personGroupID, Constraints: []validation.Constraint{{Target: "personGroupID", Name: validation.MaxLength, Rule: 64, Chain: nil}, @@ -148,32 +148,32 @@ func (client PersonGroupPersonClient) AddPersonFaceFromURL(ctx context.Context, Constraints: []validation.Constraint{{Target: "userData", Name: validation.MaxLength, Rule: 1024, Chain: nil}}}, {TargetValue: imageURL, Constraints: []validation.Constraint{{Target: "imageURL.URL", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { - return result, validation.NewError("face.PersonGroupPersonClient", "AddPersonFaceFromURL", err.Error()) + return result, validation.NewError("face.PersonGroupPersonClient", "AddFaceFromURL", err.Error()) } - req, err := client.AddPersonFaceFromURLPreparer(ctx, personGroupID, personID, imageURL, userData, targetFace) + req, err := client.AddFaceFromURLPreparer(ctx, personGroupID, personID, imageURL, userData, targetFace) if err != nil { - err = autorest.NewErrorWithError(err, "face.PersonGroupPersonClient", "AddPersonFaceFromURL", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "face.PersonGroupPersonClient", "AddFaceFromURL", nil, "Failure preparing request") return } - resp, err := client.AddPersonFaceFromURLSender(req) + resp, err := client.AddFaceFromURLSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "face.PersonGroupPersonClient", "AddPersonFaceFromURL", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "face.PersonGroupPersonClient", "AddFaceFromURL", resp, "Failure sending request") return } - result, err = client.AddPersonFaceFromURLResponder(resp) + result, err = client.AddFaceFromURLResponder(resp) if err != nil { - err = autorest.NewErrorWithError(err, "face.PersonGroupPersonClient", "AddPersonFaceFromURL", resp, "Failure responding to request") + err = autorest.NewErrorWithError(err, "face.PersonGroupPersonClient", "AddFaceFromURL", resp, "Failure responding to request") } return } -// AddPersonFaceFromURLPreparer prepares the AddPersonFaceFromURL request. -func (client PersonGroupPersonClient) AddPersonFaceFromURLPreparer(ctx context.Context, personGroupID string, personID uuid.UUID, imageURL ImageURL, userData string, targetFace []int32) (*http.Request, error) { +// AddFaceFromURLPreparer prepares the AddFaceFromURL request. +func (client PersonGroupPersonClient) AddFaceFromURLPreparer(ctx context.Context, personGroupID string, personID uuid.UUID, imageURL ImageURL, userData string, targetFace []int32) (*http.Request, error) { urlParameters := map[string]interface{}{ "Endpoint": client.Endpoint, } @@ -195,22 +195,22 @@ func (client PersonGroupPersonClient) AddPersonFaceFromURLPreparer(ctx context.C autorest.AsContentType("application/json; charset=utf-8"), autorest.AsPost(), autorest.WithCustomBaseURL("{Endpoint}/face/v1.0", urlParameters), - autorest.WithPathParameters("/persongroups/{personGroupId}/persons/{personId}/persistedFaces", pathParameters), + autorest.WithPathParameters("/persongroups/{personGroupId}/persons/{personId}/persistedfaces", pathParameters), autorest.WithJSON(imageURL), autorest.WithQueryParameters(queryParameters)) return preparer.Prepare((&http.Request{}).WithContext(ctx)) } -// AddPersonFaceFromURLSender sends the AddPersonFaceFromURL request. The method will close the +// AddFaceFromURLSender sends the AddFaceFromURL request. The method will close the // http.Response Body if it receives an error. -func (client PersonGroupPersonClient) AddPersonFaceFromURLSender(req *http.Request) (*http.Response, error) { +func (client PersonGroupPersonClient) AddFaceFromURLSender(req *http.Request) (*http.Response, error) { return autorest.SendWithSender(client, req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) } -// AddPersonFaceFromURLResponder handles the response to the AddPersonFaceFromURL request. The method always +// AddFaceFromURLResponder handles the response to the AddFaceFromURL request. The method always // closes the http.Response Body. -func (client PersonGroupPersonClient) AddPersonFaceFromURLResponder(resp *http.Response) (result PersistedFace, err error) { +func (client PersonGroupPersonClient) AddFaceFromURLResponder(resp *http.Response) (result PersistedFace, err error) { err = autorest.Respond( resp, client.ByInspecting(), @@ -298,7 +298,8 @@ func (client PersonGroupPersonClient) CreateResponder(resp *http.Response) (resu return } -// Delete delete an existing person from a person group. Persisted face images of the person will also be deleted. +// Delete delete an existing person from a person group. All stored person data, and face features in the person entry +// will be deleted. // Parameters: // personGroupID - id referencing a particular person group. // personID - id referencing a particular person. @@ -368,7 +369,7 @@ func (client PersonGroupPersonClient) DeleteResponder(resp *http.Response) (resu return } -// DeleteFace delete a face from a person. Relative image for the persisted face will also be deleted. +// DeleteFace delete a face from a person. Relative feature for the persisted face will also be deleted. // Parameters: // personGroupID - id referencing a particular person group. // personID - id referencing a particular person. @@ -417,7 +418,7 @@ func (client PersonGroupPersonClient) DeleteFacePreparer(ctx context.Context, pe preparer := autorest.CreatePreparer( autorest.AsDelete(), autorest.WithCustomBaseURL("{Endpoint}/face/v1.0", urlParameters), - autorest.WithPathParameters("/persongroups/{personGroupId}/persons/{personId}/persistedFaces/{persistedFaceId}", pathParameters)) + autorest.WithPathParameters("/persongroups/{personGroupId}/persons/{personId}/persistedfaces/{persistedFaceId}", pathParameters)) return preparer.Prepare((&http.Request{}).WithContext(ctx)) } @@ -561,7 +562,7 @@ func (client PersonGroupPersonClient) GetFacePreparer(ctx context.Context, perso preparer := autorest.CreatePreparer( autorest.AsGet(), autorest.WithCustomBaseURL("{Endpoint}/face/v1.0", urlParameters), - autorest.WithPathParameters("/persongroups/{personGroupId}/persons/{personId}/persistedFaces/{persistedFaceId}", pathParameters)) + autorest.WithPathParameters("/persongroups/{personGroupId}/persons/{personId}/persistedfaces/{persistedFaceId}", pathParameters)) return preparer.Prepare((&http.Request{}).WithContext(ctx)) } @@ -750,7 +751,7 @@ func (client PersonGroupPersonClient) UpdateResponder(resp *http.Response) (resu // personID - id referencing a particular person. // persistedFaceID - id referencing a particular persistedFaceId of an existing face. // body - request body for updating persisted face. -func (client PersonGroupPersonClient) UpdateFace(ctx context.Context, personGroupID string, personID uuid.UUID, persistedFaceID uuid.UUID, body UpdatePersonFaceRequest) (result autorest.Response, err error) { +func (client PersonGroupPersonClient) UpdateFace(ctx context.Context, personGroupID string, personID uuid.UUID, persistedFaceID uuid.UUID, body UpdateFaceRequest) (result autorest.Response, err error) { if err := validation.Validate([]validation.Validation{ {TargetValue: personGroupID, Constraints: []validation.Constraint{{Target: "personGroupID", Name: validation.MaxLength, Rule: 64, Chain: nil}, @@ -780,7 +781,7 @@ func (client PersonGroupPersonClient) UpdateFace(ctx context.Context, personGrou } // UpdateFacePreparer prepares the UpdateFace request. -func (client PersonGroupPersonClient) UpdateFacePreparer(ctx context.Context, personGroupID string, personID uuid.UUID, persistedFaceID uuid.UUID, body UpdatePersonFaceRequest) (*http.Request, error) { +func (client PersonGroupPersonClient) UpdateFacePreparer(ctx context.Context, personGroupID string, personID uuid.UUID, persistedFaceID uuid.UUID, body UpdateFaceRequest) (*http.Request, error) { urlParameters := map[string]interface{}{ "Endpoint": client.Endpoint, } @@ -795,7 +796,7 @@ func (client PersonGroupPersonClient) UpdateFacePreparer(ctx context.Context, pe autorest.AsContentType("application/json; charset=utf-8"), autorest.AsPatch(), autorest.WithCustomBaseURL("{Endpoint}/face/v1.0", urlParameters), - autorest.WithPathParameters("/persongroups/{personGroupId}/persons/{personId}/persistedFaces/{persistedFaceId}", pathParameters), + autorest.WithPathParameters("/persongroups/{personGroupId}/persons/{personId}/persistedfaces/{persistedFaceId}", pathParameters), autorest.WithJSON(body)) return preparer.Prepare((&http.Request{}).WithContext(ctx)) }