-
Notifications
You must be signed in to change notification settings - Fork 4.5k
/
MetricAlertData.cs
160 lines (151 loc) · 10.7 KB
/
MetricAlertData.cs
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
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// <auto-generated/>
#nullable disable
using System;
using System.Collections.Generic;
using System.Linq;
using Azure.Core;
using Azure.ResourceManager.Models;
using Azure.ResourceManager.Monitor.Models;
namespace Azure.ResourceManager.Monitor
{
/// <summary>
/// A class representing the MetricAlert data model.
/// The metric alert resource.
/// </summary>
public partial class MetricAlertData : TrackedResourceData
{
/// <summary>
/// Keeps track of any properties unknown to the library.
/// <para>
/// To assign an object to the value of this property use <see cref="BinaryData.FromObjectAsJson{T}(T, System.Text.Json.JsonSerializerOptions?)"/>.
/// </para>
/// <para>
/// To assign an already formatted json string to this property use <see cref="BinaryData.FromString(string)"/>.
/// </para>
/// <para>
/// Examples:
/// <list type="bullet">
/// <item>
/// <term>BinaryData.FromObjectAsJson("foo")</term>
/// <description>Creates a payload of "foo".</description>
/// </item>
/// <item>
/// <term>BinaryData.FromString("\"foo\"")</term>
/// <description>Creates a payload of "foo".</description>
/// </item>
/// <item>
/// <term>BinaryData.FromObjectAsJson(new { key = "value" })</term>
/// <description>Creates a payload of { "key": "value" }.</description>
/// </item>
/// <item>
/// <term>BinaryData.FromString("{\"key\": \"value\"}")</term>
/// <description>Creates a payload of { "key": "value" }.</description>
/// </item>
/// </list>
/// </para>
/// </summary>
private IDictionary<string, BinaryData> _serializedAdditionalRawData;
/// <summary> Initializes a new instance of <see cref="MetricAlertData"/>. </summary>
/// <param name="location"> The location. </param>
/// <param name="severity"> Alert severity {0, 1, 2, 3, 4}. </param>
/// <param name="isEnabled"> the flag that indicates whether the metric alert is enabled. </param>
/// <param name="scopes"> the list of resource id's that this metric alert is scoped to. </param>
/// <param name="evaluationFrequency"> how often the metric alert is evaluated represented in ISO 8601 duration format. </param>
/// <param name="windowSize"> the period of time (in ISO 8601 duration format) that is used to monitor alert activity based on the threshold. </param>
/// <param name="criteria">
/// defines the specific alert criteria information.
/// Please note <see cref="MetricAlertCriteria"/> is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes.
/// The available derived classes include <see cref="MetricAlertMultipleResourceMultipleMetricCriteria"/>, <see cref="MetricAlertSingleResourceMultipleMetricCriteria"/> and <see cref="WebtestLocationAvailabilityCriteria"/>.
/// </param>
/// <exception cref="ArgumentNullException"> <paramref name="scopes"/> is null. </exception>
public MetricAlertData(AzureLocation location, int severity, bool isEnabled, IEnumerable<string> scopes, TimeSpan evaluationFrequency, TimeSpan windowSize, MetricAlertCriteria criteria) : base(location)
{
Argument.AssertNotNull(scopes, nameof(scopes));
Severity = severity;
IsEnabled = isEnabled;
Scopes = scopes.ToList();
EvaluationFrequency = evaluationFrequency;
WindowSize = windowSize;
Criteria = criteria;
Actions = new ChangeTrackingList<MetricAlertAction>();
}
/// <summary> Initializes a new instance of <see cref="MetricAlertData"/>. </summary>
/// <param name="id"> The id. </param>
/// <param name="name"> The name. </param>
/// <param name="resourceType"> The resourceType. </param>
/// <param name="systemData"> The systemData. </param>
/// <param name="tags"> The tags. </param>
/// <param name="location"> The location. </param>
/// <param name="description"> the description of the metric alert that will be included in the alert email. </param>
/// <param name="severity"> Alert severity {0, 1, 2, 3, 4}. </param>
/// <param name="isEnabled"> the flag that indicates whether the metric alert is enabled. </param>
/// <param name="scopes"> the list of resource id's that this metric alert is scoped to. </param>
/// <param name="evaluationFrequency"> how often the metric alert is evaluated represented in ISO 8601 duration format. </param>
/// <param name="windowSize"> the period of time (in ISO 8601 duration format) that is used to monitor alert activity based on the threshold. </param>
/// <param name="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. </param>
/// <param name="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. </param>
/// <param name="criteria">
/// defines the specific alert criteria information.
/// Please note <see cref="MetricAlertCriteria"/> is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes.
/// The available derived classes include <see cref="MetricAlertMultipleResourceMultipleMetricCriteria"/>, <see cref="MetricAlertSingleResourceMultipleMetricCriteria"/> and <see cref="WebtestLocationAvailabilityCriteria"/>.
/// </param>
/// <param name="isAutoMitigateEnabled"> the flag that indicates whether the alert should be auto resolved or not. The default is true. </param>
/// <param name="actions"> the array of actions that are performed when the alert rule becomes active, and when an alert condition is resolved. </param>
/// <param name="lastUpdatedOn"> Last time the rule was updated in ISO8601 format. </param>
/// <param name="isMigrated"> the value indicating whether this alert rule is migrated. </param>
/// <param name="serializedAdditionalRawData"> Keeps track of any properties unknown to the library. </param>
internal MetricAlertData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, IDictionary<string, string> tags, AzureLocation location, string description, int severity, bool isEnabled, IList<string> scopes, TimeSpan evaluationFrequency, TimeSpan windowSize, ResourceType? targetResourceType, AzureLocation? targetResourceRegion, MetricAlertCriteria criteria, bool? isAutoMitigateEnabled, IList<MetricAlertAction> actions, DateTimeOffset? lastUpdatedOn, bool? isMigrated, IDictionary<string, BinaryData> serializedAdditionalRawData) : base(id, name, resourceType, systemData, tags, location)
{
Description = description;
Severity = severity;
IsEnabled = isEnabled;
Scopes = scopes;
EvaluationFrequency = evaluationFrequency;
WindowSize = windowSize;
TargetResourceType = targetResourceType;
TargetResourceRegion = targetResourceRegion;
Criteria = criteria;
IsAutoMitigateEnabled = isAutoMitigateEnabled;
Actions = actions;
LastUpdatedOn = lastUpdatedOn;
IsMigrated = isMigrated;
_serializedAdditionalRawData = serializedAdditionalRawData;
}
/// <summary> Initializes a new instance of <see cref="MetricAlertData"/> for deserialization. </summary>
internal MetricAlertData()
{
}
/// <summary> the description of the metric alert that will be included in the alert email. </summary>
public string Description { get; set; }
/// <summary> Alert severity {0, 1, 2, 3, 4}. </summary>
public int Severity { get; set; }
/// <summary> the flag that indicates whether the metric alert is enabled. </summary>
public bool IsEnabled { get; set; }
/// <summary> the list of resource id's that this metric alert is scoped to. </summary>
public IList<string> Scopes { get; }
/// <summary> how often the metric alert is evaluated represented in ISO 8601 duration format. </summary>
public TimeSpan EvaluationFrequency { get; set; }
/// <summary> the period of time (in ISO 8601 duration format) that is used to monitor alert activity based on the threshold. </summary>
public TimeSpan WindowSize { get; set; }
/// <summary> 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. </summary>
public ResourceType? TargetResourceType { get; set; }
/// <summary> 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. </summary>
public AzureLocation? TargetResourceRegion { get; set; }
/// <summary>
/// defines the specific alert criteria information.
/// Please note <see cref="MetricAlertCriteria"/> is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes.
/// The available derived classes include <see cref="MetricAlertMultipleResourceMultipleMetricCriteria"/>, <see cref="MetricAlertSingleResourceMultipleMetricCriteria"/> and <see cref="WebtestLocationAvailabilityCriteria"/>.
/// </summary>
public MetricAlertCriteria Criteria { get; set; }
/// <summary> the flag that indicates whether the alert should be auto resolved or not. The default is true. </summary>
public bool? IsAutoMitigateEnabled { get; set; }
/// <summary> the array of actions that are performed when the alert rule becomes active, and when an alert condition is resolved. </summary>
public IList<MetricAlertAction> Actions { get; }
/// <summary> Last time the rule was updated in ISO8601 format. </summary>
public DateTimeOffset? LastUpdatedOn { get; }
/// <summary> the value indicating whether this alert rule is migrated. </summary>
public bool? IsMigrated { get; }
}
}