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

package com.azure.resourcemanager.batchai.models;

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

/** Azure File Share mounting configuration. */
@Fluent
public final class AzureFileShareReference {
    @JsonIgnore private final ClientLogger logger = new ClientLogger(AzureFileShareReference.class);

    /*
     * Name of the Azure storage account.
     */
    @JsonProperty(value = "accountName", required = true)
    private String accountName;

    /*
     * URL to access the Azure File.
     */
    @JsonProperty(value = "azureFileUrl", required = true)
    private String azureFileUrl;

    /*
     * Information about the Azure storage credentials.
     */
    @JsonProperty(value = "credentials", required = true)
    private AzureStorageCredentialsInfo credentials;

    /*
     * The relative path on the compute node where the Azure File share will be
     * mounted. Note that all cluster level file shares will be mounted under
     * $AZ_BATCHAI_MOUNT_ROOT location and all job level file shares will be
     * mounted under $AZ_BATCHAI_JOB_MOUNT_ROOT.
     */
    @JsonProperty(value = "relativeMountPath", required = true)
    private String relativeMountPath;

    /*
     * File mode for files on the mounted file share. Default value: 0777.
     */
    @JsonProperty(value = "fileMode")
    private String fileMode;

    /*
     * File mode for directories on the mounted file share. Default value:
     * 0777.
     */
    @JsonProperty(value = "directoryMode")
    private String directoryMode;

    /**
     * Get the accountName property: Name of the Azure storage account.
     *
     * @return the accountName value.
     */
    public String accountName() {
        return this.accountName;
    }

    /**
     * Set the accountName property: Name of the Azure storage account.
     *
     * @param accountName the accountName value to set.
     * @return the AzureFileShareReference object itself.
     */
    public AzureFileShareReference withAccountName(String accountName) {
        this.accountName = accountName;
        return this;
    }

    /**
     * Get the azureFileUrl property: URL to access the Azure File.
     *
     * @return the azureFileUrl value.
     */
    public String azureFileUrl() {
        return this.azureFileUrl;
    }

    /**
     * Set the azureFileUrl property: URL to access the Azure File.
     *
     * @param azureFileUrl the azureFileUrl value to set.
     * @return the AzureFileShareReference object itself.
     */
    public AzureFileShareReference withAzureFileUrl(String azureFileUrl) {
        this.azureFileUrl = azureFileUrl;
        return this;
    }

    /**
     * Get the credentials property: Information about the Azure storage credentials.
     *
     * @return the credentials value.
     */
    public AzureStorageCredentialsInfo credentials() {
        return this.credentials;
    }

    /**
     * Set the credentials property: Information about the Azure storage credentials.
     *
     * @param credentials the credentials value to set.
     * @return the AzureFileShareReference object itself.
     */
    public AzureFileShareReference withCredentials(AzureStorageCredentialsInfo credentials) {
        this.credentials = credentials;
        return this;
    }

    /**
     * Get the relativeMountPath property: The relative path on the compute node where the Azure File share will be
     * mounted. Note that all cluster level file shares will be mounted under $AZ_BATCHAI_MOUNT_ROOT location and all
     * job level file shares will be mounted under $AZ_BATCHAI_JOB_MOUNT_ROOT.
     *
     * @return the relativeMountPath value.
     */
    public String relativeMountPath() {
        return this.relativeMountPath;
    }

    /**
     * Set the relativeMountPath property: The relative path on the compute node where the Azure File share will be
     * mounted. Note that all cluster level file shares will be mounted under $AZ_BATCHAI_MOUNT_ROOT location and all
     * job level file shares will be mounted under $AZ_BATCHAI_JOB_MOUNT_ROOT.
     *
     * @param relativeMountPath the relativeMountPath value to set.
     * @return the AzureFileShareReference object itself.
     */
    public AzureFileShareReference withRelativeMountPath(String relativeMountPath) {
        this.relativeMountPath = relativeMountPath;
        return this;
    }

    /**
     * Get the fileMode property: File mode for files on the mounted file share. Default value: 0777.
     *
     * @return the fileMode value.
     */
    public String fileMode() {
        return this.fileMode;
    }

    /**
     * Set the fileMode property: File mode for files on the mounted file share. Default value: 0777.
     *
     * @param fileMode the fileMode value to set.
     * @return the AzureFileShareReference object itself.
     */
    public AzureFileShareReference withFileMode(String fileMode) {
        this.fileMode = fileMode;
        return this;
    }

    /**
     * Get the directoryMode property: File mode for directories on the mounted file share. Default value: 0777.
     *
     * @return the directoryMode value.
     */
    public String directoryMode() {
        return this.directoryMode;
    }

    /**
     * Set the directoryMode property: File mode for directories on the mounted file share. Default value: 0777.
     *
     * @param directoryMode the directoryMode value to set.
     * @return the AzureFileShareReference object itself.
     */
    public AzureFileShareReference withDirectoryMode(String directoryMode) {
        this.directoryMode = directoryMode;
        return this;
    }

    /**
     * Validates the instance.
     *
     * @throws IllegalArgumentException thrown if the instance is not valid.
     */
    public void validate() {
        if (accountName() == null) {
            throw logger
                .logExceptionAsError(
                    new IllegalArgumentException(
                        "Missing required property accountName in model AzureFileShareReference"));
        }
        if (azureFileUrl() == null) {
            throw logger
                .logExceptionAsError(
                    new IllegalArgumentException(
                        "Missing required property azureFileUrl in model AzureFileShareReference"));
        }
        if (credentials() == null) {
            throw logger
                .logExceptionAsError(
                    new IllegalArgumentException(
                        "Missing required property credentials in model AzureFileShareReference"));
        } else {
            credentials().validate();
        }
        if (relativeMountPath() == null) {
            throw logger
                .logExceptionAsError(
                    new IllegalArgumentException(
                        "Missing required property relativeMountPath in model AzureFileShareReference"));
        }
    }
}
