< Summary

Class:Azure.ResourceManager.Network.Models.ManagedRulesDefinition
Assembly:Azure.ResourceManager.Network
File(s):C:\Git\azure-sdk-for-net\sdk\network\Azure.ResourceManager.Network\src\Generated\Models\ManagedRulesDefinition.cs
C:\Git\azure-sdk-for-net\sdk\network\Azure.ResourceManager.Network\src\Generated\Models\ManagedRulesDefinition.Serialization.cs
Covered lines:0
Uncovered lines:45
Coverable lines:45
Total lines:130
Line coverage:0% (0 of 45)
Covered branches:0
Total branches:26
Branch coverage:0% (0 of 26)

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
.ctor(...)-0%0%
.ctor(...)-0%0%
get_Exclusions()-0%100%
get_ManagedRuleSets()-0%100%
Azure.Core.IUtf8JsonSerializable.Write(...)-0%0%
DeserializeManagedRulesDefinition(...)-0%0%

File(s)

C:\Git\azure-sdk-for-net\sdk\network\Azure.ResourceManager.Network\src\Generated\Models\ManagedRulesDefinition.cs

#LineLine coverage
 1// Copyright (c) Microsoft Corporation. All rights reserved.
 2// Licensed under the MIT License.
 3
 4// <auto-generated/>
 5
 6#nullable disable
 7
 8using System;
 9using System.Collections.Generic;
 10using System.Linq;
 11
 12namespace Azure.ResourceManager.Network.Models
 13{
 14    /// <summary> Allow to exclude some variable satisfy the condition for the WAF check. </summary>
 15    public partial class ManagedRulesDefinition
 16    {
 17        /// <summary> Initializes a new instance of ManagedRulesDefinition. </summary>
 18        /// <param name="managedRuleSets"> The managed rule sets that are associated with the policy. </param>
 019        public ManagedRulesDefinition(IEnumerable<ManagedRuleSet> managedRuleSets)
 20        {
 021            if (managedRuleSets == null)
 22            {
 023                throw new ArgumentNullException(nameof(managedRuleSets));
 24            }
 25
 026            ManagedRuleSets = managedRuleSets.ToList();
 027        }
 28
 29        /// <summary> Initializes a new instance of ManagedRulesDefinition. </summary>
 30        /// <param name="exclusions"> The Exclusions that are applied on the policy. </param>
 31        /// <param name="managedRuleSets"> The managed rule sets that are associated with the policy. </param>
 032        internal ManagedRulesDefinition(IList<OwaspCrsExclusionEntry> exclusions, IList<ManagedRuleSet> managedRuleSets)
 33        {
 034            Exclusions = exclusions;
 035            ManagedRuleSets = managedRuleSets ?? new List<ManagedRuleSet>();
 036        }
 37
 38        /// <summary> The Exclusions that are applied on the policy. </summary>
 039        public IList<OwaspCrsExclusionEntry> Exclusions { get; set; }
 40        /// <summary> The managed rule sets that are associated with the policy. </summary>
 041        public IList<ManagedRuleSet> ManagedRuleSets { get; }
 42    }
 43}

C:\Git\azure-sdk-for-net\sdk\network\Azure.ResourceManager.Network\src\Generated\Models\ManagedRulesDefinition.Serialization.cs

#LineLine coverage
 1// Copyright (c) Microsoft Corporation. All rights reserved.
 2// Licensed under the MIT License.
 3
 4// <auto-generated/>
 5
 6#nullable disable
 7
 8using System.Collections.Generic;
 9using System.Text.Json;
 10using Azure.Core;
 11
 12namespace Azure.ResourceManager.Network.Models
 13{
 14    public partial class ManagedRulesDefinition : IUtf8JsonSerializable
 15    {
 16        void IUtf8JsonSerializable.Write(Utf8JsonWriter writer)
 17        {
 018            writer.WriteStartObject();
 019            if (Exclusions != null)
 20            {
 021                writer.WritePropertyName("exclusions");
 022                writer.WriteStartArray();
 023                foreach (var item in Exclusions)
 24                {
 025                    writer.WriteObjectValue(item);
 26                }
 027                writer.WriteEndArray();
 28            }
 029            writer.WritePropertyName("managedRuleSets");
 030            writer.WriteStartArray();
 031            foreach (var item in ManagedRuleSets)
 32            {
 033                writer.WriteObjectValue(item);
 34            }
 035            writer.WriteEndArray();
 036            writer.WriteEndObject();
 037        }
 38
 39        internal static ManagedRulesDefinition DeserializeManagedRulesDefinition(JsonElement element)
 40        {
 041            IList<OwaspCrsExclusionEntry> exclusions = default;
 042            IList<ManagedRuleSet> managedRuleSets = default;
 043            foreach (var property in element.EnumerateObject())
 44            {
 045                if (property.NameEquals("exclusions"))
 46                {
 047                    if (property.Value.ValueKind == JsonValueKind.Null)
 48                    {
 49                        continue;
 50                    }
 051                    List<OwaspCrsExclusionEntry> array = new List<OwaspCrsExclusionEntry>();
 052                    foreach (var item in property.Value.EnumerateArray())
 53                    {
 054                        if (item.ValueKind == JsonValueKind.Null)
 55                        {
 056                            array.Add(null);
 57                        }
 58                        else
 59                        {
 060                            array.Add(OwaspCrsExclusionEntry.DeserializeOwaspCrsExclusionEntry(item));
 61                        }
 62                    }
 063                    exclusions = array;
 064                    continue;
 65                }
 066                if (property.NameEquals("managedRuleSets"))
 67                {
 068                    List<ManagedRuleSet> array = new List<ManagedRuleSet>();
 069                    foreach (var item in property.Value.EnumerateArray())
 70                    {
 071                        if (item.ValueKind == JsonValueKind.Null)
 72                        {
 073                            array.Add(null);
 74                        }
 75                        else
 76                        {
 077                            array.Add(ManagedRuleSet.DeserializeManagedRuleSet(item));
 78                        }
 79                    }
 080                    managedRuleSets = array;
 81                    continue;
 82                }
 83            }
 084            return new ManagedRulesDefinition(exclusions, managedRuleSets);
 85        }
 86    }
 87}