| | 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 StorageProfile : IUtf8JsonSerializable |
| | 15 | | { |
| | 16 | | void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) |
| | 17 | | { |
| 244 | 18 | | writer.WriteStartObject(); |
| 244 | 19 | | if (ImageReference != null) |
| | 20 | | { |
| 244 | 21 | | writer.WritePropertyName("imageReference"); |
| 244 | 22 | | writer.WriteObjectValue(ImageReference); |
| | 23 | | } |
| 244 | 24 | | if (OsDisk != null) |
| | 25 | | { |
| 244 | 26 | | writer.WritePropertyName("osDisk"); |
| 244 | 27 | | writer.WriteObjectValue(OsDisk); |
| | 28 | | } |
| 244 | 29 | | if (DataDisks != null) |
| | 30 | | { |
| 64 | 31 | | writer.WritePropertyName("dataDisks"); |
| 64 | 32 | | writer.WriteStartArray(); |
| 288 | 33 | | foreach (var item in DataDisks) |
| | 34 | | { |
| 80 | 35 | | writer.WriteObjectValue(item); |
| | 36 | | } |
| 64 | 37 | | writer.WriteEndArray(); |
| | 38 | | } |
| 244 | 39 | | writer.WriteEndObject(); |
| 244 | 40 | | } |
| | 41 | |
|
| | 42 | | internal static StorageProfile DeserializeStorageProfile(JsonElement element) |
| | 43 | | { |
| 432 | 44 | | ImageReference imageReference = default; |
| 432 | 45 | | OSDisk osDisk = default; |
| 432 | 46 | | IList<DataDisk> dataDisks = default; |
| 3416 | 47 | | foreach (var property in element.EnumerateObject()) |
| | 48 | | { |
| 1276 | 49 | | if (property.NameEquals("imageReference")) |
| | 50 | | { |
| 432 | 51 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 52 | | { |
| | 53 | | continue; |
| | 54 | | } |
| 432 | 55 | | imageReference = ImageReference.DeserializeImageReference(property.Value); |
| 432 | 56 | | continue; |
| | 57 | | } |
| 844 | 58 | | if (property.NameEquals("osDisk")) |
| | 59 | | { |
| 432 | 60 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 61 | | { |
| | 62 | | continue; |
| | 63 | | } |
| 432 | 64 | | osDisk = OSDisk.DeserializeOSDisk(property.Value); |
| 432 | 65 | | continue; |
| | 66 | | } |
| 412 | 67 | | if (property.NameEquals("dataDisks")) |
| | 68 | | { |
| 412 | 69 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 70 | | { |
| | 71 | | continue; |
| | 72 | | } |
| 412 | 73 | | List<DataDisk> array = new List<DataDisk>(); |
| 1184 | 74 | | foreach (var item in property.Value.EnumerateArray()) |
| | 75 | | { |
| 180 | 76 | | if (item.ValueKind == JsonValueKind.Null) |
| | 77 | | { |
| 0 | 78 | | array.Add(null); |
| | 79 | | } |
| | 80 | | else |
| | 81 | | { |
| 180 | 82 | | array.Add(DataDisk.DeserializeDataDisk(item)); |
| | 83 | | } |
| | 84 | | } |
| 412 | 85 | | dataDisks = array; |
| | 86 | | continue; |
| | 87 | | } |
| | 88 | | } |
| 432 | 89 | | return new StorageProfile(imageReference, osDisk, dataDisks); |
| | 90 | | } |
| | 91 | | } |
| | 92 | | } |