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

/** Input for the task that validates connection to PostgreSQL and source server requirements. */
@Fluent
public final class ConnectToSourcePostgreSqlSyncTaskInput {
    /*
     * Connection information for source PostgreSQL server
     */
    @JsonProperty(value = "sourceConnectionInfo", required = true)
    private PostgreSqlConnectionInfo sourceConnectionInfo;

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

    /**
     * Get the sourceConnectionInfo property: Connection information for source PostgreSQL server.
     *
     * @return the sourceConnectionInfo value.
     */
    public PostgreSqlConnectionInfo sourceConnectionInfo() {
        return this.sourceConnectionInfo;
    }

    /**
     * Set the sourceConnectionInfo property: Connection information for source PostgreSQL server.
     *
     * @param sourceConnectionInfo the sourceConnectionInfo value to set.
     * @return the ConnectToSourcePostgreSqlSyncTaskInput object itself.
     */
    public ConnectToSourcePostgreSqlSyncTaskInput withSourceConnectionInfo(
        PostgreSqlConnectionInfo sourceConnectionInfo) {
        this.sourceConnectionInfo = sourceConnectionInfo;
        return this;
    }

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

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