예제 #1
0
 internal NatRuleCondition(string name, string description, FirewallPolicyRuleConditionType ruleConditionType, IList <FirewallPolicyRuleConditionNetworkProtocol> ipProtocols, IList <string> sourceAddresses, IList <string> destinationAddresses, IList <string> destinationPorts, IList <string> sourceIpGroups, bool?terminateTLS) : base(name, description, ruleConditionType)
 {
     IpProtocols          = ipProtocols;
     SourceAddresses      = sourceAddresses;
     DestinationAddresses = destinationAddresses;
     DestinationPorts     = destinationPorts;
     SourceIpGroups       = sourceIpGroups;
     TerminateTLS         = terminateTLS;
     RuleConditionType    = ruleConditionType;
 }
 internal ApplicationRuleCondition(string name, string description, FirewallPolicyRuleConditionType ruleConditionType, IList <string> sourceAddresses, IList <string> destinationAddresses, IList <FirewallPolicyRuleConditionApplicationProtocol> protocols, IList <string> targetUrls, IList <string> targetFqdns, IList <string> fqdnTags, IList <string> sourceIpGroups) : base(name, description, ruleConditionType)
 {
     SourceAddresses      = sourceAddresses;
     DestinationAddresses = destinationAddresses;
     Protocols            = protocols;
     TargetUrls           = targetUrls;
     TargetFqdns          = targetFqdns;
     FqdnTags             = fqdnTags;
     SourceIpGroups       = sourceIpGroups;
     RuleConditionType    = ruleConditionType;
 }
