forked from Azure/azure-sdk-for-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
client.go
2785 lines (2428 loc) · 111 KB
/
client.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
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
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
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
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// Package training implements the Azure ARM Training service API version 2.0.
//
//
package training
// Copyright (c) Microsoft and contributors. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
//
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Code generated by Microsoft (R) AutoRest Code Generator.
// Changes may cause incorrect behavior and will be lost if the code is regenerated.
import (
"context"
"github.com/Azure/go-autorest/autorest"
"github.com/Azure/go-autorest/autorest/azure"
"github.com/Azure/go-autorest/autorest/validation"
"github.com/satori/go.uuid"
"io"
"net/http"
)
const (
// DefaultBaseURI is the default URI used for the service Training
DefaultBaseURI = "https://southcentralus.api.cognitive.microsoft.com/customvision/v2.0/Training"
)
// BaseClient is the base client for Training.
type BaseClient struct {
autorest.Client
BaseURI string
APIKey string
}
// New creates an instance of the BaseClient client.
func New(aPIKey string) BaseClient {
return NewWithBaseURI(DefaultBaseURI, aPIKey)
}
// NewWithBaseURI creates an instance of the BaseClient client.
func NewWithBaseURI(baseURI string, aPIKey string) BaseClient {
return BaseClient{
Client: autorest.NewClientWithUserAgent(UserAgent()),
BaseURI: baseURI,
APIKey: aPIKey,
}
}
// CreateImageRegions this API accepts a batch of image regions, and optionally tags, to update existing images with
// region information.
// There is a limit of 64 entries in the batch.
// Parameters:
// projectID - the project id
// batch - batch of image regions which include a tag and bounding box. Limited to 64
func (client BaseClient) CreateImageRegions(ctx context.Context, projectID uuid.UUID, batch ImageRegionCreateBatch) (result ImageRegionCreateSummary, err error) {
req, err := client.CreateImageRegionsPreparer(ctx, projectID, batch)
if err != nil {
err = autorest.NewErrorWithError(err, "training.BaseClient", "CreateImageRegions", nil, "Failure preparing request")
return
}
resp, err := client.CreateImageRegionsSender(req)
if err != nil {
result.Response = autorest.Response{Response: resp}
err = autorest.NewErrorWithError(err, "training.BaseClient", "CreateImageRegions", resp, "Failure sending request")
return
}
result, err = client.CreateImageRegionsResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "training.BaseClient", "CreateImageRegions", resp, "Failure responding to request")
}
return
}
// CreateImageRegionsPreparer prepares the CreateImageRegions request.
func (client BaseClient) CreateImageRegionsPreparer(ctx context.Context, projectID uuid.UUID, batch ImageRegionCreateBatch) (*http.Request, error) {
pathParameters := map[string]interface{}{
"projectId": autorest.Encode("path", projectID),
}
preparer := autorest.CreatePreparer(
autorest.AsContentType("application/json; charset=utf-8"),
autorest.AsPost(),
autorest.WithBaseURL(client.BaseURI),
autorest.WithPathParameters("/projects/{projectId}/images/regions", pathParameters),
autorest.WithJSON(batch),
autorest.WithHeader("Training-Key", client.APIKey))
return preparer.Prepare((&http.Request{}).WithContext(ctx))
}
// CreateImageRegionsSender sends the CreateImageRegions request. The method will close the
// http.Response Body if it receives an error.
func (client BaseClient) CreateImageRegionsSender(req *http.Request) (*http.Response, error) {
return autorest.SendWithSender(client, req,
autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
}
// CreateImageRegionsResponder handles the response to the CreateImageRegions request. The method always
// closes the http.Response Body.
func (client BaseClient) CreateImageRegionsResponder(resp *http.Response) (result ImageRegionCreateSummary, err error) {
err = autorest.Respond(
resp,
client.ByInspecting(),
azure.WithErrorUnlessStatusCode(http.StatusOK),
autorest.ByUnmarshallingJSON(&result),
autorest.ByClosing())
result.Response = autorest.Response{Response: resp}
return
}
// CreateImagesFromData this API accepts body content as multipart/form-data and application/octet-stream. When using
// multipart
// multiple image files can be sent at once, with a maximum of 64 files
// Parameters:
// projectID - the project id
// tagIds - the tags ids with which to tag each image. Limited to 20
func (client BaseClient) CreateImagesFromData(ctx context.Context, projectID uuid.UUID, imageData io.ReadCloser, tagIds []string) (result ImageCreateSummary, err error) {
req, err := client.CreateImagesFromDataPreparer(ctx, projectID, imageData, tagIds)
if err != nil {
err = autorest.NewErrorWithError(err, "training.BaseClient", "CreateImagesFromData", nil, "Failure preparing request")
return
}
resp, err := client.CreateImagesFromDataSender(req)
if err != nil {
result.Response = autorest.Response{Response: resp}
err = autorest.NewErrorWithError(err, "training.BaseClient", "CreateImagesFromData", resp, "Failure sending request")
return
}
result, err = client.CreateImagesFromDataResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "training.BaseClient", "CreateImagesFromData", resp, "Failure responding to request")
}
return
}
// CreateImagesFromDataPreparer prepares the CreateImagesFromData request.
func (client BaseClient) CreateImagesFromDataPreparer(ctx context.Context, projectID uuid.UUID, imageData io.ReadCloser, tagIds []string) (*http.Request, error) {
pathParameters := map[string]interface{}{
"projectId": autorest.Encode("path", projectID),
}
queryParameters := map[string]interface{}{}
if tagIds != nil && len(tagIds) > 0 {
queryParameters["tagIds"] = autorest.Encode("query", tagIds, ",")
}
formDataParameters := map[string]interface{}{
"imageData": imageData,
}
preparer := autorest.CreatePreparer(
autorest.AsPost(),
autorest.WithBaseURL(client.BaseURI),
autorest.WithPathParameters("/projects/{projectId}/images", pathParameters),
autorest.WithQueryParameters(queryParameters),
autorest.WithMultiPartFormData(formDataParameters),
autorest.WithHeader("Training-Key", client.APIKey))
return preparer.Prepare((&http.Request{}).WithContext(ctx))
}
// CreateImagesFromDataSender sends the CreateImagesFromData request. The method will close the
// http.Response Body if it receives an error.
func (client BaseClient) CreateImagesFromDataSender(req *http.Request) (*http.Response, error) {
return autorest.SendWithSender(client, req,
autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
}
// CreateImagesFromDataResponder handles the response to the CreateImagesFromData request. The method always
// closes the http.Response Body.
func (client BaseClient) CreateImagesFromDataResponder(resp *http.Response) (result ImageCreateSummary, err error) {
err = autorest.Respond(
resp,
client.ByInspecting(),
azure.WithErrorUnlessStatusCode(http.StatusOK),
autorest.ByUnmarshallingJSON(&result),
autorest.ByClosing())
result.Response = autorest.Response{Response: resp}
return
}
// CreateImagesFromFiles this API accepts a batch of files, and optionally tags, to create images. There is a limit of
// 64 images and 20 tags.
// Parameters:
// projectID - the project id
// batch - the batch of image files to add. Limited to 64 images and 20 tags per batch
func (client BaseClient) CreateImagesFromFiles(ctx context.Context, projectID uuid.UUID, batch ImageFileCreateBatch) (result ImageCreateSummary, err error) {
req, err := client.CreateImagesFromFilesPreparer(ctx, projectID, batch)
if err != nil {
err = autorest.NewErrorWithError(err, "training.BaseClient", "CreateImagesFromFiles", nil, "Failure preparing request")
return
}
resp, err := client.CreateImagesFromFilesSender(req)
if err != nil {
result.Response = autorest.Response{Response: resp}
err = autorest.NewErrorWithError(err, "training.BaseClient", "CreateImagesFromFiles", resp, "Failure sending request")
return
}
result, err = client.CreateImagesFromFilesResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "training.BaseClient", "CreateImagesFromFiles", resp, "Failure responding to request")
}
return
}
// CreateImagesFromFilesPreparer prepares the CreateImagesFromFiles request.
func (client BaseClient) CreateImagesFromFilesPreparer(ctx context.Context, projectID uuid.UUID, batch ImageFileCreateBatch) (*http.Request, error) {
pathParameters := map[string]interface{}{
"projectId": autorest.Encode("path", projectID),
}
preparer := autorest.CreatePreparer(
autorest.AsContentType("application/json; charset=utf-8"),
autorest.AsPost(),
autorest.WithBaseURL(client.BaseURI),
autorest.WithPathParameters("/projects/{projectId}/images/files", pathParameters),
autorest.WithJSON(batch),
autorest.WithHeader("Training-Key", client.APIKey))
return preparer.Prepare((&http.Request{}).WithContext(ctx))
}
// CreateImagesFromFilesSender sends the CreateImagesFromFiles request. The method will close the
// http.Response Body if it receives an error.
func (client BaseClient) CreateImagesFromFilesSender(req *http.Request) (*http.Response, error) {
return autorest.SendWithSender(client, req,
autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
}
// CreateImagesFromFilesResponder handles the response to the CreateImagesFromFiles request. The method always
// closes the http.Response Body.
func (client BaseClient) CreateImagesFromFilesResponder(resp *http.Response) (result ImageCreateSummary, err error) {
err = autorest.Respond(
resp,
client.ByInspecting(),
azure.WithErrorUnlessStatusCode(http.StatusOK),
autorest.ByUnmarshallingJSON(&result),
autorest.ByClosing())
result.Response = autorest.Response{Response: resp}
return
}
// CreateImagesFromPredictions this API creates a batch of images from predicted images specified. There is a limit of
// 64 images and 20 tags.
// Parameters:
// projectID - the project id
// batch - image and tag ids. Limted to 64 images and 20 tags per batch
func (client BaseClient) CreateImagesFromPredictions(ctx context.Context, projectID uuid.UUID, batch ImageIDCreateBatch) (result ImageCreateSummary, err error) {
req, err := client.CreateImagesFromPredictionsPreparer(ctx, projectID, batch)
if err != nil {
err = autorest.NewErrorWithError(err, "training.BaseClient", "CreateImagesFromPredictions", nil, "Failure preparing request")
return
}
resp, err := client.CreateImagesFromPredictionsSender(req)
if err != nil {
result.Response = autorest.Response{Response: resp}
err = autorest.NewErrorWithError(err, "training.BaseClient", "CreateImagesFromPredictions", resp, "Failure sending request")
return
}
result, err = client.CreateImagesFromPredictionsResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "training.BaseClient", "CreateImagesFromPredictions", resp, "Failure responding to request")
}
return
}
// CreateImagesFromPredictionsPreparer prepares the CreateImagesFromPredictions request.
func (client BaseClient) CreateImagesFromPredictionsPreparer(ctx context.Context, projectID uuid.UUID, batch ImageIDCreateBatch) (*http.Request, error) {
pathParameters := map[string]interface{}{
"projectId": autorest.Encode("path", projectID),
}
preparer := autorest.CreatePreparer(
autorest.AsContentType("application/json; charset=utf-8"),
autorest.AsPost(),
autorest.WithBaseURL(client.BaseURI),
autorest.WithPathParameters("/projects/{projectId}/images/predictions", pathParameters),
autorest.WithJSON(batch),
autorest.WithHeader("Training-Key", client.APIKey))
return preparer.Prepare((&http.Request{}).WithContext(ctx))
}
// CreateImagesFromPredictionsSender sends the CreateImagesFromPredictions request. The method will close the
// http.Response Body if it receives an error.
func (client BaseClient) CreateImagesFromPredictionsSender(req *http.Request) (*http.Response, error) {
return autorest.SendWithSender(client, req,
autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
}
// CreateImagesFromPredictionsResponder handles the response to the CreateImagesFromPredictions request. The method always
// closes the http.Response Body.
func (client BaseClient) CreateImagesFromPredictionsResponder(resp *http.Response) (result ImageCreateSummary, err error) {
err = autorest.Respond(
resp,
client.ByInspecting(),
azure.WithErrorUnlessStatusCode(http.StatusOK),
autorest.ByUnmarshallingJSON(&result),
autorest.ByClosing())
result.Response = autorest.Response{Response: resp}
return
}
// CreateImagesFromUrls this API accepts a batch of urls, and optionally tags, to create images. There is a limit of 64
// images and 20 tags.
// Parameters:
// projectID - the project id
// batch - image urls and tag ids. Limited to 64 images and 20 tags per batch
func (client BaseClient) CreateImagesFromUrls(ctx context.Context, projectID uuid.UUID, batch ImageURLCreateBatch) (result ImageCreateSummary, err error) {
req, err := client.CreateImagesFromUrlsPreparer(ctx, projectID, batch)
if err != nil {
err = autorest.NewErrorWithError(err, "training.BaseClient", "CreateImagesFromUrls", nil, "Failure preparing request")
return
}
resp, err := client.CreateImagesFromUrlsSender(req)
if err != nil {
result.Response = autorest.Response{Response: resp}
err = autorest.NewErrorWithError(err, "training.BaseClient", "CreateImagesFromUrls", resp, "Failure sending request")
return
}
result, err = client.CreateImagesFromUrlsResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "training.BaseClient", "CreateImagesFromUrls", resp, "Failure responding to request")
}
return
}
// CreateImagesFromUrlsPreparer prepares the CreateImagesFromUrls request.
func (client BaseClient) CreateImagesFromUrlsPreparer(ctx context.Context, projectID uuid.UUID, batch ImageURLCreateBatch) (*http.Request, error) {
pathParameters := map[string]interface{}{
"projectId": autorest.Encode("path", projectID),
}
preparer := autorest.CreatePreparer(
autorest.AsContentType("application/json; charset=utf-8"),
autorest.AsPost(),
autorest.WithBaseURL(client.BaseURI),
autorest.WithPathParameters("/projects/{projectId}/images/urls", pathParameters),
autorest.WithJSON(batch),
autorest.WithHeader("Training-Key", client.APIKey))
return preparer.Prepare((&http.Request{}).WithContext(ctx))
}
// CreateImagesFromUrlsSender sends the CreateImagesFromUrls request. The method will close the
// http.Response Body if it receives an error.
func (client BaseClient) CreateImagesFromUrlsSender(req *http.Request) (*http.Response, error) {
return autorest.SendWithSender(client, req,
autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
}
// CreateImagesFromUrlsResponder handles the response to the CreateImagesFromUrls request. The method always
// closes the http.Response Body.
func (client BaseClient) CreateImagesFromUrlsResponder(resp *http.Response) (result ImageCreateSummary, err error) {
err = autorest.Respond(
resp,
client.ByInspecting(),
azure.WithErrorUnlessStatusCode(http.StatusOK),
autorest.ByUnmarshallingJSON(&result),
autorest.ByClosing())
result.Response = autorest.Response{Response: resp}
return
}
// CreateImageTags sends the create image tags request.
// Parameters:
// projectID - the project id
// batch - batch of image tags. Limited to 128 tags per batch
func (client BaseClient) CreateImageTags(ctx context.Context, projectID uuid.UUID, batch ImageTagCreateBatch) (result ImageTagCreateSummary, err error) {
req, err := client.CreateImageTagsPreparer(ctx, projectID, batch)
if err != nil {
err = autorest.NewErrorWithError(err, "training.BaseClient", "CreateImageTags", nil, "Failure preparing request")
return
}
resp, err := client.CreateImageTagsSender(req)
if err != nil {
result.Response = autorest.Response{Response: resp}
err = autorest.NewErrorWithError(err, "training.BaseClient", "CreateImageTags", resp, "Failure sending request")
return
}
result, err = client.CreateImageTagsResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "training.BaseClient", "CreateImageTags", resp, "Failure responding to request")
}
return
}
// CreateImageTagsPreparer prepares the CreateImageTags request.
func (client BaseClient) CreateImageTagsPreparer(ctx context.Context, projectID uuid.UUID, batch ImageTagCreateBatch) (*http.Request, error) {
pathParameters := map[string]interface{}{
"projectId": autorest.Encode("path", projectID),
}
preparer := autorest.CreatePreparer(
autorest.AsContentType("application/json; charset=utf-8"),
autorest.AsPost(),
autorest.WithBaseURL(client.BaseURI),
autorest.WithPathParameters("/projects/{projectId}/images/tags", pathParameters),
autorest.WithJSON(batch),
autorest.WithHeader("Training-Key", client.APIKey))
return preparer.Prepare((&http.Request{}).WithContext(ctx))
}
// CreateImageTagsSender sends the CreateImageTags request. The method will close the
// http.Response Body if it receives an error.
func (client BaseClient) CreateImageTagsSender(req *http.Request) (*http.Response, error) {
return autorest.SendWithSender(client, req,
autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
}
// CreateImageTagsResponder handles the response to the CreateImageTags request. The method always
// closes the http.Response Body.
func (client BaseClient) CreateImageTagsResponder(resp *http.Response) (result ImageTagCreateSummary, err error) {
err = autorest.Respond(
resp,
client.ByInspecting(),
azure.WithErrorUnlessStatusCode(http.StatusOK),
autorest.ByUnmarshallingJSON(&result),
autorest.ByClosing())
result.Response = autorest.Response{Response: resp}
return
}
// CreateProject sends the create project request.
// Parameters:
// name - name of the project
// description - the description of the project
// domainID - the id of the domain to use for this project. Defaults to General
func (client BaseClient) CreateProject(ctx context.Context, name string, description string, domainID *uuid.UUID) (result Project, err error) {
req, err := client.CreateProjectPreparer(ctx, name, description, domainID)
if err != nil {
err = autorest.NewErrorWithError(err, "training.BaseClient", "CreateProject", nil, "Failure preparing request")
return
}
resp, err := client.CreateProjectSender(req)
if err != nil {
result.Response = autorest.Response{Response: resp}
err = autorest.NewErrorWithError(err, "training.BaseClient", "CreateProject", resp, "Failure sending request")
return
}
result, err = client.CreateProjectResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "training.BaseClient", "CreateProject", resp, "Failure responding to request")
}
return
}
// CreateProjectPreparer prepares the CreateProject request.
func (client BaseClient) CreateProjectPreparer(ctx context.Context, name string, description string, domainID *uuid.UUID) (*http.Request, error) {
queryParameters := map[string]interface{}{
"name": autorest.Encode("query", name),
}
if len(description) > 0 {
queryParameters["description"] = autorest.Encode("query", description)
}
if domainID != nil {
queryParameters["domainId"] = autorest.Encode("query", *domainID)
}
preparer := autorest.CreatePreparer(
autorest.AsPost(),
autorest.WithBaseURL(client.BaseURI),
autorest.WithPath("/projects"),
autorest.WithQueryParameters(queryParameters),
autorest.WithHeader("Training-Key", client.APIKey))
return preparer.Prepare((&http.Request{}).WithContext(ctx))
}
// CreateProjectSender sends the CreateProject request. The method will close the
// http.Response Body if it receives an error.
func (client BaseClient) CreateProjectSender(req *http.Request) (*http.Response, error) {
return autorest.SendWithSender(client, req,
autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
}
// CreateProjectResponder handles the response to the CreateProject request. The method always
// closes the http.Response Body.
func (client BaseClient) CreateProjectResponder(resp *http.Response) (result Project, err error) {
err = autorest.Respond(
resp,
client.ByInspecting(),
azure.WithErrorUnlessStatusCode(http.StatusOK),
autorest.ByUnmarshallingJSON(&result),
autorest.ByClosing())
result.Response = autorest.Response{Response: resp}
return
}
// CreateTag sends the create tag request.
// Parameters:
// projectID - the project id
// name - the tag name
// description - optional description for the tag
func (client BaseClient) CreateTag(ctx context.Context, projectID uuid.UUID, name string, description string) (result Tag, err error) {
req, err := client.CreateTagPreparer(ctx, projectID, name, description)
if err != nil {
err = autorest.NewErrorWithError(err, "training.BaseClient", "CreateTag", nil, "Failure preparing request")
return
}
resp, err := client.CreateTagSender(req)
if err != nil {
result.Response = autorest.Response{Response: resp}
err = autorest.NewErrorWithError(err, "training.BaseClient", "CreateTag", resp, "Failure sending request")
return
}
result, err = client.CreateTagResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "training.BaseClient", "CreateTag", resp, "Failure responding to request")
}
return
}
// CreateTagPreparer prepares the CreateTag request.
func (client BaseClient) CreateTagPreparer(ctx context.Context, projectID uuid.UUID, name string, description string) (*http.Request, error) {
pathParameters := map[string]interface{}{
"projectId": autorest.Encode("path", projectID),
}
queryParameters := map[string]interface{}{
"name": autorest.Encode("query", name),
}
if len(description) > 0 {
queryParameters["description"] = autorest.Encode("query", description)
}
preparer := autorest.CreatePreparer(
autorest.AsPost(),
autorest.WithBaseURL(client.BaseURI),
autorest.WithPathParameters("/projects/{projectId}/tags", pathParameters),
autorest.WithQueryParameters(queryParameters),
autorest.WithHeader("Training-Key", client.APIKey))
return preparer.Prepare((&http.Request{}).WithContext(ctx))
}
// CreateTagSender sends the CreateTag request. The method will close the
// http.Response Body if it receives an error.
func (client BaseClient) CreateTagSender(req *http.Request) (*http.Response, error) {
return autorest.SendWithSender(client, req,
autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
}
// CreateTagResponder handles the response to the CreateTag request. The method always
// closes the http.Response Body.
func (client BaseClient) CreateTagResponder(resp *http.Response) (result Tag, err error) {
err = autorest.Respond(
resp,
client.ByInspecting(),
azure.WithErrorUnlessStatusCode(http.StatusOK),
autorest.ByUnmarshallingJSON(&result),
autorest.ByClosing())
result.Response = autorest.Response{Response: resp}
return
}
// DeleteImageRegions sends the delete image regions request.
// Parameters:
// projectID - the project id
// regionIds - regions to delete. Limited to 64
func (client BaseClient) DeleteImageRegions(ctx context.Context, projectID uuid.UUID, regionIds []string) (result autorest.Response, err error) {
if err := validation.Validate([]validation.Validation{
{TargetValue: regionIds,
Constraints: []validation.Constraint{{Target: "regionIds", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil {
return result, validation.NewError("training.BaseClient", "DeleteImageRegions", err.Error())
}
req, err := client.DeleteImageRegionsPreparer(ctx, projectID, regionIds)
if err != nil {
err = autorest.NewErrorWithError(err, "training.BaseClient", "DeleteImageRegions", nil, "Failure preparing request")
return
}
resp, err := client.DeleteImageRegionsSender(req)
if err != nil {
result.Response = resp
err = autorest.NewErrorWithError(err, "training.BaseClient", "DeleteImageRegions", resp, "Failure sending request")
return
}
result, err = client.DeleteImageRegionsResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "training.BaseClient", "DeleteImageRegions", resp, "Failure responding to request")
}
return
}
// DeleteImageRegionsPreparer prepares the DeleteImageRegions request.
func (client BaseClient) DeleteImageRegionsPreparer(ctx context.Context, projectID uuid.UUID, regionIds []string) (*http.Request, error) {
pathParameters := map[string]interface{}{
"projectId": autorest.Encode("path", projectID),
}
queryParameters := map[string]interface{}{
"regionIds": autorest.Encode("query", regionIds, ","),
}
preparer := autorest.CreatePreparer(
autorest.AsDelete(),
autorest.WithBaseURL(client.BaseURI),
autorest.WithPathParameters("/projects/{projectId}/images/regions", pathParameters),
autorest.WithQueryParameters(queryParameters),
autorest.WithHeader("Training-Key", client.APIKey))
return preparer.Prepare((&http.Request{}).WithContext(ctx))
}
// DeleteImageRegionsSender sends the DeleteImageRegions request. The method will close the
// http.Response Body if it receives an error.
func (client BaseClient) DeleteImageRegionsSender(req *http.Request) (*http.Response, error) {
return autorest.SendWithSender(client, req,
autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
}
// DeleteImageRegionsResponder handles the response to the DeleteImageRegions request. The method always
// closes the http.Response Body.
func (client BaseClient) DeleteImageRegionsResponder(resp *http.Response) (result autorest.Response, err error) {
err = autorest.Respond(
resp,
client.ByInspecting(),
azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent),
autorest.ByClosing())
result.Response = resp
return
}
// DeleteImages sends the delete images request.
// Parameters:
// projectID - the project id
// imageIds - ids of the images to be deleted. Limted to 256 images per batch
func (client BaseClient) DeleteImages(ctx context.Context, projectID uuid.UUID, imageIds []string) (result autorest.Response, err error) {
if err := validation.Validate([]validation.Validation{
{TargetValue: imageIds,
Constraints: []validation.Constraint{{Target: "imageIds", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil {
return result, validation.NewError("training.BaseClient", "DeleteImages", err.Error())
}
req, err := client.DeleteImagesPreparer(ctx, projectID, imageIds)
if err != nil {
err = autorest.NewErrorWithError(err, "training.BaseClient", "DeleteImages", nil, "Failure preparing request")
return
}
resp, err := client.DeleteImagesSender(req)
if err != nil {
result.Response = resp
err = autorest.NewErrorWithError(err, "training.BaseClient", "DeleteImages", resp, "Failure sending request")
return
}
result, err = client.DeleteImagesResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "training.BaseClient", "DeleteImages", resp, "Failure responding to request")
}
return
}
// DeleteImagesPreparer prepares the DeleteImages request.
func (client BaseClient) DeleteImagesPreparer(ctx context.Context, projectID uuid.UUID, imageIds []string) (*http.Request, error) {
pathParameters := map[string]interface{}{
"projectId": autorest.Encode("path", projectID),
}
queryParameters := map[string]interface{}{
"imageIds": autorest.Encode("query", imageIds, ","),
}
preparer := autorest.CreatePreparer(
autorest.AsDelete(),
autorest.WithBaseURL(client.BaseURI),
autorest.WithPathParameters("/projects/{projectId}/images", pathParameters),
autorest.WithQueryParameters(queryParameters),
autorest.WithHeader("Training-Key", client.APIKey))
return preparer.Prepare((&http.Request{}).WithContext(ctx))
}
// DeleteImagesSender sends the DeleteImages request. The method will close the
// http.Response Body if it receives an error.
func (client BaseClient) DeleteImagesSender(req *http.Request) (*http.Response, error) {
return autorest.SendWithSender(client, req,
autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
}
// DeleteImagesResponder handles the response to the DeleteImages request. The method always
// closes the http.Response Body.
func (client BaseClient) DeleteImagesResponder(resp *http.Response) (result autorest.Response, err error) {
err = autorest.Respond(
resp,
client.ByInspecting(),
azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent),
autorest.ByClosing())
result.Response = resp
return
}
// DeleteImageTags sends the delete image tags request.
// Parameters:
// projectID - the project id
// imageIds - image ids. Limited to 64 images
// tagIds - tags to be deleted from the specified images. Limted to 20 tags
func (client BaseClient) DeleteImageTags(ctx context.Context, projectID uuid.UUID, imageIds []string, tagIds []string) (result autorest.Response, err error) {
if err := validation.Validate([]validation.Validation{
{TargetValue: imageIds,
Constraints: []validation.Constraint{{Target: "imageIds", Name: validation.Null, Rule: true, Chain: nil}}},
{TargetValue: tagIds,
Constraints: []validation.Constraint{{Target: "tagIds", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil {
return result, validation.NewError("training.BaseClient", "DeleteImageTags", err.Error())
}
req, err := client.DeleteImageTagsPreparer(ctx, projectID, imageIds, tagIds)
if err != nil {
err = autorest.NewErrorWithError(err, "training.BaseClient", "DeleteImageTags", nil, "Failure preparing request")
return
}
resp, err := client.DeleteImageTagsSender(req)
if err != nil {
result.Response = resp
err = autorest.NewErrorWithError(err, "training.BaseClient", "DeleteImageTags", resp, "Failure sending request")
return
}
result, err = client.DeleteImageTagsResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "training.BaseClient", "DeleteImageTags", resp, "Failure responding to request")
}
return
}
// DeleteImageTagsPreparer prepares the DeleteImageTags request.
func (client BaseClient) DeleteImageTagsPreparer(ctx context.Context, projectID uuid.UUID, imageIds []string, tagIds []string) (*http.Request, error) {
pathParameters := map[string]interface{}{
"projectId": autorest.Encode("path", projectID),
}
queryParameters := map[string]interface{}{
"imageIds": autorest.Encode("query", imageIds, ","),
"tagIds": autorest.Encode("query", tagIds, ","),
}
preparer := autorest.CreatePreparer(
autorest.AsDelete(),
autorest.WithBaseURL(client.BaseURI),
autorest.WithPathParameters("/projects/{projectId}/images/tags", pathParameters),
autorest.WithQueryParameters(queryParameters),
autorest.WithHeader("Training-Key", client.APIKey))
return preparer.Prepare((&http.Request{}).WithContext(ctx))
}
// DeleteImageTagsSender sends the DeleteImageTags request. The method will close the
// http.Response Body if it receives an error.
func (client BaseClient) DeleteImageTagsSender(req *http.Request) (*http.Response, error) {
return autorest.SendWithSender(client, req,
autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
}
// DeleteImageTagsResponder handles the response to the DeleteImageTags request. The method always
// closes the http.Response Body.
func (client BaseClient) DeleteImageTagsResponder(resp *http.Response) (result autorest.Response, err error) {
err = autorest.Respond(
resp,
client.ByInspecting(),
azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent),
autorest.ByClosing())
result.Response = resp
return
}
// DeleteIteration sends the delete iteration request.
// Parameters:
// projectID - the project id
// iterationID - the iteration id
func (client BaseClient) DeleteIteration(ctx context.Context, projectID uuid.UUID, iterationID uuid.UUID) (result autorest.Response, err error) {
req, err := client.DeleteIterationPreparer(ctx, projectID, iterationID)
if err != nil {
err = autorest.NewErrorWithError(err, "training.BaseClient", "DeleteIteration", nil, "Failure preparing request")
return
}
resp, err := client.DeleteIterationSender(req)
if err != nil {
result.Response = resp
err = autorest.NewErrorWithError(err, "training.BaseClient", "DeleteIteration", resp, "Failure sending request")
return
}
result, err = client.DeleteIterationResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "training.BaseClient", "DeleteIteration", resp, "Failure responding to request")
}
return
}
// DeleteIterationPreparer prepares the DeleteIteration request.
func (client BaseClient) DeleteIterationPreparer(ctx context.Context, projectID uuid.UUID, iterationID uuid.UUID) (*http.Request, error) {
pathParameters := map[string]interface{}{
"iterationId": autorest.Encode("path", iterationID),
"projectId": autorest.Encode("path", projectID),
}
preparer := autorest.CreatePreparer(
autorest.AsDelete(),
autorest.WithBaseURL(client.BaseURI),
autorest.WithPathParameters("/projects/{projectId}/iterations/{iterationId}", pathParameters),
autorest.WithHeader("Training-Key", client.APIKey))
return preparer.Prepare((&http.Request{}).WithContext(ctx))
}
// DeleteIterationSender sends the DeleteIteration request. The method will close the
// http.Response Body if it receives an error.
func (client BaseClient) DeleteIterationSender(req *http.Request) (*http.Response, error) {
return autorest.SendWithSender(client, req,
autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
}
// DeleteIterationResponder handles the response to the DeleteIteration request. The method always
// closes the http.Response Body.
func (client BaseClient) DeleteIterationResponder(resp *http.Response) (result autorest.Response, err error) {
err = autorest.Respond(
resp,
client.ByInspecting(),
azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent),
autorest.ByClosing())
result.Response = resp
return
}
// DeletePrediction sends the delete prediction request.
// Parameters:
// projectID - the project id
// ids - the prediction ids. Limited to 64
func (client BaseClient) DeletePrediction(ctx context.Context, projectID uuid.UUID, ids []string) (result autorest.Response, err error) {
if err := validation.Validate([]validation.Validation{
{TargetValue: ids,
Constraints: []validation.Constraint{{Target: "ids", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil {
return result, validation.NewError("training.BaseClient", "DeletePrediction", err.Error())
}
req, err := client.DeletePredictionPreparer(ctx, projectID, ids)
if err != nil {
err = autorest.NewErrorWithError(err, "training.BaseClient", "DeletePrediction", nil, "Failure preparing request")
return
}
resp, err := client.DeletePredictionSender(req)
if err != nil {
result.Response = resp
err = autorest.NewErrorWithError(err, "training.BaseClient", "DeletePrediction", resp, "Failure sending request")
return
}
result, err = client.DeletePredictionResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "training.BaseClient", "DeletePrediction", resp, "Failure responding to request")
}
return
}
// DeletePredictionPreparer prepares the DeletePrediction request.
func (client BaseClient) DeletePredictionPreparer(ctx context.Context, projectID uuid.UUID, ids []string) (*http.Request, error) {
pathParameters := map[string]interface{}{
"projectId": autorest.Encode("path", projectID),
}
queryParameters := map[string]interface{}{
"ids": autorest.Encode("query", ids, ","),
}
preparer := autorest.CreatePreparer(
autorest.AsDelete(),
autorest.WithBaseURL(client.BaseURI),
autorest.WithPathParameters("/projects/{projectId}/predictions", pathParameters),
autorest.WithQueryParameters(queryParameters),
autorest.WithHeader("Training-Key", client.APIKey))
return preparer.Prepare((&http.Request{}).WithContext(ctx))
}
// DeletePredictionSender sends the DeletePrediction request. The method will close the
// http.Response Body if it receives an error.
func (client BaseClient) DeletePredictionSender(req *http.Request) (*http.Response, error) {
return autorest.SendWithSender(client, req,
autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
}
// DeletePredictionResponder handles the response to the DeletePrediction request. The method always
// closes the http.Response Body.
func (client BaseClient) DeletePredictionResponder(resp *http.Response) (result autorest.Response, err error) {
err = autorest.Respond(
resp,
client.ByInspecting(),
azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent),
autorest.ByClosing())
result.Response = resp
return
}
// DeleteProject sends the delete project request.
// Parameters:
// projectID - the project id
func (client BaseClient) DeleteProject(ctx context.Context, projectID uuid.UUID) (result autorest.Response, err error) {
req, err := client.DeleteProjectPreparer(ctx, projectID)
if err != nil {
err = autorest.NewErrorWithError(err, "training.BaseClient", "DeleteProject", nil, "Failure preparing request")
return
}
resp, err := client.DeleteProjectSender(req)
if err != nil {
result.Response = resp
err = autorest.NewErrorWithError(err, "training.BaseClient", "DeleteProject", resp, "Failure sending request")
return
}
result, err = client.DeleteProjectResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "training.BaseClient", "DeleteProject", resp, "Failure responding to request")
}
return
}
// DeleteProjectPreparer prepares the DeleteProject request.
func (client BaseClient) DeleteProjectPreparer(ctx context.Context, projectID uuid.UUID) (*http.Request, error) {
pathParameters := map[string]interface{}{
"projectId": autorest.Encode("path", projectID),
}
preparer := autorest.CreatePreparer(
autorest.AsDelete(),
autorest.WithBaseURL(client.BaseURI),
autorest.WithPathParameters("/projects/{projectId}", pathParameters),
autorest.WithHeader("Training-Key", client.APIKey))
return preparer.Prepare((&http.Request{}).WithContext(ctx))
}
// DeleteProjectSender sends the DeleteProject request. The method will close the
// http.Response Body if it receives an error.
func (client BaseClient) DeleteProjectSender(req *http.Request) (*http.Response, error) {
return autorest.SendWithSender(client, req,
autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
}
// DeleteProjectResponder handles the response to the DeleteProject request. The method always
// closes the http.Response Body.
func (client BaseClient) DeleteProjectResponder(resp *http.Response) (result autorest.Response, err error) {
err = autorest.Respond(
resp,
client.ByInspecting(),
azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent),
autorest.ByClosing())
result.Response = resp
return
}
// DeleteTag sends the delete tag request.
// Parameters:
// projectID - the project id
// tagID - id of the tag to be deleted
func (client BaseClient) DeleteTag(ctx context.Context, projectID uuid.UUID, tagID uuid.UUID) (result autorest.Response, err error) {
req, err := client.DeleteTagPreparer(ctx, projectID, tagID)
if err != nil {
err = autorest.NewErrorWithError(err, "training.BaseClient", "DeleteTag", nil, "Failure preparing request")
return
}
resp, err := client.DeleteTagSender(req)
if err != nil {
result.Response = resp
err = autorest.NewErrorWithError(err, "training.BaseClient", "DeleteTag", resp, "Failure sending request")