1 package insights
2
3
4
5
6
7
8
9 import (
10 "context"
11 "github.com/Azure/go-autorest/autorest"
12 "github.com/Azure/go-autorest/autorest/azure"
13 "github.com/Azure/go-autorest/autorest/validation"
14 "github.com/Azure/go-autorest/tracing"
15 "net/http"
16 )
17
18
19 type ActionGroupsClient struct {
20 BaseClient
21 }
22
23
24 func NewActionGroupsClient(subscriptionID string) ActionGroupsClient {
25 return NewActionGroupsClientWithBaseURI(DefaultBaseURI, subscriptionID)
26 }
27
28
29
30 func NewActionGroupsClientWithBaseURI(baseURI string, subscriptionID string) ActionGroupsClient {
31 return ActionGroupsClient{NewWithBaseURI(baseURI, subscriptionID)}
32 }
33
34
35
36
37
38
39 func (client ActionGroupsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, actionGroupName string, actionGroup ActionGroupResource) (result ActionGroupResource, err error) {
40 if tracing.IsEnabled() {
41 ctx = tracing.StartSpan(ctx, fqdn+"/ActionGroupsClient.CreateOrUpdate")
42 defer func() {
43 sc := -1
44 if result.Response.Response != nil {
45 sc = result.Response.Response.StatusCode
46 }
47 tracing.EndSpan(ctx, sc, err)
48 }()
49 }
50 if err := validation.Validate([]validation.Validation{
51 {TargetValue: resourceGroupName,
52 Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
53 {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}},
54 {TargetValue: actionGroup,
55 Constraints: []validation.Constraint{{Target: "actionGroup.ActionGroup", Name: validation.Null, Rule: false,
56 Chain: []validation.Constraint{{Target: "actionGroup.ActionGroup.GroupShortName", Name: validation.Null, Rule: true,
57 Chain: []validation.Constraint{{Target: "actionGroup.ActionGroup.GroupShortName", Name: validation.MaxLength, Rule: 12, Chain: nil}}},
58 {Target: "actionGroup.ActionGroup.Enabled", Name: validation.Null, Rule: true, Chain: nil},
59 }}}},
60 {TargetValue: client.SubscriptionID,
61 Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil {
62 return result, validation.NewError("insights.ActionGroupsClient", "CreateOrUpdate", err.Error())
63 }
64
65 req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, actionGroupName, actionGroup)
66 if err != nil {
67 err = autorest.NewErrorWithError(err, "insights.ActionGroupsClient", "CreateOrUpdate", nil, "Failure preparing request")
68 return
69 }
70
71 resp, err := client.CreateOrUpdateSender(req)
72 if err != nil {
73 result.Response = autorest.Response{Response: resp}
74 err = autorest.NewErrorWithError(err, "insights.ActionGroupsClient", "CreateOrUpdate", resp, "Failure sending request")
75 return
76 }
77
78 result, err = client.CreateOrUpdateResponder(resp)
79 if err != nil {
80 err = autorest.NewErrorWithError(err, "insights.ActionGroupsClient", "CreateOrUpdate", resp, "Failure responding to request")
81 return
82 }
83
84 return
85 }
86
87
88 func (client ActionGroupsClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, actionGroupName string, actionGroup ActionGroupResource) (*http.Request, error) {
89 pathParameters := map[string]interface{}{
90 "actionGroupName": autorest.Encode("path", actionGroupName),
91 "resourceGroupName": autorest.Encode("path", resourceGroupName),
92 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
93 }
94
95 const APIVersion = "2021-09-01"
96 queryParameters := map[string]interface{}{
97 "api-version": APIVersion,
98 }
99
100 preparer := autorest.CreatePreparer(
101 autorest.AsContentType("application/json; charset=utf-8"),
102 autorest.AsPut(),
103 autorest.WithBaseURL(client.BaseURI),
104 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}", pathParameters),
105 autorest.WithJSON(actionGroup),
106 autorest.WithQueryParameters(queryParameters))
107 return preparer.Prepare((&http.Request{}).WithContext(ctx))
108 }
109
110
111
112 func (client ActionGroupsClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) {
113 return client.Send(req, azure.DoRetryWithRegistration(client.Client))
114 }
115
116
117
118 func (client ActionGroupsClient) CreateOrUpdateResponder(resp *http.Response) (result ActionGroupResource, err error) {
119 err = autorest.Respond(
120 resp,
121 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated),
122 autorest.ByUnmarshallingJSON(&result),
123 autorest.ByClosing())
124 result.Response = autorest.Response{Response: resp}
125 return
126 }
127
128
129
130
131
132 func (client ActionGroupsClient) Delete(ctx context.Context, resourceGroupName string, actionGroupName string) (result autorest.Response, err error) {
133 if tracing.IsEnabled() {
134 ctx = tracing.StartSpan(ctx, fqdn+"/ActionGroupsClient.Delete")
135 defer func() {
136 sc := -1
137 if result.Response != nil {
138 sc = result.Response.StatusCode
139 }
140 tracing.EndSpan(ctx, sc, err)
141 }()
142 }
143 if err := validation.Validate([]validation.Validation{
144 {TargetValue: resourceGroupName,
145 Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
146 {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}},
147 {TargetValue: client.SubscriptionID,
148 Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil {
149 return result, validation.NewError("insights.ActionGroupsClient", "Delete", err.Error())
150 }
151
152 req, err := client.DeletePreparer(ctx, resourceGroupName, actionGroupName)
153 if err != nil {
154 err = autorest.NewErrorWithError(err, "insights.ActionGroupsClient", "Delete", nil, "Failure preparing request")
155 return
156 }
157
158 resp, err := client.DeleteSender(req)
159 if err != nil {
160 result.Response = resp
161 err = autorest.NewErrorWithError(err, "insights.ActionGroupsClient", "Delete", resp, "Failure sending request")
162 return
163 }
164
165 result, err = client.DeleteResponder(resp)
166 if err != nil {
167 err = autorest.NewErrorWithError(err, "insights.ActionGroupsClient", "Delete", resp, "Failure responding to request")
168 return
169 }
170
171 return
172 }
173
174
175 func (client ActionGroupsClient) DeletePreparer(ctx context.Context, resourceGroupName string, actionGroupName string) (*http.Request, error) {
176 pathParameters := map[string]interface{}{
177 "actionGroupName": autorest.Encode("path", actionGroupName),
178 "resourceGroupName": autorest.Encode("path", resourceGroupName),
179 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
180 }
181
182 const APIVersion = "2021-09-01"
183 queryParameters := map[string]interface{}{
184 "api-version": APIVersion,
185 }
186
187 preparer := autorest.CreatePreparer(
188 autorest.AsDelete(),
189 autorest.WithBaseURL(client.BaseURI),
190 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}", pathParameters),
191 autorest.WithQueryParameters(queryParameters))
192 return preparer.Prepare((&http.Request{}).WithContext(ctx))
193 }
194
195
196
197 func (client ActionGroupsClient) DeleteSender(req *http.Request) (*http.Response, error) {
198 return client.Send(req, azure.DoRetryWithRegistration(client.Client))
199 }
200
201
202
203 func (client ActionGroupsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) {
204 err = autorest.Respond(
205 resp,
206 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent),
207 autorest.ByClosing())
208 result.Response = resp
209 return
210 }
211
212
213
214
215
216
217
218 func (client ActionGroupsClient) EnableReceiver(ctx context.Context, resourceGroupName string, actionGroupName string, enableRequest EnableRequest) (result autorest.Response, err error) {
219 if tracing.IsEnabled() {
220 ctx = tracing.StartSpan(ctx, fqdn+"/ActionGroupsClient.EnableReceiver")
221 defer func() {
222 sc := -1
223 if result.Response != nil {
224 sc = result.Response.StatusCode
225 }
226 tracing.EndSpan(ctx, sc, err)
227 }()
228 }
229 if err := validation.Validate([]validation.Validation{
230 {TargetValue: resourceGroupName,
231 Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
232 {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}},
233 {TargetValue: enableRequest,
234 Constraints: []validation.Constraint{{Target: "enableRequest.ReceiverName", Name: validation.Null, Rule: true, Chain: nil}}},
235 {TargetValue: client.SubscriptionID,
236 Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil {
237 return result, validation.NewError("insights.ActionGroupsClient", "EnableReceiver", err.Error())
238 }
239
240 req, err := client.EnableReceiverPreparer(ctx, resourceGroupName, actionGroupName, enableRequest)
241 if err != nil {
242 err = autorest.NewErrorWithError(err, "insights.ActionGroupsClient", "EnableReceiver", nil, "Failure preparing request")
243 return
244 }
245
246 resp, err := client.EnableReceiverSender(req)
247 if err != nil {
248 result.Response = resp
249 err = autorest.NewErrorWithError(err, "insights.ActionGroupsClient", "EnableReceiver", resp, "Failure sending request")
250 return
251 }
252
253 result, err = client.EnableReceiverResponder(resp)
254 if err != nil {
255 err = autorest.NewErrorWithError(err, "insights.ActionGroupsClient", "EnableReceiver", resp, "Failure responding to request")
256 return
257 }
258
259 return
260 }
261
262
263 func (client ActionGroupsClient) EnableReceiverPreparer(ctx context.Context, resourceGroupName string, actionGroupName string, enableRequest EnableRequest) (*http.Request, error) {
264 pathParameters := map[string]interface{}{
265 "actionGroupName": autorest.Encode("path", actionGroupName),
266 "resourceGroupName": autorest.Encode("path", resourceGroupName),
267 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
268 }
269
270 const APIVersion = "2021-09-01"
271 queryParameters := map[string]interface{}{
272 "api-version": APIVersion,
273 }
274
275 preparer := autorest.CreatePreparer(
276 autorest.AsContentType("application/json; charset=utf-8"),
277 autorest.AsPost(),
278 autorest.WithBaseURL(client.BaseURI),
279 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}/subscribe", pathParameters),
280 autorest.WithJSON(enableRequest),
281 autorest.WithQueryParameters(queryParameters))
282 return preparer.Prepare((&http.Request{}).WithContext(ctx))
283 }
284
285
286
287 func (client ActionGroupsClient) EnableReceiverSender(req *http.Request) (*http.Response, error) {
288 return client.Send(req, azure.DoRetryWithRegistration(client.Client))
289 }
290
291
292
293 func (client ActionGroupsClient) EnableReceiverResponder(resp *http.Response) (result autorest.Response, err error) {
294 err = autorest.Respond(
295 resp,
296 azure.WithErrorUnlessStatusCode(http.StatusOK),
297 autorest.ByClosing())
298 result.Response = resp
299 return
300 }
301
302
303
304
305
306 func (client ActionGroupsClient) Get(ctx context.Context, resourceGroupName string, actionGroupName string) (result ActionGroupResource, err error) {
307 if tracing.IsEnabled() {
308 ctx = tracing.StartSpan(ctx, fqdn+"/ActionGroupsClient.Get")
309 defer func() {
310 sc := -1
311 if result.Response.Response != nil {
312 sc = result.Response.Response.StatusCode
313 }
314 tracing.EndSpan(ctx, sc, err)
315 }()
316 }
317 if err := validation.Validate([]validation.Validation{
318 {TargetValue: resourceGroupName,
319 Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
320 {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}},
321 {TargetValue: client.SubscriptionID,
322 Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil {
323 return result, validation.NewError("insights.ActionGroupsClient", "Get", err.Error())
324 }
325
326 req, err := client.GetPreparer(ctx, resourceGroupName, actionGroupName)
327 if err != nil {
328 err = autorest.NewErrorWithError(err, "insights.ActionGroupsClient", "Get", nil, "Failure preparing request")
329 return
330 }
331
332 resp, err := client.GetSender(req)
333 if err != nil {
334 result.Response = autorest.Response{Response: resp}
335 err = autorest.NewErrorWithError(err, "insights.ActionGroupsClient", "Get", resp, "Failure sending request")
336 return
337 }
338
339 result, err = client.GetResponder(resp)
340 if err != nil {
341 err = autorest.NewErrorWithError(err, "insights.ActionGroupsClient", "Get", resp, "Failure responding to request")
342 return
343 }
344
345 return
346 }
347
348
349 func (client ActionGroupsClient) GetPreparer(ctx context.Context, resourceGroupName string, actionGroupName string) (*http.Request, error) {
350 pathParameters := map[string]interface{}{
351 "actionGroupName": autorest.Encode("path", actionGroupName),
352 "resourceGroupName": autorest.Encode("path", resourceGroupName),
353 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
354 }
355
356 const APIVersion = "2021-09-01"
357 queryParameters := map[string]interface{}{
358 "api-version": APIVersion,
359 }
360
361 preparer := autorest.CreatePreparer(
362 autorest.AsGet(),
363 autorest.WithBaseURL(client.BaseURI),
364 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}", pathParameters),
365 autorest.WithQueryParameters(queryParameters))
366 return preparer.Prepare((&http.Request{}).WithContext(ctx))
367 }
368
369
370
371 func (client ActionGroupsClient) GetSender(req *http.Request) (*http.Response, error) {
372 return client.Send(req, azure.DoRetryWithRegistration(client.Client))
373 }
374
375
376
377 func (client ActionGroupsClient) GetResponder(resp *http.Response) (result ActionGroupResource, err error) {
378 err = autorest.Respond(
379 resp,
380 azure.WithErrorUnlessStatusCode(http.StatusOK),
381 autorest.ByUnmarshallingJSON(&result),
382 autorest.ByClosing())
383 result.Response = autorest.Response{Response: resp}
384 return
385 }
386
387
388
389
390 func (client ActionGroupsClient) GetTestNotifications(ctx context.Context, notificationID string) (result TestNotificationDetailsResponse, err error) {
391 if tracing.IsEnabled() {
392 ctx = tracing.StartSpan(ctx, fqdn+"/ActionGroupsClient.GetTestNotifications")
393 defer func() {
394 sc := -1
395 if result.Response.Response != nil {
396 sc = result.Response.Response.StatusCode
397 }
398 tracing.EndSpan(ctx, sc, err)
399 }()
400 }
401 if err := validation.Validate([]validation.Validation{
402 {TargetValue: client.SubscriptionID,
403 Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil {
404 return result, validation.NewError("insights.ActionGroupsClient", "GetTestNotifications", err.Error())
405 }
406
407 req, err := client.GetTestNotificationsPreparer(ctx, notificationID)
408 if err != nil {
409 err = autorest.NewErrorWithError(err, "insights.ActionGroupsClient", "GetTestNotifications", nil, "Failure preparing request")
410 return
411 }
412
413 resp, err := client.GetTestNotificationsSender(req)
414 if err != nil {
415 result.Response = autorest.Response{Response: resp}
416 err = autorest.NewErrorWithError(err, "insights.ActionGroupsClient", "GetTestNotifications", resp, "Failure sending request")
417 return
418 }
419
420 result, err = client.GetTestNotificationsResponder(resp)
421 if err != nil {
422 err = autorest.NewErrorWithError(err, "insights.ActionGroupsClient", "GetTestNotifications", resp, "Failure responding to request")
423 return
424 }
425
426 return
427 }
428
429
430 func (client ActionGroupsClient) GetTestNotificationsPreparer(ctx context.Context, notificationID string) (*http.Request, error) {
431 pathParameters := map[string]interface{}{
432 "notificationId": autorest.Encode("path", notificationID),
433 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
434 }
435
436 const APIVersion = "2021-09-01"
437 queryParameters := map[string]interface{}{
438 "api-version": APIVersion,
439 }
440
441 preparer := autorest.CreatePreparer(
442 autorest.AsGet(),
443 autorest.WithBaseURL(client.BaseURI),
444 autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Insights/notificationStatus/{notificationId}", pathParameters),
445 autorest.WithQueryParameters(queryParameters))
446 return preparer.Prepare((&http.Request{}).WithContext(ctx))
447 }
448
449
450
451 func (client ActionGroupsClient) GetTestNotificationsSender(req *http.Request) (*http.Response, error) {
452 return client.Send(req, azure.DoRetryWithRegistration(client.Client))
453 }
454
455
456
457 func (client ActionGroupsClient) GetTestNotificationsResponder(resp *http.Response) (result TestNotificationDetailsResponse, err error) {
458 err = autorest.Respond(
459 resp,
460 azure.WithErrorUnlessStatusCode(http.StatusOK),
461 autorest.ByUnmarshallingJSON(&result),
462 autorest.ByClosing())
463 result.Response = autorest.Response{Response: resp}
464 return
465 }
466
467
468
469
470 func (client ActionGroupsClient) ListByResourceGroup(ctx context.Context, resourceGroupName string) (result ActionGroupList, err error) {
471 if tracing.IsEnabled() {
472 ctx = tracing.StartSpan(ctx, fqdn+"/ActionGroupsClient.ListByResourceGroup")
473 defer func() {
474 sc := -1
475 if result.Response.Response != nil {
476 sc = result.Response.Response.StatusCode
477 }
478 tracing.EndSpan(ctx, sc, err)
479 }()
480 }
481 if err := validation.Validate([]validation.Validation{
482 {TargetValue: resourceGroupName,
483 Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
484 {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}},
485 {TargetValue: client.SubscriptionID,
486 Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil {
487 return result, validation.NewError("insights.ActionGroupsClient", "ListByResourceGroup", err.Error())
488 }
489
490 req, err := client.ListByResourceGroupPreparer(ctx, resourceGroupName)
491 if err != nil {
492 err = autorest.NewErrorWithError(err, "insights.ActionGroupsClient", "ListByResourceGroup", nil, "Failure preparing request")
493 return
494 }
495
496 resp, err := client.ListByResourceGroupSender(req)
497 if err != nil {
498 result.Response = autorest.Response{Response: resp}
499 err = autorest.NewErrorWithError(err, "insights.ActionGroupsClient", "ListByResourceGroup", resp, "Failure sending request")
500 return
501 }
502
503 result, err = client.ListByResourceGroupResponder(resp)
504 if err != nil {
505 err = autorest.NewErrorWithError(err, "insights.ActionGroupsClient", "ListByResourceGroup", resp, "Failure responding to request")
506 return
507 }
508
509 return
510 }
511
512
513 func (client ActionGroupsClient) ListByResourceGroupPreparer(ctx context.Context, resourceGroupName string) (*http.Request, error) {
514 pathParameters := map[string]interface{}{
515 "resourceGroupName": autorest.Encode("path", resourceGroupName),
516 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
517 }
518
519 const APIVersion = "2021-09-01"
520 queryParameters := map[string]interface{}{
521 "api-version": APIVersion,
522 }
523
524 preparer := autorest.CreatePreparer(
525 autorest.AsGet(),
526 autorest.WithBaseURL(client.BaseURI),
527 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups", pathParameters),
528 autorest.WithQueryParameters(queryParameters))
529 return preparer.Prepare((&http.Request{}).WithContext(ctx))
530 }
531
532
533
534 func (client ActionGroupsClient) ListByResourceGroupSender(req *http.Request) (*http.Response, error) {
535 return client.Send(req, azure.DoRetryWithRegistration(client.Client))
536 }
537
538
539
540 func (client ActionGroupsClient) ListByResourceGroupResponder(resp *http.Response) (result ActionGroupList, err error) {
541 err = autorest.Respond(
542 resp,
543 azure.WithErrorUnlessStatusCode(http.StatusOK),
544 autorest.ByUnmarshallingJSON(&result),
545 autorest.ByClosing())
546 result.Response = autorest.Response{Response: resp}
547 return
548 }
549
550
551 func (client ActionGroupsClient) ListBySubscriptionID(ctx context.Context) (result ActionGroupList, err error) {
552 if tracing.IsEnabled() {
553 ctx = tracing.StartSpan(ctx, fqdn+"/ActionGroupsClient.ListBySubscriptionID")
554 defer func() {
555 sc := -1
556 if result.Response.Response != nil {
557 sc = result.Response.Response.StatusCode
558 }
559 tracing.EndSpan(ctx, sc, err)
560 }()
561 }
562 if err := validation.Validate([]validation.Validation{
563 {TargetValue: client.SubscriptionID,
564 Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil {
565 return result, validation.NewError("insights.ActionGroupsClient", "ListBySubscriptionID", err.Error())
566 }
567
568 req, err := client.ListBySubscriptionIDPreparer(ctx)
569 if err != nil {
570 err = autorest.NewErrorWithError(err, "insights.ActionGroupsClient", "ListBySubscriptionID", nil, "Failure preparing request")
571 return
572 }
573
574 resp, err := client.ListBySubscriptionIDSender(req)
575 if err != nil {
576 result.Response = autorest.Response{Response: resp}
577 err = autorest.NewErrorWithError(err, "insights.ActionGroupsClient", "ListBySubscriptionID", resp, "Failure sending request")
578 return
579 }
580
581 result, err = client.ListBySubscriptionIDResponder(resp)
582 if err != nil {
583 err = autorest.NewErrorWithError(err, "insights.ActionGroupsClient", "ListBySubscriptionID", resp, "Failure responding to request")
584 return
585 }
586
587 return
588 }
589
590
591 func (client ActionGroupsClient) ListBySubscriptionIDPreparer(ctx context.Context) (*http.Request, error) {
592 pathParameters := map[string]interface{}{
593 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
594 }
595
596 const APIVersion = "2021-09-01"
597 queryParameters := map[string]interface{}{
598 "api-version": APIVersion,
599 }
600
601 preparer := autorest.CreatePreparer(
602 autorest.AsGet(),
603 autorest.WithBaseURL(client.BaseURI),
604 autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Insights/actionGroups", pathParameters),
605 autorest.WithQueryParameters(queryParameters))
606 return preparer.Prepare((&http.Request{}).WithContext(ctx))
607 }
608
609
610
611 func (client ActionGroupsClient) ListBySubscriptionIDSender(req *http.Request) (*http.Response, error) {
612 return client.Send(req, azure.DoRetryWithRegistration(client.Client))
613 }
614
615
616
617 func (client ActionGroupsClient) ListBySubscriptionIDResponder(resp *http.Response) (result ActionGroupList, err error) {
618 err = autorest.Respond(
619 resp,
620 azure.WithErrorUnlessStatusCode(http.StatusOK),
621 autorest.ByUnmarshallingJSON(&result),
622 autorest.ByClosing())
623 result.Response = autorest.Response{Response: resp}
624 return
625 }
626
627
628
629
630 func (client ActionGroupsClient) PostTestNotifications(ctx context.Context, notificationRequest NotificationRequestBody) (result ActionGroupsPostTestNotificationsFuture, err error) {
631 if tracing.IsEnabled() {
632 ctx = tracing.StartSpan(ctx, fqdn+"/ActionGroupsClient.PostTestNotifications")
633 defer func() {
634 sc := -1
635 if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
636 sc = result.FutureAPI.Response().StatusCode
637 }
638 tracing.EndSpan(ctx, sc, err)
639 }()
640 }
641 if err := validation.Validate([]validation.Validation{
642 {TargetValue: client.SubscriptionID,
643 Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}},
644 {TargetValue: notificationRequest,
645 Constraints: []validation.Constraint{{Target: "notificationRequest.AlertType", Name: validation.Null, Rule: true,
646 Chain: []validation.Constraint{{Target: "notificationRequest.AlertType", Name: validation.MaxLength, Rule: 30, Chain: nil}}}}}}); err != nil {
647 return result, validation.NewError("insights.ActionGroupsClient", "PostTestNotifications", err.Error())
648 }
649
650 req, err := client.PostTestNotificationsPreparer(ctx, notificationRequest)
651 if err != nil {
652 err = autorest.NewErrorWithError(err, "insights.ActionGroupsClient", "PostTestNotifications", nil, "Failure preparing request")
653 return
654 }
655
656 result, err = client.PostTestNotificationsSender(req)
657 if err != nil {
658 err = autorest.NewErrorWithError(err, "insights.ActionGroupsClient", "PostTestNotifications", result.Response(), "Failure sending request")
659 return
660 }
661
662 return
663 }
664
665
666 func (client ActionGroupsClient) PostTestNotificationsPreparer(ctx context.Context, notificationRequest NotificationRequestBody) (*http.Request, error) {
667 pathParameters := map[string]interface{}{
668 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
669 }
670
671 const APIVersion = "2021-09-01"
672 queryParameters := map[string]interface{}{
673 "api-version": APIVersion,
674 }
675
676 preparer := autorest.CreatePreparer(
677 autorest.AsContentType("application/json; charset=utf-8"),
678 autorest.AsPost(),
679 autorest.WithBaseURL(client.BaseURI),
680 autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Insights/createNotifications", pathParameters),
681 autorest.WithJSON(notificationRequest),
682 autorest.WithQueryParameters(queryParameters))
683 return preparer.Prepare((&http.Request{}).WithContext(ctx))
684 }
685
686
687
688 func (client ActionGroupsClient) PostTestNotificationsSender(req *http.Request) (future ActionGroupsPostTestNotificationsFuture, err error) {
689 var resp *http.Response
690 future.FutureAPI = &azure.Future{}
691 resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
692 if err != nil {
693 return
694 }
695 var azf azure.Future
696 azf, err = azure.NewFutureFromResponse(resp)
697 future.FutureAPI = &azf
698 future.Result = future.result
699 return
700 }
701
702
703
704 func (client ActionGroupsClient) PostTestNotificationsResponder(resp *http.Response) (result TestNotificationResponse, err error) {
705 err = autorest.Respond(
706 resp,
707 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
708 autorest.ByUnmarshallingJSON(&result),
709 autorest.ByClosing())
710 result.Response = autorest.Response{Response: resp}
711 return
712 }
713
714
715
716
717
718
719 func (client ActionGroupsClient) Update(ctx context.Context, resourceGroupName string, actionGroupName string, actionGroupPatch ActionGroupPatchBody) (result ActionGroupResource, err error) {
720 if tracing.IsEnabled() {
721 ctx = tracing.StartSpan(ctx, fqdn+"/ActionGroupsClient.Update")
722 defer func() {
723 sc := -1
724 if result.Response.Response != nil {
725 sc = result.Response.Response.StatusCode
726 }
727 tracing.EndSpan(ctx, sc, err)
728 }()
729 }
730 if err := validation.Validate([]validation.Validation{
731 {TargetValue: client.SubscriptionID,
732 Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}},
733 {TargetValue: resourceGroupName,
734 Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
735 {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil {
736 return result, validation.NewError("insights.ActionGroupsClient", "Update", err.Error())
737 }
738
739 req, err := client.UpdatePreparer(ctx, resourceGroupName, actionGroupName, actionGroupPatch)
740 if err != nil {
741 err = autorest.NewErrorWithError(err, "insights.ActionGroupsClient", "Update", nil, "Failure preparing request")
742 return
743 }
744
745 resp, err := client.UpdateSender(req)
746 if err != nil {
747 result.Response = autorest.Response{Response: resp}
748 err = autorest.NewErrorWithError(err, "insights.ActionGroupsClient", "Update", resp, "Failure sending request")
749 return
750 }
751
752 result, err = client.UpdateResponder(resp)
753 if err != nil {
754 err = autorest.NewErrorWithError(err, "insights.ActionGroupsClient", "Update", resp, "Failure responding to request")
755 return
756 }
757
758 return
759 }
760
761
762 func (client ActionGroupsClient) UpdatePreparer(ctx context.Context, resourceGroupName string, actionGroupName string, actionGroupPatch ActionGroupPatchBody) (*http.Request, error) {
763 pathParameters := map[string]interface{}{
764 "actionGroupName": autorest.Encode("path", actionGroupName),
765 "resourceGroupName": autorest.Encode("path", resourceGroupName),
766 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
767 }
768
769 const APIVersion = "2021-09-01"
770 queryParameters := map[string]interface{}{
771 "api-version": APIVersion,
772 }
773
774 preparer := autorest.CreatePreparer(
775 autorest.AsContentType("application/json; charset=utf-8"),
776 autorest.AsPatch(),
777 autorest.WithBaseURL(client.BaseURI),
778 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}", pathParameters),
779 autorest.WithJSON(actionGroupPatch),
780 autorest.WithQueryParameters(queryParameters))
781 return preparer.Prepare((&http.Request{}).WithContext(ctx))
782 }
783
784
785
786 func (client ActionGroupsClient) UpdateSender(req *http.Request) (*http.Response, error) {
787 return client.Send(req, azure.DoRetryWithRegistration(client.Client))
788 }
789
790
791
792 func (client ActionGroupsClient) UpdateResponder(resp *http.Response) (result ActionGroupResource, err error) {
793 err = autorest.Respond(
794 resp,
795 azure.WithErrorUnlessStatusCode(http.StatusOK),
796 autorest.ByUnmarshallingJSON(&result),
797 autorest.ByClosing())
798 result.Response = autorest.Response{Response: resp}
799 return
800 }
801
View as plain text