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

package com.azure.resourcemanager.security.models;

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

/** Details of the On Premise Sql resource that was assessed. */
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "source")
@JsonTypeName("OnPremiseSql")
@Fluent
public final class OnPremiseSqlResourceDetails extends OnPremiseResourceDetails {
    /*
     * The Sql server name installed on the machine
     */
    @JsonProperty(value = "serverName", required = true)
    private String serverName;

    /*
     * The Sql database name installed on the machine
     */
    @JsonProperty(value = "databaseName", required = true)
    private String databaseName;

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

    /**
     * Get the serverName property: The Sql server name installed on the machine.
     *
     * @return the serverName value.
     */
    public String serverName() {
        return this.serverName;
    }

    /**
     * Set the serverName property: The Sql server name installed on the machine.
     *
     * @param serverName the serverName value to set.
     * @return the OnPremiseSqlResourceDetails object itself.
     */
    public OnPremiseSqlResourceDetails withServerName(String serverName) {
        this.serverName = serverName;
        return this;
    }

    /**
     * Get the databaseName property: The Sql database name installed on the machine.
     *
     * @return the databaseName value.
     */
    public String databaseName() {
        return this.databaseName;
    }

    /**
     * Set the databaseName property: The Sql database name installed on the machine.
     *
     * @param databaseName the databaseName value to set.
     * @return the OnPremiseSqlResourceDetails object itself.
     */
    public OnPremiseSqlResourceDetails withDatabaseName(String databaseName) {
        this.databaseName = databaseName;
        return this;
    }

    /** {@inheritDoc} */
    @Override
    public OnPremiseSqlResourceDetails withWorkspaceId(String workspaceId) {
        super.withWorkspaceId(workspaceId);
        return this;
    }

    /** {@inheritDoc} */
    @Override
    public OnPremiseSqlResourceDetails withVmuuid(String vmuuid) {
        super.withVmuuid(vmuuid);
        return this;
    }

    /** {@inheritDoc} */
    @Override
    public OnPremiseSqlResourceDetails withSourceComputerId(String sourceComputerId) {
        super.withSourceComputerId(sourceComputerId);
        return this;
    }

    /** {@inheritDoc} */
    @Override
    public OnPremiseSqlResourceDetails withMachineName(String machineName) {
        super.withMachineName(machineName);
        return this;
    }

    /**
     * Validates the instance.
     *
     * @throws IllegalArgumentException thrown if the instance is not valid.
     */
    @Override
    public void validate() {
        super.validate();
        if (serverName() == null) {
            throw LOGGER
                .logExceptionAsError(
                    new IllegalArgumentException(
                        "Missing required property serverName in model OnPremiseSqlResourceDetails"));
        }
        if (databaseName() == null) {
            throw LOGGER
                .logExceptionAsError(
                    new IllegalArgumentException(
                        "Missing required property databaseName in model OnPremiseSqlResourceDetails"));
        }
    }

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