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

import com.azure.core.annotation.Fluent;
import com.azure.resourcemanager.redisenterprise.fluent.models.DatabaseProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.List;

/** A partial update to the RedisEnterprise database. */
@Fluent
public final class DatabaseUpdate {
    /*
     * RedisEnterprise database properties
     *
     * Properties of the database.
     */
    @JsonProperty(value = "properties")
    private DatabaseProperties innerProperties;

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

    /**
     * Get the innerProperties property: RedisEnterprise database properties
     *
     * <p>Properties of the database.
     *
     * @return the innerProperties value.
     */
    private DatabaseProperties innerProperties() {
        return this.innerProperties;
    }

    /**
     * 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.innerProperties() == null ? null : this.innerProperties().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 DatabaseUpdate object itself.
     */
    public DatabaseUpdate withClientProtocol(Protocol clientProtocol) {
        if (this.innerProperties() == null) {
            this.innerProperties = new DatabaseProperties();
        }
        this.innerProperties().withClientProtocol(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.innerProperties() == null ? null : this.innerProperties().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 DatabaseUpdate object itself.
     */
    public DatabaseUpdate withPort(Integer port) {
        if (this.innerProperties() == null) {
            this.innerProperties = new DatabaseProperties();
        }
        this.innerProperties().withPort(port);
        return this;
    }

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

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

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

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

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

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

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

    /**
     * Set the persistence property: Persistence settings.
     *
     * @param persistence the persistence value to set.
     * @return the DatabaseUpdate object itself.
     */
    public DatabaseUpdate withPersistence(Persistence persistence) {
        if (this.innerProperties() == null) {
            this.innerProperties = new DatabaseProperties();
        }
        this.innerProperties().withPersistence(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.innerProperties() == null ? null : this.innerProperties().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 DatabaseUpdate object itself.
     */
    public DatabaseUpdate withModules(List<Module> modules) {
        if (this.innerProperties() == null) {
            this.innerProperties = new DatabaseProperties();
        }
        this.innerProperties().withModules(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.innerProperties() == null ? null : this.innerProperties().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 DatabaseUpdate object itself.
     */
    public DatabaseUpdate withGeoReplication(DatabasePropertiesGeoReplication geoReplication) {
        if (this.innerProperties() == null) {
            this.innerProperties = new DatabaseProperties();
        }
        this.innerProperties().withGeoReplication(geoReplication);
        return this;
    }

    /**
     * Validates the instance.
     *
     * @throws IllegalArgumentException thrown if the instance is not valid.
     */
    public void validate() {
        if (innerProperties() != null) {
            innerProperties().validate();
        }
    }
}
