Пример #1
0
 internal AlertingAction(string odataType, AlertSeverity severity, AzNsActionGroup aznsAction, int?throttlingInMin, TriggerCondition trigger) : base(odataType)
 {
     Severity        = severity;
     AznsAction      = aznsAction;
     ThrottlingInMin = throttlingInMin;
     Trigger         = trigger;
     OdataType       = odataType ?? "Microsoft.WindowsAzure.Management.Monitoring.Alerts.Models.Microsoft.AppInsights.Nexus.DataContracts.Resources.ScheduledQueryRules.AlertingAction";
 }
Пример #2
0
        internal static AlertingAction DeserializeAlertingAction(JsonElement element)
        {
            AlertSeverity severity = default;
            Optional <AzNsActionGroup> aznsAction      = default;
            Optional <int>             throttlingInMin = default;
            TriggerCondition           trigger         = default;
            string odataType = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("severity"))
                {
                    severity = new AlertSeverity(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("aznsAction"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    aznsAction = AzNsActionGroup.DeserializeAzNsActionGroup(property.Value);
                    continue;
                }
                if (property.NameEquals("throttlingInMin"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    throttlingInMin = property.Value.GetInt32();
                    continue;
                }
                if (property.NameEquals("trigger"))
                {
                    trigger = TriggerCondition.DeserializeTriggerCondition(property.Value);
                    continue;
                }
                if (property.NameEquals("odata.type"))
                {
                    odataType = property.Value.GetString();
                    continue;
                }
            }
            return(new AlertingAction(odataType, severity, aznsAction.Value, Optional.ToNullable(throttlingInMin), trigger));
        }