public static AlertRuleData GetBasicAlertRuleData(AzureLocation location)
        {
            var ruleWebhookAction = new RuleWebhookAction()
            {
                ServiceUri = new Uri("https://www.contoso.com/alerts?type=HighCPU"),
                Properties = { new KeyValuePair <string, string>("key1", "value1") }
            };
            //RuleMetricDataSource ruleDataSource = new RuleMetricDataSource(
            //    "Microsoft.Azure.Management.Insights.Models.RuleMetricDataSource",
            //    "/subscriptions/db1ab6f0-4769-4b27-930e-01e2ef9c123c/resourceGroups/Default-EventHub-1375/providers/Microsoft.EventHub/namespaces/sdk-eventhub-Namespace-8280",
            //    "/subscriptions/db1ab6f0-4769-4b27-930e-01e2ef9c123c/resourceGroups/Default-EventHub-1375/providers/microsoft.insights/metricalerts/testAlertRule",
            //    "global",
            //    "Microsoft.EventHub/namespaces",
            //    "ActiveConnections");
            RuleMetricDataSource ruleDataSource = new RuleMetricDataSource()
            {
                //LegacyResourceId = "",
                MetricName       = "testrulemetric",
                MetricNamespace  = "Microsoft.Compute/virtualMachines",
                ResourceLocation = location,
                ResourceId       = "/subscriptions/db1ab6f0-4769-4b27-930e-01e2ef9c123c/resourceGroups/deleteme0122/providers/Microsoft.Compute/virtualMachines/MetricAlertActionTestVM01"
            };
            //var ruleCondition = new ThresholdRuleCondition(
            //    "Microsoft.Azure.Monitor.SingleResourceMultipleMetricCriteria",
            //    ruleDataSource,
            //    ConditionOperator.GreaterThan,
            //    3.0,
            //    TimeSpan.FromMinutes(15),
            //    TimeAggregationOperator.Average);
            var ruleCondition = new ThresholdRuleCondition(ConditionOperator.GreaterThan, 3.0)
            {
                WindowSize      = TimeSpan.FromMinutes(15),
                TimeAggregation = TimeAggregationOperator.Average,
                DataSource      = ruleDataSource
            };
            var data = new AlertRuleData(location, "testAlertRule", true, ruleCondition)
            {
                Actions = { ruleWebhookAction }
            };

            return(data);
        }
        internal static AlertRuleResourceCollection DeserializeAlertRuleResourceCollection(JsonElement element)
        {
            Optional <IReadOnlyList <AlertRuleData> > value = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("value"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    List <AlertRuleData> array = new List <AlertRuleData>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(AlertRuleData.DeserializeAlertRuleData(item));
                    }
                    value = array;
                    continue;
                }
            }
            return(new AlertRuleResourceCollection(Optional.ToList(value)));
        }
 public static void AssertAlertRule(AlertRuleData data1, AlertRuleData data2)
 {
     AssertTrackedResource(data1, data2);
     Assert.AreEqual(data1.Description, data2.Description);
 }