// 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.fluent.models;

import com.azure.core.annotation.Fluent;
import com.azure.core.util.logging.ClientLogger;
import com.azure.resourcemanager.datamigration.models.ConnectionInfo;
import com.azure.resourcemanager.datamigration.models.DatabaseInfo;
import com.azure.resourcemanager.datamigration.models.ProjectProvisioningState;
import com.azure.resourcemanager.datamigration.models.ProjectSourcePlatform;
import com.azure.resourcemanager.datamigration.models.ProjectTargetPlatform;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.time.OffsetDateTime;
import java.util.List;

/** Project-specific properties. */
@Fluent
public final class ProjectProperties {
    /*
     * Source platform for the project
     */
    @JsonProperty(value = "sourcePlatform", required = true)
    private ProjectSourcePlatform sourcePlatform;

    /*
     * Target platform for the project
     */
    @JsonProperty(value = "targetPlatform", required = true)
    private ProjectTargetPlatform targetPlatform;

    /*
     * UTC Date and time when project was created
     */
    @JsonProperty(value = "creationTime", access = JsonProperty.Access.WRITE_ONLY)
    private OffsetDateTime creationTime;

    /*
     * Information for connecting to source
     */
    @JsonProperty(value = "sourceConnectionInfo")
    private ConnectionInfo sourceConnectionInfo;

    /*
     * Information for connecting to target
     */
    @JsonProperty(value = "targetConnectionInfo")
    private ConnectionInfo targetConnectionInfo;

    /*
     * List of DatabaseInfo
     */
    @JsonProperty(value = "databasesInfo")
    private List<DatabaseInfo> databasesInfo;

    /*
     * The project's provisioning state
     */
    @JsonProperty(value = "provisioningState", access = JsonProperty.Access.WRITE_ONLY)
    private ProjectProvisioningState provisioningState;

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

    /**
     * Get the sourcePlatform property: Source platform for the project.
     *
     * @return the sourcePlatform value.
     */
    public ProjectSourcePlatform sourcePlatform() {
        return this.sourcePlatform;
    }

    /**
     * Set the sourcePlatform property: Source platform for the project.
     *
     * @param sourcePlatform the sourcePlatform value to set.
     * @return the ProjectProperties object itself.
     */
    public ProjectProperties withSourcePlatform(ProjectSourcePlatform sourcePlatform) {
        this.sourcePlatform = sourcePlatform;
        return this;
    }

    /**
     * Get the targetPlatform property: Target platform for the project.
     *
     * @return the targetPlatform value.
     */
    public ProjectTargetPlatform targetPlatform() {
        return this.targetPlatform;
    }

    /**
     * Set the targetPlatform property: Target platform for the project.
     *
     * @param targetPlatform the targetPlatform value to set.
     * @return the ProjectProperties object itself.
     */
    public ProjectProperties withTargetPlatform(ProjectTargetPlatform targetPlatform) {
        this.targetPlatform = targetPlatform;
        return this;
    }

    /**
     * Get the creationTime property: UTC Date and time when project was created.
     *
     * @return the creationTime value.
     */
    public OffsetDateTime creationTime() {
        return this.creationTime;
    }

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

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

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

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

    /**
     * Get the databasesInfo property: List of DatabaseInfo.
     *
     * @return the databasesInfo value.
     */
    public List<DatabaseInfo> databasesInfo() {
        return this.databasesInfo;
    }

    /**
     * Set the databasesInfo property: List of DatabaseInfo.
     *
     * @param databasesInfo the databasesInfo value to set.
     * @return the ProjectProperties object itself.
     */
    public ProjectProperties withDatabasesInfo(List<DatabaseInfo> databasesInfo) {
        this.databasesInfo = databasesInfo;
        return this;
    }

    /**
     * Get the provisioningState property: The project's provisioning state.
     *
     * @return the provisioningState value.
     */
    public ProjectProvisioningState provisioningState() {
        return this.provisioningState;
    }

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

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