// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// Code generated by Microsoft (R) AutoRest Code Generator.

package com.azure.resourcemanager.databricks.models;

import com.azure.core.annotation.Fluent;
import com.azure.core.util.logging.ClientLogger;
import com.fasterxml.jackson.annotation.JsonProperty;

/** The object that contains details of encryption used on the workspace. */
@Fluent
public final class ManagedDiskEncryption {
    /*
     * The encryption keySource (provider). Possible values (case-insensitive):  Microsoft.Keyvault
     */
    @JsonProperty(value = "keySource", required = true)
    private EncryptionKeySource keySource;

    /*
     * Key Vault input properties for encryption.
     */
    @JsonProperty(value = "keyVaultProperties", required = true)
    private ManagedDiskEncryptionKeyVaultProperties keyVaultProperties;

    /*
     * Indicate whether the latest key version should be automatically used for Managed Disk Encryption.
     */
    @JsonProperty(value = "rotationToLatestKeyVersionEnabled")
    private Boolean rotationToLatestKeyVersionEnabled;

    /** Creates an instance of ManagedDiskEncryption class. */
    public ManagedDiskEncryption() {
    }

    /**
     * Get the keySource property: The encryption keySource (provider). Possible values (case-insensitive):
     * Microsoft.Keyvault.
     *
     * @return the keySource value.
     */
    public EncryptionKeySource keySource() {
        return this.keySource;
    }

    /**
     * Set the keySource property: The encryption keySource (provider). Possible values (case-insensitive):
     * Microsoft.Keyvault.
     *
     * @param keySource the keySource value to set.
     * @return the ManagedDiskEncryption object itself.
     */
    public ManagedDiskEncryption withKeySource(EncryptionKeySource keySource) {
        this.keySource = keySource;
        return this;
    }

    /**
     * Get the keyVaultProperties property: Key Vault input properties for encryption.
     *
     * @return the keyVaultProperties value.
     */
    public ManagedDiskEncryptionKeyVaultProperties keyVaultProperties() {
        return this.keyVaultProperties;
    }

    /**
     * Set the keyVaultProperties property: Key Vault input properties for encryption.
     *
     * @param keyVaultProperties the keyVaultProperties value to set.
     * @return the ManagedDiskEncryption object itself.
     */
    public ManagedDiskEncryption withKeyVaultProperties(ManagedDiskEncryptionKeyVaultProperties keyVaultProperties) {
        this.keyVaultProperties = keyVaultProperties;
        return this;
    }

    /**
     * Get the rotationToLatestKeyVersionEnabled property: Indicate whether the latest key version should be
     * automatically used for Managed Disk Encryption.
     *
     * @return the rotationToLatestKeyVersionEnabled value.
     */
    public Boolean rotationToLatestKeyVersionEnabled() {
        return this.rotationToLatestKeyVersionEnabled;
    }

    /**
     * Set the rotationToLatestKeyVersionEnabled property: Indicate whether the latest key version should be
     * automatically used for Managed Disk Encryption.
     *
     * @param rotationToLatestKeyVersionEnabled the rotationToLatestKeyVersionEnabled value to set.
     * @return the ManagedDiskEncryption object itself.
     */
    public ManagedDiskEncryption withRotationToLatestKeyVersionEnabled(Boolean rotationToLatestKeyVersionEnabled) {
        this.rotationToLatestKeyVersionEnabled = rotationToLatestKeyVersionEnabled;
        return this;
    }

    /**
     * Validates the instance.
     *
     * @throws IllegalArgumentException thrown if the instance is not valid.
     */
    public void validate() {
        if (keySource() == null) {
            throw LOGGER
                .logExceptionAsError(
                    new IllegalArgumentException("Missing required property keySource in model ManagedDiskEncryption"));
        }
        if (keyVaultProperties() == null) {
            throw LOGGER
                .logExceptionAsError(
                    new IllegalArgumentException(
                        "Missing required property keyVaultProperties in model ManagedDiskEncryption"));
        } else {
            keyVaultProperties().validate();
        }
    }

    private static final ClientLogger LOGGER = new ClientLogger(ManagedDiskEncryption.class);
}
