| | 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 FirewallPolicyFilterRule : IUtf8JsonSerializable |
| | 15 | | { |
| | 16 | | void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) |
| | 17 | | { |
| 0 | 18 | | writer.WriteStartObject(); |
| 0 | 19 | | if (Action != null) |
| | 20 | | { |
| 0 | 21 | | writer.WritePropertyName("action"); |
| 0 | 22 | | writer.WriteObjectValue(Action); |
| | 23 | | } |
| 0 | 24 | | if (RuleConditions != null) |
| | 25 | | { |
| 0 | 26 | | writer.WritePropertyName("ruleConditions"); |
| 0 | 27 | | writer.WriteStartArray(); |
| 0 | 28 | | foreach (var item in RuleConditions) |
| | 29 | | { |
| 0 | 30 | | writer.WriteObjectValue(item); |
| | 31 | | } |
| 0 | 32 | | writer.WriteEndArray(); |
| | 33 | | } |
| 0 | 34 | | writer.WritePropertyName("ruleType"); |
| 0 | 35 | | writer.WriteStringValue(RuleType.ToString()); |
| 0 | 36 | | if (Name != null) |
| | 37 | | { |
| 0 | 38 | | writer.WritePropertyName("name"); |
| 0 | 39 | | writer.WriteStringValue(Name); |
| | 40 | | } |
| 0 | 41 | | if (Priority != null) |
| | 42 | | { |
| 0 | 43 | | writer.WritePropertyName("priority"); |
| 0 | 44 | | writer.WriteNumberValue(Priority.Value); |
| | 45 | | } |
| 0 | 46 | | writer.WriteEndObject(); |
| 0 | 47 | | } |
| | 48 | |
|
| | 49 | | internal static FirewallPolicyFilterRule DeserializeFirewallPolicyFilterRule(JsonElement element) |
| | 50 | | { |
| 0 | 51 | | FirewallPolicyFilterRuleAction action = default; |
| 0 | 52 | | IList<FirewallPolicyRuleCondition> ruleConditions = default; |
| 0 | 53 | | FirewallPolicyRuleType ruleType = default; |
| 0 | 54 | | string name = default; |
| 0 | 55 | | int? priority = default; |
| 0 | 56 | | foreach (var property in element.EnumerateObject()) |
| | 57 | | { |
| 0 | 58 | | if (property.NameEquals("action")) |
| | 59 | | { |
| 0 | 60 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 61 | | { |
| | 62 | | continue; |
| | 63 | | } |
| 0 | 64 | | action = FirewallPolicyFilterRuleAction.DeserializeFirewallPolicyFilterRuleAction(property.Value); |
| 0 | 65 | | continue; |
| | 66 | | } |
| 0 | 67 | | if (property.NameEquals("ruleConditions")) |
| | 68 | | { |
| 0 | 69 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 70 | | { |
| | 71 | | continue; |
| | 72 | | } |
| 0 | 73 | | List<FirewallPolicyRuleCondition> array = new List<FirewallPolicyRuleCondition>(); |
| 0 | 74 | | foreach (var item in property.Value.EnumerateArray()) |
| | 75 | | { |
| 0 | 76 | | if (item.ValueKind == JsonValueKind.Null) |
| | 77 | | { |
| 0 | 78 | | array.Add(null); |
| | 79 | | } |
| | 80 | | else |
| | 81 | | { |
| 0 | 82 | | array.Add(FirewallPolicyRuleCondition.DeserializeFirewallPolicyRuleCondition(item)); |
| | 83 | | } |
| | 84 | | } |
| 0 | 85 | | ruleConditions = array; |
| 0 | 86 | | continue; |
| | 87 | | } |
| 0 | 88 | | if (property.NameEquals("ruleType")) |
| | 89 | | { |
| 0 | 90 | | ruleType = new FirewallPolicyRuleType(property.Value.GetString()); |
| 0 | 91 | | continue; |
| | 92 | | } |
| 0 | 93 | | if (property.NameEquals("name")) |
| | 94 | | { |
| 0 | 95 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 96 | | { |
| | 97 | | continue; |
| | 98 | | } |
| 0 | 99 | | name = property.Value.GetString(); |
| 0 | 100 | | continue; |
| | 101 | | } |
| 0 | 102 | | if (property.NameEquals("priority")) |
| | 103 | | { |
| 0 | 104 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 105 | | { |
| | 106 | | continue; |
| | 107 | | } |
| 0 | 108 | | priority = property.Value.GetInt32(); |
| | 109 | | continue; |
| | 110 | | } |
| | 111 | | } |
| 0 | 112 | | return new FirewallPolicyFilterRule(ruleType, name, priority, action, ruleConditions); |
| | 113 | | } |
| | 114 | | } |
| | 115 | | } |