-
Notifications
You must be signed in to change notification settings - Fork 78
/
client.go
2351 lines (2117 loc) · 85.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 taskagent
import (
"bytes"
"context"
"encoding/json"
"github.com/google/uuid"
"github.com/microsoft/azure-devops-go-api/azuredevops/v6"
"net/http"
"net/url"
"strconv"
"strings"
)
var ResourceAreaId, _ = uuid.Parse("a85b8835-c1a1-4aac-ae97-1c3d0ba72dbd")
type Client interface {
// Adds an agent to a pool. You probably don't want to call this endpoint directly. Instead, [configure an agent](https://docs.microsoft.com/azure/devops/pipelines/agents/agents) using the agent download package.
AddAgent(context.Context, AddAgentArgs) (*TaskAgent, error)
// [Preview API]
AddAgentCloud(context.Context, AddAgentCloudArgs) (*TaskAgentCloud, error)
// Create an agent pool.
AddAgentPool(context.Context, AddAgentPoolArgs) (*TaskAgentPool, error)
// [Preview API] Create a new agent queue to connect a project to an agent pool.
AddAgentQueue(context.Context, AddAgentQueueArgs) (*TaskAgentQueue, error)
// [Preview API] Create a deployment group.
AddDeploymentGroup(context.Context, AddDeploymentGroupArgs) (*DeploymentGroup, error)
// [Preview API] Create an environment.
AddEnvironment(context.Context, AddEnvironmentArgs) (*EnvironmentInstance, error)
// [Preview API]
AddKubernetesResource(context.Context, AddKubernetesResourceArgs) (*KubernetesResource, error)
// [Preview API] Create a task group.
AddTaskGroup(context.Context, AddTaskGroupArgs) (*TaskGroup, error)
// [Preview API] Add a variable group.
AddVariableGroup(context.Context, AddVariableGroupArgs) (*VariableGroup, error)
// Delete an agent. You probably don't want to call this endpoint directly. Instead, [use the agent configuration script](https://docs.microsoft.com/azure/devops/pipelines/agents/agents) to remove an agent from your organization.
DeleteAgent(context.Context, DeleteAgentArgs) error
// [Preview API]
DeleteAgentCloud(context.Context, DeleteAgentCloudArgs) (*TaskAgentCloud, error)
// Delete an agent pool.
DeleteAgentPool(context.Context, DeleteAgentPoolArgs) error
// [Preview API] Removes an agent queue from a project.
DeleteAgentQueue(context.Context, DeleteAgentQueueArgs) error
// [Preview API] Delete a deployment group.
DeleteDeploymentGroup(context.Context, DeleteDeploymentGroupArgs) error
// [Preview API] Delete a deployment target in a deployment group. This deletes the agent from associated deployment pool too.
DeleteDeploymentTarget(context.Context, DeleteDeploymentTargetArgs) error
// [Preview API] Delete the specified environment.
DeleteEnvironment(context.Context, DeleteEnvironmentArgs) error
// [Preview API]
DeleteKubernetesResource(context.Context, DeleteKubernetesResourceArgs) error
// [Preview API] Delete a task group.
DeleteTaskGroup(context.Context, DeleteTaskGroupArgs) error
// [Preview API] Delete a variable group
DeleteVariableGroup(context.Context, DeleteVariableGroupArgs) error
// Get information about an agent.
GetAgent(context.Context, GetAgentArgs) (*TaskAgent, error)
// [Preview API]
GetAgentCloud(context.Context, GetAgentCloudArgs) (*TaskAgentCloud, error)
// [Preview API]
GetAgentCloudRequests(context.Context, GetAgentCloudRequestsArgs) (*[]TaskAgentCloudRequest, error)
// [Preview API]
GetAgentClouds(context.Context, GetAgentCloudsArgs) (*[]TaskAgentCloud, error)
// [Preview API] Get agent cloud types.
GetAgentCloudTypes(context.Context, GetAgentCloudTypesArgs) (*[]TaskAgentCloudType, error)
// Get information about an agent pool.
GetAgentPool(context.Context, GetAgentPoolArgs) (*TaskAgentPool, error)
// Get a list of agent pools.
GetAgentPools(context.Context, GetAgentPoolsArgs) (*[]TaskAgentPool, error)
// Get a list of agent pools.
GetAgentPoolsByIds(context.Context, GetAgentPoolsByIdsArgs) (*[]TaskAgentPool, error)
// [Preview API] Get information about an agent queue.
GetAgentQueue(context.Context, GetAgentQueueArgs) (*TaskAgentQueue, error)
// [Preview API] Get a list of agent queues.
GetAgentQueues(context.Context, GetAgentQueuesArgs) (*[]TaskAgentQueue, error)
// [Preview API] Get a list of agent queues by their IDs
GetAgentQueuesByIds(context.Context, GetAgentQueuesByIdsArgs) (*[]TaskAgentQueue, error)
// [Preview API] Get a list of agent queues by their names
GetAgentQueuesByNames(context.Context, GetAgentQueuesByNamesArgs) (*[]TaskAgentQueue, error)
// [Preview API] Get a list of agent queues by pool ids
GetAgentQueuesForPools(context.Context, GetAgentQueuesForPoolsArgs) (*[]TaskAgentQueue, error)
// Get a list of agents.
GetAgents(context.Context, GetAgentsArgs) (*[]TaskAgent, error)
// [Preview API] Get a deployment group by its ID.
GetDeploymentGroup(context.Context, GetDeploymentGroupArgs) (*DeploymentGroup, error)
// [Preview API] Get a list of deployment groups by name or IDs.
GetDeploymentGroups(context.Context, GetDeploymentGroupsArgs) (*GetDeploymentGroupsResponseValue, error)
// [Preview API] Get a deployment target by its ID in a deployment group
GetDeploymentTarget(context.Context, GetDeploymentTargetArgs) (*DeploymentMachine, error)
// [Preview API] Get a list of deployment targets in a deployment group.
GetDeploymentTargets(context.Context, GetDeploymentTargetsArgs) (*GetDeploymentTargetsResponseValue, error)
// [Preview API] Get an environment by its ID.
GetEnvironmentById(context.Context, GetEnvironmentByIdArgs) (*EnvironmentInstance, error)
// [Preview API] Get environment deployment execution history
GetEnvironmentDeploymentExecutionRecords(context.Context, GetEnvironmentDeploymentExecutionRecordsArgs) (*GetEnvironmentDeploymentExecutionRecordsResponseValue, error)
// [Preview API] Get all environments.
GetEnvironments(context.Context, GetEnvironmentsArgs) (*GetEnvironmentsResponseValue, error)
// [Preview API]
GetKubernetesResource(context.Context, GetKubernetesResourceArgs) (*KubernetesResource, error)
// [Preview API] List task groups.
GetTaskGroups(context.Context, GetTaskGroupsArgs) (*[]TaskGroup, error)
// [Preview API] Get a variable group.
GetVariableGroup(context.Context, GetVariableGroupArgs) (*VariableGroup, error)
// [Preview API] Get variable groups.
GetVariableGroups(context.Context, GetVariableGroupsArgs) (*[]VariableGroup, error)
// [Preview API] Get variable groups by ids.
GetVariableGroupsById(context.Context, GetVariableGroupsByIdArgs) (*[]VariableGroup, error)
// [Preview API]
GetVirtualMachines(context.Context, GetVirtualMachinesArgs) (*GetVirtualMachinesResponseValue, error)
// GET the Yaml schema used for Yaml file validation.
GetYamlSchema(context.Context, GetYamlSchemaArgs) (interface{}, error)
// Replace an agent. You probably don't want to call this endpoint directly. Instead, [use the agent configuration script](https://docs.microsoft.com/azure/devops/pipelines/agents/agents) to remove and reconfigure an agent from your organization.
ReplaceAgent(context.Context, ReplaceAgentArgs) (*TaskAgent, error)
// [Preview API] Add a variable group.
ShareVariableGroup(context.Context, ShareVariableGroupArgs) error
// Update agent details.
UpdateAgent(context.Context, UpdateAgentArgs) (*TaskAgent, error)
// [Preview API]
UpdateAgentCloud(context.Context, UpdateAgentCloudArgs) (*TaskAgentCloud, error)
// Update properties on an agent pool
UpdateAgentPool(context.Context, UpdateAgentPoolArgs) (*TaskAgentPool, error)
// [Preview API] Update a deployment group.
UpdateDeploymentGroup(context.Context, UpdateDeploymentGroupArgs) (*DeploymentGroup, error)
// [Preview API] Update tags of a list of deployment targets in a deployment group.
UpdateDeploymentTargets(context.Context, UpdateDeploymentTargetsArgs) (*[]DeploymentMachine, error)
// [Preview API] Update the specified environment.
UpdateEnvironment(context.Context, UpdateEnvironmentArgs) (*EnvironmentInstance, error)
// [Preview API] Update a task group.
UpdateTaskGroup(context.Context, UpdateTaskGroupArgs) (*TaskGroup, error)
// [Preview API] Update a variable group.
UpdateVariableGroup(context.Context, UpdateVariableGroupArgs) (*VariableGroup, error)
// [Preview API]
UpdateVirtualMachines(context.Context, UpdateVirtualMachinesArgs) (*[]VirtualMachine, 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
}
// Adds an agent to a pool. You probably don't want to call this endpoint directly. Instead, [configure an agent](https://docs.microsoft.com/azure/devops/pipelines/agents/agents) using the agent download package.
func (client *ClientImpl) AddAgent(ctx context.Context, args AddAgentArgs) (*TaskAgent, error) {
if args.Agent == nil {
return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.Agent"}
}
routeValues := make(map[string]string)
if args.PoolId == nil {
return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.PoolId"}
}
routeValues["poolId"] = strconv.Itoa(*args.PoolId)
body, marshalErr := json.Marshal(*args.Agent)
if marshalErr != nil {
return nil, marshalErr
}
locationId, _ := uuid.Parse("e298ef32-5878-4cab-993c-043836571f42")
resp, err := client.Client.Send(ctx, http.MethodPost, locationId, "6.0", routeValues, nil, bytes.NewReader(body), "application/json", "application/json", nil)
if err != nil {
return nil, err
}
var responseValue TaskAgent
err = client.Client.UnmarshalBody(resp, &responseValue)
return &responseValue, err
}
// Arguments for the AddAgent function
type AddAgentArgs struct {
// (required) Details about the agent being added
Agent *TaskAgent
// (required) The agent pool in which to add the agent
PoolId *int
}
// [Preview API]
func (client *ClientImpl) AddAgentCloud(ctx context.Context, args AddAgentCloudArgs) (*TaskAgentCloud, error) {
if args.AgentCloud == nil {
return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.AgentCloud"}
}
body, marshalErr := json.Marshal(*args.AgentCloud)
if marshalErr != nil {
return nil, marshalErr
}
locationId, _ := uuid.Parse("bfa72b3d-0fc6-43fb-932b-a7f6559f93b9")
resp, err := client.Client.Send(ctx, http.MethodPost, locationId, "6.0-preview.1", nil, nil, bytes.NewReader(body), "application/json", "application/json", nil)
if err != nil {
return nil, err
}
var responseValue TaskAgentCloud
err = client.Client.UnmarshalBody(resp, &responseValue)
return &responseValue, err
}
// Arguments for the AddAgentCloud function
type AddAgentCloudArgs struct {
// (required)
AgentCloud *TaskAgentCloud
}
// Create an agent pool.
func (client *ClientImpl) AddAgentPool(ctx context.Context, args AddAgentPoolArgs) (*TaskAgentPool, error) {
if args.Pool == nil {
return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.Pool"}
}
body, marshalErr := json.Marshal(*args.Pool)
if marshalErr != nil {
return nil, marshalErr
}
locationId, _ := uuid.Parse("a8c47e17-4d56-4a56-92bb-de7ea7dc65be")
resp, err := client.Client.Send(ctx, http.MethodPost, locationId, "6.0", nil, nil, bytes.NewReader(body), "application/json", "application/json", nil)
if err != nil {
return nil, err
}
var responseValue TaskAgentPool
err = client.Client.UnmarshalBody(resp, &responseValue)
return &responseValue, err
}
// Arguments for the AddAgentPool function
type AddAgentPoolArgs struct {
// (required) Details about the new agent pool
Pool *TaskAgentPool
}
// [Preview API] Create a new agent queue to connect a project to an agent pool.
func (client *ClientImpl) AddAgentQueue(ctx context.Context, args AddAgentQueueArgs) (*TaskAgentQueue, error) {
if args.Queue == nil {
return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.Queue"}
}
routeValues := make(map[string]string)
if args.Project != nil && *args.Project != "" {
routeValues["project"] = *args.Project
}
queryParams := url.Values{}
if args.AuthorizePipelines != nil {
queryParams.Add("authorizePipelines", strconv.FormatBool(*args.AuthorizePipelines))
}
body, marshalErr := json.Marshal(*args.Queue)
if marshalErr != nil {
return nil, marshalErr
}
locationId, _ := uuid.Parse("900fa995-c559-4923-aae7-f8424fe4fbea")
resp, err := client.Client.Send(ctx, http.MethodPost, locationId, "6.0-preview.1", routeValues, queryParams, bytes.NewReader(body), "application/json", "application/json", nil)
if err != nil {
return nil, err
}
var responseValue TaskAgentQueue
err = client.Client.UnmarshalBody(resp, &responseValue)
return &responseValue, err
}
// Arguments for the AddAgentQueue function
type AddAgentQueueArgs struct {
// (required) Details about the queue to create
Queue *TaskAgentQueue
// (optional) Project ID or project name
Project *string
// (optional) Automatically authorize this queue when using YAML
AuthorizePipelines *bool
}
// [Preview API] Create a deployment group.
func (client *ClientImpl) AddDeploymentGroup(ctx context.Context, args AddDeploymentGroupArgs) (*DeploymentGroup, error) {
if args.DeploymentGroup == nil {
return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.DeploymentGroup"}
}
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.DeploymentGroup)
if marshalErr != nil {
return nil, marshalErr
}
locationId, _ := uuid.Parse("083c4d89-ab35-45af-aa11-7cf66895c53e")
resp, err := client.Client.Send(ctx, http.MethodPost, locationId, "6.0-preview.1", routeValues, nil, bytes.NewReader(body), "application/json", "application/json", nil)
if err != nil {
return nil, err
}
var responseValue DeploymentGroup
err = client.Client.UnmarshalBody(resp, &responseValue)
return &responseValue, err
}
// Arguments for the AddDeploymentGroup function
type AddDeploymentGroupArgs struct {
// (required) Deployment group to create.
DeploymentGroup *DeploymentGroupCreateParameter
// (required) Project ID or project name
Project *string
}
// [Preview API] Create an environment.
func (client *ClientImpl) AddEnvironment(ctx context.Context, args AddEnvironmentArgs) (*EnvironmentInstance, error) {
if args.EnvironmentCreateParameter == nil {
return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.EnvironmentCreateParameter"}
}
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.EnvironmentCreateParameter)
if marshalErr != nil {
return nil, marshalErr
}
locationId, _ := uuid.Parse("8572b1fc-2482-47fa-8f74-7e3ed53ee54b")
resp, err := client.Client.Send(ctx, http.MethodPost, locationId, "6.0-preview.1", routeValues, nil, bytes.NewReader(body), "application/json", "application/json", nil)
if err != nil {
return nil, err
}
var responseValue EnvironmentInstance
err = client.Client.UnmarshalBody(resp, &responseValue)
return &responseValue, err
}
// Arguments for the AddEnvironment function
type AddEnvironmentArgs struct {
// (required) Environment to create.
EnvironmentCreateParameter *EnvironmentCreateParameter
// (required) Project ID or project name
Project *string
}
// [Preview API]
func (client *ClientImpl) AddKubernetesResource(ctx context.Context, args AddKubernetesResourceArgs) (*KubernetesResource, error) {
if args.CreateParameters == nil {
return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.CreateParameters"}
}
routeValues := make(map[string]string)
if args.Project == nil || *args.Project == "" {
return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"}
}
routeValues["project"] = *args.Project
if args.EnvironmentId == nil {
return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.EnvironmentId"}
}
routeValues["environmentId"] = strconv.Itoa(*args.EnvironmentId)
body, marshalErr := json.Marshal(*args.CreateParameters)
if marshalErr != nil {
return nil, marshalErr
}
locationId, _ := uuid.Parse("73fba52f-15ab-42b3-a538-ce67a9223a04")
resp, err := client.Client.Send(ctx, http.MethodPost, locationId, "6.0-preview.1", routeValues, nil, bytes.NewReader(body), "application/json", "application/json", nil)
if err != nil {
return nil, err
}
var responseValue KubernetesResource
err = client.Client.UnmarshalBody(resp, &responseValue)
return &responseValue, err
}
// Arguments for the AddKubernetesResource function
type AddKubernetesResourceArgs struct {
// (required)
CreateParameters *KubernetesResourceCreateParameters
// (required) Project ID or project name
Project *string
// (required)
EnvironmentId *int
}
// [Preview API] Create a task group.
func (client *ClientImpl) AddTaskGroup(ctx context.Context, args AddTaskGroupArgs) (*TaskGroup, error) {
if args.TaskGroup == nil {
return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.TaskGroup"}
}
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.TaskGroup)
if marshalErr != nil {
return nil, marshalErr
}
locationId, _ := uuid.Parse("6c08ffbf-dbf1-4f9a-94e5-a1cbd47005e7")
resp, err := client.Client.Send(ctx, http.MethodPost, locationId, "6.0-preview.1", routeValues, nil, bytes.NewReader(body), "application/json", "application/json", nil)
if err != nil {
return nil, err
}
var responseValue TaskGroup
err = client.Client.UnmarshalBody(resp, &responseValue)
return &responseValue, err
}
// Arguments for the AddTaskGroup function
type AddTaskGroupArgs struct {
// (required) Task group object to create.
TaskGroup *TaskGroupCreateParameter
// (required) Project ID or project name
Project *string
}
// [Preview API] Add a variable group.
func (client *ClientImpl) AddVariableGroup(ctx context.Context, args AddVariableGroupArgs) (*VariableGroup, error) {
if args.VariableGroupParameters == nil {
return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.VariableGroupParameters"}
}
body, marshalErr := json.Marshal(*args.VariableGroupParameters)
if marshalErr != nil {
return nil, marshalErr
}
locationId, _ := uuid.Parse("ef5b7057-ffc3-4c77-bbad-c10b4a4abcc7")
resp, err := client.Client.Send(ctx, http.MethodPost, locationId, "6.0-preview.2", nil, nil, bytes.NewReader(body), "application/json", "application/json", nil)
if err != nil {
return nil, err
}
var responseValue VariableGroup
err = client.Client.UnmarshalBody(resp, &responseValue)
return &responseValue, err
}
// Arguments for the AddVariableGroup function
type AddVariableGroupArgs struct {
// (required)
VariableGroupParameters *VariableGroupParameters
}
// Delete an agent. You probably don't want to call this endpoint directly. Instead, [use the agent configuration script](https://docs.microsoft.com/azure/devops/pipelines/agents/agents) to remove an agent from your organization.
func (client *ClientImpl) DeleteAgent(ctx context.Context, args DeleteAgentArgs) error {
routeValues := make(map[string]string)
if args.PoolId == nil {
return &azuredevops.ArgumentNilError{ArgumentName: "args.PoolId"}
}
routeValues["poolId"] = strconv.Itoa(*args.PoolId)
if args.AgentId == nil {
return &azuredevops.ArgumentNilError{ArgumentName: "args.AgentId"}
}
routeValues["agentId"] = strconv.Itoa(*args.AgentId)
locationId, _ := uuid.Parse("e298ef32-5878-4cab-993c-043836571f42")
_, err := client.Client.Send(ctx, http.MethodDelete, locationId, "6.0", routeValues, nil, nil, "", "application/json", nil)
if err != nil {
return err
}
return nil
}
// Arguments for the DeleteAgent function
type DeleteAgentArgs struct {
// (required) The pool ID to remove the agent from
PoolId *int
// (required) The agent ID to remove
AgentId *int
}
// [Preview API]
func (client *ClientImpl) DeleteAgentCloud(ctx context.Context, args DeleteAgentCloudArgs) (*TaskAgentCloud, error) {
routeValues := make(map[string]string)
if args.AgentCloudId == nil {
return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.AgentCloudId"}
}
routeValues["agentCloudId"] = strconv.Itoa(*args.AgentCloudId)
locationId, _ := uuid.Parse("bfa72b3d-0fc6-43fb-932b-a7f6559f93b9")
resp, err := client.Client.Send(ctx, http.MethodDelete, locationId, "6.0-preview.1", routeValues, nil, nil, "", "application/json", nil)
if err != nil {
return nil, err
}
var responseValue TaskAgentCloud
err = client.Client.UnmarshalBody(resp, &responseValue)
return &responseValue, err
}
// Arguments for the DeleteAgentCloud function
type DeleteAgentCloudArgs struct {
// (required)
AgentCloudId *int
}
// Delete an agent pool.
func (client *ClientImpl) DeleteAgentPool(ctx context.Context, args DeleteAgentPoolArgs) error {
routeValues := make(map[string]string)
if args.PoolId == nil {
return &azuredevops.ArgumentNilError{ArgumentName: "args.PoolId"}
}
routeValues["poolId"] = strconv.Itoa(*args.PoolId)
locationId, _ := uuid.Parse("a8c47e17-4d56-4a56-92bb-de7ea7dc65be")
_, err := client.Client.Send(ctx, http.MethodDelete, locationId, "6.0", routeValues, nil, nil, "", "application/json", nil)
if err != nil {
return err
}
return nil
}
// Arguments for the DeleteAgentPool function
type DeleteAgentPoolArgs struct {
// (required) ID of the agent pool to delete
PoolId *int
}
// [Preview API] Removes an agent queue from a project.
func (client *ClientImpl) DeleteAgentQueue(ctx context.Context, args DeleteAgentQueueArgs) error {
routeValues := make(map[string]string)
if args.Project != nil && *args.Project != "" {
routeValues["project"] = *args.Project
}
if args.QueueId == nil {
return &azuredevops.ArgumentNilError{ArgumentName: "args.QueueId"}
}
routeValues["queueId"] = strconv.Itoa(*args.QueueId)
locationId, _ := uuid.Parse("900fa995-c559-4923-aae7-f8424fe4fbea")
_, err := client.Client.Send(ctx, http.MethodDelete, locationId, "6.0-preview.1", routeValues, nil, nil, "", "application/json", nil)
if err != nil {
return err
}
return nil
}
// Arguments for the DeleteAgentQueue function
type DeleteAgentQueueArgs struct {
// (required) The agent queue to remove
QueueId *int
// (optional) Project ID or project name
Project *string
}
// [Preview API] Delete a deployment group.
func (client *ClientImpl) DeleteDeploymentGroup(ctx context.Context, args DeleteDeploymentGroupArgs) error {
routeValues := make(map[string]string)
if args.Project == nil || *args.Project == "" {
return &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"}
}
routeValues["project"] = *args.Project
if args.DeploymentGroupId == nil {
return &azuredevops.ArgumentNilError{ArgumentName: "args.DeploymentGroupId"}
}
routeValues["deploymentGroupId"] = strconv.Itoa(*args.DeploymentGroupId)
locationId, _ := uuid.Parse("083c4d89-ab35-45af-aa11-7cf66895c53e")
_, err := client.Client.Send(ctx, http.MethodDelete, locationId, "6.0-preview.1", routeValues, nil, nil, "", "application/json", nil)
if err != nil {
return err
}
return nil
}
// Arguments for the DeleteDeploymentGroup function
type DeleteDeploymentGroupArgs struct {
// (required) Project ID or project name
Project *string
// (required) ID of the deployment group to be deleted.
DeploymentGroupId *int
}
// [Preview API] Delete a deployment target in a deployment group. This deletes the agent from associated deployment pool too.
func (client *ClientImpl) DeleteDeploymentTarget(ctx context.Context, args DeleteDeploymentTargetArgs) error {
routeValues := make(map[string]string)
if args.Project == nil || *args.Project == "" {
return &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"}
}
routeValues["project"] = *args.Project
if args.DeploymentGroupId == nil {
return &azuredevops.ArgumentNilError{ArgumentName: "args.DeploymentGroupId"}
}
routeValues["deploymentGroupId"] = strconv.Itoa(*args.DeploymentGroupId)
if args.TargetId == nil {
return &azuredevops.ArgumentNilError{ArgumentName: "args.TargetId"}
}
routeValues["targetId"] = strconv.Itoa(*args.TargetId)
locationId, _ := uuid.Parse("2f0aa599-c121-4256-a5fd-ba370e0ae7b6")
_, err := client.Client.Send(ctx, http.MethodDelete, locationId, "6.0-preview.1", routeValues, nil, nil, "", "application/json", nil)
if err != nil {
return err
}
return nil
}
// Arguments for the DeleteDeploymentTarget function
type DeleteDeploymentTargetArgs struct {
// (required) Project ID or project name
Project *string
// (required) ID of the deployment group in which deployment target is deleted.
DeploymentGroupId *int
// (required) ID of the deployment target to delete.
TargetId *int
}
// [Preview API] Delete the specified environment.
func (client *ClientImpl) DeleteEnvironment(ctx context.Context, args DeleteEnvironmentArgs) error {
routeValues := make(map[string]string)
if args.Project == nil || *args.Project == "" {
return &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"}
}
routeValues["project"] = *args.Project
if args.EnvironmentId == nil {
return &azuredevops.ArgumentNilError{ArgumentName: "args.EnvironmentId"}
}
routeValues["environmentId"] = strconv.Itoa(*args.EnvironmentId)
locationId, _ := uuid.Parse("8572b1fc-2482-47fa-8f74-7e3ed53ee54b")
_, err := client.Client.Send(ctx, http.MethodDelete, locationId, "6.0-preview.1", routeValues, nil, nil, "", "application/json", nil)
if err != nil {
return err
}
return nil
}
// Arguments for the DeleteEnvironment function
type DeleteEnvironmentArgs struct {
// (required) Project ID or project name
Project *string
// (required) ID of the environment.
EnvironmentId *int
}
// [Preview API]
func (client *ClientImpl) DeleteKubernetesResource(ctx context.Context, args DeleteKubernetesResourceArgs) error {
routeValues := make(map[string]string)
if args.Project == nil || *args.Project == "" {
return &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"}
}
routeValues["project"] = *args.Project
if args.EnvironmentId == nil {
return &azuredevops.ArgumentNilError{ArgumentName: "args.EnvironmentId"}
}
routeValues["environmentId"] = strconv.Itoa(*args.EnvironmentId)
if args.ResourceId == nil {
return &azuredevops.ArgumentNilError{ArgumentName: "args.ResourceId"}
}
routeValues["resourceId"] = strconv.Itoa(*args.ResourceId)
locationId, _ := uuid.Parse("73fba52f-15ab-42b3-a538-ce67a9223a04")
_, err := client.Client.Send(ctx, http.MethodDelete, locationId, "6.0-preview.1", routeValues, nil, nil, "", "application/json", nil)
if err != nil {
return err
}
return nil
}
// Arguments for the DeleteKubernetesResource function
type DeleteKubernetesResourceArgs struct {
// (required) Project ID or project name
Project *string
// (required)
EnvironmentId *int
// (required)
ResourceId *int
}
// [Preview API] Delete a task group.
func (client *ClientImpl) DeleteTaskGroup(ctx context.Context, args DeleteTaskGroupArgs) error {
routeValues := make(map[string]string)
if args.Project == nil || *args.Project == "" {
return &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"}
}
routeValues["project"] = *args.Project
if args.TaskGroupId == nil {
return &azuredevops.ArgumentNilError{ArgumentName: "args.TaskGroupId"}
}
routeValues["taskGroupId"] = (*args.TaskGroupId).String()
queryParams := url.Values{}
if args.Comment != nil {
queryParams.Add("comment", *args.Comment)
}
locationId, _ := uuid.Parse("6c08ffbf-dbf1-4f9a-94e5-a1cbd47005e7")
_, err := client.Client.Send(ctx, http.MethodDelete, locationId, "6.0-preview.1", routeValues, queryParams, nil, "", "application/json", nil)
if err != nil {
return err
}
return nil
}
// Arguments for the DeleteTaskGroup function
type DeleteTaskGroupArgs struct {
// (required) Project ID or project name
Project *string
// (required) Id of the task group to be deleted.
TaskGroupId *uuid.UUID
// (optional) Comments to delete.
Comment *string
}
// [Preview API] Delete a variable group
func (client *ClientImpl) DeleteVariableGroup(ctx context.Context, args DeleteVariableGroupArgs) error {
routeValues := make(map[string]string)
if args.GroupId == nil {
return &azuredevops.ArgumentNilError{ArgumentName: "args.GroupId"}
}
routeValues["groupId"] = strconv.Itoa(*args.GroupId)
queryParams := url.Values{}
if args.ProjectIds == nil {
return &azuredevops.ArgumentNilError{ArgumentName: "projectIds"}
}
listAsString := strings.Join((*args.ProjectIds)[:], ",")
queryParams.Add("projectIds", listAsString)
locationId, _ := uuid.Parse("ef5b7057-ffc3-4c77-bbad-c10b4a4abcc7")
_, err := client.Client.Send(ctx, http.MethodDelete, locationId, "6.0-preview.2", routeValues, queryParams, nil, "", "application/json", nil)
if err != nil {
return err
}
return nil
}
// Arguments for the DeleteVariableGroup function
type DeleteVariableGroupArgs struct {
// (required) Id of the variable group.
GroupId *int
// (required)
ProjectIds *[]string
}
// Get information about an agent.
func (client *ClientImpl) GetAgent(ctx context.Context, args GetAgentArgs) (*TaskAgent, error) {
routeValues := make(map[string]string)
if args.PoolId == nil {
return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.PoolId"}
}
routeValues["poolId"] = strconv.Itoa(*args.PoolId)
if args.AgentId == nil {
return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.AgentId"}
}
routeValues["agentId"] = strconv.Itoa(*args.AgentId)
queryParams := url.Values{}
if args.IncludeCapabilities != nil {
queryParams.Add("includeCapabilities", strconv.FormatBool(*args.IncludeCapabilities))
}
if args.IncludeAssignedRequest != nil {
queryParams.Add("includeAssignedRequest", strconv.FormatBool(*args.IncludeAssignedRequest))
}
if args.IncludeLastCompletedRequest != nil {
queryParams.Add("includeLastCompletedRequest", strconv.FormatBool(*args.IncludeLastCompletedRequest))
}
if args.PropertyFilters != nil {
listAsString := strings.Join((*args.PropertyFilters)[:], ",")
queryParams.Add("propertyFilters", listAsString)
}
locationId, _ := uuid.Parse("e298ef32-5878-4cab-993c-043836571f42")
resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "6.0", routeValues, queryParams, nil, "", "application/json", nil)
if err != nil {
return nil, err
}
var responseValue TaskAgent
err = client.Client.UnmarshalBody(resp, &responseValue)
return &responseValue, err
}
// Arguments for the GetAgent function
type GetAgentArgs struct {
// (required) The agent pool containing the agent
PoolId *int
// (required) The agent ID to get information about
AgentId *int
// (optional) Whether to include the agent's capabilities in the response
IncludeCapabilities *bool
// (optional) Whether to include details about the agent's current work
IncludeAssignedRequest *bool
// (optional) Whether to include details about the agents' most recent completed work
IncludeLastCompletedRequest *bool
// (optional) Filter which custom properties will be returned
PropertyFilters *[]string
}
// [Preview API]
func (client *ClientImpl) GetAgentCloud(ctx context.Context, args GetAgentCloudArgs) (*TaskAgentCloud, error) {
routeValues := make(map[string]string)
if args.AgentCloudId == nil {
return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.AgentCloudId"}
}
routeValues["agentCloudId"] = strconv.Itoa(*args.AgentCloudId)
locationId, _ := uuid.Parse("bfa72b3d-0fc6-43fb-932b-a7f6559f93b9")
resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "6.0-preview.1", routeValues, nil, nil, "", "application/json", nil)
if err != nil {
return nil, err
}
var responseValue TaskAgentCloud
err = client.Client.UnmarshalBody(resp, &responseValue)
return &responseValue, err
}
// Arguments for the GetAgentCloud function
type GetAgentCloudArgs struct {
// (required)
AgentCloudId *int
}
// [Preview API]
func (client *ClientImpl) GetAgentCloudRequests(ctx context.Context, args GetAgentCloudRequestsArgs) (*[]TaskAgentCloudRequest, error) {
routeValues := make(map[string]string)
if args.AgentCloudId == nil {
return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.AgentCloudId"}
}
routeValues["agentCloudId"] = strconv.Itoa(*args.AgentCloudId)
locationId, _ := uuid.Parse("20189bd7-5134-49c2-b8e9-f9e856eea2b2")
resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "6.0-preview.1", routeValues, nil, nil, "", "application/json", nil)
if err != nil {
return nil, err
}
var responseValue []TaskAgentCloudRequest
err = client.Client.UnmarshalCollectionBody(resp, &responseValue)
return &responseValue, err
}
// Arguments for the GetAgentCloudRequests function
type GetAgentCloudRequestsArgs struct {
// (required)
AgentCloudId *int
}
// [Preview API]
func (client *ClientImpl) GetAgentClouds(ctx context.Context, args GetAgentCloudsArgs) (*[]TaskAgentCloud, error) {
locationId, _ := uuid.Parse("bfa72b3d-0fc6-43fb-932b-a7f6559f93b9")
resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "6.0-preview.1", nil, nil, nil, "", "application/json", nil)
if err != nil {
return nil, err
}
var responseValue []TaskAgentCloud
err = client.Client.UnmarshalCollectionBody(resp, &responseValue)
return &responseValue, err
}
// Arguments for the GetAgentClouds function
type GetAgentCloudsArgs struct {
}
// [Preview API] Get agent cloud types.
func (client *ClientImpl) GetAgentCloudTypes(ctx context.Context, args GetAgentCloudTypesArgs) (*[]TaskAgentCloudType, error) {
locationId, _ := uuid.Parse("5932e193-f376-469d-9c3e-e5588ce12cb5")
resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "6.0-preview.1", nil, nil, nil, "", "application/json", nil)
if err != nil {
return nil, err
}
var responseValue []TaskAgentCloudType
err = client.Client.UnmarshalCollectionBody(resp, &responseValue)
return &responseValue, err
}
// Arguments for the GetAgentCloudTypes function
type GetAgentCloudTypesArgs struct {
}
// Get information about an agent pool.
func (client *ClientImpl) GetAgentPool(ctx context.Context, args GetAgentPoolArgs) (*TaskAgentPool, error) {
routeValues := make(map[string]string)
if args.PoolId == nil {
return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.PoolId"}
}
routeValues["poolId"] = strconv.Itoa(*args.PoolId)
queryParams := url.Values{}
if args.Properties != nil {
listAsString := strings.Join((*args.Properties)[:], ",")
queryParams.Add("properties", listAsString)
}
if args.ActionFilter != nil {
queryParams.Add("actionFilter", string(*args.ActionFilter))
}
locationId, _ := uuid.Parse("a8c47e17-4d56-4a56-92bb-de7ea7dc65be")
resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "6.0", routeValues, queryParams, nil, "", "application/json", nil)
if err != nil {
return nil, err
}
var responseValue TaskAgentPool
err = client.Client.UnmarshalBody(resp, &responseValue)
return &responseValue, err
}
// Arguments for the GetAgentPool function
type GetAgentPoolArgs struct {
// (required) An agent pool ID
PoolId *int
// (optional) Agent pool properties (comma-separated)
Properties *[]string
// (optional) Filter by whether the calling user has use or manage permissions
ActionFilter *TaskAgentPoolActionFilter
}
// Get a list of agent pools.
func (client *ClientImpl) GetAgentPools(ctx context.Context, args GetAgentPoolsArgs) (*[]TaskAgentPool, error) {
queryParams := url.Values{}
if args.PoolName != nil {
queryParams.Add("poolName", *args.PoolName)
}
if args.Properties != nil {
listAsString := strings.Join((*args.Properties)[:], ",")
queryParams.Add("properties", listAsString)
}
if args.PoolType != nil {
queryParams.Add("poolType", string(*args.PoolType))
}
if args.ActionFilter != nil {
queryParams.Add("actionFilter", string(*args.ActionFilter))
}
locationId, _ := uuid.Parse("a8c47e17-4d56-4a56-92bb-de7ea7dc65be")
resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "6.0", nil, queryParams, nil, "", "application/json", nil)
if err != nil {
return nil, err
}
var responseValue []TaskAgentPool
err = client.Client.UnmarshalCollectionBody(resp, &responseValue)
return &responseValue, err
}
// Arguments for the GetAgentPools function
type GetAgentPoolsArgs struct {
// (optional) Filter by name
PoolName *string
// (optional) Filter by agent pool properties (comma-separated)
Properties *[]string
// (optional) Filter by pool type
PoolType *TaskAgentPoolType
// (optional) Filter by whether the calling user has use or manage permissions
ActionFilter *TaskAgentPoolActionFilter
}
// Get a list of agent pools.
func (client *ClientImpl) GetAgentPoolsByIds(ctx context.Context, args GetAgentPoolsByIdsArgs) (*[]TaskAgentPool, error) {
queryParams := url.Values{}
if args.PoolIds == nil {
return nil, &azuredevops.ArgumentNilError{ArgumentName: "poolIds"}
}
var stringList []string
for _, item := range *args.PoolIds {
stringList = append(stringList, strconv.Itoa(item))
}
listAsString := strings.Join((stringList)[:], ",")
queryParams.Add("poolIds", listAsString)
if args.ActionFilter != nil {
queryParams.Add("actionFilter", string(*args.ActionFilter))
}
locationId, _ := uuid.Parse("a8c47e17-4d56-4a56-92bb-de7ea7dc65be")
resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "6.0", nil, queryParams, nil, "", "application/json", nil)
if err != nil {
return nil, err
}
var responseValue []TaskAgentPool
err = client.Client.UnmarshalCollectionBody(resp, &responseValue)
return &responseValue, err
}
// Arguments for the GetAgentPoolsByIds function
type GetAgentPoolsByIdsArgs struct {
// (required) pool Ids to fetch
PoolIds *[]int
// (optional) Filter by whether the calling user has use or manage permissions
ActionFilter *TaskAgentPoolActionFilter
}
// [Preview API] Get information about an agent queue.
func (client *ClientImpl) GetAgentQueue(ctx context.Context, args GetAgentQueueArgs) (*TaskAgentQueue, error) {
routeValues := make(map[string]string)
if args.Project != nil && *args.Project != "" {