Example #1
0
        internal static FirewallPolicyNatRuleCollectionInfo DeserializeFirewallPolicyNatRuleCollectionInfo(JsonElement element)
        {
            Optional <FirewallPolicyNatRuleCollectionAction> action = default;
            Optional <IList <FirewallPolicyRule> >           rules  = default;
            FirewallPolicyRuleCollectionType ruleCollectionType     = default;
            Optional <string> name     = default;
            Optional <int>    priority = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("action"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    action = FirewallPolicyNatRuleCollectionAction.DeserializeFirewallPolicyNatRuleCollectionAction(property.Value);
                    continue;
                }
                if (property.NameEquals("rules"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    List <FirewallPolicyRule> array = new List <FirewallPolicyRule>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(FirewallPolicyRule.DeserializeFirewallPolicyRule(item));
                    }
                    rules = array;
                    continue;
                }
                if (property.NameEquals("ruleCollectionType"))
                {
                    ruleCollectionType = new FirewallPolicyRuleCollectionType(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("name"))
                {
                    name = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("priority"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    priority = property.Value.GetInt32();
                    continue;
                }
            }
            return(new FirewallPolicyNatRuleCollectionInfo(ruleCollectionType, name.Value, Optional.ToNullable(priority), action.Value, Optional.ToList(rules)));
        }
        internal static FirewallPolicyRuleCollection DeserializeFirewallPolicyRuleCollection(JsonElement element)
        {
            if (element.TryGetProperty("ruleCollectionType", out JsonElement discriminator))
            {
                switch (discriminator.GetString())
                {
                case "FirewallPolicyFilterRuleCollection": return(FirewallPolicyFilterRuleCollection.DeserializeFirewallPolicyFilterRuleCollection(element));

                case "FirewallPolicyNatRuleCollection": return(FirewallPolicyNatRuleCollection.DeserializeFirewallPolicyNatRuleCollection(element));
                }
            }
            FirewallPolicyRuleCollectionType ruleCollectionType = default;
            Optional <string> name     = default;
            Optional <int>    priority = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("ruleCollectionType"))
                {
                    ruleCollectionType = new FirewallPolicyRuleCollectionType(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("name"))
                {
                    name = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("priority"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    priority = property.Value.GetInt32();
                    continue;
                }
            }
            return(new FirewallPolicyRuleCollection(ruleCollectionType, name.Value, Optional.ToNullable(priority)));
        }
Example #3
0
 internal FirewallPolicyNatRuleCollectionInfo(FirewallPolicyRuleCollectionType ruleCollectionType, string name, int?priority, FirewallPolicyNatRuleCollectionAction action, IList <FirewallPolicyRule> rules) : base(ruleCollectionType, name, priority)
 {
     Action             = action;
     Rules              = rules;
     RuleCollectionType = ruleCollectionType;
 }