// 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 java.util.List;

/** Input for task that migrates SQL Server databases to Azure SQL Database Managed Instance online scenario. */
@Fluent
public class SqlServerSqlMISyncTaskInput {
    /*
     * Databases to migrate
     */
    @JsonProperty(value = "selectedDatabases", required = true)
    private List<MigrateSqlServerSqlMIDatabaseInput> selectedDatabases;

    /*
     * Backup file share information for all selected databases.
     */
    @JsonProperty(value = "backupFileShare")
    private FileShare backupFileShare;

    /*
     * Fully qualified resourceId of storage
     */
    @JsonProperty(value = "storageResourceId", required = true)
    private String storageResourceId;

    /*
     * Connection information for source SQL Server
     */
    @JsonProperty(value = "sourceConnectionInfo", required = true)
    private SqlConnectionInfo sourceConnectionInfo;

    /*
     * Connection information for Azure SQL Database Managed Instance
     */
    @JsonProperty(value = "targetConnectionInfo", required = true)
    private MiSqlConnectionInfo targetConnectionInfo;

    /*
     * Azure Active Directory Application the DMS instance will use to connect to the target instance of Azure SQL
     * Database Managed Instance and the Azure Storage Account
     */
    @JsonProperty(value = "azureApp", required = true)
    private AzureActiveDirectoryApp azureApp;

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

    /**
     * Get the selectedDatabases property: Databases to migrate.
     *
     * @return the selectedDatabases value.
     */
    public List<MigrateSqlServerSqlMIDatabaseInput> selectedDatabases() {
        return this.selectedDatabases;
    }

    /**
     * Set the selectedDatabases property: Databases to migrate.
     *
     * @param selectedDatabases the selectedDatabases value to set.
     * @return the SqlServerSqlMISyncTaskInput object itself.
     */
    public SqlServerSqlMISyncTaskInput withSelectedDatabases(
        List<MigrateSqlServerSqlMIDatabaseInput> selectedDatabases) {
        this.selectedDatabases = selectedDatabases;
        return this;
    }

    /**
     * Get the backupFileShare property: Backup file share information for all selected databases.
     *
     * @return the backupFileShare value.
     */
    public FileShare backupFileShare() {
        return this.backupFileShare;
    }

    /**
     * Set the backupFileShare property: Backup file share information for all selected databases.
     *
     * @param backupFileShare the backupFileShare value to set.
     * @return the SqlServerSqlMISyncTaskInput object itself.
     */
    public SqlServerSqlMISyncTaskInput withBackupFileShare(FileShare backupFileShare) {
        this.backupFileShare = backupFileShare;
        return this;
    }

    /**
     * Get the storageResourceId property: Fully qualified resourceId of storage.
     *
     * @return the storageResourceId value.
     */
    public String storageResourceId() {
        return this.storageResourceId;
    }

    /**
     * Set the storageResourceId property: Fully qualified resourceId of storage.
     *
     * @param storageResourceId the storageResourceId value to set.
     * @return the SqlServerSqlMISyncTaskInput object itself.
     */
    public SqlServerSqlMISyncTaskInput withStorageResourceId(String storageResourceId) {
        this.storageResourceId = storageResourceId;
        return this;
    }

    /**
     * Get the sourceConnectionInfo property: Connection information for source SQL Server.
     *
     * @return the sourceConnectionInfo value.
     */
    public SqlConnectionInfo sourceConnectionInfo() {
        return this.sourceConnectionInfo;
    }

    /**
     * Set the sourceConnectionInfo property: Connection information for source SQL Server.
     *
     * @param sourceConnectionInfo the sourceConnectionInfo value to set.
     * @return the SqlServerSqlMISyncTaskInput object itself.
     */
    public SqlServerSqlMISyncTaskInput withSourceConnectionInfo(SqlConnectionInfo sourceConnectionInfo) {
        this.sourceConnectionInfo = sourceConnectionInfo;
        return this;
    }

    /**
     * Get the targetConnectionInfo property: Connection information for Azure SQL Database Managed Instance.
     *
     * @return the targetConnectionInfo value.
     */
    public MiSqlConnectionInfo targetConnectionInfo() {
        return this.targetConnectionInfo;
    }

    /**
     * Set the targetConnectionInfo property: Connection information for Azure SQL Database Managed Instance.
     *
     * @param targetConnectionInfo the targetConnectionInfo value to set.
     * @return the SqlServerSqlMISyncTaskInput object itself.
     */
    public SqlServerSqlMISyncTaskInput withTargetConnectionInfo(MiSqlConnectionInfo targetConnectionInfo) {
        this.targetConnectionInfo = targetConnectionInfo;
        return this;
    }

    /**
     * Get the azureApp property: Azure Active Directory Application the DMS instance will use to connect to the target
     * instance of Azure SQL Database Managed Instance and the Azure Storage Account.
     *
     * @return the azureApp value.
     */
    public AzureActiveDirectoryApp azureApp() {
        return this.azureApp;
    }

    /**
     * Set the azureApp property: Azure Active Directory Application the DMS instance will use to connect to the target
     * instance of Azure SQL Database Managed Instance and the Azure Storage Account.
     *
     * @param azureApp the azureApp value to set.
     * @return the SqlServerSqlMISyncTaskInput object itself.
     */
    public SqlServerSqlMISyncTaskInput withAzureApp(AzureActiveDirectoryApp azureApp) {
        this.azureApp = azureApp;
        return this;
    }

    /**
     * Validates the instance.
     *
     * @throws IllegalArgumentException thrown if the instance is not valid.
     */
    public void validate() {
        if (selectedDatabases() == null) {
            throw LOGGER
                .logExceptionAsError(
                    new IllegalArgumentException(
                        "Missing required property selectedDatabases in model SqlServerSqlMISyncTaskInput"));
        } else {
            selectedDatabases().forEach(e -> e.validate());
        }
        if (backupFileShare() != null) {
            backupFileShare().validate();
        }
        if (storageResourceId() == null) {
            throw LOGGER
                .logExceptionAsError(
                    new IllegalArgumentException(
                        "Missing required property storageResourceId in model SqlServerSqlMISyncTaskInput"));
        }
        if (sourceConnectionInfo() == null) {
            throw LOGGER
                .logExceptionAsError(
                    new IllegalArgumentException(
                        "Missing required property sourceConnectionInfo in model SqlServerSqlMISyncTaskInput"));
        } else {
            sourceConnectionInfo().validate();
        }
        if (targetConnectionInfo() == null) {
            throw LOGGER
                .logExceptionAsError(
                    new IllegalArgumentException(
                        "Missing required property targetConnectionInfo in model SqlServerSqlMISyncTaskInput"));
        } else {
            targetConnectionInfo().validate();
        }
        if (azureApp() == null) {
            throw LOGGER
                .logExceptionAsError(
                    new IllegalArgumentException(
                        "Missing required property azureApp in model SqlServerSqlMISyncTaskInput"));
        } else {
            azureApp().validate();
        }
    }

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