// 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;

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

    /*
     * Resource ID of the existing File Server to be mounted.
     */
    @JsonProperty(value = "fileServer", required = true)
    private ResourceId fileServer;

    /*
     * File Server directory that needs to be mounted. If this property is not
     * specified, the entire File Server will be mounted.
     */
    @JsonProperty(value = "sourceDirectory")
    private String sourceDirectory;

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

    /*
     * Mount options to be passed to mount command.
     */
    @JsonProperty(value = "mountOptions")
    private String mountOptions;

    /**
     * Get the fileServer property: Resource ID of the existing File Server to be mounted.
     *
     * @return the fileServer value.
     */
    public ResourceId fileServer() {
        return this.fileServer;
    }

    /**
     * Set the fileServer property: Resource ID of the existing File Server to be mounted.
     *
     * @param fileServer the fileServer value to set.
     * @return the FileServerReference object itself.
     */
    public FileServerReference withFileServer(ResourceId fileServer) {
        this.fileServer = fileServer;
        return this;
    }

    /**
     * Get the sourceDirectory property: File Server directory that needs to be mounted. If this property is not
     * specified, the entire File Server will be mounted.
     *
     * @return the sourceDirectory value.
     */
    public String sourceDirectory() {
        return this.sourceDirectory;
    }

    /**
     * Set the sourceDirectory property: File Server directory that needs to be mounted. If this property is not
     * specified, the entire File Server will be mounted.
     *
     * @param sourceDirectory the sourceDirectory value to set.
     * @return the FileServerReference object itself.
     */
    public FileServerReference withSourceDirectory(String sourceDirectory) {
        this.sourceDirectory = sourceDirectory;
        return this;
    }

    /**
     * Get the relativeMountPath property: The relative path on the compute node where the File Server will be mounted.
     * Note that all cluster level file servers will be mounted under $AZ_BATCHAI_MOUNT_ROOT location and all job level
     * file servers 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 File Server will be mounted.
     * Note that all cluster level file servers will be mounted under $AZ_BATCHAI_MOUNT_ROOT location and all job level
     * file servers will be mounted under $AZ_BATCHAI_JOB_MOUNT_ROOT.
     *
     * @param relativeMountPath the relativeMountPath value to set.
     * @return the FileServerReference object itself.
     */
    public FileServerReference withRelativeMountPath(String relativeMountPath) {
        this.relativeMountPath = relativeMountPath;
        return this;
    }

    /**
     * Get the mountOptions property: Mount options to be passed to mount command.
     *
     * @return the mountOptions value.
     */
    public String mountOptions() {
        return this.mountOptions;
    }

    /**
     * Set the mountOptions property: Mount options to be passed to mount command.
     *
     * @param mountOptions the mountOptions value to set.
     * @return the FileServerReference object itself.
     */
    public FileServerReference withMountOptions(String mountOptions) {
        this.mountOptions = mountOptions;
        return this;
    }

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