// 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 for online migrations. */
@Fluent
public final class MigrateSqlServerSqlDbSyncTaskInput extends SqlMigrationTaskInput {
    /*
     * Databases to migrate
     */
    @JsonProperty(value = "selectedDatabases", required = true)
    private List<MigrateSqlServerSqlDbSyncDatabaseInput> selectedDatabases;

    /*
     * Validation options
     */
    @JsonProperty(value = "validationOptions")
    private MigrationValidationOptions validationOptions;

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

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

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

    /**
     * Get the validationOptions property: Validation options.
     *
     * @return the validationOptions value.
     */
    public MigrationValidationOptions validationOptions() {
        return this.validationOptions;
    }

    /**
     * Set the validationOptions property: Validation options.
     *
     * @param validationOptions the validationOptions value to set.
     * @return the MigrateSqlServerSqlDbSyncTaskInput object itself.
     */
    public MigrateSqlServerSqlDbSyncTaskInput withValidationOptions(MigrationValidationOptions validationOptions) {
        this.validationOptions = validationOptions;
        return this;
    }

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

    /** {@inheritDoc} */
    @Override
    public MigrateSqlServerSqlDbSyncTaskInput 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 MigrateSqlServerSqlDbSyncTaskInput"));
        } else {
            selectedDatabases().forEach(e -> e.validate());
        }
        if (validationOptions() != null) {
            validationOptions().validate();
        }
    }

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