/
client.go
1583 lines (1453 loc) · 59.9 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
// --------------------------------------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// --------------------------------------------------------------------------------------------
// Generated file, DO NOT EDIT
// Changes may cause incorrect behavior and will be lost if the code is regenerated.
// --------------------------------------------------------------------------------------------
package release
import (
"bytes"
"context"
"encoding/json"
"github.com/google/uuid"
"github.com/microsoft/azure-devops-go-api/azuredevops"
"io"
"net/http"
"net/url"
"strconv"
"strings"
)
var ResourceAreaId, _ = uuid.Parse("efc2f575-36ef-48e9-b672-0c6fb4a48ac5")
type Client interface {
// [Preview API] Creates a new folder.
CreateFolder(context.Context, CreateFolderArgs) (*Folder, error)
// Create a release.
CreateRelease(context.Context, CreateReleaseArgs) (*Release, error)
// Create a release definition
CreateReleaseDefinition(context.Context, CreateReleaseDefinitionArgs) (*ReleaseDefinition, error)
// [Preview API] Deletes a definition folder for given folder name and path and all it's existing definitions.
DeleteFolder(context.Context, DeleteFolderArgs) error
// Delete a release definition.
DeleteReleaseDefinition(context.Context, DeleteReleaseDefinitionArgs) error
// Get a list of approvals
GetApprovals(context.Context, GetApprovalsArgs) (*GetApprovalsResponseValue, error)
// [Preview API] Get release definition for a given definitionId and revision
GetDefinitionRevision(context.Context, GetDefinitionRevisionArgs) (io.ReadCloser, error)
GetDeployments(context.Context, GetDeploymentsArgs) (*GetDeploymentsResponseValue, error)
// [Preview API] Gets folders.
GetFolders(context.Context, GetFoldersArgs) (*[]Folder, error)
// [Preview API] Get logs for a release Id.
GetLogs(context.Context, GetLogsArgs) (io.ReadCloser, error)
// Get manual intervention for a given release and manual intervention id.
GetManualIntervention(context.Context, GetManualInterventionArgs) (*ManualIntervention, error)
// List all manual interventions for a given release.
GetManualInterventions(context.Context, GetManualInterventionsArgs) (*[]ManualIntervention, error)
// Get a Release
GetRelease(context.Context, GetReleaseArgs) (*Release, error)
// Get a release definition.
GetReleaseDefinition(context.Context, GetReleaseDefinitionArgs) (*ReleaseDefinition, error)
// [Preview API] Get revision history for a release definition
GetReleaseDefinitionHistory(context.Context, GetReleaseDefinitionHistoryArgs) (*[]ReleaseDefinitionRevision, error)
// Get a list of release definitions.
GetReleaseDefinitions(context.Context, GetReleaseDefinitionsArgs) (*GetReleaseDefinitionsResponseValue, error)
// [Preview API] Get a release environment.
GetReleaseEnvironment(context.Context, GetReleaseEnvironmentArgs) (*ReleaseEnvironment, error)
// Get release for a given revision number.
GetReleaseRevision(context.Context, GetReleaseRevisionArgs) (io.ReadCloser, error)
// Get a list of releases
GetReleases(context.Context, GetReleasesArgs) (*GetReleasesResponseValue, error)
// [Preview API] Get a release task attachment.
GetReleaseTaskAttachmentContent(context.Context, GetReleaseTaskAttachmentContentArgs) (io.ReadCloser, error)
// [Preview API] Get the release task attachments.
GetReleaseTaskAttachments(context.Context, GetReleaseTaskAttachmentsArgs) (*[]ReleaseTaskAttachment, error)
// [Preview API] Gets the task log of a release as a plain text file.
GetTaskLog(context.Context, GetTaskLogArgs) (io.ReadCloser, error)
// [Preview API] Updates an existing folder at given existing path.
UpdateFolder(context.Context, UpdateFolderArgs) (*Folder, error)
// [Preview API] Updates the gate for a deployment.
UpdateGates(context.Context, UpdateGatesArgs) (*ReleaseGates, error)
// Update manual intervention.
UpdateManualIntervention(context.Context, UpdateManualInterventionArgs) (*ManualIntervention, error)
// Update a complete release object.
UpdateRelease(context.Context, UpdateReleaseArgs) (*Release, error)
// Update status of an approval
UpdateReleaseApproval(context.Context, UpdateReleaseApprovalArgs) (*ReleaseApproval, error)
// Update a release definition.
UpdateReleaseDefinition(context.Context, UpdateReleaseDefinitionArgs) (*ReleaseDefinition, error)
// [Preview API] Update the status of a release environment
UpdateReleaseEnvironment(context.Context, UpdateReleaseEnvironmentArgs) (*ReleaseEnvironment, error)
// Update few properties of a release.
UpdateReleaseResource(context.Context, UpdateReleaseResourceArgs) (*Release, error)
}
type ClientImpl struct {
Client azuredevops.Client
}
func NewClient(ctx context.Context, connection *azuredevops.Connection) (Client, error) {
client, err := connection.GetClientByResourceAreaId(ctx, ResourceAreaId)
if err != nil {
return nil, err
}
return &ClientImpl{
Client: *client,
}, nil
}
// [Preview API] Creates a new folder.
func (client *ClientImpl) CreateFolder(ctx context.Context, args CreateFolderArgs) (*Folder, error) {
if args.Folder == nil {
return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.Folder"}
}
routeValues := make(map[string]string)
if args.Project == nil || *args.Project == "" {
return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"}
}
routeValues["project"] = *args.Project
body, marshalErr := json.Marshal(*args.Folder)
if marshalErr != nil {
return nil, marshalErr
}
locationId, _ := uuid.Parse("f7ddf76d-ce0c-4d68-94ff-becaec5d9dea")
resp, err := client.Client.Send(ctx, http.MethodPost, locationId, "5.1-preview.2", routeValues, nil, bytes.NewReader(body), "application/json", "application/json", nil)
if err != nil {
return nil, err
}
var responseValue Folder
err = client.Client.UnmarshalBody(resp, &responseValue)
return &responseValue, err
}
// Arguments for the CreateFolder function
type CreateFolderArgs struct {
// (required) Folder to create.
Folder *Folder
// (required) Project ID or project name
Project *string
}
// Create a release.
func (client *ClientImpl) CreateRelease(ctx context.Context, args CreateReleaseArgs) (*Release, error) {
if args.ReleaseStartMetadata == nil {
return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.ReleaseStartMetadata"}
}
routeValues := make(map[string]string)
if args.Project == nil || *args.Project == "" {
return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"}
}
routeValues["project"] = *args.Project
body, marshalErr := json.Marshal(*args.ReleaseStartMetadata)
if marshalErr != nil {
return nil, marshalErr
}
locationId, _ := uuid.Parse("a166fde7-27ad-408e-ba75-703c2cc9d500")
resp, err := client.Client.Send(ctx, http.MethodPost, locationId, "5.1", routeValues, nil, bytes.NewReader(body), "application/json", "application/json", nil)
if err != nil {
return nil, err
}
var responseValue Release
err = client.Client.UnmarshalBody(resp, &responseValue)
return &responseValue, err
}
// Arguments for the CreateRelease function
type CreateReleaseArgs struct {
// (required) Metadata to create a release.
ReleaseStartMetadata *ReleaseStartMetadata
// (required) Project ID or project name
Project *string
}
// Create a release definition
func (client *ClientImpl) CreateReleaseDefinition(ctx context.Context, args CreateReleaseDefinitionArgs) (*ReleaseDefinition, error) {
if args.ReleaseDefinition == nil {
return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.ReleaseDefinition"}
}
routeValues := make(map[string]string)
if args.Project == nil || *args.Project == "" {
return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"}
}
routeValues["project"] = *args.Project
body, marshalErr := json.Marshal(*args.ReleaseDefinition)
if marshalErr != nil {
return nil, marshalErr
}
locationId, _ := uuid.Parse("d8f96f24-8ea7-4cb6-baab-2df8fc515665")
resp, err := client.Client.Send(ctx, http.MethodPost, locationId, "5.1", routeValues, nil, bytes.NewReader(body), "application/json", "application/json", nil)
if err != nil {
return nil, err
}
var responseValue ReleaseDefinition
err = client.Client.UnmarshalBody(resp, &responseValue)
return &responseValue, err
}
// Arguments for the CreateReleaseDefinition function
type CreateReleaseDefinitionArgs struct {
// (required) release definition object to create.
ReleaseDefinition *ReleaseDefinition
// (required) Project ID or project name
Project *string
}
// [Preview API] Deletes a definition folder for given folder name and path and all it's existing definitions.
func (client *ClientImpl) DeleteFolder(ctx context.Context, args DeleteFolderArgs) error {
routeValues := make(map[string]string)
if args.Project == nil || *args.Project == "" {
return &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"}
}
routeValues["project"] = *args.Project
if args.Path == nil || *args.Path == "" {
return &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Path"}
}
routeValues["path"] = *args.Path
locationId, _ := uuid.Parse("f7ddf76d-ce0c-4d68-94ff-becaec5d9dea")
_, err := client.Client.Send(ctx, http.MethodDelete, locationId, "5.1-preview.2", routeValues, nil, nil, "", "application/json", nil)
if err != nil {
return err
}
return nil
}
// Arguments for the DeleteFolder function
type DeleteFolderArgs struct {
// (required) Project ID or project name
Project *string
// (required) Path of the folder to delete.
Path *string
}
// Delete a release definition.
func (client *ClientImpl) DeleteReleaseDefinition(ctx context.Context, args DeleteReleaseDefinitionArgs) error {
routeValues := make(map[string]string)
if args.Project == nil || *args.Project == "" {
return &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"}
}
routeValues["project"] = *args.Project
if args.DefinitionId == nil {
return &azuredevops.ArgumentNilError{ArgumentName: "args.DefinitionId"}
}
routeValues["definitionId"] = strconv.Itoa(*args.DefinitionId)
queryParams := url.Values{}
if args.Comment != nil {
queryParams.Add("comment", *args.Comment)
}
if args.ForceDelete != nil {
queryParams.Add("forceDelete", strconv.FormatBool(*args.ForceDelete))
}
locationId, _ := uuid.Parse("d8f96f24-8ea7-4cb6-baab-2df8fc515665")
_, err := client.Client.Send(ctx, http.MethodDelete, locationId, "5.1", routeValues, queryParams, nil, "", "application/json", nil)
if err != nil {
return err
}
return nil
}
// Arguments for the DeleteReleaseDefinition function
type DeleteReleaseDefinitionArgs struct {
// (required) Project ID or project name
Project *string
// (required) Id of the release definition.
DefinitionId *int
// (optional) Comment for deleting a release definition.
Comment *string
// (optional) 'true' to automatically cancel any in-progress release deployments and proceed with release definition deletion . Default is 'false'.
ForceDelete *bool
}
// Get a list of approvals
func (client *ClientImpl) GetApprovals(ctx context.Context, args GetApprovalsArgs) (*GetApprovalsResponseValue, error) {
routeValues := make(map[string]string)
if args.Project == nil || *args.Project == "" {
return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"}
}
routeValues["project"] = *args.Project
queryParams := url.Values{}
if args.AssignedToFilter != nil {
queryParams.Add("assignedToFilter", *args.AssignedToFilter)
}
if args.StatusFilter != nil {
queryParams.Add("statusFilter", string(*args.StatusFilter))
}
if args.ReleaseIdsFilter != nil {
var stringList []string
for _, item := range *args.ReleaseIdsFilter {
stringList = append(stringList, strconv.Itoa(item))
}
listAsString := strings.Join((stringList)[:], ",")
queryParams.Add("releaseIdsFilter", listAsString)
}
if args.TypeFilter != nil {
queryParams.Add("typeFilter", string(*args.TypeFilter))
}
if args.Top != nil {
queryParams.Add("top", strconv.Itoa(*args.Top))
}
if args.ContinuationToken != nil {
queryParams.Add("continuationToken", strconv.Itoa(*args.ContinuationToken))
}
if args.QueryOrder != nil {
queryParams.Add("queryOrder", string(*args.QueryOrder))
}
if args.IncludeMyGroupApprovals != nil {
queryParams.Add("includeMyGroupApprovals", strconv.FormatBool(*args.IncludeMyGroupApprovals))
}
locationId, _ := uuid.Parse("b47c6458-e73b-47cb-a770-4df1e8813a91")
resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1", routeValues, queryParams, nil, "", "application/json", nil)
if err != nil {
return nil, err
}
var responseValue GetApprovalsResponseValue
responseValue.ContinuationToken = resp.Header.Get(azuredevops.HeaderKeyContinuationToken)
err = client.Client.UnmarshalCollectionBody(resp, &responseValue.Value)
return &responseValue, err
}
// Arguments for the GetApprovals function
type GetApprovalsArgs struct {
// (required) Project ID or project name
Project *string
// (optional) Approvals assigned to this user.
AssignedToFilter *string
// (optional) Approvals with this status. Default is 'pending'.
StatusFilter *ApprovalStatus
// (optional) Approvals for release id(s) mentioned in the filter. Multiple releases can be mentioned by separating them with ',' e.g. releaseIdsFilter=1,2,3,4.
ReleaseIdsFilter *[]int
// (optional) Approval with this type.
TypeFilter *ApprovalType
// (optional) Number of approvals to get. Default is 50.
Top *int
// (optional) Gets the approvals after the continuation token provided.
ContinuationToken *int
// (optional) Gets the results in the defined order of created approvals. Default is 'descending'.
QueryOrder *ReleaseQueryOrder
// (optional) 'true' to include my group approvals. Default is 'false'.
IncludeMyGroupApprovals *bool
}
// Return type for the GetApprovals function
type GetApprovalsResponseValue struct {
Value []ReleaseApproval
// The continuation token to be used to get the next page of results.
ContinuationToken string
}
// [Preview API] Get release definition for a given definitionId and revision
func (client *ClientImpl) GetDefinitionRevision(ctx context.Context, args GetDefinitionRevisionArgs) (io.ReadCloser, error) {
routeValues := make(map[string]string)
if args.Project == nil || *args.Project == "" {
return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"}
}
routeValues["project"] = *args.Project
if args.DefinitionId == nil {
return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.DefinitionId"}
}
routeValues["definitionId"] = strconv.Itoa(*args.DefinitionId)
if args.Revision == nil {
return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.Revision"}
}
routeValues["revision"] = strconv.Itoa(*args.Revision)
locationId, _ := uuid.Parse("258b82e0-9d41-43f3-86d6-fef14ddd44bc")
resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1-preview.1", routeValues, nil, nil, "", "text/plain", nil)
if err != nil {
return nil, err
}
return resp.Body, err
}
// Arguments for the GetDefinitionRevision function
type GetDefinitionRevisionArgs struct {
// (required) Project ID or project name
Project *string
// (required) Id of the definition.
DefinitionId *int
// (required) Id of the revision.
Revision *int
}
func (client *ClientImpl) GetDeployments(ctx context.Context, args GetDeploymentsArgs) (*GetDeploymentsResponseValue, error) {
routeValues := make(map[string]string)
if args.Project == nil || *args.Project == "" {
return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"}
}
routeValues["project"] = *args.Project
queryParams := url.Values{}
if args.DefinitionId != nil {
queryParams.Add("definitionId", strconv.Itoa(*args.DefinitionId))
}
if args.DefinitionEnvironmentId != nil {
queryParams.Add("definitionEnvironmentId", strconv.Itoa(*args.DefinitionEnvironmentId))
}
if args.CreatedBy != nil {
queryParams.Add("createdBy", *args.CreatedBy)
}
if args.MinModifiedTime != nil {
queryParams.Add("minModifiedTime", (*args.MinModifiedTime).AsQueryParameter())
}
if args.MaxModifiedTime != nil {
queryParams.Add("maxModifiedTime", (*args.MaxModifiedTime).AsQueryParameter())
}
if args.DeploymentStatus != nil {
queryParams.Add("deploymentStatus", string(*args.DeploymentStatus))
}
if args.OperationStatus != nil {
queryParams.Add("operationStatus", string(*args.OperationStatus))
}
if args.LatestAttemptsOnly != nil {
queryParams.Add("latestAttemptsOnly", strconv.FormatBool(*args.LatestAttemptsOnly))
}
if args.QueryOrder != nil {
queryParams.Add("queryOrder", string(*args.QueryOrder))
}
if args.Top != nil {
queryParams.Add("$top", strconv.Itoa(*args.Top))
}
if args.ContinuationToken != nil {
queryParams.Add("continuationToken", strconv.Itoa(*args.ContinuationToken))
}
if args.CreatedFor != nil {
queryParams.Add("createdFor", *args.CreatedFor)
}
if args.MinStartedTime != nil {
queryParams.Add("minStartedTime", (*args.MinStartedTime).AsQueryParameter())
}
if args.MaxStartedTime != nil {
queryParams.Add("maxStartedTime", (*args.MaxStartedTime).AsQueryParameter())
}
if args.SourceBranch != nil {
queryParams.Add("sourceBranch", *args.SourceBranch)
}
locationId, _ := uuid.Parse("b005ef73-cddc-448e-9ba2-5193bf36b19f")
resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1", routeValues, queryParams, nil, "", "application/json", nil)
if err != nil {
return nil, err
}
var responseValue GetDeploymentsResponseValue
responseValue.ContinuationToken = resp.Header.Get(azuredevops.HeaderKeyContinuationToken)
err = client.Client.UnmarshalCollectionBody(resp, &responseValue.Value)
return &responseValue, err
}
// Arguments for the GetDeployments function
type GetDeploymentsArgs struct {
// (required) Project ID or project name
Project *string
// (optional)
DefinitionId *int
// (optional)
DefinitionEnvironmentId *int
// (optional)
CreatedBy *string
// (optional)
MinModifiedTime *azuredevops.Time
// (optional)
MaxModifiedTime *azuredevops.Time
// (optional)
DeploymentStatus *DeploymentStatus
// (optional)
OperationStatus *DeploymentOperationStatus
// (optional)
LatestAttemptsOnly *bool
// (optional)
QueryOrder *ReleaseQueryOrder
// (optional)
Top *int
// (optional)
ContinuationToken *int
// (optional)
CreatedFor *string
// (optional)
MinStartedTime *azuredevops.Time
// (optional)
MaxStartedTime *azuredevops.Time
// (optional)
SourceBranch *string
}
// Return type for the GetDeployments function
type GetDeploymentsResponseValue struct {
Value []Deployment
// The continuation token to be used to get the next page of results.
ContinuationToken string
}
// [Preview API] Gets folders.
func (client *ClientImpl) GetFolders(ctx context.Context, args GetFoldersArgs) (*[]Folder, error) {
routeValues := make(map[string]string)
if args.Project == nil || *args.Project == "" {
return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"}
}
routeValues["project"] = *args.Project
if args.Path != nil && *args.Path != "" {
routeValues["path"] = *args.Path
}
queryParams := url.Values{}
if args.QueryOrder != nil {
queryParams.Add("queryOrder", string(*args.QueryOrder))
}
locationId, _ := uuid.Parse("f7ddf76d-ce0c-4d68-94ff-becaec5d9dea")
resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1-preview.2", routeValues, queryParams, nil, "", "application/json", nil)
if err != nil {
return nil, err
}
var responseValue []Folder
err = client.Client.UnmarshalCollectionBody(resp, &responseValue)
return &responseValue, err
}
// Arguments for the GetFolders function
type GetFoldersArgs struct {
// (required) Project ID or project name
Project *string
// (optional) Path of the folder.
Path *string
// (optional) Gets the results in the defined order. Default is 'None'.
QueryOrder *FolderPathQueryOrder
}
// [Preview API] Get logs for a release Id.
func (client *ClientImpl) GetLogs(ctx context.Context, args GetLogsArgs) (io.ReadCloser, error) {
routeValues := make(map[string]string)
if args.Project == nil || *args.Project == "" {
return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"}
}
routeValues["project"] = *args.Project
if args.ReleaseId == nil {
return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.ReleaseId"}
}
routeValues["releaseId"] = strconv.Itoa(*args.ReleaseId)
locationId, _ := uuid.Parse("c37fbab5-214b-48e4-a55b-cb6b4f6e4038")
resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1-preview.2", routeValues, nil, nil, "", "application/zip", nil)
if err != nil {
return nil, err
}
return resp.Body, err
}
// Arguments for the GetLogs function
type GetLogsArgs struct {
// (required) Project ID or project name
Project *string
// (required) Id of the release.
ReleaseId *int
}
// Get manual intervention for a given release and manual intervention id.
func (client *ClientImpl) GetManualIntervention(ctx context.Context, args GetManualInterventionArgs) (*ManualIntervention, error) {
routeValues := make(map[string]string)
if args.Project == nil || *args.Project == "" {
return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"}
}
routeValues["project"] = *args.Project
if args.ReleaseId == nil {
return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.ReleaseId"}
}
routeValues["releaseId"] = strconv.Itoa(*args.ReleaseId)
if args.ManualInterventionId == nil {
return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.ManualInterventionId"}
}
routeValues["manualInterventionId"] = strconv.Itoa(*args.ManualInterventionId)
locationId, _ := uuid.Parse("616c46e4-f370-4456-adaa-fbaf79c7b79e")
resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1", routeValues, nil, nil, "", "application/json", nil)
if err != nil {
return nil, err
}
var responseValue ManualIntervention
err = client.Client.UnmarshalBody(resp, &responseValue)
return &responseValue, err
}
// Arguments for the GetManualIntervention function
type GetManualInterventionArgs struct {
// (required) Project ID or project name
Project *string
// (required) Id of the release.
ReleaseId *int
// (required) Id of the manual intervention.
ManualInterventionId *int
}
// List all manual interventions for a given release.
func (client *ClientImpl) GetManualInterventions(ctx context.Context, args GetManualInterventionsArgs) (*[]ManualIntervention, error) {
routeValues := make(map[string]string)
if args.Project == nil || *args.Project == "" {
return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"}
}
routeValues["project"] = *args.Project
if args.ReleaseId == nil {
return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.ReleaseId"}
}
routeValues["releaseId"] = strconv.Itoa(*args.ReleaseId)
locationId, _ := uuid.Parse("616c46e4-f370-4456-adaa-fbaf79c7b79e")
resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1", routeValues, nil, nil, "", "application/json", nil)
if err != nil {
return nil, err
}
var responseValue []ManualIntervention
err = client.Client.UnmarshalCollectionBody(resp, &responseValue)
return &responseValue, err
}
// Arguments for the GetManualInterventions function
type GetManualInterventionsArgs struct {
// (required) Project ID or project name
Project *string
// (required) Id of the release.
ReleaseId *int
}
// Get a Release
func (client *ClientImpl) GetRelease(ctx context.Context, args GetReleaseArgs) (*Release, error) {
routeValues := make(map[string]string)
if args.Project == nil || *args.Project == "" {
return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"}
}
routeValues["project"] = *args.Project
if args.ReleaseId == nil {
return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.ReleaseId"}
}
routeValues["releaseId"] = strconv.Itoa(*args.ReleaseId)
queryParams := url.Values{}
if args.ApprovalFilters != nil {
queryParams.Add("approvalFilters", string(*args.ApprovalFilters))
}
if args.PropertyFilters != nil {
listAsString := strings.Join((*args.PropertyFilters)[:], ",")
queryParams.Add("propertyFilters", listAsString)
}
if args.Expand != nil {
queryParams.Add("$expand", string(*args.Expand))
}
if args.TopGateRecords != nil {
queryParams.Add("$topGateRecords", strconv.Itoa(*args.TopGateRecords))
}
locationId, _ := uuid.Parse("a166fde7-27ad-408e-ba75-703c2cc9d500")
resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1", routeValues, queryParams, nil, "", "application/json", nil)
if err != nil {
return nil, err
}
var responseValue Release
err = client.Client.UnmarshalBody(resp, &responseValue)
return &responseValue, err
}
// Arguments for the GetRelease function
type GetReleaseArgs struct {
// (required) Project ID or project name
Project *string
// (required) Id of the release.
ReleaseId *int
// (optional) A filter which would allow fetching approval steps selectively based on whether it is automated, or manual. This would also decide whether we should fetch pre and post approval snapshots. Assumes All by default
ApprovalFilters *ApprovalFilters
// (optional) A comma-delimited list of extended properties to be retrieved. If set, the returned Release will contain values for the specified property Ids (if they exist). If not set, properties will not be included.
PropertyFilters *[]string
// (optional) A property that should be expanded in the release.
Expand *SingleReleaseExpands
// (optional) Number of release gate records to get. Default is 5.
TopGateRecords *int
}
// Get a release definition.
func (client *ClientImpl) GetReleaseDefinition(ctx context.Context, args GetReleaseDefinitionArgs) (*ReleaseDefinition, error) {
routeValues := make(map[string]string)
if args.Project == nil || *args.Project == "" {
return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"}
}
routeValues["project"] = *args.Project
if args.DefinitionId == nil {
return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.DefinitionId"}
}
routeValues["definitionId"] = strconv.Itoa(*args.DefinitionId)
queryParams := url.Values{}
if args.PropertyFilters != nil {
listAsString := strings.Join((*args.PropertyFilters)[:], ",")
queryParams.Add("propertyFilters", listAsString)
}
locationId, _ := uuid.Parse("d8f96f24-8ea7-4cb6-baab-2df8fc515665")
resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1", routeValues, queryParams, nil, "", "application/json", nil)
if err != nil {
return nil, err
}
var responseValue ReleaseDefinition
err = client.Client.UnmarshalBody(resp, &responseValue)
return &responseValue, err
}
// Arguments for the GetReleaseDefinition function
type GetReleaseDefinitionArgs struct {
// (required) Project ID or project name
Project *string
// (required) Id of the release definition.
DefinitionId *int
// (optional) A comma-delimited list of extended properties to be retrieved. If set, the returned Release Definition will contain values for the specified property Ids (if they exist). If not set, properties will not be included.
PropertyFilters *[]string
}
// [Preview API] Get revision history for a release definition
func (client *ClientImpl) GetReleaseDefinitionHistory(ctx context.Context, args GetReleaseDefinitionHistoryArgs) (*[]ReleaseDefinitionRevision, error) {
routeValues := make(map[string]string)
if args.Project == nil || *args.Project == "" {
return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"}
}
routeValues["project"] = *args.Project
if args.DefinitionId == nil {
return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.DefinitionId"}
}
routeValues["definitionId"] = strconv.Itoa(*args.DefinitionId)
locationId, _ := uuid.Parse("258b82e0-9d41-43f3-86d6-fef14ddd44bc")
resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1-preview.1", routeValues, nil, nil, "", "application/json", nil)
if err != nil {
return nil, err
}
var responseValue []ReleaseDefinitionRevision
err = client.Client.UnmarshalCollectionBody(resp, &responseValue)
return &responseValue, err
}
// Arguments for the GetReleaseDefinitionHistory function
type GetReleaseDefinitionHistoryArgs struct {
// (required) Project ID or project name
Project *string
// (required) Id of the definition.
DefinitionId *int
}
// Get a list of release definitions.
func (client *ClientImpl) GetReleaseDefinitions(ctx context.Context, args GetReleaseDefinitionsArgs) (*GetReleaseDefinitionsResponseValue, error) {
routeValues := make(map[string]string)
if args.Project == nil || *args.Project == "" {
return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"}
}
routeValues["project"] = *args.Project
queryParams := url.Values{}
if args.SearchText != nil {
queryParams.Add("searchText", *args.SearchText)
}
if args.Expand != nil {
queryParams.Add("$expand", string(*args.Expand))
}
if args.ArtifactType != nil {
queryParams.Add("artifactType", *args.ArtifactType)
}
if args.ArtifactSourceId != nil {
queryParams.Add("artifactSourceId", *args.ArtifactSourceId)
}
if args.Top != nil {
queryParams.Add("$top", strconv.Itoa(*args.Top))
}
if args.ContinuationToken != nil {
queryParams.Add("continuationToken", *args.ContinuationToken)
}
if args.QueryOrder != nil {
queryParams.Add("queryOrder", string(*args.QueryOrder))
}
if args.Path != nil {
queryParams.Add("path", *args.Path)
}
if args.IsExactNameMatch != nil {
queryParams.Add("isExactNameMatch", strconv.FormatBool(*args.IsExactNameMatch))
}
if args.TagFilter != nil {
listAsString := strings.Join((*args.TagFilter)[:], ",")
queryParams.Add("tagFilter", listAsString)
}
if args.PropertyFilters != nil {
listAsString := strings.Join((*args.PropertyFilters)[:], ",")
queryParams.Add("propertyFilters", listAsString)
}
if args.DefinitionIdFilter != nil {
listAsString := strings.Join((*args.DefinitionIdFilter)[:], ",")
queryParams.Add("definitionIdFilter", listAsString)
}
if args.IsDeleted != nil {
queryParams.Add("isDeleted", strconv.FormatBool(*args.IsDeleted))
}
if args.SearchTextContainsFolderName != nil {
queryParams.Add("searchTextContainsFolderName", strconv.FormatBool(*args.SearchTextContainsFolderName))
}
locationId, _ := uuid.Parse("d8f96f24-8ea7-4cb6-baab-2df8fc515665")
resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1", routeValues, queryParams, nil, "", "application/json", nil)
if err != nil {
return nil, err
}
var responseValue GetReleaseDefinitionsResponseValue
responseValue.ContinuationToken = resp.Header.Get(azuredevops.HeaderKeyContinuationToken)
err = client.Client.UnmarshalCollectionBody(resp, &responseValue.Value)
return &responseValue, err
}
// Arguments for the GetReleaseDefinitions function
type GetReleaseDefinitionsArgs struct {
// (required) Project ID or project name
Project *string
// (optional) Get release definitions with names containing searchText.
SearchText *string
// (optional) The properties that should be expanded in the list of Release definitions.
Expand *ReleaseDefinitionExpands
// (optional) Release definitions with given artifactType will be returned. Values can be Build, Jenkins, GitHub, Nuget, Team Build (external), ExternalTFSBuild, Git, TFVC, ExternalTfsXamlBuild.
ArtifactType *string
// (optional) Release definitions with given artifactSourceId will be returned. e.g. For build it would be {projectGuid}:{BuildDefinitionId}, for Jenkins it would be {JenkinsConnectionId}:{JenkinsDefinitionId}, for TfsOnPrem it would be {TfsOnPremConnectionId}:{ProjectName}:{TfsOnPremDefinitionId}. For third-party artifacts e.g. TeamCity, BitBucket you may refer 'uniqueSourceIdentifier' inside vss-extension.json at https://github.com/Microsoft/vsts-rm-extensions/blob/master/Extensions.
ArtifactSourceId *string
// (optional) Number of release definitions to get.
Top *int
// (optional) Gets the release definitions after the continuation token provided.
ContinuationToken *string
// (optional) Gets the results in the defined order. Default is 'IdAscending'.
QueryOrder *ReleaseDefinitionQueryOrder
// (optional) Gets the release definitions under the specified path.
Path *string
// (optional) 'true'to gets the release definitions with exact match as specified in searchText. Default is 'false'.
IsExactNameMatch *bool
// (optional) A comma-delimited list of tags. Only release definitions with these tags will be returned.
TagFilter *[]string
// (optional) A comma-delimited list of extended properties to be retrieved. If set, the returned Release Definitions will contain values for the specified property Ids (if they exist). If not set, properties will not be included. Note that this will not filter out any Release Definition from results irrespective of whether it has property set or not.
PropertyFilters *[]string
// (optional) A comma-delimited list of release definitions to retrieve.
DefinitionIdFilter *[]string
// (optional) 'true' to get release definitions that has been deleted. Default is 'false'
IsDeleted *bool
// (optional) 'true' to get the release definitions under the folder with name as specified in searchText. Default is 'false'.
SearchTextContainsFolderName *bool
}
// Return type for the GetReleaseDefinitions function
type GetReleaseDefinitionsResponseValue struct {
Value []ReleaseDefinition
// The continuation token to be used to get the next page of results.
ContinuationToken string
}
// [Preview API] Get a release environment.
func (client *ClientImpl) GetReleaseEnvironment(ctx context.Context, args GetReleaseEnvironmentArgs) (*ReleaseEnvironment, error) {
routeValues := make(map[string]string)
if args.Project == nil || *args.Project == "" {
return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"}
}
routeValues["project"] = *args.Project
if args.ReleaseId == nil {
return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.ReleaseId"}
}
routeValues["releaseId"] = strconv.Itoa(*args.ReleaseId)
if args.EnvironmentId == nil {
return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.EnvironmentId"}
}
routeValues["environmentId"] = strconv.Itoa(*args.EnvironmentId)
locationId, _ := uuid.Parse("a7e426b1-03dc-48af-9dfe-c98bac612dcb")
resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1-preview.6", routeValues, nil, nil, "", "application/json", nil)
if err != nil {
return nil, err
}
var responseValue ReleaseEnvironment
err = client.Client.UnmarshalBody(resp, &responseValue)
return &responseValue, err
}
// Arguments for the GetReleaseEnvironment function
type GetReleaseEnvironmentArgs struct {
// (required) Project ID or project name
Project *string
// (required) Id of the release.
ReleaseId *int
// (required) Id of the release environment.
EnvironmentId *int
}
// Get release for a given revision number.
func (client *ClientImpl) GetReleaseRevision(ctx context.Context, args GetReleaseRevisionArgs) (io.ReadCloser, error) {
routeValues := make(map[string]string)
if args.Project == nil || *args.Project == "" {
return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"}
}
routeValues["project"] = *args.Project
if args.ReleaseId == nil {
return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.ReleaseId"}
}
routeValues["releaseId"] = strconv.Itoa(*args.ReleaseId)
queryParams := url.Values{}
if args.DefinitionSnapshotRevision == nil {
return nil, &azuredevops.ArgumentNilError{ArgumentName: "definitionSnapshotRevision"}
}
queryParams.Add("definitionSnapshotRevision", strconv.Itoa(*args.DefinitionSnapshotRevision))
locationId, _ := uuid.Parse("a166fde7-27ad-408e-ba75-703c2cc9d500")
resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1", routeValues, queryParams, nil, "", "text/plain", nil)
if err != nil {
return nil, err
}
return resp.Body, err
}
// Arguments for the GetReleaseRevision function
type GetReleaseRevisionArgs struct {
// (required) Project ID or project name
Project *string
// (required) Id of the release.
ReleaseId *int
// (required) Definition snapshot revision number.
DefinitionSnapshotRevision *int
}
// Get a list of releases
func (client *ClientImpl) GetReleases(ctx context.Context, args GetReleasesArgs) (*GetReleasesResponseValue, error) {
routeValues := make(map[string]string)
if args.Project != nil && *args.Project != "" {
routeValues["project"] = *args.Project
}
queryParams := url.Values{}
if args.DefinitionId != nil {
queryParams.Add("definitionId", strconv.Itoa(*args.DefinitionId))
}
if args.DefinitionEnvironmentId != nil {
queryParams.Add("definitionEnvironmentId", strconv.Itoa(*args.DefinitionEnvironmentId))
}
if args.SearchText != nil {
queryParams.Add("searchText", *args.SearchText)
}
if args.CreatedBy != nil {
queryParams.Add("createdBy", *args.CreatedBy)
}
if args.StatusFilter != nil {
queryParams.Add("statusFilter", string(*args.StatusFilter))
}
if args.EnvironmentStatusFilter != nil {
queryParams.Add("environmentStatusFilter", strconv.Itoa(*args.EnvironmentStatusFilter))
}
if args.MinCreatedTime != nil {
queryParams.Add("minCreatedTime", (*args.MinCreatedTime).AsQueryParameter())
}
if args.MaxCreatedTime != nil {
queryParams.Add("maxCreatedTime", (*args.MaxCreatedTime).AsQueryParameter())
}
if args.QueryOrder != nil {
queryParams.Add("queryOrder", string(*args.QueryOrder))
}
if args.Top != nil {
queryParams.Add("$top", strconv.Itoa(*args.Top))
}
if args.ContinuationToken != nil {
queryParams.Add("continuationToken", strconv.Itoa(*args.ContinuationToken))
}
if args.Expand != nil {
queryParams.Add("$expand", string(*args.Expand))
}
if args.ArtifactTypeId != nil {
queryParams.Add("artifactTypeId", *args.ArtifactTypeId)
}
if args.SourceId != nil {
queryParams.Add("sourceId", *args.SourceId)
}
if args.ArtifactVersionId != nil {
queryParams.Add("artifactVersionId", *args.ArtifactVersionId)
}
if args.SourceBranchFilter != nil {
queryParams.Add("sourceBranchFilter", *args.SourceBranchFilter)
}
if args.IsDeleted != nil {
queryParams.Add("isDeleted", strconv.FormatBool(*args.IsDeleted))
}
if args.TagFilter != nil {
listAsString := strings.Join((*args.TagFilter)[:], ",")
queryParams.Add("tagFilter", listAsString)
}
if args.PropertyFilters != nil {
listAsString := strings.Join((*args.PropertyFilters)[:], ",")
queryParams.Add("propertyFilters", listAsString)
}
if args.ReleaseIdFilter != nil {
var stringList []string
for _, item := range *args.ReleaseIdFilter {
stringList = append(stringList, strconv.Itoa(item))