/
client.go
718 lines (633 loc) · 26.7 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
// --------------------------------------------------------------------------------------------
// 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 servicehooks
import (
"bytes"
"context"
"encoding/json"
"github.com/google/uuid"
"github.com/microsoft/azure-devops-go-api/azuredevops"
"github.com/microsoft/azure-devops-go-api/azuredevops/forminput"
"github.com/microsoft/azure-devops-go-api/azuredevops/notification"
"net/http"
"net/url"
"strconv"
)
type Client interface {
// Create a subscription.
CreateSubscription(context.Context, CreateSubscriptionArgs) (*Subscription, error)
// Query for service hook subscriptions.
CreateSubscriptionsQuery(context.Context, CreateSubscriptionsQueryArgs) (*SubscriptionsQuery, error)
// Sends a test notification. This is useful for verifying the configuration of an updated or new service hooks subscription.
CreateTestNotification(context.Context, CreateTestNotificationArgs) (*Notification, error)
// Delete a specific service hooks subscription.
DeleteSubscription(context.Context, DeleteSubscriptionArgs) error
// Get a specific consumer service. Optionally filter out consumer actions that do not support any event types for the specified publisher.
GetConsumer(context.Context, GetConsumerArgs) (*Consumer, error)
// Get details about a specific consumer action.
GetConsumerAction(context.Context, GetConsumerActionArgs) (*ConsumerAction, error)
// Get a specific event type.
GetEventType(context.Context, GetEventTypeArgs) (*EventTypeDescriptor, error)
// Get a specific notification for a subscription.
GetNotification(context.Context, GetNotificationArgs) (*Notification, error)
// Get a list of notifications for a specific subscription. A notification includes details about the event, the request to and the response from the consumer service.
GetNotifications(context.Context, GetNotificationsArgs) (*[]Notification, error)
// Get a specific service hooks publisher.
GetPublisher(context.Context, GetPublisherArgs) (*Publisher, error)
// Get a specific service hooks subscription.
GetSubscription(context.Context, GetSubscriptionArgs) (*Subscription, error)
// [Preview API]
GetSubscriptionDiagnostics(context.Context, GetSubscriptionDiagnosticsArgs) (*notification.SubscriptionDiagnostics, error)
// Get a list of consumer actions for a specific consumer.
ListConsumerActions(context.Context, ListConsumerActionsArgs) (*[]ConsumerAction, error)
// Get a list of available service hook consumer services. Optionally filter by consumers that support at least one event type from the specific publisher.
ListConsumers(context.Context, ListConsumersArgs) (*[]Consumer, error)
// Get the event types for a specific publisher.
ListEventTypes(context.Context, ListEventTypesArgs) (*[]EventTypeDescriptor, error)
// Get a list of publishers.
ListPublishers(context.Context, ListPublishersArgs) (*[]Publisher, error)
// Get a list of subscriptions.
ListSubscriptions(context.Context, ListSubscriptionsArgs) (*[]Subscription, error)
QueryInputValues(context.Context, QueryInputValuesArgs) (*forminput.InputValuesQuery, error)
// Query for notifications. A notification includes details about the event, the request to and the response from the consumer service.
QueryNotifications(context.Context, QueryNotificationsArgs) (*NotificationsQuery, error)
// Query for service hook publishers.
QueryPublishers(context.Context, QueryPublishersArgs) (*PublishersQuery, error)
// Update a subscription. <param name="subscriptionId">ID for a subscription that you wish to update.</param>
ReplaceSubscription(context.Context, ReplaceSubscriptionArgs) (*Subscription, error)
// [Preview API]
UpdateSubscriptionDiagnostics(context.Context, UpdateSubscriptionDiagnosticsArgs) (*notification.SubscriptionDiagnostics, error)
}
type ClientImpl struct {
Client azuredevops.Client
}
func NewClient(ctx context.Context, connection *azuredevops.Connection) Client {
client := connection.GetClientByUrl(connection.BaseUrl)
return &ClientImpl{
Client: *client,
}
}
// Create a subscription.
func (client *ClientImpl) CreateSubscription(ctx context.Context, args CreateSubscriptionArgs) (*Subscription, error) {
if args.Subscription == nil {
return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.Subscription"}
}
body, marshalErr := json.Marshal(*args.Subscription)
if marshalErr != nil {
return nil, marshalErr
}
locationId, _ := uuid.Parse("fc50d02a-849f-41fb-8af1-0a5216103269")
resp, err := client.Client.Send(ctx, http.MethodPost, locationId, "5.1", nil, nil, bytes.NewReader(body), "application/json", "application/json", nil)
if err != nil {
return nil, err
}
var responseValue Subscription
err = client.Client.UnmarshalBody(resp, &responseValue)
return &responseValue, err
}
// Arguments for the CreateSubscription function
type CreateSubscriptionArgs struct {
// (required) Subscription to be created.
Subscription *Subscription
}
// Query for service hook subscriptions.
func (client *ClientImpl) CreateSubscriptionsQuery(ctx context.Context, args CreateSubscriptionsQueryArgs) (*SubscriptionsQuery, error) {
if args.Query == nil {
return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.Query"}
}
body, marshalErr := json.Marshal(*args.Query)
if marshalErr != nil {
return nil, marshalErr
}
locationId, _ := uuid.Parse("c7c3c1cf-9e05-4c0d-a425-a0f922c2c6ed")
resp, err := client.Client.Send(ctx, http.MethodPost, locationId, "5.1", nil, nil, bytes.NewReader(body), "application/json", "application/json", nil)
if err != nil {
return nil, err
}
var responseValue SubscriptionsQuery
err = client.Client.UnmarshalBody(resp, &responseValue)
return &responseValue, err
}
// Arguments for the CreateSubscriptionsQuery function
type CreateSubscriptionsQueryArgs struct {
// (required)
Query *SubscriptionsQuery
}
// Sends a test notification. This is useful for verifying the configuration of an updated or new service hooks subscription.
func (client *ClientImpl) CreateTestNotification(ctx context.Context, args CreateTestNotificationArgs) (*Notification, error) {
if args.TestNotification == nil {
return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.TestNotification"}
}
queryParams := url.Values{}
if args.UseRealData != nil {
queryParams.Add("useRealData", strconv.FormatBool(*args.UseRealData))
}
body, marshalErr := json.Marshal(*args.TestNotification)
if marshalErr != nil {
return nil, marshalErr
}
locationId, _ := uuid.Parse("1139462c-7e27-4524-a997-31b9b73551fe")
resp, err := client.Client.Send(ctx, http.MethodPost, locationId, "5.1", nil, queryParams, bytes.NewReader(body), "application/json", "application/json", nil)
if err != nil {
return nil, err
}
var responseValue Notification
err = client.Client.UnmarshalBody(resp, &responseValue)
return &responseValue, err
}
// Arguments for the CreateTestNotification function
type CreateTestNotificationArgs struct {
// (required)
TestNotification *Notification
// (optional) Only allow testing with real data in existing subscriptions.
UseRealData *bool
}
// Delete a specific service hooks subscription.
func (client *ClientImpl) DeleteSubscription(ctx context.Context, args DeleteSubscriptionArgs) error {
routeValues := make(map[string]string)
if args.SubscriptionId == nil {
return &azuredevops.ArgumentNilError{ArgumentName: "args.SubscriptionId"}
}
routeValues["subscriptionId"] = (*args.SubscriptionId).String()
locationId, _ := uuid.Parse("fc50d02a-849f-41fb-8af1-0a5216103269")
_, err := client.Client.Send(ctx, http.MethodDelete, locationId, "5.1", routeValues, nil, nil, "", "application/json", nil)
if err != nil {
return err
}
return nil
}
// Arguments for the DeleteSubscription function
type DeleteSubscriptionArgs struct {
// (required) ID for a subscription.
SubscriptionId *uuid.UUID
}
// Get a specific consumer service. Optionally filter out consumer actions that do not support any event types for the specified publisher.
func (client *ClientImpl) GetConsumer(ctx context.Context, args GetConsumerArgs) (*Consumer, error) {
routeValues := make(map[string]string)
if args.ConsumerId == nil || *args.ConsumerId == "" {
return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.ConsumerId"}
}
routeValues["consumerId"] = *args.ConsumerId
queryParams := url.Values{}
if args.PublisherId != nil {
queryParams.Add("publisherId", *args.PublisherId)
}
locationId, _ := uuid.Parse("4301c514-5f34-4f5d-a145-f0ea7b5b7d19")
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 Consumer
err = client.Client.UnmarshalBody(resp, &responseValue)
return &responseValue, err
}
// Arguments for the GetConsumer function
type GetConsumerArgs struct {
// (required) ID for a consumer.
ConsumerId *string
// (optional)
PublisherId *string
}
// Get details about a specific consumer action.
func (client *ClientImpl) GetConsumerAction(ctx context.Context, args GetConsumerActionArgs) (*ConsumerAction, error) {
routeValues := make(map[string]string)
if args.ConsumerId == nil || *args.ConsumerId == "" {
return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.ConsumerId"}
}
routeValues["consumerId"] = *args.ConsumerId
if args.ConsumerActionId == nil || *args.ConsumerActionId == "" {
return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.ConsumerActionId"}
}
routeValues["consumerActionId"] = *args.ConsumerActionId
queryParams := url.Values{}
if args.PublisherId != nil {
queryParams.Add("publisherId", *args.PublisherId)
}
locationId, _ := uuid.Parse("c3428e90-7a69-4194-8ed8-0f153185ee0d")
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 ConsumerAction
err = client.Client.UnmarshalBody(resp, &responseValue)
return &responseValue, err
}
// Arguments for the GetConsumerAction function
type GetConsumerActionArgs struct {
// (required) ID for a consumer.
ConsumerId *string
// (required) ID for a consumerActionId.
ConsumerActionId *string
// (optional)
PublisherId *string
}
// Get a specific event type.
func (client *ClientImpl) GetEventType(ctx context.Context, args GetEventTypeArgs) (*EventTypeDescriptor, error) {
routeValues := make(map[string]string)
if args.PublisherId == nil || *args.PublisherId == "" {
return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.PublisherId"}
}
routeValues["publisherId"] = *args.PublisherId
if args.EventTypeId == nil || *args.EventTypeId == "" {
return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.EventTypeId"}
}
routeValues["eventTypeId"] = *args.EventTypeId
locationId, _ := uuid.Parse("db4777cd-8e08-4a84-8ba3-c974ea033718")
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 EventTypeDescriptor
err = client.Client.UnmarshalBody(resp, &responseValue)
return &responseValue, err
}
// Arguments for the GetEventType function
type GetEventTypeArgs struct {
// (required) ID for a publisher.
PublisherId *string
// (required)
EventTypeId *string
}
// Get a specific notification for a subscription.
func (client *ClientImpl) GetNotification(ctx context.Context, args GetNotificationArgs) (*Notification, error) {
routeValues := make(map[string]string)
if args.SubscriptionId == nil {
return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.SubscriptionId"}
}
routeValues["subscriptionId"] = (*args.SubscriptionId).String()
if args.NotificationId == nil {
return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.NotificationId"}
}
routeValues["notificationId"] = strconv.Itoa(*args.NotificationId)
locationId, _ := uuid.Parse("0c62d343-21b0-4732-997b-017fde84dc28")
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 Notification
err = client.Client.UnmarshalBody(resp, &responseValue)
return &responseValue, err
}
// Arguments for the GetNotification function
type GetNotificationArgs struct {
// (required) ID for a subscription.
SubscriptionId *uuid.UUID
// (required)
NotificationId *int
}
// Get a list of notifications for a specific subscription. A notification includes details about the event, the request to and the response from the consumer service.
func (client *ClientImpl) GetNotifications(ctx context.Context, args GetNotificationsArgs) (*[]Notification, error) {
routeValues := make(map[string]string)
if args.SubscriptionId == nil {
return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.SubscriptionId"}
}
routeValues["subscriptionId"] = (*args.SubscriptionId).String()
queryParams := url.Values{}
if args.MaxResults != nil {
queryParams.Add("maxResults", strconv.Itoa(*args.MaxResults))
}
if args.Status != nil {
queryParams.Add("status", string(*args.Status))
}
if args.Result != nil {
queryParams.Add("result", string(*args.Result))
}
locationId, _ := uuid.Parse("0c62d343-21b0-4732-997b-017fde84dc28")
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 []Notification
err = client.Client.UnmarshalCollectionBody(resp, &responseValue)
return &responseValue, err
}
// Arguments for the GetNotifications function
type GetNotificationsArgs struct {
// (required) ID for a subscription.
SubscriptionId *uuid.UUID
// (optional) Maximum number of notifications to return. Default is **100**.
MaxResults *int
// (optional) Get only notifications with this status.
Status *NotificationStatus
// (optional) Get only notifications with this result type.
Result *NotificationResult
}
// Get a specific service hooks publisher.
func (client *ClientImpl) GetPublisher(ctx context.Context, args GetPublisherArgs) (*Publisher, error) {
routeValues := make(map[string]string)
if args.PublisherId == nil || *args.PublisherId == "" {
return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.PublisherId"}
}
routeValues["publisherId"] = *args.PublisherId
locationId, _ := uuid.Parse("1e83a210-5b53-43bc-90f0-d476a4e5d731")
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 Publisher
err = client.Client.UnmarshalBody(resp, &responseValue)
return &responseValue, err
}
// Arguments for the GetPublisher function
type GetPublisherArgs struct {
// (required) ID for a publisher.
PublisherId *string
}
// Get a specific service hooks subscription.
func (client *ClientImpl) GetSubscription(ctx context.Context, args GetSubscriptionArgs) (*Subscription, error) {
routeValues := make(map[string]string)
if args.SubscriptionId == nil {
return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.SubscriptionId"}
}
routeValues["subscriptionId"] = (*args.SubscriptionId).String()
locationId, _ := uuid.Parse("fc50d02a-849f-41fb-8af1-0a5216103269")
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 Subscription
err = client.Client.UnmarshalBody(resp, &responseValue)
return &responseValue, err
}
// Arguments for the GetSubscription function
type GetSubscriptionArgs struct {
// (required) ID for a subscription.
SubscriptionId *uuid.UUID
}
// [Preview API]
func (client *ClientImpl) GetSubscriptionDiagnostics(ctx context.Context, args GetSubscriptionDiagnosticsArgs) (*notification.SubscriptionDiagnostics, error) {
routeValues := make(map[string]string)
if args.SubscriptionId == nil || *args.SubscriptionId == "" {
return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.SubscriptionId"}
}
routeValues["subscriptionId"] = *args.SubscriptionId
locationId, _ := uuid.Parse("3b36bcb5-02ad-43c6-bbfa-6dfc6f8e9d68")
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 notification.SubscriptionDiagnostics
err = client.Client.UnmarshalBody(resp, &responseValue)
return &responseValue, err
}
// Arguments for the GetSubscriptionDiagnostics function
type GetSubscriptionDiagnosticsArgs struct {
// (required)
SubscriptionId *string
}
// Get a list of consumer actions for a specific consumer.
func (client *ClientImpl) ListConsumerActions(ctx context.Context, args ListConsumerActionsArgs) (*[]ConsumerAction, error) {
routeValues := make(map[string]string)
if args.ConsumerId == nil || *args.ConsumerId == "" {
return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.ConsumerId"}
}
routeValues["consumerId"] = *args.ConsumerId
queryParams := url.Values{}
if args.PublisherId != nil {
queryParams.Add("publisherId", *args.PublisherId)
}
locationId, _ := uuid.Parse("c3428e90-7a69-4194-8ed8-0f153185ee0d")
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 []ConsumerAction
err = client.Client.UnmarshalCollectionBody(resp, &responseValue)
return &responseValue, err
}
// Arguments for the ListConsumerActions function
type ListConsumerActionsArgs struct {
// (required) ID for a consumer.
ConsumerId *string
// (optional)
PublisherId *string
}
// Get a list of available service hook consumer services. Optionally filter by consumers that support at least one event type from the specific publisher.
func (client *ClientImpl) ListConsumers(ctx context.Context, args ListConsumersArgs) (*[]Consumer, error) {
queryParams := url.Values{}
if args.PublisherId != nil {
queryParams.Add("publisherId", *args.PublisherId)
}
locationId, _ := uuid.Parse("4301c514-5f34-4f5d-a145-f0ea7b5b7d19")
resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1", nil, queryParams, nil, "", "application/json", nil)
if err != nil {
return nil, err
}
var responseValue []Consumer
err = client.Client.UnmarshalCollectionBody(resp, &responseValue)
return &responseValue, err
}
// Arguments for the ListConsumers function
type ListConsumersArgs struct {
// (optional)
PublisherId *string
}
// Get the event types for a specific publisher.
func (client *ClientImpl) ListEventTypes(ctx context.Context, args ListEventTypesArgs) (*[]EventTypeDescriptor, error) {
routeValues := make(map[string]string)
if args.PublisherId == nil || *args.PublisherId == "" {
return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.PublisherId"}
}
routeValues["publisherId"] = *args.PublisherId
locationId, _ := uuid.Parse("db4777cd-8e08-4a84-8ba3-c974ea033718")
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 []EventTypeDescriptor
err = client.Client.UnmarshalCollectionBody(resp, &responseValue)
return &responseValue, err
}
// Arguments for the ListEventTypes function
type ListEventTypesArgs struct {
// (required) ID for a publisher.
PublisherId *string
}
// Get a list of publishers.
func (client *ClientImpl) ListPublishers(ctx context.Context, args ListPublishersArgs) (*[]Publisher, error) {
locationId, _ := uuid.Parse("1e83a210-5b53-43bc-90f0-d476a4e5d731")
resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1", nil, nil, nil, "", "application/json", nil)
if err != nil {
return nil, err
}
var responseValue []Publisher
err = client.Client.UnmarshalCollectionBody(resp, &responseValue)
return &responseValue, err
}
// Arguments for the ListPublishers function
type ListPublishersArgs struct {
}
// Get a list of subscriptions.
func (client *ClientImpl) ListSubscriptions(ctx context.Context, args ListSubscriptionsArgs) (*[]Subscription, error) {
queryParams := url.Values{}
if args.PublisherId != nil {
queryParams.Add("publisherId", *args.PublisherId)
}
if args.EventType != nil {
queryParams.Add("eventType", *args.EventType)
}
if args.ConsumerId != nil {
queryParams.Add("consumerId", *args.ConsumerId)
}
if args.ConsumerActionId != nil {
queryParams.Add("consumerActionId", *args.ConsumerActionId)
}
locationId, _ := uuid.Parse("fc50d02a-849f-41fb-8af1-0a5216103269")
resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1", nil, queryParams, nil, "", "application/json", nil)
if err != nil {
return nil, err
}
var responseValue []Subscription
err = client.Client.UnmarshalCollectionBody(resp, &responseValue)
return &responseValue, err
}
// Arguments for the ListSubscriptions function
type ListSubscriptionsArgs struct {
// (optional) ID for a subscription.
PublisherId *string
// (optional) The event type to filter on (if any).
EventType *string
// (optional) ID for a consumer.
ConsumerId *string
// (optional) ID for a consumerActionId.
ConsumerActionId *string
}
func (client *ClientImpl) QueryInputValues(ctx context.Context, args QueryInputValuesArgs) (*forminput.InputValuesQuery, error) {
if args.InputValuesQuery == nil {
return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.InputValuesQuery"}
}
routeValues := make(map[string]string)
if args.PublisherId == nil || *args.PublisherId == "" {
return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.PublisherId"}
}
routeValues["publisherId"] = *args.PublisherId
body, marshalErr := json.Marshal(*args.InputValuesQuery)
if marshalErr != nil {
return nil, marshalErr
}
locationId, _ := uuid.Parse("d815d352-a566-4dc1-a3e3-fd245acf688c")
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 forminput.InputValuesQuery
err = client.Client.UnmarshalBody(resp, &responseValue)
return &responseValue, err
}
// Arguments for the QueryInputValues function
type QueryInputValuesArgs struct {
// (required)
InputValuesQuery *forminput.InputValuesQuery
// (required)
PublisherId *string
}
// Query for notifications. A notification includes details about the event, the request to and the response from the consumer service.
func (client *ClientImpl) QueryNotifications(ctx context.Context, args QueryNotificationsArgs) (*NotificationsQuery, error) {
if args.Query == nil {
return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.Query"}
}
body, marshalErr := json.Marshal(*args.Query)
if marshalErr != nil {
return nil, marshalErr
}
locationId, _ := uuid.Parse("1a57562f-160a-4b5c-9185-905e95b39d36")
resp, err := client.Client.Send(ctx, http.MethodPost, locationId, "5.1", nil, nil, bytes.NewReader(body), "application/json", "application/json", nil)
if err != nil {
return nil, err
}
var responseValue NotificationsQuery
err = client.Client.UnmarshalBody(resp, &responseValue)
return &responseValue, err
}
// Arguments for the QueryNotifications function
type QueryNotificationsArgs struct {
// (required)
Query *NotificationsQuery
}
// Query for service hook publishers.
func (client *ClientImpl) QueryPublishers(ctx context.Context, args QueryPublishersArgs) (*PublishersQuery, error) {
if args.Query == nil {
return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.Query"}
}
body, marshalErr := json.Marshal(*args.Query)
if marshalErr != nil {
return nil, marshalErr
}
locationId, _ := uuid.Parse("99b44a8a-65a8-4670-8f3e-e7f7842cce64")
resp, err := client.Client.Send(ctx, http.MethodPost, locationId, "5.1", nil, nil, bytes.NewReader(body), "application/json", "application/json", nil)
if err != nil {
return nil, err
}
var responseValue PublishersQuery
err = client.Client.UnmarshalBody(resp, &responseValue)
return &responseValue, err
}
// Arguments for the QueryPublishers function
type QueryPublishersArgs struct {
// (required)
Query *PublishersQuery
}
// Update a subscription. <param name="subscriptionId">ID for a subscription that you wish to update.</param>
func (client *ClientImpl) ReplaceSubscription(ctx context.Context, args ReplaceSubscriptionArgs) (*Subscription, error) {
if args.Subscription == nil {
return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.Subscription"}
}
routeValues := make(map[string]string)
if args.SubscriptionId != nil {
routeValues["subscriptionId"] = (*args.SubscriptionId).String()
}
body, marshalErr := json.Marshal(*args.Subscription)
if marshalErr != nil {
return nil, marshalErr
}
locationId, _ := uuid.Parse("fc50d02a-849f-41fb-8af1-0a5216103269")
resp, err := client.Client.Send(ctx, http.MethodPut, locationId, "5.1", routeValues, nil, bytes.NewReader(body), "application/json", "application/json", nil)
if err != nil {
return nil, err
}
var responseValue Subscription
err = client.Client.UnmarshalBody(resp, &responseValue)
return &responseValue, err
}
// Arguments for the ReplaceSubscription function
type ReplaceSubscriptionArgs struct {
// (required)
Subscription *Subscription
// (optional)
SubscriptionId *uuid.UUID
}
// [Preview API]
func (client *ClientImpl) UpdateSubscriptionDiagnostics(ctx context.Context, args UpdateSubscriptionDiagnosticsArgs) (*notification.SubscriptionDiagnostics, error) {
if args.UpdateParameters == nil {
return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.UpdateParameters"}
}
routeValues := make(map[string]string)
if args.SubscriptionId == nil || *args.SubscriptionId == "" {
return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.SubscriptionId"}
}
routeValues["subscriptionId"] = *args.SubscriptionId
body, marshalErr := json.Marshal(*args.UpdateParameters)
if marshalErr != nil {
return nil, marshalErr
}
locationId, _ := uuid.Parse("3b36bcb5-02ad-43c6-bbfa-6dfc6f8e9d68")
resp, err := client.Client.Send(ctx, http.MethodPut, locationId, "5.1-preview.1", routeValues, nil, bytes.NewReader(body), "application/json", "application/json", nil)
if err != nil {
return nil, err
}
var responseValue notification.SubscriptionDiagnostics
err = client.Client.UnmarshalBody(resp, &responseValue)
return &responseValue, err
}
// Arguments for the UpdateSubscriptionDiagnostics function
type UpdateSubscriptionDiagnosticsArgs struct {
// (required)
UpdateParameters *notification.UpdateSubscripitonDiagnosticsParameters
// (required)
SubscriptionId *string
}