internal AlertRuleResource(string id, string name, string type, string location, IDictionary <string, string> tags, string namePropertiesName, string description, bool isEnabled, RuleCondition condition, IList <RuleAction> actions, DateTimeOffset?lastUpdatedTime) : base(id, name, type, location, tags)
 {
     NamePropertiesName = namePropertiesName;
     Description        = description;
     IsEnabled          = isEnabled;
     Condition          = condition;
     Actions            = actions;
     LastUpdatedTime    = lastUpdatedTime;
 }
        public AlertRuleResource(string location, string namePropertiesName, bool isEnabled, RuleCondition condition) : base(location)
        {
            if (location == null)
            {
                throw new ArgumentNullException(nameof(location));
            }
            if (namePropertiesName == null)
            {
                throw new ArgumentNullException(nameof(namePropertiesName));
            }
            if (condition == null)
            {
                throw new ArgumentNullException(nameof(condition));
            }

            NamePropertiesName = namePropertiesName;
            IsEnabled          = isEnabled;
            Condition          = condition;
            Actions            = new ChangeTrackingList <RuleAction>();
        }
        internal static AlertRuleResource DeserializeAlertRuleResource(JsonElement element)
        {
            Optional <string> id       = default;
            Optional <string> name     = default;
            Optional <string> type     = default;
            string            location = default;
            Optional <IDictionary <string, string> > tags = default;
            string            name0                        = default;
            Optional <string> description                  = default;
            bool          isEnabled                        = default;
            RuleCondition condition                        = default;
            Optional <IList <RuleAction> > actions         = default;
            Optional <DateTimeOffset>      lastUpdatedTime = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("id"))
                {
                    id = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("name"))
                {
                    name = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("type"))
                {
                    type = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("location"))
                {
                    location = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("tags"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    Dictionary <string, string> dictionary = new Dictionary <string, string>();
                    foreach (var property0 in property.Value.EnumerateObject())
                    {
                        dictionary.Add(property0.Name, property0.Value.GetString());
                    }
                    tags = dictionary;
                    continue;
                }
                if (property.NameEquals("properties"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    foreach (var property0 in property.Value.EnumerateObject())
                    {
                        if (property0.NameEquals("name"))
                        {
                            name0 = property0.Value.GetString();
                            continue;
                        }
                        if (property0.NameEquals("description"))
                        {
                            description = property0.Value.GetString();
                            continue;
                        }
                        if (property0.NameEquals("isEnabled"))
                        {
                            isEnabled = property0.Value.GetBoolean();
                            continue;
                        }
                        if (property0.NameEquals("condition"))
                        {
                            condition = RuleCondition.DeserializeRuleCondition(property0.Value);
                            continue;
                        }
                        if (property0.NameEquals("actions"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            List <RuleAction> array = new List <RuleAction>();
                            foreach (var item in property0.Value.EnumerateArray())
                            {
                                array.Add(RuleAction.DeserializeRuleAction(item));
                            }
                            actions = array;
                            continue;
                        }
                        if (property0.NameEquals("lastUpdatedTime"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            lastUpdatedTime = property0.Value.GetDateTimeOffset("O");
                            continue;
                        }
                    }
                    continue;
                }
            }
            return(new AlertRuleResource(id.Value, name.Value, type.Value, location, Optional.ToDictionary(tags), name0, description.Value, isEnabled, condition, Optional.ToList(actions), Optional.ToNullable(lastUpdatedTime)));
        }