| | 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; |
| | 9 | | using System.Collections.Generic; |
| | 10 | | using System.Text.Json; |
| | 11 | | using Azure.Core; |
| | 12 | |
|
| | 13 | | namespace Azure.ResourceManager.Compute.Models |
| | 14 | | { |
| | 15 | | public partial class Snapshot : IUtf8JsonSerializable |
| | 16 | | { |
| | 17 | | void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) |
| | 18 | | { |
| 48 | 19 | | writer.WriteStartObject(); |
| 48 | 20 | | if (ManagedBy != null) |
| | 21 | | { |
| 0 | 22 | | writer.WritePropertyName("managedBy"); |
| 0 | 23 | | writer.WriteStringValue(ManagedBy); |
| | 24 | | } |
| 48 | 25 | | if (Sku != null) |
| | 26 | | { |
| 48 | 27 | | writer.WritePropertyName("sku"); |
| 48 | 28 | | writer.WriteObjectValue(Sku); |
| | 29 | | } |
| 48 | 30 | | if (Id != null) |
| | 31 | | { |
| 0 | 32 | | writer.WritePropertyName("id"); |
| 0 | 33 | | writer.WriteStringValue(Id); |
| | 34 | | } |
| 48 | 35 | | if (Name != null) |
| | 36 | | { |
| 0 | 37 | | writer.WritePropertyName("name"); |
| 0 | 38 | | writer.WriteStringValue(Name); |
| | 39 | | } |
| 48 | 40 | | if (Type != null) |
| | 41 | | { |
| 0 | 42 | | writer.WritePropertyName("type"); |
| 0 | 43 | | writer.WriteStringValue(Type); |
| | 44 | | } |
| 48 | 45 | | writer.WritePropertyName("location"); |
| 48 | 46 | | writer.WriteStringValue(Location); |
| 48 | 47 | | if (Tags != null) |
| | 48 | | { |
| 0 | 49 | | writer.WritePropertyName("tags"); |
| 0 | 50 | | writer.WriteStartObject(); |
| 0 | 51 | | foreach (var item in Tags) |
| | 52 | | { |
| 0 | 53 | | writer.WritePropertyName(item.Key); |
| 0 | 54 | | writer.WriteStringValue(item.Value); |
| | 55 | | } |
| 0 | 56 | | writer.WriteEndObject(); |
| | 57 | | } |
| 48 | 58 | | writer.WritePropertyName("properties"); |
| 48 | 59 | | writer.WriteStartObject(); |
| 48 | 60 | | if (TimeCreated != null) |
| | 61 | | { |
| 0 | 62 | | writer.WritePropertyName("timeCreated"); |
| 0 | 63 | | writer.WriteStringValue(TimeCreated.Value, "O"); |
| | 64 | | } |
| 48 | 65 | | if (OsType != null) |
| | 66 | | { |
| 0 | 67 | | writer.WritePropertyName("osType"); |
| 0 | 68 | | writer.WriteStringValue(OsType.Value.ToSerialString()); |
| | 69 | | } |
| 48 | 70 | | if (HyperVGeneration != null) |
| | 71 | | { |
| 0 | 72 | | writer.WritePropertyName("hyperVGeneration"); |
| 0 | 73 | | writer.WriteStringValue(HyperVGeneration.Value.ToString()); |
| | 74 | | } |
| 48 | 75 | | if (CreationData != null) |
| | 76 | | { |
| 48 | 77 | | writer.WritePropertyName("creationData"); |
| 48 | 78 | | writer.WriteObjectValue(CreationData); |
| | 79 | | } |
| 48 | 80 | | if (DiskSizeGB != null) |
| | 81 | | { |
| 0 | 82 | | writer.WritePropertyName("diskSizeGB"); |
| 0 | 83 | | writer.WriteNumberValue(DiskSizeGB.Value); |
| | 84 | | } |
| 48 | 85 | | if (DiskSizeBytes != null) |
| | 86 | | { |
| 0 | 87 | | writer.WritePropertyName("diskSizeBytes"); |
| 0 | 88 | | writer.WriteNumberValue(DiskSizeBytes.Value); |
| | 89 | | } |
| 48 | 90 | | if (UniqueId != null) |
| | 91 | | { |
| 0 | 92 | | writer.WritePropertyName("uniqueId"); |
| 0 | 93 | | writer.WriteStringValue(UniqueId); |
| | 94 | | } |
| 48 | 95 | | if (EncryptionSettingsCollection != null) |
| | 96 | | { |
| 0 | 97 | | writer.WritePropertyName("encryptionSettingsCollection"); |
| 0 | 98 | | writer.WriteObjectValue(EncryptionSettingsCollection); |
| | 99 | | } |
| 48 | 100 | | if (ProvisioningState != null) |
| | 101 | | { |
| 0 | 102 | | writer.WritePropertyName("provisioningState"); |
| 0 | 103 | | writer.WriteStringValue(ProvisioningState); |
| | 104 | | } |
| 48 | 105 | | if (Incremental != null) |
| | 106 | | { |
| 48 | 107 | | writer.WritePropertyName("incremental"); |
| 48 | 108 | | writer.WriteBooleanValue(Incremental.Value); |
| | 109 | | } |
| 48 | 110 | | if (Encryption != null) |
| | 111 | | { |
| 0 | 112 | | writer.WritePropertyName("encryption"); |
| 0 | 113 | | writer.WriteObjectValue(Encryption); |
| | 114 | | } |
| 48 | 115 | | writer.WriteEndObject(); |
| 48 | 116 | | writer.WriteEndObject(); |
| 48 | 117 | | } |
| | 118 | |
|
| | 119 | | internal static Snapshot DeserializeSnapshot(JsonElement element) |
| | 120 | | { |
| 88 | 121 | | string managedBy = default; |
| 88 | 122 | | SnapshotSku sku = default; |
| 88 | 123 | | string id = default; |
| 88 | 124 | | string name = default; |
| 88 | 125 | | string type = default; |
| 88 | 126 | | string location = default; |
| 88 | 127 | | IDictionary<string, string> tags = default; |
| 88 | 128 | | DateTimeOffset? timeCreated = default; |
| 88 | 129 | | OperatingSystemTypes? osType = default; |
| 88 | 130 | | HyperVGeneration? hyperVGeneration = default; |
| 88 | 131 | | CreationData creationData = default; |
| 88 | 132 | | int? diskSizeGB = default; |
| 88 | 133 | | long? diskSizeBytes = default; |
| 88 | 134 | | string uniqueId = default; |
| 88 | 135 | | EncryptionSettingsCollection encryptionSettingsCollection = default; |
| 88 | 136 | | string provisioningState = default; |
| 88 | 137 | | bool? incremental = default; |
| 88 | 138 | | Encryption encryption = default; |
| 1264 | 139 | | foreach (var property in element.EnumerateObject()) |
| | 140 | | { |
| 544 | 141 | | if (property.NameEquals("managedBy")) |
| | 142 | | { |
| 0 | 143 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 144 | | { |
| | 145 | | continue; |
| | 146 | | } |
| 0 | 147 | | managedBy = property.Value.GetString(); |
| 0 | 148 | | continue; |
| | 149 | | } |
| 544 | 150 | | if (property.NameEquals("sku")) |
| | 151 | | { |
| 88 | 152 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 153 | | { |
| | 154 | | continue; |
| | 155 | | } |
| 88 | 156 | | sku = SnapshotSku.DeserializeSnapshotSku(property.Value); |
| 88 | 157 | | continue; |
| | 158 | | } |
| 456 | 159 | | if (property.NameEquals("id")) |
| | 160 | | { |
| 88 | 161 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 162 | | { |
| | 163 | | continue; |
| | 164 | | } |
| 88 | 165 | | id = property.Value.GetString(); |
| 88 | 166 | | continue; |
| | 167 | | } |
| 368 | 168 | | if (property.NameEquals("name")) |
| | 169 | | { |
| 88 | 170 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 171 | | { |
| | 172 | | continue; |
| | 173 | | } |
| 88 | 174 | | name = property.Value.GetString(); |
| 88 | 175 | | continue; |
| | 176 | | } |
| 280 | 177 | | if (property.NameEquals("type")) |
| | 178 | | { |
| 88 | 179 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 180 | | { |
| | 181 | | continue; |
| | 182 | | } |
| 88 | 183 | | type = property.Value.GetString(); |
| 88 | 184 | | continue; |
| | 185 | | } |
| 192 | 186 | | if (property.NameEquals("location")) |
| | 187 | | { |
| 88 | 188 | | location = property.Value.GetString(); |
| 88 | 189 | | continue; |
| | 190 | | } |
| 104 | 191 | | if (property.NameEquals("tags")) |
| | 192 | | { |
| 16 | 193 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 194 | | { |
| | 195 | | continue; |
| | 196 | | } |
| 16 | 197 | | Dictionary<string, string> dictionary = new Dictionary<string, string>(); |
| 64 | 198 | | foreach (var property0 in property.Value.EnumerateObject()) |
| | 199 | | { |
| 16 | 200 | | if (property0.Value.ValueKind == JsonValueKind.Null) |
| | 201 | | { |
| 0 | 202 | | dictionary.Add(property0.Name, null); |
| | 203 | | } |
| | 204 | | else |
| | 205 | | { |
| 16 | 206 | | dictionary.Add(property0.Name, property0.Value.GetString()); |
| | 207 | | } |
| | 208 | | } |
| 16 | 209 | | tags = dictionary; |
| 16 | 210 | | continue; |
| | 211 | | } |
| 88 | 212 | | if (property.NameEquals("properties")) |
| | 213 | | { |
| 1936 | 214 | | foreach (var property0 in property.Value.EnumerateObject()) |
| | 215 | | { |
| 880 | 216 | | if (property0.NameEquals("timeCreated")) |
| | 217 | | { |
| 88 | 218 | | if (property0.Value.ValueKind == JsonValueKind.Null) |
| | 219 | | { |
| | 220 | | continue; |
| | 221 | | } |
| 88 | 222 | | timeCreated = property0.Value.GetDateTimeOffset("O"); |
| 88 | 223 | | continue; |
| | 224 | | } |
| 792 | 225 | | if (property0.NameEquals("osType")) |
| | 226 | | { |
| 88 | 227 | | if (property0.Value.ValueKind == JsonValueKind.Null) |
| | 228 | | { |
| | 229 | | continue; |
| | 230 | | } |
| 88 | 231 | | osType = property0.Value.GetString().ToOperatingSystemTypes(); |
| 88 | 232 | | continue; |
| | 233 | | } |
| 704 | 234 | | if (property0.NameEquals("hyperVGeneration")) |
| | 235 | | { |
| 0 | 236 | | if (property0.Value.ValueKind == JsonValueKind.Null) |
| | 237 | | { |
| | 238 | | continue; |
| | 239 | | } |
| 0 | 240 | | hyperVGeneration = new HyperVGeneration(property0.Value.GetString()); |
| 0 | 241 | | continue; |
| | 242 | | } |
| 704 | 243 | | if (property0.NameEquals("creationData")) |
| | 244 | | { |
| 88 | 245 | | if (property0.Value.ValueKind == JsonValueKind.Null) |
| | 246 | | { |
| | 247 | | continue; |
| | 248 | | } |
| 88 | 249 | | creationData = CreationData.DeserializeCreationData(property0.Value); |
| 88 | 250 | | continue; |
| | 251 | | } |
| 616 | 252 | | if (property0.NameEquals("diskSizeGB")) |
| | 253 | | { |
| 88 | 254 | | if (property0.Value.ValueKind == JsonValueKind.Null) |
| | 255 | | { |
| | 256 | | continue; |
| | 257 | | } |
| 88 | 258 | | diskSizeGB = property0.Value.GetInt32(); |
| 88 | 259 | | continue; |
| | 260 | | } |
| 528 | 261 | | if (property0.NameEquals("diskSizeBytes")) |
| | 262 | | { |
| 88 | 263 | | if (property0.Value.ValueKind == JsonValueKind.Null) |
| | 264 | | { |
| | 265 | | continue; |
| | 266 | | } |
| 88 | 267 | | diskSizeBytes = property0.Value.GetInt64(); |
| 88 | 268 | | continue; |
| | 269 | | } |
| 440 | 270 | | if (property0.NameEquals("uniqueId")) |
| | 271 | | { |
| 88 | 272 | | if (property0.Value.ValueKind == JsonValueKind.Null) |
| | 273 | | { |
| | 274 | | continue; |
| | 275 | | } |
| 88 | 276 | | uniqueId = property0.Value.GetString(); |
| 88 | 277 | | continue; |
| | 278 | | } |
| 352 | 279 | | if (property0.NameEquals("encryptionSettingsCollection")) |
| | 280 | | { |
| 0 | 281 | | if (property0.Value.ValueKind == JsonValueKind.Null) |
| | 282 | | { |
| | 283 | | continue; |
| | 284 | | } |
| 0 | 285 | | encryptionSettingsCollection = EncryptionSettingsCollection.DeserializeEncryptionSettingsCol |
| 0 | 286 | | continue; |
| | 287 | | } |
| 352 | 288 | | if (property0.NameEquals("provisioningState")) |
| | 289 | | { |
| 88 | 290 | | if (property0.Value.ValueKind == JsonValueKind.Null) |
| | 291 | | { |
| | 292 | | continue; |
| | 293 | | } |
| 88 | 294 | | provisioningState = property0.Value.GetString(); |
| 88 | 295 | | continue; |
| | 296 | | } |
| 264 | 297 | | if (property0.NameEquals("incremental")) |
| | 298 | | { |
| 88 | 299 | | if (property0.Value.ValueKind == JsonValueKind.Null) |
| | 300 | | { |
| | 301 | | continue; |
| | 302 | | } |
| 88 | 303 | | incremental = property0.Value.GetBoolean(); |
| 88 | 304 | | continue; |
| | 305 | | } |
| 176 | 306 | | if (property0.NameEquals("encryption")) |
| | 307 | | { |
| 88 | 308 | | if (property0.Value.ValueKind == JsonValueKind.Null) |
| | 309 | | { |
| | 310 | | continue; |
| | 311 | | } |
| 88 | 312 | | encryption = Encryption.DeserializeEncryption(property0.Value); |
| | 313 | | continue; |
| | 314 | | } |
| | 315 | | } |
| | 316 | | continue; |
| | 317 | | } |
| | 318 | | } |
| 88 | 319 | | return new Snapshot(id, name, type, location, tags, managedBy, sku, timeCreated, osType, hyperVGeneration, c |
| | 320 | | } |
| | 321 | | } |
| | 322 | | } |