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

package com.azure.resourcemanager.logic.models;

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

/** The reference to the key vault key. */
@Fluent
public final class KeyVaultKeyReference {
    /*
     * The key vault reference.
     */
    @JsonProperty(value = "keyVault", required = true)
    private KeyVaultKeyReferenceKeyVault keyVault;

    /*
     * The private key name in key vault.
     */
    @JsonProperty(value = "keyName", required = true)
    private String keyName;

    /*
     * The private key version in key vault.
     */
    @JsonProperty(value = "keyVersion")
    private String keyVersion;

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

    /**
     * Get the keyVault property: The key vault reference.
     *
     * @return the keyVault value.
     */
    public KeyVaultKeyReferenceKeyVault keyVault() {
        return this.keyVault;
    }

    /**
     * Set the keyVault property: The key vault reference.
     *
     * @param keyVault the keyVault value to set.
     * @return the KeyVaultKeyReference object itself.
     */
    public KeyVaultKeyReference withKeyVault(KeyVaultKeyReferenceKeyVault keyVault) {
        this.keyVault = keyVault;
        return this;
    }

    /**
     * Get the keyName property: The private key name in key vault.
     *
     * @return the keyName value.
     */
    public String keyName() {
        return this.keyName;
    }

    /**
     * Set the keyName property: The private key name in key vault.
     *
     * @param keyName the keyName value to set.
     * @return the KeyVaultKeyReference object itself.
     */
    public KeyVaultKeyReference withKeyName(String keyName) {
        this.keyName = keyName;
        return this;
    }

    /**
     * Get the keyVersion property: The private key version in key vault.
     *
     * @return the keyVersion value.
     */
    public String keyVersion() {
        return this.keyVersion;
    }

    /**
     * Set the keyVersion property: The private key version in key vault.
     *
     * @param keyVersion the keyVersion value to set.
     * @return the KeyVaultKeyReference object itself.
     */
    public KeyVaultKeyReference withKeyVersion(String keyVersion) {
        this.keyVersion = keyVersion;
        return this;
    }

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

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