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

package com.azure.resourcemanager.databoxedge.fluent.models;

import com.azure.core.annotation.Fluent;
import com.azure.core.util.logging.ClientLogger;
import com.azure.resourcemanager.databoxedge.models.AzureContainerInfo;
import com.azure.resourcemanager.databoxedge.models.ClientAccessRight;
import com.azure.resourcemanager.databoxedge.models.DataPolicy;
import com.azure.resourcemanager.databoxedge.models.MonitoringStatus;
import com.azure.resourcemanager.databoxedge.models.MountPointMap;
import com.azure.resourcemanager.databoxedge.models.RefreshDetails;
import com.azure.resourcemanager.databoxedge.models.ShareAccessProtocol;
import com.azure.resourcemanager.databoxedge.models.ShareStatus;
import com.azure.resourcemanager.databoxedge.models.UserAccessRight;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.List;

/** The share properties. */
@Fluent
public final class ShareProperties {
    /*
     * Description for the share.
     */
    @JsonProperty(value = "description")
    private String description;

    /*
     * Current status of the share.
     */
    @JsonProperty(value = "shareStatus", required = true)
    private ShareStatus shareStatus;

    /*
     * Current monitoring status of the share.
     */
    @JsonProperty(value = "monitoringStatus", required = true)
    private MonitoringStatus monitoringStatus;

    /*
     * Azure container mapping for the share.
     */
    @JsonProperty(value = "azureContainerInfo")
    private AzureContainerInfo azureContainerInfo;

    /*
     * Access protocol to be used by the share.
     */
    @JsonProperty(value = "accessProtocol", required = true)
    private ShareAccessProtocol accessProtocol;

    /*
     * Mapping of users and corresponding access rights on the share (required for SMB protocol).
     */
    @JsonProperty(value = "userAccessRights")
    private List<UserAccessRight> userAccessRights;

    /*
     * List of IP addresses and corresponding access rights on the share(required for NFS protocol).
     */
    @JsonProperty(value = "clientAccessRights")
    private List<ClientAccessRight> clientAccessRights;

    /*
     * Details of the refresh job on this share.
     */
    @JsonProperty(value = "refreshDetails")
    private RefreshDetails refreshDetails;

    /*
     * Share mount point to the role.
     */
    @JsonProperty(value = "shareMappings", access = JsonProperty.Access.WRITE_ONLY)
    private List<MountPointMap> shareMappings;

    /*
     * Data policy of the share.
     */
    @JsonProperty(value = "dataPolicy")
    private DataPolicy dataPolicy;

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

    /**
     * Get the description property: Description for the share.
     *
     * @return the description value.
     */
    public String description() {
        return this.description;
    }

    /**
     * Set the description property: Description for the share.
     *
     * @param description the description value to set.
     * @return the ShareProperties object itself.
     */
    public ShareProperties withDescription(String description) {
        this.description = description;
        return this;
    }

    /**
     * Get the shareStatus property: Current status of the share.
     *
     * @return the shareStatus value.
     */
    public ShareStatus shareStatus() {
        return this.shareStatus;
    }

    /**
     * Set the shareStatus property: Current status of the share.
     *
     * @param shareStatus the shareStatus value to set.
     * @return the ShareProperties object itself.
     */
    public ShareProperties withShareStatus(ShareStatus shareStatus) {
        this.shareStatus = shareStatus;
        return this;
    }

    /**
     * Get the monitoringStatus property: Current monitoring status of the share.
     *
     * @return the monitoringStatus value.
     */
    public MonitoringStatus monitoringStatus() {
        return this.monitoringStatus;
    }

    /**
     * Set the monitoringStatus property: Current monitoring status of the share.
     *
     * @param monitoringStatus the monitoringStatus value to set.
     * @return the ShareProperties object itself.
     */
    public ShareProperties withMonitoringStatus(MonitoringStatus monitoringStatus) {
        this.monitoringStatus = monitoringStatus;
        return this;
    }

    /**
     * Get the azureContainerInfo property: Azure container mapping for the share.
     *
     * @return the azureContainerInfo value.
     */
    public AzureContainerInfo azureContainerInfo() {
        return this.azureContainerInfo;
    }

    /**
     * Set the azureContainerInfo property: Azure container mapping for the share.
     *
     * @param azureContainerInfo the azureContainerInfo value to set.
     * @return the ShareProperties object itself.
     */
    public ShareProperties withAzureContainerInfo(AzureContainerInfo azureContainerInfo) {
        this.azureContainerInfo = azureContainerInfo;
        return this;
    }

