// 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 validates migration input for SQL to Azure SQL Managed Instance. */
@Fluent
public final class ValidateMigrationInputSqlServerSqlMITaskInput {
    /*
     * Information for connecting to source
     */
    @JsonProperty(value = "sourceConnectionInfo", required = true)
    private SqlConnectionInfo sourceConnectionInfo;

    /*
     * Information for connecting to target
     */
    @JsonProperty(value = "targetConnectionInfo", required = true)
    private SqlConnectionInfo targetConnectionInfo;

    /*
     * Databases to migrate
     */
    @JsonProperty(value = "selectedDatabases", required = true)
    private List<MigrateSqlServerSqlMIDatabaseInput> selectedDatabases;

    /*
     * Logins to migrate
     */
    @JsonProperty(value = "selectedLogins")
    private List<String> selectedLogins;

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

    /*
     * SAS URI of Azure Storage Account Container to be used for storing backup files.
     */
    @JsonProperty(value = "backupBlobShare", required = true)
    private BlobShare backupBlobShare;

    /*
     * Backup Mode to specify whether to use existing backup or create new backup.
     */
    @JsonProperty(value = "backupMode")
    private BackupMode backupMode;

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

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

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

    /**
     * Get the targetConnectionInfo property: Information for connecting to target.
     *
     * @return the targetConnectionInfo value.
     */
    public SqlConnectionInfo targetConnectionInfo() {
        return this.targetConnectionInfo;
    }

    /**
     * Set the targetConnectionInfo property: Information for connecting to target.
     *
     * @param targetConnectionInfo the targetConnectionInfo value to set.
     * @return the ValidateMigrationInputSqlServerSqlMITaskInput object itself.
     */
    public ValidateMigrationInputSqlServerSqlMITaskInput withTargetConnectionInfo(
        SqlConnectionInfo targetConnectionInfo) {
        this.targetConnectionInfo = targetConnectionInfo;
        return this;
    }

    /**
     * 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 ValidateMigrationInputSqlServerSqlMITaskInput object itself.
     */
    public ValidateMigrationInputSqlServerSqlMITaskInput withSelectedDatabases(
        List<MigrateSqlServerSqlMIDatabaseInput> selectedDatabases) {
        this.selectedDatabases = selectedDatabases;
        return this;
    }

    /**
     * Get the selectedLogins property: Logins to migrate.
     *
     * @return the selectedLogins value.
     */
    public List<String> selectedLogins() {
        return this.selectedLogins;
    }

    /**
     * Set the selectedLogins property: Logins to migrate.
     *
     * @param selectedLogins the selectedLogins value to set.
     * @return the ValidateMigrationInputSqlServerSqlMITaskInput object itself.
     */
    public ValidateMigrationInputSqlServerSqlMITaskInput withSelectedLogins(List<String> selectedLogins) {
        this.selectedLogins = selectedLogins;
        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 ValidateMigrationInputSqlServerSqlMITaskInput object itself.
     */
    public ValidateMigrationInputSqlServerSqlMITaskInput withBackupFileShare(FileShare backupFileShare) {
        this.backupFileShare = backupFileShare;
        return this;
    }

    /**
     * Get the backupBlobShare property: SAS URI of Azure Storage Account Container to be used for storing backup files.
     *
     * @return the backupBlobShare value.
     */
    public BlobShare backupBlobShare() {
        return this.backupBlobShare;
    }

    /**
     * Set the backupBlobShare property: SAS URI of Azure Storage Account Container to be used for storing backup files.
     *
     * @param backupBlobShare the backupBlobShare value to set.
     * @return the ValidateMigrationInputSqlServerSqlMITaskInput object itself.
     */
    public ValidateMigrationInputSqlServerSqlMITaskInput withBackupBlobShare(BlobShare backupBlobShare) {
        this.backupBlobShare = backupBlobShare;
        return this;
    }

    /**
     * Get the backupMode property: Backup Mode to specify whether to use existing backup or create new backup.
     *
     * @return the backupMode value.
     */
    public BackupMode backupMode() {
        return this.backupMode;
    }

    /**
     * Set the backupMode property: Backup Mode to specify whether to use existing backup or create new backup.
     *
     * @param backupMode the backupMode value to set.
     * @return the ValidateMigrationInputSqlServerSqlMITaskInput object itself.
     */
    public ValidateMigrationInputSqlServerSqlMITaskInput withBackupMode(BackupMode backupMode) {
        this.backupMode = backupMode;
        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"
                            + " ValidateMigrationInputSqlServerSqlMITaskInput"));
        } else {
            sourceConnectionInfo().validate();
        }
        if (targetConnectionInfo() == null) {
            throw LOGGER
                .logExceptionAsError(
                    new IllegalArgumentException(
                        "Missing required property targetConnectionInfo in model"
                            + " ValidateMigrationInputSqlServerSqlMITaskInput"));
        } else {
            targetConnectionInfo().validate();
        }
        if (selectedDatabases() == null) {
            throw LOGGER
                .logExceptionAsError(
                    new IllegalArgumentException(
                        "Missing required property selectedDatabases in model"
                            + " ValidateMigrationInputSqlServerSqlMITaskInput"));
        } else {
            selectedDatabases().forEach(e -> e.validate());
        }
        if (backupFileShare() != null) {
            backupFileShare().validate();
        }
        if (backupBlobShare() == null) {
            throw LOGGER
                .logExceptionAsError(
                    new IllegalArgumentException(
                        "Missing required property backupBlobShare in model"
                            + " ValidateMigrationInputSqlServerSqlMITaskInput"));
        } else {
            backupBlobShare().validate();
        }
    }

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