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

package com.azure.resourcemanager.datamigration.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;

/** Information for connecting to PostgreSQL server. */
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "type")
@JsonTypeName("PostgreSqlConnectionInfo")
@Fluent
public final class PostgreSqlConnectionInfo extends ConnectionInfo {
    /*
     * Name of the server
     */
    @JsonProperty(value = "serverName", required = true)
    private String serverName;

    /*
     * Name of the database
     */
    @JsonProperty(value = "databaseName")
    private String databaseName;

    /*
     * Port for Server
     */
    @JsonProperty(value = "port", required = true)
    private int port;

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

    /**
     * Get the serverName property: Name of the server.
     *
     * @return the serverName value.
     */
    public String serverName() {
        return this.serverName;
    }

    /**
     * Set the serverName property: Name of the server.
     *
     * @param serverName the serverName value to set.
     * @return the PostgreSqlConnectionInfo object itself.
     */
    public PostgreSqlConnectionInfo withServerName(String serverName) {
        this.serverName = serverName;
        return this;
    }

    /**
     * Get the databaseName property: Name of the database.
     *
     * @return the databaseName value.
     */
    public String databaseName() {
        return this.databaseName;
    }

    /**
     * Set the databaseName property: Name of the database.
     *
     * @param databaseName the databaseName value to set.
     * @return the PostgreSqlConnectionInfo object itself.
     */
    public PostgreSqlConnectionInfo withDatabaseName(String databaseName) {
        this.databaseName = databaseName;
        return this;
    }

    /**
     * Get the port property: Port for Server.
     *
     * @return the port value.
     */
    public int port() {
        return this.port;
    }

    /**
     * Set the port property: Port for Server.
     *
     * @param port the port value to set.
     * @return the PostgreSqlConnectionInfo object itself.
     */
    public PostgreSqlConnectionInfo withPort(int port) {
        this.port = port;
        return this;
    }

    /** {@inheritDoc} */
    @Override
    public PostgreSqlConnectionInfo withUsername(String username) {
        super.withUsername(username);
        return this;
    }

    /** {@inheritDoc} */
    @Override
    public PostgreSqlConnectionInfo withPassword(String password) {
        super.withPassword(password);
        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 PostgreSqlConnectionInfo"));
        }
    }

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