| | 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 GalleryDataDiskImage : IUtf8JsonSerializable |
| | 14 | | { |
| | 15 | | void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) |
| | 16 | | { |
| 0 | 17 | | writer.WriteStartObject(); |
| 0 | 18 | | writer.WritePropertyName("lun"); |
| 0 | 19 | | writer.WriteNumberValue(Lun); |
| 0 | 20 | | if (SizeInGB != null) |
| | 21 | | { |
| 0 | 22 | | writer.WritePropertyName("sizeInGB"); |
| 0 | 23 | | writer.WriteNumberValue(SizeInGB.Value); |
| | 24 | | } |
| 0 | 25 | | if (HostCaching != null) |
| | 26 | | { |
| 0 | 27 | | writer.WritePropertyName("hostCaching"); |
| 0 | 28 | | writer.WriteStringValue(HostCaching.Value.ToSerialString()); |
| | 29 | | } |
| 0 | 30 | | if (Source != null) |
| | 31 | | { |
| 0 | 32 | | writer.WritePropertyName("source"); |
| 0 | 33 | | writer.WriteObjectValue(Source); |
| | 34 | | } |
| 0 | 35 | | writer.WriteEndObject(); |
| 0 | 36 | | } |
| | 37 | |
|
| | 38 | | internal static GalleryDataDiskImage DeserializeGalleryDataDiskImage(JsonElement element) |
| | 39 | | { |
| 0 | 40 | | int lun = default; |
| 0 | 41 | | int? sizeInGB = default; |
| 0 | 42 | | HostCaching? hostCaching = default; |
| 0 | 43 | | GalleryArtifactVersionSource source = default; |
| 0 | 44 | | foreach (var property in element.EnumerateObject()) |
| | 45 | | { |
| 0 | 46 | | if (property.NameEquals("lun")) |
| | 47 | | { |
| 0 | 48 | | lun = property.Value.GetInt32(); |
| 0 | 49 | | continue; |
| | 50 | | } |
| 0 | 51 | | if (property.NameEquals("sizeInGB")) |
| | 52 | | { |
| 0 | 53 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 54 | | { |
| | 55 | | continue; |
| | 56 | | } |
| 0 | 57 | | sizeInGB = property.Value.GetInt32(); |
| 0 | 58 | | continue; |
| | 59 | | } |
| 0 | 60 | | if (property.NameEquals("hostCaching")) |
| | 61 | | { |
| 0 | 62 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 63 | | { |
| | 64 | | continue; |
| | 65 | | } |
| 0 | 66 | | hostCaching = property.Value.GetString().ToHostCaching(); |
| 0 | 67 | | continue; |
| | 68 | | } |
| 0 | 69 | | if (property.NameEquals("source")) |
| | 70 | | { |
| 0 | 71 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 72 | | { |
| | 73 | | continue; |
| | 74 | | } |
| 0 | 75 | | source = GalleryArtifactVersionSource.DeserializeGalleryArtifactVersionSource(property.Value); |
| | 76 | | continue; |
| | 77 | | } |
| | 78 | | } |
| 0 | 79 | | return new GalleryDataDiskImage(sizeInGB, hostCaching, source, lun); |
| | 80 | | } |
| | 81 | | } |
| | 82 | | } |