vendor: update all dependencies to latest versions

This commit is contained in:
Nick Craig-Wood
2017-09-30 15:27:27 +01:00
parent 911d121bb9
commit b017fcfe9a
3048 changed files with 537055 additions and 189679 deletions
@@ -0,0 +1,48 @@
// Package face implements the Azure ARM Face service API version 1.0.
//
// An API for face detection, verification, and identification.
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 (
"github.com/Azure/go-autorest/autorest"
)
const ()
// ManagementClient is the base client for Face.
type ManagementClient struct {
autorest.Client
SubscriptionKey string
AzureRegion AzureRegions
}
// New creates an instance of the ManagementClient client.
func New(subscriptionKey string, azureRegion AzureRegions) ManagementClient {
return NewWithoutDefaults(subscriptionKey, azureRegion)
}
// NewWithoutDefaults creates an instance of the ManagementClient client.
func NewWithoutDefaults(subscriptionKey string, azureRegion AzureRegions) ManagementClient {
return ManagementClient{
Client: autorest.NewClientWithUserAgent(UserAgent()),
SubscriptionKey: subscriptionKey,
AzureRegion: azureRegion,
}
}
@@ -0,0 +1,483 @@
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 (
"github.com/Azure/go-autorest/autorest"
"github.com/Azure/go-autorest/autorest/azure"
"github.com/Azure/go-autorest/autorest/validation"
"io"
"net/http"
)
// GroupClient is the an API for face detection, verification, and identification.
type GroupClient struct {
ManagementClient
}
// NewGroupClient creates an instance of the GroupClient client.
func NewGroupClient(subscriptionKey string, azureRegion AzureRegions) GroupClient {
return GroupClient{New(subscriptionKey, azureRegion)}
}
// Detect detect human faces in an image and returns face locations, and optionally with faceIds, landmarks, and
// attributes.
//
// imageURL is a JSON document with a URL pointing to the image that is to be analyzed. returnFaceID is a value
// indicating whether the operation should return faceIds of detected faces. returnFaceLandmarks is a value indicating
// whether the operation should return landmarks of the detected faces. returnFaceAttributes is analyze and return the
// one or more specified face attributes in the comma-separated string like "returnFaceAttributes=age,gender".
// Supported face attributes include age, gender, headPose, smile, facialHair, glasses and emotion. Note that each face
// attribute analysis has additional computational and time cost.
func (client GroupClient) Detect(imageURL ImageURL, returnFaceID *bool, returnFaceLandmarks *bool, returnFaceAttributes string) (result ListDetectedFace, err error) {
if err := validation.Validate([]validation.Validation{
{TargetValue: imageURL,
Constraints: []validation.Constraint{{Target: "imageURL.URL", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil {
return result, validation.NewErrorWithValidationError(err, "face.GroupClient", "Detect")
}
req, err := client.DetectPreparer(imageURL, returnFaceID, returnFaceLandmarks, returnFaceAttributes)
if err != nil {
err = autorest.NewErrorWithError(err, "face.GroupClient", "Detect", nil, "Failure preparing request")
return
}
resp, err := client.DetectSender(req)
if err != nil {
result.Response = autorest.Response{Response: resp}
err = autorest.NewErrorWithError(err, "face.GroupClient", "Detect", resp, "Failure sending request")
return
}
result, err = client.DetectResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "face.GroupClient", "Detect", resp, "Failure responding to request")
}
return
}
// DetectPreparer prepares the Detect request.
func (client GroupClient) DetectPreparer(imageURL ImageURL, returnFaceID *bool, returnFaceLandmarks *bool, returnFaceAttributes string) (*http.Request, error) {
urlParameters := map[string]interface{}{
"AzureRegion": client.AzureRegion,
}
queryParameters := map[string]interface{}{}
if returnFaceID != nil {
queryParameters["returnFaceId"] = autorest.Encode("query", *returnFaceID)
}
if returnFaceLandmarks != nil {
queryParameters["returnFaceLandmarks"] = autorest.Encode("query", *returnFaceLandmarks)
}
if len(returnFaceAttributes) > 0 {
queryParameters["returnFaceAttributes"] = autorest.Encode("query", returnFaceAttributes)
}
preparer := autorest.CreatePreparer(
autorest.AsJSON(),
autorest.AsPost(),
autorest.WithCustomBaseURL("https://{AzureRegion}.api.cognitive.microsoft.com/face/v1.0", urlParameters),
autorest.WithPath("/detect"),
autorest.WithJSON(imageURL),
autorest.WithQueryParameters(queryParameters),
autorest.WithHeader("Ocp-Apim-Subscription-Key", client.SubscriptionKey))
return preparer.Prepare(&http.Request{})
}
// DetectSender sends the Detect request. The method will close the
// http.Response Body if it receives an error.
func (client GroupClient) DetectSender(req *http.Request) (*http.Response, error) {
return autorest.SendWithSender(client, req)
}
// DetectResponder handles the response to the Detect request. The method always
// closes the http.Response Body.
func (client GroupClient) DetectResponder(resp *http.Response) (result ListDetectedFace, 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
}
// DetectInStream detect human faces in an image and returns face locations, and optionally with faceIds, landmarks,
// and attributes.
//
// imageParameter is an image stream. imageParameter will be closed upon successful return. Callers should ensure
// closure when receiving an error.returnFaceID is a value indicating whether the operation should return faceIds of
// detected faces. returnFaceLandmarks is a value indicating whether the operation should return landmarks of the
// detected faces. returnFaceAttributes is analyze and return the one or more specified face attributes in the
// comma-separated string like "returnFaceAttributes=age,gender". Supported face attributes include age, gender,
// headPose, smile, facialHair, glasses and emotion. Note that each face attribute analysis has additional
// computational and time cost.
func (client GroupClient) DetectInStream(imageParameter io.ReadCloser, returnFaceID *bool, returnFaceLandmarks *bool, returnFaceAttributes string) (result ListDetectedFace, err error) {
req, err := client.DetectInStreamPreparer(imageParameter, returnFaceID, returnFaceLandmarks, returnFaceAttributes)
if err != nil {
err = autorest.NewErrorWithError(err, "face.GroupClient", "DetectInStream", nil, "Failure preparing request")
return
}
resp, err := client.DetectInStreamSender(req)
if err != nil {
result.Response = autorest.Response{Response: resp}
err = autorest.NewErrorWithError(err, "face.GroupClient", "DetectInStream", resp, "Failure sending request")
return
}
result, err = client.DetectInStreamResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "face.GroupClient", "DetectInStream", resp, "Failure responding to request")
}
return
}
// DetectInStreamPreparer prepares the DetectInStream request.
func (client GroupClient) DetectInStreamPreparer(imageParameter io.ReadCloser, returnFaceID *bool, returnFaceLandmarks *bool, returnFaceAttributes string) (*http.Request, error) {
urlParameters := map[string]interface{}{
"AzureRegion": client.AzureRegion,
}
queryParameters := map[string]interface{}{}
if returnFaceID != nil {
queryParameters["returnFaceId"] = autorest.Encode("query", *returnFaceID)
}
if returnFaceLandmarks != nil {
queryParameters["returnFaceLandmarks"] = autorest.Encode("query", *returnFaceLandmarks)
}
if len(returnFaceAttributes) > 0 {
queryParameters["returnFaceAttributes"] = autorest.Encode("query", returnFaceAttributes)
}
preparer := autorest.CreatePreparer(
autorest.AsPost(),
autorest.WithCustomBaseURL("https://{AzureRegion}.api.cognitive.microsoft.com/face/v1.0", urlParameters),
autorest.WithPath("/detect"),
autorest.WithFile(imageParameter),
autorest.WithQueryParameters(queryParameters),
autorest.WithHeader("Ocp-Apim-Subscription-Key", client.SubscriptionKey))
return preparer.Prepare(&http.Request{})
}
// DetectInStreamSender sends the DetectInStream request. The method will close the
// http.Response Body if it receives an error.
func (client GroupClient) DetectInStreamSender(req *http.Request) (*http.Response, error) {
return autorest.SendWithSender(client, req)
}
// DetectInStreamResponder handles the response to the DetectInStream request. The method always
// closes the http.Response Body.
func (client GroupClient) DetectInStreamResponder(resp *http.Response) (result ListDetectedFace, 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
}
// FindSimilar given query face's faceId, find the similar-looking faces from a faceId array or a faceListId.
//
func (client GroupClient) FindSimilar(body FindSimilarRequest) (result ListSimilarFaceResult, err error) {
if err := validation.Validate([]validation.Validation{
{TargetValue: body,
Constraints: []validation.Constraint{{Target: "body.FaceID", Name: validation.Null, Rule: true,
Chain: []validation.Constraint{{Target: "body.FaceID", Name: validation.MaxLength, Rule: 64, Chain: nil}}},
{Target: "body.FaceListID", Name: validation.Null, Rule: false,
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.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,
Chain: []validation.Constraint{{Target: "body.MaxNumOfCandidatesReturned", Name: validation.InclusiveMaximum, Rule: 1000, Chain: nil},
{Target: "body.MaxNumOfCandidatesReturned", Name: validation.InclusiveMinimum, Rule: 1, Chain: nil},
}}}}}); err != nil {
return result, validation.NewErrorWithValidationError(err, "face.GroupClient", "FindSimilar")
}
req, err := client.FindSimilarPreparer(body)
if err != nil {
err = autorest.NewErrorWithError(err, "face.GroupClient", "FindSimilar", nil, "Failure preparing request")
return
}
resp, err := client.FindSimilarSender(req)
if err != nil {
result.Response = autorest.Response{Response: resp}
err = autorest.NewErrorWithError(err, "face.GroupClient", "FindSimilar", resp, "Failure sending request")
return
}
result, err = client.FindSimilarResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "face.GroupClient", "FindSimilar", resp, "Failure responding to request")
}
return
}
// FindSimilarPreparer prepares the FindSimilar request.
func (client GroupClient) FindSimilarPreparer(body FindSimilarRequest) (*http.Request, error) {
urlParameters := map[string]interface{}{
"AzureRegion": client.AzureRegion,
}
preparer := autorest.CreatePreparer(
autorest.AsJSON(),
autorest.AsPost(),
autorest.WithCustomBaseURL("https://{AzureRegion}.api.cognitive.microsoft.com/face/v1.0", urlParameters),
autorest.WithPath("/findsimilars"),
autorest.WithJSON(body),
autorest.WithHeader("Ocp-Apim-Subscription-Key", client.SubscriptionKey))
return preparer.Prepare(&http.Request{})
}
// FindSimilarSender sends the FindSimilar request. The method will close the
// http.Response Body if it receives an error.
func (client GroupClient) FindSimilarSender(req *http.Request) (*http.Response, error) {
return autorest.SendWithSender(client, req)
}
// FindSimilarResponder handles the response to the FindSimilar request. The method always
// closes the http.Response Body.
func (client GroupClient) FindSimilarResponder(resp *http.Response) (result ListSimilarFaceResult, 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
}
// Group divide candidate faces into groups based on face similarity.
//
func (client GroupClient) Group(body GroupRequest) (result GroupResponse, err error) {
if err := validation.Validate([]validation.Validation{
{TargetValue: body,
Constraints: []validation.Constraint{{Target: "body.FaceIds", Name: validation.Null, Rule: true,
Chain: []validation.Constraint{{Target: "body.FaceIds", Name: validation.MaxItems, Rule: 1000, Chain: nil}}}}}}); err != nil {
return result, validation.NewErrorWithValidationError(err, "face.GroupClient", "Group")
}
req, err := client.GroupPreparer(body)
if err != nil {
err = autorest.NewErrorWithError(err, "face.GroupClient", "Group", nil, "Failure preparing request")
return
}
resp, err := client.GroupSender(req)
if err != nil {
result.Response = autorest.Response{Response: resp}
err = autorest.NewErrorWithError(err, "face.GroupClient", "Group", resp, "Failure sending request")
return
}
result, err = client.GroupResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "face.GroupClient", "Group", resp, "Failure responding to request")
}
return
}
// GroupPreparer prepares the Group request.
func (client GroupClient) GroupPreparer(body GroupRequest) (*http.Request, error) {
urlParameters := map[string]interface{}{
"AzureRegion": client.AzureRegion,
}
preparer := autorest.CreatePreparer(
autorest.AsJSON(),
autorest.AsPost(),
autorest.WithCustomBaseURL("https://{AzureRegion}.api.cognitive.microsoft.com/face/v1.0", urlParameters),
autorest.WithPath("/group"),
autorest.WithJSON(body),
autorest.WithHeader("Ocp-Apim-Subscription-Key", client.SubscriptionKey))
return preparer.Prepare(&http.Request{})
}
// GroupSender sends the Group request. The method will close the
// http.Response Body if it receives an error.
func (client GroupClient) GroupSender(req *http.Request) (*http.Response, error) {
return autorest.SendWithSender(client, req)
}
// GroupResponder handles the response to the Group request. The method always
// closes the http.Response Body.
func (client GroupClient) GroupResponder(resp *http.Response) (result GroupResponse, err error) {
err = autorest.Respond(
resp,
client.ByInspecting(),
azure.WithErrorUnlessStatusCode(http.StatusOK),
autorest.ByUnmarshallingJSON(&result),
autorest.ByClosing())
result.Response = autorest.Response{Response: resp}
return
}
// Identify identify unknown faces from a person group.
//
func (client GroupClient) Identify(body IdentifyRequest) (result ListIdentifyResultItem, err error) {
if err := validation.Validate([]validation.Validation{
{TargetValue: body,
Constraints: []validation.Constraint{{Target: "body.PersonGroupID", Name: validation.Null, Rule: true, Chain: nil},
{Target: "body.FaceIds", Name: validation.Null, Rule: true,
Chain: []validation.Constraint{{Target: "body.FaceIds", Name: validation.MaxItems, Rule: 1000, Chain: nil}}},
{Target: "body.MaxNumOfCandidatesReturned", Name: validation.Null, Rule: false,
Chain: []validation.Constraint{{Target: "body.MaxNumOfCandidatesReturned", Name: validation.InclusiveMaximum, Rule: 1000, Chain: nil},
{Target: "body.MaxNumOfCandidatesReturned", Name: validation.InclusiveMinimum, Rule: 1, Chain: nil},
}},
{Target: "body.ConfidenceThreshold", Name: validation.Null, Rule: false,
Chain: []validation.Constraint{{Target: "body.ConfidenceThreshold", Name: validation.InclusiveMaximum, Rule: 1, Chain: nil},
{Target: "body.ConfidenceThreshold", Name: validation.InclusiveMinimum, Rule: 0, Chain: nil},
}}}}}); err != nil {
return result, validation.NewErrorWithValidationError(err, "face.GroupClient", "Identify")
}
req, err := client.IdentifyPreparer(body)
if err != nil {
err = autorest.NewErrorWithError(err, "face.GroupClient", "Identify", nil, "Failure preparing request")
return
}
resp, err := client.IdentifySender(req)
if err != nil {
result.Response = autorest.Response{Response: resp}
err = autorest.NewErrorWithError(err, "face.GroupClient", "Identify", resp, "Failure sending request")
return
}
result, err = client.IdentifyResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "face.GroupClient", "Identify", resp, "Failure responding to request")
}
return
}
// IdentifyPreparer prepares the Identify request.
func (client GroupClient) IdentifyPreparer(body IdentifyRequest) (*http.Request, error) {
urlParameters := map[string]interface{}{
"AzureRegion": client.AzureRegion,
}
preparer := autorest.CreatePreparer(
autorest.AsJSON(),
autorest.AsPost(),
autorest.WithCustomBaseURL("https://{AzureRegion}.api.cognitive.microsoft.com/face/v1.0", urlParameters),
autorest.WithPath("/identify"),
autorest.WithJSON(body),
autorest.WithHeader("Ocp-Apim-Subscription-Key", client.SubscriptionKey))
return preparer.Prepare(&http.Request{})
}
// IdentifySender sends the Identify request. The method will close the
// http.Response Body if it receives an error.
func (client GroupClient) IdentifySender(req *http.Request) (*http.Response, error) {
return autorest.SendWithSender(client, req)
}
// IdentifyResponder handles the response to the Identify request. The method always
// closes the http.Response Body.
func (client GroupClient) IdentifyResponder(resp *http.Response) (result ListIdentifyResultItem, 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
}
// Verify verify whether two faces belong to a same person or whether one face belongs to a person.
//
func (client GroupClient) Verify(body VerifyRequest) (result VerifyResult, err error) {
if err := validation.Validate([]validation.Validation{
{TargetValue: body,
Constraints: []validation.Constraint{{Target: "body.FaceID", Name: validation.Null, Rule: true,
Chain: []validation.Constraint{{Target: "body.FaceID", Name: validation.MaxLength, Rule: 64, Chain: nil}}},
{Target: "body.PersonID", Name: validation.Null, Rule: true, Chain: nil},
{Target: "body.PersonGroupID", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil {
return result, validation.NewErrorWithValidationError(err, "face.GroupClient", "Verify")
}
req, err := client.VerifyPreparer(body)
if err != nil {
err = autorest.NewErrorWithError(err, "face.GroupClient", "Verify", nil, "Failure preparing request")
return
}
resp, err := client.VerifySender(req)
if err != nil {
result.Response = autorest.Response{Response: resp}
err = autorest.NewErrorWithError(err, "face.GroupClient", "Verify", resp, "Failure sending request")
return
}
result, err = client.VerifyResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "face.GroupClient", "Verify", resp, "Failure responding to request")
}
return
}
// VerifyPreparer prepares the Verify request.
func (client GroupClient) VerifyPreparer(body VerifyRequest) (*http.Request, error) {
urlParameters := map[string]interface{}{
"AzureRegion": client.AzureRegion,
}
preparer := autorest.CreatePreparer(
autorest.AsJSON(),
autorest.AsPost(),
autorest.WithCustomBaseURL("https://{AzureRegion}.api.cognitive.microsoft.com/face/v1.0", urlParameters),
autorest.WithPath("/verify"),
autorest.WithJSON(body),
autorest.WithHeader("Ocp-Apim-Subscription-Key", client.SubscriptionKey))
return preparer.Prepare(&http.Request{})
}
// VerifySender sends the Verify request. The method will close the
// http.Response Body if it receives an error.
func (client GroupClient) VerifySender(req *http.Request) (*http.Response, error) {
return autorest.SendWithSender(client, req)
}
// VerifyResponder handles the response to the Verify request. The method always
// closes the http.Response Body.
func (client GroupClient) VerifyResponder(resp *http.Response) (result VerifyResult, err error) {
err = autorest.Respond(
resp,
client.ByInspecting(),
azure.WithErrorUnlessStatusCode(http.StatusOK),
autorest.ByUnmarshallingJSON(&result),
autorest.ByClosing())
result.Response = autorest.Response{Response: resp}
return
}
@@ -0,0 +1,608 @@
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 (
"github.com/Azure/go-autorest/autorest"
"github.com/Azure/go-autorest/autorest/azure"
"github.com/Azure/go-autorest/autorest/validation"
"net/http"
)
// ListGroupClient is the an API for face detection, verification, and identification.
type ListGroupClient struct {
ManagementClient
}
// NewListGroupClient creates an instance of the ListGroupClient client.
func NewListGroupClient(subscriptionKey string, azureRegion AzureRegions) ListGroupClient {
return ListGroupClient{New(subscriptionKey, azureRegion)}
}
// AddFace add a face to a 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.
//
// faceListID is id referencing a Face List. userData is user-specified data about the face list for any purpose. The
// maximum length is 1KB. targetFace is a face rectangle to specify the target face to be added into the face list, 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 ListGroupClient) AddFace(faceListID string, userData string, targetFace string) (result autorest.Response, err error) {
if err := validation.Validate([]validation.Validation{
{TargetValue: faceListID,
Constraints: []validation.Constraint{{Target: "faceListID", Name: validation.MaxLength, Rule: 64, Chain: nil},
{Target: "faceListID", Name: validation.Pattern, Rule: `^[a-z0-9-_]+$`, Chain: nil}}}}); err != nil {
return result, validation.NewErrorWithValidationError(err, "face.ListGroupClient", "AddFace")
}
req, err := client.AddFacePreparer(faceListID, userData, targetFace)
if err != nil {
err = autorest.NewErrorWithError(err, "face.ListGroupClient", "AddFace", nil, "Failure preparing request")
return
}
resp, err := client.AddFaceSender(req)
if err != nil {
result.Response = resp
err = autorest.NewErrorWithError(err, "face.ListGroupClient", "AddFace", resp, "Failure sending request")
return
}
result, err = client.AddFaceResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "face.ListGroupClient", "AddFace", resp, "Failure responding to request")
}
return
}
// AddFacePreparer prepares the AddFace request.
func (client ListGroupClient) AddFacePreparer(faceListID string, userData string, targetFace string) (*http.Request, error) {
urlParameters := map[string]interface{}{
"AzureRegion": client.AzureRegion,
}
pathParameters := map[string]interface{}{
"faceListId": autorest.Encode("path", faceListID),
}
queryParameters := map[string]interface{}{}
if len(userData) > 0 {
queryParameters["userData"] = autorest.Encode("query", userData)
}
if len(targetFace) > 0 {
queryParameters["targetFace"] = autorest.Encode("query", targetFace)
}
preparer := autorest.CreatePreparer(
autorest.AsPost(),
autorest.WithCustomBaseURL("https://{AzureRegion}.api.cognitive.microsoft.com/face/v1.0", urlParameters),
autorest.WithPathParameters("/facelists/{faceListId}/persistedFaces", pathParameters),
autorest.WithQueryParameters(queryParameters),
autorest.WithHeader("Ocp-Apim-Subscription-Key", client.SubscriptionKey))
return preparer.Prepare(&http.Request{})
}
// AddFaceSender sends the AddFace request. The method will close the
// http.Response Body if it receives an error.
func (client ListGroupClient) AddFaceSender(req *http.Request) (*http.Response, error) {
return autorest.SendWithSender(client, req)
}
// AddFaceResponder handles the response to the AddFace request. The method always
// closes the http.Response Body.
func (client ListGroupClient) AddFaceResponder(resp *http.Response) (result autorest.Response, err error) {
err = autorest.Respond(
resp,
client.ByInspecting(),
azure.WithErrorUnlessStatusCode(http.StatusOK),
autorest.ByClosing())
result.Response = resp
return
}
// AddFaceFromStream add a face to a 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.
//
// faceListID is id referencing a Face List. userData is user-specified data about the face list for any purpose. The
// maximum length is 1KB. targetFace is a face rectangle to specify the target face to be added into the face list, 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 ListGroupClient) AddFaceFromStream(faceListID string, userData string, targetFace string) (result autorest.Response, err error) {
if err := validation.Validate([]validation.Validation{
{TargetValue: faceListID,
Constraints: []validation.Constraint{{Target: "faceListID", Name: validation.MaxLength, Rule: 64, Chain: nil},
{Target: "faceListID", Name: validation.Pattern, Rule: `^[a-z0-9-_]+$`, Chain: nil}}}}); err != nil {
return result, validation.NewErrorWithValidationError(err, "face.ListGroupClient", "AddFaceFromStream")
}
req, err := client.AddFaceFromStreamPreparer(faceListID, userData, targetFace)
if err != nil {
err = autorest.NewErrorWithError(err, "face.ListGroupClient", "AddFaceFromStream", nil, "Failure preparing request")
return
}
resp, err := client.AddFaceFromStreamSender(req)
if err != nil {
result.Response = resp
err = autorest.NewErrorWithError(err, "face.ListGroupClient", "AddFaceFromStream", resp, "Failure sending request")
return
}
result, err = client.AddFaceFromStreamResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "face.ListGroupClient", "AddFaceFromStream", resp, "Failure responding to request")
}
return
}
// AddFaceFromStreamPreparer prepares the AddFaceFromStream request.
func (client ListGroupClient) AddFaceFromStreamPreparer(faceListID string, userData string, targetFace string) (*http.Request, error) {
urlParameters := map[string]interface{}{
"AzureRegion": client.AzureRegion,
}
pathParameters := map[string]interface{}{
"faceListId": autorest.Encode("path", faceListID),
}
queryParameters := map[string]interface{}{}
if len(userData) > 0 {
queryParameters["userData"] = autorest.Encode("query", userData)
}
if len(targetFace) > 0 {
queryParameters["targetFace"] = autorest.Encode("query", targetFace)
}
preparer := autorest.CreatePreparer(
autorest.AsPost(),
autorest.WithCustomBaseURL("https://{AzureRegion}.api.cognitive.microsoft.com/face/v1.0", urlParameters),
autorest.WithPathParameters("/facelists/{faceListId}/persistedFaces", pathParameters),
autorest.WithQueryParameters(queryParameters),
autorest.WithHeader("Ocp-Apim-Subscription-Key", client.SubscriptionKey))
return preparer.Prepare(&http.Request{})
}
// AddFaceFromStreamSender sends the AddFaceFromStream request. The method will close the
// http.Response Body if it receives an error.
func (client ListGroupClient) AddFaceFromStreamSender(req *http.Request) (*http.Response, error) {
return autorest.SendWithSender(client, req)
}
// AddFaceFromStreamResponder handles the response to the AddFaceFromStream request. The method always
// closes the http.Response Body.
func (client ListGroupClient) AddFaceFromStreamResponder(resp *http.Response) (result autorest.Response, err error) {
err = autorest.Respond(
resp,
client.ByInspecting(),
azure.WithErrorUnlessStatusCode(http.StatusOK),
autorest.ByClosing())
result.Response = resp
return
}
// Create create an empty face list. Up to 64 face lists are allowed to exist in one subscription.
//
// faceListID is id referencing a particular face list.
func (client ListGroupClient) Create(faceListID string, body CreateFaceListRequest) (result autorest.Response, err error) {
if err := validation.Validate([]validation.Validation{
{TargetValue: faceListID,
Constraints: []validation.Constraint{{Target: "faceListID", Name: validation.MaxLength, Rule: 64, Chain: nil},
{Target: "faceListID", 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.NewErrorWithValidationError(err, "face.ListGroupClient", "Create")
}
req, err := client.CreatePreparer(faceListID, body)
if err != nil {
err = autorest.NewErrorWithError(err, "face.ListGroupClient", "Create", nil, "Failure preparing request")
return
}
resp, err := client.CreateSender(req)
if err != nil {
result.Response = resp
err = autorest.NewErrorWithError(err, "face.ListGroupClient", "Create", resp, "Failure sending request")
return
}
result, err = client.CreateResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "face.ListGroupClient", "Create", resp, "Failure responding to request")
}
return
}
// CreatePreparer prepares the Create request.
func (client ListGroupClient) CreatePreparer(faceListID string, body CreateFaceListRequest) (*http.Request, error) {
urlParameters := map[string]interface{}{
"AzureRegion": client.AzureRegion,
}
pathParameters := map[string]interface{}{
"faceListId": autorest.Encode("path", faceListID),
}
preparer := autorest.CreatePreparer(
autorest.AsJSON(),
autorest.AsPut(),
autorest.WithCustomBaseURL("https://{AzureRegion}.api.cognitive.microsoft.com/face/v1.0", urlParameters),
autorest.WithPathParameters("/facelists/{faceListId}", pathParameters),
autorest.WithJSON(body),
autorest.WithHeader("Ocp-Apim-Subscription-Key", client.SubscriptionKey))
return preparer.Prepare(&http.Request{})
}
// CreateSender sends the Create request. The method will close the
// http.Response Body if it receives an error.
func (client ListGroupClient) CreateSender(req *http.Request) (*http.Response, error) {
return autorest.SendWithSender(client, req)
}
// CreateResponder handles the response to the Create request. The method always
// closes the http.Response Body.
func (client ListGroupClient) 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 face list according to faceListId. Persisted face images in the face list will also be
// deleted.
//
// faceListID is id referencing a Face List.
func (client ListGroupClient) Delete(faceListID string) (result autorest.Response, err error) {
if err := validation.Validate([]validation.Validation{
{TargetValue: faceListID,
Constraints: []validation.Constraint{{Target: "faceListID", Name: validation.MaxLength, Rule: 64, Chain: nil},
{Target: "faceListID", Name: validation.Pattern, Rule: `^[a-z0-9-_]+$`, Chain: nil}}}}); err != nil {
return result, validation.NewErrorWithValidationError(err, "face.ListGroupClient", "Delete")
}
req, err := client.DeletePreparer(faceListID)
if err != nil {
err = autorest.NewErrorWithError(err, "face.ListGroupClient", "Delete", nil, "Failure preparing request")
return
}
resp, err := client.DeleteSender(req)
if err != nil {
result.Response = resp
err = autorest.NewErrorWithError(err, "face.ListGroupClient", "Delete", resp, "Failure sending request")
return
}
result, err = client.DeleteResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "face.ListGroupClient", "Delete", resp, "Failure responding to request")
}
return
}
// DeletePreparer prepares the Delete request.
func (client ListGroupClient) DeletePreparer(faceListID string) (*http.Request, error) {
urlParameters := map[string]interface{}{
"AzureRegion": client.AzureRegion,
}
pathParameters := map[string]interface{}{
"faceListId": autorest.Encode("path", faceListID),
}
preparer := autorest.CreatePreparer(
autorest.AsDelete(),
autorest.WithCustomBaseURL("https://{AzureRegion}.api.cognitive.microsoft.com/face/v1.0", urlParameters),
autorest.WithPathParameters("/facelists/{faceListId}", pathParameters),
autorest.WithHeader("Ocp-Apim-Subscription-Key", client.SubscriptionKey))
return preparer.Prepare(&http.Request{})
}
// DeleteSender sends the Delete request. The method will close the
// http.Response Body if it receives an error.
func (client ListGroupClient) DeleteSender(req *http.Request) (*http.Response, error) {
return autorest.SendWithSender(client, req)
}
// DeleteResponder handles the response to the Delete request. The method always
// closes the http.Response Body.
func (client ListGroupClient) 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 face list (given by a persisitedFaceId and a faceListId). Persisted image
// related to the face will also be deleted.
//
// faceListID is faceListId of an existing face list. persistedFaceID is persistedFaceId of an existing face.
func (client ListGroupClient) DeleteFace(faceListID string, persistedFaceID string) (result autorest.Response, err error) {
if err := validation.Validate([]validation.Validation{
{TargetValue: faceListID,
Constraints: []validation.Constraint{{Target: "faceListID", Name: validation.MaxLength, Rule: 64, Chain: nil},
{Target: "faceListID", Name: validation.Pattern, Rule: `^[a-z0-9-_]+$`, Chain: nil}}}}); err != nil {
return result, validation.NewErrorWithValidationError(err, "face.ListGroupClient", "DeleteFace")
}
req, err := client.DeleteFacePreparer(faceListID, persistedFaceID)
if err != nil {
err = autorest.NewErrorWithError(err, "face.ListGroupClient", "DeleteFace", nil, "Failure preparing request")
return
}
resp, err := client.DeleteFaceSender(req)
if err != nil {
result.Response = resp
err = autorest.NewErrorWithError(err, "face.ListGroupClient", "DeleteFace", resp, "Failure sending request")
return
}
result, err = client.DeleteFaceResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "face.ListGroupClient", "DeleteFace", resp, "Failure responding to request")
}
return
}
// DeleteFacePreparer prepares the DeleteFace request.
func (client ListGroupClient) DeleteFacePreparer(faceListID string, persistedFaceID string) (*http.Request, error) {
urlParameters := map[string]interface{}{
"AzureRegion": client.AzureRegion,
}
pathParameters := map[string]interface{}{
"faceListId": autorest.Encode("path", faceListID),
"persistedFaceId": autorest.Encode("path", persistedFaceID),
}
preparer := autorest.CreatePreparer(
autorest.AsDelete(),
autorest.WithCustomBaseURL("https://{AzureRegion}.api.cognitive.microsoft.com/face/v1.0", urlParameters),
autorest.WithPathParameters("/facelists/{faceListId}/persistedFaces/{persistedFaceId}", pathParameters),
autorest.WithHeader("Ocp-Apim-Subscription-Key", client.SubscriptionKey))
return preparer.Prepare(&http.Request{})
}
// DeleteFaceSender sends the DeleteFace request. The method will close the
// http.Response Body if it receives an error.
func (client ListGroupClient) DeleteFaceSender(req *http.Request) (*http.Response, error) {
return autorest.SendWithSender(client, req)
}
// DeleteFaceResponder handles the response to the DeleteFace request. The method always
// closes the http.Response Body.
func (client ListGroupClient) 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 face list's information.
//
// faceListID is id referencing a Face List.
func (client ListGroupClient) Get(faceListID string) (result GetFaceListResult, err error) {
if err := validation.Validate([]validation.Validation{
{TargetValue: faceListID,
Constraints: []validation.Constraint{{Target: "faceListID", Name: validation.MaxLength, Rule: 64, Chain: nil},
{Target: "faceListID", Name: validation.Pattern, Rule: `^[a-z0-9-_]+$`, Chain: nil}}}}); err != nil {
return result, validation.NewErrorWithValidationError(err, "face.ListGroupClient", "Get")
}
req, err := client.GetPreparer(faceListID)
if err != nil {
err = autorest.NewErrorWithError(err, "face.ListGroupClient", "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.ListGroupClient", "Get", resp, "Failure sending request")
return
}
result, err = client.GetResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "face.ListGroupClient", "Get", resp, "Failure responding to request")
}
return
}
// GetPreparer prepares the Get request.
func (client ListGroupClient) GetPreparer(faceListID string) (*http.Request, error) {
urlParameters := map[string]interface{}{
"AzureRegion": client.AzureRegion,
}
pathParameters := map[string]interface{}{
"faceListId": autorest.Encode("path", faceListID),
}
preparer := autorest.CreatePreparer(
autorest.AsGet(),
autorest.WithCustomBaseURL("https://{AzureRegion}.api.cognitive.microsoft.com/face/v1.0", urlParameters),
autorest.WithPathParameters("/facelists/{faceListId}", pathParameters),
autorest.WithHeader("Ocp-Apim-Subscription-Key", client.SubscriptionKey))
return preparer.Prepare(&http.Request{})
}
// GetSender sends the Get request. The method will close the
// http.Response Body if it receives an error.
func (client ListGroupClient) GetSender(req *http.Request) (*http.Response, error) {
return autorest.SendWithSender(client, req)
}
// GetResponder handles the response to the Get request. The method always
// closes the http.Response Body.
func (client ListGroupClient) GetResponder(resp *http.Response) (result GetFaceListResult, 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 face lists. Only faceListId, name and userData will be returned.
func (client ListGroupClient) List() (result ListGetFaceListResult, err error) {
req, err := client.ListPreparer()
if err != nil {
err = autorest.NewErrorWithError(err, "face.ListGroupClient", "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.ListGroupClient", "List", resp, "Failure sending request")
return
}
result, err = client.ListResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "face.ListGroupClient", "List", resp, "Failure responding to request")
}
return
}
// ListPreparer prepares the List request.
func (client ListGroupClient) ListPreparer() (*http.Request, error) {
urlParameters := map[string]interface{}{
"AzureRegion": client.AzureRegion,
}
preparer := autorest.CreatePreparer(
autorest.AsGet(),
autorest.WithCustomBaseURL("https://{AzureRegion}.api.cognitive.microsoft.com/face/v1.0", urlParameters),
autorest.WithPath("/facelists"),
autorest.WithHeader("Ocp-Apim-Subscription-Key", client.SubscriptionKey))
return preparer.Prepare(&http.Request{})
}
// ListSender sends the List request. The method will close the
// http.Response Body if it receives an error.
func (client ListGroupClient) ListSender(req *http.Request) (*http.Response, error) {
return autorest.SendWithSender(client, req)
}
// ListResponder handles the response to the List request. The method always
// closes the http.Response Body.
func (client ListGroupClient) ListResponder(resp *http.Response) (result ListGetFaceListResult, 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 information of a face list.
//
// faceListID is id referencing a Face List.
func (client ListGroupClient) Update(faceListID string, body CreateFaceListRequest) (result autorest.Response, err error) {
if err := validation.Validate([]validation.Validation{
{TargetValue: faceListID,
Constraints: []validation.Constraint{{Target: "faceListID", Name: validation.MaxLength, Rule: 64, Chain: nil},
{Target: "faceListID", Name: validation.Pattern, Rule: `^[a-z0-9-_]+$`, Chain: nil}}}}); err != nil {
return result, validation.NewErrorWithValidationError(err, "face.ListGroupClient", "Update")
}
req, err := client.UpdatePreparer(faceListID, body)
if err != nil {
err = autorest.NewErrorWithError(err, "face.ListGroupClient", "Update", nil, "Failure preparing request")
return
}
resp, err := client.UpdateSender(req)
if err != nil {
result.Response = resp
err = autorest.NewErrorWithError(err, "face.ListGroupClient", "Update", resp, "Failure sending request")
return
}
result, err = client.UpdateResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "face.ListGroupClient", "Update", resp, "Failure responding to request")
}
return
}
// UpdatePreparer prepares the Update request.
func (client ListGroupClient) UpdatePreparer(faceListID string, body CreateFaceListRequest) (*http.Request, error) {
urlParameters := map[string]interface{}{
"AzureRegion": client.AzureRegion,
}
pathParameters := map[string]interface{}{
"faceListId": autorest.Encode("path", faceListID),
}
preparer := autorest.CreatePreparer(
autorest.AsJSON(),
autorest.AsPatch(),
autorest.WithCustomBaseURL("https://{AzureRegion}.api.cognitive.microsoft.com/face/v1.0", urlParameters),
autorest.WithPathParameters("/facelists/{faceListId}", pathParameters),
autorest.WithJSON(body),
autorest.WithHeader("Ocp-Apim-Subscription-Key", client.SubscriptionKey))
return preparer.Prepare(&http.Request{})
}
// UpdateSender sends the Update request. The method will close the
// http.Response Body if it receives an error.
func (client ListGroupClient) UpdateSender(req *http.Request) (*http.Response, error) {
return autorest.SendWithSender(client, req)
}
// UpdateResponder handles the response to the Update request. The method always
// closes the http.Response Body.
func (client ListGroupClient) 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
}
@@ -0,0 +1,360 @@
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 (
"github.com/Azure/go-autorest/autorest"
"github.com/Azure/go-autorest/autorest/date"
)
// AzureRegions enumerates the values for azure regions.
type AzureRegions string
const (
// Eastus2 specifies the eastus 2 state for azure regions.
Eastus2 AzureRegions = "eastus2"
// Southeastasia specifies the southeastasia state for azure regions.
Southeastasia AzureRegions = "southeastasia"
// Westcentralus specifies the westcentralus state for azure regions.
Westcentralus AzureRegions = "westcentralus"
// Westeurope specifies the westeurope state for azure regions.
Westeurope AzureRegions = "westeurope"
// Westus specifies the westus state for azure regions.
Westus AzureRegions = "westus"
)
// Gender enumerates the values for gender.
type Gender string
const (
// Female specifies the female state for gender.
Female Gender = "female"
// Male specifies the male state for gender.
Male Gender = "male"
)
// Glasses enumerates the values for glasses.
type Glasses string
const (
// NoGlasses specifies the no glasses state for glasses.
NoGlasses Glasses = "noGlasses"
// ReadingGlasses specifies the reading glasses state for glasses.
ReadingGlasses Glasses = "readingGlasses"
// Sunglasses specifies the sunglasses state for glasses.
Sunglasses Glasses = "sunglasses"
// SwimmingGoggles specifies the swimming goggles state for glasses.
SwimmingGoggles Glasses = "swimmingGoggles"
)
// Mode enumerates the values for mode.
type Mode string
const (
// MatchFace specifies the match face state for mode.
MatchFace Mode = "matchFace"
// MatchPerson specifies the match person state for mode.
MatchPerson Mode = "matchPerson"
)
// Status enumerates the values for status.
type Status string
const (
// Failed specifies the failed state for status.
Failed Status = "failed"
// Nonstarted specifies the nonstarted state for status.
Nonstarted Status = "nonstarted"
// Running specifies the running state for status.
Running Status = "running"
// Succeeded specifies the succeeded state for status.
Succeeded Status = "succeeded"
)
// APIError is error information returned by the API
type APIError struct {
Error *Error `json:"error,omitempty"`
}
// Attributes is face Attributes
type Attributes struct {
Age *float64 `json:"age,omitempty"`
Gender Gender `json:"gender,omitempty"`
Smile *float64 `json:"smile,omitempty"`
Glasses Glasses `json:"glasses,omitempty"`
FacialHair *FacialHairProperties `json:"facialHair,omitempty"`
HeadPose *HeadPoseProperties `json:"headPose,omitempty"`
Emotion *EmotionProperties `json:"emotion,omitempty"`
}
// CreateFaceListRequest is request to create a face list.
type CreateFaceListRequest struct {
Name *string `json:"name,omitempty"`
UserData *string `json:"userData,omitempty"`
}
// CreatePersonGroupRequest is request to create a person group.
type CreatePersonGroupRequest struct {
Name *string `json:"name,omitempty"`
UserData *string `json:"userData,omitempty"`
}
// CreatePersonRequest is request to create a person object.
type CreatePersonRequest struct {
Name *string `json:"name,omitempty"`
UserData *string `json:"userData,omitempty"`
}
// CreatePersonResult is result of creating person.
type CreatePersonResult struct {
autorest.Response `json:"-"`
PersonID *string `json:"personId,omitempty"`
}
// DetectedFace is detected Face object.
type DetectedFace struct {
FaceID *string `json:"faceId,omitempty"`
FaceRectangle *Rectangle `json:"faceRectangle,omitempty"`
FaceLandmarks *Landmarks `json:"faceLandmarks,omitempty"`
}
// EmotionProperties is properties describing facial emotion.
type EmotionProperties struct {
Anger *float64 `json:"anger,omitempty"`
Contempt *float64 `json:"contempt,omitempty"`
Disgust *float64 `json:"disgust,omitempty"`
Fear *float64 `json:"fear,omitempty"`
Happiness *float64 `json:"happiness,omitempty"`
Neutral *float64 `json:"neutral,omitempty"`
Sadness *float64 `json:"sadness,omitempty"`
Surprise *float64 `json:"surprise,omitempty"`
}
// Error is error body.
type Error struct {
Code *string `json:"code,omitempty"`
Message *string `json:"message,omitempty"`
}
// FacialHairProperties is properties describing facial hair attributes.
type FacialHairProperties struct {
Mustache *float64 `json:"mustache,omitempty"`
Beard *float64 `json:"beard,omitempty"`
Sideburns *float64 `json:"sideburns,omitempty"`
}
// FindSimilarRequest is request body for find similar operation.
type FindSimilarRequest struct {
FaceID *string `json:"faceId,omitempty"`
FaceListID *string `json:"faceListId,omitempty"`
FaceIds *[]string `json:"faceIds,omitempty"`
MaxNumOfCandidatesReturned *int32 `json:"maxNumOfCandidatesReturned,omitempty"`
Mode Mode `json:"mode,omitempty"`
}
// GetFaceListResult is result of the GetFaceList operation.
type GetFaceListResult struct {
autorest.Response `json:"-"`
FaceListID *string `json:"faceListId,omitempty"`
Name *string `json:"name,omitempty"`
UserData *string `json:"userData,omitempty"`
}
// GroupRequest is request body for group request.
type GroupRequest struct {
FaceIds *[]string `json:"faceIds,omitempty"`
}
// GroupResponse is an array of face groups based on face similarity.
type GroupResponse struct {
autorest.Response `json:"-"`
Groups *[][]string `json:"groups,omitempty"`
MessyGroup *[]string `json:"messyGroup,omitempty"`
}
// HeadPoseProperties is properties indicating head pose of the face.
type HeadPoseProperties struct {
Roll *float64 `json:"roll,omitempty"`
Yaw *float64 `json:"yaw,omitempty"`
Pitch *float64 `json:"pitch,omitempty"`
}
// IdentifyRequest is request body for identify face operation.
type IdentifyRequest struct {
PersonGroupID *string `json:"personGroupId,omitempty"`
FaceIds *[]string `json:"faceIds,omitempty"`
MaxNumOfCandidatesReturned *int32 `json:"maxNumOfCandidatesReturned,omitempty"`
ConfidenceThreshold *float64 `json:"confidenceThreshold,omitempty"`
}
// IdentifyResultCandidate is all possible faces that may qualify.
type IdentifyResultCandidate struct {
PersonID *string `json:"personId,omitempty"`
Confidence *float64 `json:"confidence,omitempty"`
}
// IdentifyResultItem is response body for identify face operation.
type IdentifyResultItem struct {
FaceID *string `json:"faceId,omitempty"`
Candidates *[]IdentifyResultCandidate `json:"candidates,omitempty"`
}
// ImageURL is
type ImageURL struct {
URL *string `json:"url,omitempty"`
}
// Landmarks is a collection of 27-point face landmarks pointing to the important positions of face components.
type Landmarks struct {
PupilLeft *Position `json:"pupilLeft,omitempty"`
PupilRight *Position `json:"pupilRight,omitempty"`
NoseTip *Position `json:"noseTip,omitempty"`
MouthLeft *Position `json:"mouthLeft,omitempty"`
MouthRight *Position `json:"mouthRight,omitempty"`
EyebrowLeftOuter *Position `json:"eyebrowLeftOuter,omitempty"`
EyebrowLeftInner *Position `json:"eyebrowLeftInner,omitempty"`
EyeLeftOuter *Position `json:"eyeLeftOuter,omitempty"`
EyeLeftTop *Position `json:"eyeLeftTop,omitempty"`
EyeLeftBottom *Position `json:"eyeLeftBottom,omitempty"`
EyeLeftInner *Position `json:"eyeLeftInner,omitempty"`
EyebrowRightInner *Position `json:"eyebrowRightInner,omitempty"`
EyebrowRightOuter *Position `json:"eyebrowRightOuter,omitempty"`
EyeRightInner *Position `json:"eyeRightInner,omitempty"`
EyeRightTop *Position `json:"eyeRightTop,omitempty"`
EyeRightBottom *Position `json:"eyeRightBottom,omitempty"`
EyeRightOuter *Position `json:"eyeRightOuter,omitempty"`
NoseRootLeft *Position `json:"noseRootLeft,omitempty"`
NoseRootRight *Position `json:"noseRootRight,omitempty"`
NoseLeftAlarTop *Position `json:"noseLeftAlarTop,omitempty"`
NoseRightAlarTop *Position `json:"noseRightAlarTop,omitempty"`
NoseLeftAlarOutTip *Position `json:"noseLeftAlarOutTip,omitempty"`
NoseRightAlarOutTip *Position `json:"noseRightAlarOutTip,omitempty"`
UpperLipTop *Position `json:"upperLipTop,omitempty"`
UpperLipBottom *Position `json:"upperLipBottom,omitempty"`
UnderLipTop *Position `json:"underLipTop,omitempty"`
UnderLipBottom *Position `json:"underLipBottom,omitempty"`
}
// ListDetectedFace is
type ListDetectedFace struct {
autorest.Response `json:"-"`
Value *[]DetectedFace `json:"value,omitempty"`
}
// ListGetFaceListResult is
type ListGetFaceListResult struct {
autorest.Response `json:"-"`
Value *[]GetFaceListResult `json:"value,omitempty"`
}
// ListIdentifyResultItem is
type ListIdentifyResultItem struct {
autorest.Response `json:"-"`
Value *[]IdentifyResultItem `json:"value,omitempty"`
}
// ListPersonGroupResult is
type ListPersonGroupResult struct {
autorest.Response `json:"-"`
Value *[]PersonGroupResult `json:"value,omitempty"`
}
// ListPersonResult is
type ListPersonResult struct {
autorest.Response `json:"-"`
Value *[]PersonResult `json:"value,omitempty"`
}
// ListSimilarFaceResult is
type ListSimilarFaceResult struct {
autorest.Response `json:"-"`
Value *[]SimilarFaceResult `json:"value,omitempty"`
}
// PersonFaceResult is personFace object.
type PersonFaceResult struct {
autorest.Response `json:"-"`
PersistedFaceID *string `json:"persistedFaceId,omitempty"`
UserData *string `json:"userData,omitempty"`
}
// PersonGroupResult is person group object.
type PersonGroupResult struct {
autorest.Response `json:"-"`
PersonGroupID *string `json:"personGroupId,omitempty"`
Name *string `json:"name,omitempty"`
UserData *string `json:"userData,omitempty"`
}
// PersonResult is person object.
type PersonResult struct {
autorest.Response `json:"-"`
PersonID *string `json:"personId,omitempty"`
PersistedFaceIds *[]string `json:"persistedFaceIds,omitempty"`
Name *string `json:"name,omitempty"`
UserData *string `json:"userData,omitempty"`
}
// Position is coordinates within an image
type Position struct {
X *int32 `json:"x,omitempty"`
Y *int32 `json:"y,omitempty"`
}
// Rectangle is a rectangle within which a face can be found
type Rectangle struct {
Width *int32 `json:"width,omitempty"`
Height *int32 `json:"height,omitempty"`
Left *int32 `json:"left,omitempty"`
Top *int32 `json:"top,omitempty"`
}
// SimilarFaceResult is response body for find similar face operation.
type SimilarFaceResult struct {
FaceID *string `json:"faceId,omitempty"`
PersistedFaceID *string `json:"persistedFaceId,omitempty"`
Confidence *float64 `json:"confidence,omitempty"`
}
// TrainingStatus is training status object.
type TrainingStatus struct {
autorest.Response `json:"-"`
Status Status `json:"status,omitempty"`
Created *date.Time `json:"createdDateTime,omitempty"`
LastAction *date.Time `json:"lastActionDateTime,omitempty"`
Message *string `json:"message,omitempty"`
}
// UpdatePersonFaceDataRequest is request to update person face data.
type UpdatePersonFaceDataRequest struct {
UserData *string `json:"userData,omitempty"`
}
// VerifyRequest is request body for verify operation.
type VerifyRequest struct {
FaceID *string `json:"faceId,omitempty"`
PersonID *string `json:"personId,omitempty"`
PersonGroupID *string `json:"personGroupId,omitempty"`
}
// VerifyResult is result of the verify operation.
type VerifyResult struct {
autorest.Response `json:"-"`
IsIdentical *bool `json:"isIdentical,omitempty"`
Confidence *float64 `json:"confidence,omitempty"`
}
@@ -0,0 +1,711 @@
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 (
"github.com/Azure/go-autorest/autorest"
"github.com/Azure/go-autorest/autorest/azure"
"github.com/Azure/go-autorest/autorest/validation"
"net/http"
)
// PersonClient is the an API for face detection, verification, and identification.
type PersonClient struct {
ManagementClient
}
// NewPersonClient creates an instance of the PersonClient client.
func NewPersonClient(subscriptionKey string, azureRegion AzureRegions) PersonClient {
return PersonClient{New(subscriptionKey, azureRegion)}
}
// AddFace add a representative face to a person for identification. The input face is specified as an image with a
// targetFace rectangle.
//
// personGroupID is specifying the person group containing the target person. personID is target person that the face
// is added to. userData is user-specified data about the target face to add for any purpose. The maximum length is
// 1KB. targetFace is 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 PersonClient) AddFace(personGroupID string, personID string, userData string, targetFace string) (result autorest.Response, err error) {
req, err := client.AddFacePreparer(personGroupID, personID, userData, targetFace)
if err != nil {
err = autorest.NewErrorWithError(err, "face.PersonClient", "AddFace", nil, "Failure preparing request")
return
}
resp, err := client.AddFaceSender(req)
if err != nil {
result.Response = resp
err = autorest.NewErrorWithError(err, "face.PersonClient", "AddFace", resp, "Failure sending request")
return
}
result, err = client.AddFaceResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "face.PersonClient", "AddFace", resp, "Failure responding to request")
}
return
}
// AddFacePreparer prepares the AddFace request.
func (client PersonClient) AddFacePreparer(personGroupID string, personID string, userData string, targetFace string) (*http.Request, error) {
urlParameters := map[string]interface{}{
"AzureRegion": client.AzureRegion,
}
pathParameters := map[string]interface{}{
"personGroupId": autorest.Encode("path", personGroupID),
"personId": autorest.Encode("path", personID),
}
queryParameters := map[string]interface{}{}
if len(userData) > 0 {
queryParameters["userData"] = autorest.Encode("query", userData)
}
if len(targetFace) > 0 {
queryParameters["targetFace"] = autorest.Encode("query", targetFace)
}
preparer := autorest.CreatePreparer(
autorest.AsPost(),
autorest.WithCustomBaseURL("https://{AzureRegion}.api.cognitive.microsoft.com/face/v1.0", urlParameters),
autorest.WithPathParameters("/persongroups/{personGroupId}/persons/{personId}/persistedFaces", pathParameters),
autorest.WithQueryParameters(queryParameters),
autorest.WithHeader("Ocp-Apim-Subscription-Key", client.SubscriptionKey))
return preparer.Prepare(&http.Request{})
}
// AddFaceSender sends the AddFace request. The method will close the
// http.Response Body if it receives an error.
func (client PersonClient) AddFaceSender(req *http.Request) (*http.Response, error) {
return autorest.SendWithSender(client, req)
}
// AddFaceResponder handles the response to the AddFace request. The method always
// closes the http.Response Body.
func (client PersonClient) AddFaceResponder(resp *http.Response) (result autorest.Response, err error) {
err = autorest.Respond(
resp,
client.ByInspecting(),
azure.WithErrorUnlessStatusCode(http.StatusOK),
autorest.ByClosing())
result.Response = resp
return
}
// AddFaceFromStream add a representative face to a person for identification. The input face is specified as an image
// with a targetFace rectangle.
//
// personGroupID is specifying the person group containing the target person. personID is target person that the face
// is added to. userData is user-specified data about the target face to add for any purpose. The maximum length is
// 1KB. targetFace is 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 PersonClient) AddFaceFromStream(personGroupID string, personID string, userData string, targetFace string) (result autorest.Response, err error) {
req, err := client.AddFaceFromStreamPreparer(personGroupID, personID, userData, targetFace)
if err != nil {
err = autorest.NewErrorWithError(err, "face.PersonClient", "AddFaceFromStream", nil, "Failure preparing request")
return
}
resp, err := client.AddFaceFromStreamSender(req)
if err != nil {
result.Response = resp
err = autorest.NewErrorWithError(err, "face.PersonClient", "AddFaceFromStream", resp, "Failure sending request")
return
}
result, err = client.AddFaceFromStreamResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "face.PersonClient", "AddFaceFromStream", resp, "Failure responding to request")
}
return
}
// AddFaceFromStreamPreparer prepares the AddFaceFromStream request.
func (client PersonClient) AddFaceFromStreamPreparer(personGroupID string, personID string, userData string, targetFace string) (*http.Request, error) {
urlParameters := map[string]interface{}{
"AzureRegion": client.AzureRegion,
}
pathParameters := map[string]interface{}{
"personGroupId": autorest.Encode("path", personGroupID),
"personId": autorest.Encode("path", personID),
}
queryParameters := map[string]interface{}{}
if len(userData) > 0 {
queryParameters["userData"] = autorest.Encode("query", userData)
}
if len(targetFace) > 0 {
queryParameters["targetFace"] = autorest.Encode("query", targetFace)
}
preparer := autorest.CreatePreparer(
autorest.AsPost(),
autorest.WithCustomBaseURL("https://{AzureRegion}.api.cognitive.microsoft.com/face/v1.0", urlParameters),
autorest.WithPathParameters("/persongroups/{personGroupId}/persons/{personId}/persistedFaces", pathParameters),
autorest.WithQueryParameters(queryParameters),
autorest.WithHeader("Ocp-Apim-Subscription-Key", client.SubscriptionKey))
return preparer.Prepare(&http.Request{})
}
// AddFaceFromStreamSender sends the AddFaceFromStream request. The method will close the
// http.Response Body if it receives an error.
func (client PersonClient) AddFaceFromStreamSender(req *http.Request) (*http.Response, error) {
return autorest.SendWithSender(client, req)
}
// AddFaceFromStreamResponder handles the response to the AddFaceFromStream request. The method always
// closes the http.Response Body.
func (client PersonClient) AddFaceFromStreamResponder(resp *http.Response) (result autorest.Response, err error) {
err = autorest.Respond(
resp,
client.ByInspecting(),
azure.WithErrorUnlessStatusCode(http.StatusOK),
autorest.ByClosing())
result.Response = resp
return
}
// Create create a new person in a specified person group.
//
// personGroupID is specifying the target person group to create the person.
func (client PersonClient) Create(personGroupID string, body CreatePersonRequest) (result CreatePersonResult, err error) {
if err := validation.Validate([]validation.Validation{
{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.NewErrorWithValidationError(err, "face.PersonClient", "Create")
}
req, err := client.CreatePreparer(personGroupID, body)
if err != nil {
err = autorest.NewErrorWithError(err, "face.PersonClient", "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.PersonClient", "Create", resp, "Failure sending request")
return
}
result, err = client.CreateResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "face.PersonClient", "Create", resp, "Failure responding to request")
}
return
}
// CreatePreparer prepares the Create request.
func (client PersonClient) CreatePreparer(personGroupID string, body CreatePersonRequest) (*http.Request, error) {
urlParameters := map[string]interface{}{
"AzureRegion": client.AzureRegion,
}
pathParameters := map[string]interface{}{
"personGroupId": autorest.Encode("path", personGroupID),
}
preparer := autorest.CreatePreparer(
autorest.AsJSON(),
autorest.AsPost(),
autorest.WithCustomBaseURL("https://{AzureRegion}.api.cognitive.microsoft.com/face/v1.0", urlParameters),
autorest.WithPathParameters("/persongroups/{personGroupId}/persons", pathParameters),
autorest.WithJSON(body),
autorest.WithHeader("Ocp-Apim-Subscription-Key", client.SubscriptionKey))
return preparer.Prepare(&http.Request{})
}
// CreateSender sends the Create request. The method will close the
// http.Response Body if it receives an error.
func (client PersonClient) CreateSender(req *http.Request) (*http.Response, error) {
return autorest.SendWithSender(client, req)
}
// CreateResponder handles the response to the Create request. The method always
// closes the http.Response Body.
func (client PersonClient) CreateResponder(resp *http.Response) (result CreatePersonResult, 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 person group. Persisted face images of the person will also be deleted.
//
// personGroupID is specifying the person group containing the person. personID is the target personId to delete.
func (client PersonClient) Delete(personGroupID string, personID string) (result autorest.Response, err error) {
req, err := client.DeletePreparer(personGroupID, personID)
if err != nil {
err = autorest.NewErrorWithError(err, "face.PersonClient", "Delete", nil, "Failure preparing request")
return
}
resp, err := client.DeleteSender(req)
if err != nil {
result.Response = resp
err = autorest.NewErrorWithError(err, "face.PersonClient", "Delete", resp, "Failure sending request")
return
}
result, err = client.DeleteResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "face.PersonClient", "Delete", resp, "Failure responding to request")
}
return
}
// DeletePreparer prepares the Delete request.
func (client PersonClient) DeletePreparer(personGroupID string, personID string) (*http.Request, error) {
urlParameters := map[string]interface{}{
"AzureRegion": client.AzureRegion,
}
pathParameters := map[string]interface{}{
"personGroupId": autorest.Encode("path", personGroupID),
"personId": autorest.Encode("path", personID),
}
preparer := autorest.CreatePreparer(
autorest.AsDelete(),
autorest.WithCustomBaseURL("https://{AzureRegion}.api.cognitive.microsoft.com/face/v1.0", urlParameters),
autorest.WithPathParameters("/persongroups/{personGroupId}/persons/{personId}", pathParameters),
autorest.WithHeader("Ocp-Apim-Subscription-Key", client.SubscriptionKey))
return preparer.Prepare(&http.Request{})
}
// DeleteSender sends the Delete request. The method will close the
// http.Response Body if it receives an error.
func (client PersonClient) DeleteSender(req *http.Request) (*http.Response, error) {
return autorest.SendWithSender(client, req)
}
// DeleteResponder handles the response to the Delete request. The method always
// closes the http.Response Body.
func (client PersonClient) 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 image for the persisted face will also be deleted.
//
// personGroupID is specifying the person group containing the target person. personID is specifying the person that
// the target persisted face belong to. persistedFaceID is the persisted face to remove.
func (client PersonClient) DeleteFace(personGroupID string, personID string, persistedFaceID string) (result autorest.Response, err error) {
req, err := client.DeleteFacePreparer(personGroupID, personID, persistedFaceID)
if err != nil {
err = autorest.NewErrorWithError(err, "face.PersonClient", "DeleteFace", nil, "Failure preparing request")
return
}
resp, err := client.DeleteFaceSender(req)
if err != nil {
result.Response = resp
err = autorest.NewErrorWithError(err, "face.PersonClient", "DeleteFace", resp, "Failure sending request")
return
}
result, err = client.DeleteFaceResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "face.PersonClient", "DeleteFace", resp, "Failure responding to request")
}
return
}
// DeleteFacePreparer prepares the DeleteFace request.
func (client PersonClient) DeleteFacePreparer(personGroupID string, personID string, persistedFaceID string) (*http.Request, error) {
urlParameters := map[string]interface{}{
"AzureRegion": client.AzureRegion,
}
pathParameters := map[string]interface{}{
"persistedFaceId": autorest.Encode("path", persistedFaceID),
"personGroupId": autorest.Encode("path", personGroupID),
"personId": autorest.Encode("path", personID),
}
preparer := autorest.CreatePreparer(
autorest.AsDelete(),
autorest.WithCustomBaseURL("https://{AzureRegion}.api.cognitive.microsoft.com/face/v1.0", urlParameters),
autorest.WithPathParameters("/persongroups/{personGroupId}/persons/{personId}/persistedFaces/{persistedFaceId}", pathParameters),
autorest.WithHeader("Ocp-Apim-Subscription-Key", client.SubscriptionKey))
return preparer.Prepare(&http.Request{})
}
// DeleteFaceSender sends the DeleteFace request. The method will close the
// http.Response Body if it receives an error.
func (client PersonClient) DeleteFaceSender(req *http.Request) (*http.Response, error) {
return autorest.SendWithSender(client, req)
}
// DeleteFaceResponder handles the response to the DeleteFace request. The method always
// closes the http.Response Body.
func (client PersonClient) 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.
//
// personGroupID is specifying the person group containing the target person. personID is specifying the target person.
func (client PersonClient) Get(personGroupID string, personID string) (result PersonResult, err error) {
req, err := client.GetPreparer(personGroupID, personID)
if err != nil {
err = autorest.NewErrorWithError(err, "face.PersonClient", "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.PersonClient", "Get", resp, "Failure sending request")
return
}
result, err = client.GetResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "face.PersonClient", "Get", resp, "Failure responding to request")
}
return
}
// GetPreparer prepares the Get request.
func (client PersonClient) GetPreparer(personGroupID string, personID string) (*http.Request, error) {
urlParameters := map[string]interface{}{
"AzureRegion": client.AzureRegion,
}
pathParameters := map[string]interface{}{
"personGroupId": autorest.Encode("path", personGroupID),
"personId": autorest.Encode("path", personID),
}
preparer := autorest.CreatePreparer(
autorest.AsGet(),
autorest.WithCustomBaseURL("https://{AzureRegion}.api.cognitive.microsoft.com/face/v1.0", urlParameters),
autorest.WithPathParameters("/persongroups/{personGroupId}/persons/{personId}", pathParameters),
autorest.WithHeader("Ocp-Apim-Subscription-Key", client.SubscriptionKey))
return preparer.Prepare(&http.Request{})
}
// GetSender sends the Get request. The method will close the
// http.Response Body if it receives an error.
func (client PersonClient) GetSender(req *http.Request) (*http.Response, error) {
return autorest.SendWithSender(client, req)
}
// GetResponder handles the response to the Get request. The method always
// closes the http.Response Body.
func (client PersonClient) GetResponder(resp *http.Response) (result PersonResult, 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
// personGroupId).
//
// personGroupID is specifying the person group containing the target person. personID is specifying the target person
// that the face belongs to. persistedFaceID is the persistedFaceId of the target persisted face of the person.
func (client PersonClient) GetFace(personGroupID string, personID string, persistedFaceID string) (result PersonFaceResult, err error) {
req, err := client.GetFacePreparer(personGroupID, personID, persistedFaceID)
if err != nil {
err = autorest.NewErrorWithError(err, "face.PersonClient", "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.PersonClient", "GetFace", resp, "Failure sending request")
return
}
result, err = client.GetFaceResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "face.PersonClient", "GetFace", resp, "Failure responding to request")
}
return
}
// GetFacePreparer prepares the GetFace request.
func (client PersonClient) GetFacePreparer(personGroupID string, personID string, persistedFaceID string) (*http.Request, error) {
urlParameters := map[string]interface{}{
"AzureRegion": client.AzureRegion,
}
pathParameters := map[string]interface{}{
"persistedFaceId": autorest.Encode("path", persistedFaceID),
"personGroupId": autorest.Encode("path", personGroupID),
"personId": autorest.Encode("path", personID),
}
preparer := autorest.CreatePreparer(
autorest.AsGet(),
autorest.WithCustomBaseURL("https://{AzureRegion}.api.cognitive.microsoft.com/face/v1.0", urlParameters),
autorest.WithPathParameters("/persongroups/{personGroupId}/persons/{personId}/persistedFaces/{persistedFaceId}", pathParameters),
autorest.WithHeader("Ocp-Apim-Subscription-Key", client.SubscriptionKey))
return preparer.Prepare(&http.Request{})
}
// GetFaceSender sends the GetFace request. The method will close the
// http.Response Body if it receives an error.
func (client PersonClient) GetFaceSender(req *http.Request) (*http.Response, error) {
return autorest.SendWithSender(client, req)
}
// GetFaceResponder handles the response to the GetFace request. The method always
// closes the http.Response Body.
func (client PersonClient) GetFaceResponder(resp *http.Response) (result PersonFaceResult, 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 person group, and retrieve person information (including personId, name, userData and
// persistedFaceIds of registered faces of the person).
//
// personGroupID is personGroupId of the target person group.
func (client PersonClient) List(personGroupID string) (result ListPersonResult, err error) {
req, err := client.ListPreparer(personGroupID)
if err != nil {
err = autorest.NewErrorWithError(err, "face.PersonClient", "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.PersonClient", "List", resp, "Failure sending request")
return
}
result, err = client.ListResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "face.PersonClient", "List", resp, "Failure responding to request")
}
return
}
// ListPreparer prepares the List request.
func (client PersonClient) ListPreparer(personGroupID string) (*http.Request, error) {
urlParameters := map[string]interface{}{
"AzureRegion": client.AzureRegion,
}
pathParameters := map[string]interface{}{
"personGroupId": autorest.Encode("path", personGroupID),
}
preparer := autorest.CreatePreparer(
autorest.AsGet(),
autorest.WithCustomBaseURL("https://{AzureRegion}.api.cognitive.microsoft.com/face/v1.0", urlParameters),
autorest.WithPathParameters("/persongroups/{personGroupId}/persons", pathParameters),
autorest.WithHeader("Ocp-Apim-Subscription-Key", client.SubscriptionKey))
return preparer.Prepare(&http.Request{})
}
// ListSender sends the List request. The method will close the
// http.Response Body if it receives an error.
func (client PersonClient) ListSender(req *http.Request) (*http.Response, error) {
return autorest.SendWithSender(client, req)
}
// ListResponder handles the response to the List request. The method always
// closes the http.Response Body.
func (client PersonClient) ListResponder(resp *http.Response) (result ListPersonResult, 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.
//
// personGroupID is specifying the person group containing the target person. personID is personId of the target
// person.
func (client PersonClient) Update(personGroupID string, personID string, body CreatePersonRequest) (result autorest.Response, err error) {
req, err := client.UpdatePreparer(personGroupID, personID, body)
if err != nil {
err = autorest.NewErrorWithError(err, "face.PersonClient", "Update", nil, "Failure preparing request")
return
}
resp, err := client.UpdateSender(req)
if err != nil {
result.Response = resp
err = autorest.NewErrorWithError(err, "face.PersonClient", "Update", resp, "Failure sending request")
return
}
result, err = client.UpdateResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "face.PersonClient", "Update", resp, "Failure responding to request")
}
return
}
// UpdatePreparer prepares the Update request.
func (client PersonClient) UpdatePreparer(personGroupID string, personID string, body CreatePersonRequest) (*http.Request, error) {
urlParameters := map[string]interface{}{
"AzureRegion": client.AzureRegion,
}
pathParameters := map[string]interface{}{
"personGroupId": autorest.Encode("path", personGroupID),
"personId": autorest.Encode("path", personID),
}
preparer := autorest.CreatePreparer(
autorest.AsJSON(),
autorest.AsPatch(),
autorest.WithCustomBaseURL("https://{AzureRegion}.api.cognitive.microsoft.com/face/v1.0", urlParameters),
autorest.WithPathParameters("/persongroups/{personGroupId}/persons/{personId}", pathParameters),
autorest.WithJSON(body),
autorest.WithHeader("Ocp-Apim-Subscription-Key", client.SubscriptionKey))
return preparer.Prepare(&http.Request{})
}
// UpdateSender sends the Update request. The method will close the
// http.Response Body if it receives an error.
func (client PersonClient) UpdateSender(req *http.Request) (*http.Response, error) {
return autorest.SendWithSender(client, req)
}
// UpdateResponder handles the response to the Update request. The method always
// closes the http.Response Body.
func (client PersonClient) 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.
//
// personGroupID is specifying the person group containing the target person. personID is personId of the target
// person. persistedFaceID is persistedFaceId of target face, which is persisted and will not expire.
func (client PersonClient) UpdateFace(personGroupID string, personID string, persistedFaceID string, body UpdatePersonFaceDataRequest) (result autorest.Response, err error) {
req, err := client.UpdateFacePreparer(personGroupID, personID, persistedFaceID, body)
if err != nil {
err = autorest.NewErrorWithError(err, "face.PersonClient", "UpdateFace", nil, "Failure preparing request")
return
}
resp, err := client.UpdateFaceSender(req)
if err != nil {
result.Response = resp
err = autorest.NewErrorWithError(err, "face.PersonClient", "UpdateFace", resp, "Failure sending request")
return
}
result, err = client.UpdateFaceResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "face.PersonClient", "UpdateFace", resp, "Failure responding to request")
}
return
}
// UpdateFacePreparer prepares the UpdateFace request.
func (client PersonClient) UpdateFacePreparer(personGroupID string, personID string, persistedFaceID string, body UpdatePersonFaceDataRequest) (*http.Request, error) {
urlParameters := map[string]interface{}{
"AzureRegion": client.AzureRegion,
}
pathParameters := map[string]interface{}{
"persistedFaceId": autorest.Encode("path", persistedFaceID),
"personGroupId": autorest.Encode("path", personGroupID),
"personId": autorest.Encode("path", personID),
}
preparer := autorest.CreatePreparer(
autorest.AsJSON(),
autorest.AsPatch(),
autorest.WithCustomBaseURL("https://{AzureRegion}.api.cognitive.microsoft.com/face/v1.0", urlParameters),
autorest.WithPathParameters("/persongroups/{personGroupId}/persons/{personId}/persistedFaces/{persistedFaceId}", pathParameters),
autorest.WithJSON(body),
autorest.WithHeader("Ocp-Apim-Subscription-Key", client.SubscriptionKey))
return preparer.Prepare(&http.Request{})
}
// UpdateFaceSender sends the UpdateFace request. The method will close the
// http.Response Body if it receives an error.
func (client PersonClient) UpdateFaceSender(req *http.Request) (*http.Response, error) {
return autorest.SendWithSender(client, req)
}
// UpdateFaceResponder handles the response to the UpdateFace request. The method always
// closes the http.Response Body.
func (client PersonClient) 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
}
@@ -0,0 +1,500 @@
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 (
"github.com/Azure/go-autorest/autorest"
"github.com/Azure/go-autorest/autorest/azure"
"github.com/Azure/go-autorest/autorest/validation"
"net/http"
)
// PersonGroupClient is the an API for face detection, verification, and identification.
type PersonGroupClient struct {
ManagementClient
}
// NewPersonGroupClient creates an instance of the PersonGroupClient client.
func NewPersonGroupClient(subscriptionKey string, azureRegion AzureRegions) PersonGroupClient {
return PersonGroupClient{New(subscriptionKey, azureRegion)}
}
// Create create a new person group with specified personGroupId, name and user-provided userData.
//
// personGroupID is user-provided personGroupId as a string.
func (client PersonGroupClient) Create(personGroupID string, body CreatePersonGroupRequest) (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},
{Target: "personGroupID", 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.NewErrorWithValidationError(err, "face.PersonGroupClient", "Create")
}
req, err := client.CreatePreparer(personGroupID, body)
if err != nil {
err = autorest.NewErrorWithError(err, "face.PersonGroupClient", "Create", nil, "Failure preparing request")
return
}
resp, err := client.CreateSender(req)
if err != nil {
result.Response = resp
err = autorest.NewErrorWithError(err, "face.PersonGroupClient", "Create", resp, "Failure sending request")
return
}
result, err = client.CreateResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "face.PersonGroupClient", "Create", resp, "Failure responding to request")
}
return
}
// CreatePreparer prepares the Create request.
func (client PersonGroupClient) CreatePreparer(personGroupID string, body CreatePersonGroupRequest) (*http.Request, error) {
urlParameters := map[string]interface{}{
"AzureRegion": client.AzureRegion,
}
pathParameters := map[string]interface{}{
"personGroupId": autorest.Encode("path", personGroupID),
}
preparer := autorest.CreatePreparer(
autorest.AsJSON(),
autorest.AsPut(),
autorest.WithCustomBaseURL("https://{AzureRegion}.api.cognitive.microsoft.com/face/v1.0", urlParameters),
autorest.WithPathParameters("/persongroups/{personGroupId}", pathParameters),
autorest.WithJSON(body),
autorest.WithHeader("Ocp-Apim-Subscription-Key", client.SubscriptionKey))
return preparer.Prepare(&http.Request{})
}
// CreateSender sends the Create request. The method will close the
// http.Response Body if it receives an error.
func (client PersonGroupClient) CreateSender(req *http.Request) (*http.Response, error) {
return autorest.SendWithSender(client, req)
}
// CreateResponder handles the response to the Create request. The method always
// closes the http.Response Body.
func (client PersonGroupClient) 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 person group. Persisted face images of all people in the person group will also be
// deleted.
//
// personGroupID is the personGroupId of the person group to be deleted.
func (client PersonGroupClient) Delete(personGroupID string) (result autorest.Response, err error) {
req, err := client.DeletePreparer(personGroupID)
if err != nil {
err = autorest.NewErrorWithError(err, "face.PersonGroupClient", "Delete", nil, "Failure preparing request")
return
}
resp, err := client.DeleteSender(req)
if err != nil {
result.Response = resp
err = autorest.NewErrorWithError(err, "face.PersonGroupClient", "Delete", resp, "Failure sending request")
return
}
result, err = client.DeleteResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "face.PersonGroupClient", "Delete", resp, "Failure responding to request")
}
return
}
// DeletePreparer prepares the Delete request.
func (client PersonGroupClient) DeletePreparer(personGroupID string) (*http.Request, error) {
urlParameters := map[string]interface{}{
"AzureRegion": client.AzureRegion,
}
pathParameters := map[string]interface{}{
"personGroupId": autorest.Encode("path", personGroupID),
}
preparer := autorest.CreatePreparer(
autorest.AsDelete(),
autorest.WithCustomBaseURL("https://{AzureRegion}.api.cognitive.microsoft.com/face/v1.0", urlParameters),
autorest.WithPathParameters("/persongroups/{personGroupId}", pathParameters),
autorest.WithHeader("Ocp-Apim-Subscription-Key", client.SubscriptionKey))
return preparer.Prepare(&http.Request{})
}
// DeleteSender sends the Delete request. The method will close the
// http.Response Body if it receives an error.
func (client PersonGroupClient) DeleteSender(req *http.Request) (*http.Response, error) {
return autorest.SendWithSender(client, req)
}
// DeleteResponder handles the response to the Delete request. The method always
// closes the http.Response Body.
func (client PersonGroupClient) 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 person group, including its name and userData.
//
// personGroupID is personGroupId of the target person group.
func (client PersonGroupClient) Get(personGroupID string) (result PersonGroupResult, err error) {
req, err := client.GetPreparer(personGroupID)
if err != nil {
err = autorest.NewErrorWithError(err, "face.PersonGroupClient", "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.PersonGroupClient", "Get", resp, "Failure sending request")
return
}
result, err = client.GetResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "face.PersonGroupClient", "Get", resp, "Failure responding to request")
}
return
}
// GetPreparer prepares the Get request.
func (client PersonGroupClient) GetPreparer(personGroupID string) (*http.Request, error) {
urlParameters := map[string]interface{}{
"AzureRegion": client.AzureRegion,
}
pathParameters := map[string]interface{}{
"personGroupId": autorest.Encode("path", personGroupID),
}
preparer := autorest.CreatePreparer(
autorest.AsGet(),
autorest.WithCustomBaseURL("https://{AzureRegion}.api.cognitive.microsoft.com/face/v1.0", urlParameters),
autorest.WithPathParameters("/persongroups/{personGroupId}", pathParameters),
autorest.WithHeader("Ocp-Apim-Subscription-Key", client.SubscriptionKey))
return preparer.Prepare(&http.Request{})
}
// GetSender sends the Get request. The method will close the
// http.Response Body if it receives an error.
func (client PersonGroupClient) GetSender(req *http.Request) (*http.Response, error) {
return autorest.SendWithSender(client, req)
}
// GetResponder handles the response to the Get request. The method always
// closes the http.Response Body.
func (client PersonGroupClient) GetResponder(resp *http.Response) (result PersonGroupResult, 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 person group (completed or ongoing).
//
// personGroupID is personGroupId of target person group.
func (client PersonGroupClient) GetTrainingStatus(personGroupID string) (result TrainingStatus, err error) {
req, err := client.GetTrainingStatusPreparer(personGroupID)
if err != nil {
err = autorest.NewErrorWithError(err, "face.PersonGroupClient", "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.PersonGroupClient", "GetTrainingStatus", resp, "Failure sending request")
return
}
result, err = client.GetTrainingStatusResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "face.PersonGroupClient", "GetTrainingStatus", resp, "Failure responding to request")
}
return
}
// GetTrainingStatusPreparer prepares the GetTrainingStatus request.
func (client PersonGroupClient) GetTrainingStatusPreparer(personGroupID string) (*http.Request, error) {
urlParameters := map[string]interface{}{
"AzureRegion": client.AzureRegion,
}
pathParameters := map[string]interface{}{
"personGroupId": autorest.Encode("path", personGroupID),
}
preparer := autorest.CreatePreparer(
autorest.AsGet(),
autorest.WithCustomBaseURL("https://{AzureRegion}.api.cognitive.microsoft.com/face/v1.0", urlParameters),
autorest.WithPathParameters("/persongroups/{personGroupId}/training", pathParameters),
autorest.WithHeader("Ocp-Apim-Subscription-Key", client.SubscriptionKey))
return preparer.Prepare(&http.Request{})
}
// GetTrainingStatusSender sends the GetTrainingStatus request. The method will close the
// http.Response Body if it receives an error.
func (client PersonGroupClient) GetTrainingStatusSender(req *http.Request) (*http.Response, error) {
return autorest.SendWithSender(client, req)
}
// GetTrainingStatusResponder handles the response to the GetTrainingStatus request. The method always
// closes the http.Response Body.
func (client PersonGroupClient) 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 person groups and their information.
//
// start is list person groups from the least personGroupId greater than the "start". top is the number of person
// groups to list.
func (client PersonGroupClient) List(start string, top *int32) (result ListPersonGroupResult, 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: 1000, Chain: nil},
{Target: "top", Name: validation.InclusiveMinimum, Rule: 1, Chain: nil},
}}}}}); err != nil {
return result, validation.NewErrorWithValidationError(err, "face.PersonGroupClient", "List")
}
req, err := client.ListPreparer(start, top)
if err != nil {
err = autorest.NewErrorWithError(err, "face.PersonGroupClient", "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.PersonGroupClient", "List", resp, "Failure sending request")
return
}
result, err = client.ListResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "face.PersonGroupClient", "List", resp, "Failure responding to request")
}
return
}
// ListPreparer prepares the List request.
func (client PersonGroupClient) ListPreparer(start string, top *int32) (*http.Request, error) {
urlParameters := map[string]interface{}{
"AzureRegion": client.AzureRegion,
}
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("https://{AzureRegion}.api.cognitive.microsoft.com/face/v1.0", urlParameters),
autorest.WithPath("/persongroups"),
autorest.WithQueryParameters(queryParameters),
autorest.WithHeader("Ocp-Apim-Subscription-Key", client.SubscriptionKey))
return preparer.Prepare(&http.Request{})
}
// ListSender sends the List request. The method will close the
// http.Response Body if it receives an error.
func (client PersonGroupClient) ListSender(req *http.Request) (*http.Response, error) {
return autorest.SendWithSender(client, req)
}
// ListResponder handles the response to the List request. The method always
// closes the http.Response Body.
func (client PersonGroupClient) ListResponder(resp *http.Response) (result ListPersonGroupResult, 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 person group training task, the training task may not be started immediately.
//
// personGroupID is target person group to be trained.
func (client PersonGroupClient) Train(personGroupID string) (result autorest.Response, err error) {
req, err := client.TrainPreparer(personGroupID)
if err != nil {
err = autorest.NewErrorWithError(err, "face.PersonGroupClient", "Train", nil, "Failure preparing request")
return
}
resp, err := client.TrainSender(req)
if err != nil {
result.Response = resp
err = autorest.NewErrorWithError(err, "face.PersonGroupClient", "Train", resp, "Failure sending request")
return
}
result, err = client.TrainResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "face.PersonGroupClient", "Train", resp, "Failure responding to request")
}
return
}
// TrainPreparer prepares the Train request.
func (client PersonGroupClient) TrainPreparer(personGroupID string) (*http.Request, error) {
urlParameters := map[string]interface{}{
"AzureRegion": client.AzureRegion,
}
pathParameters := map[string]interface{}{
"personGroupId": autorest.Encode("path", personGroupID),
}
preparer := autorest.CreatePreparer(
autorest.AsPost(),
autorest.WithCustomBaseURL("https://{AzureRegion}.api.cognitive.microsoft.com/face/v1.0", urlParameters),
autorest.WithPathParameters("/persongroups/{personGroupId}/train", pathParameters),
autorest.WithHeader("Ocp-Apim-Subscription-Key", client.SubscriptionKey))
return preparer.Prepare(&http.Request{})
}
// TrainSender sends the Train request. The method will close the
// http.Response Body if it receives an error.
func (client PersonGroupClient) TrainSender(req *http.Request) (*http.Response, error) {
return autorest.SendWithSender(client, req)
}
// TrainResponder handles the response to the Train request. The method always
// closes the http.Response Body.
func (client PersonGroupClient) 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 person group's display name and userData. The properties which does not appear in request
// body will not be updated.
//
// personGroupID is personGroupId of the person group to be updated.
func (client PersonGroupClient) Update(personGroupID string, body CreatePersonGroupRequest) (result autorest.Response, err error) {
req, err := client.UpdatePreparer(personGroupID, body)
if err != nil {
err = autorest.NewErrorWithError(err, "face.PersonGroupClient", "Update", nil, "Failure preparing request")
return
}
resp, err := client.UpdateSender(req)
if err != nil {
result.Response = resp
err = autorest.NewErrorWithError(err, "face.PersonGroupClient", "Update", resp, "Failure sending request")
return
}
result, err = client.UpdateResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "face.PersonGroupClient", "Update", resp, "Failure responding to request")
}
return
}
// UpdatePreparer prepares the Update request.
func (client PersonGroupClient) UpdatePreparer(personGroupID string, body CreatePersonGroupRequest) (*http.Request, error) {
urlParameters := map[string]interface{}{
"AzureRegion": client.AzureRegion,
}
pathParameters := map[string]interface{}{
"personGroupId": autorest.Encode("path", personGroupID),
}
preparer := autorest.CreatePreparer(
autorest.AsJSON(),
autorest.AsPatch(),
autorest.WithCustomBaseURL("https://{AzureRegion}.api.cognitive.microsoft.com/face/v1.0", urlParameters),
autorest.WithPathParameters("/persongroups/{personGroupId}", pathParameters),
autorest.WithJSON(body),
autorest.WithHeader("Ocp-Apim-Subscription-Key", client.SubscriptionKey))
return preparer.Prepare(&http.Request{})
}
// UpdateSender sends the Update request. The method will close the
// http.Response Body if it receives an error.
func (client PersonGroupClient) UpdateSender(req *http.Request) (*http.Response, error) {
return autorest.SendWithSender(client, req)
}
// UpdateResponder handles the response to the Update request. The method always
// closes the http.Response Body.
func (client PersonGroupClient) 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
}
@@ -0,0 +1,28 @@
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.
// UserAgent returns the UserAgent string to use when sending http.Requests.
func UserAgent() string {
return "Azure-SDK-For-Go/v11.0.0-beta arm-face/1.0"
}
// Version returns the semantic version (see http://semver.org) of the client.
func Version() string {
return "v11.0.0-beta"
}