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

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

import com.azure.core.annotation.Fluent;
import com.azure.core.util.logging.ClientLogger;
import com.azure.resourcemanager.networkcloud.models.ClusterAvailableUpgradeVersion;
import com.azure.resourcemanager.networkcloud.models.ClusterCapacity;
import com.azure.resourcemanager.networkcloud.models.ClusterConnectionStatus;
import com.azure.resourcemanager.networkcloud.models.ClusterDetailedStatus;
import com.azure.resourcemanager.networkcloud.models.ClusterManagerConnectionStatus;
import com.azure.resourcemanager.networkcloud.models.ClusterProvisioningState;
import com.azure.resourcemanager.networkcloud.models.ClusterType;
import com.azure.resourcemanager.networkcloud.models.ExtendedLocation;
import com.azure.resourcemanager.networkcloud.models.ManagedResourceGroupConfiguration;
import com.azure.resourcemanager.networkcloud.models.RackDefinition;
import com.azure.resourcemanager.networkcloud.models.ServicePrincipalInformation;
import com.azure.resourcemanager.networkcloud.models.ValidationThreshold;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.List;

/** ClusterProperties represents the properties of a cluster. */
@Fluent
public final class ClusterProperties {
    /*
     * RackDefinition represents details regarding the rack.
     *
     * The rack definition that is intended to reflect only a single rack in a single rack cluster, or an aggregator
     * rack in a multi-rack cluster.
     */
    @JsonProperty(value = "aggregatorOrSingleRackDefinition", required = true)
    private RackDefinition aggregatorOrSingleRackDefinition;

    /*
     * The resource ID of the Log Analytics Workspace that will be used for storing relevant logs.
     */
    @JsonProperty(value = "analyticsWorkspaceId")
    private String analyticsWorkspaceId;

    /*
     * The list of cluster runtime version upgrades available for this cluster.
     */
    @JsonProperty(value = "availableUpgradeVersions", access = JsonProperty.Access.WRITE_ONLY)
    private List<ClusterAvailableUpgradeVersion> availableUpgradeVersions;

    /*
     * ClusterCapacity represents various details regarding compute capacity.
     *
     * The capacity supported by this cluster.
     */
    @JsonProperty(value = "clusterCapacity", access = JsonProperty.Access.WRITE_ONLY)
    private ClusterCapacity clusterCapacity;

    /*
     * The latest heartbeat status between the cluster manager and the cluster.
     */
    @JsonProperty(value = "clusterConnectionStatus", access = JsonProperty.Access.WRITE_ONLY)
    private ClusterConnectionStatus clusterConnectionStatus;

    /*
     * ExtendedLocation represents the Azure custom location where the resource will be created.
     *
     * The extended location (custom location) that represents the cluster's control plane location. This extended
     * location is used to route the requests of child objects of the cluster that are handled by the platform
     * operator.
     */
    @JsonProperty(value = "clusterExtendedLocation", access = JsonProperty.Access.WRITE_ONLY)
    private ExtendedLocation clusterExtendedLocation;

    /*
     * The customer-provided location information to identify where the cluster resides.
     */
    @JsonProperty(value = "clusterLocation")
    private String clusterLocation;

    /*
     * The latest connectivity status between cluster manager and the cluster.
     */
    @JsonProperty(value = "clusterManagerConnectionStatus", access = JsonProperty.Access.WRITE_ONLY)
    private ClusterManagerConnectionStatus clusterManagerConnectionStatus;

    /*
     * The resource ID of the cluster manager that manages this cluster. This is set by the Cluster Manager when the
     * cluster is created.
     */
    @JsonProperty(value = "clusterManagerId", access = JsonProperty.Access.WRITE_ONLY)
    private String clusterManagerId;

    /*
     * ServicePrincipalInformation represents the details of the service principal to be used by the cluster during Arc
     * Appliance installation.
     *
     * The service principal to be used by the cluster during Arc Appliance installation.
     */
    @JsonProperty(value = "clusterServicePrincipal")
    private ServicePrincipalInformation clusterServicePrincipal;

    /*
     * The type of rack configuration for the cluster.
     */
    @JsonProperty(value = "clusterType", required = true)
    private ClusterType clusterType;

