// 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.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import com.fasterxml.jackson.annotation.JsonTypeName;
import java.util.Map;

/** Validation result for Sql Server to Azure Sql DB migration. */
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "resultType")
@JsonTypeName("MigrationValidationOutput")
@Fluent
public final class MigrateSqlServerSqlDbTaskOutputValidationResult extends MigrateSqlServerSqlDbTaskOutput {
    /*
     * Migration Identifier
     */
    @JsonProperty(value = "migrationId", access = JsonProperty.Access.WRITE_ONLY)
    private String migrationId;

    /*
     * Validation summary results for each database
     */
    @JsonProperty(value = "summaryResults")
    @JsonInclude(value = JsonInclude.Include.NON_NULL, content = JsonInclude.Include.ALWAYS)
    private Map<String, MigrationValidationDatabaseSummaryResult> summaryResults;

    /*
     * Current status of validation at the migration level. Status from the database validation result status will be
     * aggregated here.
     */
    @JsonProperty(value = "status", access = JsonProperty.Access.WRITE_ONLY)
    private ValidationStatus status;

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

    /**
     * Get the migrationId property: Migration Identifier.
     *
     * @return the migrationId value.
     */
    public String migrationId() {
        return this.migrationId;
    }

    /**
     * Get the summaryResults property: Validation summary results for each database.
     *
     * @return the summaryResults value.
     */
    public Map<String, MigrationValidationDatabaseSummaryResult> summaryResults() {
        return this.summaryResults;
    }

    /**
     * Set the summaryResults property: Validation summary results for each database.
     *
     * @param summaryResults the summaryResults value to set.
     * @return the MigrateSqlServerSqlDbTaskOutputValidationResult object itself.
     */
    public MigrateSqlServerSqlDbTaskOutputValidationResult withSummaryResults(
        Map<String, MigrationValidationDatabaseSummaryResult> summaryResults) {
        this.summaryResults = summaryResults;
        return this;
    }

    /**
     * Get the status property: Current status of validation at the migration level. Status from the database validation
     * result status will be aggregated here.
     *
     * @return the status value.
     */
    public ValidationStatus status() {
        return this.status;
    }

    /**
     * Validates the instance.
     *
     * @throws IllegalArgumentException thrown if the instance is not valid.
     */
    @Override
    public void validate() {
        super.validate();
        if (summaryResults() != null) {
            summaryResults()
                .values()
                .forEach(
                    e -> {
                        if (e != null) {
                            e.validate();
                        }
                    });
        }
    }
}
