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