| | 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 Image : IUtf8JsonSerializable |
| | 15 | | { |
| | 16 | | void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) |
| | 17 | | { |
| 16 | 18 | | writer.WriteStartObject(); |
| 16 | 19 | | if (Id != null) |
| | 20 | | { |
| 0 | 21 | | writer.WritePropertyName("id"); |
| 0 | 22 | | writer.WriteStringValue(Id); |
| | 23 | | } |
| 16 | 24 | | if (Name != null) |
| | 25 | | { |
| 0 | 26 | | writer.WritePropertyName("name"); |
| 0 | 27 | | writer.WriteStringValue(Name); |
| | 28 | | } |
| 16 | 29 | | if (Type != null) |
| | 30 | | { |
| 0 | 31 | | writer.WritePropertyName("type"); |
| 0 | 32 | | writer.WriteStringValue(Type); |
| | 33 | | } |
| 16 | 34 | | writer.WritePropertyName("location"); |
| 16 | 35 | | writer.WriteStringValue(Location); |
| 16 | 36 | | if (Tags != null) |
| | 37 | | { |
| 16 | 38 | | writer.WritePropertyName("tags"); |
| 16 | 39 | | writer.WriteStartObject(); |
| 96 | 40 | | foreach (var item in Tags) |
| | 41 | | { |
| 32 | 42 | | writer.WritePropertyName(item.Key); |
| 32 | 43 | | writer.WriteStringValue(item.Value); |
| | 44 | | } |
| 16 | 45 | | writer.WriteEndObject(); |
| | 46 | | } |
| 16 | 47 | | writer.WritePropertyName("properties"); |
| 16 | 48 | | writer.WriteStartObject(); |
| 16 | 49 | | if (SourceVirtualMachine != null) |
| | 50 | | { |
| 0 | 51 | | writer.WritePropertyName("sourceVirtualMachine"); |
| 0 | 52 | | writer.WriteObjectValue(SourceVirtualMachine); |
| | 53 | | } |
| 16 | 54 | | if (StorageProfile != null) |
| | 55 | | { |
| 16 | 56 | | writer.WritePropertyName("storageProfile"); |
| 16 | 57 | | writer.WriteObjectValue(StorageProfile); |
| | 58 | | } |
| 16 | 59 | | if (ProvisioningState != null) |
| | 60 | | { |
| 0 | 61 | | writer.WritePropertyName("provisioningState"); |
| 0 | 62 | | writer.WriteStringValue(ProvisioningState); |
| | 63 | | } |
| 16 | 64 | | if (HyperVGeneration != null) |
| | 65 | | { |
| 16 | 66 | | writer.WritePropertyName("hyperVGeneration"); |
| 16 | 67 | | writer.WriteStringValue(HyperVGeneration.Value.ToString()); |
| | 68 | | } |
| 16 | 69 | | writer.WriteEndObject(); |
| 16 | 70 | | writer.WriteEndObject(); |
| 16 | 71 | | } |
| | 72 | |
|
| | 73 | | internal static Image DeserializeImage(JsonElement element) |
| | 74 | | { |
| 28 | 75 | | string id = default; |
| 28 | 76 | | string name = default; |
| 28 | 77 | | string type = default; |
| 28 | 78 | | string location = default; |
| 28 | 79 | | IDictionary<string, string> tags = default; |
| 28 | 80 | | SubResource sourceVirtualMachine = default; |
| 28 | 81 | | ImageStorageProfile storageProfile = default; |
| 28 | 82 | | string provisioningState = default; |
| 28 | 83 | | HyperVGenerationTypes? hyperVGeneration = default; |
| 376 | 84 | | foreach (var property in element.EnumerateObject()) |
| | 85 | | { |
| 160 | 86 | | if (property.NameEquals("id")) |
| | 87 | | { |
| 24 | 88 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 89 | | { |
| | 90 | | continue; |
| | 91 | | } |
| 24 | 92 | | id = property.Value.GetString(); |
| 24 | 93 | | continue; |
| | 94 | | } |
| 136 | 95 | | if (property.NameEquals("name")) |
| | 96 | | { |
| 28 | 97 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 98 | | { |
| | 99 | | continue; |
| | 100 | | } |
| 28 | 101 | | name = property.Value.GetString(); |
| 28 | 102 | | continue; |
| | 103 | | } |
| 108 | 104 | | if (property.NameEquals("type")) |
| | 105 | | { |
| 24 | 106 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 107 | | { |
| | 108 | | continue; |
| | 109 | | } |
| 24 | 110 | | type = property.Value.GetString(); |
| 24 | 111 | | continue; |
| | 112 | | } |
| 84 | 113 | | if (property.NameEquals("location")) |
| | 114 | | { |
| 24 | 115 | | location = property.Value.GetString(); |
| 24 | 116 | | continue; |
| | 117 | | } |
| 60 | 118 | | if (property.NameEquals("tags")) |
| | 119 | | { |
| 24 | 120 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 121 | | { |
| | 122 | | continue; |
| | 123 | | } |
| 24 | 124 | | Dictionary<string, string> dictionary = new Dictionary<string, string>(); |
| 160 | 125 | | foreach (var property0 in property.Value.EnumerateObject()) |
| | 126 | | { |
| 56 | 127 | | if (property0.Value.ValueKind == JsonValueKind.Null) |
| | 128 | | { |
| 0 | 129 | | dictionary.Add(property0.Name, null); |
| | 130 | | } |
| | 131 | | else |
| | 132 | | { |
| 56 | 133 | | dictionary.Add(property0.Name, property0.Value.GetString()); |
| | 134 | | } |
| | 135 | | } |
| 24 | 136 | | tags = dictionary; |
| 24 | 137 | | continue; |
| | 138 | | } |
| 36 | 139 | | if (property.NameEquals("properties")) |
| | 140 | | { |
| 192 | 141 | | foreach (var property0 in property.Value.EnumerateObject()) |
| | 142 | | { |
| 72 | 143 | | if (property0.NameEquals("sourceVirtualMachine")) |
| | 144 | | { |
| 0 | 145 | | if (property0.Value.ValueKind == JsonValueKind.Null) |
| | 146 | | { |
| | 147 | | continue; |
| | 148 | | } |
| 0 | 149 | | sourceVirtualMachine = SubResource.DeserializeSubResource(property0.Value); |
| 0 | 150 | | continue; |
| | 151 | | } |
| 72 | 152 | | if (property0.NameEquals("storageProfile")) |
| | 153 | | { |
| 24 | 154 | | if (property0.Value.ValueKind == JsonValueKind.Null) |
| | 155 | | { |
| | 156 | | continue; |
| | 157 | | } |
| 24 | 158 | | storageProfile = ImageStorageProfile.DeserializeImageStorageProfile(property0.Value); |
| 24 | 159 | | continue; |
| | 160 | | } |
| 48 | 161 | | if (property0.NameEquals("provisioningState")) |
| | 162 | | { |
| 24 | 163 | | if (property0.Value.ValueKind == JsonValueKind.Null) |
| | 164 | | { |
| | 165 | | continue; |
| | 166 | | } |
| 24 | 167 | | provisioningState = property0.Value.GetString(); |
| 24 | 168 | | continue; |
| | 169 | | } |
| 24 | 170 | | if (property0.NameEquals("hyperVGeneration")) |
| | 171 | | { |
| 24 | 172 | | if (property0.Value.ValueKind == JsonValueKind.Null) |
| | 173 | | { |
| | 174 | | continue; |
| | 175 | | } |
| 24 | 176 | | hyperVGeneration = new HyperVGenerationTypes(property0.Value.GetString()); |
| | 177 | | continue; |
| | 178 | | } |
| | 179 | | } |
| | 180 | | continue; |
| | 181 | | } |
| | 182 | | } |
| 28 | 183 | | return new Image(id, name, type, location, tags, sourceVirtualMachine, storageProfile, provisioningState, hy |
| | 184 | | } |
| | 185 | | } |
| | 186 | | } |