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