| | 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 Disk : IUtf8JsonSerializable |
| | 16 | | { |
| | 17 | | void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) |
| | 18 | | { |
| 180 | 19 | | writer.WriteStartObject(); |
| 180 | 20 | | if (ManagedBy != null) |
| | 21 | | { |
| 0 | 22 | | writer.WritePropertyName("managedBy"); |
| 0 | 23 | | writer.WriteStringValue(ManagedBy); |
| | 24 | | } |
| 180 | 25 | | if (ManagedByExtended != null) |
| | 26 | | { |
| 0 | 27 | | writer.WritePropertyName("managedByExtended"); |
| 0 | 28 | | writer.WriteStartArray(); |
| 0 | 29 | | foreach (var item in ManagedByExtended) |
| | 30 | | { |
| 0 | 31 | | writer.WriteStringValue(item); |
| | 32 | | } |
| 0 | 33 | | writer.WriteEndArray(); |
| | 34 | | } |
| 180 | 35 | | if (Sku != null) |
| | 36 | | { |
| 180 | 37 | | writer.WritePropertyName("sku"); |
| 180 | 38 | | writer.WriteObjectValue(Sku); |
| | 39 | | } |
| 180 | 40 | | if (Zones != null) |
| | 41 | | { |
| 16 | 42 | | writer.WritePropertyName("zones"); |
| 16 | 43 | | writer.WriteStartArray(); |
| 64 | 44 | | foreach (var item in Zones) |
| | 45 | | { |
| 16 | 46 | | writer.WriteStringValue(item); |
| | 47 | | } |
| 16 | 48 | | writer.WriteEndArray(); |
| | 49 | | } |
| 180 | 50 | | if (Id != null) |
| | 51 | | { |
| 0 | 52 | | writer.WritePropertyName("id"); |
| 0 | 53 | | writer.WriteStringValue(Id); |
| | 54 | | } |
| 180 | 55 | | if (Name != null) |
| | 56 | | { |
| 0 | 57 | | writer.WritePropertyName("name"); |
| 0 | 58 | | writer.WriteStringValue(Name); |
| | 59 | | } |
| 180 | 60 | | if (Type != null) |
| | 61 | | { |
| 0 | 62 | | writer.WritePropertyName("type"); |
| 0 | 63 | | writer.WriteStringValue(Type); |
| | 64 | | } |
| 180 | 65 | | writer.WritePropertyName("location"); |
| 180 | 66 | | writer.WriteStringValue(Location); |
| 180 | 67 | | if (Tags != null) |
| | 68 | | { |
| 0 | 69 | | writer.WritePropertyName("tags"); |
| 0 | 70 | | writer.WriteStartObject(); |
| 0 | 71 | | foreach (var item in Tags) |
| | 72 | | { |
| 0 | 73 | | writer.WritePropertyName(item.Key); |
| 0 | 74 | | writer.WriteStringValue(item.Value); |
| | 75 | | } |
| 0 | 76 | | writer.WriteEndObject(); |
| | 77 | | } |
| 180 | 78 | | writer.WritePropertyName("properties"); |
| 180 | 79 | | writer.WriteStartObject(); |
| 180 | 80 | | if (TimeCreated != null) |
| | 81 | | { |
| 0 | 82 | | writer.WritePropertyName("timeCreated"); |
| 0 | 83 | | writer.WriteStringValue(TimeCreated.Value, "O"); |
| | 84 | | } |
| 180 | 85 | | if (OsType != null) |
| | 86 | | { |
| 180 | 87 | | writer.WritePropertyName("osType"); |
| 180 | 88 | | writer.WriteStringValue(OsType.Value.ToSerialString()); |
| | 89 | | } |
| 180 | 90 | | if (HyperVGeneration != null) |
| | 91 | | { |
| 16 | 92 | | writer.WritePropertyName("hyperVGeneration"); |
| 16 | 93 | | writer.WriteStringValue(HyperVGeneration.Value.ToString()); |
| | 94 | | } |
| 180 | 95 | | if (CreationData != null) |
| | 96 | | { |
| 180 | 97 | | writer.WritePropertyName("creationData"); |
| 180 | 98 | | writer.WriteObjectValue(CreationData); |
| | 99 | | } |
| 180 | 100 | | if (DiskSizeGB != null) |
| | 101 | | { |
| 172 | 102 | | writer.WritePropertyName("diskSizeGB"); |
| 172 | 103 | | writer.WriteNumberValue(DiskSizeGB.Value); |
| | 104 | | } |
| 180 | 105 | | if (DiskSizeBytes != null) |
| | 106 | | { |
| 0 | 107 | | writer.WritePropertyName("diskSizeBytes"); |
| 0 | 108 | | writer.WriteNumberValue(DiskSizeBytes.Value); |
| | 109 | | } |
| 180 | 110 | | if (UniqueId != null) |
| | 111 | | { |
| 0 | 112 | | writer.WritePropertyName("uniqueId"); |
| 0 | 113 | | writer.WriteStringValue(UniqueId); |
| | 114 | | } |
| 180 | 115 | | if (EncryptionSettingsCollection != null) |
| | 116 | | { |
| 4 | 117 | | writer.WritePropertyName("encryptionSettingsCollection"); |
| 4 | 118 | | writer.WriteObjectValue(EncryptionSettingsCollection); |
| | 119 | | } |
| 180 | 120 | | if (ProvisioningState != null) |
| | 121 | | { |
| 0 | 122 | | writer.WritePropertyName("provisioningState"); |
| 0 | 123 | | writer.WriteStringValue(ProvisioningState); |
| | 124 | | } |
| 180 | 125 | | if (DiskIopsReadWrite != null) |
| | 126 | | { |
| 8 | 127 | | writer.WritePropertyName("diskIOPSReadWrite"); |
| 8 | 128 | | writer.WriteNumberValue(DiskIopsReadWrite.Value); |
| | 129 | | } |
| 180 | 130 | | if (DiskMBpsReadWrite != null) |
| | 131 | | { |
| 8 | 132 | | writer.WritePropertyName("diskMBpsReadWrite"); |
| 8 | 133 | | writer.WriteNumberValue(DiskMBpsReadWrite.Value); |
| | 134 | | } |
| 180 | 135 | | if (DiskIopsReadOnly != null) |
| | 136 | | { |
| 0 | 137 | | writer.WritePropertyName("diskIOPSReadOnly"); |
| 0 | 138 | | writer.WriteNumberValue(DiskIopsReadOnly.Value); |
| | 139 | | } |
| 180 | 140 | | if (DiskMBpsReadOnly != null) |
| | 141 | | { |
| 0 | 142 | | writer.WritePropertyName("diskMBpsReadOnly"); |
| 0 | 143 | | writer.WriteNumberValue(DiskMBpsReadOnly.Value); |
| | 144 | | } |
| 180 | 145 | | if (DiskState != null) |
| | 146 | | { |
| 0 | 147 | | writer.WritePropertyName("diskState"); |
| 0 | 148 | | writer.WriteStringValue(DiskState.Value.ToString()); |
| | 149 | | } |
| 180 | 150 | | if (Encryption != null) |
| | 151 | | { |
| 0 | 152 | | writer.WritePropertyName("encryption"); |
| 0 | 153 | | writer.WriteObjectValue(Encryption); |
| | 154 | | } |
| 180 | 155 | | if (MaxShares != null) |
| | 156 | | { |
| 0 | 157 | | writer.WritePropertyName("maxShares"); |
| 0 | 158 | | writer.WriteNumberValue(MaxShares.Value); |
| | 159 | | } |
| 180 | 160 | | if (ShareInfo != null) |
| | 161 | | { |
| 0 | 162 | | writer.WritePropertyName("shareInfo"); |
| 0 | 163 | | writer.WriteStartArray(); |
| 0 | 164 | | foreach (var item in ShareInfo) |
| | 165 | | { |
| 0 | 166 | | writer.WriteObjectValue(item); |
| | 167 | | } |
| 0 | 168 | | writer.WriteEndArray(); |
| | 169 | | } |
| 180 | 170 | | writer.WriteEndObject(); |
| 180 | 171 | | writer.WriteEndObject(); |
| 180 | 172 | | } |
| | 173 | |
|
| | 174 | | internal static Disk DeserializeDisk(JsonElement element) |
| | 175 | | { |
| 228 | 176 | | string managedBy = default; |
| 228 | 177 | | IList<string> managedByExtended = default; |
| 228 | 178 | | DiskSku sku = default; |
| 228 | 179 | | IList<string> zones = default; |
| 228 | 180 | | string id = default; |
| 228 | 181 | | string name = default; |
| 228 | 182 | | string type = default; |
| 228 | 183 | | string location = default; |
| 228 | 184 | | IDictionary<string, string> tags = default; |
| 228 | 185 | | DateTimeOffset? timeCreated = default; |
| 228 | 186 | | OperatingSystemTypes? osType = default; |
| 228 | 187 | | HyperVGeneration? hyperVGeneration = default; |
| 228 | 188 | | CreationData creationData = default; |
| 228 | 189 | | int? diskSizeGB = default; |
| 228 | 190 | | long? diskSizeBytes = default; |
| 228 | 191 | | string uniqueId = default; |
| 228 | 192 | | EncryptionSettingsCollection encryptionSettingsCollection = default; |
| 228 | 193 | | string provisioningState = default; |
| 228 | 194 | | long? diskIOPSReadWrite = default; |
| 228 | 195 | | long? diskMBpsReadWrite = default; |
| 228 | 196 | | long? diskIOPSReadOnly = default; |
| 228 | 197 | | long? diskMBpsReadOnly = default; |
| 228 | 198 | | DiskState? diskState = default; |
| 228 | 199 | | Encryption encryption = default; |
| 228 | 200 | | int? maxShares = default; |
| 228 | 201 | | IList<ShareInfoElement> shareInfo = default; |
| 3320 | 202 | | foreach (var property in element.EnumerateObject()) |
| | 203 | | { |
| 1432 | 204 | | if (property.NameEquals("managedBy")) |
| | 205 | | { |
| 4 | 206 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 207 | | { |
| | 208 | | continue; |
| | 209 | | } |
| 4 | 210 | | managedBy = property.Value.GetString(); |
| 4 | 211 | | continue; |
| | 212 | | } |
| 1428 | 213 | | if (property.NameEquals("managedByExtended")) |
| | 214 | | { |
| 0 | 215 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 216 | | { |
| | 217 | | continue; |
| | 218 | | } |
| 0 | 219 | | List<string> array = new List<string>(); |
| 0 | 220 | | foreach (var item in property.Value.EnumerateArray()) |
| | 221 | | { |
| 0 | 222 | | if (item.ValueKind == JsonValueKind.Null) |
| | 223 | | { |
| 0 | 224 | | array.Add(null); |
| | 225 | | } |
| | 226 | | else |
| | 227 | | { |
| 0 | 228 | | array.Add(item.GetString()); |
| | 229 | | } |
| | 230 | | } |
| 0 | 231 | | managedByExtended = array; |
| 0 | 232 | | continue; |
| | 233 | | } |
| 1428 | 234 | | if (property.NameEquals("sku")) |
| | 235 | | { |
| 228 | 236 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 237 | | { |
| | 238 | | continue; |
| | 239 | | } |
| 228 | 240 | | sku = DiskSku.DeserializeDiskSku(property.Value); |
| 228 | 241 | | continue; |
| | 242 | | } |
| 1200 | 243 | | if (property.NameEquals("zones")) |
| | 244 | | { |
| 32 | 245 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 246 | | { |
| | 247 | | continue; |
| | 248 | | } |
| 32 | 249 | | List<string> array = new List<string>(); |
| 128 | 250 | | foreach (var item in property.Value.EnumerateArray()) |
| | 251 | | { |
| 32 | 252 | | if (item.ValueKind == JsonValueKind.Null) |
| | 253 | | { |
| 0 | 254 | | array.Add(null); |
| | 255 | | } |
| | 256 | | else |
| | 257 | | { |
| 32 | 258 | | array.Add(item.GetString()); |
| | 259 | | } |
| | 260 | | } |
| 32 | 261 | | zones = array; |
| 32 | 262 | | continue; |
| | 263 | | } |
| 1168 | 264 | | if (property.NameEquals("id")) |
| | 265 | | { |
| 228 | 266 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 267 | | { |
| | 268 | | continue; |
| | 269 | | } |
| 228 | 270 | | id = property.Value.GetString(); |
| 228 | 271 | | continue; |
| | 272 | | } |
| 940 | 273 | | if (property.NameEquals("name")) |
| | 274 | | { |
| 228 | 275 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 276 | | { |
| | 277 | | continue; |
| | 278 | | } |
| 228 | 279 | | name = property.Value.GetString(); |
| 228 | 280 | | continue; |
| | 281 | | } |
| 712 | 282 | | if (property.NameEquals("type")) |
| | 283 | | { |
| 228 | 284 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 285 | | { |
| | 286 | | continue; |
| | 287 | | } |
| 228 | 288 | | type = property.Value.GetString(); |
| 228 | 289 | | continue; |
| | 290 | | } |
| 484 | 291 | | if (property.NameEquals("location")) |
| | 292 | | { |
| 228 | 293 | | location = property.Value.GetString(); |
| 228 | 294 | | continue; |
| | 295 | | } |
| 256 | 296 | | if (property.NameEquals("tags")) |
| | 297 | | { |
| 28 | 298 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 299 | | { |
| | 300 | | continue; |
| | 301 | | } |
| 28 | 302 | | Dictionary<string, string> dictionary = new Dictionary<string, string>(); |
| 120 | 303 | | foreach (var property0 in property.Value.EnumerateObject()) |
| | 304 | | { |
| 32 | 305 | | if (property0.Value.ValueKind == JsonValueKind.Null) |
| | 306 | | { |
| 0 | 307 | | dictionary.Add(property0.Name, null); |
| | 308 | | } |
| | 309 | | else |
| | 310 | | { |
| 32 | 311 | | dictionary.Add(property0.Name, property0.Value.GetString()); |
| | 312 | | } |
| | 313 | | } |
| 28 | 314 | | tags = dictionary; |
| 28 | 315 | | continue; |
| | 316 | | } |
| 228 | 317 | | if (property.NameEquals("properties")) |
| | 318 | | { |
| 5608 | 319 | | foreach (var property0 in property.Value.EnumerateObject()) |
| | 320 | | { |
| 2576 | 321 | | if (property0.NameEquals("timeCreated")) |
| | 322 | | { |
| 228 | 323 | | if (property0.Value.ValueKind == JsonValueKind.Null) |
| | 324 | | { |
| | 325 | | continue; |
| | 326 | | } |
| 228 | 327 | | timeCreated = property0.Value.GetDateTimeOffset("O"); |
| 228 | 328 | | continue; |
| | 329 | | } |
| 2348 | 330 | | if (property0.NameEquals("osType")) |
| | 331 | | { |
| 228 | 332 | | if (property0.Value.ValueKind == JsonValueKind.Null) |
| | 333 | | { |
| | 334 | | continue; |
| | 335 | | } |
| 228 | 336 | | osType = property0.Value.GetString().ToOperatingSystemTypes(); |
| 228 | 337 | | continue; |
| | 338 | | } |
| 2120 | 339 | | if (property0.NameEquals("hyperVGeneration")) |
| | 340 | | { |
| 20 | 341 | | if (property0.Value.ValueKind == JsonValueKind.Null) |
| | 342 | | { |
| | 343 | | continue; |
| | 344 | | } |
| 20 | 345 | | hyperVGeneration = new HyperVGeneration(property0.Value.GetString()); |
| 20 | 346 | | continue; |
| | 347 | | } |
| 2100 | 348 | | if (property0.NameEquals("creationData")) |
| | 349 | | { |
| 228 | 350 | | if (property0.Value.ValueKind == JsonValueKind.Null) |
| | 351 | | { |
| | 352 | | continue; |
| | 353 | | } |
| 228 | 354 | | creationData = CreationData.DeserializeCreationData(property0.Value); |
| 228 | 355 | | continue; |
| | 356 | | } |
| 1872 | 357 | | if (property0.NameEquals("diskSizeGB")) |
| | 358 | | { |
| 220 | 359 | | if (property0.Value.ValueKind == JsonValueKind.Null) |
| | 360 | | { |
| | 361 | | continue; |
| | 362 | | } |
| 220 | 363 | | diskSizeGB = property0.Value.GetInt32(); |
| 220 | 364 | | continue; |
| | 365 | | } |
| 1652 | 366 | | if (property0.NameEquals("diskSizeBytes")) |
| | 367 | | { |
| 220 | 368 | | if (property0.Value.ValueKind == JsonValueKind.Null) |
| | 369 | | { |
| | 370 | | continue; |
| | 371 | | } |
| 220 | 372 | | diskSizeBytes = property0.Value.GetInt64(); |
| 220 | 373 | | continue; |
| | 374 | | } |
| 1432 | 375 | | if (property0.NameEquals("uniqueId")) |
| | 376 | | { |
| 228 | 377 | | if (property0.Value.ValueKind == JsonValueKind.Null) |
| | 378 | | { |
| | 379 | | continue; |
| | 380 | | } |
| 228 | 381 | | uniqueId = property0.Value.GetString(); |
| 228 | 382 | | continue; |
| | 383 | | } |
| 1204 | 384 | | if (property0.NameEquals("encryptionSettingsCollection")) |
| | 385 | | { |
| 0 | 386 | | if (property0.Value.ValueKind == JsonValueKind.Null) |
| | 387 | | { |
| | 388 | | continue; |
| | 389 | | } |
| 0 | 390 | | encryptionSettingsCollection = EncryptionSettingsCollection.DeserializeEncryptionSettingsCol |
| 0 | 391 | | continue; |
| | 392 | | } |
| 1204 | 393 | | if (property0.NameEquals("provisioningState")) |
| | 394 | | { |
| 228 | 395 | | if (property0.Value.ValueKind == JsonValueKind.Null) |
| | 396 | | { |
| | 397 | | continue; |
| | 398 | | } |
| 228 | 399 | | provisioningState = property0.Value.GetString(); |
| 228 | 400 | | continue; |
| | 401 | | } |
| 976 | 402 | | if (property0.NameEquals("diskIOPSReadWrite")) |
| | 403 | | { |
| 228 | 404 | | if (property0.Value.ValueKind == JsonValueKind.Null) |
| | 405 | | { |
| | 406 | | continue; |
| | 407 | | } |
| 228 | 408 | | diskIOPSReadWrite = property0.Value.GetInt64(); |
| 228 | 409 | | continue; |
| | 410 | | } |
| 748 | 411 | | if (property0.NameEquals("diskMBpsReadWrite")) |
| | 412 | | { |
| 228 | 413 | | if (property0.Value.ValueKind == JsonValueKind.Null) |
| | 414 | | { |
| | 415 | | continue; |
| | 416 | | } |
| 228 | 417 | | diskMBpsReadWrite = property0.Value.GetInt64(); |
| 228 | 418 | | continue; |
| | 419 | | } |
| 520 | 420 | | if (property0.NameEquals("diskIOPSReadOnly")) |
| | 421 | | { |
| 16 | 422 | | if (property0.Value.ValueKind == JsonValueKind.Null) |
| | 423 | | { |
| | 424 | | continue; |
| | 425 | | } |
| 16 | 426 | | diskIOPSReadOnly = property0.Value.GetInt64(); |
| 16 | 427 | | continue; |
| | 428 | | } |
| 504 | 429 | | if (property0.NameEquals("diskMBpsReadOnly")) |
| | 430 | | { |
| 16 | 431 | | if (property0.Value.ValueKind == JsonValueKind.Null) |
| | 432 | | { |
| | 433 | | continue; |
| | 434 | | } |
| 16 | 435 | | diskMBpsReadOnly = property0.Value.GetInt64(); |
| 16 | 436 | | continue; |
| | 437 | | } |
| 488 | 438 | | if (property0.NameEquals("diskState")) |
| | 439 | | { |
| 228 | 440 | | if (property0.Value.ValueKind == JsonValueKind.Null) |
| | 441 | | { |
| | 442 | | continue; |
| | 443 | | } |
| 228 | 444 | | diskState = new DiskState(property0.Value.GetString()); |
| 228 | 445 | | continue; |
| | 446 | | } |
| 260 | 447 | | if (property0.NameEquals("encryption")) |
| | 448 | | { |
| 228 | 449 | | if (property0.Value.ValueKind == JsonValueKind.Null) |
| | 450 | | { |
| | 451 | | continue; |
| | 452 | | } |
| 228 | 453 | | encryption = Encryption.DeserializeEncryption(property0.Value); |
| 228 | 454 | | continue; |
| | 455 | | } |
| 32 | 456 | | if (property0.NameEquals("maxShares")) |
| | 457 | | { |
| 16 | 458 | | if (property0.Value.ValueKind == JsonValueKind.Null) |
| | 459 | | { |
| | 460 | | continue; |
| | 461 | | } |
| 16 | 462 | | maxShares = property0.Value.GetInt32(); |
| 16 | 463 | | continue; |
| | 464 | | } |
| 16 | 465 | | if (property0.NameEquals("shareInfo")) |
| | 466 | | { |
| 0 | 467 | | if (property0.Value.ValueKind == JsonValueKind.Null) |
| | 468 | | { |
| | 469 | | continue; |
| | 470 | | } |
| 0 | 471 | | List<ShareInfoElement> array = new List<ShareInfoElement>(); |
| 0 | 472 | | foreach (var item in property0.Value.EnumerateArray()) |
| | 473 | | { |
| 0 | 474 | | if (item.ValueKind == JsonValueKind.Null) |
| | 475 | | { |
| 0 | 476 | | array.Add(null); |
| | 477 | | } |
| | 478 | | else |
| | 479 | | { |
| 0 | 480 | | array.Add(ShareInfoElement.DeserializeShareInfoElement(item)); |
| | 481 | | } |
| | 482 | | } |
| 0 | 483 | | shareInfo = array; |
| | 484 | | continue; |
| | 485 | | } |
| | 486 | | } |
| | 487 | | continue; |
| | 488 | | } |
| | 489 | | } |
| 228 | 490 | | return new Disk(id, name, type, location, tags, managedBy, managedByExtended, sku, zones, timeCreated, osTyp |
| | 491 | | } |
| | 492 | | } |
| | 493 | | } |