コード例 #1
0
        internal static FirewallPolicyRule DeserializeFirewallPolicyRule(JsonElement element)
        {
            if (element.TryGetProperty("ruleType", out JsonElement discriminator))
            {
                switch (discriminator.GetString())
                {
                case "FirewallPolicyFilterRule": return(FirewallPolicyFilterRule.DeserializeFirewallPolicyFilterRule(element));

                case "FirewallPolicyNatRule": return(FirewallPolicyNatRule.DeserializeFirewallPolicyNatRule(element));
                }
            }
            FirewallPolicyRuleType ruleType = default;
            Optional <string>      name     = default;
            Optional <int>         priority = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("ruleType"))
                {
                    ruleType = new FirewallPolicyRuleType(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("name"))
                {
                    name = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("priority"))
                {
                    priority = property.Value.GetInt32();
                    continue;
                }
            }
            return(new FirewallPolicyRule(ruleType, name.Value, Optional.ToNullable(priority)));
        }
        internal static FirewallPolicyFilterRule DeserializeFirewallPolicyFilterRule(JsonElement element)
        {
            Optional <FirewallPolicyFilterRuleAction>       action         = default;
            Optional <IList <FirewallPolicyRuleCondition> > ruleConditions = default;
            FirewallPolicyRuleType ruleType = 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 = FirewallPolicyFilterRuleAction.DeserializeFirewallPolicyFilterRuleAction(property.Value);
                    continue;
                }
                if (property.NameEquals("ruleConditions"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    List <FirewallPolicyRuleCondition> array = new List <FirewallPolicyRuleCondition>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(FirewallPolicyRuleCondition.DeserializeFirewallPolicyRuleCondition(item));
                    }
                    ruleConditions = array;
                    continue;
                }
                if (property.NameEquals("ruleType"))
                {
                    ruleType = new FirewallPolicyRuleType(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 FirewallPolicyFilterRule(ruleType, name.Value, Optional.ToNullable(priority), action.Value, Optional.ToList(ruleConditions)));
        }
コード例 #3
0
 internal NetworkRule(string name, string description, FirewallPolicyRuleType ruleType, IList <FirewallPolicyRuleNetworkProtocol> ipProtocols, IList <string> sourceAddresses, IList <string> destinationAddresses, IList <string> destinationPorts, IList <string> sourceIPGroups, IList <string> destinationIPGroups, IList <string> destinationFqdns) : base(name, description, ruleType)
 {
     IPProtocols          = ipProtocols;
     SourceAddresses      = sourceAddresses;
     DestinationAddresses = destinationAddresses;
     DestinationPorts     = destinationPorts;
     SourceIPGroups       = sourceIPGroups;
     DestinationIPGroups  = destinationIPGroups;
     DestinationFqdns     = destinationFqdns;
     RuleType             = ruleType;
 }
コード例 #4
0
ファイル: NatRule.cs プロジェクト: anpint/azure-sdk-for-net
 internal NatRule(string name, string description, FirewallPolicyRuleType ruleType, IList <FirewallPolicyRuleNetworkProtocol> ipProtocols, IList <string> sourceAddresses, IList <string> destinationAddresses, IList <string> destinationPorts, string translatedAddress, string translatedPort, IList <string> sourceIPGroups, string translatedFqdn) : base(name, description, ruleType)
 {
     IPProtocols          = ipProtocols;
     SourceAddresses      = sourceAddresses;
     DestinationAddresses = destinationAddresses;
     DestinationPorts     = destinationPorts;
     TranslatedAddress    = translatedAddress;
     TranslatedPort       = translatedPort;
     SourceIPGroups       = sourceIPGroups;
     TranslatedFqdn       = translatedFqdn;
     RuleType             = ruleType;
 }