    /*
     * The current runtime version of the cluster.
     */
    @JsonProperty(value = "clusterVersion", required = true)
    private String clusterVersion;

    /*
     * ValidationThreshold indicates allowed machine and node hardware and deployment failures.
     *
     * The validation threshold indicating the allowable failures of compute machines during environment validation and
     * deployment.
     */
    @JsonProperty(value = "computeDeploymentThreshold")
    private ValidationThreshold computeDeploymentThreshold;

    /*
     * The list of rack definitions for the compute racks in a multi-rack
     * cluster, or an empty list in a single-rack cluster.
     */
    @JsonProperty(value = "computeRackDefinitions")
    private List<RackDefinition> computeRackDefinitions;

    /*
     * The current detailed status of the cluster.
     */
    @JsonProperty(value = "detailedStatus", access = JsonProperty.Access.WRITE_ONLY)
    private ClusterDetailedStatus detailedStatus;

    /*
     * The descriptive message about the detailed status.
     */
    @JsonProperty(value = "detailedStatusMessage", access = JsonProperty.Access.WRITE_ONLY)
    private String detailedStatusMessage;

    /*
     * ExtendedLocation represents the Azure custom location where the resource will be created.
     *
     * Field Deprecated. This field will not be populated in an upcoming version. The extended location (custom
     * location) that represents the Hybrid AKS control plane location. This extended location is used when creating
     * provisioned clusters (Hybrid AKS clusters).
     */
    @JsonProperty(value = "hybridAksExtendedLocation", access = JsonProperty.Access.WRITE_ONLY)
    private ExtendedLocation hybridAksExtendedLocation;

    /*
     * ManagedResourceGroupConfiguration represents the configuration of the resource group managed by Azure.
     *
     * The configuration of the managed resource group associated with the resource.
     */
    @JsonProperty(value = "managedResourceGroupConfiguration")
    private ManagedResourceGroupConfiguration managedResourceGroupConfiguration;

    /*
     * The count of Manual Action Taken (MAT) events that have not been validated.
     */
    @JsonProperty(value = "manualActionCount", access = JsonProperty.Access.WRITE_ONLY)
    private Long manualActionCount;

    /*
     * The resource ID of the Network Fabric associated with the cluster.
     */
    @JsonProperty(value = "networkFabricId", required = true)
    private String networkFabricId;

    /*
     * The provisioning state of the cluster.
     */
    @JsonProperty(value = "provisioningState", access = JsonProperty.Access.WRITE_ONLY)
    private ClusterProvisioningState provisioningState;

    /*
     * The support end date of the runtime version of the cluster.
     */
    @JsonProperty(value = "supportExpiryDate", access = JsonProperty.Access.WRITE_ONLY)
    private String supportExpiryDate;

    /*
     * The list of workload resource IDs that are hosted within this cluster.
     */
    @JsonProperty(value = "workloadResourceIds", access = JsonProperty.Access.WRITE_ONLY)
    private List<String> workloadResourceIds;

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

    /**
     * Get the aggregatorOrSingleRackDefinition property: RackDefinition represents details regarding the rack.
     *
     * <p>The rack definition that is intended to reflect only a single rack in a single rack cluster, or an aggregator
     * rack in a multi-rack cluster.
     *
     * @return the aggregatorOrSingleRackDefinition value.
     */
    public RackDefinition aggregatorOrSingleRackDefinition() {
        return this.aggregatorOrSingleRackDefinition;
    }

    /**
     * Set the aggregatorOrSingleRackDefinition property: RackDefinition represents details regarding the rack.
     *
     * <p>The rack definition that is intended to reflect only a single rack in a single rack cluster, or an aggregator
     * rack in a multi-rack cluster.
     *
     * @param aggregatorOrSingleRackDefinition the aggregatorOrSingleRackDefinition value to set.
     * @return the ClusterProperties object itself.
     */
    public ClusterProperties withAggregatorOrSingleRackDefinition(RackDefinition aggregatorOrSingleRackDefinition) {
        this.aggregatorOrSingleRackDefinition = aggregatorOrSingleRackDefinition;
        return this;
    }

