// 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 MySQL database connection. */
@Fluent
public final class ConnectToSourceMySqlTaskInput {
    /*
     * Information for connecting to MySQL source
     */
    @JsonProperty(value = "sourceConnectionInfo", required = true)
    private MySqlConnectionInfo sourceConnectionInfo;

    /*
     * Target Platform for the migration
     */
    @JsonProperty(value = "targetPlatform")
    private MySqlTargetPlatformType targetPlatform;

    /*
     * Permission group for validations
     */
    @JsonProperty(value = "checkPermissionsGroup")
    private ServerLevelPermissionsGroup checkPermissionsGroup;

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

    /**
     * Get the sourceConnectionInfo property: Information for connecting to MySQL source.
     *
     * @return the sourceConnectionInfo value.
     */
    public MySqlConnectionInfo sourceConnectionInfo() {
        return this.sourceConnectionInfo;
    }

    /**
     * Set the sourceConnectionInfo property: Information for connecting to MySQL source.
     *
     * @param sourceConnectionInfo the sourceConnectionInfo value to set.
     * @return the ConnectToSourceMySqlTaskInput object itself.
     */
    public ConnectToSourceMySqlTaskInput withSourceConnectionInfo(MySqlConnectionInfo sourceConnectionInfo) {
        this.sourceConnectionInfo = sourceConnectionInfo;
        return this;
    }

    /**
     * Get the targetPlatform property: Target Platform for the migration.
     *
     * @return the targetPlatform value.
     */
    public MySqlTargetPlatformType targetPlatform() {
        return this.targetPlatform;
    }

    /**
     * Set the targetPlatform property: Target Platform for the migration.
     *
     * @param targetPlatform the targetPlatform value to set.
     * @return the ConnectToSourceMySqlTaskInput object itself.
     */
    public ConnectToSourceMySqlTaskInput withTargetPlatform(MySqlTargetPlatformType targetPlatform) {
        this.targetPlatform = targetPlatform;
        return this;
    }

    /**
     * Get the checkPermissionsGroup property: Permission group for validations.
     *
     * @return the checkPermissionsGroup value.
     */
    public ServerLevelPermissionsGroup checkPermissionsGroup() {
        return this.checkPermissionsGroup;
    }

    /**
     * Set the checkPermissionsGroup property: Permission group for validations.
     *
     * @param checkPermissionsGroup the checkPermissionsGroup value to set.
     * @return the ConnectToSourceMySqlTaskInput object itself.
     */
    public ConnectToSourceMySqlTaskInput withCheckPermissionsGroup(ServerLevelPermissionsGroup checkPermissionsGroup) {
        this.checkPermissionsGroup = checkPermissionsGroup;
        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 ConnectToSourceMySqlTaskInput"));
        } else {
            sourceConnectionInfo().validate();
        }
    }

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