| | | 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 NatRuleCondition : IUtf8JsonSerializable |
| | | 15 | | { |
| | | 16 | | void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) |
| | | 17 | | { |
| | 0 | 18 | | writer.WriteStartObject(); |
| | 0 | 19 | | if (IpProtocols != null) |
| | | 20 | | { |
| | 0 | 21 | | writer.WritePropertyName("ipProtocols"); |
| | 0 | 22 | | writer.WriteStartArray(); |
| | 0 | 23 | | foreach (var item in IpProtocols) |
| | | 24 | | { |
| | 0 | 25 | | writer.WriteStringValue(item.ToString()); |
| | | 26 | | } |
| | 0 | 27 | | writer.WriteEndArray(); |
| | | 28 | | } |
| | 0 | 29 | | if (SourceAddresses != null) |
| | | 30 | | { |
| | 0 | 31 | | writer.WritePropertyName("sourceAddresses"); |
| | 0 | 32 | | writer.WriteStartArray(); |
| | 0 | 33 | | foreach (var item in SourceAddresses) |
| | | 34 | | { |
| | 0 | 35 | | writer.WriteStringValue(item); |
| | | 36 | | } |
| | 0 | 37 | | writer.WriteEndArray(); |
| | | 38 | | } |
| | 0 | 39 | | if (DestinationAddresses != null) |
| | | 40 | | { |
| | 0 | 41 | | writer.WritePropertyName("destinationAddresses"); |
| | 0 | 42 | | writer.WriteStartArray(); |
| | 0 | 43 | | foreach (var item in DestinationAddresses) |
| | | 44 | | { |
| | 0 | 45 | | writer.WriteStringValue(item); |
| | | 46 | | } |
| | 0 | 47 | | writer.WriteEndArray(); |
| | | 48 | | } |
| | 0 | 49 | | if (DestinationPorts != null) |
| | | 50 | | { |
| | 0 | 51 | | writer.WritePropertyName("destinationPorts"); |
| | 0 | 52 | | writer.WriteStartArray(); |
| | 0 | 53 | | foreach (var item in DestinationPorts) |
| | | 54 | | { |
| | 0 | 55 | | writer.WriteStringValue(item); |
| | | 56 | | } |
| | 0 | 57 | | writer.WriteEndArray(); |
| | | 58 | | } |
| | 0 | 59 | | if (SourceIpGroups != null) |
| | | 60 | | { |
| | 0 | 61 | | writer.WritePropertyName("sourceIpGroups"); |
| | 0 | 62 | | writer.WriteStartArray(); |
| | 0 | 63 | | foreach (var item in SourceIpGroups) |
| | | 64 | | { |
| | 0 | 65 | | writer.WriteStringValue(item); |
| | | 66 | | } |
| | 0 | 67 | | writer.WriteEndArray(); |
| | | 68 | | } |
| | 0 | 69 | | if (TerminateTLS != null) |
| | | 70 | | { |
| | 0 | 71 | | writer.WritePropertyName("terminateTLS"); |
| | 0 | 72 | | writer.WriteBooleanValue(TerminateTLS.Value); |
| | | 73 | | } |
| | 0 | 74 | | if (Name != null) |
| | | 75 | | { |
| | 0 | 76 | | writer.WritePropertyName("name"); |
| | 0 | 77 | | writer.WriteStringValue(Name); |
| | | 78 | | } |
| | 0 | 79 | | if (Description != null) |
| | | 80 | | { |
| | 0 | 81 | | writer.WritePropertyName("description"); |
| | 0 | 82 | | writer.WriteStringValue(Description); |
| | | 83 | | } |
| | 0 | 84 | | writer.WritePropertyName("ruleConditionType"); |
| | 0 | 85 | | writer.WriteStringValue(RuleConditionType.ToString()); |
| | 0 | 86 | | writer.WriteEndObject(); |
| | 0 | 87 | | } |
| | | 88 | | |
| | | 89 | | internal static NatRuleCondition DeserializeNatRuleCondition(JsonElement element) |
| | | 90 | | { |
| | 0 | 91 | | IList<FirewallPolicyRuleConditionNetworkProtocol> ipProtocols = default; |
| | 0 | 92 | | IList<string> sourceAddresses = default; |
| | 0 | 93 | | IList<string> destinationAddresses = default; |
| | 0 | 94 | | IList<string> destinationPorts = default; |
| | 0 | 95 | | IList<string> sourceIpGroups = default; |
| | 0 | 96 | | bool? terminateTLS = default; |
| | 0 | 97 | | string name = default; |
| | 0 | 98 | | string description = default; |
| | 0 | 99 | | FirewallPolicyRuleConditionType ruleConditionType = default; |
| | 0 | 100 | | foreach (var property in element.EnumerateObject()) |
| | | 101 | | { |
| | 0 | 102 | | if (property.NameEquals("ipProtocols")) |
| | | 103 | | { |
| | 0 | 104 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | | 105 | | { |
| | | 106 | | continue; |
| | | 107 | | } |
| | 0 | 108 | | List<FirewallPolicyRuleConditionNetworkProtocol> array = new List<FirewallPolicyRuleConditionNetwork |
| | 0 | 109 | | foreach (var item in property.Value.EnumerateArray()) |
| | | 110 | | { |
| | 0 | 111 | | array.Add(new FirewallPolicyRuleConditionNetworkProtocol(item.GetString())); |
| | | 112 | | } |
| | 0 | 113 | | ipProtocols = array; |
| | 0 | 114 | | continue; |
| | | 115 | | } |
| | 0 | 116 | | if (property.NameEquals("sourceAddresses")) |
| | | 117 | | { |
| | 0 | 118 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | | 119 | | { |
| | | 120 | | continue; |
| | | 121 | | } |
| | 0 | 122 | | List<string> array = new List<string>(); |
| | 0 | 123 | | foreach (var item in property.Value.EnumerateArray()) |
| | | 124 | | { |
| | 0 | 125 | | if (item.ValueKind == JsonValueKind.Null) |
| | | 126 | | { |
| | 0 | 127 | | array.Add(null); |
| | | 128 | | } |
| | | 129 | | else |
| | | 130 | | { |
| | 0 | 131 | | array.Add(item.GetString()); |
| | | 132 | | } |
| | | 133 | | } |
| | 0 | 134 | | sourceAddresses = array; |
| | 0 | 135 | | continue; |
| | | 136 | | } |
| | 0 | 137 | | if (property.NameEquals("destinationAddresses")) |
| | | 138 | | { |
| | 0 | 139 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | | 140 | | { |
| | | 141 | | continue; |
| | | 142 | | } |
| | 0 | 143 | | List<string> array = new List<string>(); |
| | 0 | 144 | | foreach (var item in property.Value.EnumerateArray()) |
| | | 145 | | { |
| | 0 | 146 | | if (item.ValueKind == JsonValueKind.Null) |
| | | 147 | | { |
| | 0 | 148 | | array.Add(null); |
| | | 149 | | } |
| | | 150 | | else |
| | | 151 | | { |
| | 0 | 152 | | array.Add(item.GetString()); |
| | | 153 | | } |
| | | 154 | | } |
| | 0 | 155 | | destinationAddresses = array; |
| | 0 | 156 | | continue; |
| | | 157 | | } |
| | 0 | 158 | | if (property.NameEquals("destinationPorts")) |
| | | 159 | | { |
| | 0 | 160 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | | 161 | | { |
| | | 162 | | continue; |
| | | 163 | | } |
| | 0 | 164 | | List<string> array = new List<string>(); |
| | 0 | 165 | | foreach (var item in property.Value.EnumerateArray()) |
| | | 166 | | { |
| | 0 | 167 | | if (item.ValueKind == JsonValueKind.Null) |
| | | 168 | | { |
| | 0 | 169 | | array.Add(null); |
| | | 170 | | } |
| | | 171 | | else |
| | | 172 | | { |
| | 0 | 173 | | array.Add(item.GetString()); |
| | | 174 | | } |
| | | 175 | | } |
| | 0 | 176 | | destinationPorts = array; |
| | 0 | 177 | | continue; |
| | | 178 | | } |
| | 0 | 179 | | if (property.NameEquals("sourceIpGroups")) |
| | | 180 | | { |
| | 0 | 181 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | | 182 | | { |
| | | 183 | | continue; |
| | | 184 | | } |
| | 0 | 185 | | List<string> array = new List<string>(); |
| | 0 | 186 | | foreach (var item in property.Value.EnumerateArray()) |
| | | 187 | | { |
| | 0 | 188 | | if (item.ValueKind == JsonValueKind.Null) |
| | | 189 | | { |
| | 0 | 190 | | array.Add(null); |
| | | 191 | | } |
| | | 192 | | else |
| | | 193 | | { |
| | 0 | 194 | | array.Add(item.GetString()); |
| | | 195 | | } |
| | | 196 | | } |
| | 0 | 197 | | sourceIpGroups = array; |
| | 0 | 198 | | continue; |
| | | 199 | | } |
| | 0 | 200 | | if (property.NameEquals("terminateTLS")) |
| | | 201 | | { |
| | 0 | 202 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | | 203 | | { |
| | | 204 | | continue; |
| | | 205 | | } |
| | 0 | 206 | | terminateTLS = property.Value.GetBoolean(); |
| | 0 | 207 | | continue; |
| | | 208 | | } |
| | 0 | 209 | | if (property.NameEquals("name")) |
| | | 210 | | { |
| | 0 | 211 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | | 212 | | { |
| | | 213 | | continue; |
| | | 214 | | } |
| | 0 | 215 | | name = property.Value.GetString(); |
| | 0 | 216 | | continue; |
| | | 217 | | } |
| | 0 | 218 | | if (property.NameEquals("description")) |
| | | 219 | | { |
| | 0 | 220 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | | 221 | | { |
| | | 222 | | continue; |
| | | 223 | | } |
| | 0 | 224 | | description = property.Value.GetString(); |
| | 0 | 225 | | continue; |
| | | 226 | | } |
| | 0 | 227 | | if (property.NameEquals("ruleConditionType")) |
| | | 228 | | { |
| | 0 | 229 | | ruleConditionType = new FirewallPolicyRuleConditionType(property.Value.GetString()); |
| | | 230 | | continue; |
| | | 231 | | } |
| | | 232 | | } |
| | 0 | 233 | | return new NatRuleCondition(name, description, ruleConditionType, ipProtocols, sourceAddresses, destinationA |
| | | 234 | | } |
| | | 235 | | } |
| | | 236 | | } |