    /**
     * Get the analyticsWorkspaceId property: The resource ID of the Log Analytics Workspace that will be used for
     * storing relevant logs.
     *
     * @return the analyticsWorkspaceId value.
     */
    public String analyticsWorkspaceId() {
        return this.analyticsWorkspaceId;
    }

    /**
     * Set the analyticsWorkspaceId property: The resource ID of the Log Analytics Workspace that will be used for
     * storing relevant logs.
     *
     * @param analyticsWorkspaceId the analyticsWorkspaceId value to set.
     * @return the ClusterProperties object itself.
     */
    public ClusterProperties withAnalyticsWorkspaceId(String analyticsWorkspaceId) {
        this.analyticsWorkspaceId = analyticsWorkspaceId;
        return this;
    }

    /**
     * Get the availableUpgradeVersions property: The list of cluster runtime version upgrades available for this
     * cluster.
     *
     * @return the availableUpgradeVersions value.
     */
    public List<ClusterAvailableUpgradeVersion> availableUpgradeVersions() {
        return this.availableUpgradeVersions;
    }

    /**
     * Get the clusterCapacity property: ClusterCapacity represents various details regarding compute capacity.
     *
     * <p>The capacity supported by this cluster.
     *
     * @return the clusterCapacity value.
     */
    public ClusterCapacity clusterCapacity() {
        return this.clusterCapacity;
    }

    /**
     * Get the clusterConnectionStatus property: The latest heartbeat status between the cluster manager and the
     * cluster.
     *
     * @return the clusterConnectionStatus value.
     */
    public ClusterConnectionStatus clusterConnectionStatus() {
        return this.clusterConnectionStatus;
    }

    /**
     * Get the clusterExtendedLocation property: ExtendedLocation represents the Azure custom location where the
     * resource will be created.
     *
     * <p>The extended location (custom location) that represents the cluster's control plane location. This extended
     * location is used to route the requests of child objects of the cluster that are handled by the platform operator.
     *
     * @return the clusterExtendedLocation value.
     */
    public ExtendedLocation clusterExtendedLocation() {
        return this.clusterExtendedLocation;
    }

    /**
     * Get the clusterLocation property: The customer-provided location information to identify where the cluster
     * resides.
     *
     * @return the clusterLocation value.
     */
    public String clusterLocation() {
        return this.clusterLocation;
    }

    /**
     * Set the clusterLocation property: The customer-provided location information to identify where the cluster
     * resides.
     *
     * @param clusterLocation the clusterLocation value to set.
     * @return the ClusterProperties object itself.
     */
    public ClusterProperties withClusterLocation(String clusterLocation) {
        this.clusterLocation = clusterLocation;
        return this;
    }

    /**
     * Get the clusterManagerConnectionStatus property: The latest connectivity status between cluster manager and the
     * cluster.
     *
     * @return the clusterManagerConnectionStatus value.
     */
    public ClusterManagerConnectionStatus clusterManagerConnectionStatus() {
        return this.clusterManagerConnectionStatus;
    }

    /**
     * Get the clusterManagerId property: The resource ID of the cluster manager that manages this cluster. This is set
     * by the Cluster Manager when the cluster is created.
     *
     * @return the clusterManagerId value.
     */
    public String clusterManagerId() {
        return this.clusterManagerId;
    }

    /**
     * Get the clusterServicePrincipal property: ServicePrincipalInformation represents the details of the service
     * principal to be used by the cluster during Arc Appliance installation.
     *
     * <p>The service principal to be used by the cluster during Arc Appliance installation.
     *
     * @return the clusterServicePrincipal value.
     */
    public ServicePrincipalInformation clusterServicePrincipal() {
        return this.clusterServicePrincipal;
    }

    /**
     * Set the clusterServicePrincipal property: ServicePrincipalInformation represents the details of the service
     * principal to be used by the cluster during Arc Appliance installation.
     *
     * <p>The service principal to be used by the cluster during Arc Appliance installation.
     *
     * @param clusterServicePrincipal the clusterServicePrincipal value to set.
     * @return the ClusterProperties object itself.
     */
    public ClusterProperties withClusterServicePrincipal(ServicePrincipalInformation clusterServicePrincipal) {
        this.clusterServicePrincipal = clusterServicePrincipal;
        return this;
    }

