| | 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 VirtualNetwork : IUtf8JsonSerializable |
| | 15 | | { |
| | 16 | | void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) |
| | 17 | | { |
| 216 | 18 | | writer.WriteStartObject(); |
| 216 | 19 | | if (Etag != null) |
| | 20 | | { |
| 0 | 21 | | writer.WritePropertyName("etag"); |
| 0 | 22 | | writer.WriteStringValue(Etag); |
| | 23 | | } |
| 216 | 24 | | if (Id != null) |
| | 25 | | { |
| 0 | 26 | | writer.WritePropertyName("id"); |
| 0 | 27 | | writer.WriteStringValue(Id); |
| | 28 | | } |
| 216 | 29 | | if (Name != null) |
| | 30 | | { |
| 0 | 31 | | writer.WritePropertyName("name"); |
| 0 | 32 | | writer.WriteStringValue(Name); |
| | 33 | | } |
| 216 | 34 | | if (Type != null) |
| | 35 | | { |
| 0 | 36 | | writer.WritePropertyName("type"); |
| 0 | 37 | | writer.WriteStringValue(Type); |
| | 38 | | } |
| 216 | 39 | | if (Location != null) |
| | 40 | | { |
| 216 | 41 | | writer.WritePropertyName("location"); |
| 216 | 42 | | writer.WriteStringValue(Location); |
| | 43 | | } |
| 216 | 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 | | } |
| 216 | 55 | | writer.WritePropertyName("properties"); |
| 216 | 56 | | writer.WriteStartObject(); |
| 216 | 57 | | if (AddressSpace != null) |
| | 58 | | { |
| 216 | 59 | | writer.WritePropertyName("addressSpace"); |
| 216 | 60 | | writer.WriteObjectValue(AddressSpace); |
| | 61 | | } |
| 216 | 62 | | if (DhcpOptions != null) |
| | 63 | | { |
| 200 | 64 | | writer.WritePropertyName("dhcpOptions"); |
| 200 | 65 | | writer.WriteObjectValue(DhcpOptions); |
| | 66 | | } |
| 216 | 67 | | if (Subnets != null) |
| | 68 | | { |
| 216 | 69 | | writer.WritePropertyName("subnets"); |
| 216 | 70 | | writer.WriteStartArray(); |
| 944 | 71 | | foreach (var item in Subnets) |
| | 72 | | { |
| 256 | 73 | | writer.WriteObjectValue(item); |
| | 74 | | } |
| 216 | 75 | | writer.WriteEndArray(); |
| | 76 | | } |
| 216 | 77 | | if (VirtualNetworkPeerings != null) |
| | 78 | | { |
| 0 | 79 | | writer.WritePropertyName("virtualNetworkPeerings"); |
| 0 | 80 | | writer.WriteStartArray(); |
| 0 | 81 | | foreach (var item in VirtualNetworkPeerings) |
| | 82 | | { |
| 0 | 83 | | writer.WriteObjectValue(item); |
| | 84 | | } |
| 0 | 85 | | writer.WriteEndArray(); |
| | 86 | | } |
| 216 | 87 | | if (ResourceGuid != null) |
| | 88 | | { |
| 0 | 89 | | writer.WritePropertyName("resourceGuid"); |
| 0 | 90 | | writer.WriteStringValue(ResourceGuid); |
| | 91 | | } |
| 216 | 92 | | if (ProvisioningState != null) |
| | 93 | | { |
| 0 | 94 | | writer.WritePropertyName("provisioningState"); |
| 0 | 95 | | writer.WriteStringValue(ProvisioningState.Value.ToString()); |
| | 96 | | } |
| 216 | 97 | | if (EnableDdosProtection != null) |
| | 98 | | { |
| 0 | 99 | | writer.WritePropertyName("enableDdosProtection"); |
| 0 | 100 | | writer.WriteBooleanValue(EnableDdosProtection.Value); |
| | 101 | | } |
| 216 | 102 | | if (EnableVmProtection != null) |
| | 103 | | { |
| 0 | 104 | | writer.WritePropertyName("enableVmProtection"); |
| 0 | 105 | | writer.WriteBooleanValue(EnableVmProtection.Value); |
| | 106 | | } |
| 216 | 107 | | if (DdosProtectionPlan != null) |
| | 108 | | { |
| 0 | 109 | | writer.WritePropertyName("ddosProtectionPlan"); |
| 0 | 110 | | writer.WriteObjectValue(DdosProtectionPlan); |
| | 111 | | } |
| 216 | 112 | | if (BgpCommunities != null) |
| | 113 | | { |
| 0 | 114 | | writer.WritePropertyName("bgpCommunities"); |
| 0 | 115 | | writer.WriteObjectValue(BgpCommunities); |
| | 116 | | } |
| 216 | 117 | | if (IpAllocations != null) |
| | 118 | | { |
| 0 | 119 | | writer.WritePropertyName("ipAllocations"); |
| 0 | 120 | | writer.WriteStartArray(); |
| 0 | 121 | | foreach (var item in IpAllocations) |
| | 122 | | { |
| 0 | 123 | | writer.WriteObjectValue(item); |
| | 124 | | } |
| 0 | 125 | | writer.WriteEndArray(); |
| | 126 | | } |
| 216 | 127 | | writer.WriteEndObject(); |
| 216 | 128 | | writer.WriteEndObject(); |
| 216 | 129 | | } |
| | 130 | |
|
| | 131 | | internal static VirtualNetwork DeserializeVirtualNetwork(JsonElement element) |
| | 132 | | { |
| 156 | 133 | | string etag = default; |
| 156 | 134 | | string id = default; |
| 156 | 135 | | string name = default; |
| 156 | 136 | | string type = default; |
| 156 | 137 | | string location = default; |
| 156 | 138 | | IDictionary<string, string> tags = default; |
| 156 | 139 | | AddressSpace addressSpace = default; |
| 156 | 140 | | DhcpOptions dhcpOptions = default; |
| 156 | 141 | | IList<Subnet> subnets = default; |
| 156 | 142 | | IList<VirtualNetworkPeering> virtualNetworkPeerings = default; |
| 156 | 143 | | string resourceGuid = default; |
| 156 | 144 | | ProvisioningState? provisioningState = default; |
| 156 | 145 | | bool? enableDdosProtection = default; |
| 156 | 146 | | bool? enableVmProtection = default; |
| 156 | 147 | | SubResource ddosProtectionPlan = default; |
| 156 | 148 | | VirtualNetworkBgpCommunities bgpCommunities = default; |
| 156 | 149 | | IList<SubResource> ipAllocations = default; |
| 2184 | 150 | | foreach (var property in element.EnumerateObject()) |
| | 151 | | { |
| 936 | 152 | | if (property.NameEquals("etag")) |
| | 153 | | { |
| 156 | 154 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 155 | | { |
| | 156 | | continue; |
| | 157 | | } |
| 156 | 158 | | etag = property.Value.GetString(); |
| 156 | 159 | | continue; |
| | 160 | | } |
| 780 | 161 | | if (property.NameEquals("id")) |
| | 162 | | { |
| 156 | 163 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 164 | | { |
| | 165 | | continue; |
| | 166 | | } |
| 156 | 167 | | id = property.Value.GetString(); |
| 156 | 168 | | continue; |
| | 169 | | } |
| 624 | 170 | | if (property.NameEquals("name")) |
| | 171 | | { |
| 156 | 172 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 173 | | { |
| | 174 | | continue; |
| | 175 | | } |
| 156 | 176 | | name = property.Value.GetString(); |
| 156 | 177 | | continue; |
| | 178 | | } |
| 468 | 179 | | if (property.NameEquals("type")) |
| | 180 | | { |
| 156 | 181 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 182 | | { |
| | 183 | | continue; |
| | 184 | | } |
| 156 | 185 | | type = property.Value.GetString(); |
| 156 | 186 | | continue; |
| | 187 | | } |
| 312 | 188 | | if (property.NameEquals("location")) |
| | 189 | | { |
| 156 | 190 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 191 | | { |
| | 192 | | continue; |
| | 193 | | } |
| 156 | 194 | | location = property.Value.GetString(); |
| 156 | 195 | | continue; |
| | 196 | | } |
| 156 | 197 | | if (property.NameEquals("tags")) |
| | 198 | | { |
| 0 | 199 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 200 | | { |
| | 201 | | continue; |
| | 202 | | } |
| 0 | 203 | | Dictionary<string, string> dictionary = new Dictionary<string, string>(); |
| 0 | 204 | | foreach (var property0 in property.Value.EnumerateObject()) |
| | 205 | | { |
| 0 | 206 | | if (property0.Value.ValueKind == JsonValueKind.Null) |
| | 207 | | { |
| 0 | 208 | | dictionary.Add(property0.Name, null); |
| | 209 | | } |
| | 210 | | else |
| | 211 | | { |
| 0 | 212 | | dictionary.Add(property0.Name, property0.Value.GetString()); |
| | 213 | | } |
| | 214 | | } |
| 0 | 215 | | tags = dictionary; |
| 0 | 216 | | continue; |
| | 217 | | } |
| 156 | 218 | | if (property.NameEquals("properties")) |
| | 219 | | { |
| 2792 | 220 | | foreach (var property0 in property.Value.EnumerateObject()) |
| | 221 | | { |
| 1240 | 222 | | if (property0.NameEquals("addressSpace")) |
| | 223 | | { |
| 156 | 224 | | if (property0.Value.ValueKind == JsonValueKind.Null) |
| | 225 | | { |
| | 226 | | continue; |
| | 227 | | } |
| 156 | 228 | | addressSpace = AddressSpace.DeserializeAddressSpace(property0.Value); |
| 156 | 229 | | continue; |
| | 230 | | } |
| 1084 | 231 | | if (property0.NameEquals("dhcpOptions")) |
| | 232 | | { |
| 148 | 233 | | if (property0.Value.ValueKind == JsonValueKind.Null) |
| | 234 | | { |
| | 235 | | continue; |
| | 236 | | } |
| 148 | 237 | | dhcpOptions = DhcpOptions.DeserializeDhcpOptions(property0.Value); |
| 148 | 238 | | continue; |
| | 239 | | } |
| 936 | 240 | | if (property0.NameEquals("subnets")) |
| | 241 | | { |
| 156 | 242 | | if (property0.Value.ValueKind == JsonValueKind.Null) |
| | 243 | | { |
| | 244 | | continue; |
| | 245 | | } |
| 156 | 246 | | List<Subnet> array = new List<Subnet>(); |
| 736 | 247 | | foreach (var item in property0.Value.EnumerateArray()) |
| | 248 | | { |
| 212 | 249 | | if (item.ValueKind == JsonValueKind.Null) |
| | 250 | | { |
| 0 | 251 | | array.Add(null); |
| | 252 | | } |
| | 253 | | else |
| | 254 | | { |
| 212 | 255 | | array.Add(Subnet.DeserializeSubnet(item)); |
| | 256 | | } |
| | 257 | | } |
| 156 | 258 | | subnets = array; |
| 156 | 259 | | continue; |
| | 260 | | } |
| 780 | 261 | | if (property0.NameEquals("virtualNetworkPeerings")) |
| | 262 | | { |
| 156 | 263 | | if (property0.Value.ValueKind == JsonValueKind.Null) |
| | 264 | | { |
| | 265 | | continue; |
| | 266 | | } |
| 156 | 267 | | List<VirtualNetworkPeering> array = new List<VirtualNetworkPeering>(); |
| 320 | 268 | | foreach (var item in property0.Value.EnumerateArray()) |
| | 269 | | { |
| 4 | 270 | | if (item.ValueKind == JsonValueKind.Null) |
| | 271 | | { |
| 0 | 272 | | array.Add(null); |
| | 273 | | } |
| | 274 | | else |
| | 275 | | { |
| 4 | 276 | | array.Add(VirtualNetworkPeering.DeserializeVirtualNetworkPeering(item)); |
| | 277 | | } |
| | 278 | | } |
| 156 | 279 | | virtualNetworkPeerings = array; |
| 156 | 280 | | continue; |
| | 281 | | } |
| 624 | 282 | | if (property0.NameEquals("resourceGuid")) |
| | 283 | | { |
| 156 | 284 | | if (property0.Value.ValueKind == JsonValueKind.Null) |
| | 285 | | { |
| | 286 | | continue; |
| | 287 | | } |
| 156 | 288 | | resourceGuid = property0.Value.GetString(); |
| 156 | 289 | | continue; |
| | 290 | | } |
| 468 | 291 | | if (property0.NameEquals("provisioningState")) |
| | 292 | | { |
| 156 | 293 | | if (property0.Value.ValueKind == JsonValueKind.Null) |
| | 294 | | { |
| | 295 | | continue; |
| | 296 | | } |
| 156 | 297 | | provisioningState = new ProvisioningState(property0.Value.GetString()); |
| 156 | 298 | | continue; |
| | 299 | | } |
| 312 | 300 | | if (property0.NameEquals("enableDdosProtection")) |
| | 301 | | { |
| 156 | 302 | | if (property0.Value.ValueKind == JsonValueKind.Null) |
| | 303 | | { |
| | 304 | | continue; |
| | 305 | | } |
| 156 | 306 | | enableDdosProtection = property0.Value.GetBoolean(); |
| 156 | 307 | | continue; |
| | 308 | | } |
| 156 | 309 | | if (property0.NameEquals("enableVmProtection")) |
| | 310 | | { |
| 156 | 311 | | if (property0.Value.ValueKind == JsonValueKind.Null) |
| | 312 | | { |
| | 313 | | continue; |
| | 314 | | } |
| 156 | 315 | | enableVmProtection = property0.Value.GetBoolean(); |
| 156 | 316 | | continue; |
| | 317 | | } |
| 0 | 318 | | if (property0.NameEquals("ddosProtectionPlan")) |
| | 319 | | { |
| 0 | 320 | | if (property0.Value.ValueKind == JsonValueKind.Null) |
| | 321 | | { |
| | 322 | | continue; |
| | 323 | | } |
| 0 | 324 | | ddosProtectionPlan = SubResource.DeserializeSubResource(property0.Value); |
| 0 | 325 | | continue; |
| | 326 | | } |
| 0 | 327 | | if (property0.NameEquals("bgpCommunities")) |
| | 328 | | { |
| 0 | 329 | | if (property0.Value.ValueKind == JsonValueKind.Null) |
| | 330 | | { |
| | 331 | | continue; |
| | 332 | | } |
| 0 | 333 | | bgpCommunities = VirtualNetworkBgpCommunities.DeserializeVirtualNetworkBgpCommunities(proper |
| 0 | 334 | | continue; |
| | 335 | | } |
| 0 | 336 | | if (property0.NameEquals("ipAllocations")) |
| | 337 | | { |
| 0 | 338 | | if (property0.Value.ValueKind == JsonValueKind.Null) |
| | 339 | | { |
| | 340 | | continue; |
| | 341 | | } |
| 0 | 342 | | List<SubResource> array = new List<SubResource>(); |
| 0 | 343 | | foreach (var item in property0.Value.EnumerateArray()) |
| | 344 | | { |
| 0 | 345 | | if (item.ValueKind == JsonValueKind.Null) |
| | 346 | | { |
| 0 | 347 | | array.Add(null); |
| | 348 | | } |
| | 349 | | else |
| | 350 | | { |
| 0 | 351 | | array.Add(SubResource.DeserializeSubResource(item)); |
| | 352 | | } |
| | 353 | | } |
| 0 | 354 | | ipAllocations = array; |
| | 355 | | continue; |
| | 356 | | } |
| | 357 | | } |
| | 358 | | continue; |
| | 359 | | } |
| | 360 | | } |
| 156 | 361 | | return new VirtualNetwork(id, name, type, location, tags, etag, addressSpace, dhcpOptions, subnets, virtualN |
| | 362 | | } |
| | 363 | | } |
| | 364 | | } |