コード例 #5
0
 internal ApplicationRule(string name, string description, FirewallPolicyRuleType ruleType, IList <string> sourceAddresses, IList <string> destinationAddresses, IList <FirewallPolicyRuleApplicationProtocol> protocols, IList <string> targetFqdns, IList <string> targetUrls, IList <string> fqdnTags, IList <string> sourceIPGroups, bool?terminateTLS, IList <string> webCategories) : base(name, description, ruleType)
 {
     SourceAddresses      = sourceAddresses;
     DestinationAddresses = destinationAddresses;
     Protocols            = protocols;
     TargetFqdns          = targetFqdns;
     TargetUrls           = targetUrls;
     FqdnTags             = fqdnTags;
     SourceIPGroups       = sourceIPGroups;
     TerminateTLS         = terminateTLS;
     WebCategories        = webCategories;
     RuleType             = ruleType;
 }
        internal static FirewallPolicyNatRule DeserializeFirewallPolicyNatRule(JsonElement element)
        {
            Optional <FirewallPolicyNatRuleAction> action = default;
            Optional <string> translatedAddress           = default;
            Optional <string> translatedPort = default;
            Optional <FirewallPolicyRuleCondition> ruleCondition = default;
            FirewallPolicyRuleType ruleType = default;
            Optional <string>      name     = default;
            Optional <int>         priority = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("action"))
                {
                    action = FirewallPolicyNatRuleAction.DeserializeFirewallPolicyNatRuleAction(property.Value);
                    continue;
                }
                if (property.NameEquals("translatedAddress"))
                {
                    translatedAddress = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("translatedPort"))
                {
                    translatedPort = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("ruleCondition"))
                {
                    ruleCondition = FirewallPolicyRuleCondition.DeserializeFirewallPolicyRuleCondition(property.Value);
                    continue;
                }
                if (property.NameEquals("ruleType"))
                {
                    ruleType = new FirewallPolicyRuleType(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("name"))
                {
                    name = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("priority"))
                {
                    priority = property.Value.GetInt32();
                    continue;
                }
            }
            return(new FirewallPolicyNatRule(ruleType, name.Value, Optional.ToNullable(priority), action.Value, translatedAddress.Value, translatedPort.Value, ruleCondition.Value));
        }
コード例 #7
0
        internal static FirewallPolicyRule DeserializeFirewallPolicyRule(JsonElement element)
        {
            if (element.TryGetProperty("ruleType", out JsonElement discriminator))
            {
                switch (discriminator.GetString())
                {
                case "ApplicationRule": return(ApplicationRule.DeserializeApplicationRule(element));

                case "NatRule": return(NatRule.DeserializeNatRule(element));

                case "NetworkRule": return(NetworkRule.DeserializeNetworkRule(element));
                }
            }
            Optional <string>      name        = default;
            Optional <string>      description = default;
            FirewallPolicyRuleType ruleType    = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("name"))
                {
                    name = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("description"))
                {
                    description = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("ruleType"))
                {
                    ruleType = new FirewallPolicyRuleType(property.Value.GetString());
                    continue;
                }
            }
            return(new FirewallPolicyRule(name.Value, description.Value, ruleType));
        }
コード例 #8
0
 internal FirewallPolicyFilterRule(FirewallPolicyRuleType ruleType, string name, int?priority, FirewallPolicyFilterRuleAction action, IList <FirewallPolicyRuleCondition> ruleConditions) : base(ruleType, name, priority)
 {
     Action         = action;
     RuleConditions = ruleConditions;
     RuleType       = ruleType;
 }
コード例 #9
0
        internal static ApplicationRule DeserializeApplicationRule(JsonElement element)
        {
            Optional <IList <string> > sourceAddresses      = default;
            Optional <IList <string> > destinationAddresses = default;
            Optional <IList <FirewallPolicyRuleApplicationProtocol> > protocols = default;
            Optional <IList <string> > targetFqdns    = default;
            Optional <IList <string> > targetUrls     = default;
            Optional <IList <string> > fqdnTags       = default;
            Optional <IList <string> > sourceIpGroups = default;
            Optional <bool>            terminateTLS   = default;
            Optional <IList <string> > webCategories  = default;
            Optional <string>          name           = default;
            Optional <string>          description    = default;
            FirewallPolicyRuleType     ruleType       = 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 <FirewallPolicyRuleApplicationProtocol> array = new List <FirewallPolicyRuleApplicationProtocol>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(FirewallPolicyRuleApplicationProtocol.DeserializeFirewallPolicyRuleApplicationProtocol(item));
                    }
                    protocols = 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("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("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("terminateTLS"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    terminateTLS = property.Value.GetBoolean();
                    continue;
                }
                if (property.NameEquals("webCategories"))
                {
                    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());
                    }
                    webCategories = array;
                    continue;
                }
                if (property.NameEquals("name"))
                {
                    name = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("description"))
                {
                    description = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("ruleType"))
                {
                    ruleType = new FirewallPolicyRuleType(property.Value.GetString());
                    continue;
                }
            }
            return(new ApplicationRule(name.Value, description.Value, ruleType, Optional.ToList(sourceAddresses), Optional.ToList(destinationAddresses), Optional.ToList(protocols), Optional.ToList(targetFqdns), Optional.ToList(targetUrls), Optional.ToList(fqdnTags), Optional.ToList(sourceIpGroups), Optional.ToNullable(terminateTLS), Optional.ToList(webCategories)));
        }
