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

package com.azure.resourcemanager.workloads.models;

import com.azure.core.annotation.Fluent;
import com.azure.core.util.logging.ClientLogger;
import com.fasterxml.jackson.annotation.JsonProperty;

/** Gets or sets the database configuration. */
@Fluent
public final class DatabaseConfiguration {
    /*
     * The database type.
     */
    @JsonProperty(value = "databaseType")
    private SapDatabaseType databaseType;

    /*
     * The subnet id.
     */
    @JsonProperty(value = "subnetId", required = true)
    private String subnetId;

    /*
     * Gets or sets the virtual machine configuration.
     */
    @JsonProperty(value = "virtualMachineConfiguration", required = true)
    private VirtualMachineConfiguration virtualMachineConfiguration;

    /*
     * The number of database VMs.
     */
    @JsonProperty(value = "instanceCount", required = true)
    private long instanceCount;

    /*
     * Gets or sets the disk configuration.
     */
    @JsonProperty(value = "diskConfiguration")
    private DiskConfiguration diskConfiguration;

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

    /**
     * Get the databaseType property: The database type.
     *
     * @return the databaseType value.
     */
    public SapDatabaseType databaseType() {
        return this.databaseType;
    }

    /**
     * Set the databaseType property: The database type.
     *
     * @param databaseType the databaseType value to set.
     * @return the DatabaseConfiguration object itself.
     */
    public DatabaseConfiguration withDatabaseType(SapDatabaseType databaseType) {
        this.databaseType = databaseType;
        return this;
    }

    /**
     * Get the subnetId property: The subnet id.
     *
     * @return the subnetId value.
     */
    public String subnetId() {
        return this.subnetId;
    }

    /**
     * Set the subnetId property: The subnet id.
     *
     * @param subnetId the subnetId value to set.
     * @return the DatabaseConfiguration object itself.
     */
    public DatabaseConfiguration withSubnetId(String subnetId) {
        this.subnetId = subnetId;
        return this;
    }

    /**
     * Get the virtualMachineConfiguration property: Gets or sets the virtual machine configuration.
     *
     * @return the virtualMachineConfiguration value.
     */
    public VirtualMachineConfiguration virtualMachineConfiguration() {
        return this.virtualMachineConfiguration;
    }

    /**
     * Set the virtualMachineConfiguration property: Gets or sets the virtual machine configuration.
     *
     * @param virtualMachineConfiguration the virtualMachineConfiguration value to set.
     * @return the DatabaseConfiguration object itself.
     */
    public DatabaseConfiguration withVirtualMachineConfiguration(
        VirtualMachineConfiguration virtualMachineConfiguration) {
        this.virtualMachineConfiguration = virtualMachineConfiguration;
        return this;
    }

    /**
     * Get the instanceCount property: The number of database VMs.
     *
     * @return the instanceCount value.
     */
    public long instanceCount() {
        return this.instanceCount;
    }

    /**
     * Set the instanceCount property: The number of database VMs.
     *
     * @param instanceCount the instanceCount value to set.
     * @return the DatabaseConfiguration object itself.
     */
    public DatabaseConfiguration withInstanceCount(long instanceCount) {
        this.instanceCount = instanceCount;
        return this;
    }

    /**
     * Get the diskConfiguration property: Gets or sets the disk configuration.
     *
     * @return the diskConfiguration value.
     */
    public DiskConfiguration diskConfiguration() {
        return this.diskConfiguration;
    }

    /**
     * Set the diskConfiguration property: Gets or sets the disk configuration.
     *
     * @param diskConfiguration the diskConfiguration value to set.
     * @return the DatabaseConfiguration object itself.
     */
    public DatabaseConfiguration withDiskConfiguration(DiskConfiguration diskConfiguration) {
        this.diskConfiguration = diskConfiguration;
        return this;
    }

    /**
     * Validates the instance.
     *
     * @throws IllegalArgumentException thrown if the instance is not valid.
     */
    public void validate() {
        if (subnetId() == null) {
            throw LOGGER
                .logExceptionAsError(
                    new IllegalArgumentException("Missing required property subnetId in model DatabaseConfiguration"));
        }
        if (virtualMachineConfiguration() == null) {
            throw LOGGER
                .logExceptionAsError(
                    new IllegalArgumentException(
                        "Missing required property virtualMachineConfiguration in model DatabaseConfiguration"));
        } else {
            virtualMachineConfiguration().validate();
        }
        if (diskConfiguration() != null) {
            diskConfiguration().validate();
        }
    }

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