internal ApplicationGatewayWebApplicationFirewallConfiguration(bool enabled, ApplicationGatewayFirewallMode firewallMode, string ruleSetType, string ruleSetVersion, IList <ApplicationGatewayFirewallDisabledRuleGroup> disabledRuleGroups, bool?requestBodyCheck, int?maxRequestBodySize, int?maxRequestBodySizeInKb, int?fileUploadLimitInMb, IList <ApplicationGatewayFirewallExclusion> exclusions)
 {
     Enabled                = enabled;
     FirewallMode           = firewallMode;
     RuleSetType            = ruleSetType;
     RuleSetVersion         = ruleSetVersion;
     DisabledRuleGroups     = disabledRuleGroups;
     RequestBodyCheck       = requestBodyCheck;
     MaxRequestBodySize     = maxRequestBodySize;
     MaxRequestBodySizeInKb = maxRequestBodySizeInKb;
     FileUploadLimitInMb    = fileUploadLimitInMb;
     Exclusions             = exclusions;
 }
        public ApplicationGatewayWebApplicationFirewallConfiguration(bool enabled, ApplicationGatewayFirewallMode firewallMode, string ruleSetType, string ruleSetVersion)
        {
            if (ruleSetType == null)
            {
                throw new ArgumentNullException(nameof(ruleSetType));
            }
            if (ruleSetVersion == null)
            {
                throw new ArgumentNullException(nameof(ruleSetVersion));
            }

            Enabled        = enabled;
            FirewallMode   = firewallMode;
            RuleSetType    = ruleSetType;
            RuleSetVersion = ruleSetVersion;
        }
        public ApplicationGatewayWebApplicationFirewallConfiguration(bool enabled, ApplicationGatewayFirewallMode firewallMode, string ruleSetType, string ruleSetVersion)
        {
            if (ruleSetType == null)
            {
                throw new ArgumentNullException(nameof(ruleSetType));
            }
            if (ruleSetVersion == null)
            {
                throw new ArgumentNullException(nameof(ruleSetVersion));
            }

            Enabled            = enabled;
            FirewallMode       = firewallMode;
            RuleSetType        = ruleSetType;
            RuleSetVersion     = ruleSetVersion;
            DisabledRuleGroups = new ChangeTrackingList <ApplicationGatewayFirewallDisabledRuleGroup>();
            Exclusions         = new ChangeTrackingList <ApplicationGatewayFirewallExclusion>();
        }
