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

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

import com.azure.core.annotation.Fluent;
import com.azure.core.util.logging.ClientLogger;
import com.azure.resourcemanager.cosmosdbforpostgresql.models.ConfigurationDataType;
import com.azure.resourcemanager.cosmosdbforpostgresql.models.ProvisioningState;
import com.azure.resourcemanager.cosmosdbforpostgresql.models.ServerRoleGroupConfiguration;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.List;

/** The properties of configuration. */
@Fluent
public final class ConfigurationProperties {
    /*
     * Description of the configuration.
     */
    @JsonProperty(value = "description", access = JsonProperty.Access.WRITE_ONLY)
    private String description;

    /*
     * Data type of the configuration.
     */
    @JsonProperty(value = "dataType", access = JsonProperty.Access.WRITE_ONLY)
    private ConfigurationDataType dataType;

    /*
     * Allowed values of the configuration.
     */
    @JsonProperty(value = "allowedValues", access = JsonProperty.Access.WRITE_ONLY)
    private String allowedValues;

    /*
     * If configuration change requires restart.
     */
    @JsonProperty(value = "requiresRestart")
    private Boolean requiresRestart;

    /*
     * The list of server role group configuration values.
     */
    @JsonProperty(value = "serverRoleGroupConfigurations", required = true)
    private List<ServerRoleGroupConfiguration> serverRoleGroupConfigurations;

    /*
     * Provisioning state of the configuration
     */
    @JsonProperty(value = "provisioningState", access = JsonProperty.Access.WRITE_ONLY)
    private ProvisioningState provisioningState;

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

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

    /**
     * Get the dataType property: Data type of the configuration.
     *
     * @return the dataType value.
     */
    public ConfigurationDataType dataType() {
        return this.dataType;
    }

    /**
     * Get the allowedValues property: Allowed values of the configuration.
     *
     * @return the allowedValues value.
     */
    public String allowedValues() {
        return this.allowedValues;
    }

    /**
     * Get the requiresRestart property: If configuration change requires restart.
     *
     * @return the requiresRestart value.
     */
    public Boolean requiresRestart() {
        return this.requiresRestart;
    }

    /**
     * Set the requiresRestart property: If configuration change requires restart.
     *
     * @param requiresRestart the requiresRestart value to set.
     * @return the ConfigurationProperties object itself.
     */
    public ConfigurationProperties withRequiresRestart(Boolean requiresRestart) {
        this.requiresRestart = requiresRestart;
        return this;
    }

    /**
     * Get the serverRoleGroupConfigurations property: The list of server role group configuration values.
     *
     * @return the serverRoleGroupConfigurations value.
     */
    public List<ServerRoleGroupConfiguration> serverRoleGroupConfigurations() {
        return this.serverRoleGroupConfigurations;
    }

    /**
     * Set the serverRoleGroupConfigurations property: The list of server role group configuration values.
     *
     * @param serverRoleGroupConfigurations the serverRoleGroupConfigurations value to set.
     * @return the ConfigurationProperties object itself.
     */
    public ConfigurationProperties withServerRoleGroupConfigurations(
        List<ServerRoleGroupConfiguration> serverRoleGroupConfigurations) {
        this.serverRoleGroupConfigurations = serverRoleGroupConfigurations;
        return this;
    }

    /**
     * Get the provisioningState property: Provisioning state of the configuration.
     *
     * @return the provisioningState value.
     */
    public ProvisioningState provisioningState() {
        return this.provisioningState;
    }

    /**
     * Validates the instance.
     *
     * @throws IllegalArgumentException thrown if the instance is not valid.
     */
    public void validate() {
        if (serverRoleGroupConfigurations() == null) {
            throw LOGGER
                .logExceptionAsError(
                    new IllegalArgumentException(
                        "Missing required property serverRoleGroupConfigurations in model ConfigurationProperties"));
        } else {
            serverRoleGroupConfigurations().forEach(e -> e.validate());
        }
    }

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