/
models.go
1678 lines (1539 loc) · 56.5 KB
/
models.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
package monitorlegacy
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
//
// Code generated by Microsoft (R) AutoRest Code Generator.
// Changes may cause incorrect behavior and will be lost if the code is regenerated.
import (
"encoding/json"
"github.com/Azure/go-autorest/autorest"
"github.com/Azure/go-autorest/autorest/date"
)
// The package's fully qualified name.
const fqdn = "github.com/Azure/azure-sdk-for-go/services/preview/monitor/mgmt/2016-03-01-preview/monitorlegacy"
// AlertRule an alert rule.
type AlertRule struct {
// Name - the name of the alert rule.
Name *string `json:"name,omitempty"`
// Description - the description of the alert rule that will be included in the alert email.
Description *string `json:"description,omitempty"`
// ProvisioningState - the provisioning state.
ProvisioningState *string `json:"provisioningState,omitempty"`
// IsEnabled - the flag that indicates whether the alert rule is enabled.
IsEnabled *bool `json:"isEnabled,omitempty"`
// Condition - the condition that results in the alert rule being activated.
Condition BasicRuleCondition `json:"condition,omitempty"`
// Action - action that is performed when the alert rule becomes active, and when an alert condition is resolved.
Action BasicRuleAction `json:"action,omitempty"`
// Actions - the array of actions that are performed when the alert rule becomes active, and when an alert condition is resolved.
Actions *[]BasicRuleAction `json:"actions,omitempty"`
// LastUpdatedTime - READ-ONLY; Last time the rule was updated in ISO8601 format.
LastUpdatedTime *date.Time `json:"lastUpdatedTime,omitempty"`
}
// MarshalJSON is the custom marshaler for AlertRule.
func (ar AlertRule) MarshalJSON() ([]byte, error) {
objectMap := make(map[string]interface{})
if ar.Name != nil {
objectMap["name"] = ar.Name
}
if ar.Description != nil {
objectMap["description"] = ar.Description
}
if ar.ProvisioningState != nil {
objectMap["provisioningState"] = ar.ProvisioningState
}
if ar.IsEnabled != nil {
objectMap["isEnabled"] = ar.IsEnabled
}
objectMap["condition"] = ar.Condition
objectMap["action"] = ar.Action
if ar.Actions != nil {
objectMap["actions"] = ar.Actions
}
return json.Marshal(objectMap)
}
// UnmarshalJSON is the custom unmarshaler for AlertRule struct.
func (ar *AlertRule) UnmarshalJSON(body []byte) error {
var m map[string]*json.RawMessage
err := json.Unmarshal(body, &m)
if err != nil {
return err
}
for k, v := range m {
switch k {
case "name":
if v != nil {
var name string
err = json.Unmarshal(*v, &name)
if err != nil {
return err
}
ar.Name = &name
}
case "description":
if v != nil {
var description string
err = json.Unmarshal(*v, &description)
if err != nil {
return err
}
ar.Description = &description
}
case "provisioningState":
if v != nil {
var provisioningState string
err = json.Unmarshal(*v, &provisioningState)
if err != nil {
return err
}
ar.ProvisioningState = &provisioningState
}
case "isEnabled":
if v != nil {
var isEnabled bool
err = json.Unmarshal(*v, &isEnabled)
if err != nil {
return err
}
ar.IsEnabled = &isEnabled
}
case "condition":
if v != nil {
condition, err := unmarshalBasicRuleCondition(*v)
if err != nil {
return err
}
ar.Condition = condition
}
case "action":
if v != nil {
action, err := unmarshalBasicRuleAction(*v)
if err != nil {
return err
}
ar.Action = action
}
case "actions":
if v != nil {
actions, err := unmarshalBasicRuleActionArray(*v)
if err != nil {
return err
}
ar.Actions = &actions
}
case "lastUpdatedTime":
if v != nil {
var lastUpdatedTime date.Time
err = json.Unmarshal(*v, &lastUpdatedTime)
if err != nil {
return err
}
ar.LastUpdatedTime = &lastUpdatedTime
}
}
}
return nil
}
// AlertRuleResource the alert rule resource.
type AlertRuleResource struct {
autorest.Response `json:"-"`
// AlertRule - The alert rule properties of the resource.
*AlertRule `json:"properties,omitempty"`
// ID - READ-ONLY; Azure resource Id
ID *string `json:"id,omitempty"`
// Name - READ-ONLY; Azure resource name
Name *string `json:"name,omitempty"`
// Type - READ-ONLY; Azure resource type
Type *string `json:"type,omitempty"`
// Location - Resource location
Location *string `json:"location,omitempty"`
// Tags - Resource tags
Tags map[string]*string `json:"tags"`
}
// MarshalJSON is the custom marshaler for AlertRuleResource.
func (arr AlertRuleResource) MarshalJSON() ([]byte, error) {
objectMap := make(map[string]interface{})
if arr.AlertRule != nil {
objectMap["properties"] = arr.AlertRule
}
if arr.Location != nil {
objectMap["location"] = arr.Location
}
if arr.Tags != nil {
objectMap["tags"] = arr.Tags
}
return json.Marshal(objectMap)
}
// UnmarshalJSON is the custom unmarshaler for AlertRuleResource struct.
func (arr *AlertRuleResource) UnmarshalJSON(body []byte) error {
var m map[string]*json.RawMessage
err := json.Unmarshal(body, &m)
if err != nil {
return err
}
for k, v := range m {
switch k {
case "properties":
if v != nil {
var alertRule AlertRule
err = json.Unmarshal(*v, &alertRule)
if err != nil {
return err
}
arr.AlertRule = &alertRule
}
case "id":
if v != nil {
var ID string
err = json.Unmarshal(*v, &ID)
if err != nil {
return err
}
arr.ID = &ID
}
case "name":
if v != nil {
var name string
err = json.Unmarshal(*v, &name)
if err != nil {
return err
}
arr.Name = &name
}
case "type":
if v != nil {
var typeVar string
err = json.Unmarshal(*v, &typeVar)
if err != nil {
return err
}
arr.Type = &typeVar
}
case "location":
if v != nil {
var location string
err = json.Unmarshal(*v, &location)
if err != nil {
return err
}
arr.Location = &location
}
case "tags":
if v != nil {
var tags map[string]*string
err = json.Unmarshal(*v, &tags)
if err != nil {
return err
}
arr.Tags = tags
}
}
}
return nil
}
// AlertRuleResourceCollection represents a collection of alert rule resources.
type AlertRuleResourceCollection struct {
autorest.Response `json:"-"`
// Value - the values for the alert rule resources.
Value *[]AlertRuleResource `json:"value,omitempty"`
}
// AlertRuleResourcePatch the alert rule object for patch operations.
type AlertRuleResourcePatch struct {
// Tags - Resource tags
Tags map[string]*string `json:"tags"`
// AlertRule - The properties of an alert rule.
*AlertRule `json:"properties,omitempty"`
}
// MarshalJSON is the custom marshaler for AlertRuleResourcePatch.
func (arrp AlertRuleResourcePatch) MarshalJSON() ([]byte, error) {
objectMap := make(map[string]interface{})
if arrp.Tags != nil {
objectMap["tags"] = arrp.Tags
}
if arrp.AlertRule != nil {
objectMap["properties"] = arrp.AlertRule
}
return json.Marshal(objectMap)
}
// UnmarshalJSON is the custom unmarshaler for AlertRuleResourcePatch struct.
func (arrp *AlertRuleResourcePatch) UnmarshalJSON(body []byte) error {
var m map[string]*json.RawMessage
err := json.Unmarshal(body, &m)
if err != nil {
return err
}
for k, v := range m {
switch k {
case "tags":
if v != nil {
var tags map[string]*string
err = json.Unmarshal(*v, &tags)
if err != nil {
return err
}
arrp.Tags = tags
}
case "properties":
if v != nil {
var alertRule AlertRule
err = json.Unmarshal(*v, &alertRule)
if err != nil {
return err
}
arrp.AlertRule = &alertRule
}
}
}
return nil
}
// DataContainer information about a container with data for a given resource.
type DataContainer struct {
// Workspace - Log Analytics workspace information.
Workspace *WorkspaceInfo `json:"workspace,omitempty"`
}
// Error error details.
type Error struct {
// Code - Error code identifying the specific error.
Code *string `json:"code,omitempty"`
// Message - Error message in the caller's locale.
Message *string `json:"message,omitempty"`
}
// ErrorResponse describes the format of Error response.
type ErrorResponse struct {
// Code - Error code
Code *string `json:"code,omitempty"`
// Message - Error message indicating why the operation failed.
Message *string `json:"message,omitempty"`
}
// EventCategoryCollection a collection of event categories. Currently possible values are: Administrative,
// Security, ServiceHealth, Alert, Recommendation, Policy.
type EventCategoryCollection struct {
autorest.Response `json:"-"`
// Value - the list that includes the Azure event categories.
Value *[]LocalizableString `json:"value,omitempty"`
}
// Incident an alert incident indicates the activation status of an alert rule.
type Incident struct {
autorest.Response `json:"-"`
// Name - READ-ONLY; Incident name.
Name *string `json:"name,omitempty"`
// RuleName - READ-ONLY; Rule name that is associated with the incident.
RuleName *string `json:"ruleName,omitempty"`
// IsActive - READ-ONLY; A boolean to indicate whether the incident is active or resolved.
IsActive *bool `json:"isActive,omitempty"`
// ActivatedTime - READ-ONLY; The time at which the incident was activated in ISO8601 format.
ActivatedTime *date.Time `json:"activatedTime,omitempty"`
// ResolvedTime - READ-ONLY; The time at which the incident was resolved in ISO8601 format. If null, it means the incident is still active.
ResolvedTime *date.Time `json:"resolvedTime,omitempty"`
}
// MarshalJSON is the custom marshaler for Incident.
func (i Incident) MarshalJSON() ([]byte, error) {
objectMap := make(map[string]interface{})
return json.Marshal(objectMap)
}
// IncidentListResult the List incidents operation response.
type IncidentListResult struct {
autorest.Response `json:"-"`
// Value - the incident collection.
Value *[]Incident `json:"value,omitempty"`
}
// LocalizableString the localizable string class.
type LocalizableString struct {
// Value - the invariant value.
Value *string `json:"value,omitempty"`
// LocalizedValue - the locale specific value.
LocalizedValue *string `json:"localizedValue,omitempty"`
}
// LocationThresholdRuleCondition a rule condition based on a certain number of locations failing.
type LocationThresholdRuleCondition struct {
// WindowSize - the period of time (in ISO 8601 duration format) that is used to monitor alert activity based on the threshold. If specified then it must be between 5 minutes and 1 day.
WindowSize *string `json:"windowSize,omitempty"`
// FailedLocationCount - the number of locations that must fail to activate the alert.
FailedLocationCount *int32 `json:"failedLocationCount,omitempty"`
// DataSource - the resource from which the rule collects its data. For this type dataSource will always be of type RuleMetricDataSource.
DataSource BasicRuleDataSource `json:"dataSource,omitempty"`
// OdataType - Possible values include: 'OdataTypeRuleCondition', 'OdataTypeMicrosoftAzureManagementInsightsModelsThresholdRuleCondition', 'OdataTypeMicrosoftAzureManagementInsightsModelsLocationThresholdRuleCondition', 'OdataTypeMicrosoftAzureManagementInsightsModelsManagementEventRuleCondition'
OdataType OdataTypeBasicRuleCondition `json:"odata.type,omitempty"`
}
// MarshalJSON is the custom marshaler for LocationThresholdRuleCondition.
func (ltrc LocationThresholdRuleCondition) MarshalJSON() ([]byte, error) {
ltrc.OdataType = OdataTypeMicrosoftAzureManagementInsightsModelsLocationThresholdRuleCondition
objectMap := make(map[string]interface{})
if ltrc.WindowSize != nil {
objectMap["windowSize"] = ltrc.WindowSize
}
if ltrc.FailedLocationCount != nil {
objectMap["failedLocationCount"] = ltrc.FailedLocationCount
}
objectMap["dataSource"] = ltrc.DataSource
if ltrc.OdataType != "" {
objectMap["odata.type"] = ltrc.OdataType
}
return json.Marshal(objectMap)
}
// AsThresholdRuleCondition is the BasicRuleCondition implementation for LocationThresholdRuleCondition.
func (ltrc LocationThresholdRuleCondition) AsThresholdRuleCondition() (*ThresholdRuleCondition, bool) {
return nil, false
}
// AsLocationThresholdRuleCondition is the BasicRuleCondition implementation for LocationThresholdRuleCondition.
func (ltrc LocationThresholdRuleCondition) AsLocationThresholdRuleCondition() (*LocationThresholdRuleCondition, bool) {
return <rc, true
}
// AsManagementEventRuleCondition is the BasicRuleCondition implementation for LocationThresholdRuleCondition.
func (ltrc LocationThresholdRuleCondition) AsManagementEventRuleCondition() (*ManagementEventRuleCondition, bool) {
return nil, false
}
// AsRuleCondition is the BasicRuleCondition implementation for LocationThresholdRuleCondition.
func (ltrc LocationThresholdRuleCondition) AsRuleCondition() (*RuleCondition, bool) {
return nil, false
}
// AsBasicRuleCondition is the BasicRuleCondition implementation for LocationThresholdRuleCondition.
func (ltrc LocationThresholdRuleCondition) AsBasicRuleCondition() (BasicRuleCondition, bool) {
return <rc, true
}
// UnmarshalJSON is the custom unmarshaler for LocationThresholdRuleCondition struct.
func (ltrc *LocationThresholdRuleCondition) UnmarshalJSON(body []byte) error {
var m map[string]*json.RawMessage
err := json.Unmarshal(body, &m)
if err != nil {
return err
}
for k, v := range m {
switch k {
case "windowSize":
if v != nil {
var windowSize string
err = json.Unmarshal(*v, &windowSize)
if err != nil {
return err
}
ltrc.WindowSize = &windowSize
}
case "failedLocationCount":
if v != nil {
var failedLocationCount int32
err = json.Unmarshal(*v, &failedLocationCount)
if err != nil {
return err
}
ltrc.FailedLocationCount = &failedLocationCount
}
case "dataSource":
if v != nil {
dataSource, err := unmarshalBasicRuleDataSource(*v)
if err != nil {
return err
}
ltrc.DataSource = dataSource
}
case "odata.type":
if v != nil {
var odataType OdataTypeBasicRuleCondition
err = json.Unmarshal(*v, &odataType)
if err != nil {
return err
}
ltrc.OdataType = odataType
}
}
}
return nil
}
// LogProfileCollection represents a collection of log profiles.
type LogProfileCollection struct {
autorest.Response `json:"-"`
// Value - the values of the log profiles.
Value *[]LogProfileResource `json:"value,omitempty"`
}
// LogProfileProperties the log profile properties.
type LogProfileProperties struct {
// StorageAccountID - the resource id of the storage account to which you would like to send the Activity Log.
StorageAccountID *string `json:"storageAccountId,omitempty"`
// ServiceBusRuleID - The service bus rule ID of the service bus namespace in which you would like to have Event Hubs created for streaming the Activity Log. The rule ID is of the format: '{service bus resource ID}/authorizationrules/{key name}'.
ServiceBusRuleID *string `json:"serviceBusRuleId,omitempty"`
// Locations - List of regions for which Activity Log events should be stored or streamed. It is a comma separated list of valid ARM locations including the 'global' location.
Locations *[]string `json:"locations,omitempty"`
// Categories - the categories of the logs. These categories are created as is convenient to the user. Some values are: 'Write', 'Delete', and/or 'Action.'
Categories *[]string `json:"categories,omitempty"`
// RetentionPolicy - the retention policy for the events in the log.
RetentionPolicy *RetentionPolicy `json:"retentionPolicy,omitempty"`
}
// LogProfileResource the log profile resource.
type LogProfileResource struct {
autorest.Response `json:"-"`
// LogProfileProperties - The log profile properties of the resource.
*LogProfileProperties `json:"properties,omitempty"`
// ID - READ-ONLY; Azure resource Id
ID *string `json:"id,omitempty"`
// Name - READ-ONLY; Azure resource name
Name *string `json:"name,omitempty"`
// Type - READ-ONLY; Azure resource type
Type *string `json:"type,omitempty"`
// Location - Resource location
Location *string `json:"location,omitempty"`
// Tags - Resource tags
Tags map[string]*string `json:"tags"`
}
// MarshalJSON is the custom marshaler for LogProfileResource.
func (lpr LogProfileResource) MarshalJSON() ([]byte, error) {
objectMap := make(map[string]interface{})
if lpr.LogProfileProperties != nil {
objectMap["properties"] = lpr.LogProfileProperties
}
if lpr.Location != nil {
objectMap["location"] = lpr.Location
}
if lpr.Tags != nil {
objectMap["tags"] = lpr.Tags
}
return json.Marshal(objectMap)
}
// UnmarshalJSON is the custom unmarshaler for LogProfileResource struct.
func (lpr *LogProfileResource) UnmarshalJSON(body []byte) error {
var m map[string]*json.RawMessage
err := json.Unmarshal(body, &m)
if err != nil {
return err
}
for k, v := range m {
switch k {
case "properties":
if v != nil {
var logProfileProperties LogProfileProperties
err = json.Unmarshal(*v, &logProfileProperties)
if err != nil {
return err
}
lpr.LogProfileProperties = &logProfileProperties
}
case "id":
if v != nil {
var ID string
err = json.Unmarshal(*v, &ID)
if err != nil {
return err
}
lpr.ID = &ID
}
case "name":
if v != nil {
var name string
err = json.Unmarshal(*v, &name)
if err != nil {
return err
}
lpr.Name = &name
}
case "type":
if v != nil {
var typeVar string
err = json.Unmarshal(*v, &typeVar)
if err != nil {
return err
}
lpr.Type = &typeVar
}
case "location":
if v != nil {
var location string
err = json.Unmarshal(*v, &location)
if err != nil {
return err
}
lpr.Location = &location
}
case "tags":
if v != nil {
var tags map[string]*string
err = json.Unmarshal(*v, &tags)
if err != nil {
return err
}
lpr.Tags = tags
}
}
}
return nil
}
// LogProfileResourcePatch the log profile resource for patch operations.
type LogProfileResourcePatch struct {
// Tags - Resource tags
Tags map[string]*string `json:"tags"`
// LogProfileProperties - The log profile properties for an update operation.
*LogProfileProperties `json:"properties,omitempty"`
}
// MarshalJSON is the custom marshaler for LogProfileResourcePatch.
func (lprp LogProfileResourcePatch) MarshalJSON() ([]byte, error) {
objectMap := make(map[string]interface{})
if lprp.Tags != nil {
objectMap["tags"] = lprp.Tags
}
if lprp.LogProfileProperties != nil {
objectMap["properties"] = lprp.LogProfileProperties
}
return json.Marshal(objectMap)
}
// UnmarshalJSON is the custom unmarshaler for LogProfileResourcePatch struct.
func (lprp *LogProfileResourcePatch) UnmarshalJSON(body []byte) error {
var m map[string]*json.RawMessage
err := json.Unmarshal(body, &m)
if err != nil {
return err
}
for k, v := range m {
switch k {
case "tags":
if v != nil {
var tags map[string]*string
err = json.Unmarshal(*v, &tags)
if err != nil {
return err
}
lprp.Tags = tags
}
case "properties":
if v != nil {
var logProfileProperties LogProfileProperties
err = json.Unmarshal(*v, &logProfileProperties)
if err != nil {
return err
}
lprp.LogProfileProperties = &logProfileProperties
}
}
}
return nil
}
// ManagementEventAggregationCondition how the data that is collected should be combined over time.
type ManagementEventAggregationCondition struct {
// Operator - the condition operator. Possible values include: 'GreaterThan', 'GreaterThanOrEqual', 'LessThan', 'LessThanOrEqual'
Operator ConditionOperator `json:"operator,omitempty"`
// Threshold - The threshold value that activates the alert.
Threshold *float64 `json:"threshold,omitempty"`
// WindowSize - the period of time (in ISO 8601 duration format) that is used to monitor alert activity based on the threshold. If specified then it must be between 5 minutes and 1 day.
WindowSize *string `json:"windowSize,omitempty"`
}
// ManagementEventRuleCondition a management event rule condition.
type ManagementEventRuleCondition struct {
// Aggregation - How the data that is collected should be combined over time and when the alert is activated. Note that for management event alerts aggregation is optional – if it is not provided then any event will cause the alert to activate.
Aggregation *ManagementEventAggregationCondition `json:"aggregation,omitempty"`
// DataSource - the resource from which the rule collects its data. For this type dataSource will always be of type RuleMetricDataSource.
DataSource BasicRuleDataSource `json:"dataSource,omitempty"`
// OdataType - Possible values include: 'OdataTypeRuleCondition', 'OdataTypeMicrosoftAzureManagementInsightsModelsThresholdRuleCondition', 'OdataTypeMicrosoftAzureManagementInsightsModelsLocationThresholdRuleCondition', 'OdataTypeMicrosoftAzureManagementInsightsModelsManagementEventRuleCondition'
OdataType OdataTypeBasicRuleCondition `json:"odata.type,omitempty"`
}
// MarshalJSON is the custom marshaler for ManagementEventRuleCondition.
func (merc ManagementEventRuleCondition) MarshalJSON() ([]byte, error) {
merc.OdataType = OdataTypeMicrosoftAzureManagementInsightsModelsManagementEventRuleCondition
objectMap := make(map[string]interface{})
if merc.Aggregation != nil {
objectMap["aggregation"] = merc.Aggregation
}
objectMap["dataSource"] = merc.DataSource
if merc.OdataType != "" {
objectMap["odata.type"] = merc.OdataType
}
return json.Marshal(objectMap)
}
// AsThresholdRuleCondition is the BasicRuleCondition implementation for ManagementEventRuleCondition.
func (merc ManagementEventRuleCondition) AsThresholdRuleCondition() (*ThresholdRuleCondition, bool) {
return nil, false
}
// AsLocationThresholdRuleCondition is the BasicRuleCondition implementation for ManagementEventRuleCondition.
func (merc ManagementEventRuleCondition) AsLocationThresholdRuleCondition() (*LocationThresholdRuleCondition, bool) {
return nil, false
}
// AsManagementEventRuleCondition is the BasicRuleCondition implementation for ManagementEventRuleCondition.
func (merc ManagementEventRuleCondition) AsManagementEventRuleCondition() (*ManagementEventRuleCondition, bool) {
return &merc, true
}
// AsRuleCondition is the BasicRuleCondition implementation for ManagementEventRuleCondition.
func (merc ManagementEventRuleCondition) AsRuleCondition() (*RuleCondition, bool) {
return nil, false
}
// AsBasicRuleCondition is the BasicRuleCondition implementation for ManagementEventRuleCondition.
func (merc ManagementEventRuleCondition) AsBasicRuleCondition() (BasicRuleCondition, bool) {
return &merc, true
}
// UnmarshalJSON is the custom unmarshaler for ManagementEventRuleCondition struct.
func (merc *ManagementEventRuleCondition) UnmarshalJSON(body []byte) error {
var m map[string]*json.RawMessage
err := json.Unmarshal(body, &m)
if err != nil {
return err
}
for k, v := range m {
switch k {
case "aggregation":
if v != nil {
var aggregation ManagementEventAggregationCondition
err = json.Unmarshal(*v, &aggregation)
if err != nil {
return err
}
merc.Aggregation = &aggregation
}
case "dataSource":
if v != nil {
dataSource, err := unmarshalBasicRuleDataSource(*v)
if err != nil {
return err
}
merc.DataSource = dataSource
}
case "odata.type":
if v != nil {
var odataType OdataTypeBasicRuleCondition
err = json.Unmarshal(*v, &odataType)
if err != nil {
return err
}
merc.OdataType = odataType
}
}
}
return nil
}
// ProxyResource an azure resource object
type ProxyResource struct {
// ID - READ-ONLY; Azure resource Id
ID *string `json:"id,omitempty"`
// Name - READ-ONLY; Azure resource name
Name *string `json:"name,omitempty"`
// Type - READ-ONLY; Azure resource type
Type *string `json:"type,omitempty"`
}
// MarshalJSON is the custom marshaler for ProxyResource.
func (pr ProxyResource) MarshalJSON() ([]byte, error) {
objectMap := make(map[string]interface{})
return json.Marshal(objectMap)
}
// Resource an azure resource object
type Resource struct {
// ID - READ-ONLY; Azure resource Id
ID *string `json:"id,omitempty"`
// Name - READ-ONLY; Azure resource name
Name *string `json:"name,omitempty"`
// Type - READ-ONLY; Azure resource type
Type *string `json:"type,omitempty"`
// Location - Resource location
Location *string `json:"location,omitempty"`
// Tags - Resource tags
Tags map[string]*string `json:"tags"`
}
// MarshalJSON is the custom marshaler for Resource.
func (r Resource) MarshalJSON() ([]byte, error) {
objectMap := make(map[string]interface{})
if r.Location != nil {
objectMap["location"] = r.Location
}
if r.Tags != nil {
objectMap["tags"] = r.Tags
}
return json.Marshal(objectMap)
}
// ResponseWithError an error response from the API.
type ResponseWithError struct {
// Error - Error information.
Error *Error `json:"error,omitempty"`
}
// RetentionPolicy specifies the retention policy for the log.
type RetentionPolicy struct {
// Enabled - a value indicating whether the retention policy is enabled.
Enabled *bool `json:"enabled,omitempty"`
// Days - the number of days for the retention in days. A value of 0 will retain the events indefinitely.
Days *int32 `json:"days,omitempty"`
}
// BasicRuleAction the action that is performed when the alert rule becomes active, and when an alert condition is
// resolved.
type BasicRuleAction interface {
AsRuleEmailAction() (*RuleEmailAction, bool)
AsRuleWebhookAction() (*RuleWebhookAction, bool)
AsRuleAction() (*RuleAction, bool)
}
// RuleAction the action that is performed when the alert rule becomes active, and when an alert condition is
// resolved.
type RuleAction struct {
// OdataType - Possible values include: 'OdataTypeRuleAction', 'OdataTypeMicrosoftAzureManagementInsightsModelsRuleEmailAction', 'OdataTypeMicrosoftAzureManagementInsightsModelsRuleWebhookAction'
OdataType OdataTypeBasicRuleAction `json:"odata.type,omitempty"`
}
func unmarshalBasicRuleAction(body []byte) (BasicRuleAction, error) {
var m map[string]interface{}
err := json.Unmarshal(body, &m)
if err != nil {
return nil, err
}
switch m["odata.type"] {
case string(OdataTypeMicrosoftAzureManagementInsightsModelsRuleEmailAction):
var rea RuleEmailAction
err := json.Unmarshal(body, &rea)
return rea, err
case string(OdataTypeMicrosoftAzureManagementInsightsModelsRuleWebhookAction):
var rwa RuleWebhookAction
err := json.Unmarshal(body, &rwa)
return rwa, err
default:
var ra RuleAction
err := json.Unmarshal(body, &ra)
return ra, err
}
}
func unmarshalBasicRuleActionArray(body []byte) ([]BasicRuleAction, error) {
var rawMessages []*json.RawMessage
err := json.Unmarshal(body, &rawMessages)
if err != nil {
return nil, err
}
raArray := make([]BasicRuleAction, len(rawMessages))
for index, rawMessage := range rawMessages {
ra, err := unmarshalBasicRuleAction(*rawMessage)
if err != nil {
return nil, err
}
raArray[index] = ra
}
return raArray, nil
}
// MarshalJSON is the custom marshaler for RuleAction.
func (ra RuleAction) MarshalJSON() ([]byte, error) {
ra.OdataType = OdataTypeRuleAction
objectMap := make(map[string]interface{})
if ra.OdataType != "" {
objectMap["odata.type"] = ra.OdataType
}
return json.Marshal(objectMap)
}
// AsRuleEmailAction is the BasicRuleAction implementation for RuleAction.
func (ra RuleAction) AsRuleEmailAction() (*RuleEmailAction, bool) {
return nil, false
}
// AsRuleWebhookAction is the BasicRuleAction implementation for RuleAction.
func (ra RuleAction) AsRuleWebhookAction() (*RuleWebhookAction, bool) {
return nil, false
}
// AsRuleAction is the BasicRuleAction implementation for RuleAction.
func (ra RuleAction) AsRuleAction() (*RuleAction, bool) {
return &ra, true
}
// AsBasicRuleAction is the BasicRuleAction implementation for RuleAction.
func (ra RuleAction) AsBasicRuleAction() (BasicRuleAction, bool) {
return &ra, true
}
// BasicRuleCondition the condition that results in the alert rule being activated.
type BasicRuleCondition interface {
AsThresholdRuleCondition() (*ThresholdRuleCondition, bool)
AsLocationThresholdRuleCondition() (*LocationThresholdRuleCondition, bool)
AsManagementEventRuleCondition() (*ManagementEventRuleCondition, bool)
AsRuleCondition() (*RuleCondition, bool)
}
// RuleCondition the condition that results in the alert rule being activated.
type RuleCondition struct {
// DataSource - the resource from which the rule collects its data. For this type dataSource will always be of type RuleMetricDataSource.
DataSource BasicRuleDataSource `json:"dataSource,omitempty"`
// OdataType - Possible values include: 'OdataTypeRuleCondition', 'OdataTypeMicrosoftAzureManagementInsightsModelsThresholdRuleCondition', 'OdataTypeMicrosoftAzureManagementInsightsModelsLocationThresholdRuleCondition', 'OdataTypeMicrosoftAzureManagementInsightsModelsManagementEventRuleCondition'
OdataType OdataTypeBasicRuleCondition `json:"odata.type,omitempty"`
}
func unmarshalBasicRuleCondition(body []byte) (BasicRuleCondition, error) {
var m map[string]interface{}
err := json.Unmarshal(body, &m)
if err != nil {
return nil, err
}
switch m["odata.type"] {
case string(OdataTypeMicrosoftAzureManagementInsightsModelsThresholdRuleCondition):
var trc ThresholdRuleCondition
err := json.Unmarshal(body, &trc)
return trc, err
case string(OdataTypeMicrosoftAzureManagementInsightsModelsLocationThresholdRuleCondition):
var ltrc LocationThresholdRuleCondition
err := json.Unmarshal(body, <rc)
return ltrc, err
case string(OdataTypeMicrosoftAzureManagementInsightsModelsManagementEventRuleCondition):
var merc ManagementEventRuleCondition
err := json.Unmarshal(body, &merc)
return merc, err
default:
var rc RuleCondition
err := json.Unmarshal(body, &rc)
return rc, err
}
}
func unmarshalBasicRuleConditionArray(body []byte) ([]BasicRuleCondition, error) {
var rawMessages []*json.RawMessage
err := json.Unmarshal(body, &rawMessages)
if err != nil {
return nil, err
}
rcArray := make([]BasicRuleCondition, len(rawMessages))
for index, rawMessage := range rawMessages {
rc, err := unmarshalBasicRuleCondition(*rawMessage)
if err != nil {
return nil, err
}
rcArray[index] = rc
}
return rcArray, nil
}
// MarshalJSON is the custom marshaler for RuleCondition.
func (rc RuleCondition) MarshalJSON() ([]byte, error) {
rc.OdataType = OdataTypeRuleCondition
objectMap := make(map[string]interface{})
objectMap["dataSource"] = rc.DataSource
if rc.OdataType != "" {
objectMap["odata.type"] = rc.OdataType
}
return json.Marshal(objectMap)
}
// AsThresholdRuleCondition is the BasicRuleCondition implementation for RuleCondition.
func (rc RuleCondition) AsThresholdRuleCondition() (*ThresholdRuleCondition, bool) {
return nil, false
}
// AsLocationThresholdRuleCondition is the BasicRuleCondition implementation for RuleCondition.
func (rc RuleCondition) AsLocationThresholdRuleCondition() (*LocationThresholdRuleCondition, bool) {
return nil, false
}
// AsManagementEventRuleCondition is the BasicRuleCondition implementation for RuleCondition.
func (rc RuleCondition) AsManagementEventRuleCondition() (*ManagementEventRuleCondition, bool) {
return nil, false
}
// AsRuleCondition is the BasicRuleCondition implementation for RuleCondition.
func (rc RuleCondition) AsRuleCondition() (*RuleCondition, bool) {
return &rc, true
}
// AsBasicRuleCondition is the BasicRuleCondition implementation for RuleCondition.
func (rc RuleCondition) AsBasicRuleCondition() (BasicRuleCondition, bool) {
return &rc, true
}
// UnmarshalJSON is the custom unmarshaler for RuleCondition struct.
func (rc *RuleCondition) UnmarshalJSON(body []byte) error {
var m map[string]*json.RawMessage
err := json.Unmarshal(body, &m)
if err != nil {
return err
}
for k, v := range m {
switch k {
case "dataSource":
if v != nil {