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

/** ClusterPatchProperties represents the properties of the cluster for patching. */
@Fluent
public final class ClusterPatchProperties {
    /*
     * 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")
    private RackDefinition aggregatorOrSingleRackDefinition;

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

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

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

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

    /**
     * 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 ClusterPatchProperties object itself.
     */
    public ClusterPatchProperties withAggregatorOrSingleRackDefinition(
        RackDefinition aggregatorOrSingleRackDefinition) {
        this.aggregatorOrSingleRackDefinition = aggregatorOrSingleRackDefinition;
        return this;
    }

    /**
     * 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 ClusterPatchProperties object itself.
     */
    public ClusterPatchProperties withClusterLocation(String clusterLocation) {
        this.clusterLocation = clusterLocation;
        return this;
    }

    /**
     * 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 ClusterPatchProperties object itself.
     */
    public ClusterPatchProperties withClusterServicePrincipal(ServicePrincipalInformation clusterServicePrincipal) {
        this.clusterServicePrincipal = clusterServicePrincipal;
        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 ClusterPatchProperties object itself.
     */
    public ClusterPatchProperties 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 ClusterPatchProperties object itself.
     */
    public ClusterPatchProperties withComputeRackDefinitions(List<RackDefinition> computeRackDefinitions) {
        this.computeRackDefinitions = computeRackDefinitions;
        return this;
    }

    /**
     * Validates the instance.
     *
     * @throws IllegalArgumentException thrown if the instance is not valid.
     */
    public void validate() {
        if (aggregatorOrSingleRackDefinition() != null) {
            aggregatorOrSingleRackDefinition().validate();
        }
        if (clusterServicePrincipal() != null) {
            clusterServicePrincipal().validate();
        }
        if (computeDeploymentThreshold() != null) {
            computeDeploymentThreshold().validate();
        }
        if (computeRackDefinitions() != null) {
            computeRackDefinitions().forEach(e -> e.validate());
        }
    }
}
