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