| | 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.KeyVault.Models |
| | 13 | | { |
| | 14 | | public partial class NetworkRuleSet : IUtf8JsonSerializable |
| | 15 | | { |
| | 16 | | void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) |
| | 17 | | { |
| 104 | 18 | | writer.WriteStartObject(); |
| 104 | 19 | | if (Optional.IsDefined(Bypass)) |
| | 20 | | { |
| 104 | 21 | | writer.WritePropertyName("bypass"); |
| 104 | 22 | | writer.WriteStringValue(Bypass.Value.ToString()); |
| | 23 | | } |
| 104 | 24 | | if (Optional.IsDefined(DefaultAction)) |
| | 25 | | { |
| 104 | 26 | | writer.WritePropertyName("defaultAction"); |
| 104 | 27 | | writer.WriteStringValue(DefaultAction.Value.ToString()); |
| | 28 | | } |
| 104 | 29 | | if (Optional.IsCollectionDefined(IpRules)) |
| | 30 | | { |
| 104 | 31 | | writer.WritePropertyName("ipRules"); |
| 104 | 32 | | writer.WriteStartArray(); |
| 624 | 33 | | foreach (var item in IpRules) |
| | 34 | | { |
| 208 | 35 | | writer.WriteObjectValue(item); |
| | 36 | | } |
| 104 | 37 | | writer.WriteEndArray(); |
| | 38 | | } |
| 104 | 39 | | if (Optional.IsCollectionDefined(VirtualNetworkRules)) |
| | 40 | | { |
| 8 | 41 | | writer.WritePropertyName("virtualNetworkRules"); |
| 8 | 42 | | writer.WriteStartArray(); |
| 0 | 43 | | foreach (var item in VirtualNetworkRules) |
| | 44 | | { |
| 0 | 45 | | writer.WriteObjectValue(item); |
| | 46 | | } |
| 8 | 47 | | writer.WriteEndArray(); |
| | 48 | | } |
| 104 | 49 | | writer.WriteEndObject(); |
| 104 | 50 | | } |
| | 51 | |
|
| | 52 | | internal static NetworkRuleSet DeserializeNetworkRuleSet(JsonElement element) |
| | 53 | | { |
| 76 | 54 | | Optional<NetworkRuleBypassOptions> bypass = default; |
| 76 | 55 | | Optional<NetworkRuleAction> defaultAction = default; |
| 76 | 56 | | Optional<IList<IPRule>> ipRules = default; |
| 76 | 57 | | Optional<IList<VirtualNetworkRule>> virtualNetworkRules = default; |
| 760 | 58 | | foreach (var property in element.EnumerateObject()) |
| | 59 | | { |
| 304 | 60 | | if (property.NameEquals("bypass")) |
| | 61 | | { |
| 76 | 62 | | bypass = new NetworkRuleBypassOptions(property.Value.GetString()); |
| 76 | 63 | | continue; |
| | 64 | | } |
| 228 | 65 | | if (property.NameEquals("defaultAction")) |
| | 66 | | { |
| 76 | 67 | | defaultAction = new NetworkRuleAction(property.Value.GetString()); |
| 76 | 68 | | continue; |
| | 69 | | } |
| 152 | 70 | | if (property.NameEquals("ipRules")) |
| | 71 | | { |
| 76 | 72 | | List<IPRule> array = new List<IPRule>(); |
| 456 | 73 | | foreach (var item in property.Value.EnumerateArray()) |
| | 74 | | { |
| 152 | 75 | | array.Add(IPRule.DeserializeIPRule(item)); |
| | 76 | | } |
| 76 | 77 | | ipRules = array; |
| 76 | 78 | | continue; |
| | 79 | | } |
| 76 | 80 | | if (property.NameEquals("virtualNetworkRules")) |
| | 81 | | { |
| 76 | 82 | | List<VirtualNetworkRule> array = new List<VirtualNetworkRule>(); |
| 0 | 83 | | foreach (var item in property.Value.EnumerateArray()) |
| | 84 | | { |
| 0 | 85 | | array.Add(VirtualNetworkRule.DeserializeVirtualNetworkRule(item)); |
| | 86 | | } |
| 76 | 87 | | virtualNetworkRules = array; |
| | 88 | | continue; |
| | 89 | | } |
| | 90 | | } |
| 76 | 91 | | return new NetworkRuleSet(Optional.ToNullable(bypass), Optional.ToNullable(defaultAction), Optional.ToList(i |
| | 92 | | } |
| | 93 | | } |
| | 94 | | } |