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