1 package activitylogs
2
3
4
5
6
7
8
9 import (
10 "context"
11 "encoding/json"
12 "github.com/Azure/go-autorest/autorest"
13 "github.com/Azure/go-autorest/autorest/date"
14 "github.com/Azure/go-autorest/autorest/to"
15 "github.com/Azure/go-autorest/tracing"
16 "net/http"
17 )
18
19
20 const fqdn = "github.com/Azure/azure-sdk-for-go/services/monitor/mgmt/2020-10-01/activitylogs"
21
22
23 type ActionGroupForActivityLogAlerts struct {
24
25 ActionGroupID *string `json:"actionGroupId,omitempty"`
26
27 WebhookProperties map[string]*string `json:"webhookProperties"`
28 }
29
30
31 func (agfala ActionGroupForActivityLogAlerts) MarshalJSON() ([]byte, error) {
32 objectMap := make(map[string]interface{})
33 if agfala.ActionGroupID != nil {
34 objectMap["actionGroupId"] = agfala.ActionGroupID
35 }
36 if agfala.WebhookProperties != nil {
37 objectMap["webhookProperties"] = agfala.WebhookProperties
38 }
39 return json.Marshal(objectMap)
40 }
41
42
43 type ActionList struct {
44
45 ActionGroups *[]ActionGroupForActivityLogAlerts `json:"actionGroups,omitempty"`
46 }
47
48
49 type AlertResource struct {
50 autorest.Response `json:"-"`
51
52 *AlertRuleProperties `json:"properties,omitempty"`
53
54 ID *string `json:"id,omitempty"`
55
56 Name *string `json:"name,omitempty"`
57
58 Type *string `json:"type,omitempty"`
59
60 Location *string `json:"location,omitempty"`
61
62 Tags map[string]*string `json:"tags"`
63 }
64
65
66 func (ar AlertResource) MarshalJSON() ([]byte, error) {
67 objectMap := make(map[string]interface{})
68 if ar.AlertRuleProperties != nil {
69 objectMap["properties"] = ar.AlertRuleProperties
70 }
71 if ar.Location != nil {
72 objectMap["location"] = ar.Location
73 }
74 if ar.Tags != nil {
75 objectMap["tags"] = ar.Tags
76 }
77 return json.Marshal(objectMap)
78 }
79
80
81 func (ar *AlertResource) UnmarshalJSON(body []byte) error {
82 var m map[string]*json.RawMessage
83 err := json.Unmarshal(body, &m)
84 if err != nil {
85 return err
86 }
87 for k, v := range m {
88 switch k {
89 case "properties":
90 if v != nil {
91 var alertRuleProperties AlertRuleProperties
92 err = json.Unmarshal(*v, &alertRuleProperties)
93 if err != nil {
94 return err
95 }
96 ar.AlertRuleProperties = &alertRuleProperties
97 }
98 case "id":
99 if v != nil {
100 var ID string
101 err = json.Unmarshal(*v, &ID)
102 if err != nil {
103 return err
104 }
105 ar.ID = &ID
106 }
107 case "name":
108 if v != nil {
109 var name string
110 err = json.Unmarshal(*v, &name)
111 if err != nil {
112 return err
113 }
114 ar.Name = &name
115 }
116 case "type":
117 if v != nil {
118 var typeVar string
119 err = json.Unmarshal(*v, &typeVar)
120 if err != nil {
121 return err
122 }
123 ar.Type = &typeVar
124 }
125 case "location":
126 if v != nil {
127 var location string
128 err = json.Unmarshal(*v, &location)
129 if err != nil {
130 return err
131 }
132 ar.Location = &location
133 }
134 case "tags":
135 if v != nil {
136 var tags map[string]*string
137 err = json.Unmarshal(*v, &tags)
138 if err != nil {
139 return err
140 }
141 ar.Tags = tags
142 }
143 }
144 }
145
146 return nil
147 }
148
149
150
151 type AlertRuleAllOfCondition struct {
152
153 AllOf *[]AlertRuleAnyOfOrLeafCondition `json:"allOf,omitempty"`
154 }
155
156
157
158
159
160
161
162
163
164
165 type AlertRuleAnyOfOrLeafCondition struct {
166
167 AnyOf *[]AlertRuleLeafCondition `json:"anyOf,omitempty"`
168
169
170 Field *string `json:"field,omitempty"`
171
172 Equals *string `json:"equals,omitempty"`
173
174 ContainsAny *[]string `json:"containsAny,omitempty"`
175 }
176
177
178
179
180 type AlertRuleLeafCondition struct {
181
182
183 Field *string `json:"field,omitempty"`
184
185 Equals *string `json:"equals,omitempty"`
186
187 ContainsAny *[]string `json:"containsAny,omitempty"`
188 }
189
190
191 type AlertRuleList struct {
192 autorest.Response `json:"-"`
193
194 Value *[]AlertResource `json:"value,omitempty"`
195
196 NextLink *string `json:"nextLink,omitempty"`
197 }
198
199
200 type AlertRuleListIterator struct {
201 i int
202 page AlertRuleListPage
203 }
204
205
206
207 func (iter *AlertRuleListIterator) NextWithContext(ctx context.Context) (err error) {
208 if tracing.IsEnabled() {
209 ctx = tracing.StartSpan(ctx, fqdn+"/AlertRuleListIterator.NextWithContext")
210 defer func() {
211 sc := -1
212 if iter.Response().Response.Response != nil {
213 sc = iter.Response().Response.Response.StatusCode
214 }
215 tracing.EndSpan(ctx, sc, err)
216 }()
217 }
218 iter.i++
219 if iter.i < len(iter.page.Values()) {
220 return nil
221 }
222 err = iter.page.NextWithContext(ctx)
223 if err != nil {
224 iter.i--
225 return err
226 }
227 iter.i = 0
228 return nil
229 }
230
231
232
233
234 func (iter *AlertRuleListIterator) Next() error {
235 return iter.NextWithContext(context.Background())
236 }
237
238
239 func (iter AlertRuleListIterator) NotDone() bool {
240 return iter.page.NotDone() && iter.i < len(iter.page.Values())
241 }
242
243
244 func (iter AlertRuleListIterator) Response() AlertRuleList {
245 return iter.page.Response()
246 }
247
248
249
250 func (iter AlertRuleListIterator) Value() AlertResource {
251 if !iter.page.NotDone() {
252 return AlertResource{}
253 }
254 return iter.page.Values()[iter.i]
255 }
256
257
258 func NewAlertRuleListIterator(page AlertRuleListPage) AlertRuleListIterator {
259 return AlertRuleListIterator{page: page}
260 }
261
262
263 func (arl AlertRuleList) IsEmpty() bool {
264 return arl.Value == nil || len(*arl.Value) == 0
265 }
266
267
268 func (arl AlertRuleList) hasNextLink() bool {
269 return arl.NextLink != nil && len(*arl.NextLink) != 0
270 }
271
272
273
274 func (arl AlertRuleList) alertRuleListPreparer(ctx context.Context) (*http.Request, error) {
275 if !arl.hasNextLink() {
276 return nil, nil
277 }
278 return autorest.Prepare((&http.Request{}).WithContext(ctx),
279 autorest.AsJSON(),
280 autorest.AsGet(),
281 autorest.WithBaseURL(to.String(arl.NextLink)))
282 }
283
284
285 type AlertRuleListPage struct {
286 fn func(context.Context, AlertRuleList) (AlertRuleList, error)
287 arl AlertRuleList
288 }
289
290
291
292 func (page *AlertRuleListPage) NextWithContext(ctx context.Context) (err error) {
293 if tracing.IsEnabled() {
294 ctx = tracing.StartSpan(ctx, fqdn+"/AlertRuleListPage.NextWithContext")
295 defer func() {
296 sc := -1
297 if page.Response().Response.Response != nil {
298 sc = page.Response().Response.Response.StatusCode
299 }
300 tracing.EndSpan(ctx, sc, err)
301 }()
302 }
303 for {
304 next, err := page.fn(ctx, page.arl)
305 if err != nil {
306 return err
307 }
308 page.arl = next
309 if !next.hasNextLink() || !next.IsEmpty() {
310 break
311 }
312 }
313 return nil
314 }
315
316
317
318
319 func (page *AlertRuleListPage) Next() error {
320 return page.NextWithContext(context.Background())
321 }
322
323
324 func (page AlertRuleListPage) NotDone() bool {
325 return !page.arl.IsEmpty()
326 }
327
328
329 func (page AlertRuleListPage) Response() AlertRuleList {
330 return page.arl
331 }
332
333
334 func (page AlertRuleListPage) Values() []AlertResource {
335 if page.arl.IsEmpty() {
336 return nil
337 }
338 return *page.arl.Value
339 }
340
341
342 func NewAlertRuleListPage(cur AlertRuleList, getNextPage func(context.Context, AlertRuleList) (AlertRuleList, error)) AlertRuleListPage {
343 return AlertRuleListPage{
344 fn: getNextPage,
345 arl: cur,
346 }
347 }
348
349
350 type AlertRulePatchObject struct {
351
352 Tags map[string]*string `json:"tags"`
353
354 *AlertRulePatchProperties `json:"properties,omitempty"`
355 }
356
357
358 func (arpo AlertRulePatchObject) MarshalJSON() ([]byte, error) {
359 objectMap := make(map[string]interface{})
360 if arpo.Tags != nil {
361 objectMap["tags"] = arpo.Tags
362 }
363 if arpo.AlertRulePatchProperties != nil {
364 objectMap["properties"] = arpo.AlertRulePatchProperties
365 }
366 return json.Marshal(objectMap)
367 }
368
369
370 func (arpo *AlertRulePatchObject) UnmarshalJSON(body []byte) error {
371 var m map[string]*json.RawMessage
372 err := json.Unmarshal(body, &m)
373 if err != nil {
374 return err
375 }
376 for k, v := range m {
377 switch k {
378 case "tags":
379 if v != nil {
380 var tags map[string]*string
381 err = json.Unmarshal(*v, &tags)
382 if err != nil {
383 return err
384 }
385 arpo.Tags = tags
386 }
387 case "properties":
388 if v != nil {
389 var alertRulePatchProperties AlertRulePatchProperties
390 err = json.Unmarshal(*v, &alertRulePatchProperties)
391 if err != nil {
392 return err
393 }
394 arpo.AlertRulePatchProperties = &alertRulePatchProperties
395 }
396 }
397 }
398
399 return nil
400 }
401
402
403 type AlertRulePatchProperties struct {
404
405 Enabled *bool `json:"enabled,omitempty"`
406 }
407
408
409 type AlertRuleProperties struct {
410
411 Scopes *[]string `json:"scopes,omitempty"`
412
413 Condition *AlertRuleAllOfCondition `json:"condition,omitempty"`
414
415 Actions *ActionList `json:"actions,omitempty"`
416
417 Enabled *bool `json:"enabled,omitempty"`
418
419 Description *string `json:"description,omitempty"`
420 }
421
422
423 type AzureResource struct {
424
425 ID *string `json:"id,omitempty"`
426
427 Name *string `json:"name,omitempty"`
428
429 Type *string `json:"type,omitempty"`
430
431 Location *string `json:"location,omitempty"`
432
433 Tags map[string]*string `json:"tags"`
434 }
435
436
437 func (ar AzureResource) MarshalJSON() ([]byte, error) {
438 objectMap := make(map[string]interface{})
439 if ar.Location != nil {
440 objectMap["location"] = ar.Location
441 }
442 if ar.Tags != nil {
443 objectMap["tags"] = ar.Tags
444 }
445 return json.Marshal(objectMap)
446 }
447
448
449 type ErrorResponse struct {
450
451 Code *string `json:"code,omitempty"`
452
453 Message *string `json:"message,omitempty"`
454 }
455
456
457 type EventData struct {
458
459 Authorization *SenderAuthorization `json:"authorization,omitempty"`
460
461 Claims map[string]*string `json:"claims"`
462
463 Caller *string `json:"caller,omitempty"`
464
465 Description *string `json:"description,omitempty"`
466
467 ID *string `json:"id,omitempty"`
468
469 EventDataID *string `json:"eventDataId,omitempty"`
470
471 CorrelationID *string `json:"correlationId,omitempty"`
472
473 EventName *LocalizableString `json:"eventName,omitempty"`
474
475 Category *LocalizableString `json:"category,omitempty"`
476
477 HTTPRequest *HTTPRequestInfo `json:"httpRequest,omitempty"`
478
479 Level EventLevel `json:"level,omitempty"`
480
481 ResourceGroupName *string `json:"resourceGroupName,omitempty"`
482
483 ResourceProviderName *LocalizableString `json:"resourceProviderName,omitempty"`
484
485 ResourceID *string `json:"resourceId,omitempty"`
486
487 ResourceType *LocalizableString `json:"resourceType,omitempty"`
488
489 OperationID *string `json:"operationId,omitempty"`
490
491 OperationName *LocalizableString `json:"operationName,omitempty"`
492
493 Properties map[string]*string `json:"properties"`
494
495 Status *LocalizableString `json:"status,omitempty"`
496
497 SubStatus *LocalizableString `json:"subStatus,omitempty"`
498
499 EventTimestamp *date.Time `json:"eventTimestamp,omitempty"`
500
501 SubmissionTimestamp *date.Time `json:"submissionTimestamp,omitempty"`
502
503 SubscriptionID *string `json:"subscriptionId,omitempty"`
504
505 TenantID *string `json:"tenantId,omitempty"`
506 }
507
508
509 func (ed EventData) MarshalJSON() ([]byte, error) {
510 objectMap := make(map[string]interface{})
511 return json.Marshal(objectMap)
512 }
513
514
515 type EventDataCollection struct {
516 autorest.Response `json:"-"`
517
518 Value *[]EventData `json:"value,omitempty"`
519
520 NextLink *string `json:"nextLink,omitempty"`
521 }
522
523
524 type EventDataCollectionIterator struct {
525 i int
526 page EventDataCollectionPage
527 }
528
529
530
531 func (iter *EventDataCollectionIterator) NextWithContext(ctx context.Context) (err error) {
532 if tracing.IsEnabled() {
533 ctx = tracing.StartSpan(ctx, fqdn+"/EventDataCollectionIterator.NextWithContext")
534 defer func() {
535 sc := -1
536 if iter.Response().Response.Response != nil {
537 sc = iter.Response().Response.Response.StatusCode
538 }
539 tracing.EndSpan(ctx, sc, err)
540 }()
541 }
542 iter.i++
543 if iter.i < len(iter.page.Values()) {
544 return nil
545 }
546 err = iter.page.NextWithContext(ctx)
547 if err != nil {
548 iter.i--
549 return err
550 }
551 iter.i = 0
552 return nil
553 }
554
555
556
557
558 func (iter *EventDataCollectionIterator) Next() error {
559 return iter.NextWithContext(context.Background())
560 }
561
562
563 func (iter EventDataCollectionIterator) NotDone() bool {
564 return iter.page.NotDone() && iter.i < len(iter.page.Values())
565 }
566
567
568 func (iter EventDataCollectionIterator) Response() EventDataCollection {
569 return iter.page.Response()
570 }
571
572
573
574 func (iter EventDataCollectionIterator) Value() EventData {
575 if !iter.page.NotDone() {
576 return EventData{}
577 }
578 return iter.page.Values()[iter.i]
579 }
580
581
582 func NewEventDataCollectionIterator(page EventDataCollectionPage) EventDataCollectionIterator {
583 return EventDataCollectionIterator{page: page}
584 }
585
586
587 func (edc EventDataCollection) IsEmpty() bool {
588 return edc.Value == nil || len(*edc.Value) == 0
589 }
590
591
592 func (edc EventDataCollection) hasNextLink() bool {
593 return edc.NextLink != nil && len(*edc.NextLink) != 0
594 }
595
596
597
598 func (edc EventDataCollection) eventDataCollectionPreparer(ctx context.Context) (*http.Request, error) {
599 if !edc.hasNextLink() {
600 return nil, nil
601 }
602 return autorest.Prepare((&http.Request{}).WithContext(ctx),
603 autorest.AsJSON(),
604 autorest.AsGet(),
605 autorest.WithBaseURL(to.String(edc.NextLink)))
606 }
607
608
609 type EventDataCollectionPage struct {
610 fn func(context.Context, EventDataCollection) (EventDataCollection, error)
611 edc EventDataCollection
612 }
613
614
615
616 func (page *EventDataCollectionPage) NextWithContext(ctx context.Context) (err error) {
617 if tracing.IsEnabled() {
618 ctx = tracing.StartSpan(ctx, fqdn+"/EventDataCollectionPage.NextWithContext")
619 defer func() {
620 sc := -1
621 if page.Response().Response.Response != nil {
622 sc = page.Response().Response.Response.StatusCode
623 }
624 tracing.EndSpan(ctx, sc, err)
625 }()
626 }
627 for {
628 next, err := page.fn(ctx, page.edc)
629 if err != nil {
630 return err
631 }
632 page.edc = next
633 if !next.hasNextLink() || !next.IsEmpty() {
634 break
635 }
636 }
637 return nil
638 }
639
640
641
642
643 func (page *EventDataCollectionPage) Next() error {
644 return page.NextWithContext(context.Background())
645 }
646
647
648 func (page EventDataCollectionPage) NotDone() bool {
649 return !page.edc.IsEmpty()
650 }
651
652
653 func (page EventDataCollectionPage) Response() EventDataCollection {
654 return page.edc
655 }
656
657
658 func (page EventDataCollectionPage) Values() []EventData {
659 if page.edc.IsEmpty() {
660 return nil
661 }
662 return *page.edc.Value
663 }
664
665
666 func NewEventDataCollectionPage(cur EventDataCollection, getNextPage func(context.Context, EventDataCollection) (EventDataCollection, error)) EventDataCollectionPage {
667 return EventDataCollectionPage{
668 fn: getNextPage,
669 edc: cur,
670 }
671 }
672
673
674 type HTTPRequestInfo struct {
675
676 ClientRequestID *string `json:"clientRequestId,omitempty"`
677
678 ClientIPAddress *string `json:"clientIpAddress,omitempty"`
679
680 Method *string `json:"method,omitempty"`
681
682 URI *string `json:"uri,omitempty"`
683 }
684
685
686 type LocalizableString struct {
687
688 Value *string `json:"value,omitempty"`
689
690 LocalizedValue *string `json:"localizedValue,omitempty"`
691 }
692
693
694
695
696 type SenderAuthorization struct {
697
698 Action *string `json:"action,omitempty"`
699
700 Role *string `json:"role,omitempty"`
701
702 Scope *string `json:"scope,omitempty"`
703 }
704
View as plain text