Ejemplo n.º 4
0
        internal static ApplicationGatewayWebApplicationFirewallConfiguration DeserializeApplicationGatewayWebApplicationFirewallConfiguration(JsonElement element)
        {
            bool enabled = default;
            ApplicationGatewayFirewallMode firewallMode = default;
            string ruleSetType    = default;
            string ruleSetVersion = default;
            IList <ApplicationGatewayFirewallDisabledRuleGroup> disabledRuleGroups = default;
            bool?requestBodyCheck       = default;
            int? maxRequestBodySize     = default;
            int? maxRequestBodySizeInKb = default;
            int? fileUploadLimitInMb    = default;
            IList <ApplicationGatewayFirewallExclusion> exclusions = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("enabled"))
                {
                    enabled = property.Value.GetBoolean();
                    continue;
                }
                if (property.NameEquals("firewallMode"))
                {
                    firewallMode = new ApplicationGatewayFirewallMode(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("ruleSetType"))
                {
                    ruleSetType = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("ruleSetVersion"))
                {
                    ruleSetVersion = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("disabledRuleGroups"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    List <ApplicationGatewayFirewallDisabledRuleGroup> array = new List <ApplicationGatewayFirewallDisabledRuleGroup>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        if (item.ValueKind == JsonValueKind.Null)
                        {
                            array.Add(null);
                        }
                        else
                        {
                            array.Add(ApplicationGatewayFirewallDisabledRuleGroup.DeserializeApplicationGatewayFirewallDisabledRuleGroup(item));
                        }
                    }
                    disabledRuleGroups = array;
                    continue;
                }
                if (property.NameEquals("requestBodyCheck"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    requestBodyCheck = property.Value.GetBoolean();
                    continue;
                }
                if (property.NameEquals("maxRequestBodySize"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    maxRequestBodySize = property.Value.GetInt32();
                    continue;
                }
                if (property.NameEquals("maxRequestBodySizeInKb"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    maxRequestBodySizeInKb = property.Value.GetInt32();
                    continue;
                }
                if (property.NameEquals("fileUploadLimitInMb"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    fileUploadLimitInMb = property.Value.GetInt32();
                    continue;
                }
                if (property.NameEquals("exclusions"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    List <ApplicationGatewayFirewallExclusion> array = new List <ApplicationGatewayFirewallExclusion>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        if (item.ValueKind == JsonValueKind.Null)
                        {
                            array.Add(null);
                        }
                        else
                        {
                            array.Add(ApplicationGatewayFirewallExclusion.DeserializeApplicationGatewayFirewallExclusion(item));
                        }
                    }
                    exclusions = array;
                    continue;
                }
            }
            return(new ApplicationGatewayWebApplicationFirewallConfiguration(enabled, firewallMode, ruleSetType, ruleSetVersion, disabledRuleGroups, requestBodyCheck, maxRequestBodySize, maxRequestBodySizeInKb, fileUploadLimitInMb, exclusions));
        }
        internal static ApplicationGatewayWebApplicationFirewallConfiguration DeserializeApplicationGatewayWebApplicationFirewallConfiguration(JsonElement element)
        {
            bool enabled = default;
            ApplicationGatewayFirewallMode firewallMode = default;
            string ruleSetType    = default;
            string ruleSetVersion = default;
            Optional <IList <ApplicationGatewayFirewallDisabledRuleGroup> > disabledRuleGroups = default;
            Optional <bool> requestBodyCheck       = default;
            Optional <int>  maxRequestBodySize     = default;
            Optional <int>  maxRequestBodySizeInKb = default;
            Optional <int>  fileUploadLimitInMb    = default;
            Optional <IList <ApplicationGatewayFirewallExclusion> > exclusions = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("enabled"))
                {
                    enabled = property.Value.GetBoolean();
                    continue;
                }
                if (property.NameEquals("firewallMode"))
                {
                    firewallMode = new ApplicationGatewayFirewallMode(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("ruleSetType"))
                {
                    ruleSetType = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("ruleSetVersion"))
                {
                    ruleSetVersion = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("disabledRuleGroups"))
                {
                    List <ApplicationGatewayFirewallDisabledRuleGroup> array = new List <ApplicationGatewayFirewallDisabledRuleGroup>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(ApplicationGatewayFirewallDisabledRuleGroup.DeserializeApplicationGatewayFirewallDisabledRuleGroup(item));
                    }
                    disabledRuleGroups = array;
                    continue;
                }
                if (property.NameEquals("requestBodyCheck"))
                {
                    requestBodyCheck = property.Value.GetBoolean();
                    continue;
                }
                if (property.NameEquals("maxRequestBodySize"))
                {
                    maxRequestBodySize = property.Value.GetInt32();
                    continue;
                }
                if (property.NameEquals("maxRequestBodySizeInKb"))
                {
                    maxRequestBodySizeInKb = property.Value.GetInt32();
                    continue;
                }
                if (property.NameEquals("fileUploadLimitInMb"))
                {
                    fileUploadLimitInMb = property.Value.GetInt32();
                    continue;
                }
                if (property.NameEquals("exclusions"))
                {
                    List <ApplicationGatewayFirewallExclusion> array = new List <ApplicationGatewayFirewallExclusion>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(ApplicationGatewayFirewallExclusion.DeserializeApplicationGatewayFirewallExclusion(item));
                    }
                    exclusions = array;
                    continue;
                }
            }
            return(new ApplicationGatewayWebApplicationFirewallConfiguration(enabled, firewallMode, ruleSetType, ruleSetVersion, Optional.ToList(disabledRuleGroups), Optional.ToNullable(requestBodyCheck), Optional.ToNullable(maxRequestBodySize), Optional.ToNullable(maxRequestBodySizeInKb), Optional.ToNullable(fileUploadLimitInMb), Optional.ToList(exclusions)));
        }