forked from Azure/azure-sdk-for-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
models.go
2336 lines (2196 loc) · 84.1 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 metrics
// 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/2021-05-01-preview/metrics"
// AlertAction an alert action.
type AlertAction struct {
// ActionGroupID - the id of the action group to use.
ActionGroupID *string `json:"actionGroupId,omitempty"`
// WebHookProperties - This field allows specifying custom properties, which would be appended to the alert payload sent as input to the webhook.
WebHookProperties map[string]*string `json:"webHookProperties"`
}
// MarshalJSON is the custom marshaler for AlertAction.
func (aa AlertAction) MarshalJSON() ([]byte, error) {
objectMap := make(map[string]interface{})
if aa.ActionGroupID != nil {
objectMap["actionGroupId"] = aa.ActionGroupID
}
if aa.WebHookProperties != nil {
objectMap["webHookProperties"] = aa.WebHookProperties
}
return json.Marshal(objectMap)
}
// BasicAlertCriteria the rule criteria that defines the conditions of the alert rule.
type BasicAlertCriteria interface {
AsAlertSingleResourceMultipleMetricCriteria() (*AlertSingleResourceMultipleMetricCriteria, bool)
AsWebtestLocationAvailabilityCriteria() (*WebtestLocationAvailabilityCriteria, bool)
AsAlertMultipleResourceMultipleMetricCriteria() (*AlertMultipleResourceMultipleMetricCriteria, bool)
AsAlertCriteria() (*AlertCriteria, bool)
}
// AlertCriteria the rule criteria that defines the conditions of the alert rule.
type AlertCriteria struct {
// AdditionalProperties - Unmatched properties from the message are deserialized this collection
AdditionalProperties map[string]interface{} `json:""`
// OdataType - Possible values include: 'OdataTypeMetricAlertCriteria', 'OdataTypeMicrosoftAzureMonitorSingleResourceMultipleMetricCriteria', 'OdataTypeMicrosoftAzureMonitorWebtestLocationAvailabilityCriteria', 'OdataTypeMicrosoftAzureMonitorMultipleResourceMultipleMetricCriteria'
OdataType OdataType `json:"odata.type,omitempty"`
}
func unmarshalBasicAlertCriteria(body []byte) (BasicAlertCriteria, error) {
var m map[string]interface{}
err := json.Unmarshal(body, &m)
if err != nil {
return nil, err
}
switch m["odata.type"] {
case string(OdataTypeMicrosoftAzureMonitorSingleResourceMultipleMetricCriteria):
var asrmmc AlertSingleResourceMultipleMetricCriteria
err := json.Unmarshal(body, &asrmmc)
return asrmmc, err
case string(OdataTypeMicrosoftAzureMonitorWebtestLocationAvailabilityCriteria):
var wlac WebtestLocationAvailabilityCriteria
err := json.Unmarshal(body, &wlac)
return wlac, err
case string(OdataTypeMicrosoftAzureMonitorMultipleResourceMultipleMetricCriteria):
var amrmmc AlertMultipleResourceMultipleMetricCriteria
err := json.Unmarshal(body, &amrmmc)
return amrmmc, err
default:
var ac AlertCriteria
err := json.Unmarshal(body, &ac)
return ac, err
}
}
func unmarshalBasicAlertCriteriaArray(body []byte) ([]BasicAlertCriteria, error) {
var rawMessages []*json.RawMessage
err := json.Unmarshal(body, &rawMessages)
if err != nil {
return nil, err
}
acArray := make([]BasicAlertCriteria, len(rawMessages))
for index, rawMessage := range rawMessages {
ac, err := unmarshalBasicAlertCriteria(*rawMessage)
if err != nil {
return nil, err
}
acArray[index] = ac
}
return acArray, nil
}
// MarshalJSON is the custom marshaler for AlertCriteria.
func (ac AlertCriteria) MarshalJSON() ([]byte, error) {
ac.OdataType = OdataTypeMetricAlertCriteria
objectMap := make(map[string]interface{})
if ac.OdataType != "" {
objectMap["odata.type"] = ac.OdataType
}
for k, v := range ac.AdditionalProperties {
objectMap[k] = v
}
return json.Marshal(objectMap)
}
// AsAlertSingleResourceMultipleMetricCriteria is the BasicAlertCriteria implementation for AlertCriteria.
func (ac AlertCriteria) AsAlertSingleResourceMultipleMetricCriteria() (*AlertSingleResourceMultipleMetricCriteria, bool) {
return nil, false
}
// AsWebtestLocationAvailabilityCriteria is the BasicAlertCriteria implementation for AlertCriteria.
func (ac AlertCriteria) AsWebtestLocationAvailabilityCriteria() (*WebtestLocationAvailabilityCriteria, bool) {
return nil, false
}
// AsAlertMultipleResourceMultipleMetricCriteria is the BasicAlertCriteria implementation for AlertCriteria.
func (ac AlertCriteria) AsAlertMultipleResourceMultipleMetricCriteria() (*AlertMultipleResourceMultipleMetricCriteria, bool) {
return nil, false
}
// AsAlertCriteria is the BasicAlertCriteria implementation for AlertCriteria.
func (ac AlertCriteria) AsAlertCriteria() (*AlertCriteria, bool) {
return &ac, true
}
// AsBasicAlertCriteria is the BasicAlertCriteria implementation for AlertCriteria.
func (ac AlertCriteria) AsBasicAlertCriteria() (BasicAlertCriteria, bool) {
return &ac, true
}
// UnmarshalJSON is the custom unmarshaler for AlertCriteria struct.
func (ac *AlertCriteria) 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 {
default:
if v != nil {
var additionalProperties interface{}
err = json.Unmarshal(*v, &additionalProperties)
if err != nil {
return err
}
if ac.AdditionalProperties == nil {
ac.AdditionalProperties = make(map[string]interface{})
}
ac.AdditionalProperties[k] = additionalProperties
}
case "odata.type":
if v != nil {
var odataType OdataType
err = json.Unmarshal(*v, &odataType)
if err != nil {
return err
}
ac.OdataType = odataType
}
}
}
return nil
}
// AlertMultipleResourceMultipleMetricCriteria specifies the metric alert criteria for multiple resource
// that has multiple metric criteria.
type AlertMultipleResourceMultipleMetricCriteria struct {
// AllOf - the list of multiple metric criteria for this 'all of' operation.
AllOf *[]BasicMultiMetricCriteria `json:"allOf,omitempty"`
// AdditionalProperties - Unmatched properties from the message are deserialized this collection
AdditionalProperties map[string]interface{} `json:""`
// OdataType - Possible values include: 'OdataTypeMetricAlertCriteria', 'OdataTypeMicrosoftAzureMonitorSingleResourceMultipleMetricCriteria', 'OdataTypeMicrosoftAzureMonitorWebtestLocationAvailabilityCriteria', 'OdataTypeMicrosoftAzureMonitorMultipleResourceMultipleMetricCriteria'
OdataType OdataType `json:"odata.type,omitempty"`
}
// MarshalJSON is the custom marshaler for AlertMultipleResourceMultipleMetricCriteria.
func (amrmmc AlertMultipleResourceMultipleMetricCriteria) MarshalJSON() ([]byte, error) {
amrmmc.OdataType = OdataTypeMicrosoftAzureMonitorMultipleResourceMultipleMetricCriteria
objectMap := make(map[string]interface{})
if amrmmc.AllOf != nil {
objectMap["allOf"] = amrmmc.AllOf
}
if amrmmc.OdataType != "" {
objectMap["odata.type"] = amrmmc.OdataType
}
for k, v := range amrmmc.AdditionalProperties {
objectMap[k] = v
}
return json.Marshal(objectMap)
}
// AsAlertSingleResourceMultipleMetricCriteria is the BasicAlertCriteria implementation for AlertMultipleResourceMultipleMetricCriteria.
func (amrmmc AlertMultipleResourceMultipleMetricCriteria) AsAlertSingleResourceMultipleMetricCriteria() (*AlertSingleResourceMultipleMetricCriteria, bool) {
return nil, false
}
// AsWebtestLocationAvailabilityCriteria is the BasicAlertCriteria implementation for AlertMultipleResourceMultipleMetricCriteria.
func (amrmmc AlertMultipleResourceMultipleMetricCriteria) AsWebtestLocationAvailabilityCriteria() (*WebtestLocationAvailabilityCriteria, bool) {
return nil, false
}
// AsAlertMultipleResourceMultipleMetricCriteria is the BasicAlertCriteria implementation for AlertMultipleResourceMultipleMetricCriteria.
func (amrmmc AlertMultipleResourceMultipleMetricCriteria) AsAlertMultipleResourceMultipleMetricCriteria() (*AlertMultipleResourceMultipleMetricCriteria, bool) {
return &amrmmc, true
}
// AsAlertCriteria is the BasicAlertCriteria implementation for AlertMultipleResourceMultipleMetricCriteria.
func (amrmmc AlertMultipleResourceMultipleMetricCriteria) AsAlertCriteria() (*AlertCriteria, bool) {
return nil, false
}
// AsBasicAlertCriteria is the BasicAlertCriteria implementation for AlertMultipleResourceMultipleMetricCriteria.
func (amrmmc AlertMultipleResourceMultipleMetricCriteria) AsBasicAlertCriteria() (BasicAlertCriteria, bool) {
return &amrmmc, true
}
// UnmarshalJSON is the custom unmarshaler for AlertMultipleResourceMultipleMetricCriteria struct.
func (amrmmc *AlertMultipleResourceMultipleMetricCriteria) 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 "allOf":
if v != nil {
allOf, err := unmarshalBasicMultiMetricCriteriaArray(*v)
if err != nil {
return err
}
amrmmc.AllOf = &allOf
}
default:
if v != nil {
var additionalProperties interface{}
err = json.Unmarshal(*v, &additionalProperties)
if err != nil {
return err
}
if amrmmc.AdditionalProperties == nil {
amrmmc.AdditionalProperties = make(map[string]interface{})
}
amrmmc.AdditionalProperties[k] = additionalProperties
}
case "odata.type":
if v != nil {
var odataType OdataType
err = json.Unmarshal(*v, &odataType)
if err != nil {
return err
}
amrmmc.OdataType = odataType
}
}
}
return nil
}
// AlertProperties an alert rule.
type AlertProperties struct {
// Description - the description of the metric alert that will be included in the alert email.
Description *string `json:"description,omitempty"`
// Severity - Alert severity {0, 1, 2, 3, 4}
Severity *int32 `json:"severity,omitempty"`
// Enabled - the flag that indicates whether the metric alert is enabled.
Enabled *bool `json:"enabled,omitempty"`
// Scopes - the list of resource id's that this metric alert is scoped to.
Scopes *[]string `json:"scopes,omitempty"`
// EvaluationFrequency - how often the metric alert is evaluated represented in ISO 8601 duration format.
EvaluationFrequency *string `json:"evaluationFrequency,omitempty"`
// WindowSize - the period of time (in ISO 8601 duration format) that is used to monitor alert activity based on the threshold.
WindowSize *string `json:"windowSize,omitempty"`
// TargetResourceType - the resource type of the target resource(s) on which the alert is created/updated. Mandatory if the scope contains a subscription, resource group, or more than one resource.
TargetResourceType *string `json:"targetResourceType,omitempty"`
// TargetResourceRegion - the region of the target resource(s) on which the alert is created/updated. Mandatory if the scope contains a subscription, resource group, or more than one resource.
TargetResourceRegion *string `json:"targetResourceRegion,omitempty"`
// Criteria - defines the specific alert criteria information.
Criteria BasicAlertCriteria `json:"criteria,omitempty"`
// AutoMitigate - the flag that indicates whether the alert should be auto resolved or not. The default is true.
AutoMitigate *bool `json:"autoMitigate,omitempty"`
// Actions - the array of actions that are performed when the alert rule becomes active, and when an alert condition is resolved.
Actions *[]AlertAction `json:"actions,omitempty"`
// LastUpdatedTime - READ-ONLY; Last time the rule was updated in ISO8601 format.
LastUpdatedTime *date.Time `json:"lastUpdatedTime,omitempty"`
// IsMigrated - READ-ONLY; the value indicating whether this alert rule is migrated.
IsMigrated *bool `json:"isMigrated,omitempty"`
}
// MarshalJSON is the custom marshaler for AlertProperties.
func (ap AlertProperties) MarshalJSON() ([]byte, error) {
objectMap := make(map[string]interface{})
if ap.Description != nil {
objectMap["description"] = ap.Description
}
if ap.Severity != nil {
objectMap["severity"] = ap.Severity
}
if ap.Enabled != nil {
objectMap["enabled"] = ap.Enabled
}
if ap.Scopes != nil {
objectMap["scopes"] = ap.Scopes
}
if ap.EvaluationFrequency != nil {
objectMap["evaluationFrequency"] = ap.EvaluationFrequency
}
if ap.WindowSize != nil {
objectMap["windowSize"] = ap.WindowSize
}
if ap.TargetResourceType != nil {
objectMap["targetResourceType"] = ap.TargetResourceType
}
if ap.TargetResourceRegion != nil {
objectMap["targetResourceRegion"] = ap.TargetResourceRegion
}
objectMap["criteria"] = ap.Criteria
if ap.AutoMitigate != nil {
objectMap["autoMitigate"] = ap.AutoMitigate
}
if ap.Actions != nil {
objectMap["actions"] = ap.Actions
}
return json.Marshal(objectMap)
}
// UnmarshalJSON is the custom unmarshaler for AlertProperties struct.
func (ap *AlertProperties) 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 "description":
if v != nil {
var description string
err = json.Unmarshal(*v, &description)
if err != nil {
return err
}
ap.Description = &description
}
case "severity":
if v != nil {
var severity int32
err = json.Unmarshal(*v, &severity)
if err != nil {
return err
}
ap.Severity = &severity
}
case "enabled":
if v != nil {
var enabled bool
err = json.Unmarshal(*v, &enabled)
if err != nil {
return err
}
ap.Enabled = &enabled
}
case "scopes":
if v != nil {
var scopes []string
err = json.Unmarshal(*v, &scopes)
if err != nil {
return err
}
ap.Scopes = &scopes
}
case "evaluationFrequency":
if v != nil {
var evaluationFrequency string
err = json.Unmarshal(*v, &evaluationFrequency)
if err != nil {
return err
}
ap.EvaluationFrequency = &evaluationFrequency
}
case "windowSize":
if v != nil {
var windowSize string
err = json.Unmarshal(*v, &windowSize)
if err != nil {
return err
}
ap.WindowSize = &windowSize
}
case "targetResourceType":
if v != nil {
var targetResourceType string
err = json.Unmarshal(*v, &targetResourceType)
if err != nil {
return err
}
ap.TargetResourceType = &targetResourceType
}
case "targetResourceRegion":
if v != nil {
var targetResourceRegion string
err = json.Unmarshal(*v, &targetResourceRegion)
if err != nil {
return err
}
ap.TargetResourceRegion = &targetResourceRegion
}
case "criteria":
if v != nil {
criteria, err := unmarshalBasicAlertCriteria(*v)
if err != nil {
return err
}
ap.Criteria = criteria
}
case "autoMitigate":
if v != nil {
var autoMitigate bool
err = json.Unmarshal(*v, &autoMitigate)
if err != nil {
return err
}
ap.AutoMitigate = &autoMitigate
}
case "actions":
if v != nil {
var actions []AlertAction
err = json.Unmarshal(*v, &actions)
if err != nil {
return err
}
ap.Actions = &actions
}
case "lastUpdatedTime":
if v != nil {
var lastUpdatedTime date.Time
err = json.Unmarshal(*v, &lastUpdatedTime)
if err != nil {
return err
}
ap.LastUpdatedTime = &lastUpdatedTime
}
case "isMigrated":
if v != nil {
var isMigrated bool
err = json.Unmarshal(*v, &isMigrated)
if err != nil {
return err
}
ap.IsMigrated = &isMigrated
}
}
}
return nil
}
// AlertPropertiesPatch an alert rule properties for patch.
type AlertPropertiesPatch struct {
// Description - the description of the metric alert that will be included in the alert email.
Description *string `json:"description,omitempty"`
// Severity - Alert severity {0, 1, 2, 3, 4}
Severity *int32 `json:"severity,omitempty"`
// Enabled - the flag that indicates whether the metric alert is enabled.
Enabled *bool `json:"enabled,omitempty"`
// Scopes - the list of resource id's that this metric alert is scoped to.
Scopes *[]string `json:"scopes,omitempty"`
// EvaluationFrequency - how often the metric alert is evaluated represented in ISO 8601 duration format.
EvaluationFrequency *string `json:"evaluationFrequency,omitempty"`
// WindowSize - the period of time (in ISO 8601 duration format) that is used to monitor alert activity based on the threshold.
WindowSize *string `json:"windowSize,omitempty"`
// TargetResourceType - the resource type of the target resource(s) on which the alert is created/updated. Mandatory for MultipleResourceMultipleMetricCriteria.
TargetResourceType *string `json:"targetResourceType,omitempty"`
// TargetResourceRegion - the region of the target resource(s) on which the alert is created/updated. Mandatory for MultipleResourceMultipleMetricCriteria.
TargetResourceRegion *string `json:"targetResourceRegion,omitempty"`
// Criteria - defines the specific alert criteria information.
Criteria BasicAlertCriteria `json:"criteria,omitempty"`
// AutoMitigate - the flag that indicates whether the alert should be auto resolved or not. The default is true.
AutoMitigate *bool `json:"autoMitigate,omitempty"`
// Actions - the array of actions that are performed when the alert rule becomes active, and when an alert condition is resolved.
Actions *[]AlertAction `json:"actions,omitempty"`
// LastUpdatedTime - READ-ONLY; Last time the rule was updated in ISO8601 format.
LastUpdatedTime *date.Time `json:"lastUpdatedTime,omitempty"`
// IsMigrated - READ-ONLY; the value indicating whether this alert rule is migrated.
IsMigrated *bool `json:"isMigrated,omitempty"`
}
// MarshalJSON is the custom marshaler for AlertPropertiesPatch.
func (app AlertPropertiesPatch) MarshalJSON() ([]byte, error) {
objectMap := make(map[string]interface{})
if app.Description != nil {
objectMap["description"] = app.Description
}
if app.Severity != nil {
objectMap["severity"] = app.Severity
}
if app.Enabled != nil {
objectMap["enabled"] = app.Enabled
}
if app.Scopes != nil {
objectMap["scopes"] = app.Scopes
}
if app.EvaluationFrequency != nil {
objectMap["evaluationFrequency"] = app.EvaluationFrequency
}
if app.WindowSize != nil {
objectMap["windowSize"] = app.WindowSize
}
if app.TargetResourceType != nil {
objectMap["targetResourceType"] = app.TargetResourceType
}
if app.TargetResourceRegion != nil {
objectMap["targetResourceRegion"] = app.TargetResourceRegion
}
objectMap["criteria"] = app.Criteria
if app.AutoMitigate != nil {
objectMap["autoMitigate"] = app.AutoMitigate
}
if app.Actions != nil {
objectMap["actions"] = app.Actions
}
return json.Marshal(objectMap)
}
// UnmarshalJSON is the custom unmarshaler for AlertPropertiesPatch struct.
func (app *AlertPropertiesPatch) 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 "description":
if v != nil {
var description string
err = json.Unmarshal(*v, &description)
if err != nil {
return err
}
app.Description = &description
}
case "severity":
if v != nil {
var severity int32
err = json.Unmarshal(*v, &severity)
if err != nil {
return err
}
app.Severity = &severity
}
case "enabled":
if v != nil {
var enabled bool
err = json.Unmarshal(*v, &enabled)
if err != nil {
return err
}
app.Enabled = &enabled
}
case "scopes":
if v != nil {
var scopes []string
err = json.Unmarshal(*v, &scopes)
if err != nil {
return err
}
app.Scopes = &scopes
}
case "evaluationFrequency":
if v != nil {
var evaluationFrequency string
err = json.Unmarshal(*v, &evaluationFrequency)
if err != nil {
return err
}
app.EvaluationFrequency = &evaluationFrequency
}
case "windowSize":
if v != nil {
var windowSize string
err = json.Unmarshal(*v, &windowSize)
if err != nil {
return err
}
app.WindowSize = &windowSize
}
case "targetResourceType":
if v != nil {
var targetResourceType string
err = json.Unmarshal(*v, &targetResourceType)
if err != nil {
return err
}
app.TargetResourceType = &targetResourceType
}
case "targetResourceRegion":
if v != nil {
var targetResourceRegion string
err = json.Unmarshal(*v, &targetResourceRegion)
if err != nil {
return err
}
app.TargetResourceRegion = &targetResourceRegion
}
case "criteria":
if v != nil {
criteria, err := unmarshalBasicAlertCriteria(*v)
if err != nil {
return err
}
app.Criteria = criteria
}
case "autoMitigate":
if v != nil {
var autoMitigate bool
err = json.Unmarshal(*v, &autoMitigate)
if err != nil {
return err
}
app.AutoMitigate = &autoMitigate
}
case "actions":
if v != nil {
var actions []AlertAction
err = json.Unmarshal(*v, &actions)
if err != nil {
return err
}
app.Actions = &actions
}
case "lastUpdatedTime":
if v != nil {
var lastUpdatedTime date.Time
err = json.Unmarshal(*v, &lastUpdatedTime)
if err != nil {
return err
}
app.LastUpdatedTime = &lastUpdatedTime
}
case "isMigrated":
if v != nil {
var isMigrated bool
err = json.Unmarshal(*v, &isMigrated)
if err != nil {
return err
}
app.IsMigrated = &isMigrated
}
}
}
return nil
}
// AlertResource the metric alert resource.
type AlertResource struct {
autorest.Response `json:"-"`
// AlertProperties - The alert rule properties of the resource.
*AlertProperties `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 AlertResource.
func (ar AlertResource) MarshalJSON() ([]byte, error) {
objectMap := make(map[string]interface{})
if ar.AlertProperties != nil {
objectMap["properties"] = ar.AlertProperties
}
if ar.Location != nil {
objectMap["location"] = ar.Location
}
if ar.Tags != nil {
objectMap["tags"] = ar.Tags
}
return json.Marshal(objectMap)
}
// UnmarshalJSON is the custom unmarshaler for AlertResource struct.
func (ar *AlertResource) 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 alertProperties AlertProperties
err = json.Unmarshal(*v, &alertProperties)
if err != nil {
return err
}
ar.AlertProperties = &alertProperties
}
case "id":
if v != nil {
var ID string
err = json.Unmarshal(*v, &ID)
if err != nil {
return err
}
ar.ID = &ID
}
case "name":
if v != nil {
var name string
err = json.Unmarshal(*v, &name)
if err != nil {
return err
}
ar.Name = &name
}
case "type":
if v != nil {
var typeVar string
err = json.Unmarshal(*v, &typeVar)
if err != nil {
return err
}
ar.Type = &typeVar
}
case "location":
if v != nil {
var location string
err = json.Unmarshal(*v, &location)
if err != nil {
return err
}
ar.Location = &location
}
case "tags":
if v != nil {
var tags map[string]*string
err = json.Unmarshal(*v, &tags)
if err != nil {
return err
}
ar.Tags = tags
}
}
}
return nil
}
// AlertResourceCollection represents a collection of alert rule resources.
type AlertResourceCollection struct {
autorest.Response `json:"-"`
// Value - the values for the alert rule resources.
Value *[]AlertResource `json:"value,omitempty"`
}
// AlertResourcePatch the metric alert resource for patch operations.
type AlertResourcePatch struct {
// Tags - Resource tags
Tags map[string]*string `json:"tags"`
// AlertPropertiesPatch - The alert rule properties of the resource.
*AlertPropertiesPatch `json:"properties,omitempty"`
}
// MarshalJSON is the custom marshaler for AlertResourcePatch.
func (arp AlertResourcePatch) MarshalJSON() ([]byte, error) {
objectMap := make(map[string]interface{})
if arp.Tags != nil {
objectMap["tags"] = arp.Tags
}
if arp.AlertPropertiesPatch != nil {
objectMap["properties"] = arp.AlertPropertiesPatch
}
return json.Marshal(objectMap)
}
// UnmarshalJSON is the custom unmarshaler for AlertResourcePatch struct.
func (arp *AlertResourcePatch) 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
}
arp.Tags = tags
}
case "properties":
if v != nil {
var alertPropertiesPatch AlertPropertiesPatch
err = json.Unmarshal(*v, &alertPropertiesPatch)
if err != nil {
return err
}
arp.AlertPropertiesPatch = &alertPropertiesPatch
}
}
}
return nil
}
// AlertSingleResourceMultipleMetricCriteria specifies the metric alert criteria for a single resource that
// has multiple metric criteria.
type AlertSingleResourceMultipleMetricCriteria struct {
// AllOf - The list of metric criteria for this 'all of' operation.
AllOf *[]Criteria `json:"allOf,omitempty"`
// AdditionalProperties - Unmatched properties from the message are deserialized this collection
AdditionalProperties map[string]interface{} `json:""`
// OdataType - Possible values include: 'OdataTypeMetricAlertCriteria', 'OdataTypeMicrosoftAzureMonitorSingleResourceMultipleMetricCriteria', 'OdataTypeMicrosoftAzureMonitorWebtestLocationAvailabilityCriteria', 'OdataTypeMicrosoftAzureMonitorMultipleResourceMultipleMetricCriteria'
OdataType OdataType `json:"odata.type,omitempty"`
}
// MarshalJSON is the custom marshaler for AlertSingleResourceMultipleMetricCriteria.
func (asrmmc AlertSingleResourceMultipleMetricCriteria) MarshalJSON() ([]byte, error) {
asrmmc.OdataType = OdataTypeMicrosoftAzureMonitorSingleResourceMultipleMetricCriteria
objectMap := make(map[string]interface{})
if asrmmc.AllOf != nil {
objectMap["allOf"] = asrmmc.AllOf
}
if asrmmc.OdataType != "" {
objectMap["odata.type"] = asrmmc.OdataType
}
for k, v := range asrmmc.AdditionalProperties {
objectMap[k] = v
}
return json.Marshal(objectMap)
}
// AsAlertSingleResourceMultipleMetricCriteria is the BasicAlertCriteria implementation for AlertSingleResourceMultipleMetricCriteria.
func (asrmmc AlertSingleResourceMultipleMetricCriteria) AsAlertSingleResourceMultipleMetricCriteria() (*AlertSingleResourceMultipleMetricCriteria, bool) {
return &asrmmc, true
}
// AsWebtestLocationAvailabilityCriteria is the BasicAlertCriteria implementation for AlertSingleResourceMultipleMetricCriteria.
func (asrmmc AlertSingleResourceMultipleMetricCriteria) AsWebtestLocationAvailabilityCriteria() (*WebtestLocationAvailabilityCriteria, bool) {
return nil, false
}
// AsAlertMultipleResourceMultipleMetricCriteria is the BasicAlertCriteria implementation for AlertSingleResourceMultipleMetricCriteria.
func (asrmmc AlertSingleResourceMultipleMetricCriteria) AsAlertMultipleResourceMultipleMetricCriteria() (*AlertMultipleResourceMultipleMetricCriteria, bool) {
return nil, false
}
// AsAlertCriteria is the BasicAlertCriteria implementation for AlertSingleResourceMultipleMetricCriteria.
func (asrmmc AlertSingleResourceMultipleMetricCriteria) AsAlertCriteria() (*AlertCriteria, bool) {
return nil, false
}
// AsBasicAlertCriteria is the BasicAlertCriteria implementation for AlertSingleResourceMultipleMetricCriteria.
func (asrmmc AlertSingleResourceMultipleMetricCriteria) AsBasicAlertCriteria() (BasicAlertCriteria, bool) {
return &asrmmc, true
}
// UnmarshalJSON is the custom unmarshaler for AlertSingleResourceMultipleMetricCriteria struct.
func (asrmmc *AlertSingleResourceMultipleMetricCriteria) 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 "allOf":
if v != nil {
var allOf []Criteria
err = json.Unmarshal(*v, &allOf)
if err != nil {
return err
}
asrmmc.AllOf = &allOf
}
default:
if v != nil {
var additionalProperties interface{}
err = json.Unmarshal(*v, &additionalProperties)
if err != nil {
return err
}
if asrmmc.AdditionalProperties == nil {
asrmmc.AdditionalProperties = make(map[string]interface{})
}
asrmmc.AdditionalProperties[k] = additionalProperties
}
case "odata.type":
if v != nil {
var odataType OdataType
err = json.Unmarshal(*v, &odataType)
if err != nil {
return err
}
asrmmc.OdataType = odataType
}
}
}
return nil
}
// AlertStatus an alert status.
type AlertStatus struct {
// Name - The status name.
Name *string `json:"name,omitempty"`
// ID - The alert rule arm id.
ID *string `json:"id,omitempty"`
// Type - The extended resource type name.
Type *string `json:"type,omitempty"`
// Properties - The alert status properties of the metric alert status.
Properties *AlertStatusProperties `json:"properties,omitempty"`
}
// AlertStatusCollection represents a collection of alert rule resources.
type AlertStatusCollection struct {
autorest.Response `json:"-"`
// Value - the values for the alert rule resources.
Value *[]AlertStatus `json:"value,omitempty"`
}
// AlertStatusProperties an alert status properties.
type AlertStatusProperties struct {
// Dimensions - An object describing the type of the dimensions.
Dimensions map[string]*string `json:"dimensions"`
// Status - status value
Status *string `json:"status,omitempty"`
// Timestamp - UTC time when the status was checked.
Timestamp *date.Time `json:"timestamp,omitempty"`
}
// MarshalJSON is the custom marshaler for AlertStatusProperties.
func (asp AlertStatusProperties) MarshalJSON() ([]byte, error) {
objectMap := make(map[string]interface{})
if asp.Dimensions != nil {
objectMap["dimensions"] = asp.Dimensions
}
if asp.Status != nil {
objectMap["status"] = asp.Status
}
if asp.Timestamp != nil {
objectMap["timestamp"] = asp.Timestamp
}
return json.Marshal(objectMap)
}
// Availability metric availability specifies the time grain (aggregation interval or frequency) and the
// retention period for that time grain.
type Availability struct {
// TimeGrain - the time grain specifies the aggregation interval for the metric. Expressed as a duration 'PT1M', 'P1D', etc.
TimeGrain *string `json:"timeGrain,omitempty"`
// Retention - the retention period for the metric at the specified timegrain. Expressed as a duration 'PT1M', 'P1D', etc.
Retention *string `json:"retention,omitempty"`
}
// BaselineMetadata represents a baseline metadata value.
type BaselineMetadata struct {
// Name - Name of the baseline metadata.
Name *string `json:"name,omitempty"`
// Value - Value of the baseline metadata.
Value *string `json:"value,omitempty"`
}
// BaselinesProperties the response to a metric baselines query.
type BaselinesProperties struct {
// Timespan - The timespan for which the data was retrieved. Its value consists of two datetimes concatenated, separated by '/'. This may be adjusted in the future and returned back from what was originally requested.
Timespan *string `json:"timespan,omitempty"`
// Interval - The interval (window size) for which the metric data was returned in. This may be adjusted in the future and returned back from what was originally requested. This is not present if a metadata request was made.
Interval *string `json:"interval,omitempty"`
// Namespace - The namespace of the metrics been queried.
Namespace *string `json:"namespace,omitempty"`
// Baselines - The baseline for each time series that was queried.
Baselines *[]TimeSeriesBaseline `json:"baselines,omitempty"`
}
// BaselinesResponse a list of metric baselines.
type BaselinesResponse struct {
autorest.Response `json:"-"`
// Value - The list of metric baselines.
Value *[]SingleMetricBaseline `json:"value,omitempty"`