1 package activitylogs
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 AlertsClient struct {
20 BaseClient
21 }
22
23
24 func NewAlertsClient(subscriptionID string) AlertsClient {
25 return NewAlertsClientWithBaseURI(DefaultBaseURI, subscriptionID)
26 }
27
28
29
30 func NewAlertsClientWithBaseURI(baseURI string, subscriptionID string) AlertsClient {
31 return AlertsClient{NewWithBaseURI(baseURI, subscriptionID)}
32 }
33
34
35
36
37
38
39 func (client AlertsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, activityLogAlertName string, activityLogAlertRule AlertResource) (result AlertResource, err error) {
40 if tracing.IsEnabled() {
41 ctx = tracing.StartSpan(ctx, fqdn+"/AlertsClient.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: client.SubscriptionID,
52 Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}},
53 {TargetValue: resourceGroupName,
54 Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
55 {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}},
56 {TargetValue: activityLogAlertRule,
57 Constraints: []validation.Constraint{{Target: "activityLogAlertRule.AlertRuleProperties", Name: validation.Null, Rule: false,
58 Chain: []validation.Constraint{{Target: "activityLogAlertRule.AlertRuleProperties.Scopes", Name: validation.Null, Rule: true, Chain: nil},
59 {Target: "activityLogAlertRule.AlertRuleProperties.Condition", Name: validation.Null, Rule: true,
60 Chain: []validation.Constraint{{Target: "activityLogAlertRule.AlertRuleProperties.Condition.AllOf", Name: validation.Null, Rule: true, Chain: nil}}},
61 {Target: "activityLogAlertRule.AlertRuleProperties.Actions", Name: validation.Null, Rule: true, Chain: nil},
62 }}}}}); err != nil {
63 return result, validation.NewError("activitylogs.AlertsClient", "CreateOrUpdate", err.Error())
64 }
65
66 req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, activityLogAlertName, activityLogAlertRule)
67 if err != nil {
68 err = autorest.NewErrorWithError(err, "activitylogs.AlertsClient", "CreateOrUpdate", nil, "Failure preparing request")
69 return
70 }
71
72 resp, err := client.CreateOrUpdateSender(req)
73 if err != nil {
74 result.Response = autorest.Response{Response: resp}
75 err = autorest.NewErrorWithError(err, "activitylogs.AlertsClient", "CreateOrUpdate", resp, "Failure sending request")
76 return
77 }
78
79 result, err = client.CreateOrUpdateResponder(resp)
80 if err != nil {
81 err = autorest.NewErrorWithError(err, "activitylogs.AlertsClient", "CreateOrUpdate", resp, "Failure responding to request")
82 return
83 }
84
85 return
86 }
87
88
89 func (client AlertsClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, activityLogAlertName string, activityLogAlertRule AlertResource) (*http.Request, error) {
90 pathParameters := map[string]interface{}{
91 "activityLogAlertName": autorest.Encode("path", activityLogAlertName),
92 "resourceGroupName": autorest.Encode("path", resourceGroupName),
93 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
94 }
95
96 const APIVersion = "2020-10-01"
97 queryParameters := map[string]interface{}{
98 "api-version": APIVersion,
99 }
100
101 preparer := autorest.CreatePreparer(
102 autorest.AsContentType("application/json; charset=utf-8"),
103 autorest.AsPut(),
104 autorest.WithBaseURL(client.BaseURI),
105 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/activityLogAlerts/{activityLogAlertName}", pathParameters),
106 autorest.WithJSON(activityLogAlertRule),
107 autorest.WithQueryParameters(queryParameters))
108 return preparer.Prepare((&http.Request{}).WithContext(ctx))
109 }
110
111
112
113 func (client AlertsClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) {
114 return client.Send(req, azure.DoRetryWithRegistration(client.Client))
115 }
116
117
118
119 func (client AlertsClient) CreateOrUpdateResponder(resp *http.Response) (result AlertResource, err error) {
120 err = autorest.Respond(
121 resp,
122 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated),
123 autorest.ByUnmarshallingJSON(&result),
124 autorest.ByClosing())
125 result.Response = autorest.Response{Response: resp}
126 return
127 }
128
129
130
131
132
133 func (client AlertsClient) Delete(ctx context.Context, resourceGroupName string, activityLogAlertName string) (result autorest.Response, err error) {
134 if tracing.IsEnabled() {
135 ctx = tracing.StartSpan(ctx, fqdn+"/AlertsClient.Delete")
136 defer func() {
137 sc := -1
138 if result.Response != nil {
139 sc = result.Response.StatusCode
140 }
141 tracing.EndSpan(ctx, sc, err)
142 }()
143 }
144 if err := validation.Validate([]validation.Validation{
145 {TargetValue: client.SubscriptionID,
146 Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}},
147 {TargetValue: resourceGroupName,
148 Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
149 {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil {
150 return result, validation.NewError("activitylogs.AlertsClient", "Delete", err.Error())
151 }
152
153 req, err := client.DeletePreparer(ctx, resourceGroupName, activityLogAlertName)
154 if err != nil {
155 err = autorest.NewErrorWithError(err, "activitylogs.AlertsClient", "Delete", nil, "Failure preparing request")
156 return
157 }
158
159 resp, err := client.DeleteSender(req)
160 if err != nil {
161 result.Response = resp
162 err = autorest.NewErrorWithError(err, "activitylogs.AlertsClient", "Delete", resp, "Failure sending request")
163 return
164 }
165
166 result, err = client.DeleteResponder(resp)
167 if err != nil {
168 err = autorest.NewErrorWithError(err, "activitylogs.AlertsClient", "Delete", resp, "Failure responding to request")
169 return
170 }
171
172 return
173 }
174
175
176 func (client AlertsClient) DeletePreparer(ctx context.Context, resourceGroupName string, activityLogAlertName string) (*http.Request, error) {
177 pathParameters := map[string]interface{}{
178 "activityLogAlertName": autorest.Encode("path", activityLogAlertName),
179 "resourceGroupName": autorest.Encode("path", resourceGroupName),
180 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
181 }
182
183 const APIVersion = "2020-10-01"
184 queryParameters := map[string]interface{}{
185 "api-version": APIVersion,
186 }
187
188 preparer := autorest.CreatePreparer(
189 autorest.AsDelete(),
190 autorest.WithBaseURL(client.BaseURI),
191 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/activityLogAlerts/{activityLogAlertName}", pathParameters),
192 autorest.WithQueryParameters(queryParameters))
193 return preparer.Prepare((&http.Request{}).WithContext(ctx))
194 }
195
196
197
198 func (client AlertsClient) DeleteSender(req *http.Request) (*http.Response, error) {
199 return client.Send(req, azure.DoRetryWithRegistration(client.Client))
200 }
201
202
203
204 func (client AlertsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) {
205 err = autorest.Respond(
206 resp,
207 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent),
208 autorest.ByClosing())
209 result.Response = resp
210 return
211 }
212
213
214
215
216
217 func (client AlertsClient) Get(ctx context.Context, resourceGroupName string, activityLogAlertName string) (result AlertResource, err error) {
218 if tracing.IsEnabled() {
219 ctx = tracing.StartSpan(ctx, fqdn+"/AlertsClient.Get")
220 defer func() {
221 sc := -1
222 if result.Response.Response != nil {
223 sc = result.Response.Response.StatusCode
224 }
225 tracing.EndSpan(ctx, sc, err)
226 }()
227 }
228 if err := validation.Validate([]validation.Validation{
229 {TargetValue: client.SubscriptionID,
230 Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}},
231 {TargetValue: resourceGroupName,
232 Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
233 {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil {
234 return result, validation.NewError("activitylogs.AlertsClient", "Get", err.Error())
235 }
236
237 req, err := client.GetPreparer(ctx, resourceGroupName, activityLogAlertName)
238 if err != nil {
239 err = autorest.NewErrorWithError(err, "activitylogs.AlertsClient", "Get", nil, "Failure preparing request")
240 return
241 }
242
243 resp, err := client.GetSender(req)
244 if err != nil {
245 result.Response = autorest.Response{Response: resp}
246 err = autorest.NewErrorWithError(err, "activitylogs.AlertsClient", "Get", resp, "Failure sending request")
247 return
248 }
249
250 result, err = client.GetResponder(resp)
251 if err != nil {
252 err = autorest.NewErrorWithError(err, "activitylogs.AlertsClient", "Get", resp, "Failure responding to request")
253 return
254 }
255
256 return
257 }
258
259
260 func (client AlertsClient) GetPreparer(ctx context.Context, resourceGroupName string, activityLogAlertName string) (*http.Request, error) {
261 pathParameters := map[string]interface{}{
262 "activityLogAlertName": autorest.Encode("path", activityLogAlertName),
263 "resourceGroupName": autorest.Encode("path", resourceGroupName),
264 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
265 }
266
267 const APIVersion = "2020-10-01"
268 queryParameters := map[string]interface{}{
269 "api-version": APIVersion,
270 }
271
272 preparer := autorest.CreatePreparer(
273 autorest.AsGet(),
274 autorest.WithBaseURL(client.BaseURI),
275 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/activityLogAlerts/{activityLogAlertName}", pathParameters),
276 autorest.WithQueryParameters(queryParameters))
277 return preparer.Prepare((&http.Request{}).WithContext(ctx))
278 }
279
280
281
282 func (client AlertsClient) GetSender(req *http.Request) (*http.Response, error) {
283 return client.Send(req, azure.DoRetryWithRegistration(client.Client))
284 }
285
286
287
288 func (client AlertsClient) GetResponder(resp *http.Response) (result AlertResource, err error) {
289 err = autorest.Respond(
290 resp,
291 azure.WithErrorUnlessStatusCode(http.StatusOK),
292 autorest.ByUnmarshallingJSON(&result),
293 autorest.ByClosing())
294 result.Response = autorest.Response{Response: resp}
295 return
296 }
297
298
299
300
301 func (client AlertsClient) ListByResourceGroup(ctx context.Context, resourceGroupName string) (result AlertRuleListPage, err error) {
302 if tracing.IsEnabled() {
303 ctx = tracing.StartSpan(ctx, fqdn+"/AlertsClient.ListByResourceGroup")
304 defer func() {
305 sc := -1
306 if result.arl.Response.Response != nil {
307 sc = result.arl.Response.Response.StatusCode
308 }
309 tracing.EndSpan(ctx, sc, err)
310 }()
311 }
312 if err := validation.Validate([]validation.Validation{
313 {TargetValue: client.SubscriptionID,
314 Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}},
315 {TargetValue: resourceGroupName,
316 Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
317 {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil {
318 return result, validation.NewError("activitylogs.AlertsClient", "ListByResourceGroup", err.Error())
319 }
320
321 result.fn = client.listByResourceGroupNextResults
322 req, err := client.ListByResourceGroupPreparer(ctx, resourceGroupName)
323 if err != nil {
324 err = autorest.NewErrorWithError(err, "activitylogs.AlertsClient", "ListByResourceGroup", nil, "Failure preparing request")
325 return
326 }
327
328 resp, err := client.ListByResourceGroupSender(req)
329 if err != nil {
330 result.arl.Response = autorest.Response{Response: resp}
331 err = autorest.NewErrorWithError(err, "activitylogs.AlertsClient", "ListByResourceGroup", resp, "Failure sending request")
332 return
333 }
334
335 result.arl, err = client.ListByResourceGroupResponder(resp)
336 if err != nil {
337 err = autorest.NewErrorWithError(err, "activitylogs.AlertsClient", "ListByResourceGroup", resp, "Failure responding to request")
338 return
339 }
340 if result.arl.hasNextLink() && result.arl.IsEmpty() {
341 err = result.NextWithContext(ctx)
342 return
343 }
344
345 return
346 }
347
348
349 func (client AlertsClient) ListByResourceGroupPreparer(ctx context.Context, resourceGroupName string) (*http.Request, error) {
350 pathParameters := map[string]interface{}{
351 "resourceGroupName": autorest.Encode("path", resourceGroupName),
352 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
353 }
354
355 const APIVersion = "2020-10-01"
356 queryParameters := map[string]interface{}{
357 "api-version": APIVersion,
358 }
359
360 preparer := autorest.CreatePreparer(
361 autorest.AsGet(),
362 autorest.WithBaseURL(client.BaseURI),
363 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/activityLogAlerts", pathParameters),
364 autorest.WithQueryParameters(queryParameters))
365 return preparer.Prepare((&http.Request{}).WithContext(ctx))
366 }
367
368
369
370 func (client AlertsClient) ListByResourceGroupSender(req *http.Request) (*http.Response, error) {
371 return client.Send(req, azure.DoRetryWithRegistration(client.Client))
372 }
373
374
375
376 func (client AlertsClient) ListByResourceGroupResponder(resp *http.Response) (result AlertRuleList, err error) {
377 err = autorest.Respond(
378 resp,
379 azure.WithErrorUnlessStatusCode(http.StatusOK),
380 autorest.ByUnmarshallingJSON(&result),
381 autorest.ByClosing())
382 result.Response = autorest.Response{Response: resp}
383 return
384 }
385
386
387 func (client AlertsClient) listByResourceGroupNextResults(ctx context.Context, lastResults AlertRuleList) (result AlertRuleList, err error) {
388 req, err := lastResults.alertRuleListPreparer(ctx)
389 if err != nil {
390 return result, autorest.NewErrorWithError(err, "activitylogs.AlertsClient", "listByResourceGroupNextResults", nil, "Failure preparing next results request")
391 }
392 if req == nil {
393 return
394 }
395 resp, err := client.ListByResourceGroupSender(req)
396 if err != nil {
397 result.Response = autorest.Response{Response: resp}
398 return result, autorest.NewErrorWithError(err, "activitylogs.AlertsClient", "listByResourceGroupNextResults", resp, "Failure sending next results request")
399 }
400 result, err = client.ListByResourceGroupResponder(resp)
401 if err != nil {
402 err = autorest.NewErrorWithError(err, "activitylogs.AlertsClient", "listByResourceGroupNextResults", resp, "Failure responding to next results request")
403 }
404 return
405 }
406
407
408 func (client AlertsClient) ListByResourceGroupComplete(ctx context.Context, resourceGroupName string) (result AlertRuleListIterator, err error) {
409 if tracing.IsEnabled() {
410 ctx = tracing.StartSpan(ctx, fqdn+"/AlertsClient.ListByResourceGroup")
411 defer func() {
412 sc := -1
413 if result.Response().Response.Response != nil {
414 sc = result.page.Response().Response.Response.StatusCode
415 }
416 tracing.EndSpan(ctx, sc, err)
417 }()
418 }
419 result.page, err = client.ListByResourceGroup(ctx, resourceGroupName)
420 return
421 }
422
423
424 func (client AlertsClient) ListBySubscriptionID(ctx context.Context) (result AlertRuleListPage, err error) {
425 if tracing.IsEnabled() {
426 ctx = tracing.StartSpan(ctx, fqdn+"/AlertsClient.ListBySubscriptionID")
427 defer func() {
428 sc := -1
429 if result.arl.Response.Response != nil {
430 sc = result.arl.Response.Response.StatusCode
431 }
432 tracing.EndSpan(ctx, sc, err)
433 }()
434 }
435 if err := validation.Validate([]validation.Validation{
436 {TargetValue: client.SubscriptionID,
437 Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil {
438 return result, validation.NewError("activitylogs.AlertsClient", "ListBySubscriptionID", err.Error())
439 }
440
441 result.fn = client.listBySubscriptionIDNextResults
442 req, err := client.ListBySubscriptionIDPreparer(ctx)
443 if err != nil {
444 err = autorest.NewErrorWithError(err, "activitylogs.AlertsClient", "ListBySubscriptionID", nil, "Failure preparing request")
445 return
446 }
447
448 resp, err := client.ListBySubscriptionIDSender(req)
449 if err != nil {
450 result.arl.Response = autorest.Response{Response: resp}
451 err = autorest.NewErrorWithError(err, "activitylogs.AlertsClient", "ListBySubscriptionID", resp, "Failure sending request")
452 return
453 }
454
455 result.arl, err = client.ListBySubscriptionIDResponder(resp)
456 if err != nil {
457 err = autorest.NewErrorWithError(err, "activitylogs.AlertsClient", "ListBySubscriptionID", resp, "Failure responding to request")
458 return
459 }
460 if result.arl.hasNextLink() && result.arl.IsEmpty() {
461 err = result.NextWithContext(ctx)
462 return
463 }
464
465 return
466 }
467
468
469 func (client AlertsClient) ListBySubscriptionIDPreparer(ctx context.Context) (*http.Request, error) {
470 pathParameters := map[string]interface{}{
471 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
472 }
473
474 const APIVersion = "2020-10-01"
475 queryParameters := map[string]interface{}{
476 "api-version": APIVersion,
477 }
478
479 preparer := autorest.CreatePreparer(
480 autorest.AsGet(),
481 autorest.WithBaseURL(client.BaseURI),
482 autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Insights/activityLogAlerts", pathParameters),
483 autorest.WithQueryParameters(queryParameters))
484 return preparer.Prepare((&http.Request{}).WithContext(ctx))
485 }
486
487
488
489 func (client AlertsClient) ListBySubscriptionIDSender(req *http.Request) (*http.Response, error) {
490 return client.Send(req, azure.DoRetryWithRegistration(client.Client))
491 }
492
493
494
495 func (client AlertsClient) ListBySubscriptionIDResponder(resp *http.Response) (result AlertRuleList, err error) {
496 err = autorest.Respond(
497 resp,
498 azure.WithErrorUnlessStatusCode(http.StatusOK),
499 autorest.ByUnmarshallingJSON(&result),
500 autorest.ByClosing())
501 result.Response = autorest.Response{Response: resp}
502 return
503 }
504
505
506 func (client AlertsClient) listBySubscriptionIDNextResults(ctx context.Context, lastResults AlertRuleList) (result AlertRuleList, err error) {
507 req, err := lastResults.alertRuleListPreparer(ctx)
508 if err != nil {
509 return result, autorest.NewErrorWithError(err, "activitylogs.AlertsClient", "listBySubscriptionIDNextResults", nil, "Failure preparing next results request")
510 }
511 if req == nil {
512 return
513 }
514 resp, err := client.ListBySubscriptionIDSender(req)
515 if err != nil {
516 result.Response = autorest.Response{Response: resp}
517 return result, autorest.NewErrorWithError(err, "activitylogs.AlertsClient", "listBySubscriptionIDNextResults", resp, "Failure sending next results request")
518 }
519 result, err = client.ListBySubscriptionIDResponder(resp)
520 if err != nil {
521 err = autorest.NewErrorWithError(err, "activitylogs.AlertsClient", "listBySubscriptionIDNextResults", resp, "Failure responding to next results request")
522 }
523 return
524 }
525
526
527 func (client AlertsClient) ListBySubscriptionIDComplete(ctx context.Context) (result AlertRuleListIterator, err error) {
528 if tracing.IsEnabled() {
529 ctx = tracing.StartSpan(ctx, fqdn+"/AlertsClient.ListBySubscriptionID")
530 defer func() {
531 sc := -1
532 if result.Response().Response.Response != nil {
533 sc = result.page.Response().Response.Response.StatusCode
534 }
535 tracing.EndSpan(ctx, sc, err)
536 }()
537 }
538 result.page, err = client.ListBySubscriptionID(ctx)
539 return
540 }
541
542
543
544
545
546
547
548 func (client AlertsClient) Update(ctx context.Context, resourceGroupName string, activityLogAlertName string, activityLogAlertRulePatch AlertRulePatchObject) (result AlertResource, err error) {
549 if tracing.IsEnabled() {
550 ctx = tracing.StartSpan(ctx, fqdn+"/AlertsClient.Update")
551 defer func() {
552 sc := -1
553 if result.Response.Response != nil {
554 sc = result.Response.Response.StatusCode
555 }
556 tracing.EndSpan(ctx, sc, err)
557 }()
558 }
559 if err := validation.Validate([]validation.Validation{
560 {TargetValue: client.SubscriptionID,
561 Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}},
562 {TargetValue: resourceGroupName,
563 Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
564 {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil {
565 return result, validation.NewError("activitylogs.AlertsClient", "Update", err.Error())
566 }
567
568 req, err := client.UpdatePreparer(ctx, resourceGroupName, activityLogAlertName, activityLogAlertRulePatch)
569 if err != nil {
570 err = autorest.NewErrorWithError(err, "activitylogs.AlertsClient", "Update", nil, "Failure preparing request")
571 return
572 }
573
574 resp, err := client.UpdateSender(req)
575 if err != nil {
576 result.Response = autorest.Response{Response: resp}
577 err = autorest.NewErrorWithError(err, "activitylogs.AlertsClient", "Update", resp, "Failure sending request")
578 return
579 }
580
581 result, err = client.UpdateResponder(resp)
582 if err != nil {
583 err = autorest.NewErrorWithError(err, "activitylogs.AlertsClient", "Update", resp, "Failure responding to request")
584 return
585 }
586
587 return
588 }
589
590
591 func (client AlertsClient) UpdatePreparer(ctx context.Context, resourceGroupName string, activityLogAlertName string, activityLogAlertRulePatch AlertRulePatchObject) (*http.Request, error) {
592 pathParameters := map[string]interface{}{
593 "activityLogAlertName": autorest.Encode("path", activityLogAlertName),
594 "resourceGroupName": autorest.Encode("path", resourceGroupName),
595 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
596 }
597
598 const APIVersion = "2020-10-01"
599 queryParameters := map[string]interface{}{
600 "api-version": APIVersion,
601 }
602
603 preparer := autorest.CreatePreparer(
604 autorest.AsContentType("application/json; charset=utf-8"),
605 autorest.AsPatch(),
606 autorest.WithBaseURL(client.BaseURI),
607 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/activityLogAlerts/{activityLogAlertName}", pathParameters),
608 autorest.WithJSON(activityLogAlertRulePatch),
609 autorest.WithQueryParameters(queryParameters))
610 return preparer.Prepare((&http.Request{}).WithContext(ctx))
611 }
612
613
614
615 func (client AlertsClient) UpdateSender(req *http.Request) (*http.Response, error) {
616 return client.Send(req, azure.DoRetryWithRegistration(client.Client))
617 }
618
619
620
621 func (client AlertsClient) UpdateResponder(resp *http.Response) (result AlertResource, err error) {
622 err = autorest.Respond(
623 resp,
624 azure.WithErrorUnlessStatusCode(http.StatusOK),
625 autorest.ByUnmarshallingJSON(&result),
626 autorest.ByClosing())
627 result.Response = autorest.Response{Response: resp}
628 return
629 }
630
View as plain text