| | 1 | | // Copyright (c) Microsoft Corporation. All rights reserved. |
| | 2 | | // Licensed under the MIT License. |
| | 3 | |
|
| | 4 | | // <auto-generated/> |
| | 5 | |
|
| | 6 | | #nullable disable |
| | 7 | |
|
| | 8 | | using System.Collections.Generic; |
| | 9 | | using System.Text.Json; |
| | 10 | | using Azure.Core; |
| | 11 | |
|
| | 12 | | namespace Azure.ResourceManager.Network.Models |
| | 13 | | { |
| | 14 | | public partial class ManagedRulesDefinition : IUtf8JsonSerializable |
| | 15 | | { |
| | 16 | | void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) |
| | 17 | | { |
| 0 | 18 | | writer.WriteStartObject(); |
| 0 | 19 | | if (Exclusions != null) |
| | 20 | | { |
| 0 | 21 | | writer.WritePropertyName("exclusions"); |
| 0 | 22 | | writer.WriteStartArray(); |
| 0 | 23 | | foreach (var item in Exclusions) |
| | 24 | | { |
| 0 | 25 | | writer.WriteObjectValue(item); |
| | 26 | | } |
| 0 | 27 | | writer.WriteEndArray(); |
| | 28 | | } |
| 0 | 29 | | writer.WritePropertyName("managedRuleSets"); |
| 0 | 30 | | writer.WriteStartArray(); |
| 0 | 31 | | foreach (var item in ManagedRuleSets) |
| | 32 | | { |
| 0 | 33 | | writer.WriteObjectValue(item); |
| | 34 | | } |
| 0 | 35 | | writer.WriteEndArray(); |
| 0 | 36 | | writer.WriteEndObject(); |
| 0 | 37 | | } |
| | 38 | |
|
| | 39 | | internal static ManagedRulesDefinition DeserializeManagedRulesDefinition(JsonElement element) |
| | 40 | | { |
| 0 | 41 | | IList<OwaspCrsExclusionEntry> exclusions = default; |
| 0 | 42 | | IList<ManagedRuleSet> managedRuleSets = default; |
| 0 | 43 | | foreach (var property in element.EnumerateObject()) |
| | 44 | | { |
| 0 | 45 | | if (property.NameEquals("exclusions")) |
| | 46 | | { |
| 0 | 47 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 48 | | { |
| | 49 | | continue; |
| | 50 | | } |
| 0 | 51 | | List<OwaspCrsExclusionEntry> array = new List<OwaspCrsExclusionEntry>(); |
| 0 | 52 | | foreach (var item in property.Value.EnumerateArray()) |
| | 53 | | { |
| 0 | 54 | | if (item.ValueKind == JsonValueKind.Null) |
| | 55 | | { |
| 0 | 56 | | array.Add(null); |
| | 57 | | } |
| | 58 | | else |
| | 59 | | { |
| 0 | 60 | | array.Add(OwaspCrsExclusionEntry.DeserializeOwaspCrsExclusionEntry(item)); |
| | 61 | | } |
| | 62 | | } |
| 0 | 63 | | exclusions = array; |
| 0 | 64 | | continue; |
| | 65 | | } |
| 0 | 66 | | if (property.NameEquals("managedRuleSets")) |
| | 67 | | { |
| 0 | 68 | | List<ManagedRuleSet> array = new List<ManagedRuleSet>(); |
| 0 | 69 | | foreach (var item in property.Value.EnumerateArray()) |
| | 70 | | { |
| 0 | 71 | | if (item.ValueKind == JsonValueKind.Null) |
| | 72 | | { |
| 0 | 73 | | array.Add(null); |
| | 74 | | } |
| | 75 | | else |
| | 76 | | { |
| 0 | 77 | | array.Add(ManagedRuleSet.DeserializeManagedRuleSet(item)); |
| | 78 | | } |
| | 79 | | } |
| 0 | 80 | | managedRuleSets = array; |
| | 81 | | continue; |
| | 82 | | } |
| | 83 | | } |
| 0 | 84 | | return new ManagedRulesDefinition(exclusions, managedRuleSets); |
| | 85 | | } |
| | 86 | | } |
| | 87 | | } |