| | 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 ManagedRuleSet : IUtf8JsonSerializable |
| | 15 | | { |
| | 16 | | void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) |
| | 17 | | { |
| 0 | 18 | | writer.WriteStartObject(); |
| 0 | 19 | | writer.WritePropertyName("ruleSetType"); |
| 0 | 20 | | writer.WriteStringValue(RuleSetType); |
| 0 | 21 | | writer.WritePropertyName("ruleSetVersion"); |
| 0 | 22 | | writer.WriteStringValue(RuleSetVersion); |
| 0 | 23 | | if (RuleGroupOverrides != null) |
| | 24 | | { |
| 0 | 25 | | writer.WritePropertyName("ruleGroupOverrides"); |
| 0 | 26 | | writer.WriteStartArray(); |
| 0 | 27 | | foreach (var item in RuleGroupOverrides) |
| | 28 | | { |
| 0 | 29 | | writer.WriteObjectValue(item); |
| | 30 | | } |
| 0 | 31 | | writer.WriteEndArray(); |
| | 32 | | } |
| 0 | 33 | | writer.WriteEndObject(); |
| 0 | 34 | | } |
| | 35 | |
|
| | 36 | | internal static ManagedRuleSet DeserializeManagedRuleSet(JsonElement element) |
| | 37 | | { |
| 0 | 38 | | string ruleSetType = default; |
| 0 | 39 | | string ruleSetVersion = default; |
| 0 | 40 | | IList<ManagedRuleGroupOverride> ruleGroupOverrides = default; |
| 0 | 41 | | foreach (var property in element.EnumerateObject()) |
| | 42 | | { |
| 0 | 43 | | if (property.NameEquals("ruleSetType")) |
| | 44 | | { |
| 0 | 45 | | ruleSetType = property.Value.GetString(); |
| 0 | 46 | | continue; |
| | 47 | | } |
| 0 | 48 | | if (property.NameEquals("ruleSetVersion")) |
| | 49 | | { |
| 0 | 50 | | ruleSetVersion = property.Value.GetString(); |
| 0 | 51 | | continue; |
| | 52 | | } |
| 0 | 53 | | if (property.NameEquals("ruleGroupOverrides")) |
| | 54 | | { |
| 0 | 55 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 56 | | { |
| | 57 | | continue; |
| | 58 | | } |
| 0 | 59 | | List<ManagedRuleGroupOverride> array = new List<ManagedRuleGroupOverride>(); |
| 0 | 60 | | foreach (var item in property.Value.EnumerateArray()) |
| | 61 | | { |
| 0 | 62 | | if (item.ValueKind == JsonValueKind.Null) |
| | 63 | | { |
| 0 | 64 | | array.Add(null); |
| | 65 | | } |
| | 66 | | else |
| | 67 | | { |
| 0 | 68 | | array.Add(ManagedRuleGroupOverride.DeserializeManagedRuleGroupOverride(item)); |
| | 69 | | } |
| | 70 | | } |
| 0 | 71 | | ruleGroupOverrides = array; |
| | 72 | | continue; |
| | 73 | | } |
| | 74 | | } |
| 0 | 75 | | return new ManagedRuleSet(ruleSetType, ruleSetVersion, ruleGroupOverrides); |
| | 76 | | } |
| | 77 | | } |
| | 78 | | } |