예제 #3
0
        internal static FirewallPolicyRuleCondition DeserializeFirewallPolicyRuleCondition(JsonElement element)
        {
            if (element.TryGetProperty("ruleConditionType", out JsonElement discriminator))
            {
                switch (discriminator.GetString())
                {
                case "ApplicationRuleCondition": return(ApplicationRuleCondition.DeserializeApplicationRuleCondition(element));

                case "NatRuleCondition": return(NatRuleCondition.DeserializeNatRuleCondition(element));

                case "NetworkRuleCondition": return(NetworkRuleCondition.DeserializeNetworkRuleCondition(element));
                }
            }
            string name        = default;
            string description = default;
            FirewallPolicyRuleConditionType ruleConditionType = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("name"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    name = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("description"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    description = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("ruleConditionType"))
                {
                    ruleConditionType = new FirewallPolicyRuleConditionType(property.Value.GetString());
                    continue;
                }
            }
            return(new FirewallPolicyRuleCondition(name, description, ruleConditionType));
        }
        internal static ApplicationRuleCondition DeserializeApplicationRuleCondition(JsonElement element)
        {
            IList <string> sourceAddresses      = default;
            IList <string> destinationAddresses = default;
            IList <FirewallPolicyRuleConditionApplicationProtocol> protocols = default;
            IList <string> targetUrls     = default;
            IList <string> targetFqdns    = default;
            IList <string> fqdnTags       = default;
            IList <string> sourceIpGroups = default;
            string         name           = default;
            string         description    = default;
            FirewallPolicyRuleConditionType ruleConditionType = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("sourceAddresses"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    List <string> array = new List <string>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        if (item.ValueKind == JsonValueKind.Null)
                        {
                            array.Add(null);
                        }
                        else
                        {
                            array.Add(item.GetString());
                        }
                    }
                    sourceAddresses = array;
                    continue;
                }
                if (property.NameEquals("destinationAddresses"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    List <string> array = new List <string>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        if (item.ValueKind == JsonValueKind.Null)
                        {
                            array.Add(null);
                        }
                        else
                        {
                            array.Add(item.GetString());
                        }
                    }
                    destinationAddresses = array;
                    continue;
                }
                if (property.NameEquals("protocols"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    List <FirewallPolicyRuleConditionApplicationProtocol> array = new List <FirewallPolicyRuleConditionApplicationProtocol>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        if (item.ValueKind == JsonValueKind.Null)
                        {
                            array.Add(null);
                        }
                        else
                        {
                            array.Add(FirewallPolicyRuleConditionApplicationProtocol.DeserializeFirewallPolicyRuleConditionApplicationProtocol(item));
                        }
                    }
                    protocols = array;
                    continue;
                }
                if (property.NameEquals("targetUrls"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    List <string> array = new List <string>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        if (item.ValueKind == JsonValueKind.Null)
                        {
                            array.Add(null);
                        }
                        else
                        {
                            array.Add(item.GetString());
                        }
                    }
                    targetUrls = array;
                    continue;
                }
                if (property.NameEquals("targetFqdns"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    List <string> array = new List <string>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        if (item.ValueKind == JsonValueKind.Null)
                        {
                            array.Add(null);
                        }
                        else
                        {
                            array.Add(item.GetString());
                        }
                    }
                    targetFqdns = array;
                    continue;
                }
                if (property.NameEquals("fqdnTags"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    List <string> array = new List <string>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        if (item.ValueKind == JsonValueKind.Null)
                        {
                            array.Add(null);
                        }
                        else
                        {
                            array.Add(item.GetString());
                        }
                    }
                    fqdnTags = array;
                    continue;
                }
                if (property.NameEquals("sourceIpGroups"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    List <string> array = new List <string>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        if (item.ValueKind == JsonValueKind.Null)
                        {
                            array.Add(null);
                        }
                        else
                        {
                            array.Add(item.GetString());
                        }
                    }
                    sourceIpGroups = array;
                    continue;
                }
                if (property.NameEquals("name"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    name = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("description"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    description = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("ruleConditionType"))
                {
                    ruleConditionType = new FirewallPolicyRuleConditionType(property.Value.GetString());
                    continue;
                }
            }
            return(new ApplicationRuleCondition(name, description, ruleConditionType, sourceAddresses, destinationAddresses, protocols, targetUrls, targetFqdns, fqdnTags, sourceIpGroups));
        }
        internal static NetworkRuleCondition DeserializeNetworkRuleCondition(JsonElement element)
        {
            Optional <IList <FirewallPolicyRuleConditionNetworkProtocol> > ipProtocols = default;
            Optional <IList <string> >      sourceAddresses      = default;
            Optional <IList <string> >      destinationAddresses = default;
            Optional <IList <string> >      destinationPorts     = default;
            Optional <IList <string> >      sourceIpGroups       = default;
            Optional <IList <string> >      destinationIpGroups  = default;
            Optional <string>               name              = default;
            Optional <string>               description       = default;
            FirewallPolicyRuleConditionType ruleConditionType = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("ipProtocols"))
                {
                    List <FirewallPolicyRuleConditionNetworkProtocol> array = new List <FirewallPolicyRuleConditionNetworkProtocol>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(new FirewallPolicyRuleConditionNetworkProtocol(item.GetString()));
                    }
                    ipProtocols = array;
                    continue;
                }
                if (property.NameEquals("sourceAddresses"))
                {
                    List <string> array = new List <string>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(item.GetString());
                    }
                    sourceAddresses = array;
                    continue;
                }
                if (property.NameEquals("destinationAddresses"))
                {
                    List <string> array = new List <string>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(item.GetString());
                    }
                    destinationAddresses = array;
                    continue;
                }
                if (property.NameEquals("destinationPorts"))
                {
                    List <string> array = new List <string>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(item.GetString());
                    }
                    destinationPorts = array;
                    continue;
                }
                if (property.NameEquals("sourceIpGroups"))
                {
                    List <string> array = new List <string>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(item.GetString());
                    }
                    sourceIpGroups = array;
                    continue;
                }
                if (property.NameEquals("destinationIpGroups"))
                {
                    List <string> array = new List <string>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(item.GetString());
                    }
                    destinationIpGroups = array;
                    continue;
                }
                if (property.NameEquals("name"))
                {
                    name = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("description"))
                {
                    description = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("ruleConditionType"))
                {
                    ruleConditionType = new FirewallPolicyRuleConditionType(property.Value.GetString());
                    continue;
                }
            }
            return(new NetworkRuleCondition(name.Value, description.Value, ruleConditionType, Optional.ToList(ipProtocols), Optional.ToList(sourceAddresses), Optional.ToList(destinationAddresses), Optional.ToList(destinationPorts), Optional.ToList(sourceIpGroups), Optional.ToList(destinationIpGroups)));
        }
