| | 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.EventHubs.Models |
| | 13 | | { |
| | 14 | | public partial class NetworkRuleSet : IUtf8JsonSerializable |
| | 15 | | { |
| | 16 | | void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) |
| | 17 | | { |
| 8 | 18 | | writer.WriteStartObject(); |
| 8 | 19 | | if (Id != null) |
| | 20 | | { |
| 0 | 21 | | writer.WritePropertyName("id"); |
| 0 | 22 | | writer.WriteStringValue(Id); |
| | 23 | | } |
| 8 | 24 | | if (Name != null) |
| | 25 | | { |
| 0 | 26 | | writer.WritePropertyName("name"); |
| 0 | 27 | | writer.WriteStringValue(Name); |
| | 28 | | } |
| 8 | 29 | | if (Type != null) |
| | 30 | | { |
| 0 | 31 | | writer.WritePropertyName("type"); |
| 0 | 32 | | writer.WriteStringValue(Type); |
| | 33 | | } |
| 8 | 34 | | writer.WritePropertyName("properties"); |
| 8 | 35 | | writer.WriteStartObject(); |
| 8 | 36 | | if (DefaultAction != null) |
| | 37 | | { |
| 8 | 38 | | writer.WritePropertyName("defaultAction"); |
| 8 | 39 | | writer.WriteStringValue(DefaultAction.Value.ToString()); |
| | 40 | | } |
| 8 | 41 | | if (VirtualNetworkRules != null) |
| | 42 | | { |
| 4 | 43 | | writer.WritePropertyName("virtualNetworkRules"); |
| 4 | 44 | | writer.WriteStartArray(); |
| 32 | 45 | | foreach (var item in VirtualNetworkRules) |
| | 46 | | { |
| 12 | 47 | | writer.WriteObjectValue(item); |
| | 48 | | } |
| 4 | 49 | | writer.WriteEndArray(); |
| | 50 | | } |
| 8 | 51 | | if (IpRules != null) |
| | 52 | | { |
| 4 | 53 | | writer.WritePropertyName("ipRules"); |
| 4 | 54 | | writer.WriteStartArray(); |
| 48 | 55 | | foreach (var item in IpRules) |
| | 56 | | { |
| 20 | 57 | | writer.WriteObjectValue(item); |
| | 58 | | } |
| 4 | 59 | | writer.WriteEndArray(); |
| | 60 | | } |
| 8 | 61 | | writer.WriteEndObject(); |
| 8 | 62 | | writer.WriteEndObject(); |
| 8 | 63 | | } |
| | 64 | |
|
| | 65 | | internal static NetworkRuleSet DeserializeNetworkRuleSet(JsonElement element) |
| | 66 | | { |
| 16 | 67 | | string id = default; |
| 16 | 68 | | string name = default; |
| 16 | 69 | | string type = default; |
| 16 | 70 | | DefaultAction? defaultAction = default; |
| 16 | 71 | | IList<NWRuleSetVirtualNetworkRules> virtualNetworkRules = default; |
| 16 | 72 | | IList<NWRuleSetIpRules> ipRules = default; |
| 192 | 73 | | foreach (var property in element.EnumerateObject()) |
| | 74 | | { |
| 80 | 75 | | if (property.NameEquals("id")) |
| | 76 | | { |
| 16 | 77 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 78 | | { |
| | 79 | | continue; |
| | 80 | | } |
| 16 | 81 | | id = property.Value.GetString(); |
| 16 | 82 | | continue; |
| | 83 | | } |
| 64 | 84 | | if (property.NameEquals("name")) |
| | 85 | | { |
| 16 | 86 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 87 | | { |
| | 88 | | continue; |
| | 89 | | } |
| 16 | 90 | | name = property.Value.GetString(); |
| 16 | 91 | | continue; |
| | 92 | | } |
| 48 | 93 | | if (property.NameEquals("type")) |
| | 94 | | { |
| 16 | 95 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 96 | | { |
| | 97 | | continue; |
| | 98 | | } |
| 16 | 99 | | type = property.Value.GetString(); |
| 16 | 100 | | continue; |
| | 101 | | } |
| 32 | 102 | | if (property.NameEquals("properties")) |
| | 103 | | { |
| 128 | 104 | | foreach (var property0 in property.Value.EnumerateObject()) |
| | 105 | | { |
| 48 | 106 | | if (property0.NameEquals("defaultAction")) |
| | 107 | | { |
| 16 | 108 | | if (property0.Value.ValueKind == JsonValueKind.Null) |
| | 109 | | { |
| | 110 | | continue; |
| | 111 | | } |
| 16 | 112 | | defaultAction = new DefaultAction(property0.Value.GetString()); |
| 16 | 113 | | continue; |
| | 114 | | } |
| 32 | 115 | | if (property0.NameEquals("virtualNetworkRules")) |
| | 116 | | { |
| 16 | 117 | | if (property0.Value.ValueKind == JsonValueKind.Null) |
| | 118 | | { |
| | 119 | | continue; |
| | 120 | | } |
| 16 | 121 | | List<NWRuleSetVirtualNetworkRules> array = new List<NWRuleSetVirtualNetworkRules>(); |
| 80 | 122 | | foreach (var item in property0.Value.EnumerateArray()) |
| | 123 | | { |
| 24 | 124 | | if (item.ValueKind == JsonValueKind.Null) |
| | 125 | | { |
| 0 | 126 | | array.Add(null); |
| | 127 | | } |
| | 128 | | else |
| | 129 | | { |
| 24 | 130 | | array.Add(NWRuleSetVirtualNetworkRules.DeserializeNWRuleSetVirtualNetworkRules(item) |
| | 131 | | } |
| | 132 | | } |
| 16 | 133 | | virtualNetworkRules = array; |
| 16 | 134 | | continue; |
| | 135 | | } |
| 16 | 136 | | if (property0.NameEquals("ipRules")) |
| | 137 | | { |
| 16 | 138 | | if (property0.Value.ValueKind == JsonValueKind.Null) |
| | 139 | | { |
| | 140 | | continue; |
| | 141 | | } |
| 16 | 142 | | List<NWRuleSetIpRules> array = new List<NWRuleSetIpRules>(); |
| 112 | 143 | | foreach (var item in property0.Value.EnumerateArray()) |
| | 144 | | { |
| 40 | 145 | | if (item.ValueKind == JsonValueKind.Null) |
| | 146 | | { |
| 0 | 147 | | array.Add(null); |
| | 148 | | } |
| | 149 | | else |
| | 150 | | { |
| 40 | 151 | | array.Add(NWRuleSetIpRules.DeserializeNWRuleSetIpRules(item)); |
| | 152 | | } |
| | 153 | | } |
| 16 | 154 | | ipRules = array; |
| | 155 | | continue; |
| | 156 | | } |
| | 157 | | } |
| | 158 | | continue; |
| | 159 | | } |
| | 160 | | } |
| 16 | 161 | | return new NetworkRuleSet(id, name, type, defaultAction, virtualNetworkRules, ipRules); |
| | 162 | | } |
| | 163 | | } |
| | 164 | | } |