| | 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 DiskInstanceView : IUtf8JsonSerializable |
| | 15 | | { |
| | 16 | | void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) |
| | 17 | | { |
| 32 | 18 | | writer.WriteStartObject(); |
| 32 | 19 | | if (Name != null) |
| | 20 | | { |
| 32 | 21 | | writer.WritePropertyName("name"); |
| 32 | 22 | | writer.WriteStringValue(Name); |
| | 23 | | } |
| 32 | 24 | | if (EncryptionSettings != null) |
| | 25 | | { |
| 0 | 26 | | writer.WritePropertyName("encryptionSettings"); |
| 0 | 27 | | writer.WriteStartArray(); |
| 0 | 28 | | foreach (var item in EncryptionSettings) |
| | 29 | | { |
| 0 | 30 | | writer.WriteObjectValue(item); |
| | 31 | | } |
| 0 | 32 | | writer.WriteEndArray(); |
| | 33 | | } |
| 32 | 34 | | if (Statuses != null) |
| | 35 | | { |
| 32 | 36 | | writer.WritePropertyName("statuses"); |
| 32 | 37 | | writer.WriteStartArray(); |
| 128 | 38 | | foreach (var item in Statuses) |
| | 39 | | { |
| 32 | 40 | | writer.WriteObjectValue(item); |
| | 41 | | } |
| 32 | 42 | | writer.WriteEndArray(); |
| | 43 | | } |
| 32 | 44 | | writer.WriteEndObject(); |
| 32 | 45 | | } |
| | 46 | |
|
| | 47 | | internal static DiskInstanceView DeserializeDiskInstanceView(JsonElement element) |
| | 48 | | { |
| 268 | 49 | | string name = default; |
| 268 | 50 | | IList<DiskEncryptionSettings> encryptionSettings = default; |
| 268 | 51 | | IList<InstanceViewStatus> statuses = default; |
| 1608 | 52 | | foreach (var property in element.EnumerateObject()) |
| | 53 | | { |
| 536 | 54 | | if (property.NameEquals("name")) |
| | 55 | | { |
| 268 | 56 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 57 | | { |
| | 58 | | continue; |
| | 59 | | } |
| 268 | 60 | | name = property.Value.GetString(); |
| 268 | 61 | | continue; |
| | 62 | | } |
| 268 | 63 | | if (property.NameEquals("encryptionSettings")) |
| | 64 | | { |
| 0 | 65 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 66 | | { |
| | 67 | | continue; |
| | 68 | | } |
| 0 | 69 | | List<DiskEncryptionSettings> array = new List<DiskEncryptionSettings>(); |
| 0 | 70 | | foreach (var item in property.Value.EnumerateArray()) |
| | 71 | | { |
| 0 | 72 | | if (item.ValueKind == JsonValueKind.Null) |
| | 73 | | { |
| 0 | 74 | | array.Add(null); |
| | 75 | | } |
| | 76 | | else |
| | 77 | | { |
| 0 | 78 | | array.Add(DiskEncryptionSettings.DeserializeDiskEncryptionSettings(item)); |
| | 79 | | } |
| | 80 | | } |
| 0 | 81 | | encryptionSettings = array; |
| 0 | 82 | | continue; |
| | 83 | | } |
| 268 | 84 | | if (property.NameEquals("statuses")) |
| | 85 | | { |
| 268 | 86 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 87 | | { |
| | 88 | | continue; |
| | 89 | | } |
| 268 | 90 | | List<InstanceViewStatus> array = new List<InstanceViewStatus>(); |
| 1072 | 91 | | foreach (var item in property.Value.EnumerateArray()) |
| | 92 | | { |
| 268 | 93 | | if (item.ValueKind == JsonValueKind.Null) |
| | 94 | | { |
| 0 | 95 | | array.Add(null); |
| | 96 | | } |
| | 97 | | else |
| | 98 | | { |
| 268 | 99 | | array.Add(InstanceViewStatus.DeserializeInstanceViewStatus(item)); |
| | 100 | | } |
| | 101 | | } |
| 268 | 102 | | statuses = array; |
| | 103 | | continue; |
| | 104 | | } |
| | 105 | | } |
| 268 | 106 | | return new DiskInstanceView(name, encryptionSettings, statuses); |
| | 107 | | } |
| | 108 | | } |
| | 109 | | } |