| | 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.Text.Json; |
| | 9 | | using Azure.Core; |
| | 10 | |
|
| | 11 | | namespace Azure.ResourceManager.Network.Models |
| | 12 | | { |
| | 13 | | public partial class FirewallPolicyRule : IUtf8JsonSerializable |
| | 14 | | { |
| | 15 | | void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) |
| | 16 | | { |
| 0 | 17 | | writer.WriteStartObject(); |
| 0 | 18 | | writer.WritePropertyName("ruleType"); |
| 0 | 19 | | writer.WriteStringValue(RuleType.ToString()); |
| 0 | 20 | | if (Name != null) |
| | 21 | | { |
| 0 | 22 | | writer.WritePropertyName("name"); |
| 0 | 23 | | writer.WriteStringValue(Name); |
| | 24 | | } |
| 0 | 25 | | if (Priority != null) |
| | 26 | | { |
| 0 | 27 | | writer.WritePropertyName("priority"); |
| 0 | 28 | | writer.WriteNumberValue(Priority.Value); |
| | 29 | | } |
| 0 | 30 | | writer.WriteEndObject(); |
| 0 | 31 | | } |
| | 32 | |
|
| | 33 | | internal static FirewallPolicyRule DeserializeFirewallPolicyRule(JsonElement element) |
| | 34 | | { |
| 0 | 35 | | if (element.TryGetProperty("ruleType", out JsonElement discriminator)) |
| | 36 | | { |
| 0 | 37 | | switch (discriminator.GetString()) |
| | 38 | | { |
| 0 | 39 | | case "FirewallPolicyFilterRule": return FirewallPolicyFilterRule.DeserializeFirewallPolicyFilterRule |
| 0 | 40 | | case "FirewallPolicyNatRule": return FirewallPolicyNatRule.DeserializeFirewallPolicyNatRule(element) |
| | 41 | | } |
| | 42 | | } |
| 0 | 43 | | FirewallPolicyRuleType ruleType = default; |
| 0 | 44 | | string name = default; |
| 0 | 45 | | int? priority = default; |
| 0 | 46 | | foreach (var property in element.EnumerateObject()) |
| | 47 | | { |
| 0 | 48 | | if (property.NameEquals("ruleType")) |
| | 49 | | { |
| 0 | 50 | | ruleType = new FirewallPolicyRuleType(property.Value.GetString()); |
| 0 | 51 | | continue; |
| | 52 | | } |
| 0 | 53 | | if (property.NameEquals("name")) |
| | 54 | | { |
| 0 | 55 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 56 | | { |
| | 57 | | continue; |
| | 58 | | } |
| 0 | 59 | | name = property.Value.GetString(); |
| 0 | 60 | | continue; |
| | 61 | | } |
| 0 | 62 | | if (property.NameEquals("priority")) |
| | 63 | | { |
| 0 | 64 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 65 | | { |
| | 66 | | continue; |
| | 67 | | } |
| 0 | 68 | | priority = property.Value.GetInt32(); |
| | 69 | | continue; |
| | 70 | | } |
| | 71 | | } |
| 0 | 72 | | return new FirewallPolicyRule(ruleType, name, priority); |
| | 73 | | } |
| | 74 | | } |
| | 75 | | } |