| | 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.Storage.Models |
| | 13 | | { |
| | 14 | | public partial class NetworkRuleSet : IUtf8JsonSerializable |
| | 15 | | { |
| | 16 | | void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) |
| | 17 | | { |
| 16 | 18 | | writer.WriteStartObject(); |
| 16 | 19 | | if (Bypass != null) |
| | 20 | | { |
| 12 | 21 | | writer.WritePropertyName("bypass"); |
| 12 | 22 | | writer.WriteStringValue(Bypass.Value.ToString()); |
| | 23 | | } |
| 16 | 24 | | if (VirtualNetworkRules != null) |
| | 25 | | { |
| 0 | 26 | | writer.WritePropertyName("virtualNetworkRules"); |
| 0 | 27 | | writer.WriteStartArray(); |
| 0 | 28 | | foreach (var item in VirtualNetworkRules) |
| | 29 | | { |
| 0 | 30 | | writer.WriteObjectValue(item); |
| | 31 | | } |
| 0 | 32 | | writer.WriteEndArray(); |
| | 33 | | } |
| 16 | 34 | | if (IpRules != null) |
| | 35 | | { |
| 12 | 36 | | writer.WritePropertyName("ipRules"); |
| 12 | 37 | | writer.WriteStartArray(); |
| 56 | 38 | | foreach (var item in IpRules) |
| | 39 | | { |
| 16 | 40 | | writer.WriteObjectValue(item); |
| | 41 | | } |
| 12 | 42 | | writer.WriteEndArray(); |
| | 43 | | } |
| 16 | 44 | | writer.WritePropertyName("defaultAction"); |
| 16 | 45 | | writer.WriteStringValue(DefaultAction.ToSerialString()); |
| 16 | 46 | | writer.WriteEndObject(); |
| 16 | 47 | | } |
| | 48 | |
|
| | 49 | | internal static NetworkRuleSet DeserializeNetworkRuleSet(JsonElement element) |
| | 50 | | { |
| 836 | 51 | | Bypass? bypass = default; |
| 836 | 52 | | IList<VirtualNetworkRule> virtualNetworkRules = default; |
| 836 | 53 | | IList<IPRule> ipRules = default; |
| 836 | 54 | | DefaultAction defaultAction = default; |
| 8360 | 55 | | foreach (var property in element.EnumerateObject()) |
| | 56 | | { |
| 3344 | 57 | | if (property.NameEquals("bypass")) |
| | 58 | | { |
| 836 | 59 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 60 | | { |
| | 61 | | continue; |
| | 62 | | } |
| 836 | 63 | | bypass = new Bypass(property.Value.GetString()); |
| 836 | 64 | | continue; |
| | 65 | | } |
| 2508 | 66 | | if (property.NameEquals("virtualNetworkRules")) |
| | 67 | | { |
| 836 | 68 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 69 | | { |
| | 70 | | continue; |
| | 71 | | } |
| 836 | 72 | | List<VirtualNetworkRule> array = new List<VirtualNetworkRule>(); |
| 1704 | 73 | | foreach (var item in property.Value.EnumerateArray()) |
| | 74 | | { |
| 16 | 75 | | if (item.ValueKind == JsonValueKind.Null) |
| | 76 | | { |
| 0 | 77 | | array.Add(null); |
| | 78 | | } |
| | 79 | | else |
| | 80 | | { |
| 16 | 81 | | array.Add(VirtualNetworkRule.DeserializeVirtualNetworkRule(item)); |
| | 82 | | } |
| | 83 | | } |
| 836 | 84 | | virtualNetworkRules = array; |
| 836 | 85 | | continue; |
| | 86 | | } |
| 1672 | 87 | | if (property.NameEquals("ipRules")) |
| | 88 | | { |
| 836 | 89 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 90 | | { |
| | 91 | | continue; |
| | 92 | | } |
| 836 | 93 | | List<IPRule> array = new List<IPRule>(); |
| 1864 | 94 | | foreach (var item in property.Value.EnumerateArray()) |
| | 95 | | { |
| 96 | 96 | | if (item.ValueKind == JsonValueKind.Null) |
| | 97 | | { |
| 0 | 98 | | array.Add(null); |
| | 99 | | } |
| | 100 | | else |
| | 101 | | { |
| 96 | 102 | | array.Add(IPRule.DeserializeIPRule(item)); |
| | 103 | | } |
| | 104 | | } |
| 836 | 105 | | ipRules = array; |
| 836 | 106 | | continue; |
| | 107 | | } |
| 836 | 108 | | if (property.NameEquals("defaultAction")) |
| | 109 | | { |
| 836 | 110 | | defaultAction = property.Value.GetString().ToDefaultAction(); |
| | 111 | | continue; |
| | 112 | | } |
| | 113 | | } |
| 836 | 114 | | return new NetworkRuleSet(bypass, virtualNetworkRules, ipRules, defaultAction); |
| | 115 | | } |
| | 116 | | } |
| | 117 | | } |