-
Notifications
You must be signed in to change notification settings - Fork 4.5k
/
AlertsManagementExtensions.cs
101 lines (98 loc) · 8.35 KB
/
AlertsManagementExtensions.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
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
using System.Threading;
using System.Threading.Tasks;
using Azure.ResourceManager.AlertsManagement.Models;
using Azure.ResourceManager.Resources;
namespace Azure.ResourceManager.AlertsManagement
{
public static partial class AlertsManagementExtensions
{
/// <summary>
/// Get a summarized count of your alerts grouped by various parameters (e.g. grouping by 'Severity' returns the count of alerts for each severity).
/// <list type="bullet">
/// <item>
/// <term>Request Path</term>
/// <description>/subscriptions/{subscriptionId}/providers/Microsoft.AlertsManagement/alertsSummary</description>
/// </item>
/// <item>
/// <term>Operation Id</term>
/// <description>Alerts_GetSummary</description>
/// </item>
/// </list>
/// </summary>
/// <param name="subscriptionResource"> The <see cref="SubscriptionResource" /> instance the method will execute against. </param>
/// <param name="groupby"> This parameter allows the result set to be grouped by input fields (Maximum 2 comma separated fields supported). For example, groupby=severity or groupby=severity,alertstate. </param>
/// <param name="includeSmartGroupsCount"> Include count of the SmartGroups as part of the summary. Default value is 'false'. </param>
/// <param name="targetResource"> Filter by target resource( which is full ARM ID) Default value is select all. </param>
/// <param name="targetResourceType"> Filter by target resource type. Default value is select all. </param>
/// <param name="targetResourceGroup"> Filter by target resource group name. Default value is select all. </param>
/// <param name="monitorService"> Filter by monitor service which generates the alert instance. Default value is select all. </param>
/// <param name="monitorCondition"> Filter by monitor condition which is either 'Fired' or 'Resolved'. Default value is to select all. </param>
/// <param name="severity"> Filter by severity. Default value is select all. </param>
/// <param name="alertState"> Filter by state of the alert instance. Default value is to select all. </param>
/// <param name="alertRule"> Filter by specific alert rule. Default value is to select all. </param>
/// <param name="timeRange"> Filter by time range by below listed values. Default value is 1 day. </param>
/// <param name="customTimeRange"> Filter by custom time range in the format <start-time>/<end-time> where time is in (ISO-8601 format)'. Permissible values is within 30 days from query time. Either timeRange or customTimeRange could be used but not both. Default is none. </param>
/// <param name="cancellationToken"> The cancellation token to use. </param>
public static async Task<Response<ServiceAlertSummary>> GetServiceAlertSummaryAsync(this SubscriptionResource subscriptionResource, AlertsSummaryGroupByField groupby, bool? includeSmartGroupsCount = null, string targetResource = null, string targetResourceType = null, string targetResourceGroup = null, MonitorServiceSourceForAlert? monitorService = null, MonitorCondition? monitorCondition = null, ServiceAlertSeverity? severity = null, ServiceAlertState? alertState = null, string alertRule = null, TimeRangeFilter? timeRange = null, string customTimeRange = null, CancellationToken cancellationToken = default)
{
SubscriptionResourceGetServiceAlertSummaryOptions options = new SubscriptionResourceGetServiceAlertSummaryOptions(groupby);
options.IncludeSmartGroupsCount = includeSmartGroupsCount;
options.TargetResource = targetResource;
options.TargetResourceType = targetResourceType;
options.TargetResourceGroup = targetResourceGroup;
options.MonitorService = monitorService;
options.MonitorCondition = monitorCondition;
options.Severity = severity;
options.AlertState = alertState;
options.AlertRule = alertRule;
options.TimeRange = timeRange;
options.CustomTimeRange = customTimeRange;
return await subscriptionResource.GetServiceAlertSummaryAsync(options, cancellationToken).ConfigureAwait(false);
}
/// <summary>
/// Get a summarized count of your alerts grouped by various parameters (e.g. grouping by 'Severity' returns the count of alerts for each severity).
/// <list type="bullet">
/// <item>
/// <term>Request Path</term>
/// <description>/subscriptions/{subscriptionId}/providers/Microsoft.AlertsManagement/alertsSummary</description>
/// </item>
/// <item>
/// <term>Operation Id</term>
/// <description>Alerts_GetSummary</description>
/// </item>
/// </list>
/// </summary>
/// <param name="subscriptionResource"> The <see cref="SubscriptionResource" /> instance the method will execute against. </param>
/// <param name="groupby"> This parameter allows the result set to be grouped by input fields (Maximum 2 comma separated fields supported). For example, groupby=severity or groupby=severity,alertstate. </param>
/// <param name="includeSmartGroupsCount"> Include count of the SmartGroups as part of the summary. Default value is 'false'. </param>
/// <param name="targetResource"> Filter by target resource( which is full ARM ID) Default value is select all. </param>
/// <param name="targetResourceType"> Filter by target resource type. Default value is select all. </param>
/// <param name="targetResourceGroup"> Filter by target resource group name. Default value is select all. </param>
/// <param name="monitorService"> Filter by monitor service which generates the alert instance. Default value is select all. </param>
/// <param name="monitorCondition"> Filter by monitor condition which is either 'Fired' or 'Resolved'. Default value is to select all. </param>
/// <param name="severity"> Filter by severity. Default value is select all. </param>
/// <param name="alertState"> Filter by state of the alert instance. Default value is to select all. </param>
/// <param name="alertRule"> Filter by specific alert rule. Default value is to select all. </param>
/// <param name="timeRange"> Filter by time range by below listed values. Default value is 1 day. </param>
/// <param name="customTimeRange"> Filter by custom time range in the format <start-time>/<end-time> where time is in (ISO-8601 format)'. Permissible values is within 30 days from query time. Either timeRange or customTimeRange could be used but not both. Default is none. </param>
/// <param name="cancellationToken"> The cancellation token to use. </param>
public static Response<ServiceAlertSummary> GetServiceAlertSummary(this SubscriptionResource subscriptionResource, AlertsSummaryGroupByField groupby, bool? includeSmartGroupsCount = null, string targetResource = null, string targetResourceType = null, string targetResourceGroup = null, MonitorServiceSourceForAlert? monitorService = null, MonitorCondition? monitorCondition = null, ServiceAlertSeverity? severity = null, ServiceAlertState? alertState = null, string alertRule = null, TimeRangeFilter? timeRange = null, string customTimeRange = null, CancellationToken cancellationToken = default)
{
SubscriptionResourceGetServiceAlertSummaryOptions options = new SubscriptionResourceGetServiceAlertSummaryOptions(groupby);
options.IncludeSmartGroupsCount = includeSmartGroupsCount;
options.TargetResource = targetResource;
options.TargetResourceType = targetResourceType;
options.TargetResourceGroup = targetResourceGroup;
options.MonitorService = monitorService;
options.MonitorCondition = monitorCondition;
options.Severity = severity;
options.AlertState = alertState;
options.AlertRule = alertRule;
options.TimeRange = timeRange;
options.CustomTimeRange = customTimeRange;
return subscriptionResource.GetServiceAlertSummary(options, cancellationToken);
}
}
}