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 LargePersonGroupPersonClient struct {
22 BaseClient
23 }
24
25
26 func NewLargePersonGroupPersonClient(endpoint string) LargePersonGroupPersonClient {
27 return LargePersonGroupPersonClient{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
74
75
76
77
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
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
156
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
162
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
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
211
212
213
214
215
216
217
218
219
220
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
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
301
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
307
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
319
320
321
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
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
387
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
393
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
405
406
407
408
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
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
468
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
474
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
485
486
487
488
489
490
491
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
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
552
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
558
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
569
570
571
572
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
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
632
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
638
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
650
651
652
653
654
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
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
715
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
721
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
733
734
735
736
737
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
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
810
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
816
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
828
829
830
831
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
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
893
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
899
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
910
911
912
913
914
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
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
977
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
983
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