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

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

import com.azure.core.annotation.Fluent;
import com.azure.core.util.logging.ClientLogger;
import com.azure.resourcemanager.storagepool.models.Acl;
import com.azure.resourcemanager.storagepool.models.IscsiLun;
import com.azure.resourcemanager.storagepool.models.IscsiTargetAclMode;
import com.azure.resourcemanager.storagepool.models.OperationalStatus;
import com.azure.resourcemanager.storagepool.models.ProvisioningStates;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.List;

/** Response properties for iSCSI Target operations. */
@Fluent
public final class IscsiTargetProperties {
    /*
     * Mode for Target connectivity.
     */
    @JsonProperty(value = "aclMode", required = true)
    private IscsiTargetAclMode aclMode;

    /*
     * Access Control List (ACL) for an iSCSI Target; defines LUN masking policy
     */
    @JsonProperty(value = "staticAcls")
    private List<Acl> staticAcls;

    /*
     * List of LUNs to be exposed through iSCSI Target.
     */
    @JsonProperty(value = "luns")
    private List<IscsiLun> luns;

    /*
     * iSCSI Target IQN (iSCSI Qualified Name); example: "iqn.2005-03.org.iscsi:server".
     */
    @JsonProperty(value = "targetIqn", required = true)
    private String targetIqn;

    /*
     * State of the operation on the resource.
     */
    @JsonProperty(value = "provisioningState", required = true, access = JsonProperty.Access.WRITE_ONLY)
    private ProvisioningStates provisioningState;

    /*
     * Operational status of the iSCSI Target.
     */
    @JsonProperty(value = "status", required = true)
    private OperationalStatus status;

    /*
     * List of private IPv4 addresses to connect to the iSCSI Target.
     */
    @JsonProperty(value = "endpoints")
    private List<String> endpoints;

    /*
     * The port used by iSCSI Target portal group.
     */
    @JsonProperty(value = "port")
    private Integer port;

    /*
     * List of identifiers for active sessions on the iSCSI target
     */
    @JsonProperty(value = "sessions", access = JsonProperty.Access.WRITE_ONLY)
    private List<String> sessions;

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

    /**
     * Get the aclMode property: Mode for Target connectivity.
     *
     * @return the aclMode value.
     */
    public IscsiTargetAclMode aclMode() {
        return this.aclMode;
    }

    /**
     * Set the aclMode property: Mode for Target connectivity.
     *
     * @param aclMode the aclMode value to set.
     * @return the IscsiTargetProperties object itself.
     */
    public IscsiTargetProperties withAclMode(IscsiTargetAclMode aclMode) {
        this.aclMode = aclMode;
        return this;
    }

    /**
     * Get the staticAcls property: Access Control List (ACL) for an iSCSI Target; defines LUN masking policy.
     *
     * @return the staticAcls value.
     */
    public List<Acl> staticAcls() {
        return this.staticAcls;
    }

    /**
     * Set the staticAcls property: Access Control List (ACL) for an iSCSI Target; defines LUN masking policy.
     *
     * @param staticAcls the staticAcls value to set.
     * @return the IscsiTargetProperties object itself.
     */
    public IscsiTargetProperties withStaticAcls(List<Acl> staticAcls) {
        this.staticAcls = staticAcls;
        return this;
    }

    /**
     * Get the luns property: List of LUNs to be exposed through iSCSI Target.
     *
     * @return the luns value.
     */
    public List<IscsiLun> luns() {
        return this.luns;
    }

    /**
     * Set the luns property: List of LUNs to be exposed through iSCSI Target.
     *
     * @param luns the luns value to set.
     * @return the IscsiTargetProperties object itself.
     */
    public IscsiTargetProperties withLuns(List<IscsiLun> luns) {
        this.luns = luns;
        return this;
    }

    /**
     * Get the targetIqn property: iSCSI Target IQN (iSCSI Qualified Name); example: "iqn.2005-03.org.iscsi:server".
     *
     * @return the targetIqn value.
     */
    public String targetIqn() {
        return this.targetIqn;
    }

    /**
     * Set the targetIqn property: iSCSI Target IQN (iSCSI Qualified Name); example: "iqn.2005-03.org.iscsi:server".
     *
     * @param targetIqn the targetIqn value to set.
     * @return the IscsiTargetProperties object itself.
     */
    public IscsiTargetProperties withTargetIqn(String targetIqn) {
        this.targetIqn = targetIqn;
        return this;
    }

    /**
     * Get the provisioningState property: State of the operation on the resource.
     *
     * @return the provisioningState value.
     */
    public ProvisioningStates provisioningState() {
        return this.provisioningState;
    }

    /**
     * Get the status property: Operational status of the iSCSI Target.
     *
     * @return the status value.
     */
    public OperationalStatus status() {
        return this.status;
    }

    /**
     * Set the status property: Operational status of the iSCSI Target.
     *
     * @param status the status value to set.
     * @return the IscsiTargetProperties object itself.
     */
    public IscsiTargetProperties withStatus(OperationalStatus status) {
        this.status = status;
        return this;
    }

    /**
     * Get the endpoints property: List of private IPv4 addresses to connect to the iSCSI Target.
     *
     * @return the endpoints value.
     */
    public List<String> endpoints() {
        return this.endpoints;
    }

    /**
     * Set the endpoints property: List of private IPv4 addresses to connect to the iSCSI Target.
     *
     * @param endpoints the endpoints value to set.
     * @return the IscsiTargetProperties object itself.
     */
    public IscsiTargetProperties withEndpoints(List<String> endpoints) {
        this.endpoints = endpoints;
        return this;
    }

    /**
     * Get the port property: The port used by iSCSI Target portal group.
     *
     * @return the port value.
     */
    public Integer port() {
        return this.port;
    }

    /**
     * Set the port property: The port used by iSCSI Target portal group.
     *
     * @param port the port value to set.
     * @return the IscsiTargetProperties object itself.
     */
    public IscsiTargetProperties withPort(Integer port) {
        this.port = port;
        return this;
    }

    /**
     * Get the sessions property: List of identifiers for active sessions on the iSCSI target.
     *
     * @return the sessions value.
     */
    public List<String> sessions() {
        return this.sessions;
    }

    /**
     * Validates the instance.
     *
     * @throws IllegalArgumentException thrown if the instance is not valid.
     */
    public void validate() {
        if (aclMode() == null) {
            throw LOGGER
                .logExceptionAsError(
                    new IllegalArgumentException("Missing required property aclMode in model IscsiTargetProperties"));
        }
        if (staticAcls() != null) {
            staticAcls().forEach(e -> e.validate());
        }
        if (luns() != null) {
            luns().forEach(e -> e.validate());
        }
        if (targetIqn() == null) {
            throw LOGGER
                .logExceptionAsError(
                    new IllegalArgumentException("Missing required property targetIqn in model IscsiTargetProperties"));
        }
        if (status() == null) {
            throw LOGGER
                .logExceptionAsError(
                    new IllegalArgumentException("Missing required property status in model IscsiTargetProperties"));
        }
    }

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