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

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

import com.azure.core.annotation.Fluent;
import com.azure.resourcemanager.redisenterprise.models.ClusteringPolicy;
import com.azure.resourcemanager.redisenterprise.models.DatabasePropertiesGeoReplication;
import com.azure.resourcemanager.redisenterprise.models.EvictionPolicy;
import com.azure.resourcemanager.redisenterprise.models.Module;
import com.azure.resourcemanager.redisenterprise.models.Persistence;
import com.azure.resourcemanager.redisenterprise.models.Protocol;
import com.azure.resourcemanager.redisenterprise.models.ProvisioningState;
import com.azure.resourcemanager.redisenterprise.models.ResourceState;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.List;

/**
 * RedisEnterprise database properties
 *
 * <p>Properties of RedisEnterprise databases, as opposed to general resource properties like location, tags.
 */
@Fluent
public final class DatabaseProperties {
    /*
     * Specifies whether redis clients can connect using TLS-encrypted or plaintext redis protocols. Default is
     * TLS-encrypted.
     */
    @JsonProperty(value = "clientProtocol")
    private Protocol clientProtocol;

    /*
     * TCP port of the database endpoint. Specified at create time. Defaults to an available port.
     */
    @JsonProperty(value = "port")
    private Integer port;

    /*
     * Current provisioning status of the database
     */
    @JsonProperty(value = "provisioningState", access = JsonProperty.Access.WRITE_ONLY)
    private ProvisioningState provisioningState;

    /*
     * Current resource status of the database
     */
    @JsonProperty(value = "resourceState", access = JsonProperty.Access.WRITE_ONLY)
    private ResourceState resourceState;

    /*
     * Clustering policy - default is OSSCluster. Specified at create time.
     */
    @JsonProperty(value = "clusteringPolicy")
    private ClusteringPolicy clusteringPolicy;

    /*
     * Redis eviction policy - default is VolatileLRU
     */
    @JsonProperty(value = "evictionPolicy")
    private EvictionPolicy evictionPolicy;

    /*
     * Persistence settings
     */
    @JsonProperty(value = "persistence")
    private Persistence persistence;

    /*
     * Optional set of redis modules to enable in this database - modules can only be added at creation time.
     */
    @JsonProperty(value = "modules")
    private List<Module> modules;

    /*
     * Optional set of properties to configure geo replication for this database.
     */
    @JsonProperty(value = "geoReplication")
    private DatabasePropertiesGeoReplication geoReplication;

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

    /**
     * Get the clientProtocol property: Specifies whether redis clients can connect using TLS-encrypted or plaintext
     * redis protocols. Default is TLS-encrypted.
     *
     * @return the clientProtocol value.
     */
    public Protocol clientProtocol() {
        return this.clientProtocol;
    }

    /**
     * Set the clientProtocol property: Specifies whether redis clients can connect using TLS-encrypted or plaintext
     * redis protocols. Default is TLS-encrypted.
     *
     * @param clientProtocol the clientProtocol value to set.
     * @return the DatabaseProperties object itself.
     */
    public DatabaseProperties withClientProtocol(Protocol clientProtocol) {
        this.clientProtocol = clientProtocol;
        return this;
    }

    /**
     * Get the port property: TCP port of the database endpoint. Specified at create time. Defaults to an available
     * port.
     *
     * @return the port value.
     */
    public Integer port() {
        return this.port;
    }

    /**
     * Set the port property: TCP port of the database endpoint. Specified at create time. Defaults to an available
     * port.
     *
     * @param port the port value to set.
     * @return the DatabaseProperties object itself.
     */
    public DatabaseProperties withPort(Integer port) {
        this.port = port;
        return this;
    }

    /**
     * Get the provisioningState property: Current provisioning status of the database.
     *
     * @return the provisioningState value.
     */
    public ProvisioningState provisioningState() {
        return this.provisioningState;
    }

    /**
     * Get the resourceState property: Current resource status of the database.
     *
     * @return the resourceState value.
     */
    public ResourceState resourceState() {
        return this.resourceState;
    }

    /**
     * Get the clusteringPolicy property: Clustering policy - default is OSSCluster. Specified at create time.
     *
     * @return the clusteringPolicy value.
     */
    public ClusteringPolicy clusteringPolicy() {
        return this.clusteringPolicy;
    }

    /**
     * Set the clusteringPolicy property: Clustering policy - default is OSSCluster. Specified at create time.
     *
     * @param clusteringPolicy the clusteringPolicy value to set.
     * @return the DatabaseProperties object itself.
     */
    public DatabaseProperties withClusteringPolicy(ClusteringPolicy clusteringPolicy) {
        this.clusteringPolicy = clusteringPolicy;
        return this;
    }

    /**
     * Get the evictionPolicy property: Redis eviction policy - default is VolatileLRU.
     *
     * @return the evictionPolicy value.
     */
    public EvictionPolicy evictionPolicy() {
        return this.evictionPolicy;
    }

    /**
     * Set the evictionPolicy property: Redis eviction policy - default is VolatileLRU.
     *
     * @param evictionPolicy the evictionPolicy value to set.
     * @return the DatabaseProperties object itself.
     */
    public DatabaseProperties withEvictionPolicy(EvictionPolicy evictionPolicy) {
        this.evictionPolicy = evictionPolicy;
        return this;
    }

    /**
     * Get the persistence property: Persistence settings.
     *
     * @return the persistence value.
     */
    public Persistence persistence() {
        return this.persistence;
    }

    /**
     * Set the persistence property: Persistence settings.
     *
     * @param persistence the persistence value to set.
     * @return the DatabaseProperties object itself.
     */
    public DatabaseProperties withPersistence(Persistence persistence) {
        this.persistence = persistence;
        return this;
    }

    /**
     * Get the modules property: Optional set of redis modules to enable in this database - modules can only be added at
     * creation time.
     *
     * @return the modules value.
     */
    public List<Module> modules() {
        return this.modules;
    }

    /**
     * Set the modules property: Optional set of redis modules to enable in this database - modules can only be added at
     * creation time.
     *
     * @param modules the modules value to set.
     * @return the DatabaseProperties object itself.
     */
    public DatabaseProperties withModules(List<Module> modules) {
        this.modules = modules;
        return this;
    }

    /**
     * Get the geoReplication property: Optional set of properties to configure geo replication for this database.
     *
     * @return the geoReplication value.
     */
    public DatabasePropertiesGeoReplication geoReplication() {
        return this.geoReplication;
    }

    /**
     * Set the geoReplication property: Optional set of properties to configure geo replication for this database.
     *
     * @param geoReplication the geoReplication value to set.
     * @return the DatabaseProperties object itself.
     */
    public DatabaseProperties withGeoReplication(DatabasePropertiesGeoReplication geoReplication) {
        this.geoReplication = geoReplication;
        return this;
    }

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