// 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 com.fasterxml.jackson.annotation.JsonTypeInfo;
import com.fasterxml.jackson.annotation.JsonTypeName;

/** Properties required to create a connection to Azure SQL database Managed instance. */
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "type")
@JsonTypeName("MiSqlConnectionInfo")
@Fluent
public final class MiSqlConnectionInfo extends ConnectionInfo {
    /*
     * Resource id for Azure SQL database Managed instance
     */
    @JsonProperty(value = "managedInstanceResourceId", required = true)
    private String managedInstanceResourceId;

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

    /**
     * Get the managedInstanceResourceId property: Resource id for Azure SQL database Managed instance.
     *
     * @return the managedInstanceResourceId value.
     */
    public String managedInstanceResourceId() {
        return this.managedInstanceResourceId;
    }

    /**
     * Set the managedInstanceResourceId property: Resource id for Azure SQL database Managed instance.
     *
     * @param managedInstanceResourceId the managedInstanceResourceId value to set.
     * @return the MiSqlConnectionInfo object itself.
     */
    public MiSqlConnectionInfo withManagedInstanceResourceId(String managedInstanceResourceId) {
        this.managedInstanceResourceId = managedInstanceResourceId;
        return this;
    }

    /** {@inheritDoc} */
    @Override
    public MiSqlConnectionInfo withUsername(String username) {
        super.withUsername(username);
        return this;
    }

    /** {@inheritDoc} */
    @Override
    public MiSqlConnectionInfo withPassword(String password) {
        super.withPassword(password);
        return this;
    }

    /**
     * Validates the instance.
     *
     * @throws IllegalArgumentException thrown if the instance is not valid.
     */
    @Override
    public void validate() {
        super.validate();
        if (managedInstanceResourceId() == null) {
            throw LOGGER
                .logExceptionAsError(
                    new IllegalArgumentException(
                        "Missing required property managedInstanceResourceId in model MiSqlConnectionInfo"));
        }
    }

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