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