コード例 #10
0
        internal static NatRule DeserializeNatRule(JsonElement element)
        {
            Optional <IList <FirewallPolicyRuleNetworkProtocol> > ipProtocols = default;
            Optional <IList <string> > sourceAddresses      = default;
            Optional <IList <string> > destinationAddresses = default;
            Optional <IList <string> > destinationPorts     = default;
            Optional <string>          translatedAddress    = default;
            Optional <string>          translatedPort       = default;
            Optional <IList <string> > sourceIpGroups       = default;
            Optional <string>          translatedFqdn       = default;
            Optional <string>          name        = default;
            Optional <string>          description = default;
            FirewallPolicyRuleType     ruleType    = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("ipProtocols"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    List <FirewallPolicyRuleNetworkProtocol> array = new List <FirewallPolicyRuleNetworkProtocol>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(new FirewallPolicyRuleNetworkProtocol(item.GetString()));
                    }
                    ipProtocols = array;
                    continue;
                }
                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("destinationPorts"))
                {
                    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());
                    }
                    destinationPorts = array;
                    continue;
                }
                if (property.NameEquals("translatedAddress"))
                {
                    translatedAddress = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("translatedPort"))
                {
                    translatedPort = property.Value.GetString();
                    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("translatedFqdn"))
                {
                    translatedFqdn = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("name"))
                {
                    name = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("description"))
                {
                    description = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("ruleType"))
                {
                    ruleType = new FirewallPolicyRuleType(property.Value.GetString());
                    continue;
                }
            }
            return(new NatRule(name.Value, description.Value, ruleType, Optional.ToList(ipProtocols), Optional.ToList(sourceAddresses), Optional.ToList(destinationAddresses), Optional.ToList(destinationPorts), translatedAddress.Value, translatedPort.Value, Optional.ToList(sourceIpGroups), translatedFqdn.Value));
        }
        internal static FirewallPolicyFilterRule DeserializeFirewallPolicyFilterRule(JsonElement element)
        {
            FirewallPolicyFilterRuleAction      action         = default;
            IList <FirewallPolicyRuleCondition> ruleConditions = default;
            FirewallPolicyRuleType ruleType = default;
            string name     = default;
            int?   priority = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("action"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    action = FirewallPolicyFilterRuleAction.DeserializeFirewallPolicyFilterRuleAction(property.Value);
                    continue;
                }
                if (property.NameEquals("ruleConditions"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    List <FirewallPolicyRuleCondition> array = new List <FirewallPolicyRuleCondition>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        if (item.ValueKind == JsonValueKind.Null)
                        {
                            array.Add(null);
                        }
                        else
                        {
                            array.Add(FirewallPolicyRuleCondition.DeserializeFirewallPolicyRuleCondition(item));
                        }
                    }
                    ruleConditions = array;
                    continue;
                }
                if (property.NameEquals("ruleType"))
                {
                    ruleType = new FirewallPolicyRuleType(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("name"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    name = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("priority"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    priority = property.Value.GetInt32();
                    continue;
                }
            }
            return(new FirewallPolicyFilterRule(ruleType, name, priority, action, ruleConditions));
        }
        internal static FirewallPolicyNatRule DeserializeFirewallPolicyNatRule(JsonElement element)
        {
            FirewallPolicyNatRuleAction action = default;
            string translatedAddress           = default;
            string translatedPort = default;
            FirewallPolicyRuleCondition ruleCondition = default;
            FirewallPolicyRuleType      ruleType      = default;
            string name     = default;
            int?   priority = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("action"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    action = FirewallPolicyNatRuleAction.DeserializeFirewallPolicyNatRuleAction(property.Value);
                    continue;
                }
                if (property.NameEquals("translatedAddress"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    translatedAddress = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("translatedPort"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    translatedPort = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("ruleCondition"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    ruleCondition = FirewallPolicyRuleCondition.DeserializeFirewallPolicyRuleCondition(property.Value);
                    continue;
                }
                if (property.NameEquals("ruleType"))
                {
                    ruleType = new FirewallPolicyRuleType(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("name"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    name = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("priority"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    priority = property.Value.GetInt32();
                    continue;
                }
            }
            return(new FirewallPolicyNatRule(ruleType, name, priority, action, translatedAddress, translatedPort, ruleCondition));
        }