    /**
     * Get the accessProtocol property: Access protocol to be used by the share.
     *
     * @return the accessProtocol value.
     */
    public ShareAccessProtocol accessProtocol() {
        return this.accessProtocol;
    }

    /**
     * Set the accessProtocol property: Access protocol to be used by the share.
     *
     * @param accessProtocol the accessProtocol value to set.
     * @return the ShareProperties object itself.
     */
    public ShareProperties withAccessProtocol(ShareAccessProtocol accessProtocol) {
        this.accessProtocol = accessProtocol;
        return this;
    }

    /**
     * Get the userAccessRights property: Mapping of users and corresponding access rights on the share (required for
     * SMB protocol).
     *
     * @return the userAccessRights value.
     */
    public List<UserAccessRight> userAccessRights() {
        return this.userAccessRights;
    }

    /**
     * Set the userAccessRights property: Mapping of users and corresponding access rights on the share (required for
     * SMB protocol).
     *
     * @param userAccessRights the userAccessRights value to set.
     * @return the ShareProperties object itself.
     */
    public ShareProperties withUserAccessRights(List<UserAccessRight> userAccessRights) {
        this.userAccessRights = userAccessRights;
        return this;
    }

    /**
     * Get the clientAccessRights property: List of IP addresses and corresponding access rights on the share(required
     * for NFS protocol).
     *
     * @return the clientAccessRights value.
     */
    public List<ClientAccessRight> clientAccessRights() {
        return this.clientAccessRights;
    }

    /**
     * Set the clientAccessRights property: List of IP addresses and corresponding access rights on the share(required
     * for NFS protocol).
     *
     * @param clientAccessRights the clientAccessRights value to set.
     * @return the ShareProperties object itself.
     */
    public ShareProperties withClientAccessRights(List<ClientAccessRight> clientAccessRights) {
        this.clientAccessRights = clientAccessRights;
        return this;
    }

    /**
     * Get the refreshDetails property: Details of the refresh job on this share.
     *
     * @return the refreshDetails value.
     */
    public RefreshDetails refreshDetails() {
        return this.refreshDetails;
    }

    /**
     * Set the refreshDetails property: Details of the refresh job on this share.
     *
     * @param refreshDetails the refreshDetails value to set.
     * @return the ShareProperties object itself.
     */
    public ShareProperties withRefreshDetails(RefreshDetails refreshDetails) {
        this.refreshDetails = refreshDetails;
        return this;
    }

    /**
     * Get the shareMappings property: Share mount point to the role.
     *
     * @return the shareMappings value.
     */
    public List<MountPointMap> shareMappings() {
        return this.shareMappings;
    }

    /**
     * Get the dataPolicy property: Data policy of the share.
     *
     * @return the dataPolicy value.
     */
    public DataPolicy dataPolicy() {
        return this.dataPolicy;
    }

    /**
     * Set the dataPolicy property: Data policy of the share.
     *
     * @param dataPolicy the dataPolicy value to set.
     * @return the ShareProperties object itself.
     */
    public ShareProperties withDataPolicy(DataPolicy dataPolicy) {
        this.dataPolicy = dataPolicy;
        return this;
    }

    /**
     * Validates the instance.
     *
     * @throws IllegalArgumentException thrown if the instance is not valid.
     */
    public void validate() {
        if (shareStatus() == null) {
            throw LOGGER
                .logExceptionAsError(
                    new IllegalArgumentException("Missing required property shareStatus in model ShareProperties"));
        }
        if (monitoringStatus() == null) {
            throw LOGGER
                .logExceptionAsError(
                    new IllegalArgumentException(
                        "Missing required property monitoringStatus in model ShareProperties"));
        }
        if (azureContainerInfo() != null) {
            azureContainerInfo().validate();
        }
        if (accessProtocol() == null) {
            throw LOGGER
                .logExceptionAsError(
                    new IllegalArgumentException("Missing required property accessProtocol in model ShareProperties"));
        }
        if (userAccessRights() != null) {
            userAccessRights().forEach(e -> e.validate());
        }
        if (clientAccessRights() != null) {
            clientAccessRights().forEach(e -> e.validate());
        }
        if (refreshDetails() != null) {
            refreshDetails().validate();
        }
        if (shareMappings() != null) {
            shareMappings().forEach(e -> e.validate());
        }
    }

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