forked from Azure/azure-sdk-for-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
models.go
1256 lines (1137 loc) · 43.7 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 alertsmanagement
// 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 (
"context"
"encoding/json"
"github.com/Azure/go-autorest/autorest"
"github.com/Azure/go-autorest/autorest/date"
"github.com/Azure/go-autorest/autorest/to"
"github.com/Azure/go-autorest/tracing"
"net/http"
)
// The package's fully qualified name.
const fqdn = "github.com/Azure/azure-sdk-for-go/services/alertsmanagement/mgmt/2019-03-01/alertsmanagement"
// ActionGroupsInformation the Action Groups information, used by the alert rule.
type ActionGroupsInformation struct {
// CustomEmailSubject - An optional custom email subject to use in email notifications.
CustomEmailSubject *string `json:"customEmailSubject,omitempty"`
// CustomWebhookPayload - An optional custom web-hook payload to use in web-hook notifications.
CustomWebhookPayload *string `json:"customWebhookPayload,omitempty"`
// GroupIds - The Action Group resource IDs.
GroupIds *[]string `json:"groupIds,omitempty"`
}
// Alert an alert created in alert management service.
type Alert struct {
autorest.Response `json:"-"`
Properties *AlertProperties `json:"properties,omitempty"`
// ID - READ-ONLY; Azure resource Id
ID *string `json:"id,omitempty"`
// Type - READ-ONLY; Azure resource type
Type *string `json:"type,omitempty"`
// Name - READ-ONLY; Azure resource name
Name *string `json:"name,omitempty"`
}
// MarshalJSON is the custom marshaler for Alert.
func (a Alert) MarshalJSON() ([]byte, error) {
objectMap := make(map[string]interface{})
if a.Properties != nil {
objectMap["properties"] = a.Properties
}
return json.Marshal(objectMap)
}
// AlertModification alert Modification details
type AlertModification struct {
autorest.Response `json:"-"`
Properties *AlertModificationProperties `json:"properties,omitempty"`
// ID - READ-ONLY; Azure resource Id
ID *string `json:"id,omitempty"`
// Type - READ-ONLY; Azure resource type
Type *string `json:"type,omitempty"`
// Name - READ-ONLY; Azure resource name
Name *string `json:"name,omitempty"`
}
// MarshalJSON is the custom marshaler for AlertModification.
func (am AlertModification) MarshalJSON() ([]byte, error) {
objectMap := make(map[string]interface{})
if am.Properties != nil {
objectMap["properties"] = am.Properties
}
return json.Marshal(objectMap)
}
// AlertModificationItem alert modification item.
type AlertModificationItem struct {
// ModificationEvent - Reason for the modification. Possible values include: 'AlertCreated', 'StateChange', 'MonitorConditionChange'
ModificationEvent AlertModificationEvent `json:"modificationEvent,omitempty"`
// OldValue - Old value
OldValue *string `json:"oldValue,omitempty"`
// NewValue - New value
NewValue *string `json:"newValue,omitempty"`
// ModifiedAt - Modified date and time
ModifiedAt *string `json:"modifiedAt,omitempty"`
// ModifiedBy - Modified user details (Principal client name)
ModifiedBy *string `json:"modifiedBy,omitempty"`
// Comments - Modification comments
Comments *string `json:"comments,omitempty"`
// Description - Description of the modification
Description *string `json:"description,omitempty"`
}
// AlertModificationProperties properties of the alert modification item.
type AlertModificationProperties struct {
// AlertID - READ-ONLY; Unique Id of the alert for which the history is being retrieved
AlertID *string `json:"alertId,omitempty"`
// Modifications - Modification details
Modifications *[]AlertModificationItem `json:"modifications,omitempty"`
}
// MarshalJSON is the custom marshaler for AlertModificationProperties.
func (amp AlertModificationProperties) MarshalJSON() ([]byte, error) {
objectMap := make(map[string]interface{})
if amp.Modifications != nil {
objectMap["modifications"] = amp.Modifications
}
return json.Marshal(objectMap)
}
// AlertProperties alert property bag
type AlertProperties struct {
Essentials *Essentials `json:"essentials,omitempty"`
Context interface{} `json:"context,omitempty"`
EgressConfig interface{} `json:"egressConfig,omitempty"`
}
// AlertRule the alert rule information
type AlertRule struct {
autorest.Response `json:"-"`
// AlertRuleProperties - The properties of the alert rule.
*AlertRuleProperties `json:"properties,omitempty"`
// ID - READ-ONLY; The resource ID.
ID *string `json:"id,omitempty"`
// Type - READ-ONLY; The resource type.
Type *string `json:"type,omitempty"`
// Name - READ-ONLY; The resource name.
Name *string `json:"name,omitempty"`
}
// MarshalJSON is the custom marshaler for AlertRule.
func (ar AlertRule) MarshalJSON() ([]byte, error) {
objectMap := make(map[string]interface{})
if ar.AlertRuleProperties != nil {
objectMap["properties"] = ar.AlertRuleProperties
}
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 "properties":
if v != nil {
var alertRuleProperties AlertRuleProperties
err = json.Unmarshal(*v, &alertRuleProperties)
if err != nil {
return err
}
ar.AlertRuleProperties = &alertRuleProperties
}
case "id":
if v != nil {
var ID string
err = json.Unmarshal(*v, &ID)
if err != nil {
return err
}
ar.ID = &ID
}
case "type":
if v != nil {
var typeVar string
err = json.Unmarshal(*v, &typeVar)
if err != nil {
return err
}
ar.Type = &typeVar
}
case "name":
if v != nil {
var name string
err = json.Unmarshal(*v, &name)
if err != nil {
return err
}
ar.Name = &name
}
}
}
return nil
}
// AlertRuleProperties the alert rule properties.
type AlertRuleProperties struct {
// Description - The alert rule description.
Description *string `json:"description,omitempty"`
// State - The alert rule state. Possible values include: 'Enabled', 'Disabled'
State AlertRuleState `json:"state,omitempty"`
// Severity - The alert rule severity. Possible values include: 'Sev0', 'Sev1', 'Sev2', 'Sev3', 'Sev4'
Severity Severity `json:"severity,omitempty"`
// Frequency - The alert rule frequency in ISO8601 format. The time granularity must be in minutes and minimum value is 5 minutes.
Frequency *string `json:"frequency,omitempty"`
// Detector - The alert rule's detector.
Detector *Detector `json:"detector,omitempty"`
// Scope - The alert rule resources scope.
Scope *[]string `json:"scope,omitempty"`
// ActionGroups - The alert rule actions.
ActionGroups *ActionGroupsInformation `json:"actionGroups,omitempty"`
// Throttling - The alert rule throttling information.
Throttling *ThrottlingInformation `json:"throttling,omitempty"`
}
// AlertRulesList list of Smart Detector alert rules.
type AlertRulesList struct {
autorest.Response `json:"-"`
// Value - List of Smart Detector alert rules.
Value *[]AlertRule `json:"value,omitempty"`
// NextLink - The URL to get the next set of results.
NextLink *string `json:"nextLink,omitempty"`
}
// AlertRulesListIterator provides access to a complete listing of AlertRule values.
type AlertRulesListIterator struct {
i int
page AlertRulesListPage
}
// NextWithContext advances to the next value. If there was an error making
// the request the iterator does not advance and the error is returned.
func (iter *AlertRulesListIterator) NextWithContext(ctx context.Context) (err error) {
if tracing.IsEnabled() {
ctx = tracing.StartSpan(ctx, fqdn+"/AlertRulesListIterator.NextWithContext")
defer func() {
sc := -1
if iter.Response().Response.Response != nil {
sc = iter.Response().Response.Response.StatusCode
}
tracing.EndSpan(ctx, sc, err)
}()
}
iter.i++
if iter.i < len(iter.page.Values()) {
return nil
}
err = iter.page.NextWithContext(ctx)
if err != nil {
iter.i--
return err
}
iter.i = 0
return nil
}
// Next advances to the next value. If there was an error making
// the request the iterator does not advance and the error is returned.
// Deprecated: Use NextWithContext() instead.
func (iter *AlertRulesListIterator) Next() error {
return iter.NextWithContext(context.Background())
}
// NotDone returns true if the enumeration should be started or is not yet complete.
func (iter AlertRulesListIterator) NotDone() bool {
return iter.page.NotDone() && iter.i < len(iter.page.Values())
}
// Response returns the raw server response from the last page request.
func (iter AlertRulesListIterator) Response() AlertRulesList {
return iter.page.Response()
}
// Value returns the current value or a zero-initialized value if the
// iterator has advanced beyond the end of the collection.
func (iter AlertRulesListIterator) Value() AlertRule {
if !iter.page.NotDone() {
return AlertRule{}
}
return iter.page.Values()[iter.i]
}
// Creates a new instance of the AlertRulesListIterator type.
func NewAlertRulesListIterator(page AlertRulesListPage) AlertRulesListIterator {
return AlertRulesListIterator{page: page}
}
// IsEmpty returns true if the ListResult contains no values.
func (arl AlertRulesList) IsEmpty() bool {
return arl.Value == nil || len(*arl.Value) == 0
}
// hasNextLink returns true if the NextLink is not empty.
func (arl AlertRulesList) hasNextLink() bool {
return arl.NextLink != nil && len(*arl.NextLink) != 0
}
// alertRulesListPreparer prepares a request to retrieve the next set of results.
// It returns nil if no more results exist.
func (arl AlertRulesList) alertRulesListPreparer(ctx context.Context) (*http.Request, error) {
if !arl.hasNextLink() {
return nil, nil
}
return autorest.Prepare((&http.Request{}).WithContext(ctx),
autorest.AsJSON(),
autorest.AsGet(),
autorest.WithBaseURL(to.String(arl.NextLink)))
}
// AlertRulesListPage contains a page of AlertRule values.
type AlertRulesListPage struct {
fn func(context.Context, AlertRulesList) (AlertRulesList, error)
arl AlertRulesList
}
// NextWithContext advances to the next page of values. If there was an error making
// the request the page does not advance and the error is returned.
func (page *AlertRulesListPage) NextWithContext(ctx context.Context) (err error) {
if tracing.IsEnabled() {
ctx = tracing.StartSpan(ctx, fqdn+"/AlertRulesListPage.NextWithContext")
defer func() {
sc := -1
if page.Response().Response.Response != nil {
sc = page.Response().Response.Response.StatusCode
}
tracing.EndSpan(ctx, sc, err)
}()
}
for {
next, err := page.fn(ctx, page.arl)
if err != nil {
return err
}
page.arl = next
if !next.hasNextLink() || !next.IsEmpty() {
break
}
}
return nil
}
// Next advances to the next page of values. If there was an error making
// the request the page does not advance and the error is returned.
// Deprecated: Use NextWithContext() instead.
func (page *AlertRulesListPage) Next() error {
return page.NextWithContext(context.Background())
}
// NotDone returns true if the page enumeration should be started or is not yet complete.
func (page AlertRulesListPage) NotDone() bool {
return !page.arl.IsEmpty()
}
// Response returns the raw server response from the last page request.
func (page AlertRulesListPage) Response() AlertRulesList {
return page.arl
}
// Values returns the slice of values for the current page or nil if there are no values.
func (page AlertRulesListPage) Values() []AlertRule {
if page.arl.IsEmpty() {
return nil
}
return *page.arl.Value
}
// Creates a new instance of the AlertRulesListPage type.
func NewAlertRulesListPage(cur AlertRulesList, getNextPage func(context.Context, AlertRulesList) (AlertRulesList, error)) AlertRulesListPage {
return AlertRulesListPage{
fn: getNextPage,
arl: cur,
}
}
// AlertsList list the alerts.
type AlertsList struct {
autorest.Response `json:"-"`
// NextLink - URL to fetch the next set of alerts.
NextLink *string `json:"nextLink,omitempty"`
// Value - List of alerts
Value *[]Alert `json:"value,omitempty"`
}
// AlertsListIterator provides access to a complete listing of Alert values.
type AlertsListIterator struct {
i int
page AlertsListPage
}
// NextWithContext advances to the next value. If there was an error making
// the request the iterator does not advance and the error is returned.
func (iter *AlertsListIterator) NextWithContext(ctx context.Context) (err error) {
if tracing.IsEnabled() {
ctx = tracing.StartSpan(ctx, fqdn+"/AlertsListIterator.NextWithContext")
defer func() {
sc := -1
if iter.Response().Response.Response != nil {
sc = iter.Response().Response.Response.StatusCode
}
tracing.EndSpan(ctx, sc, err)
}()
}
iter.i++
if iter.i < len(iter.page.Values()) {
return nil
}
err = iter.page.NextWithContext(ctx)
if err != nil {
iter.i--
return err
}
iter.i = 0
return nil
}
// Next advances to the next value. If there was an error making
// the request the iterator does not advance and the error is returned.
// Deprecated: Use NextWithContext() instead.
func (iter *AlertsListIterator) Next() error {
return iter.NextWithContext(context.Background())
}
// NotDone returns true if the enumeration should be started or is not yet complete.
func (iter AlertsListIterator) NotDone() bool {
return iter.page.NotDone() && iter.i < len(iter.page.Values())
}
// Response returns the raw server response from the last page request.
func (iter AlertsListIterator) Response() AlertsList {
return iter.page.Response()
}
// Value returns the current value or a zero-initialized value if the
// iterator has advanced beyond the end of the collection.
func (iter AlertsListIterator) Value() Alert {
if !iter.page.NotDone() {
return Alert{}
}
return iter.page.Values()[iter.i]
}
// Creates a new instance of the AlertsListIterator type.
func NewAlertsListIterator(page AlertsListPage) AlertsListIterator {
return AlertsListIterator{page: page}
}
// IsEmpty returns true if the ListResult contains no values.
func (al AlertsList) IsEmpty() bool {
return al.Value == nil || len(*al.Value) == 0
}
// hasNextLink returns true if the NextLink is not empty.
func (al AlertsList) hasNextLink() bool {
return al.NextLink != nil && len(*al.NextLink) != 0
}
// alertsListPreparer prepares a request to retrieve the next set of results.
// It returns nil if no more results exist.
func (al AlertsList) alertsListPreparer(ctx context.Context) (*http.Request, error) {
if !al.hasNextLink() {
return nil, nil
}
return autorest.Prepare((&http.Request{}).WithContext(ctx),
autorest.AsJSON(),
autorest.AsGet(),
autorest.WithBaseURL(to.String(al.NextLink)))
}
// AlertsListPage contains a page of Alert values.
type AlertsListPage struct {
fn func(context.Context, AlertsList) (AlertsList, error)
al AlertsList
}
// NextWithContext advances to the next page of values. If there was an error making
// the request the page does not advance and the error is returned.
func (page *AlertsListPage) NextWithContext(ctx context.Context) (err error) {
if tracing.IsEnabled() {
ctx = tracing.StartSpan(ctx, fqdn+"/AlertsListPage.NextWithContext")
defer func() {
sc := -1
if page.Response().Response.Response != nil {
sc = page.Response().Response.Response.StatusCode
}
tracing.EndSpan(ctx, sc, err)
}()
}
for {
next, err := page.fn(ctx, page.al)
if err != nil {
return err
}
page.al = next
if !next.hasNextLink() || !next.IsEmpty() {
break
}
}
return nil
}
// Next advances to the next page of values. If there was an error making
// the request the page does not advance and the error is returned.
// Deprecated: Use NextWithContext() instead.
func (page *AlertsListPage) Next() error {
return page.NextWithContext(context.Background())
}
// NotDone returns true if the page enumeration should be started or is not yet complete.
func (page AlertsListPage) NotDone() bool {
return !page.al.IsEmpty()
}
// Response returns the raw server response from the last page request.
func (page AlertsListPage) Response() AlertsList {
return page.al
}
// Values returns the slice of values for the current page or nil if there are no values.
func (page AlertsListPage) Values() []Alert {
if page.al.IsEmpty() {
return nil
}
return *page.al.Value
}
// Creates a new instance of the AlertsListPage type.
func NewAlertsListPage(cur AlertsList, getNextPage func(context.Context, AlertsList) (AlertsList, error)) AlertsListPage {
return AlertsListPage{
fn: getNextPage,
al: cur,
}
}
// AlertsMetaData alert meta data information.
type AlertsMetaData struct {
autorest.Response `json:"-"`
Properties BasicAlertsMetaDataProperties `json:"properties,omitempty"`
}
// UnmarshalJSON is the custom unmarshaler for AlertsMetaData struct.
func (amd *AlertsMetaData) 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 {
properties, err := unmarshalBasicAlertsMetaDataProperties(*v)
if err != nil {
return err
}
amd.Properties = properties
}
}
}
return nil
}
// BasicAlertsMetaDataProperties alert meta data property bag
type BasicAlertsMetaDataProperties interface {
AsMonitorServiceList() (*MonitorServiceList, bool)
AsAlertsMetaDataProperties() (*AlertsMetaDataProperties, bool)
}
// AlertsMetaDataProperties alert meta data property bag
type AlertsMetaDataProperties struct {
// MetadataIdentifier - Possible values include: 'MetadataIdentifierAlertsMetaDataProperties', 'MetadataIdentifierMonitorServiceList'
MetadataIdentifier MetadataIdentifier `json:"metadataIdentifier,omitempty"`
}
func unmarshalBasicAlertsMetaDataProperties(body []byte) (BasicAlertsMetaDataProperties, error) {
var m map[string]interface{}
err := json.Unmarshal(body, &m)
if err != nil {
return nil, err
}
switch m["metadataIdentifier"] {
case string(MetadataIdentifierMonitorServiceList):
var msl MonitorServiceList
err := json.Unmarshal(body, &msl)
return msl, err
default:
var amdp AlertsMetaDataProperties
err := json.Unmarshal(body, &amdp)
return amdp, err
}
}
func unmarshalBasicAlertsMetaDataPropertiesArray(body []byte) ([]BasicAlertsMetaDataProperties, error) {
var rawMessages []*json.RawMessage
err := json.Unmarshal(body, &rawMessages)
if err != nil {
return nil, err
}
amdpArray := make([]BasicAlertsMetaDataProperties, len(rawMessages))
for index, rawMessage := range rawMessages {
amdp, err := unmarshalBasicAlertsMetaDataProperties(*rawMessage)
if err != nil {
return nil, err
}
amdpArray[index] = amdp
}
return amdpArray, nil
}
// MarshalJSON is the custom marshaler for AlertsMetaDataProperties.
func (amdp AlertsMetaDataProperties) MarshalJSON() ([]byte, error) {
amdp.MetadataIdentifier = MetadataIdentifierAlertsMetaDataProperties
objectMap := make(map[string]interface{})
if amdp.MetadataIdentifier != "" {
objectMap["metadataIdentifier"] = amdp.MetadataIdentifier
}
return json.Marshal(objectMap)
}
// AsMonitorServiceList is the BasicAlertsMetaDataProperties implementation for AlertsMetaDataProperties.
func (amdp AlertsMetaDataProperties) AsMonitorServiceList() (*MonitorServiceList, bool) {
return nil, false
}
// AsAlertsMetaDataProperties is the BasicAlertsMetaDataProperties implementation for AlertsMetaDataProperties.
func (amdp AlertsMetaDataProperties) AsAlertsMetaDataProperties() (*AlertsMetaDataProperties, bool) {
return &amdp, true
}
// AsBasicAlertsMetaDataProperties is the BasicAlertsMetaDataProperties implementation for AlertsMetaDataProperties.
func (amdp AlertsMetaDataProperties) AsBasicAlertsMetaDataProperties() (BasicAlertsMetaDataProperties, bool) {
return &amdp, true
}
// AlertsSummary summary of alerts based on the input filters and 'groupby' parameters.
type AlertsSummary struct {
autorest.Response `json:"-"`
Properties *AlertsSummaryGroup `json:"properties,omitempty"`
// ID - READ-ONLY; Azure resource Id
ID *string `json:"id,omitempty"`
// Type - READ-ONLY; Azure resource type
Type *string `json:"type,omitempty"`
// Name - READ-ONLY; Azure resource name
Name *string `json:"name,omitempty"`
}
// MarshalJSON is the custom marshaler for AlertsSummary.
func (as AlertsSummary) MarshalJSON() ([]byte, error) {
objectMap := make(map[string]interface{})
if as.Properties != nil {
objectMap["properties"] = as.Properties
}
return json.Marshal(objectMap)
}
// AlertsSummaryGroup group the result set.
type AlertsSummaryGroup struct {
// Total - Total count of the result set.
Total *int32 `json:"total,omitempty"`
// SmartGroupsCount - Total count of the smart groups.
SmartGroupsCount *int32 `json:"smartGroupsCount,omitempty"`
// Groupedby - Name of the field aggregated
Groupedby *string `json:"groupedby,omitempty"`
// Values - List of the items
Values *[]AlertsSummaryGroupItem `json:"values,omitempty"`
}
// AlertsSummaryGroupItem alerts summary group item
type AlertsSummaryGroupItem struct {
// Name - Value of the aggregated field
Name *string `json:"name,omitempty"`
// Count - Count of the aggregated field
Count *int32 `json:"count,omitempty"`
// Groupedby - Name of the field aggregated
Groupedby *string `json:"groupedby,omitempty"`
// Values - List of the items
Values *[]AlertsSummaryGroupItem `json:"values,omitempty"`
}
// AzureResource an Azure resource object
type AzureResource struct {
// ID - READ-ONLY; The resource ID.
ID *string `json:"id,omitempty"`
// Type - READ-ONLY; The resource type.
Type *string `json:"type,omitempty"`
// Name - READ-ONLY; The resource name.
Name *string `json:"name,omitempty"`
}
// Detector the detector information. By default this is not populated, unless it's specified in
// expandDetector
type Detector struct {
// ID - The detector id.
ID *string `json:"id,omitempty"`
// Parameters - The detector's parameters.'
Parameters map[string]interface{} `json:"parameters"`
// Name - The Smart Detector name. By default this is not populated, unless it's specified in expandDetector
Name *string `json:"name,omitempty"`
// Description - The Smart Detector description. By default this is not populated, unless it's specified in expandDetector
Description *string `json:"description,omitempty"`
// SupportedResourceTypes - The Smart Detector supported resource types. By default this is not populated, unless it's specified in expandDetector
SupportedResourceTypes *[]string `json:"supportedResourceTypes,omitempty"`
// ImagePaths - The Smart Detector image path. By default this is not populated, unless it's specified in expandDetector
ImagePaths *[]string `json:"imagePaths,omitempty"`
}
// MarshalJSON is the custom marshaler for Detector.
func (d Detector) MarshalJSON() ([]byte, error) {
objectMap := make(map[string]interface{})
if d.ID != nil {
objectMap["id"] = d.ID
}
if d.Parameters != nil {
objectMap["parameters"] = d.Parameters
}
if d.Name != nil {
objectMap["name"] = d.Name
}
if d.Description != nil {
objectMap["description"] = d.Description
}
if d.SupportedResourceTypes != nil {
objectMap["supportedResourceTypes"] = d.SupportedResourceTypes
}
if d.ImagePaths != nil {
objectMap["imagePaths"] = d.ImagePaths
}
return json.Marshal(objectMap)
}
// ErrorResponse an error response from the service.
type ErrorResponse struct {
Error *ErrorResponseBody `json:"error,omitempty"`
}
// ErrorResponseBody details of error response.
type ErrorResponseBody struct {
// Code - Error code, intended to be consumed programmatically.
Code *string `json:"code,omitempty"`
// Message - Description of the error, intended for display in user interface.
Message *string `json:"message,omitempty"`
// Target - Target of the particular error, for example name of the property.
Target *string `json:"target,omitempty"`
// Details - A list of additional details about the error.
Details *[]ErrorResponseBody `json:"details,omitempty"`
}
// Essentials this object contains consistent fields across different monitor services.
type Essentials struct {
// Severity - READ-ONLY; Severity of alert Sev0 being highest and Sev4 being lowest. Possible values include: 'Sev0', 'Sev1', 'Sev2', 'Sev3', 'Sev4'
Severity Severity `json:"severity,omitempty"`
// SignalType - READ-ONLY; The type of signal the alert is based on, which could be metrics, logs or activity logs. Possible values include: 'Metric', 'Log', 'Unknown'
SignalType SignalType `json:"signalType,omitempty"`
// AlertState - READ-ONLY; Alert object state, which can be modified by the user. Possible values include: 'AlertStateNew', 'AlertStateAcknowledged', 'AlertStateClosed'
AlertState AlertState `json:"alertState,omitempty"`
// MonitorCondition - READ-ONLY; Can be 'Fired' or 'Resolved', which represents whether the underlying conditions have crossed the defined alert rule thresholds. Possible values include: 'Fired', 'Resolved'
MonitorCondition MonitorCondition `json:"monitorCondition,omitempty"`
// TargetResource - Target ARM resource, on which alert got created.
TargetResource *string `json:"targetResource,omitempty"`
// TargetResourceName - Name of the target ARM resource name, on which alert got created.
TargetResourceName *string `json:"targetResourceName,omitempty"`
// TargetResourceGroup - Resource group of target ARM resource, on which alert got created.
TargetResourceGroup *string `json:"targetResourceGroup,omitempty"`
// TargetResourceType - Resource type of target ARM resource, on which alert got created.
TargetResourceType *string `json:"targetResourceType,omitempty"`
// MonitorService - READ-ONLY; Monitor service on which the rule(monitor) is set. Possible values include: 'ApplicationInsights', 'ActivityLogAdministrative', 'ActivityLogSecurity', 'ActivityLogRecommendation', 'ActivityLogPolicy', 'ActivityLogAutoscale', 'LogAnalytics', 'Nagios', 'Platform', 'SCOM', 'ServiceHealth', 'SmartDetector', 'VMInsights', 'Zabbix', 'ResourceHealth'
MonitorService MonitorService `json:"monitorService,omitempty"`
// AlertRule - READ-ONLY; Rule(monitor) which fired alert instance. Depending on the monitor service, this would be ARM id or name of the rule.
AlertRule *string `json:"alertRule,omitempty"`
// SourceCreatedID - READ-ONLY; Unique Id created by monitor service for each alert instance. This could be used to track the issue at the monitor service, in case of Nagios, Zabbix, SCOM etc.
SourceCreatedID *string `json:"sourceCreatedId,omitempty"`
// SmartGroupID - READ-ONLY; Unique Id of the smart group
SmartGroupID *string `json:"smartGroupId,omitempty"`
// SmartGroupingReason - READ-ONLY; Verbose reason describing the reason why this alert instance is added to a smart group
SmartGroupingReason *string `json:"smartGroupingReason,omitempty"`
// StartDateTime - READ-ONLY; Creation time(ISO-8601 format) of alert instance.
StartDateTime *date.Time `json:"startDateTime,omitempty"`
// LastModifiedDateTime - READ-ONLY; Last modification time(ISO-8601 format) of alert instance.
LastModifiedDateTime *date.Time `json:"lastModifiedDateTime,omitempty"`
// MonitorConditionResolvedDateTime - READ-ONLY; Resolved time(ISO-8601 format) of alert instance. This will be updated when monitor service resolves the alert instance because the rule condition is no longer met.
MonitorConditionResolvedDateTime *date.Time `json:"monitorConditionResolvedDateTime,omitempty"`
// LastModifiedUserName - READ-ONLY; User who last modified the alert, in case of monitor service updates user would be 'system', otherwise name of the user.
LastModifiedUserName *string `json:"lastModifiedUserName,omitempty"`
}
// MarshalJSON is the custom marshaler for Essentials.
func (e Essentials) MarshalJSON() ([]byte, error) {
objectMap := make(map[string]interface{})
if e.TargetResource != nil {
objectMap["targetResource"] = e.TargetResource
}
if e.TargetResourceName != nil {
objectMap["targetResourceName"] = e.TargetResourceName
}
if e.TargetResourceGroup != nil {
objectMap["targetResourceGroup"] = e.TargetResourceGroup
}
if e.TargetResourceType != nil {
objectMap["targetResourceType"] = e.TargetResourceType
}
return json.Marshal(objectMap)
}
// MonitorServiceDetails details of a monitor service
type MonitorServiceDetails struct {
// Name - Monitor service name
Name *string `json:"name,omitempty"`
// DisplayName - Monitor service display name
DisplayName *string `json:"displayName,omitempty"`
}
// MonitorServiceList monitor service details
type MonitorServiceList struct {
// Data - Array of operations
Data *[]MonitorServiceDetails `json:"data,omitempty"`
// MetadataIdentifier - Possible values include: 'MetadataIdentifierAlertsMetaDataProperties', 'MetadataIdentifierMonitorServiceList'
MetadataIdentifier MetadataIdentifier `json:"metadataIdentifier,omitempty"`
}
// MarshalJSON is the custom marshaler for MonitorServiceList.
func (msl MonitorServiceList) MarshalJSON() ([]byte, error) {
msl.MetadataIdentifier = MetadataIdentifierMonitorServiceList
objectMap := make(map[string]interface{})
if msl.Data != nil {
objectMap["data"] = msl.Data
}
if msl.MetadataIdentifier != "" {
objectMap["metadataIdentifier"] = msl.MetadataIdentifier
}
return json.Marshal(objectMap)
}
// AsMonitorServiceList is the BasicAlertsMetaDataProperties implementation for MonitorServiceList.
func (msl MonitorServiceList) AsMonitorServiceList() (*MonitorServiceList, bool) {
return &msl, true
}
// AsAlertsMetaDataProperties is the BasicAlertsMetaDataProperties implementation for MonitorServiceList.
func (msl MonitorServiceList) AsAlertsMetaDataProperties() (*AlertsMetaDataProperties, bool) {
return nil, false
}
// AsBasicAlertsMetaDataProperties is the BasicAlertsMetaDataProperties implementation for MonitorServiceList.
func (msl MonitorServiceList) AsBasicAlertsMetaDataProperties() (BasicAlertsMetaDataProperties, bool) {
return &msl, true
}
// Operation operation provided by provider
type Operation struct {
// Name - Name of the operation
Name *string `json:"name,omitempty"`
// Display - Properties of the operation
Display *OperationDisplay `json:"display,omitempty"`
}
// OperationDisplay properties of the operation
type OperationDisplay struct {
// Provider - Provider name
Provider *string `json:"provider,omitempty"`
// Resource - Resource name
Resource *string `json:"resource,omitempty"`
// Operation - Operation name
Operation *string `json:"operation,omitempty"`
// Description - Description of the operation
Description *string `json:"description,omitempty"`
}
// OperationsList lists the operations available in the AlertsManagement RP.
type OperationsList struct {
autorest.Response `json:"-"`
// NextLink - URL to fetch the next set of alerts.
NextLink *string `json:"nextLink,omitempty"`
// Value - Array of operations
Value *[]Operation `json:"value,omitempty"`
}
// OperationsListIterator provides access to a complete listing of Operation values.
type OperationsListIterator struct {
i int
page OperationsListPage
}
// NextWithContext advances to the next value. If there was an error making
// the request the iterator does not advance and the error is returned.
func (iter *OperationsListIterator) NextWithContext(ctx context.Context) (err error) {
if tracing.IsEnabled() {
ctx = tracing.StartSpan(ctx, fqdn+"/OperationsListIterator.NextWithContext")
defer func() {
sc := -1
if iter.Response().Response.Response != nil {
sc = iter.Response().Response.Response.StatusCode
}
tracing.EndSpan(ctx, sc, err)
}()
}
iter.i++
if iter.i < len(iter.page.Values()) {
return nil
}
err = iter.page.NextWithContext(ctx)
if err != nil {
iter.i--
return err
}
iter.i = 0
return nil
}
// Next advances to the next value. If there was an error making
// the request the iterator does not advance and the error is returned.
// Deprecated: Use NextWithContext() instead.
func (iter *OperationsListIterator) Next() error {
return iter.NextWithContext(context.Background())
}
// NotDone returns true if the enumeration should be started or is not yet complete.
func (iter OperationsListIterator) NotDone() bool {
return iter.page.NotDone() && iter.i < len(iter.page.Values())
}
// Response returns the raw server response from the last page request.
func (iter OperationsListIterator) Response() OperationsList {
return iter.page.Response()
}
// Value returns the current value or a zero-initialized value if the
// iterator has advanced beyond the end of the collection.
func (iter OperationsListIterator) Value() Operation {
if !iter.page.NotDone() {
return Operation{}
}
return iter.page.Values()[iter.i]
}
// Creates a new instance of the OperationsListIterator type.
func NewOperationsListIterator(page OperationsListPage) OperationsListIterator {
return OperationsListIterator{page: page}
}
// IsEmpty returns true if the ListResult contains no values.
func (ol OperationsList) IsEmpty() bool {
return ol.Value == nil || len(*ol.Value) == 0
}
// hasNextLink returns true if the NextLink is not empty.
func (ol OperationsList) hasNextLink() bool {
return ol.NextLink != nil && len(*ol.NextLink) != 0
}
// operationsListPreparer prepares a request to retrieve the next set of results.
// It returns nil if no more results exist.
func (ol OperationsList) operationsListPreparer(ctx context.Context) (*http.Request, error) {
if !ol.hasNextLink() {
return nil, nil
}
return autorest.Prepare((&http.Request{}).WithContext(ctx),
autorest.AsJSON(),
autorest.AsGet(),
autorest.WithBaseURL(to.String(ol.NextLink)))
}
// OperationsListPage contains a page of Operation values.
type OperationsListPage struct {
fn func(context.Context, OperationsList) (OperationsList, error)
ol OperationsList
}
// NextWithContext advances to the next page of values. If there was an error making
// the request the page does not advance and the error is returned.
func (page *OperationsListPage) NextWithContext(ctx context.Context) (err error) {
if tracing.IsEnabled() {
ctx = tracing.StartSpan(ctx, fqdn+"/OperationsListPage.NextWithContext")
defer func() {
sc := -1
if page.Response().Response.Response != nil {
sc = page.Response().Response.Response.StatusCode
}
tracing.EndSpan(ctx, sc, err)
}()
}
for {
next, err := page.fn(ctx, page.ol)
if err != nil {
return err
}
page.ol = next
if !next.hasNextLink() || !next.IsEmpty() {
break
}
}
return nil
}
// Next advances to the next page of values. If there was an error making
// the request the page does not advance and the error is returned.
// Deprecated: Use NextWithContext() instead.
func (page *OperationsListPage) Next() error {
return page.NextWithContext(context.Background())
}
// NotDone returns true if the page enumeration should be started or is not yet complete.
func (page OperationsListPage) NotDone() bool {
return !page.ol.IsEmpty()
}