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 "net/http"
16 )
17
18
19 type PersonGroupClient struct {
20 BaseClient
21 }
22
23
24 func NewPersonGroupClient(endpoint string) PersonGroupClient {
25 return PersonGroupClient{New(endpoint)}
26 }
27
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 func (client PersonGroupClient) Create(ctx context.Context, personGroupID string, body MetaDataContract) (result autorest.Response, err error) {
60 if tracing.IsEnabled() {
61 ctx = tracing.StartSpan(ctx, fqdn+"/PersonGroupClient.Create")
62 defer func() {
63 sc := -1
64 if result.Response != nil {
65 sc = result.Response.StatusCode
66 }
67 tracing.EndSpan(ctx, sc, err)
68 }()
69 }
70 if err := validation.Validate([]validation.Validation{
71 {TargetValue: personGroupID,
72 Constraints: []validation.Constraint{{Target: "personGroupID", Name: validation.MaxLength, Rule: 64, Chain: nil},
73 {Target: "personGroupID", Name: validation.Pattern, Rule: `^[a-z0-9-_]+$`, Chain: nil}}}}); err != nil {
74 return result, validation.NewError("face.PersonGroupClient", "Create", err.Error())
75 }
76
77 req, err := client.CreatePreparer(ctx, personGroupID, body)
78 if err != nil {
79 err = autorest.NewErrorWithError(err, "face.PersonGroupClient", "Create", nil, "Failure preparing request")
80 return
81 }
82
83 resp, err := client.CreateSender(req)
84 if err != nil {
85 result.Response = resp
86 err = autorest.NewErrorWithError(err, "face.PersonGroupClient", "Create", resp, "Failure sending request")
87 return
88 }
89
90 result, err = client.CreateResponder(resp)
91 if err != nil {
92 err = autorest.NewErrorWithError(err, "face.PersonGroupClient", "Create", resp, "Failure responding to request")
93 return
94 }
95
96 return
97 }
98
99
100 func (client PersonGroupClient) CreatePreparer(ctx context.Context, personGroupID string, body MetaDataContract) (*http.Request, error) {
101 urlParameters := map[string]interface{}{
102 "Endpoint": client.Endpoint,
103 }
104
105 pathParameters := map[string]interface{}{
106 "personGroupId": autorest.Encode("path", personGroupID),
107 }
108
109 preparer := autorest.CreatePreparer(
110 autorest.AsContentType("application/json; charset=utf-8"),
111 autorest.AsPut(),
112 autorest.WithCustomBaseURL("{Endpoint}/face/v1.0", urlParameters),
113 autorest.WithPathParameters("/persongroups/{personGroupId}", pathParameters),
114 autorest.WithJSON(body))
115 return preparer.Prepare((&http.Request{}).WithContext(ctx))
116 }
117
118
119
120 func (client PersonGroupClient) CreateSender(req *http.Request) (*http.Response, error) {
121 return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
122 }
123
124
125
126 func (client PersonGroupClient) CreateResponder(resp *http.Response) (result autorest.Response, err error) {
127 err = autorest.Respond(
128 resp,
129 azure.WithErrorUnlessStatusCode(http.StatusOK),
130 autorest.ByClosing())
131 result.Response = resp
132 return
133 }
134
135
136
137
138
139 func (client PersonGroupClient) Delete(ctx context.Context, personGroupID string) (result autorest.Response, err error) {
140 if tracing.IsEnabled() {
141 ctx = tracing.StartSpan(ctx, fqdn+"/PersonGroupClient.Delete")
142 defer func() {
143 sc := -1
144 if result.Response != nil {
145 sc = result.Response.StatusCode
146 }
147 tracing.EndSpan(ctx, sc, err)
148 }()
149 }
150 if err := validation.Validate([]validation.Validation{
151 {TargetValue: personGroupID,
152 Constraints: []validation.Constraint{{Target: "personGroupID", Name: validation.MaxLength, Rule: 64, Chain: nil},
153 {Target: "personGroupID", Name: validation.Pattern, Rule: `^[a-z0-9-_]+$`, Chain: nil}}}}); err != nil {
154 return result, validation.NewError("face.PersonGroupClient", "Delete", err.Error())
155 }
156
157 req, err := client.DeletePreparer(ctx, personGroupID)
158 if err != nil {
159 err = autorest.NewErrorWithError(err, "face.PersonGroupClient", "Delete", nil, "Failure preparing request")
160 return
161 }
162
163 resp, err := client.DeleteSender(req)
164 if err != nil {
165 result.Response = resp
166 err = autorest.NewErrorWithError(err, "face.PersonGroupClient", "Delete", resp, "Failure sending request")
167 return
168 }
169
170 result, err = client.DeleteResponder(resp)
171 if err != nil {
172 err = autorest.NewErrorWithError(err, "face.PersonGroupClient", "Delete", resp, "Failure responding to request")
173 return
174 }
175
176 return
177 }
178
179
180 func (client PersonGroupClient) DeletePreparer(ctx context.Context, personGroupID string) (*http.Request, error) {
181 urlParameters := map[string]interface{}{
182 "Endpoint": client.Endpoint,
183 }
184
185 pathParameters := map[string]interface{}{
186 "personGroupId": autorest.Encode("path", personGroupID),
187 }
188
189 preparer := autorest.CreatePreparer(
190 autorest.AsDelete(),
191 autorest.WithCustomBaseURL("{Endpoint}/face/v1.0", urlParameters),
192 autorest.WithPathParameters("/persongroups/{personGroupId}", pathParameters))
193 return preparer.Prepare((&http.Request{}).WithContext(ctx))
194 }
195
196
197
198 func (client PersonGroupClient) DeleteSender(req *http.Request) (*http.Response, error) {
199 return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
200 }
201
202
203
204 func (client PersonGroupClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) {
205 err = autorest.Respond(
206 resp,
207 azure.WithErrorUnlessStatusCode(http.StatusOK),
208 autorest.ByClosing())
209 result.Response = resp
210 return
211 }
212
213
214
215
216
217
218
219 func (client PersonGroupClient) Get(ctx context.Context, personGroupID string, returnRecognitionModel *bool) (result PersonGroup, err error) {
220 if tracing.IsEnabled() {
221 ctx = tracing.StartSpan(ctx, fqdn+"/PersonGroupClient.Get")
222 defer func() {
223 sc := -1
224 if result.Response.Response != nil {
225 sc = result.Response.Response.StatusCode
226 }
227 tracing.EndSpan(ctx, sc, err)
228 }()
229 }
230 if err := validation.Validate([]validation.Validation{
231 {TargetValue: personGroupID,
232 Constraints: []validation.Constraint{{Target: "personGroupID", Name: validation.MaxLength, Rule: 64, Chain: nil},
233 {Target: "personGroupID", Name: validation.Pattern, Rule: `^[a-z0-9-_]+$`, Chain: nil}}}}); err != nil {
234 return result, validation.NewError("face.PersonGroupClient", "Get", err.Error())
235 }
236
237 req, err := client.GetPreparer(ctx, personGroupID, returnRecognitionModel)
238 if err != nil {
239 err = autorest.NewErrorWithError(err, "face.PersonGroupClient", "Get", nil, "Failure preparing request")
240 return
241 }
242
243 resp, err := client.GetSender(req)
244 if err != nil {
245 result.Response = autorest.Response{Response: resp}
246 err = autorest.NewErrorWithError(err, "face.PersonGroupClient", "Get", resp, "Failure sending request")
247 return
248 }
249
250 result, err = client.GetResponder(resp)
251 if err != nil {
252 err = autorest.NewErrorWithError(err, "face.PersonGroupClient", "Get", resp, "Failure responding to request")
253 return
254 }
255
256 return
257 }
258
259
260 func (client PersonGroupClient) GetPreparer(ctx context.Context, personGroupID string, returnRecognitionModel *bool) (*http.Request, error) {
261 urlParameters := map[string]interface{}{
262 "Endpoint": client.Endpoint,
263 }
264
265 pathParameters := map[string]interface{}{
266 "personGroupId": autorest.Encode("path", personGroupID),
267 }
268
269 queryParameters := map[string]interface{}{}
270 if returnRecognitionModel != nil {
271 queryParameters["returnRecognitionModel"] = autorest.Encode("query", *returnRecognitionModel)
272 } else {
273 queryParameters["returnRecognitionModel"] = autorest.Encode("query", false)
274 }
275
276 preparer := autorest.CreatePreparer(
277 autorest.AsGet(),
278 autorest.WithCustomBaseURL("{Endpoint}/face/v1.0", urlParameters),
279 autorest.WithPathParameters("/persongroups/{personGroupId}", pathParameters),
280 autorest.WithQueryParameters(queryParameters))
281 return preparer.Prepare((&http.Request{}).WithContext(ctx))
282 }
283
284
285
286 func (client PersonGroupClient) GetSender(req *http.Request) (*http.Response, error) {
287 return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
288 }
289
290
291
292 func (client PersonGroupClient) GetResponder(resp *http.Response) (result PersonGroup, err error) {
293 err = autorest.Respond(
294 resp,
295 azure.WithErrorUnlessStatusCode(http.StatusOK),
296 autorest.ByUnmarshallingJSON(&result),
297 autorest.ByClosing())
298 result.Response = autorest.Response{Response: resp}
299 return
300 }
301
302
303
304
305 func (client PersonGroupClient) GetTrainingStatus(ctx context.Context, personGroupID string) (result TrainingStatus, err error) {
306 if tracing.IsEnabled() {
307 ctx = tracing.StartSpan(ctx, fqdn+"/PersonGroupClient.GetTrainingStatus")
308 defer func() {
309 sc := -1
310 if result.Response.Response != nil {
311 sc = result.Response.Response.StatusCode
312 }
313 tracing.EndSpan(ctx, sc, err)
314 }()
315 }
316 if err := validation.Validate([]validation.Validation{
317 {TargetValue: personGroupID,
318 Constraints: []validation.Constraint{{Target: "personGroupID", Name: validation.MaxLength, Rule: 64, Chain: nil},
319 {Target: "personGroupID", Name: validation.Pattern, Rule: `^[a-z0-9-_]+$`, Chain: nil}}}}); err != nil {
320 return result, validation.NewError("face.PersonGroupClient", "GetTrainingStatus", err.Error())
321 }
322
323 req, err := client.GetTrainingStatusPreparer(ctx, personGroupID)
324 if err != nil {
325 err = autorest.NewErrorWithError(err, "face.PersonGroupClient", "GetTrainingStatus", nil, "Failure preparing request")
326 return
327 }
328
329 resp, err := client.GetTrainingStatusSender(req)
330 if err != nil {
331 result.Response = autorest.Response{Response: resp}
332 err = autorest.NewErrorWithError(err, "face.PersonGroupClient", "GetTrainingStatus", resp, "Failure sending request")
333 return
334 }
335
336 result, err = client.GetTrainingStatusResponder(resp)
337 if err != nil {
338 err = autorest.NewErrorWithError(err, "face.PersonGroupClient", "GetTrainingStatus", resp, "Failure responding to request")
339 return
340 }
341
342 return
343 }
344
345
346 func (client PersonGroupClient) GetTrainingStatusPreparer(ctx context.Context, personGroupID string) (*http.Request, error) {
347 urlParameters := map[string]interface{}{
348 "Endpoint": client.Endpoint,
349 }
350
351 pathParameters := map[string]interface{}{
352 "personGroupId": autorest.Encode("path", personGroupID),
353 }
354
355 preparer := autorest.CreatePreparer(
356 autorest.AsGet(),
357 autorest.WithCustomBaseURL("{Endpoint}/face/v1.0", urlParameters),
358 autorest.WithPathParameters("/persongroups/{personGroupId}/training", pathParameters))
359 return preparer.Prepare((&http.Request{}).WithContext(ctx))
360 }
361
362
363
364 func (client PersonGroupClient) GetTrainingStatusSender(req *http.Request) (*http.Response, error) {
365 return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
366 }
367
368
369
370 func (client PersonGroupClient) GetTrainingStatusResponder(resp *http.Response) (result TrainingStatus, err error) {
371 err = autorest.Respond(
372 resp,
373 azure.WithErrorUnlessStatusCode(http.StatusOK),
374 autorest.ByUnmarshallingJSON(&result),
375 autorest.ByClosing())
376 result.Response = autorest.Response{Response: resp}
377 return
378 }
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396 func (client PersonGroupClient) List(ctx context.Context, start string, top *int32, returnRecognitionModel *bool) (result ListPersonGroup, err error) {
397 if tracing.IsEnabled() {
398 ctx = tracing.StartSpan(ctx, fqdn+"/PersonGroupClient.List")
399 defer func() {
400 sc := -1
401 if result.Response.Response != nil {
402 sc = result.Response.Response.StatusCode
403 }
404 tracing.EndSpan(ctx, sc, err)
405 }()
406 }
407 if err := validation.Validate([]validation.Validation{
408 {TargetValue: start,
409 Constraints: []validation.Constraint{{Target: "start", Name: validation.Empty, Rule: false,
410 Chain: []validation.Constraint{{Target: "start", Name: validation.MaxLength, Rule: 64, Chain: nil}}}}},
411 {TargetValue: top,
412 Constraints: []validation.Constraint{{Target: "top", Name: validation.Null, Rule: false,
413 Chain: []validation.Constraint{{Target: "top", Name: validation.InclusiveMaximum, Rule: int64(1000), Chain: nil},
414 {Target: "top", Name: validation.InclusiveMinimum, Rule: int64(1), Chain: nil},
415 }}}}}); err != nil {
416 return result, validation.NewError("face.PersonGroupClient", "List", err.Error())
417 }
418
419 req, err := client.ListPreparer(ctx, start, top, returnRecognitionModel)
420 if err != nil {
421 err = autorest.NewErrorWithError(err, "face.PersonGroupClient", "List", nil, "Failure preparing request")
422 return
423 }
424
425 resp, err := client.ListSender(req)
426 if err != nil {
427 result.Response = autorest.Response{Response: resp}
428 err = autorest.NewErrorWithError(err, "face.PersonGroupClient", "List", resp, "Failure sending request")
429 return
430 }
431
432 result, err = client.ListResponder(resp)
433 if err != nil {
434 err = autorest.NewErrorWithError(err, "face.PersonGroupClient", "List", resp, "Failure responding to request")
435 return
436 }
437
438 return
439 }
440
441
442 func (client PersonGroupClient) ListPreparer(ctx context.Context, start string, top *int32, returnRecognitionModel *bool) (*http.Request, error) {
443 urlParameters := map[string]interface{}{
444 "Endpoint": client.Endpoint,
445 }
446
447 queryParameters := map[string]interface{}{}
448 if len(start) > 0 {
449 queryParameters["start"] = autorest.Encode("query", start)
450 }
451 if top != nil {
452 queryParameters["top"] = autorest.Encode("query", *top)
453 } else {
454 queryParameters["top"] = autorest.Encode("query", 1000)
455 }
456 if returnRecognitionModel != nil {
457 queryParameters["returnRecognitionModel"] = autorest.Encode("query", *returnRecognitionModel)
458 } else {
459 queryParameters["returnRecognitionModel"] = autorest.Encode("query", false)
460 }
461
462 preparer := autorest.CreatePreparer(
463 autorest.AsGet(),
464 autorest.WithCustomBaseURL("{Endpoint}/face/v1.0", urlParameters),
465 autorest.WithPath("/persongroups"),
466 autorest.WithQueryParameters(queryParameters))
467 return preparer.Prepare((&http.Request{}).WithContext(ctx))
468 }
469
470
471
472 func (client PersonGroupClient) ListSender(req *http.Request) (*http.Response, error) {
473 return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
474 }
475
476
477
478 func (client PersonGroupClient) ListResponder(resp *http.Response) (result ListPersonGroup, err error) {
479 err = autorest.Respond(
480 resp,
481 azure.WithErrorUnlessStatusCode(http.StatusOK),
482 autorest.ByUnmarshallingJSON(&result.Value),
483 autorest.ByClosing())
484 result.Response = autorest.Response{Response: resp}
485 return
486 }
487
488
489
490
491 func (client PersonGroupClient) Train(ctx context.Context, personGroupID string) (result autorest.Response, err error) {
492 if tracing.IsEnabled() {
493 ctx = tracing.StartSpan(ctx, fqdn+"/PersonGroupClient.Train")
494 defer func() {
495 sc := -1
496 if result.Response != nil {
497 sc = result.Response.StatusCode
498 }
499 tracing.EndSpan(ctx, sc, err)
500 }()
501 }
502 if err := validation.Validate([]validation.Validation{
503 {TargetValue: personGroupID,
504 Constraints: []validation.Constraint{{Target: "personGroupID", Name: validation.MaxLength, Rule: 64, Chain: nil},
505 {Target: "personGroupID", Name: validation.Pattern, Rule: `^[a-z0-9-_]+$`, Chain: nil}}}}); err != nil {
506 return result, validation.NewError("face.PersonGroupClient", "Train", err.Error())
507 }
508
509 req, err := client.TrainPreparer(ctx, personGroupID)
510 if err != nil {
511 err = autorest.NewErrorWithError(err, "face.PersonGroupClient", "Train", nil, "Failure preparing request")
512 return
513 }
514
515 resp, err := client.TrainSender(req)
516 if err != nil {
517 result.Response = resp
518 err = autorest.NewErrorWithError(err, "face.PersonGroupClient", "Train", resp, "Failure sending request")
519 return
520 }
521
522 result, err = client.TrainResponder(resp)
523 if err != nil {
524 err = autorest.NewErrorWithError(err, "face.PersonGroupClient", "Train", resp, "Failure responding to request")
525 return
526 }
527
528 return
529 }
530
531
532 func (client PersonGroupClient) TrainPreparer(ctx context.Context, personGroupID string) (*http.Request, error) {
533 urlParameters := map[string]interface{}{
534 "Endpoint": client.Endpoint,
535 }
536
537 pathParameters := map[string]interface{}{
538 "personGroupId": autorest.Encode("path", personGroupID),
539 }
540
541 preparer := autorest.CreatePreparer(
542 autorest.AsPost(),
543 autorest.WithCustomBaseURL("{Endpoint}/face/v1.0", urlParameters),
544 autorest.WithPathParameters("/persongroups/{personGroupId}/train", pathParameters))
545 return preparer.Prepare((&http.Request{}).WithContext(ctx))
546 }
547
548
549
550 func (client PersonGroupClient) TrainSender(req *http.Request) (*http.Response, error) {
551 return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
552 }
553
554
555
556 func (client PersonGroupClient) TrainResponder(resp *http.Response) (result autorest.Response, err error) {
557 err = autorest.Respond(
558 resp,
559 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
560 autorest.ByClosing())
561 result.Response = resp
562 return
563 }
564
565
566
567
568
569
570 func (client PersonGroupClient) Update(ctx context.Context, personGroupID string, body NameAndUserDataContract) (result autorest.Response, err error) {
571 if tracing.IsEnabled() {
572 ctx = tracing.StartSpan(ctx, fqdn+"/PersonGroupClient.Update")
573 defer func() {
574 sc := -1
575 if result.Response != nil {
576 sc = result.Response.StatusCode
577 }
578 tracing.EndSpan(ctx, sc, err)
579 }()
580 }
581 if err := validation.Validate([]validation.Validation{
582 {TargetValue: personGroupID,
583 Constraints: []validation.Constraint{{Target: "personGroupID", Name: validation.MaxLength, Rule: 64, Chain: nil},
584 {Target: "personGroupID", Name: validation.Pattern, Rule: `^[a-z0-9-_]+$`, Chain: nil}}}}); err != nil {
585 return result, validation.NewError("face.PersonGroupClient", "Update", err.Error())
586 }
587
588 req, err := client.UpdatePreparer(ctx, personGroupID, body)
589 if err != nil {
590 err = autorest.NewErrorWithError(err, "face.PersonGroupClient", "Update", nil, "Failure preparing request")
591 return
592 }
593
594 resp, err := client.UpdateSender(req)
595 if err != nil {
596 result.Response = resp
597 err = autorest.NewErrorWithError(err, "face.PersonGroupClient", "Update", resp, "Failure sending request")
598 return
599 }
600
601 result, err = client.UpdateResponder(resp)
602 if err != nil {
603 err = autorest.NewErrorWithError(err, "face.PersonGroupClient", "Update", resp, "Failure responding to request")
604 return
605 }
606
607 return
608 }
609
610
611 func (client PersonGroupClient) UpdatePreparer(ctx context.Context, personGroupID string, body NameAndUserDataContract) (*http.Request, error) {
612 urlParameters := map[string]interface{}{
613 "Endpoint": client.Endpoint,
614 }
615
616 pathParameters := map[string]interface{}{
617 "personGroupId": autorest.Encode("path", personGroupID),
618 }
619
620 preparer := autorest.CreatePreparer(
621 autorest.AsContentType("application/json; charset=utf-8"),
622 autorest.AsPatch(),
623 autorest.WithCustomBaseURL("{Endpoint}/face/v1.0", urlParameters),
624 autorest.WithPathParameters("/persongroups/{personGroupId}", pathParameters),
625 autorest.WithJSON(body))
626 return preparer.Prepare((&http.Request{}).WithContext(ctx))
627 }
628
629
630
631 func (client PersonGroupClient) UpdateSender(req *http.Request) (*http.Response, error) {
632 return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
633 }
634
635
636
637 func (client PersonGroupClient) UpdateResponder(resp *http.Response) (result autorest.Response, err error) {
638 err = autorest.Respond(
639 resp,
640 azure.WithErrorUnlessStatusCode(http.StatusOK),
641 autorest.ByClosing())
642 result.Response = resp
643 return
644 }
645
View as plain text