internal static DiskInstanceView DeserializeDiskInstanceView(JsonElement element) { Optional <string> name = default; Optional <IReadOnlyList <DiskEncryptionSettings> > encryptionSettings = default; Optional <IReadOnlyList <InstanceViewStatus> > statuses = default; foreach (var property in element.EnumerateObject()) { if (property.NameEquals("name")) { name = property.Value.GetString(); continue; } if (property.NameEquals("encryptionSettings")) { if (property.Value.ValueKind == JsonValueKind.Null) { property.ThrowNonNullablePropertyIsNull(); continue; } List <DiskEncryptionSettings> array = new List <DiskEncryptionSettings>(); foreach (var item in property.Value.EnumerateArray()) { array.Add(DiskEncryptionSettings.DeserializeDiskEncryptionSettings(item)); } encryptionSettings = array; continue; } if (property.NameEquals("statuses")) { if (property.Value.ValueKind == JsonValueKind.Null) { property.ThrowNonNullablePropertyIsNull(); continue; } List <InstanceViewStatus> array = new List <InstanceViewStatus>(); foreach (var item in property.Value.EnumerateArray()) { array.Add(InstanceViewStatus.DeserializeInstanceViewStatus(item)); } statuses = array; continue; } } return(new DiskInstanceView(name.Value, Optional.ToList(encryptionSettings), Optional.ToList(statuses))); }
internal static RestorePointSourceVmosDisk DeserializeRestorePointSourceVmosDisk(JsonElement element) { Optional <OperatingSystemType> osType = default; Optional <DiskEncryptionSettings> encryptionSettings = default; Optional <string> name = default; Optional <CachingTypes> caching = default; Optional <int> diskSizeGB = default; Optional <ManagedDiskParameters> managedDisk = default; Optional <WritableSubResource> diskRestorePoint = default; foreach (var property in element.EnumerateObject()) { if (property.NameEquals("osType")) { if (property.Value.ValueKind == JsonValueKind.Null) { property.ThrowNonNullablePropertyIsNull(); continue; } osType = new OperatingSystemType(property.Value.GetString()); continue; } if (property.NameEquals("encryptionSettings")) { if (property.Value.ValueKind == JsonValueKind.Null) { property.ThrowNonNullablePropertyIsNull(); continue; } encryptionSettings = DiskEncryptionSettings.DeserializeDiskEncryptionSettings(property.Value); continue; } if (property.NameEquals("name")) { name = property.Value.GetString(); continue; } if (property.NameEquals("caching")) { if (property.Value.ValueKind == JsonValueKind.Null) { property.ThrowNonNullablePropertyIsNull(); continue; } caching = property.Value.GetString().ToCachingTypes(); continue; } if (property.NameEquals("diskSizeGB")) { if (property.Value.ValueKind == JsonValueKind.Null) { property.ThrowNonNullablePropertyIsNull(); continue; } diskSizeGB = property.Value.GetInt32(); continue; } if (property.NameEquals("managedDisk")) { if (property.Value.ValueKind == JsonValueKind.Null) { property.ThrowNonNullablePropertyIsNull(); continue; } managedDisk = ManagedDiskParameters.DeserializeManagedDiskParameters(property.Value); continue; } if (property.NameEquals("diskRestorePoint")) { if (property.Value.ValueKind == JsonValueKind.Null) { property.ThrowNonNullablePropertyIsNull(); continue; } diskRestorePoint = JsonSerializer.Deserialize <WritableSubResource>(property.Value.ToString()); continue; } } return(new RestorePointSourceVmosDisk(Optional.ToNullable(osType), encryptionSettings.Value, name.Value, Optional.ToNullable(caching), Optional.ToNullable(diskSizeGB), managedDisk.Value, diskRestorePoint)); }
internal static OSDisk DeserializeOSDisk(JsonElement element) { Optional <OperatingSystemTypes> osType = default; Optional <DiskEncryptionSettings> encryptionSettings = default; Optional <string> name = default; Optional <VirtualHardDisk> vhd = default; Optional <VirtualHardDisk> image = default; Optional <CachingTypes> caching = default; Optional <bool> writeAcceleratorEnabled = default; Optional <DiffDiskSettings> diffDiskSettings = default; DiskCreateOptionTypes createOption = default; Optional <int> diskSizeGB = default; Optional <ManagedDiskParameters> managedDisk = default; foreach (var property in element.EnumerateObject()) { if (property.NameEquals("osType")) { if (property.Value.ValueKind == JsonValueKind.Null) { property.ThrowNonNullablePropertyIsNull(); continue; } osType = property.Value.GetString().ToOperatingSystemTypes(); continue; } if (property.NameEquals("encryptionSettings")) { if (property.Value.ValueKind == JsonValueKind.Null) { property.ThrowNonNullablePropertyIsNull(); continue; } encryptionSettings = DiskEncryptionSettings.DeserializeDiskEncryptionSettings(property.Value); continue; } if (property.NameEquals("name")) { name = property.Value.GetString(); continue; } if (property.NameEquals("vhd")) { if (property.Value.ValueKind == JsonValueKind.Null) { property.ThrowNonNullablePropertyIsNull(); continue; } vhd = VirtualHardDisk.DeserializeVirtualHardDisk(property.Value); continue; } if (property.NameEquals("image")) { if (property.Value.ValueKind == JsonValueKind.Null) { property.ThrowNonNullablePropertyIsNull(); continue; } image = VirtualHardDisk.DeserializeVirtualHardDisk(property.Value); continue; } if (property.NameEquals("caching")) { if (property.Value.ValueKind == JsonValueKind.Null) { property.ThrowNonNullablePropertyIsNull(); continue; } caching = property.Value.GetString().ToCachingTypes(); continue; } if (property.NameEquals("writeAcceleratorEnabled")) { if (property.Value.ValueKind == JsonValueKind.Null) { property.ThrowNonNullablePropertyIsNull(); continue; } writeAcceleratorEnabled = property.Value.GetBoolean(); continue; } if (property.NameEquals("diffDiskSettings")) { if (property.Value.ValueKind == JsonValueKind.Null) { property.ThrowNonNullablePropertyIsNull(); continue; } diffDiskSettings = DiffDiskSettings.DeserializeDiffDiskSettings(property.Value); continue; } if (property.NameEquals("createOption")) { createOption = new DiskCreateOptionTypes(property.Value.GetString()); continue; } if (property.NameEquals("diskSizeGB")) { if (property.Value.ValueKind == JsonValueKind.Null) { property.ThrowNonNullablePropertyIsNull(); continue; } diskSizeGB = property.Value.GetInt32(); continue; } if (property.NameEquals("managedDisk")) { if (property.Value.ValueKind == JsonValueKind.Null) { property.ThrowNonNullablePropertyIsNull(); continue; } managedDisk = ManagedDiskParameters.DeserializeManagedDiskParameters(property.Value); continue; } } return(new OSDisk(Optional.ToNullable(osType), encryptionSettings.Value, name.Value, vhd.Value, image.Value, Optional.ToNullable(caching), Optional.ToNullable(writeAcceleratorEnabled), diffDiskSettings.Value, createOption, Optional.ToNullable(diskSizeGB), managedDisk.Value)); }
internal static DiskInstanceView DeserializeDiskInstanceView(JsonElement element) { string name = default; IList <DiskEncryptionSettings> encryptionSettings = default; IList <InstanceViewStatus> statuses = default; foreach (var property in element.EnumerateObject()) { if (property.NameEquals("name")) { if (property.Value.ValueKind == JsonValueKind.Null) { continue; } name = property.Value.GetString(); continue; } if (property.NameEquals("encryptionSettings")) { if (property.Value.ValueKind == JsonValueKind.Null) { continue; } List <DiskEncryptionSettings> array = new List <DiskEncryptionSettings>(); foreach (var item in property.Value.EnumerateArray()) { if (item.ValueKind == JsonValueKind.Null) { array.Add(null); } else { array.Add(DiskEncryptionSettings.DeserializeDiskEncryptionSettings(item)); } } encryptionSettings = array; continue; } if (property.NameEquals("statuses")) { if (property.Value.ValueKind == JsonValueKind.Null) { continue; } List <InstanceViewStatus> array = new List <InstanceViewStatus>(); foreach (var item in property.Value.EnumerateArray()) { if (item.ValueKind == JsonValueKind.Null) { array.Add(null); } else { array.Add(InstanceViewStatus.DeserializeInstanceViewStatus(item)); } } statuses = array; continue; } } return(new DiskInstanceView(name, encryptionSettings, statuses)); }
internal static OSDisk DeserializeOSDisk(JsonElement element) { OperatingSystemTypes? osType = default; DiskEncryptionSettings encryptionSettings = default; string name = default; VirtualHardDisk vhd = default; VirtualHardDisk image = default; CachingTypes? caching = default; bool? writeAcceleratorEnabled = default; DiffDiskSettings diffDiskSettings = default; DiskCreateOptionTypes createOption = default; int?diskSizeGB = default; ManagedDiskParameters managedDisk = default; foreach (var property in element.EnumerateObject()) { if (property.NameEquals("osType")) { if (property.Value.ValueKind == JsonValueKind.Null) { continue; } osType = property.Value.GetString().ToOperatingSystemTypes(); continue; } if (property.NameEquals("encryptionSettings")) { if (property.Value.ValueKind == JsonValueKind.Null) { continue; } encryptionSettings = DiskEncryptionSettings.DeserializeDiskEncryptionSettings(property.Value); continue; } if (property.NameEquals("name")) { if (property.Value.ValueKind == JsonValueKind.Null) { continue; } name = property.Value.GetString(); continue; } if (property.NameEquals("vhd")) { if (property.Value.ValueKind == JsonValueKind.Null) { continue; } vhd = VirtualHardDisk.DeserializeVirtualHardDisk(property.Value); continue; } if (property.NameEquals("image")) { if (property.Value.ValueKind == JsonValueKind.Null) { continue; } image = VirtualHardDisk.DeserializeVirtualHardDisk(property.Value); continue; } if (property.NameEquals("caching")) { if (property.Value.ValueKind == JsonValueKind.Null) { continue; } caching = property.Value.GetString().ToCachingTypes(); continue; } if (property.NameEquals("writeAcceleratorEnabled")) { if (property.Value.ValueKind == JsonValueKind.Null) { continue; } writeAcceleratorEnabled = property.Value.GetBoolean(); continue; } if (property.NameEquals("diffDiskSettings")) { if (property.Value.ValueKind == JsonValueKind.Null) { continue; } diffDiskSettings = DiffDiskSettings.DeserializeDiffDiskSettings(property.Value); continue; } if (property.NameEquals("createOption")) { createOption = new DiskCreateOptionTypes(property.Value.GetString()); continue; } if (property.NameEquals("diskSizeGB")) { if (property.Value.ValueKind == JsonValueKind.Null) { continue; } diskSizeGB = property.Value.GetInt32(); continue; } if (property.NameEquals("managedDisk")) { if (property.Value.ValueKind == JsonValueKind.Null) { continue; } managedDisk = ManagedDiskParameters.DeserializeManagedDiskParameters(property.Value); continue; } } return(new OSDisk(osType, encryptionSettings, name, vhd, image, caching, writeAcceleratorEnabled, diffDiskSettings, createOption, diskSizeGB, managedDisk)); }