예제 #6
0
        internal static NatRuleCondition DeserializeNatRuleCondition(JsonElement element)
        {
            IList <FirewallPolicyRuleConditionNetworkProtocol> ipProtocols = default;
            IList <string> sourceAddresses      = default;
            IList <string> destinationAddresses = default;
            IList <string> destinationPorts     = default;
            IList <string> sourceIpGroups       = default;
            bool?          terminateTLS         = default;
            string         name        = default;
            string         description = default;
            FirewallPolicyRuleConditionType ruleConditionType = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("ipProtocols"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    List <FirewallPolicyRuleConditionNetworkProtocol> array = new List <FirewallPolicyRuleConditionNetworkProtocol>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(new FirewallPolicyRuleConditionNetworkProtocol(item.GetString()));
                    }
                    ipProtocols = array;
                    continue;
                }
                if (property.NameEquals("sourceAddresses"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    List <string> array = new List <string>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        if (item.ValueKind == JsonValueKind.Null)
                        {
                            array.Add(null);
                        }
                        else
                        {
                            array.Add(item.GetString());
                        }
                    }
                    sourceAddresses = array;
                    continue;
                }
                if (property.NameEquals("destinationAddresses"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    List <string> array = new List <string>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        if (item.ValueKind == JsonValueKind.Null)
                        {
                            array.Add(null);
                        }
                        else
                        {
                            array.Add(item.GetString());
                        }
                    }
                    destinationAddresses = array;
                    continue;
                }
                if (property.NameEquals("destinationPorts"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    List <string> array = new List <string>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        if (item.ValueKind == JsonValueKind.Null)
                        {
                            array.Add(null);
                        }
                        else
                        {
                            array.Add(item.GetString());
                        }
                    }
                    destinationPorts = array;
                    continue;
                }
                if (property.NameEquals("sourceIpGroups"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    List <string> array = new List <string>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        if (item.ValueKind == JsonValueKind.Null)
                        {
                            array.Add(null);
                        }
                        else
                        {
                            array.Add(item.GetString());
                        }
                    }
                    sourceIpGroups = array;
                    continue;
                }
                if (property.NameEquals("terminateTLS"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    terminateTLS = property.Value.GetBoolean();
                    continue;
                }
                if (property.NameEquals("name"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    name = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("description"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    description = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("ruleConditionType"))
                {
                    ruleConditionType = new FirewallPolicyRuleConditionType(property.Value.GetString());
                    continue;
                }
            }
            return(new NatRuleCondition(name, description, ruleConditionType, ipProtocols, sourceAddresses, destinationAddresses, destinationPorts, sourceIpGroups, terminateTLS));
        }
예제 #7
0
        internal static ApplicationRuleCondition DeserializeApplicationRuleCondition(JsonElement element)
        {
            Optional <IList <string> > sourceAddresses      = default;
            Optional <IList <string> > destinationAddresses = default;
            Optional <IList <FirewallPolicyRuleConditionApplicationProtocol> > protocols = default;
            Optional <IList <string> >      targetUrls        = default;
            Optional <IList <string> >      targetFqdns       = default;
            Optional <IList <string> >      fqdnTags          = default;
            Optional <IList <string> >      sourceIpGroups    = default;
            Optional <string>               name              = default;
            Optional <string>               description       = default;
            FirewallPolicyRuleConditionType ruleConditionType = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("sourceAddresses"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    List <string> array = new List <string>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(item.GetString());
                    }
                    sourceAddresses = array;
                    continue;
                }
                if (property.NameEquals("destinationAddresses"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    List <string> array = new List <string>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(item.GetString());
                    }
                    destinationAddresses = array;
                    continue;
                }
                if (property.NameEquals("protocols"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    List <FirewallPolicyRuleConditionApplicationProtocol> array = new List <FirewallPolicyRuleConditionApplicationProtocol>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(FirewallPolicyRuleConditionApplicationProtocol.DeserializeFirewallPolicyRuleConditionApplicationProtocol(item));
                    }
                    protocols = array;
                    continue;
                }
                if (property.NameEquals("targetUrls"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    List <string> array = new List <string>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(item.GetString());
                    }
                    targetUrls = array;
                    continue;
                }
                if (property.NameEquals("targetFqdns"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    List <string> array = new List <string>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(item.GetString());
                    }
                    targetFqdns = array;
                    continue;
                }
                if (property.NameEquals("fqdnTags"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    List <string> array = new List <string>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(item.GetString());
                    }
                    fqdnTags = array;
                    continue;
                }
                if (property.NameEquals("sourceIpGroups"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    List <string> array = new List <string>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(item.GetString());
                    }
                    sourceIpGroups = array;
                    continue;
                }
                if (property.NameEquals("name"))
                {
                    name = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("description"))
                {
                    description = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("ruleConditionType"))
                {
                    ruleConditionType = new FirewallPolicyRuleConditionType(property.Value.GetString());
                    continue;
                }
            }
            return(new ApplicationRuleCondition(name.Value, description.Value, ruleConditionType, Optional.ToList(sourceAddresses), Optional.ToList(destinationAddresses), Optional.ToList(protocols), Optional.ToList(targetUrls), Optional.ToList(targetFqdns), Optional.ToList(fqdnTags), Optional.ToList(sourceIpGroups)));
        }