1 package face
2
3
4
5
6
7
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
21 type ListClient struct {
22 BaseClient
23 }
24
25
26 func NewListClient(endpoint string) ListClient {
27 return ListClient{New(endpoint)}
28 }
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73 func (client ListClient) AddFaceFromStream(ctx context.Context, faceListID string, imageParameter io.ReadCloser, userData string, targetFace []int32, detectionModel DetectionModel) (result PersistedFace, err error) {
74 if tracing.IsEnabled() {
75 ctx = tracing.StartSpan(ctx, fqdn+"/ListClient.AddFaceFromStream")
76 defer func() {
77 sc := -1
78 if result.Response.Response != nil {
79 sc = result.Response.Response.StatusCode
80 }
81 tracing.EndSpan(ctx, sc, err)
82 }()
83 }
84 if err := validation.Validate([]validation.Validation{
85 {TargetValue: faceListID,
86 Constraints: []validation.Constraint{{Target: "faceListID", Name: validation.MaxLength, Rule: 64, Chain: nil},
87 {Target: "faceListID", Name: validation.Pattern, Rule: `^[a-z0-9-_]+$`, Chain: nil}}},
88 {TargetValue: userData,
89 Constraints: []validation.Constraint{{Target: "userData", Name: validation.Empty, Rule: false,
90 Chain: []validation.Constraint{{Target: "userData", Name: validation.MaxLength, Rule: 1024, Chain: nil}}}}}}); err != nil {
91 return result, validation.NewError("face.ListClient", "AddFaceFromStream", err.Error())
92 }
93
94 req, err := client.AddFaceFromStreamPreparer(ctx, faceListID, imageParameter, userData, targetFace, detectionModel)
95 if err != nil {
96 err = autorest.NewErrorWithError(err, "face.ListClient", "AddFaceFromStream", nil, "Failure preparing request")
97 return
98 }
99
100 resp, err := client.AddFaceFromStreamSender(req)
101 if err != nil {
102 result.Response = autorest.Response{Response: resp}
103 err = autorest.NewErrorWithError(err, "face.ListClient", "AddFaceFromStream", resp, "Failure sending request")
104 return
105 }
106
107 result, err = client.AddFaceFromStreamResponder(resp)
108 if err != nil {
109 err = autorest.NewErrorWithError(err, "face.ListClient", "AddFaceFromStream", resp, "Failure responding to request")
110 return
111 }
112
113 return
114 }
115
116
117 func (client ListClient) AddFaceFromStreamPreparer(ctx context.Context, faceListID string, imageParameter io.ReadCloser, userData string, targetFace []int32, detectionModel DetectionModel) (*http.Request, error) {
118 urlParameters := map[string]interface{}{
119 "Endpoint": client.Endpoint,
120 }
121
122 pathParameters := map[string]interface{}{
123 "faceListId": autorest.Encode("path", faceListID),
124 }
125
126 queryParameters := map[string]interface{}{}
127 if len(userData) > 0 {
128 queryParameters["userData"] = autorest.Encode("query", userData)
129 }
130 if targetFace != nil && len(targetFace) > 0 {
131 queryParameters["targetFace"] = autorest.Encode("query", targetFace, ",")
132 }
133 if len(string(detectionModel)) > 0 {
134 queryParameters["detectionModel"] = autorest.Encode("query", detectionModel)
135 } else {
136 queryParameters["detectionModel"] = autorest.Encode("query", "detection_01")
137 }
138
139 preparer := autorest.CreatePreparer(
140 autorest.AsContentType("application/octet-stream"),
141 autorest.AsPost(),
142 autorest.WithCustomBaseURL("{Endpoint}/face/v1.0", urlParameters),
143 autorest.WithPathParameters("/facelists/{faceListId}/persistedfaces", pathParameters),
144 autorest.WithFile(imageParameter),
145 autorest.WithQueryParameters(queryParameters))
146 return preparer.Prepare((&http.Request{}).WithContext(ctx))
147 }
148
149
150
151 func (client ListClient) AddFaceFromStreamSender(req *http.Request) (*http.Response, error) {
152 return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
153 }
154
155
156
157 func (client ListClient) AddFaceFromStreamResponder(resp *http.Response) (result PersistedFace, err error) {
158 err = autorest.Respond(
159 resp,
160 azure.WithErrorUnlessStatusCode(http.StatusOK),
161 autorest.ByUnmarshallingJSON(&result),
162 autorest.ByClosing())
163 result.Response = autorest.Response{Response: resp}
164 return
165 }
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210 func (client ListClient) AddFaceFromURL(ctx context.Context, faceListID string, imageURL ImageURL, userData string, targetFace []int32, detectionModel DetectionModel) (result PersistedFace, err error) {
211 if tracing.IsEnabled() {
212 ctx = tracing.StartSpan(ctx, fqdn+"/ListClient.AddFaceFromURL")
213 defer func() {
214 sc := -1
215 if result.Response.Response != nil {
216 sc = result.Response.Response.StatusCode
217 }
218 tracing.EndSpan(ctx, sc, err)
219 }()
220 }
221 if err := validation.Validate([]validation.Validation{
222 {TargetValue: faceListID,
223 Constraints: []validation.Constraint{{Target: "faceListID", Name: validation.MaxLength, Rule: 64, Chain: nil},
224 {Target: "faceListID", Name: validation.Pattern, Rule: `^[a-z0-9-_]+$`, Chain: nil}}},
225 {TargetValue: userData,
226 Constraints: []validation.Constraint{{Target: "userData", Name: validation.Empty, Rule: false,
227 Chain: []validation.Constraint{{Target: "userData", Name: validation.MaxLength, Rule: 1024, Chain: nil}}}}},
228 {TargetValue: imageURL,
229 Constraints: []validation.Constraint{{Target: "imageURL.URL", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil {
230 return result, validation.NewError("face.ListClient", "AddFaceFromURL", err.Error())
231 }
232
233 req, err := client.AddFaceFromURLPreparer(ctx, faceListID, imageURL, userData, targetFace, detectionModel)
234 if err != nil {
235 err = autorest.NewErrorWithError(err, "face.ListClient", "AddFaceFromURL", nil, "Failure preparing request")
236 return
237 }
238
239 resp, err := client.AddFaceFromURLSender(req)
240 if err != nil {
241 result.Response = autorest.Response{Response: resp}
242 err = autorest.NewErrorWithError(err, "face.ListClient", "AddFaceFromURL", resp, "Failure sending request")
243 return
244 }
245
246 result, err = client.AddFaceFromURLResponder(resp)
247 if err != nil {
248 err = autorest.NewErrorWithError(err, "face.ListClient", "AddFaceFromURL", resp, "Failure responding to request")
249 return
250 }
251
252 return
253 }
254
255
256 func (client ListClient) AddFaceFromURLPreparer(ctx context.Context, faceListID string, imageURL ImageURL, userData string, targetFace []int32, detectionModel DetectionModel) (*http.Request, error) {
257 urlParameters := map[string]interface{}{
258 "Endpoint": client.Endpoint,
259 }
260
261 pathParameters := map[string]interface{}{
262 "faceListId": autorest.Encode("path", faceListID),
263 }
264
265 queryParameters := map[string]interface{}{}
266 if len(userData) > 0 {
267 queryParameters["userData"] = autorest.Encode("query", userData)
268 }
269 if targetFace != nil && len(targetFace) > 0 {
270 queryParameters["targetFace"] = autorest.Encode("query", targetFace, ",")
271 }
272 if len(string(detectionModel)) > 0 {
273 queryParameters["detectionModel"] = autorest.Encode("query", detectionModel)
274 } else {
275 queryParameters["detectionModel"] = autorest.Encode("query", "detection_01")
276 }
277
278 preparer := autorest.CreatePreparer(
279 autorest.AsContentType("application/json; charset=utf-8"),
280 autorest.AsPost(),
281 autorest.WithCustomBaseURL("{Endpoint}/face/v1.0", urlParameters),
282 autorest.WithPathParameters("/facelists/{faceListId}/persistedfaces", pathParameters),
283 autorest.WithJSON(imageURL),
284 autorest.WithQueryParameters(queryParameters))
285 return preparer.Prepare((&http.Request{}).WithContext(ctx))
286 }
287
288
289
290 func (client ListClient) AddFaceFromURLSender(req *http.Request) (*http.Response, error) {
291 return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
292 }
293
294
295
296 func (client ListClient) AddFaceFromURLResponder(resp *http.Response) (result PersistedFace, err error) {
297 err = autorest.Respond(
298 resp,
299 azure.WithErrorUnlessStatusCode(http.StatusOK),
300 autorest.ByUnmarshallingJSON(&result),
301 autorest.ByClosing())
302 result.Response = autorest.Response{Response: resp}
303 return
304 }
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335 func (client ListClient) Create(ctx context.Context, faceListID string, body MetaDataContract) (result autorest.Response, err error) {
336 if tracing.IsEnabled() {
337 ctx = tracing.StartSpan(ctx, fqdn+"/ListClient.Create")
338 defer func() {
339 sc := -1
340 if result.Response != nil {
341 sc = result.Response.StatusCode
342 }
343 tracing.EndSpan(ctx, sc, err)
344 }()
345 }
346 if err := validation.Validate([]validation.Validation{
347 {TargetValue: faceListID,
348 Constraints: []validation.Constraint{{Target: "faceListID", Name: validation.MaxLength, Rule: 64, Chain: nil},
349 {Target: "faceListID", Name: validation.Pattern, Rule: `^[a-z0-9-_]+$`, Chain: nil}}}}); err != nil {
350 return result, validation.NewError("face.ListClient", "Create", err.Error())
351 }
352
353 req, err := client.CreatePreparer(ctx, faceListID, body)
354 if err != nil {
355 err = autorest.NewErrorWithError(err, "face.ListClient", "Create", nil, "Failure preparing request")
356 return
357 }
358
359 resp, err := client.CreateSender(req)
360 if err != nil {
361 result.Response = resp
362 err = autorest.NewErrorWithError(err, "face.ListClient", "Create", resp, "Failure sending request")
363 return
364 }
365
366 result, err = client.CreateResponder(resp)
367 if err != nil {
368 err = autorest.NewErrorWithError(err, "face.ListClient", "Create", resp, "Failure responding to request")
369 return
370 }
371
372 return
373 }
374
375
376 func (client ListClient) CreatePreparer(ctx context.Context, faceListID string, body MetaDataContract) (*http.Request, error) {
377 urlParameters := map[string]interface{}{
378 "Endpoint": client.Endpoint,
379 }
380
381 pathParameters := map[string]interface{}{
382 "faceListId": autorest.Encode("path", faceListID),
383 }
384
385 preparer := autorest.CreatePreparer(
386 autorest.AsContentType("application/json; charset=utf-8"),
387 autorest.AsPut(),
388 autorest.WithCustomBaseURL("{Endpoint}/face/v1.0", urlParameters),
389 autorest.WithPathParameters("/facelists/{faceListId}", pathParameters),
390 autorest.WithJSON(body))
391 return preparer.Prepare((&http.Request{}).WithContext(ctx))
392 }
393
394
395
396 func (client ListClient) CreateSender(req *http.Request) (*http.Response, error) {
397 return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
398 }
399
400
401
402 func (client ListClient) CreateResponder(resp *http.Response) (result autorest.Response, err error) {
403 err = autorest.Respond(
404 resp,
405 azure.WithErrorUnlessStatusCode(http.StatusOK),
406 autorest.ByClosing())
407 result.Response = resp
408 return
409 }
410
411
412
413
414 func (client ListClient) Delete(ctx context.Context, faceListID string) (result autorest.Response, err error) {
415 if tracing.IsEnabled() {
416 ctx = tracing.StartSpan(ctx, fqdn+"/ListClient.Delete")
417 defer func() {
418 sc := -1
419 if result.Response != nil {
420 sc = result.Response.StatusCode
421 }
422 tracing.EndSpan(ctx, sc, err)
423 }()
424 }
425 if err := validation.Validate([]validation.Validation{
426 {TargetValue: faceListID,
427 Constraints: []validation.Constraint{{Target: "faceListID", Name: validation.MaxLength, Rule: 64, Chain: nil},
428 {Target: "faceListID", Name: validation.Pattern, Rule: `^[a-z0-9-_]+$`, Chain: nil}}}}); err != nil {
429 return result, validation.NewError("face.ListClient", "Delete", err.Error())
430 }
431
432 req, err := client.DeletePreparer(ctx, faceListID)
433 if err != nil {
434 err = autorest.NewErrorWithError(err, "face.ListClient", "Delete", nil, "Failure preparing request")
435 return
436 }
437
438 resp, err := client.DeleteSender(req)
439 if err != nil {
440 result.Response = resp
441 err = autorest.NewErrorWithError(err, "face.ListClient", "Delete", resp, "Failure sending request")
442 return
443 }
444
445 result, err = client.DeleteResponder(resp)
446 if err != nil {
447 err = autorest.NewErrorWithError(err, "face.ListClient", "Delete", resp, "Failure responding to request")
448 return
449 }
450
451 return
452 }
453
454
455 func (client ListClient) DeletePreparer(ctx context.Context, faceListID string) (*http.Request, error) {
456 urlParameters := map[string]interface{}{
457 "Endpoint": client.Endpoint,
458 }
459
460 pathParameters := map[string]interface{}{
461 "faceListId": autorest.Encode("path", faceListID),
462 }
463
464 preparer := autorest.CreatePreparer(
465 autorest.AsDelete(),
466 autorest.WithCustomBaseURL("{Endpoint}/face/v1.0", urlParameters),
467 autorest.WithPathParameters("/facelists/{faceListId}", pathParameters))
468 return preparer.Prepare((&http.Request{}).WithContext(ctx))
469 }
470
471
472
473 func (client ListClient) DeleteSender(req *http.Request) (*http.Response, error) {
474 return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
475 }
476
477
478
479 func (client ListClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) {
480 err = autorest.Respond(
481 resp,
482 azure.WithErrorUnlessStatusCode(http.StatusOK),
483 autorest.ByClosing())
484 result.Response = resp
485 return
486 }
487
488
489
490
491
492
493
494 func (client ListClient) DeleteFace(ctx context.Context, faceListID string, persistedFaceID uuid.UUID) (result autorest.Response, err error) {
495 if tracing.IsEnabled() {
496 ctx = tracing.StartSpan(ctx, fqdn+"/ListClient.DeleteFace")
497 defer func() {
498 sc := -1
499 if result.Response != nil {
500 sc = result.Response.StatusCode
501 }
502 tracing.EndSpan(ctx, sc, err)
503 }()
504 }
505 if err := validation.Validate([]validation.Validation{
506 {TargetValue: faceListID,
507 Constraints: []validation.Constraint{{Target: "faceListID", Name: validation.MaxLength, Rule: 64, Chain: nil},
508 {Target: "faceListID", Name: validation.Pattern, Rule: `^[a-z0-9-_]+$`, Chain: nil}}}}); err != nil {
509 return result, validation.NewError("face.ListClient", "DeleteFace", err.Error())
510 }
511
512 req, err := client.DeleteFacePreparer(ctx, faceListID, persistedFaceID)
513 if err != nil {
514 err = autorest.NewErrorWithError(err, "face.ListClient", "DeleteFace", nil, "Failure preparing request")
515 return
516 }
517
518 resp, err := client.DeleteFaceSender(req)
519 if err != nil {
520 result.Response = resp
521 err = autorest.NewErrorWithError(err, "face.ListClient", "DeleteFace", resp, "Failure sending request")
522 return
523 }
524
525 result, err = client.DeleteFaceResponder(resp)
526 if err != nil {
527 err = autorest.NewErrorWithError(err, "face.ListClient", "DeleteFace", resp, "Failure responding to request")
528 return
529 }
530
531 return
532 }
533
534
535 func (client ListClient) DeleteFacePreparer(ctx context.Context, faceListID string, persistedFaceID uuid.UUID) (*http.Request, error) {
536 urlParameters := map[string]interface{}{
537 "Endpoint": client.Endpoint,
538 }
539
540 pathParameters := map[string]interface{}{
541 "faceListId": autorest.Encode("path", faceListID),
542 "persistedFaceId": autorest.Encode("path", persistedFaceID),
543 }
544
545 preparer := autorest.CreatePreparer(
546 autorest.AsDelete(),
547 autorest.WithCustomBaseURL("{Endpoint}/face/v1.0", urlParameters),
548 autorest.WithPathParameters("/facelists/{faceListId}/persistedfaces/{persistedFaceId}", pathParameters))
549 return preparer.Prepare((&http.Request{}).WithContext(ctx))
550 }
551
552
553
554 func (client ListClient) DeleteFaceSender(req *http.Request) (*http.Response, error) {
555 return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
556 }
557
558
559
560 func (client ListClient) DeleteFaceResponder(resp *http.Response) (result autorest.Response, err error) {
561 err = autorest.Respond(
562 resp,
563 azure.WithErrorUnlessStatusCode(http.StatusOK),
564 autorest.ByClosing())
565 result.Response = resp
566 return
567 }
568
569
570
571
572
573
574 func (client ListClient) Get(ctx context.Context, faceListID string, returnRecognitionModel *bool) (result List, err error) {
575 if tracing.IsEnabled() {
576 ctx = tracing.StartSpan(ctx, fqdn+"/ListClient.Get")
577 defer func() {
578 sc := -1
579 if result.Response.Response != nil {
580 sc = result.Response.Response.StatusCode
581 }
582 tracing.EndSpan(ctx, sc, err)
583 }()
584 }
585 if err := validation.Validate([]validation.Validation{
586 {TargetValue: faceListID,
587 Constraints: []validation.Constraint{{Target: "faceListID", Name: validation.MaxLength, Rule: 64, Chain: nil},
588 {Target: "faceListID", Name: validation.Pattern, Rule: `^[a-z0-9-_]+$`, Chain: nil}}}}); err != nil {
589 return result, validation.NewError("face.ListClient", "Get", err.Error())
590 }
591
592 req, err := client.GetPreparer(ctx, faceListID, returnRecognitionModel)
593 if err != nil {
594 err = autorest.NewErrorWithError(err, "face.ListClient", "Get", nil, "Failure preparing request")
595 return
596 }
597
598 resp, err := client.GetSender(req)
599 if err != nil {
600 result.Response = autorest.Response{Response: resp}
601 err = autorest.NewErrorWithError(err, "face.ListClient", "Get", resp, "Failure sending request")
602 return
603 }
604
605 result, err = client.GetResponder(resp)
606 if err != nil {
607 err = autorest.NewErrorWithError(err, "face.ListClient", "Get", resp, "Failure responding to request")
608 return
609 }
610
611 return
612 }
613
614
615 func (client ListClient) GetPreparer(ctx context.Context, faceListID string, returnRecognitionModel *bool) (*http.Request, error) {
616 urlParameters := map[string]interface{}{
617 "Endpoint": client.Endpoint,
618 }
619
620 pathParameters := map[string]interface{}{
621 "faceListId": autorest.Encode("path", faceListID),
622 }
623
624 queryParameters := map[string]interface{}{}
625 if returnRecognitionModel != nil {
626 queryParameters["returnRecognitionModel"] = autorest.Encode("query", *returnRecognitionModel)
627 } else {
628 queryParameters["returnRecognitionModel"] = autorest.Encode("query", false)
629 }
630
631 preparer := autorest.CreatePreparer(
632 autorest.AsGet(),
633 autorest.WithCustomBaseURL("{Endpoint}/face/v1.0", urlParameters),
634 autorest.WithPathParameters("/facelists/{faceListId}", pathParameters),
635 autorest.WithQueryParameters(queryParameters))
636 return preparer.Prepare((&http.Request{}).WithContext(ctx))
637 }
638
639
640
641 func (client ListClient) GetSender(req *http.Request) (*http.Response, error) {
642 return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
643 }
644
645
646
647 func (client ListClient) GetResponder(resp *http.Response) (result List, err error) {
648 err = autorest.Respond(
649 resp,
650 azure.WithErrorUnlessStatusCode(http.StatusOK),
651 autorest.ByUnmarshallingJSON(&result),
652 autorest.ByClosing())
653 result.Response = autorest.Response{Response: resp}
654 return
655 }
656
657
658
659
660
661
662
663 func (client ListClient) List(ctx context.Context, returnRecognitionModel *bool) (result ListList, err error) {
664 if tracing.IsEnabled() {
665 ctx = tracing.StartSpan(ctx, fqdn+"/ListClient.List")
666 defer func() {
667 sc := -1
668 if result.Response.Response != nil {
669 sc = result.Response.Response.StatusCode
670 }
671 tracing.EndSpan(ctx, sc, err)
672 }()
673 }
674 req, err := client.ListPreparer(ctx, returnRecognitionModel)
675 if err != nil {
676 err = autorest.NewErrorWithError(err, "face.ListClient", "List", nil, "Failure preparing request")
677 return
678 }
679
680 resp, err := client.ListSender(req)
681 if err != nil {
682 result.Response = autorest.Response{Response: resp}
683 err = autorest.NewErrorWithError(err, "face.ListClient", "List", resp, "Failure sending request")
684 return
685 }
686
687 result, err = client.ListResponder(resp)
688 if err != nil {
689 err = autorest.NewErrorWithError(err, "face.ListClient", "List", resp, "Failure responding to request")
690 return
691 }
692
693 return
694 }
695
696
697 func (client ListClient) ListPreparer(ctx context.Context, returnRecognitionModel *bool) (*http.Request, error) {
698 urlParameters := map[string]interface{}{
699 "Endpoint": client.Endpoint,
700 }
701
702 queryParameters := map[string]interface{}{}
703 if returnRecognitionModel != nil {
704 queryParameters["returnRecognitionModel"] = autorest.Encode("query", *returnRecognitionModel)
705 } else {
706 queryParameters["returnRecognitionModel"] = autorest.Encode("query", false)
707 }
708
709 preparer := autorest.CreatePreparer(
710 autorest.AsGet(),
711 autorest.WithCustomBaseURL("{Endpoint}/face/v1.0", urlParameters),
712 autorest.WithPath("/facelists"),
713 autorest.WithQueryParameters(queryParameters))
714 return preparer.Prepare((&http.Request{}).WithContext(ctx))
715 }
716
717
718
719 func (client ListClient) ListSender(req *http.Request) (*http.Response, error) {
720 return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
721 }
722
723
724
725 func (client ListClient) ListResponder(resp *http.Response) (result ListList, err error) {
726 err = autorest.Respond(
727 resp,
728 azure.WithErrorUnlessStatusCode(http.StatusOK),
729 autorest.ByUnmarshallingJSON(&result.Value),
730 autorest.ByClosing())
731 result.Response = autorest.Response{Response: resp}
732 return
733 }
734
735
736
737
738
739 func (client ListClient) Update(ctx context.Context, faceListID string, body NameAndUserDataContract) (result autorest.Response, err error) {
740 if tracing.IsEnabled() {
741 ctx = tracing.StartSpan(ctx, fqdn+"/ListClient.Update")
742 defer func() {
743 sc := -1
744 if result.Response != nil {
745 sc = result.Response.StatusCode
746 }
747 tracing.EndSpan(ctx, sc, err)
748 }()
749 }
750 if err := validation.Validate([]validation.Validation{
751 {TargetValue: faceListID,
752 Constraints: []validation.Constraint{{Target: "faceListID", Name: validation.MaxLength, Rule: 64, Chain: nil},
753 {Target: "faceListID", Name: validation.Pattern, Rule: `^[a-z0-9-_]+$`, Chain: nil}}}}); err != nil {
754 return result, validation.NewError("face.ListClient", "Update", err.Error())
755 }
756
757 req, err := client.UpdatePreparer(ctx, faceListID, body)
758 if err != nil {
759 err = autorest.NewErrorWithError(err, "face.ListClient", "Update", nil, "Failure preparing request")
760 return
761 }
762
763 resp, err := client.UpdateSender(req)
764 if err != nil {
765 result.Response = resp
766 err = autorest.NewErrorWithError(err, "face.ListClient", "Update", resp, "Failure sending request")
767 return
768 }
769
770 result, err = client.UpdateResponder(resp)
771 if err != nil {
772 err = autorest.NewErrorWithError(err, "face.ListClient", "Update", resp, "Failure responding to request")
773 return
774 }
775
776 return
777 }
778
779
780 func (client ListClient) UpdatePreparer(ctx context.Context, faceListID string, body NameAndUserDataContract) (*http.Request, error) {
781 urlParameters := map[string]interface{}{
782 "Endpoint": client.Endpoint,
783 }
784
785 pathParameters := map[string]interface{}{
786 "faceListId": autorest.Encode("path", faceListID),
787 }
788
789 preparer := autorest.CreatePreparer(
790 autorest.AsContentType("application/json; charset=utf-8"),
791 autorest.AsPatch(),
792 autorest.WithCustomBaseURL("{Endpoint}/face/v1.0", urlParameters),
793 autorest.WithPathParameters("/facelists/{faceListId}", pathParameters),
794 autorest.WithJSON(body))
795 return preparer.Prepare((&http.Request{}).WithContext(ctx))
796 }
797
798
799
800 func (client ListClient) UpdateSender(req *http.Request) (*http.Response, error) {
801 return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
802 }
803
804
805
806 func (client ListClient) UpdateResponder(resp *http.Response) (result autorest.Response, err error) {
807 err = autorest.Respond(
808 resp,
809 azure.WithErrorUnlessStatusCode(http.StatusOK),
810 autorest.ByClosing())
811 result.Response = resp
812 return
813 }
814
View as plain text