    /**
     * Get the clusterType property: The type of rack configuration for the cluster.
     *
     * @return the clusterType value.
     */
    public ClusterType clusterType() {
        return this.clusterType;
    }

    /**
     * Set the clusterType property: The type of rack configuration for the cluster.
     *
     * @param clusterType the clusterType value to set.
     * @return the ClusterProperties object itself.
     */
    public ClusterProperties withClusterType(ClusterType clusterType) {
        this.clusterType = clusterType;
        return this;
    }

    /**
     * Get the clusterVersion property: The current runtime version of the cluster.
     *
     * @return the clusterVersion value.
     */
    public String clusterVersion() {
        return this.clusterVersion;
    }

    /**
     * Set the clusterVersion property: The current runtime version of the cluster.
     *
     * @param clusterVersion the clusterVersion value to set.
     * @return the ClusterProperties object itself.
     */
    public ClusterProperties withClusterVersion(String clusterVersion) {
        this.clusterVersion = clusterVersion;
        return this;
    }

    /**
     * Get the computeDeploymentThreshold property: ValidationThreshold indicates allowed machine and node hardware and
     * deployment failures.
     *
     * <p>The validation threshold indicating the allowable failures of compute machines during environment validation
     * and deployment.
     *
     * @return the computeDeploymentThreshold value.
     */
    public ValidationThreshold computeDeploymentThreshold() {
        return this.computeDeploymentThreshold;
    }

    /**
     * Set the computeDeploymentThreshold property: ValidationThreshold indicates allowed machine and node hardware and
     * deployment failures.
     *
     * <p>The validation threshold indicating the allowable failures of compute machines during environment validation
     * and deployment.
     *
     * @param computeDeploymentThreshold the computeDeploymentThreshold value to set.
     * @return the ClusterProperties object itself.
     */
    public ClusterProperties withComputeDeploymentThreshold(ValidationThreshold computeDeploymentThreshold) {
        this.computeDeploymentThreshold = computeDeploymentThreshold;
        return this;
    }

    /**
     * Get the computeRackDefinitions property: The list of rack definitions for the compute racks in a multi-rack
     * cluster, or an empty list in a single-rack cluster.
     *
     * @return the computeRackDefinitions value.
     */
    public List<RackDefinition> computeRackDefinitions() {
        return this.computeRackDefinitions;
    }

    /**
     * Set the computeRackDefinitions property: The list of rack definitions for the compute racks in a multi-rack
     * cluster, or an empty list in a single-rack cluster.
     *
     * @param computeRackDefinitions the computeRackDefinitions value to set.
     * @return the ClusterProperties object itself.
     */
    public ClusterProperties withComputeRackDefinitions(List<RackDefinition> computeRackDefinitions) {
        this.computeRackDefinitions = computeRackDefinitions;
        return this;
    }

    /**
     * Get the detailedStatus property: The current detailed status of the cluster.
     *
     * @return the detailedStatus value.
     */
    public ClusterDetailedStatus detailedStatus() {
        return this.detailedStatus;
    }

    /**
     * Get the detailedStatusMessage property: The descriptive message about the detailed status.
     *
     * @return the detailedStatusMessage value.
     */
    public String detailedStatusMessage() {
        return this.detailedStatusMessage;
    }

    /**
     * Get the hybridAksExtendedLocation property: ExtendedLocation represents the Azure custom location where the
     * resource will be created.
     *
     * <p>Field Deprecated. This field will not be populated in an upcoming version. The extended location (custom
     * location) that represents the Hybrid AKS control plane location. This extended location is used when creating
     * provisioned clusters (Hybrid AKS clusters).
     *
     * @return the hybridAksExtendedLocation value.
     */
    public ExtendedLocation hybridAksExtendedLocation() {
        return this.hybridAksExtendedLocation;
    }

    /**
     * Get the managedResourceGroupConfiguration property: ManagedResourceGroupConfiguration represents the
     * configuration of the resource group managed by Azure.
     *
     * <p>The configuration of the managed resource group associated with the resource.
     *
     * @return the managedResourceGroupConfiguration value.
     */
    public ManagedResourceGroupConfiguration managedResourceGroupConfiguration() {
        return this.managedResourceGroupConfiguration;
    }

