...

Source file src/github.com/Azure/azure-sdk-for-go/services/cognitiveservices/v1.0/face/largepersongroupperson.go

Documentation: github.com/Azure/azure-sdk-for-go/services/cognitiveservices/v1.0/face

     1  package face
     2  
     3  // Copyright (c) Microsoft Corporation. All rights reserved.
     4  // Licensed under the MIT License. See License.txt in the project root for license information.
     5  //
     6  // Code generated by Microsoft (R) AutoRest Code Generator.
     7  // Changes may cause incorrect behavior and will be lost if the code is regenerated.
     8  
     9  import (
    10  	"context"
    11  	"github.com/Azure/go-autorest/autorest"
    12  	"github.com/Azure/go-autorest/autorest/azure"
    13  	"github.com/Azure/go-autorest/autorest/validation"
    14  	"github.com/Azure/go-autorest/tracing"
    15  	"github.com/gofrs/uuid"
    16  	"io"
    17  	"net/http"
    18  )
    19  
    20  // LargePersonGroupPersonClient is the an API for face detection, verification, and identification.
    21  type LargePersonGroupPersonClient struct {
    22  	BaseClient
    23  }
    24  
    25  // NewLargePersonGroupPersonClient creates an instance of the LargePersonGroupPersonClient client.
    26  func NewLargePersonGroupPersonClient(endpoint string) LargePersonGroupPersonClient {
    27  	return LargePersonGroupPersonClient{New(endpoint)}
    28  }
    29  
    30  // AddFaceFromStream add a face to a person into a large person group for face identification or verification. To deal
    31  // with an image contains multiple faces, input face can be specified as an image with a targetFace rectangle. It
    32  // returns a persistedFaceId representing the added face. No image will be stored. Only the extracted face feature will
    33  // be stored on server until [LargePersonGroup PersonFace -
    34  // Delete](https://docs.microsoft.com/rest/api/cognitiveservices/face/largepersongroupperson/deleteface),
    35  // [LargePersonGroup Person -
    36  // Delete](https://docs.microsoft.com/rest/api/cognitiveservices/face/largepersongroupperson/delete) or
    37  // [LargePersonGroup - Delete](https://docs.microsoft.com/rest/api/cognitiveservices/face/largepersongroup/delete) is
    38  // called.
    39  // <br /> Note persistedFaceId is different from faceId generated by [Face -
    40  // Detect](https://docs.microsoft.com/rest/api/cognitiveservices/face/face/detectwithurl).
    41  // * Higher face image quality means better recognition precision. Please consider high-quality faces: frontal, clear,
    42  // and face size is 200x200 pixels (100 pixels between eyes) or bigger.
    43  // * Each person entry can hold up to 248 faces.
    44  // * JPEG, PNG, GIF (the first frame), and BMP format are supported. The allowed image file size is from 1KB to 6MB.
    45  // * "targetFace" rectangle should contain one face. Zero or multiple faces will be regarded as an error. If the
    46  // provided "targetFace" rectangle is not returned from [Face -
    47  // Detect](https://docs.microsoft.com/rest/api/cognitiveservices/face/face/detectwithurl), there’s no guarantee to
    48  // detect and add the face successfully.
    49  // * Out of detectable face size (36x36 - 4096x4096 pixels), large head-pose, or large occlusions will cause failures.
    50  // * Adding/deleting faces to/from a same person will be processed sequentially. Adding/deleting faces to/from
    51  // different persons are processed in parallel.
    52  // * The minimum detectable face size is 36x36 pixels in an image no larger than 1920x1080 pixels. Images with
    53  // dimensions higher than 1920x1080 pixels will need a proportionally larger minimum face size.
    54  // * Different 'detectionModel' values can be provided. To use and compare different detection models, please refer to
    55  // [How to specify a detection
    56  // model](https://docs.microsoft.com/azure/cognitive-services/face/face-api-how-to-topics/specify-detection-model)
    57  // | Model | Recommended use-case(s) |
    58  // | ---------- | -------- |
    59  // | 'detection_01': | The default detection model for [LargePersonGroup Person - Add
    60  // Face](https://docs.microsoft.com/rest/api/cognitiveservices/face/largepersongroupperson/addfacefromurl). Recommend
    61  // for near frontal face detection. For scenarios with exceptionally large angle (head-pose) faces, occluded faces or
    62  // wrong image orientation, the faces in such cases may not be detected. |
    63  // | 'detection_02': | Detection model released in 2019 May with improved accuracy especially on small, side and blurry
    64  // faces. |
    65  // Parameters:
    66  // largePersonGroupID - id referencing a particular large person group.
    67  // personID - id referencing a particular person.
    68  // imageParameter - an image stream.
    69  // userData - user-specified data about the face for any purpose. The maximum length is 1KB.
    70  // targetFace - a face rectangle to specify the target face to be added to a person in the format of
    71  // "targetFace=left,top,width,height". E.g. "targetFace=10,10,100,100". If there is more than one face in the
    72  // image, targetFace is required to specify which face to add. No targetFace means there is only one face
    73  // detected in the entire image.
    74  // detectionModel - name of detection model. Detection model is used to detect faces in the submitted image. A
    75  // detection model name can be provided when performing Face - Detect or (Large)FaceList - Add Face or
    76  // (Large)PersonGroup - Add Face. The default value is 'detection_01', if another model is needed, please
    77  // explicitly specify it.
    78  func (client LargePersonGroupPersonClient) AddFaceFromStream(ctx context.Context, largePersonGroupID string, personID uuid.UUID, imageParameter io.ReadCloser, userData string, targetFace []int32, detectionModel DetectionModel) (result PersistedFace, err error) {
    79  	if tracing.IsEnabled() {
    80  		ctx = tracing.StartSpan(ctx, fqdn+"/LargePersonGroupPersonClient.AddFaceFromStream")
    81  		defer func() {
    82  			sc := -1
    83  			if result.Response.Response != nil {
    84  				sc = result.Response.Response.StatusCode
    85  			}
    86  			tracing.EndSpan(ctx, sc, err)
    87  		}()
    88  	}
    89  	if err := validation.Validate([]validation.Validation{
    90  		{TargetValue: largePersonGroupID,
    91  			Constraints: []validation.Constraint{{Target: "largePersonGroupID", Name: validation.MaxLength, Rule: 64, Chain: nil},
    92  				{Target: "largePersonGroupID", Name: validation.Pattern, Rule: `^[a-z0-9-_]+$`, Chain: nil}}},
    93  		{TargetValue: userData,
    94  			Constraints: []validation.Constraint{{Target: "userData", Name: validation.Empty, Rule: false,
    95  				Chain: []validation.Constraint{{Target: "userData", Name: validation.MaxLength, Rule: 1024, Chain: nil}}}}}}); err != nil {
    96  		return result, validation.NewError("face.LargePersonGroupPersonClient", "AddFaceFromStream", err.Error())
    97  	}
    98  
    99  	req, err := client.AddFaceFromStreamPreparer(ctx, largePersonGroupID, personID, imageParameter, userData, targetFace, detectionModel)
   100  	if err != nil {
   101  		err = autorest.NewErrorWithError(err, "face.LargePersonGroupPersonClient", "AddFaceFromStream", nil, "Failure preparing request")
   102  		return
   103  	}
   104  
   105  	resp, err := client.AddFaceFromStreamSender(req)
   106  	if err != nil {
   107  		result.Response = autorest.Response{Response: resp}
   108  		err = autorest.NewErrorWithError(err, "face.LargePersonGroupPersonClient", "AddFaceFromStream", resp, "Failure sending request")
   109  		return
   110  	}
   111  
   112  	result, err = client.AddFaceFromStreamResponder(resp)
   113  	if err != nil {
   114  		err = autorest.NewErrorWithError(err, "face.LargePersonGroupPersonClient", "AddFaceFromStream", resp, "Failure responding to request")
   115  		return
   116  	}
   117  
   118  	return
   119  }
   120  
   121  // AddFaceFromStreamPreparer prepares the AddFaceFromStream request.
   122  func (client LargePersonGroupPersonClient) AddFaceFromStreamPreparer(ctx context.Context, largePersonGroupID string, personID uuid.UUID, imageParameter io.ReadCloser, userData string, targetFace []int32, detectionModel DetectionModel) (*http.Request, error) {
   123  	urlParameters := map[string]interface{}{
   124  		"Endpoint": client.Endpoint,
   125  	}
   126  
   127  	pathParameters := map[string]interface{}{
   128  		"largePersonGroupId": autorest.Encode("path", largePersonGroupID),
   129  		"personId":           autorest.Encode("path", personID),
   130  	}
   131  
   132  	queryParameters := map[string]interface{}{}
   133  	if len(userData) > 0 {
   134  		queryParameters["userData"] = autorest.Encode("query", userData)
   135  	}
   136  	if targetFace != nil && len(targetFace) > 0 {
   137  		queryParameters["targetFace"] = autorest.Encode("query", targetFace, ",")
   138  	}
   139  	if len(string(detectionModel)) > 0 {
   140  		queryParameters["detectionModel"] = autorest.Encode("query", detectionModel)
   141  	} else {
   142  		queryParameters["detectionModel"] = autorest.Encode("query", "detection_01")
   143  	}
   144  
   145  	preparer := autorest.CreatePreparer(
   146  		autorest.AsContentType("application/octet-stream"),
   147  		autorest.AsPost(),
   148  		autorest.WithCustomBaseURL("{Endpoint}/face/v1.0", urlParameters),
   149  		autorest.WithPathParameters("/largepersongroups/{largePersonGroupId}/persons/{personId}/persistedfaces", pathParameters),
   150  		autorest.WithFile(imageParameter),
   151  		autorest.WithQueryParameters(queryParameters))
   152  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   153  }
   154  
   155  // AddFaceFromStreamSender sends the AddFaceFromStream request. The method will close the
   156  // http.Response Body if it receives an error.
   157  func (client LargePersonGroupPersonClient) AddFaceFromStreamSender(req *http.Request) (*http.Response, error) {
   158  	return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
   159  }
   160  
   161  // AddFaceFromStreamResponder handles the response to the AddFaceFromStream request. The method always
   162  // closes the http.Response Body.
   163  func (client LargePersonGroupPersonClient) AddFaceFromStreamResponder(resp *http.Response) (result PersistedFace, err error) {
   164  	err = autorest.Respond(
   165  		resp,
   166  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   167  		autorest.ByUnmarshallingJSON(&result),
   168  		autorest.ByClosing())
   169  	result.Response = autorest.Response{Response: resp}
   170  	return
   171  }
   172  
   173  // AddFaceFromURL add a face to a person into a large person group for face identification or verification. To deal
   174  // with an image contains multiple faces, input face can be specified as an image with a targetFace rectangle. It
   175  // returns a persistedFaceId representing the added face. No image will be stored. Only the extracted face feature will
   176  // be stored on server until [LargePersonGroup PersonFace -
   177  // Delete](https://docs.microsoft.com/rest/api/cognitiveservices/face/largepersongroupperson/deleteface),
   178  // [LargePersonGroup Person -
   179  // Delete](https://docs.microsoft.com/rest/api/cognitiveservices/face/largepersongroupperson/delete) or
   180  // [LargePersonGroup - Delete](https://docs.microsoft.com/rest/api/cognitiveservices/face/largepersongroup/delete) is
   181  // called.
   182  // <br /> Note persistedFaceId is different from faceId generated by [Face -
   183  // Detect](https://docs.microsoft.com/rest/api/cognitiveservices/face/face/detectwithurl).
   184  // * Higher face image quality means better recognition precision. Please consider high-quality faces: frontal, clear,
   185  // and face size is 200x200 pixels (100 pixels between eyes) or bigger.
   186  // * Each person entry can hold up to 248 faces.
   187  // * JPEG, PNG, GIF (the first frame), and BMP format are supported. The allowed image file size is from 1KB to 6MB.
   188  // * "targetFace" rectangle should contain one face. Zero or multiple faces will be regarded as an error. If the
   189  // provided "targetFace" rectangle is not returned from [Face -
   190  // Detect](https://docs.microsoft.com/rest/api/cognitiveservices/face/face/detectwithurl), there’s no guarantee to
   191  // detect and add the face successfully.
   192  // * Out of detectable face size (36x36 - 4096x4096 pixels), large head-pose, or large occlusions will cause failures.
   193  // * Adding/deleting faces to/from a same person will be processed sequentially. Adding/deleting faces to/from
   194  // different persons are processed in parallel.
   195  // * The minimum detectable face size is 36x36 pixels in an image no larger than 1920x1080 pixels. Images with
   196  // dimensions higher than 1920x1080 pixels will need a proportionally larger minimum face size.
   197  // * Different 'detectionModel' values can be provided. To use and compare different detection models, please refer to
   198  // [How to specify a detection
   199  // model](https://docs.microsoft.com/azure/cognitive-services/face/face-api-how-to-topics/specify-detection-model)
   200  // | Model | Recommended use-case(s) |
   201  // | ---------- | -------- |
   202  // | 'detection_01': | The default detection model for [LargePersonGroup Person - Add
   203  // Face](https://docs.microsoft.com/rest/api/cognitiveservices/face/largepersongroupperson/addfacefromurl). Recommend
   204  // for near frontal face detection. For scenarios with exceptionally large angle (head-pose) faces, occluded faces or
   205  // wrong image orientation, the faces in such cases may not be detected. |
   206  // | 'detection_02': | Detection model released in 2019 May with improved accuracy especially on small, side and blurry
   207  // faces. |
   208  // Parameters:
   209  // largePersonGroupID - id referencing a particular large person group.
   210  // personID - id referencing a particular person.
   211  // imageURL - a JSON document with a URL pointing to the image that is to be analyzed.
   212  // userData - user-specified data about the face for any purpose. The maximum length is 1KB.
   213  // targetFace - a face rectangle to specify the target face to be added to a person in the format of
   214  // "targetFace=left,top,width,height". E.g. "targetFace=10,10,100,100". If there is more than one face in the
   215  // image, targetFace is required to specify which face to add. No targetFace means there is only one face
   216  // detected in the entire image.
   217  // detectionModel - name of detection model. Detection model is used to detect faces in the submitted image. A
   218  // detection model name can be provided when performing Face - Detect or (Large)FaceList - Add Face or
   219  // (Large)PersonGroup - Add Face. The default value is 'detection_01', if another model is needed, please
   220  // explicitly specify it.
   221  func (client LargePersonGroupPersonClient) AddFaceFromURL(ctx context.Context, largePersonGroupID string, personID uuid.UUID, imageURL ImageURL, userData string, targetFace []int32, detectionModel DetectionModel) (result PersistedFace, err error) {
   222  	if tracing.IsEnabled() {
   223  		ctx = tracing.StartSpan(ctx, fqdn+"/LargePersonGroupPersonClient.AddFaceFromURL")
   224  		defer func() {
   225  			sc := -1
   226  			if result.Response.Response != nil {
   227  				sc = result.Response.Response.StatusCode
   228  			}
   229  			tracing.EndSpan(ctx, sc, err)
   230  		}()
   231  	}
   232  	if err := validation.Validate([]validation.Validation{
   233  		{TargetValue: largePersonGroupID,
   234  			Constraints: []validation.Constraint{{Target: "largePersonGroupID", Name: validation.MaxLength, Rule: 64, Chain: nil},
   235  				{Target: "largePersonGroupID", Name: validation.Pattern, Rule: `^[a-z0-9-_]+$`, Chain: nil}}},
   236  		{TargetValue: userData,
   237  			Constraints: []validation.Constraint{{Target: "userData", Name: validation.Empty, Rule: false,
   238  				Chain: []validation.Constraint{{Target: "userData", Name: validation.MaxLength, Rule: 1024, Chain: nil}}}}},
   239  		{TargetValue: imageURL,
   240  			Constraints: []validation.Constraint{{Target: "imageURL.URL", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil {
   241  		return result, validation.NewError("face.LargePersonGroupPersonClient", "AddFaceFromURL", err.Error())
   242  	}
   243  
   244  	req, err := client.AddFaceFromURLPreparer(ctx, largePersonGroupID, personID, imageURL, userData, targetFace, detectionModel)
   245  	if err != nil {
   246  		err = autorest.NewErrorWithError(err, "face.LargePersonGroupPersonClient", "AddFaceFromURL", nil, "Failure preparing request")
   247  		return
   248  	}
   249  
   250  	resp, err := client.AddFaceFromURLSender(req)
   251  	if err != nil {
   252  		result.Response = autorest.Response{Response: resp}
   253  		err = autorest.NewErrorWithError(err, "face.LargePersonGroupPersonClient", "AddFaceFromURL", resp, "Failure sending request")
   254  		return
   255  	}
   256  
   257  	result, err = client.AddFaceFromURLResponder(resp)
   258  	if err != nil {
   259  		err = autorest.NewErrorWithError(err, "face.LargePersonGroupPersonClient", "AddFaceFromURL", resp, "Failure responding to request")
   260  		return
   261  	}
   262  
   263  	return
   264  }
   265  
   266  // AddFaceFromURLPreparer prepares the AddFaceFromURL request.
   267  func (client LargePersonGroupPersonClient) AddFaceFromURLPreparer(ctx context.Context, largePersonGroupID string, personID uuid.UUID, imageURL ImageURL, userData string, targetFace []int32, detectionModel DetectionModel) (*http.Request, error) {
   268  	urlParameters := map[string]interface{}{
   269  		"Endpoint": client.Endpoint,
   270  	}
   271  
   272  	pathParameters := map[string]interface{}{
   273  		"largePersonGroupId": autorest.Encode("path", largePersonGroupID),
   274  		"personId":           autorest.Encode("path", personID),
   275  	}
   276  
   277  	queryParameters := map[string]interface{}{}
   278  	if len(userData) > 0 {
   279  		queryParameters["userData"] = autorest.Encode("query", userData)
   280  	}
   281  	if targetFace != nil && len(targetFace) > 0 {
   282  		queryParameters["targetFace"] = autorest.Encode("query", targetFace, ",")
   283  	}
   284  	if len(string(detectionModel)) > 0 {
   285  		queryParameters["detectionModel"] = autorest.Encode("query", detectionModel)
   286  	} else {
   287  		queryParameters["detectionModel"] = autorest.Encode("query", "detection_01")
   288  	}
   289  
   290  	preparer := autorest.CreatePreparer(
   291  		autorest.AsContentType("application/json; charset=utf-8"),
   292  		autorest.AsPost(),
   293  		autorest.WithCustomBaseURL("{Endpoint}/face/v1.0", urlParameters),
   294  		autorest.WithPathParameters("/largepersongroups/{largePersonGroupId}/persons/{personId}/persistedfaces", pathParameters),
   295  		autorest.WithJSON(imageURL),
   296  		autorest.WithQueryParameters(queryParameters))
   297  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   298  }
   299  
   300  // AddFaceFromURLSender sends the AddFaceFromURL request. The method will close the
   301  // http.Response Body if it receives an error.
   302  func (client LargePersonGroupPersonClient) AddFaceFromURLSender(req *http.Request) (*http.Response, error) {
   303  	return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
   304  }
   305  
   306  // AddFaceFromURLResponder handles the response to the AddFaceFromURL request. The method always
   307  // closes the http.Response Body.
   308  func (client LargePersonGroupPersonClient) AddFaceFromURLResponder(resp *http.Response) (result PersistedFace, err error) {
   309  	err = autorest.Respond(
   310  		resp,
   311  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   312  		autorest.ByUnmarshallingJSON(&result),
   313  		autorest.ByClosing())
   314  	result.Response = autorest.Response{Response: resp}
   315  	return
   316  }
   317  
   318  // Create create a new person in a specified large person group.
   319  // Parameters:
   320  // largePersonGroupID - id referencing a particular large person group.
   321  // body - request body for creating new person.
   322  func (client LargePersonGroupPersonClient) Create(ctx context.Context, largePersonGroupID string, body NameAndUserDataContract) (result Person, err error) {
   323  	if tracing.IsEnabled() {
   324  		ctx = tracing.StartSpan(ctx, fqdn+"/LargePersonGroupPersonClient.Create")
   325  		defer func() {
   326  			sc := -1
   327  			if result.Response.Response != nil {
   328  				sc = result.Response.Response.StatusCode
   329  			}
   330  			tracing.EndSpan(ctx, sc, err)
   331  		}()
   332  	}
   333  	if err := validation.Validate([]validation.Validation{
   334  		{TargetValue: largePersonGroupID,
   335  			Constraints: []validation.Constraint{{Target: "largePersonGroupID", Name: validation.MaxLength, Rule: 64, Chain: nil},
   336  				{Target: "largePersonGroupID", Name: validation.Pattern, Rule: `^[a-z0-9-_]+$`, Chain: nil}}},
   337  		{TargetValue: body,
   338  			Constraints: []validation.Constraint{{Target: "body.Name", Name: validation.Null, Rule: false,
   339  				Chain: []validation.Constraint{{Target: "body.Name", Name: validation.MaxLength, Rule: 128, Chain: nil}}},
   340  				{Target: "body.UserData", Name: validation.Null, Rule: false,
   341  					Chain: []validation.Constraint{{Target: "body.UserData", Name: validation.MaxLength, Rule: 16384, Chain: nil}}}}}}); err != nil {
   342  		return result, validation.NewError("face.LargePersonGroupPersonClient", "Create", err.Error())
   343  	}
   344  
   345  	req, err := client.CreatePreparer(ctx, largePersonGroupID, body)
   346  	if err != nil {
   347  		err = autorest.NewErrorWithError(err, "face.LargePersonGroupPersonClient", "Create", nil, "Failure preparing request")
   348  		return
   349  	}
   350  
   351  	resp, err := client.CreateSender(req)
   352  	if err != nil {
   353  		result.Response = autorest.Response{Response: resp}
   354  		err = autorest.NewErrorWithError(err, "face.LargePersonGroupPersonClient", "Create", resp, "Failure sending request")
   355  		return
   356  	}
   357  
   358  	result, err = client.CreateResponder(resp)
   359  	if err != nil {
   360  		err = autorest.NewErrorWithError(err, "face.LargePersonGroupPersonClient", "Create", resp, "Failure responding to request")
   361  		return
   362  	}
   363  
   364  	return
   365  }
   366  
   367  // CreatePreparer prepares the Create request.
   368  func (client LargePersonGroupPersonClient) CreatePreparer(ctx context.Context, largePersonGroupID string, body NameAndUserDataContract) (*http.Request, error) {
   369  	urlParameters := map[string]interface{}{
   370  		"Endpoint": client.Endpoint,
   371  	}
   372  
   373  	pathParameters := map[string]interface{}{
   374  		"largePersonGroupId": autorest.Encode("path", largePersonGroupID),
   375  	}
   376  
   377  	preparer := autorest.CreatePreparer(
   378  		autorest.AsContentType("application/json; charset=utf-8"),
   379  		autorest.AsPost(),
   380  		autorest.WithCustomBaseURL("{Endpoint}/face/v1.0", urlParameters),
   381  		autorest.WithPathParameters("/largepersongroups/{largePersonGroupId}/persons", pathParameters),
   382  		autorest.WithJSON(body))
   383  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   384  }
   385  
   386  // CreateSender sends the Create request. The method will close the
   387  // http.Response Body if it receives an error.
   388  func (client LargePersonGroupPersonClient) CreateSender(req *http.Request) (*http.Response, error) {
   389  	return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
   390  }
   391  
   392  // CreateResponder handles the response to the Create request. The method always
   393  // closes the http.Response Body.
   394  func (client LargePersonGroupPersonClient) CreateResponder(resp *http.Response) (result Person, err error) {
   395  	err = autorest.Respond(
   396  		resp,
   397  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   398  		autorest.ByUnmarshallingJSON(&result),
   399  		autorest.ByClosing())
   400  	result.Response = autorest.Response{Response: resp}
   401  	return
   402  }
   403  
   404  // Delete delete an existing person from a large person group. The persistedFaceId, userData, person name and face
   405  // feature in the person entry will all be deleted.
   406  // Parameters:
   407  // largePersonGroupID - id referencing a particular large person group.
   408  // personID - id referencing a particular person.
   409  func (client LargePersonGroupPersonClient) Delete(ctx context.Context, largePersonGroupID string, personID uuid.UUID) (result autorest.Response, err error) {
   410  	if tracing.IsEnabled() {
   411  		ctx = tracing.StartSpan(ctx, fqdn+"/LargePersonGroupPersonClient.Delete")
   412  		defer func() {
   413  			sc := -1
   414  			if result.Response != nil {
   415  				sc = result.Response.StatusCode
   416  			}
   417  			tracing.EndSpan(ctx, sc, err)
   418  		}()
   419  	}
   420  	if err := validation.Validate([]validation.Validation{
   421  		{TargetValue: largePersonGroupID,
   422  			Constraints: []validation.Constraint{{Target: "largePersonGroupID", Name: validation.MaxLength, Rule: 64, Chain: nil},
   423  				{Target: "largePersonGroupID", Name: validation.Pattern, Rule: `^[a-z0-9-_]+$`, Chain: nil}}}}); err != nil {
   424  		return result, validation.NewError("face.LargePersonGroupPersonClient", "Delete", err.Error())
   425  	}
   426  
   427  	req, err := client.DeletePreparer(ctx, largePersonGroupID, personID)
   428  	if err != nil {
   429  		err = autorest.NewErrorWithError(err, "face.LargePersonGroupPersonClient", "Delete", nil, "Failure preparing request")
   430  		return
   431  	}
   432  
   433  	resp, err := client.DeleteSender(req)
   434  	if err != nil {
   435  		result.Response = resp
   436  		err = autorest.NewErrorWithError(err, "face.LargePersonGroupPersonClient", "Delete", resp, "Failure sending request")
   437  		return
   438  	}
   439  
   440  	result, err = client.DeleteResponder(resp)
   441  	if err != nil {
   442  		err = autorest.NewErrorWithError(err, "face.LargePersonGroupPersonClient", "Delete", resp, "Failure responding to request")
   443  		return
   444  	}
   445  
   446  	return
   447  }
   448  
   449  // DeletePreparer prepares the Delete request.
   450  func (client LargePersonGroupPersonClient) DeletePreparer(ctx context.Context, largePersonGroupID string, personID uuid.UUID) (*http.Request, error) {
   451  	urlParameters := map[string]interface{}{
   452  		"Endpoint": client.Endpoint,
   453  	}
   454  
   455  	pathParameters := map[string]interface{}{
   456  		"largePersonGroupId": autorest.Encode("path", largePersonGroupID),
   457  		"personId":           autorest.Encode("path", personID),
   458  	}
   459  
   460  	preparer := autorest.CreatePreparer(
   461  		autorest.AsDelete(),
   462  		autorest.WithCustomBaseURL("{Endpoint}/face/v1.0", urlParameters),
   463  		autorest.WithPathParameters("/largepersongroups/{largePersonGroupId}/persons/{personId}", pathParameters))
   464  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   465  }
   466  
   467  // DeleteSender sends the Delete request. The method will close the
   468  // http.Response Body if it receives an error.
   469  func (client LargePersonGroupPersonClient) DeleteSender(req *http.Request) (*http.Response, error) {
   470  	return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
   471  }
   472  
   473  // DeleteResponder handles the response to the Delete request. The method always
   474  // closes the http.Response Body.
   475  func (client LargePersonGroupPersonClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) {
   476  	err = autorest.Respond(
   477  		resp,
   478  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   479  		autorest.ByClosing())
   480  	result.Response = resp
   481  	return
   482  }
   483  
   484  // DeleteFace delete a face from a person in a large person group by specified largePersonGroupId, personId and
   485  // persistedFaceId.
   486  // <br /> Adding/deleting faces to/from a same person will be processed sequentially. Adding/deleting faces to/from
   487  // different persons are processed in parallel.
   488  // Parameters:
   489  // largePersonGroupID - id referencing a particular large person group.
   490  // personID - id referencing a particular person.
   491  // persistedFaceID - id referencing a particular persistedFaceId of an existing face.
   492  func (client LargePersonGroupPersonClient) DeleteFace(ctx context.Context, largePersonGroupID string, personID uuid.UUID, persistedFaceID uuid.UUID) (result autorest.Response, err error) {
   493  	if tracing.IsEnabled() {
   494  		ctx = tracing.StartSpan(ctx, fqdn+"/LargePersonGroupPersonClient.DeleteFace")
   495  		defer func() {
   496  			sc := -1
   497  			if result.Response != nil {
   498  				sc = result.Response.StatusCode
   499  			}
   500  			tracing.EndSpan(ctx, sc, err)
   501  		}()
   502  	}
   503  	if err := validation.Validate([]validation.Validation{
   504  		{TargetValue: largePersonGroupID,
   505  			Constraints: []validation.Constraint{{Target: "largePersonGroupID", Name: validation.MaxLength, Rule: 64, Chain: nil},
   506  				{Target: "largePersonGroupID", Name: validation.Pattern, Rule: `^[a-z0-9-_]+$`, Chain: nil}}}}); err != nil {
   507  		return result, validation.NewError("face.LargePersonGroupPersonClient", "DeleteFace", err.Error())
   508  	}
   509  
   510  	req, err := client.DeleteFacePreparer(ctx, largePersonGroupID, personID, persistedFaceID)
   511  	if err != nil {
   512  		err = autorest.NewErrorWithError(err, "face.LargePersonGroupPersonClient", "DeleteFace", nil, "Failure preparing request")
   513  		return
   514  	}
   515  
   516  	resp, err := client.DeleteFaceSender(req)
   517  	if err != nil {
   518  		result.Response = resp
   519  		err = autorest.NewErrorWithError(err, "face.LargePersonGroupPersonClient", "DeleteFace", resp, "Failure sending request")
   520  		return
   521  	}
   522  
   523  	result, err = client.DeleteFaceResponder(resp)
   524  	if err != nil {
   525  		err = autorest.NewErrorWithError(err, "face.LargePersonGroupPersonClient", "DeleteFace", resp, "Failure responding to request")
   526  		return
   527  	}
   528  
   529  	return
   530  }
   531  
   532  // DeleteFacePreparer prepares the DeleteFace request.
   533  func (client LargePersonGroupPersonClient) DeleteFacePreparer(ctx context.Context, largePersonGroupID string, personID uuid.UUID, persistedFaceID uuid.UUID) (*http.Request, error) {
   534  	urlParameters := map[string]interface{}{
   535  		"Endpoint": client.Endpoint,
   536  	}
   537  
   538  	pathParameters := map[string]interface{}{
   539  		"largePersonGroupId": autorest.Encode("path", largePersonGroupID),
   540  		"persistedFaceId":    autorest.Encode("path", persistedFaceID),
   541  		"personId":           autorest.Encode("path", personID),
   542  	}
   543  
   544  	preparer := autorest.CreatePreparer(
   545  		autorest.AsDelete(),
   546  		autorest.WithCustomBaseURL("{Endpoint}/face/v1.0", urlParameters),
   547  		autorest.WithPathParameters("/largepersongroups/{largePersonGroupId}/persons/{personId}/persistedfaces/{persistedFaceId}", pathParameters))
   548  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   549  }
   550  
   551  // DeleteFaceSender sends the DeleteFace request. The method will close the
   552  // http.Response Body if it receives an error.
   553  func (client LargePersonGroupPersonClient) DeleteFaceSender(req *http.Request) (*http.Response, error) {
   554  	return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
   555  }
   556  
   557  // DeleteFaceResponder handles the response to the DeleteFace request. The method always
   558  // closes the http.Response Body.
   559  func (client LargePersonGroupPersonClient) DeleteFaceResponder(resp *http.Response) (result autorest.Response, err error) {
   560  	err = autorest.Respond(
   561  		resp,
   562  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   563  		autorest.ByClosing())
   564  	result.Response = resp
   565  	return
   566  }
   567  
   568  // Get retrieve a person's name and userData, and the persisted faceIds representing the registered person face
   569  // feature.
   570  // Parameters:
   571  // largePersonGroupID - id referencing a particular large person group.
   572  // personID - id referencing a particular person.
   573  func (client LargePersonGroupPersonClient) Get(ctx context.Context, largePersonGroupID string, personID uuid.UUID) (result Person, err error) {
   574  	if tracing.IsEnabled() {
   575  		ctx = tracing.StartSpan(ctx, fqdn+"/LargePersonGroupPersonClient.Get")
   576  		defer func() {
   577  			sc := -1
   578  			if result.Response.Response != nil {
   579  				sc = result.Response.Response.StatusCode
   580  			}
   581  			tracing.EndSpan(ctx, sc, err)
   582  		}()
   583  	}
   584  	if err := validation.Validate([]validation.Validation{
   585  		{TargetValue: largePersonGroupID,
   586  			Constraints: []validation.Constraint{{Target: "largePersonGroupID", Name: validation.MaxLength, Rule: 64, Chain: nil},
   587  				{Target: "largePersonGroupID", Name: validation.Pattern, Rule: `^[a-z0-9-_]+$`, Chain: nil}}}}); err != nil {
   588  		return result, validation.NewError("face.LargePersonGroupPersonClient", "Get", err.Error())
   589  	}
   590  
   591  	req, err := client.GetPreparer(ctx, largePersonGroupID, personID)
   592  	if err != nil {
   593  		err = autorest.NewErrorWithError(err, "face.LargePersonGroupPersonClient", "Get", nil, "Failure preparing request")
   594  		return
   595  	}
   596  
   597  	resp, err := client.GetSender(req)
   598  	if err != nil {
   599  		result.Response = autorest.Response{Response: resp}
   600  		err = autorest.NewErrorWithError(err, "face.LargePersonGroupPersonClient", "Get", resp, "Failure sending request")
   601  		return
   602  	}
   603  
   604  	result, err = client.GetResponder(resp)
   605  	if err != nil {
   606  		err = autorest.NewErrorWithError(err, "face.LargePersonGroupPersonClient", "Get", resp, "Failure responding to request")
   607  		return
   608  	}
   609  
   610  	return
   611  }
   612  
   613  // GetPreparer prepares the Get request.
   614  func (client LargePersonGroupPersonClient) GetPreparer(ctx context.Context, largePersonGroupID string, personID uuid.UUID) (*http.Request, error) {
   615  	urlParameters := map[string]interface{}{
   616  		"Endpoint": client.Endpoint,
   617  	}
   618  
   619  	pathParameters := map[string]interface{}{
   620  		"largePersonGroupId": autorest.Encode("path", largePersonGroupID),
   621  		"personId":           autorest.Encode("path", personID),
   622  	}
   623  
   624  	preparer := autorest.CreatePreparer(
   625  		autorest.AsGet(),
   626  		autorest.WithCustomBaseURL("{Endpoint}/face/v1.0", urlParameters),
   627  		autorest.WithPathParameters("/largepersongroups/{largePersonGroupId}/persons/{personId}", pathParameters))
   628  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   629  }
   630  
   631  // GetSender sends the Get request. The method will close the
   632  // http.Response Body if it receives an error.
   633  func (client LargePersonGroupPersonClient) GetSender(req *http.Request) (*http.Response, error) {
   634  	return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
   635  }
   636  
   637  // GetResponder handles the response to the Get request. The method always
   638  // closes the http.Response Body.
   639  func (client LargePersonGroupPersonClient) GetResponder(resp *http.Response) (result Person, err error) {
   640  	err = autorest.Respond(
   641  		resp,
   642  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   643  		autorest.ByUnmarshallingJSON(&result),
   644  		autorest.ByClosing())
   645  	result.Response = autorest.Response{Response: resp}
   646  	return
   647  }
   648  
   649  // GetFace retrieve information about a persisted face (specified by persistedFaceId, personId and its belonging
   650  // largePersonGroupId).
   651  // Parameters:
   652  // largePersonGroupID - id referencing a particular large person group.
   653  // personID - id referencing a particular person.
   654  // persistedFaceID - id referencing a particular persistedFaceId of an existing face.
   655  func (client LargePersonGroupPersonClient) GetFace(ctx context.Context, largePersonGroupID string, personID uuid.UUID, persistedFaceID uuid.UUID) (result PersistedFace, err error) {
   656  	if tracing.IsEnabled() {
   657  		ctx = tracing.StartSpan(ctx, fqdn+"/LargePersonGroupPersonClient.GetFace")
   658  		defer func() {
   659  			sc := -1
   660  			if result.Response.Response != nil {
   661  				sc = result.Response.Response.StatusCode
   662  			}
   663  			tracing.EndSpan(ctx, sc, err)
   664  		}()
   665  	}
   666  	if err := validation.Validate([]validation.Validation{
   667  		{TargetValue: largePersonGroupID,
   668  			Constraints: []validation.Constraint{{Target: "largePersonGroupID", Name: validation.MaxLength, Rule: 64, Chain: nil},
   669  				{Target: "largePersonGroupID", Name: validation.Pattern, Rule: `^[a-z0-9-_]+$`, Chain: nil}}}}); err != nil {
   670  		return result, validation.NewError("face.LargePersonGroupPersonClient", "GetFace", err.Error())
   671  	}
   672  
   673  	req, err := client.GetFacePreparer(ctx, largePersonGroupID, personID, persistedFaceID)
   674  	if err != nil {
   675  		err = autorest.NewErrorWithError(err, "face.LargePersonGroupPersonClient", "GetFace", nil, "Failure preparing request")
   676  		return
   677  	}
   678  
   679  	resp, err := client.GetFaceSender(req)
   680  	if err != nil {
   681  		result.Response = autorest.Response{Response: resp}
   682  		err = autorest.NewErrorWithError(err, "face.LargePersonGroupPersonClient", "GetFace", resp, "Failure sending request")
   683  		return
   684  	}
   685  
   686  	result, err = client.GetFaceResponder(resp)
   687  	if err != nil {
   688  		err = autorest.NewErrorWithError(err, "face.LargePersonGroupPersonClient", "GetFace", resp, "Failure responding to request")
   689  		return
   690  	}
   691  
   692  	return
   693  }
   694  
   695  // GetFacePreparer prepares the GetFace request.
   696  func (client LargePersonGroupPersonClient) GetFacePreparer(ctx context.Context, largePersonGroupID string, personID uuid.UUID, persistedFaceID uuid.UUID) (*http.Request, error) {
   697  	urlParameters := map[string]interface{}{
   698  		"Endpoint": client.Endpoint,
   699  	}
   700  
   701  	pathParameters := map[string]interface{}{
   702  		"largePersonGroupId": autorest.Encode("path", largePersonGroupID),
   703  		"persistedFaceId":    autorest.Encode("path", persistedFaceID),
   704  		"personId":           autorest.Encode("path", personID),
   705  	}
   706  
   707  	preparer := autorest.CreatePreparer(
   708  		autorest.AsGet(),
   709  		autorest.WithCustomBaseURL("{Endpoint}/face/v1.0", urlParameters),
   710  		autorest.WithPathParameters("/largepersongroups/{largePersonGroupId}/persons/{personId}/persistedfaces/{persistedFaceId}", pathParameters))
   711  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   712  }
   713  
   714  // GetFaceSender sends the GetFace request. The method will close the
   715  // http.Response Body if it receives an error.
   716  func (client LargePersonGroupPersonClient) GetFaceSender(req *http.Request) (*http.Response, error) {
   717  	return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
   718  }
   719  
   720  // GetFaceResponder handles the response to the GetFace request. The method always
   721  // closes the http.Response Body.
   722  func (client LargePersonGroupPersonClient) GetFaceResponder(resp *http.Response) (result PersistedFace, err error) {
   723  	err = autorest.Respond(
   724  		resp,
   725  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   726  		autorest.ByUnmarshallingJSON(&result),
   727  		autorest.ByClosing())
   728  	result.Response = autorest.Response{Response: resp}
   729  	return
   730  }
   731  
   732  // List list all persons in a large person group, and retrieve person information (including personId, name, userData
   733  // and persistedFaceIds of registered faces of the person).
   734  // Parameters:
   735  // largePersonGroupID - id referencing a particular large person group.
   736  // start - starting person id to return (used to list a range of persons).
   737  // top - number of persons to return starting with the person id indicated by the 'start' parameter.
   738  func (client LargePersonGroupPersonClient) List(ctx context.Context, largePersonGroupID string, start string, top *int32) (result ListPerson, err error) {
   739  	if tracing.IsEnabled() {
   740  		ctx = tracing.StartSpan(ctx, fqdn+"/LargePersonGroupPersonClient.List")
   741  		defer func() {
   742  			sc := -1
   743  			if result.Response.Response != nil {
   744  				sc = result.Response.Response.StatusCode
   745  			}
   746  			tracing.EndSpan(ctx, sc, err)
   747  		}()
   748  	}
   749  	if err := validation.Validate([]validation.Validation{
   750  		{TargetValue: largePersonGroupID,
   751  			Constraints: []validation.Constraint{{Target: "largePersonGroupID", Name: validation.MaxLength, Rule: 64, Chain: nil},
   752  				{Target: "largePersonGroupID", Name: validation.Pattern, Rule: `^[a-z0-9-_]+$`, Chain: nil}}},
   753  		{TargetValue: top,
   754  			Constraints: []validation.Constraint{{Target: "top", Name: validation.Null, Rule: false,
   755  				Chain: []validation.Constraint{{Target: "top", Name: validation.InclusiveMaximum, Rule: int64(1000), Chain: nil},
   756  					{Target: "top", Name: validation.InclusiveMinimum, Rule: int64(1), Chain: nil},
   757  				}}}}}); err != nil {
   758  		return result, validation.NewError("face.LargePersonGroupPersonClient", "List", err.Error())
   759  	}
   760  
   761  	req, err := client.ListPreparer(ctx, largePersonGroupID, start, top)
   762  	if err != nil {
   763  		err = autorest.NewErrorWithError(err, "face.LargePersonGroupPersonClient", "List", nil, "Failure preparing request")
   764  		return
   765  	}
   766  
   767  	resp, err := client.ListSender(req)
   768  	if err != nil {
   769  		result.Response = autorest.Response{Response: resp}
   770  		err = autorest.NewErrorWithError(err, "face.LargePersonGroupPersonClient", "List", resp, "Failure sending request")
   771  		return
   772  	}
   773  
   774  	result, err = client.ListResponder(resp)
   775  	if err != nil {
   776  		err = autorest.NewErrorWithError(err, "face.LargePersonGroupPersonClient", "List", resp, "Failure responding to request")
   777  		return
   778  	}
   779  
   780  	return
   781  }
   782  
   783  // ListPreparer prepares the List request.
   784  func (client LargePersonGroupPersonClient) ListPreparer(ctx context.Context, largePersonGroupID string, start string, top *int32) (*http.Request, error) {
   785  	urlParameters := map[string]interface{}{
   786  		"Endpoint": client.Endpoint,
   787  	}
   788  
   789  	pathParameters := map[string]interface{}{
   790  		"largePersonGroupId": autorest.Encode("path", largePersonGroupID),
   791  	}
   792  
   793  	queryParameters := map[string]interface{}{}
   794  	if len(start) > 0 {
   795  		queryParameters["start"] = autorest.Encode("query", start)
   796  	}
   797  	if top != nil {
   798  		queryParameters["top"] = autorest.Encode("query", *top)
   799  	}
   800  
   801  	preparer := autorest.CreatePreparer(
   802  		autorest.AsGet(),
   803  		autorest.WithCustomBaseURL("{Endpoint}/face/v1.0", urlParameters),
   804  		autorest.WithPathParameters("/largepersongroups/{largePersonGroupId}/persons", pathParameters),
   805  		autorest.WithQueryParameters(queryParameters))
   806  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   807  }
   808  
   809  // ListSender sends the List request. The method will close the
   810  // http.Response Body if it receives an error.
   811  func (client LargePersonGroupPersonClient) ListSender(req *http.Request) (*http.Response, error) {
   812  	return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
   813  }
   814  
   815  // ListResponder handles the response to the List request. The method always
   816  // closes the http.Response Body.
   817  func (client LargePersonGroupPersonClient) ListResponder(resp *http.Response) (result ListPerson, err error) {
   818  	err = autorest.Respond(
   819  		resp,
   820  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   821  		autorest.ByUnmarshallingJSON(&result.Value),
   822  		autorest.ByClosing())
   823  	result.Response = autorest.Response{Response: resp}
   824  	return
   825  }
   826  
   827  // Update update name or userData of a person.
   828  // Parameters:
   829  // largePersonGroupID - id referencing a particular large person group.
   830  // personID - id referencing a particular person.
   831  // body - request body for person update operation.
   832  func (client LargePersonGroupPersonClient) Update(ctx context.Context, largePersonGroupID string, personID uuid.UUID, body NameAndUserDataContract) (result autorest.Response, err error) {
   833  	if tracing.IsEnabled() {
   834  		ctx = tracing.StartSpan(ctx, fqdn+"/LargePersonGroupPersonClient.Update")
   835  		defer func() {
   836  			sc := -1
   837  			if result.Response != nil {
   838  				sc = result.Response.StatusCode
   839  			}
   840  			tracing.EndSpan(ctx, sc, err)
   841  		}()
   842  	}
   843  	if err := validation.Validate([]validation.Validation{
   844  		{TargetValue: largePersonGroupID,
   845  			Constraints: []validation.Constraint{{Target: "largePersonGroupID", Name: validation.MaxLength, Rule: 64, Chain: nil},
   846  				{Target: "largePersonGroupID", Name: validation.Pattern, Rule: `^[a-z0-9-_]+$`, Chain: nil}}}}); err != nil {
   847  		return result, validation.NewError("face.LargePersonGroupPersonClient", "Update", err.Error())
   848  	}
   849  
   850  	req, err := client.UpdatePreparer(ctx, largePersonGroupID, personID, body)
   851  	if err != nil {
   852  		err = autorest.NewErrorWithError(err, "face.LargePersonGroupPersonClient", "Update", nil, "Failure preparing request")
   853  		return
   854  	}
   855  
   856  	resp, err := client.UpdateSender(req)
   857  	if err != nil {
   858  		result.Response = resp
   859  		err = autorest.NewErrorWithError(err, "face.LargePersonGroupPersonClient", "Update", resp, "Failure sending request")
   860  		return
   861  	}
   862  
   863  	result, err = client.UpdateResponder(resp)
   864  	if err != nil {
   865  		err = autorest.NewErrorWithError(err, "face.LargePersonGroupPersonClient", "Update", resp, "Failure responding to request")
   866  		return
   867  	}
   868  
   869  	return
   870  }
   871  
   872  // UpdatePreparer prepares the Update request.
   873  func (client LargePersonGroupPersonClient) UpdatePreparer(ctx context.Context, largePersonGroupID string, personID uuid.UUID, body NameAndUserDataContract) (*http.Request, error) {
   874  	urlParameters := map[string]interface{}{
   875  		"Endpoint": client.Endpoint,
   876  	}
   877  
   878  	pathParameters := map[string]interface{}{
   879  		"largePersonGroupId": autorest.Encode("path", largePersonGroupID),
   880  		"personId":           autorest.Encode("path", personID),
   881  	}
   882  
   883  	preparer := autorest.CreatePreparer(
   884  		autorest.AsContentType("application/json; charset=utf-8"),
   885  		autorest.AsPatch(),
   886  		autorest.WithCustomBaseURL("{Endpoint}/face/v1.0", urlParameters),
   887  		autorest.WithPathParameters("/largepersongroups/{largePersonGroupId}/persons/{personId}", pathParameters),
   888  		autorest.WithJSON(body))
   889  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   890  }
   891  
   892  // UpdateSender sends the Update request. The method will close the
   893  // http.Response Body if it receives an error.
   894  func (client LargePersonGroupPersonClient) UpdateSender(req *http.Request) (*http.Response, error) {
   895  	return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
   896  }
   897  
   898  // UpdateResponder handles the response to the Update request. The method always
   899  // closes the http.Response Body.
   900  func (client LargePersonGroupPersonClient) UpdateResponder(resp *http.Response) (result autorest.Response, err error) {
   901  	err = autorest.Respond(
   902  		resp,
   903  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   904  		autorest.ByClosing())
   905  	result.Response = resp
   906  	return
   907  }
   908  
   909  // UpdateFace update a person persisted face's userData field.
   910  // Parameters:
   911  // largePersonGroupID - id referencing a particular large person group.
   912  // personID - id referencing a particular person.
   913  // persistedFaceID - id referencing a particular persistedFaceId of an existing face.
   914  // body - request body for updating persisted face.
   915  func (client LargePersonGroupPersonClient) UpdateFace(ctx context.Context, largePersonGroupID string, personID uuid.UUID, persistedFaceID uuid.UUID, body UpdateFaceRequest) (result autorest.Response, err error) {
   916  	if tracing.IsEnabled() {
   917  		ctx = tracing.StartSpan(ctx, fqdn+"/LargePersonGroupPersonClient.UpdateFace")
   918  		defer func() {
   919  			sc := -1
   920  			if result.Response != nil {
   921  				sc = result.Response.StatusCode
   922  			}
   923  			tracing.EndSpan(ctx, sc, err)
   924  		}()
   925  	}
   926  	if err := validation.Validate([]validation.Validation{
   927  		{TargetValue: largePersonGroupID,
   928  			Constraints: []validation.Constraint{{Target: "largePersonGroupID", Name: validation.MaxLength, Rule: 64, Chain: nil},
   929  				{Target: "largePersonGroupID", Name: validation.Pattern, Rule: `^[a-z0-9-_]+$`, Chain: nil}}}}); err != nil {
   930  		return result, validation.NewError("face.LargePersonGroupPersonClient", "UpdateFace", err.Error())
   931  	}
   932  
   933  	req, err := client.UpdateFacePreparer(ctx, largePersonGroupID, personID, persistedFaceID, body)
   934  	if err != nil {
   935  		err = autorest.NewErrorWithError(err, "face.LargePersonGroupPersonClient", "UpdateFace", nil, "Failure preparing request")
   936  		return
   937  	}
   938  
   939  	resp, err := client.UpdateFaceSender(req)
   940  	if err != nil {
   941  		result.Response = resp
   942  		err = autorest.NewErrorWithError(err, "face.LargePersonGroupPersonClient", "UpdateFace", resp, "Failure sending request")
   943  		return
   944  	}
   945  
   946  	result, err = client.UpdateFaceResponder(resp)
   947  	if err != nil {
   948  		err = autorest.NewErrorWithError(err, "face.LargePersonGroupPersonClient", "UpdateFace", resp, "Failure responding to request")
   949  		return
   950  	}
   951  
   952  	return
   953  }
   954  
   955  // UpdateFacePreparer prepares the UpdateFace request.
   956  func (client LargePersonGroupPersonClient) UpdateFacePreparer(ctx context.Context, largePersonGroupID string, personID uuid.UUID, persistedFaceID uuid.UUID, body UpdateFaceRequest) (*http.Request, error) {
   957  	urlParameters := map[string]interface{}{
   958  		"Endpoint": client.Endpoint,
   959  	}
   960  
   961  	pathParameters := map[string]interface{}{
   962  		"largePersonGroupId": autorest.Encode("path", largePersonGroupID),
   963  		"persistedFaceId":    autorest.Encode("path", persistedFaceID),
   964  		"personId":           autorest.Encode("path", personID),
   965  	}
   966  
   967  	preparer := autorest.CreatePreparer(
   968  		autorest.AsContentType("application/json; charset=utf-8"),
   969  		autorest.AsPatch(),
   970  		autorest.WithCustomBaseURL("{Endpoint}/face/v1.0", urlParameters),
   971  		autorest.WithPathParameters("/largepersongroups/{largePersonGroupId}/persons/{personId}/persistedfaces/{persistedFaceId}", pathParameters),
   972  		autorest.WithJSON(body))
   973  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   974  }
   975  
   976  // UpdateFaceSender sends the UpdateFace request. The method will close the
   977  // http.Response Body if it receives an error.
   978  func (client LargePersonGroupPersonClient) UpdateFaceSender(req *http.Request) (*http.Response, error) {
   979  	return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
   980  }
   981  
   982  // UpdateFaceResponder handles the response to the UpdateFace request. The method always
   983  // closes the http.Response Body.
   984  func (client LargePersonGroupPersonClient) UpdateFaceResponder(resp *http.Response) (result autorest.Response, err error) {
   985  	err = autorest.Respond(
   986  		resp,
   987  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   988  		autorest.ByClosing())
   989  	result.Response = resp
   990  	return
   991  }
   992  

View as plain text