| | 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.Compute.Models |
| | 13 | | { |
| | 14 | | public partial class VirtualMachine : IUtf8JsonSerializable |
| | 15 | | { |
| | 16 | | void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) |
| | 17 | | { |
| 244 | 18 | | writer.WriteStartObject(); |
| 244 | 19 | | if (Plan != null) |
| | 20 | | { |
| 4 | 21 | | writer.WritePropertyName("plan"); |
| 4 | 22 | | writer.WriteObjectValue(Plan); |
| | 23 | | } |
| 244 | 24 | | if (Resources != null) |
| | 25 | | { |
| 0 | 26 | | writer.WritePropertyName("resources"); |
| 0 | 27 | | writer.WriteStartArray(); |
| 0 | 28 | | foreach (var item in Resources) |
| | 29 | | { |
| 0 | 30 | | writer.WriteObjectValue(item); |
| | 31 | | } |
| 0 | 32 | | writer.WriteEndArray(); |
| | 33 | | } |
| 244 | 34 | | if (Identity != null) |
| | 35 | | { |
| 0 | 36 | | writer.WritePropertyName("identity"); |
| 0 | 37 | | writer.WriteObjectValue(Identity); |
| | 38 | | } |
| 244 | 39 | | if (Zones != null) |
| | 40 | | { |
| 8 | 41 | | writer.WritePropertyName("zones"); |
| 8 | 42 | | writer.WriteStartArray(); |
| 32 | 43 | | foreach (var item in Zones) |
| | 44 | | { |
| 8 | 45 | | writer.WriteStringValue(item); |
| | 46 | | } |
| 8 | 47 | | writer.WriteEndArray(); |
| | 48 | | } |
| 244 | 49 | | if (Id != null) |
| | 50 | | { |
| 16 | 51 | | writer.WritePropertyName("id"); |
| 16 | 52 | | writer.WriteStringValue(Id); |
| | 53 | | } |
| 244 | 54 | | if (Name != null) |
| | 55 | | { |
| 244 | 56 | | writer.WritePropertyName("name"); |
| 244 | 57 | | writer.WriteStringValue(Name); |
| | 58 | | } |
| 244 | 59 | | if (Type != null) |
| | 60 | | { |
| 244 | 61 | | writer.WritePropertyName("type"); |
| 244 | 62 | | writer.WriteStringValue(Type); |
| | 63 | | } |
| 244 | 64 | | writer.WritePropertyName("location"); |
| 244 | 65 | | writer.WriteStringValue(Location); |
| 244 | 66 | | if (Tags != null) |
| | 67 | | { |
| 244 | 68 | | writer.WritePropertyName("tags"); |
| 244 | 69 | | writer.WriteStartObject(); |
| 1464 | 70 | | foreach (var item in Tags) |
| | 71 | | { |
| 488 | 72 | | writer.WritePropertyName(item.Key); |
| 488 | 73 | | writer.WriteStringValue(item.Value); |
| | 74 | | } |
| 244 | 75 | | writer.WriteEndObject(); |
| | 76 | | } |
| 244 | 77 | | writer.WritePropertyName("properties"); |
| 244 | 78 | | writer.WriteStartObject(); |
| 244 | 79 | | if (HardwareProfile != null) |
| | 80 | | { |
| 244 | 81 | | writer.WritePropertyName("hardwareProfile"); |
| 244 | 82 | | writer.WriteObjectValue(HardwareProfile); |
| | 83 | | } |
| 244 | 84 | | if (StorageProfile != null) |
| | 85 | | { |
| 244 | 86 | | writer.WritePropertyName("storageProfile"); |
| 244 | 87 | | writer.WriteObjectValue(StorageProfile); |
| | 88 | | } |
| 244 | 89 | | if (AdditionalCapabilities != null) |
| | 90 | | { |
| 8 | 91 | | writer.WritePropertyName("additionalCapabilities"); |
| 8 | 92 | | writer.WriteObjectValue(AdditionalCapabilities); |
| | 93 | | } |
| 244 | 94 | | if (OsProfile != null) |
| | 95 | | { |
| 244 | 96 | | writer.WritePropertyName("osProfile"); |
| 244 | 97 | | writer.WriteObjectValue(OsProfile); |
| | 98 | | } |
| 244 | 99 | | if (NetworkProfile != null) |
| | 100 | | { |
| 244 | 101 | | writer.WritePropertyName("networkProfile"); |
| 244 | 102 | | writer.WriteObjectValue(NetworkProfile); |
| | 103 | | } |
| 244 | 104 | | if (DiagnosticsProfile != null) |
| | 105 | | { |
| 8 | 106 | | writer.WritePropertyName("diagnosticsProfile"); |
| 8 | 107 | | writer.WriteObjectValue(DiagnosticsProfile); |
| | 108 | | } |
| 244 | 109 | | if (AvailabilitySet != null) |
| | 110 | | { |
| 0 | 111 | | writer.WritePropertyName("availabilitySet"); |
| 0 | 112 | | writer.WriteObjectValue(AvailabilitySet); |
| | 113 | | } |
| 244 | 114 | | if (VirtualMachineScaleSet != null) |
| | 115 | | { |
| 0 | 116 | | writer.WritePropertyName("virtualMachineScaleSet"); |
| 0 | 117 | | writer.WriteObjectValue(VirtualMachineScaleSet); |
| | 118 | | } |
| 244 | 119 | | if (ProximityPlacementGroup != null) |
| | 120 | | { |
| 0 | 121 | | writer.WritePropertyName("proximityPlacementGroup"); |
| 0 | 122 | | writer.WriteObjectValue(ProximityPlacementGroup); |
| | 123 | | } |
| 244 | 124 | | if (Priority != null) |
| | 125 | | { |
| 8 | 126 | | writer.WritePropertyName("priority"); |
| 8 | 127 | | writer.WriteStringValue(Priority.Value.ToString()); |
| | 128 | | } |
| 244 | 129 | | if (EvictionPolicy != null) |
| | 130 | | { |
| 0 | 131 | | writer.WritePropertyName("evictionPolicy"); |
| 0 | 132 | | writer.WriteStringValue(EvictionPolicy.Value.ToString()); |
| | 133 | | } |
| 244 | 134 | | if (BillingProfile != null) |
| | 135 | | { |
| 8 | 136 | | writer.WritePropertyName("billingProfile"); |
| 8 | 137 | | writer.WriteObjectValue(BillingProfile); |
| | 138 | | } |
| 244 | 139 | | if (Host != null) |
| | 140 | | { |
| 0 | 141 | | writer.WritePropertyName("host"); |
| 0 | 142 | | writer.WriteObjectValue(Host); |
| | 143 | | } |
| 244 | 144 | | if (ProvisioningState != null) |
| | 145 | | { |
| 16 | 146 | | writer.WritePropertyName("provisioningState"); |
| 16 | 147 | | writer.WriteStringValue(ProvisioningState); |
| | 148 | | } |
| 244 | 149 | | if (InstanceView != null) |
| | 150 | | { |
| 16 | 151 | | writer.WritePropertyName("instanceView"); |
| 16 | 152 | | writer.WriteObjectValue(InstanceView); |
| | 153 | | } |
| 244 | 154 | | if (LicenseType != null) |
| | 155 | | { |
| 8 | 156 | | writer.WritePropertyName("licenseType"); |
| 8 | 157 | | writer.WriteStringValue(LicenseType); |
| | 158 | | } |
| 244 | 159 | | if (VmId != null) |
| | 160 | | { |
| 16 | 161 | | writer.WritePropertyName("vmId"); |
| 16 | 162 | | writer.WriteStringValue(VmId); |
| | 163 | | } |
| 244 | 164 | | writer.WriteEndObject(); |
| 244 | 165 | | writer.WriteEndObject(); |
| 244 | 166 | | } |
| | 167 | |
|
| | 168 | | internal static VirtualMachine DeserializeVirtualMachine(JsonElement element) |
| | 169 | | { |
| 344 | 170 | | Plan plan = default; |
| 344 | 171 | | IList<VirtualMachineExtension> resources = default; |
| 344 | 172 | | VirtualMachineIdentity identity = default; |
| 344 | 173 | | IList<string> zones = default; |
| 344 | 174 | | string id = default; |
| 344 | 175 | | string name = default; |
| 344 | 176 | | string type = default; |
| 344 | 177 | | string location = default; |
| 344 | 178 | | IDictionary<string, string> tags = default; |
| 344 | 179 | | HardwareProfile hardwareProfile = default; |
| 344 | 180 | | StorageProfile storageProfile = default; |
| 344 | 181 | | AdditionalCapabilities additionalCapabilities = default; |
| 344 | 182 | | OSProfile osProfile = default; |
| 344 | 183 | | NetworkProfile networkProfile = default; |
| 344 | 184 | | DiagnosticsProfile diagnosticsProfile = default; |
| 344 | 185 | | SubResource availabilitySet = default; |
| 344 | 186 | | SubResource virtualMachineScaleSet = default; |
| 344 | 187 | | SubResource proximityPlacementGroup = default; |
| 344 | 188 | | VirtualMachinePriorityTypes? priority = default; |
| 344 | 189 | | VirtualMachineEvictionPolicyTypes? evictionPolicy = default; |
| 344 | 190 | | BillingProfile billingProfile = default; |
| 344 | 191 | | SubResource host = default; |
| 344 | 192 | | string provisioningState = default; |
| 344 | 193 | | VirtualMachineInstanceView instanceView = default; |
| 344 | 194 | | string licenseType = default; |
| 344 | 195 | | string vmId = default; |
| 4904 | 196 | | foreach (var property in element.EnumerateObject()) |
| | 197 | | { |
| 2108 | 198 | | if (property.NameEquals("plan")) |
| | 199 | | { |
| 0 | 200 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 201 | | { |
| | 202 | | continue; |
| | 203 | | } |
| 0 | 204 | | plan = Plan.DeserializePlan(property.Value); |
| 0 | 205 | | continue; |
| | 206 | | } |
| 2108 | 207 | | if (property.NameEquals("resources")) |
| | 208 | | { |
| 24 | 209 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 210 | | { |
| | 211 | | continue; |
| | 212 | | } |
| 24 | 213 | | List<VirtualMachineExtension> array = new List<VirtualMachineExtension>(); |
| 112 | 214 | | foreach (var item in property.Value.EnumerateArray()) |
| | 215 | | { |
| 32 | 216 | | if (item.ValueKind == JsonValueKind.Null) |
| | 217 | | { |
| 0 | 218 | | array.Add(null); |
| | 219 | | } |
| | 220 | | else |
| | 221 | | { |
| 32 | 222 | | array.Add(VirtualMachineExtension.DeserializeVirtualMachineExtension(item)); |
| | 223 | | } |
| | 224 | | } |
| 24 | 225 | | resources = array; |
| 24 | 226 | | continue; |
| | 227 | | } |
| 2084 | 228 | | if (property.NameEquals("identity")) |
| | 229 | | { |
| 0 | 230 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 231 | | { |
| | 232 | | continue; |
| | 233 | | } |
| 0 | 234 | | identity = VirtualMachineIdentity.DeserializeVirtualMachineIdentity(property.Value); |
| 0 | 235 | | continue; |
| | 236 | | } |
| 2084 | 237 | | if (property.NameEquals("zones")) |
| | 238 | | { |
| 20 | 239 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 240 | | { |
| | 241 | | continue; |
| | 242 | | } |
| 20 | 243 | | List<string> array = new List<string>(); |
| 80 | 244 | | foreach (var item in property.Value.EnumerateArray()) |
| | 245 | | { |
| 20 | 246 | | if (item.ValueKind == JsonValueKind.Null) |
| | 247 | | { |
| 0 | 248 | | array.Add(null); |
| | 249 | | } |
| | 250 | | else |
| | 251 | | { |
| 20 | 252 | | array.Add(item.GetString()); |
| | 253 | | } |
| | 254 | | } |
| 20 | 255 | | zones = array; |
| 20 | 256 | | continue; |
| | 257 | | } |
| 2064 | 258 | | if (property.NameEquals("id")) |
| | 259 | | { |
| 344 | 260 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 261 | | { |
| | 262 | | continue; |
| | 263 | | } |
| 344 | 264 | | id = property.Value.GetString(); |
| 344 | 265 | | continue; |
| | 266 | | } |
| 1720 | 267 | | if (property.NameEquals("name")) |
| | 268 | | { |
| 344 | 269 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 270 | | { |
| | 271 | | continue; |
| | 272 | | } |
| 344 | 273 | | name = property.Value.GetString(); |
| 344 | 274 | | continue; |
| | 275 | | } |
| 1376 | 276 | | if (property.NameEquals("type")) |
| | 277 | | { |
| 344 | 278 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 279 | | { |
| | 280 | | continue; |
| | 281 | | } |
| 344 | 282 | | type = property.Value.GetString(); |
| 344 | 283 | | continue; |
| | 284 | | } |
| 1032 | 285 | | if (property.NameEquals("location")) |
| | 286 | | { |
| 344 | 287 | | location = property.Value.GetString(); |
| 344 | 288 | | continue; |
| | 289 | | } |
| 688 | 290 | | if (property.NameEquals("tags")) |
| | 291 | | { |
| 344 | 292 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 293 | | { |
| | 294 | | continue; |
| | 295 | | } |
| 344 | 296 | | Dictionary<string, string> dictionary = new Dictionary<string, string>(); |
| 2072 | 297 | | foreach (var property0 in property.Value.EnumerateObject()) |
| | 298 | | { |
| 692 | 299 | | if (property0.Value.ValueKind == JsonValueKind.Null) |
| | 300 | | { |
| 0 | 301 | | dictionary.Add(property0.Name, null); |
| | 302 | | } |
| | 303 | | else |
| | 304 | | { |
| 692 | 305 | | dictionary.Add(property0.Name, property0.Value.GetString()); |
| | 306 | | } |
| | 307 | | } |
| 344 | 308 | | tags = dictionary; |
| 344 | 309 | | continue; |
| | 310 | | } |
| 344 | 311 | | if (property.NameEquals("properties")) |
| | 312 | | { |
| 5264 | 313 | | foreach (var property0 in property.Value.EnumerateObject()) |
| | 314 | | { |
| 2288 | 315 | | if (property0.NameEquals("hardwareProfile")) |
| | 316 | | { |
| 344 | 317 | | if (property0.Value.ValueKind == JsonValueKind.Null) |
| | 318 | | { |
| | 319 | | continue; |
| | 320 | | } |
| 344 | 321 | | hardwareProfile = HardwareProfile.DeserializeHardwareProfile(property0.Value); |
| 344 | 322 | | continue; |
| | 323 | | } |
| 1944 | 324 | | if (property0.NameEquals("storageProfile")) |
| | 325 | | { |
| 344 | 326 | | if (property0.Value.ValueKind == JsonValueKind.Null) |
| | 327 | | { |
| | 328 | | continue; |
| | 329 | | } |
| 344 | 330 | | storageProfile = StorageProfile.DeserializeStorageProfile(property0.Value); |
| 344 | 331 | | continue; |
| | 332 | | } |
| 1600 | 333 | | if (property0.NameEquals("additionalCapabilities")) |
| | 334 | | { |
| 20 | 335 | | if (property0.Value.ValueKind == JsonValueKind.Null) |
| | 336 | | { |
| | 337 | | continue; |
| | 338 | | } |
| 20 | 339 | | additionalCapabilities = AdditionalCapabilities.DeserializeAdditionalCapabilities(property0. |
| 20 | 340 | | continue; |
| | 341 | | } |
| 1580 | 342 | | if (property0.NameEquals("osProfile")) |
| | 343 | | { |
| 344 | 344 | | if (property0.Value.ValueKind == JsonValueKind.Null) |
| | 345 | | { |
| | 346 | | continue; |
| | 347 | | } |
| 344 | 348 | | osProfile = OSProfile.DeserializeOSProfile(property0.Value); |
| 344 | 349 | | continue; |
| | 350 | | } |
| 1236 | 351 | | if (property0.NameEquals("networkProfile")) |
| | 352 | | { |
| 344 | 353 | | if (property0.Value.ValueKind == JsonValueKind.Null) |
| | 354 | | { |
| | 355 | | continue; |
| | 356 | | } |
| 344 | 357 | | networkProfile = NetworkProfile.DeserializeNetworkProfile(property0.Value); |
| 344 | 358 | | continue; |
| | 359 | | } |
| 892 | 360 | | if (property0.NameEquals("diagnosticsProfile")) |
| | 361 | | { |
| 16 | 362 | | if (property0.Value.ValueKind == JsonValueKind.Null) |
| | 363 | | { |
| | 364 | | continue; |
| | 365 | | } |
| 16 | 366 | | diagnosticsProfile = DiagnosticsProfile.DeserializeDiagnosticsProfile(property0.Value); |
| 16 | 367 | | continue; |
| | 368 | | } |
| 876 | 369 | | if (property0.NameEquals("availabilitySet")) |
| | 370 | | { |
| 0 | 371 | | if (property0.Value.ValueKind == JsonValueKind.Null) |
| | 372 | | { |
| | 373 | | continue; |
| | 374 | | } |
| 0 | 375 | | availabilitySet = SubResource.DeserializeSubResource(property0.Value); |
| 0 | 376 | | continue; |
| | 377 | | } |
| 876 | 378 | | if (property0.NameEquals("virtualMachineScaleSet")) |
| | 379 | | { |
| 0 | 380 | | if (property0.Value.ValueKind == JsonValueKind.Null) |
| | 381 | | { |
| | 382 | | continue; |
| | 383 | | } |
| 0 | 384 | | virtualMachineScaleSet = SubResource.DeserializeSubResource(property0.Value); |
| 0 | 385 | | continue; |
| | 386 | | } |
| 876 | 387 | | if (property0.NameEquals("proximityPlacementGroup")) |
| | 388 | | { |
| 0 | 389 | | if (property0.Value.ValueKind == JsonValueKind.Null) |
| | 390 | | { |
| | 391 | | continue; |
| | 392 | | } |
| 0 | 393 | | proximityPlacementGroup = SubResource.DeserializeSubResource(property0.Value); |
| 0 | 394 | | continue; |
| | 395 | | } |
| 876 | 396 | | if (property0.NameEquals("priority")) |
| | 397 | | { |
| 8 | 398 | | if (property0.Value.ValueKind == JsonValueKind.Null) |
| | 399 | | { |
| | 400 | | continue; |
| | 401 | | } |
| 8 | 402 | | priority = new VirtualMachinePriorityTypes(property0.Value.GetString()); |
| 8 | 403 | | continue; |
| | 404 | | } |
| 868 | 405 | | if (property0.NameEquals("evictionPolicy")) |
| | 406 | | { |
| 8 | 407 | | if (property0.Value.ValueKind == JsonValueKind.Null) |
| | 408 | | { |
| | 409 | | continue; |
| | 410 | | } |
| 8 | 411 | | evictionPolicy = new VirtualMachineEvictionPolicyTypes(property0.Value.GetString()); |
| 8 | 412 | | continue; |
| | 413 | | } |
| 860 | 414 | | if (property0.NameEquals("billingProfile")) |
| | 415 | | { |
| 8 | 416 | | if (property0.Value.ValueKind == JsonValueKind.Null) |
| | 417 | | { |
| | 418 | | continue; |
| | 419 | | } |
| 8 | 420 | | billingProfile = BillingProfile.DeserializeBillingProfile(property0.Value); |
| 8 | 421 | | continue; |
| | 422 | | } |
| 852 | 423 | | if (property0.NameEquals("host")) |
| | 424 | | { |
| 0 | 425 | | if (property0.Value.ValueKind == JsonValueKind.Null) |
| | 426 | | { |
| | 427 | | continue; |
| | 428 | | } |
| 0 | 429 | | host = SubResource.DeserializeSubResource(property0.Value); |
| 0 | 430 | | continue; |
| | 431 | | } |
| 852 | 432 | | if (property0.NameEquals("provisioningState")) |
| | 433 | | { |
| 344 | 434 | | if (property0.Value.ValueKind == JsonValueKind.Null) |
| | 435 | | { |
| | 436 | | continue; |
| | 437 | | } |
| 344 | 438 | | provisioningState = property0.Value.GetString(); |
| 344 | 439 | | continue; |
| | 440 | | } |
| 508 | 441 | | if (property0.NameEquals("instanceView")) |
| | 442 | | { |
| 152 | 443 | | if (property0.Value.ValueKind == JsonValueKind.Null) |
| | 444 | | { |
| | 445 | | continue; |
| | 446 | | } |
| 152 | 447 | | instanceView = VirtualMachineInstanceView.DeserializeVirtualMachineInstanceView(property0.Va |
| 152 | 448 | | continue; |
| | 449 | | } |
| 356 | 450 | | if (property0.NameEquals("licenseType")) |
| | 451 | | { |
| 12 | 452 | | if (property0.Value.ValueKind == JsonValueKind.Null) |
| | 453 | | { |
| | 454 | | continue; |
| | 455 | | } |
| 12 | 456 | | licenseType = property0.Value.GetString(); |
| 12 | 457 | | continue; |
| | 458 | | } |
| 344 | 459 | | if (property0.NameEquals("vmId")) |
| | 460 | | { |
| 344 | 461 | | if (property0.Value.ValueKind == JsonValueKind.Null) |
| | 462 | | { |
| | 463 | | continue; |
| | 464 | | } |
| 344 | 465 | | vmId = property0.Value.GetString(); |
| | 466 | | continue; |
| | 467 | | } |
| | 468 | | } |
| | 469 | | continue; |
| | 470 | | } |
| | 471 | | } |
| 344 | 472 | | return new VirtualMachine(id, name, type, location, tags, plan, resources, identity, zones, hardwareProfile, |
| | 473 | | } |
| | 474 | | } |
| | 475 | | } |