| | 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 SecurityRule : IUtf8JsonSerializable |
| | 15 | | { |
| | 16 | | void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) |
| | 17 | | { |
| 104 | 18 | | writer.WriteStartObject(); |
| 104 | 19 | | if (Name != null) |
| | 20 | | { |
| 104 | 21 | | writer.WritePropertyName("name"); |
| 104 | 22 | | writer.WriteStringValue(Name); |
| | 23 | | } |
| 104 | 24 | | if (Etag != null) |
| | 25 | | { |
| 56 | 26 | | writer.WritePropertyName("etag"); |
| 56 | 27 | | writer.WriteStringValue(Etag); |
| | 28 | | } |
| 104 | 29 | | if (Id != null) |
| | 30 | | { |
| 56 | 31 | | writer.WritePropertyName("id"); |
| 56 | 32 | | writer.WriteStringValue(Id); |
| | 33 | | } |
| 104 | 34 | | writer.WritePropertyName("properties"); |
| 104 | 35 | | writer.WriteStartObject(); |
| 104 | 36 | | if (Description != null) |
| | 37 | | { |
| 104 | 38 | | writer.WritePropertyName("description"); |
| 104 | 39 | | writer.WriteStringValue(Description); |
| | 40 | | } |
| 104 | 41 | | if (Protocol != null) |
| | 42 | | { |
| 104 | 43 | | writer.WritePropertyName("protocol"); |
| 104 | 44 | | writer.WriteStringValue(Protocol.Value.ToString()); |
| | 45 | | } |
| 104 | 46 | | if (SourcePortRange != null) |
| | 47 | | { |
| 104 | 48 | | writer.WritePropertyName("sourcePortRange"); |
| 104 | 49 | | writer.WriteStringValue(SourcePortRange); |
| | 50 | | } |
| 104 | 51 | | if (DestinationPortRange != null) |
| | 52 | | { |
| 104 | 53 | | writer.WritePropertyName("destinationPortRange"); |
| 104 | 54 | | writer.WriteStringValue(DestinationPortRange); |
| | 55 | | } |
| 104 | 56 | | if (SourceAddressPrefix != null) |
| | 57 | | { |
| 104 | 58 | | writer.WritePropertyName("sourceAddressPrefix"); |
| 104 | 59 | | writer.WriteStringValue(SourceAddressPrefix); |
| | 60 | | } |
| 104 | 61 | | if (SourceAddressPrefixes != null) |
| | 62 | | { |
| 56 | 63 | | writer.WritePropertyName("sourceAddressPrefixes"); |
| 56 | 64 | | writer.WriteStartArray(); |
| 0 | 65 | | foreach (var item in SourceAddressPrefixes) |
| | 66 | | { |
| 0 | 67 | | writer.WriteStringValue(item); |
| | 68 | | } |
| 56 | 69 | | writer.WriteEndArray(); |
| | 70 | | } |
| 104 | 71 | | if (SourceApplicationSecurityGroups != null) |
| | 72 | | { |
| 0 | 73 | | writer.WritePropertyName("sourceApplicationSecurityGroups"); |
| 0 | 74 | | writer.WriteStartArray(); |
| 0 | 75 | | foreach (var item in SourceApplicationSecurityGroups) |
| | 76 | | { |
| 0 | 77 | | writer.WriteObjectValue(item); |
| | 78 | | } |
| 0 | 79 | | writer.WriteEndArray(); |
| | 80 | | } |
| 104 | 81 | | if (DestinationAddressPrefix != null) |
| | 82 | | { |
| 104 | 83 | | writer.WritePropertyName("destinationAddressPrefix"); |
| 104 | 84 | | writer.WriteStringValue(DestinationAddressPrefix); |
| | 85 | | } |
| 104 | 86 | | if (DestinationAddressPrefixes != null) |
| | 87 | | { |
| 56 | 88 | | writer.WritePropertyName("destinationAddressPrefixes"); |
| 56 | 89 | | writer.WriteStartArray(); |
| 0 | 90 | | foreach (var item in DestinationAddressPrefixes) |
| | 91 | | { |
| 0 | 92 | | writer.WriteStringValue(item); |
| | 93 | | } |
| 56 | 94 | | writer.WriteEndArray(); |
| | 95 | | } |
| 104 | 96 | | if (DestinationApplicationSecurityGroups != null) |
| | 97 | | { |
| 0 | 98 | | writer.WritePropertyName("destinationApplicationSecurityGroups"); |
| 0 | 99 | | writer.WriteStartArray(); |
| 0 | 100 | | foreach (var item in DestinationApplicationSecurityGroups) |
| | 101 | | { |
| 0 | 102 | | writer.WriteObjectValue(item); |
| | 103 | | } |
| 0 | 104 | | writer.WriteEndArray(); |
| | 105 | | } |
| 104 | 106 | | if (SourcePortRanges != null) |
| | 107 | | { |
| 56 | 108 | | writer.WritePropertyName("sourcePortRanges"); |
| 56 | 109 | | writer.WriteStartArray(); |
| 0 | 110 | | foreach (var item in SourcePortRanges) |
| | 111 | | { |
| 0 | 112 | | writer.WriteStringValue(item); |
| | 113 | | } |
| 56 | 114 | | writer.WriteEndArray(); |
| | 115 | | } |
| 104 | 116 | | if (DestinationPortRanges != null) |
| | 117 | | { |
| 56 | 118 | | writer.WritePropertyName("destinationPortRanges"); |
| 56 | 119 | | writer.WriteStartArray(); |
| 0 | 120 | | foreach (var item in DestinationPortRanges) |
| | 121 | | { |
| 0 | 122 | | writer.WriteStringValue(item); |
| | 123 | | } |
| 56 | 124 | | writer.WriteEndArray(); |
| | 125 | | } |
| 104 | 126 | | if (Access != null) |
| | 127 | | { |
| 104 | 128 | | writer.WritePropertyName("access"); |
| 104 | 129 | | writer.WriteStringValue(Access.Value.ToString()); |
| | 130 | | } |
| 104 | 131 | | if (Priority != null) |
| | 132 | | { |
| 104 | 133 | | writer.WritePropertyName("priority"); |
| 104 | 134 | | writer.WriteNumberValue(Priority.Value); |
| | 135 | | } |
| 104 | 136 | | if (Direction != null) |
| | 137 | | { |
| 104 | 138 | | writer.WritePropertyName("direction"); |
| 104 | 139 | | writer.WriteStringValue(Direction.Value.ToString()); |
| | 140 | | } |
| 104 | 141 | | if (ProvisioningState != null) |
| | 142 | | { |
| 56 | 143 | | writer.WritePropertyName("provisioningState"); |
| 56 | 144 | | writer.WriteStringValue(ProvisioningState.Value.ToString()); |
| | 145 | | } |
| 104 | 146 | | writer.WriteEndObject(); |
| 104 | 147 | | writer.WriteEndObject(); |
| 104 | 148 | | } |
| | 149 | |
|
| | 150 | | internal static SecurityRule DeserializeSecurityRule(JsonElement element) |
| | 151 | | { |
| 2788 | 152 | | string name = default; |
| 2788 | 153 | | string etag = default; |
| 2788 | 154 | | string id = default; |
| 2788 | 155 | | string description = default; |
| 2788 | 156 | | SecurityRuleProtocol? protocol = default; |
| 2788 | 157 | | string sourcePortRange = default; |
| 2788 | 158 | | string destinationPortRange = default; |
| 2788 | 159 | | string sourceAddressPrefix = default; |
| 2788 | 160 | | IList<string> sourceAddressPrefixes = default; |
| 2788 | 161 | | IList<ApplicationSecurityGroup> sourceApplicationSecurityGroups = default; |
| 2788 | 162 | | string destinationAddressPrefix = default; |
| 2788 | 163 | | IList<string> destinationAddressPrefixes = default; |
| 2788 | 164 | | IList<ApplicationSecurityGroup> destinationApplicationSecurityGroups = default; |
| 2788 | 165 | | IList<string> sourcePortRanges = default; |
| 2788 | 166 | | IList<string> destinationPortRanges = default; |
| 2788 | 167 | | SecurityRuleAccess? access = default; |
| 2788 | 168 | | int? priority = default; |
| 2788 | 169 | | SecurityRuleDirection? direction = default; |
| 2788 | 170 | | ProvisioningState? provisioningState = default; |
| 33456 | 171 | | foreach (var property in element.EnumerateObject()) |
| | 172 | | { |
| 13940 | 173 | | if (property.NameEquals("name")) |
| | 174 | | { |
| 2788 | 175 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 176 | | { |
| | 177 | | continue; |
| | 178 | | } |
| 2788 | 179 | | name = property.Value.GetString(); |
| 2788 | 180 | | continue; |
| | 181 | | } |
| 11152 | 182 | | if (property.NameEquals("etag")) |
| | 183 | | { |
| 2788 | 184 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 185 | | { |
| | 186 | | continue; |
| | 187 | | } |
| 2788 | 188 | | etag = property.Value.GetString(); |
| 2788 | 189 | | continue; |
| | 190 | | } |
| 8364 | 191 | | if (property.NameEquals("id")) |
| | 192 | | { |
| 2788 | 193 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 194 | | { |
| | 195 | | continue; |
| | 196 | | } |
| 2788 | 197 | | id = property.Value.GetString(); |
| 2788 | 198 | | continue; |
| | 199 | | } |
| 5576 | 200 | | if (property.NameEquals("properties")) |
| | 201 | | { |
| 78760 | 202 | | foreach (var property0 in property.Value.EnumerateObject()) |
| | 203 | | { |
| 36592 | 204 | | if (property0.NameEquals("description")) |
| | 205 | | { |
| 1684 | 206 | | if (property0.Value.ValueKind == JsonValueKind.Null) |
| | 207 | | { |
| | 208 | | continue; |
| | 209 | | } |
| 1684 | 210 | | description = property0.Value.GetString(); |
| 1684 | 211 | | continue; |
| | 212 | | } |
| 34908 | 213 | | if (property0.NameEquals("protocol")) |
| | 214 | | { |
| 2788 | 215 | | if (property0.Value.ValueKind == JsonValueKind.Null) |
| | 216 | | { |
| | 217 | | continue; |
| | 218 | | } |
| 2788 | 219 | | protocol = new SecurityRuleProtocol(property0.Value.GetString()); |
| 2788 | 220 | | continue; |
| | 221 | | } |
| 32120 | 222 | | if (property0.NameEquals("sourcePortRange")) |
| | 223 | | { |
| 2788 | 224 | | if (property0.Value.ValueKind == JsonValueKind.Null) |
| | 225 | | { |
| | 226 | | continue; |
| | 227 | | } |
| 2788 | 228 | | sourcePortRange = property0.Value.GetString(); |
| 2788 | 229 | | continue; |
| | 230 | | } |
| 29332 | 231 | | if (property0.NameEquals("destinationPortRange")) |
| | 232 | | { |
| 1708 | 233 | | if (property0.Value.ValueKind == JsonValueKind.Null) |
| | 234 | | { |
| | 235 | | continue; |
| | 236 | | } |
| 1708 | 237 | | destinationPortRange = property0.Value.GetString(); |
| 1708 | 238 | | continue; |
| | 239 | | } |
| 27624 | 240 | | if (property0.NameEquals("sourceAddressPrefix")) |
| | 241 | | { |
| 2532 | 242 | | if (property0.Value.ValueKind == JsonValueKind.Null) |
| | 243 | | { |
| | 244 | | continue; |
| | 245 | | } |
| 2532 | 246 | | sourceAddressPrefix = property0.Value.GetString(); |
| 2532 | 247 | | continue; |
| | 248 | | } |
| 25092 | 249 | | if (property0.NameEquals("sourceAddressPrefixes")) |
| | 250 | | { |
| 2788 | 251 | | if (property0.Value.ValueKind == JsonValueKind.Null) |
| | 252 | | { |
| | 253 | | continue; |
| | 254 | | } |
| 2788 | 255 | | List<string> array = new List<string>(); |
| 26840 | 256 | | foreach (var item in property0.Value.EnumerateArray()) |
| | 257 | | { |
| 10632 | 258 | | if (item.ValueKind == JsonValueKind.Null) |
| | 259 | | { |
| 0 | 260 | | array.Add(null); |
| | 261 | | } |
| | 262 | | else |
| | 263 | | { |
| 10632 | 264 | | array.Add(item.GetString()); |
| | 265 | | } |
| | 266 | | } |
| 2788 | 267 | | sourceAddressPrefixes = array; |
| 2788 | 268 | | continue; |
| | 269 | | } |
| 22304 | 270 | | if (property0.NameEquals("sourceApplicationSecurityGroups")) |
| | 271 | | { |
| 0 | 272 | | if (property0.Value.ValueKind == JsonValueKind.Null) |
| | 273 | | { |
| | 274 | | continue; |
| | 275 | | } |
| 0 | 276 | | List<ApplicationSecurityGroup> array = new List<ApplicationSecurityGroup>(); |
| 0 | 277 | | foreach (var item in property0.Value.EnumerateArray()) |
| | 278 | | { |
| 0 | 279 | | if (item.ValueKind == JsonValueKind.Null) |
| | 280 | | { |
| 0 | 281 | | array.Add(null); |
| | 282 | | } |
| | 283 | | else |
| | 284 | | { |
| 0 | 285 | | array.Add(ApplicationSecurityGroup.DeserializeApplicationSecurityGroup(item)); |
| | 286 | | } |
| | 287 | | } |
| 0 | 288 | | sourceApplicationSecurityGroups = array; |
| 0 | 289 | | continue; |
| | 290 | | } |
| 22304 | 291 | | if (property0.NameEquals("destinationAddressPrefix")) |
| | 292 | | { |
| 2788 | 293 | | if (property0.Value.ValueKind == JsonValueKind.Null) |
| | 294 | | { |
| | 295 | | continue; |
| | 296 | | } |
| 2788 | 297 | | destinationAddressPrefix = property0.Value.GetString(); |
| 2788 | 298 | | continue; |
| | 299 | | } |
| 19516 | 300 | | if (property0.NameEquals("destinationAddressPrefixes")) |
| | 301 | | { |
| 2788 | 302 | | if (property0.Value.ValueKind == JsonValueKind.Null) |
| | 303 | | { |
| | 304 | | continue; |
| | 305 | | } |
| 2788 | 306 | | List<string> array = new List<string>(); |
| 0 | 307 | | foreach (var item in property0.Value.EnumerateArray()) |
| | 308 | | { |
| 0 | 309 | | if (item.ValueKind == JsonValueKind.Null) |
| | 310 | | { |
| 0 | 311 | | array.Add(null); |
| | 312 | | } |
| | 313 | | else |
| | 314 | | { |
| 0 | 315 | | array.Add(item.GetString()); |
| | 316 | | } |
| | 317 | | } |
| 2788 | 318 | | destinationAddressPrefixes = array; |
| 2788 | 319 | | continue; |
| | 320 | | } |
| 16728 | 321 | | if (property0.NameEquals("destinationApplicationSecurityGroups")) |
| | 322 | | { |
| 0 | 323 | | if (property0.Value.ValueKind == JsonValueKind.Null) |
| | 324 | | { |
| | 325 | | continue; |
| | 326 | | } |
| 0 | 327 | | List<ApplicationSecurityGroup> array = new List<ApplicationSecurityGroup>(); |
| 0 | 328 | | foreach (var item in property0.Value.EnumerateArray()) |
| | 329 | | { |
| 0 | 330 | | if (item.ValueKind == JsonValueKind.Null) |
| | 331 | | { |
| 0 | 332 | | array.Add(null); |
| | 333 | | } |
| | 334 | | else |
| | 335 | | { |
| 0 | 336 | | array.Add(ApplicationSecurityGroup.DeserializeApplicationSecurityGroup(item)); |
| | 337 | | } |
| | 338 | | } |
| 0 | 339 | | destinationApplicationSecurityGroups = array; |
| 0 | 340 | | continue; |
| | 341 | | } |
| 16728 | 342 | | if (property0.NameEquals("sourcePortRanges")) |
| | 343 | | { |
| 2788 | 344 | | if (property0.Value.ValueKind == JsonValueKind.Null) |
| | 345 | | { |
| | 346 | | continue; |
| | 347 | | } |
| 2788 | 348 | | List<string> array = new List<string>(); |
| 0 | 349 | | foreach (var item in property0.Value.EnumerateArray()) |
| | 350 | | { |
| 0 | 351 | | if (item.ValueKind == JsonValueKind.Null) |
| | 352 | | { |
| 0 | 353 | | array.Add(null); |
| | 354 | | } |
| | 355 | | else |
| | 356 | | { |
| 0 | 357 | | array.Add(item.GetString()); |
| | 358 | | } |
| | 359 | | } |
| 2788 | 360 | | sourcePortRanges = array; |
| 2788 | 361 | | continue; |
| | 362 | | } |
| 13940 | 363 | | if (property0.NameEquals("destinationPortRanges")) |
| | 364 | | { |
| 2788 | 365 | | if (property0.Value.ValueKind == JsonValueKind.Null) |
| | 366 | | { |
| | 367 | | continue; |
| | 368 | | } |
| 2788 | 369 | | List<string> array = new List<string>(); |
| 36072 | 370 | | foreach (var item in property0.Value.EnumerateArray()) |
| | 371 | | { |
| 15248 | 372 | | if (item.ValueKind == JsonValueKind.Null) |
| | 373 | | { |
| 0 | 374 | | array.Add(null); |
| | 375 | | } |
| | 376 | | else |
| | 377 | | { |
| 15248 | 378 | | array.Add(item.GetString()); |
| | 379 | | } |
| | 380 | | } |
| 2788 | 381 | | destinationPortRanges = array; |
| 2788 | 382 | | continue; |
| | 383 | | } |
| 11152 | 384 | | if (property0.NameEquals("access")) |
| | 385 | | { |
| 2788 | 386 | | if (property0.Value.ValueKind == JsonValueKind.Null) |
| | 387 | | { |
| | 388 | | continue; |
| | 389 | | } |
| 2788 | 390 | | access = new SecurityRuleAccess(property0.Value.GetString()); |
| 2788 | 391 | | continue; |
| | 392 | | } |
| 8364 | 393 | | if (property0.NameEquals("priority")) |
| | 394 | | { |
| 2788 | 395 | | if (property0.Value.ValueKind == JsonValueKind.Null) |
| | 396 | | { |
| | 397 | | continue; |
| | 398 | | } |
| 2788 | 399 | | priority = property0.Value.GetInt32(); |
| 2788 | 400 | | continue; |
| | 401 | | } |
| 5576 | 402 | | if (property0.NameEquals("direction")) |
| | 403 | | { |
| 2788 | 404 | | if (property0.Value.ValueKind == JsonValueKind.Null) |
| | 405 | | { |
| | 406 | | continue; |
| | 407 | | } |
| 2788 | 408 | | direction = new SecurityRuleDirection(property0.Value.GetString()); |
| 2788 | 409 | | continue; |
| | 410 | | } |
| 2788 | 411 | | if (property0.NameEquals("provisioningState")) |
| | 412 | | { |
| 2788 | 413 | | if (property0.Value.ValueKind == JsonValueKind.Null) |
| | 414 | | { |
| | 415 | | continue; |
| | 416 | | } |
| 2788 | 417 | | provisioningState = new ProvisioningState(property0.Value.GetString()); |
| | 418 | | continue; |
| | 419 | | } |
| | 420 | | } |
| | 421 | | continue; |
| | 422 | | } |
| | 423 | | } |
| 2788 | 424 | | return new SecurityRule(id, name, etag, description, protocol, sourcePortRange, destinationPortRange, source |
| | 425 | | } |
| | 426 | | } |
| | 427 | | } |