Esempio n. 1
0
        internal static DiskEncryptionSettings DeserializeDiskEncryptionSettings(JsonElement element)
        {
            Optional <KeyVaultSecretReference> diskEncryptionKey = default;
            Optional <KeyVaultKeyReference>    keyEncryptionKey  = default;
            Optional <bool> enabled = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("diskEncryptionKey"))
                {
                    diskEncryptionKey = KeyVaultSecretReference.DeserializeKeyVaultSecretReference(property.Value);
                    continue;
                }
                if (property.NameEquals("keyEncryptionKey"))
                {
                    keyEncryptionKey = KeyVaultKeyReference.DeserializeKeyVaultKeyReference(property.Value);
                    continue;
                }
                if (property.NameEquals("enabled"))
                {
                    enabled = property.Value.GetBoolean();
                    continue;
                }
            }
            return(new DiskEncryptionSettings(diskEncryptionKey.Value, keyEncryptionKey.Value, Optional.ToNullable(enabled)));
        }
Esempio n. 2
0
        internal static DiskEncryptionSettings DeserializeDiskEncryptionSettings(JsonElement element)
        {
            KeyVaultSecretReference diskEncryptionKey = default;
            KeyVaultKeyReference    keyEncryptionKey  = default;
            bool?enabled = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("diskEncryptionKey"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    diskEncryptionKey = KeyVaultSecretReference.DeserializeKeyVaultSecretReference(property.Value);
                    continue;
                }
                if (property.NameEquals("keyEncryptionKey"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    keyEncryptionKey = KeyVaultKeyReference.DeserializeKeyVaultKeyReference(property.Value);
                    continue;
                }
                if (property.NameEquals("enabled"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    enabled = property.Value.GetBoolean();
                    continue;
                }
            }
            return(new DiskEncryptionSettings(diskEncryptionKey, keyEncryptionKey, enabled));
        }