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