// 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 the task that migrates on-prem SQL Server databases to Azure SQL Database. */
@Fluent
public final class MigrateSqlServerSqlDbTaskInput extends SqlMigrationTaskInput {
    /*
     * Databases to migrate
     */
    @JsonProperty(value = "selectedDatabases", required = true)
    private List<MigrateSqlServerSqlDbDatabaseInput> selectedDatabases;

    /*
     * Options for enabling various post migration validations. Available options,
     * 1.) Data Integrity Check: Performs a checksum based comparison on source and target tables after the migration
     * to ensure the correctness of the data.
     * 2.) Schema Validation: Performs a thorough schema comparison between the source and target tables and provides a
     * list of differences between the source and target database, 3.) Query Analysis: Executes a set of queries picked
     * up automatically either from the Query Plan Cache or Query Store and execute them and compares the execution
     * time between the source and target database.
     */
    @JsonProperty(value = "validationOptions")
    private MigrationValidationOptions validationOptions;

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

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

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

    /**
     * Get the validationOptions property: Options for enabling various post migration validations. Available options,
     * 1.) Data Integrity Check: Performs a checksum based comparison on source and target tables after the migration to
     * ensure the correctness of the data. 2.) Schema Validation: Performs a thorough schema comparison between the
     * source and target tables and provides a list of differences between the source and target database, 3.) Query
     * Analysis: Executes a set of queries picked up automatically either from the Query Plan Cache or Query Store and
     * execute them and compares the execution time between the source and target database.
     *
     * @return the validationOptions value.
     */
    public MigrationValidationOptions validationOptions() {
        return this.validationOptions;
    }

    /**
     * Set the validationOptions property: Options for enabling various post migration validations. Available options,
     * 1.) Data Integrity Check: Performs a checksum based comparison on source and target tables after the migration to
     * ensure the correctness of the data. 2.) Schema Validation: Performs a thorough schema comparison between the
     * source and target tables and provides a list of differences between the source and target database, 3.) Query
     * Analysis: Executes a set of queries picked up automatically either from the Query Plan Cache or Query Store and
     * execute them and compares the execution time between the source and target database.
     *
     * @param validationOptions the validationOptions value to set.
     * @return the MigrateSqlServerSqlDbTaskInput object itself.
     */
    public MigrateSqlServerSqlDbTaskInput withValidationOptions(MigrationValidationOptions validationOptions) {
        this.validationOptions = validationOptions;
        return this;
    }

    /** {@inheritDoc} */
    @Override
    public MigrateSqlServerSqlDbTaskInput withSourceConnectionInfo(SqlConnectionInfo sourceConnectionInfo) {
        super.withSourceConnectionInfo(sourceConnectionInfo);
        return this;
    }

    /** {@inheritDoc} */
    @Override
    public MigrateSqlServerSqlDbTaskInput withTargetConnectionInfo(SqlConnectionInfo targetConnectionInfo) {
        super.withTargetConnectionInfo(targetConnectionInfo);
        return this;
    }

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

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