    /**
     * Set the managedResourceGroupConfiguration property: ManagedResourceGroupConfiguration represents the
     * configuration of the resource group managed by Azure.
     *
     * <p>The configuration of the managed resource group associated with the resource.
     *
     * @param managedResourceGroupConfiguration the managedResourceGroupConfiguration value to set.
     * @return the ClusterProperties object itself.
     */
    public ClusterProperties withManagedResourceGroupConfiguration(
        ManagedResourceGroupConfiguration managedResourceGroupConfiguration) {
        this.managedResourceGroupConfiguration = managedResourceGroupConfiguration;
        return this;
    }

    /**
     * Get the manualActionCount property: The count of Manual Action Taken (MAT) events that have not been validated.
     *
     * @return the manualActionCount value.
     */
    public Long manualActionCount() {
        return this.manualActionCount;
    }

    /**
     * Get the networkFabricId property: The resource ID of the Network Fabric associated with the cluster.
     *
     * @return the networkFabricId value.
     */
    public String networkFabricId() {
        return this.networkFabricId;
    }

    /**
     * Set the networkFabricId property: The resource ID of the Network Fabric associated with the cluster.
     *
     * @param networkFabricId the networkFabricId value to set.
     * @return the ClusterProperties object itself.
     */
    public ClusterProperties withNetworkFabricId(String networkFabricId) {
        this.networkFabricId = networkFabricId;
        return this;
    }

    /**
     * Get the provisioningState property: The provisioning state of the cluster.
     *
     * @return the provisioningState value.
     */
    public ClusterProvisioningState provisioningState() {
        return this.provisioningState;
    }

    /**
     * Get the supportExpiryDate property: The support end date of the runtime version of the cluster.
     *
     * @return the supportExpiryDate value.
     */
    public String supportExpiryDate() {
        return this.supportExpiryDate;
    }

    /**
     * Get the workloadResourceIds property: The list of workload resource IDs that are hosted within this cluster.
     *
     * @return the workloadResourceIds value.
     */
    public List<String> workloadResourceIds() {
        return this.workloadResourceIds;
    }

    /**
     * Validates the instance.
     *
     * @throws IllegalArgumentException thrown if the instance is not valid.
     */
    public void validate() {
        if (aggregatorOrSingleRackDefinition() == null) {
            throw LOGGER
                .logExceptionAsError(
                    new IllegalArgumentException(
                        "Missing required property aggregatorOrSingleRackDefinition in model ClusterProperties"));
        } else {
            aggregatorOrSingleRackDefinition().validate();
        }
        if (availableUpgradeVersions() != null) {
            availableUpgradeVersions().forEach(e -> e.validate());
        }
        if (clusterCapacity() != null) {
            clusterCapacity().validate();
        }
        if (clusterExtendedLocation() != null) {
            clusterExtendedLocation().validate();
        }
        if (clusterServicePrincipal() != null) {
            clusterServicePrincipal().validate();
        }
        if (clusterType() == null) {
            throw LOGGER
                .logExceptionAsError(
                    new IllegalArgumentException("Missing required property clusterType in model ClusterProperties"));
        }
        if (clusterVersion() == null) {
            throw LOGGER
                .logExceptionAsError(
                    new IllegalArgumentException(
                        "Missing required property clusterVersion in model ClusterProperties"));
        }
        if (computeDeploymentThreshold() != null) {
            computeDeploymentThreshold().validate();
        }
        if (computeRackDefinitions() != null) {
            computeRackDefinitions().forEach(e -> e.validate());
        }
        if (hybridAksExtendedLocation() != null) {
            hybridAksExtendedLocation().validate();
        }
        if (managedResourceGroupConfiguration() != null) {
            managedResourceGroupConfiguration().validate();
        }
        if (networkFabricId() == null) {
            throw LOGGER
                .logExceptionAsError(
                    new IllegalArgumentException(
                        "Missing required property networkFabricId in model ClusterProperties"));
        }
    }

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