| | 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.Text.Json; |
| | 9 | | using Azure.Core; |
| | 10 | |
|
| | 11 | | namespace Azure.ResourceManager.Compute.Models |
| | 12 | | { |
| | 13 | | public partial class ImageDisk : IUtf8JsonSerializable |
| | 14 | | { |
| | 15 | | void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) |
| | 16 | | { |
| 0 | 17 | | writer.WriteStartObject(); |
| 0 | 18 | | if (Snapshot != null) |
| | 19 | | { |
| 0 | 20 | | writer.WritePropertyName("snapshot"); |
| 0 | 21 | | writer.WriteObjectValue(Snapshot); |
| | 22 | | } |
| 0 | 23 | | if (ManagedDisk != null) |
| | 24 | | { |
| 0 | 25 | | writer.WritePropertyName("managedDisk"); |
| 0 | 26 | | writer.WriteObjectValue(ManagedDisk); |
| | 27 | | } |
| 0 | 28 | | if (BlobUri != null) |
| | 29 | | { |
| 0 | 30 | | writer.WritePropertyName("blobUri"); |
| 0 | 31 | | writer.WriteStringValue(BlobUri); |
| | 32 | | } |
| 0 | 33 | | if (Caching != null) |
| | 34 | | { |
| 0 | 35 | | writer.WritePropertyName("caching"); |
| 0 | 36 | | writer.WriteStringValue(Caching.Value.ToSerialString()); |
| | 37 | | } |
| 0 | 38 | | if (DiskSizeGB != null) |
| | 39 | | { |
| 0 | 40 | | writer.WritePropertyName("diskSizeGB"); |
| 0 | 41 | | writer.WriteNumberValue(DiskSizeGB.Value); |
| | 42 | | } |
| 0 | 43 | | if (StorageAccountType != null) |
| | 44 | | { |
| 0 | 45 | | writer.WritePropertyName("storageAccountType"); |
| 0 | 46 | | writer.WriteStringValue(StorageAccountType.Value.ToString()); |
| | 47 | | } |
| 0 | 48 | | if (DiskEncryptionSet != null) |
| | 49 | | { |
| 0 | 50 | | writer.WritePropertyName("diskEncryptionSet"); |
| 0 | 51 | | writer.WriteObjectValue(DiskEncryptionSet); |
| | 52 | | } |
| 0 | 53 | | writer.WriteEndObject(); |
| 0 | 54 | | } |
| | 55 | |
|
| | 56 | | internal static ImageDisk DeserializeImageDisk(JsonElement element) |
| | 57 | | { |
| 0 | 58 | | SubResource snapshot = default; |
| 0 | 59 | | SubResource managedDisk = default; |
| 0 | 60 | | string blobUri = default; |
| 0 | 61 | | CachingTypes? caching = default; |
| 0 | 62 | | int? diskSizeGB = default; |
| 0 | 63 | | StorageAccountTypes? storageAccountType = default; |
| 0 | 64 | | SubResource diskEncryptionSet = default; |
| 0 | 65 | | foreach (var property in element.EnumerateObject()) |
| | 66 | | { |
| 0 | 67 | | if (property.NameEquals("snapshot")) |
| | 68 | | { |
| 0 | 69 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 70 | | { |
| | 71 | | continue; |
| | 72 | | } |
| 0 | 73 | | snapshot = SubResource.DeserializeSubResource(property.Value); |
| 0 | 74 | | continue; |
| | 75 | | } |
| 0 | 76 | | if (property.NameEquals("managedDisk")) |
| | 77 | | { |
| 0 | 78 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 79 | | { |
| | 80 | | continue; |
| | 81 | | } |
| 0 | 82 | | managedDisk = SubResource.DeserializeSubResource(property.Value); |
| 0 | 83 | | continue; |
| | 84 | | } |
| 0 | 85 | | if (property.NameEquals("blobUri")) |
| | 86 | | { |
| 0 | 87 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 88 | | { |
| | 89 | | continue; |
| | 90 | | } |
| 0 | 91 | | blobUri = property.Value.GetString(); |
| 0 | 92 | | continue; |
| | 93 | | } |
| 0 | 94 | | if (property.NameEquals("caching")) |
| | 95 | | { |
| 0 | 96 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 97 | | { |
| | 98 | | continue; |
| | 99 | | } |
| 0 | 100 | | caching = property.Value.GetString().ToCachingTypes(); |
| 0 | 101 | | continue; |
| | 102 | | } |
| 0 | 103 | | if (property.NameEquals("diskSizeGB")) |
| | 104 | | { |
| 0 | 105 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 106 | | { |
| | 107 | | continue; |
| | 108 | | } |
| 0 | 109 | | diskSizeGB = property.Value.GetInt32(); |
| 0 | 110 | | continue; |
| | 111 | | } |
| 0 | 112 | | if (property.NameEquals("storageAccountType")) |
| | 113 | | { |
| 0 | 114 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 115 | | { |
| | 116 | | continue; |
| | 117 | | } |
| 0 | 118 | | storageAccountType = new StorageAccountTypes(property.Value.GetString()); |
| 0 | 119 | | continue; |
| | 120 | | } |
| 0 | 121 | | if (property.NameEquals("diskEncryptionSet")) |
| | 122 | | { |
| 0 | 123 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 124 | | { |
| | 125 | | continue; |
| | 126 | | } |
| 0 | 127 | | diskEncryptionSet = SubResource.DeserializeSubResource(property.Value); |
| | 128 | | continue; |
| | 129 | | } |
| | 130 | | } |
| 0 | 131 | | return new ImageDisk(snapshot, managedDisk, blobUri, caching, diskSizeGB, storageAccountType, diskEncryption |
| | 132 | | } |
| | 133 | | } |
| | 134 | | } |