// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// Code generated by Microsoft (R) AutoRest Code Generator.

package com.azure.resourcemanager.postgresqlflexibleserver.models;

import com.azure.core.annotation.Fluent;
import com.azure.core.util.logging.ClientLogger;
import com.fasterxml.jackson.annotation.JsonProperty;

/** Migration secret parameters. */
@Fluent
public final class MigrationSecretParameters {
    /*
     * Admin credentials for source and target servers
     */
    @JsonProperty(value = "adminCredentials", required = true)
    private AdminCredentials adminCredentials;

    /*
     * Gets or sets the username for the source server. This user need not be an admin.
     */
    @JsonProperty(value = "sourceServerUsername")
    private String sourceServerUsername;

    /*
     * Gets or sets the username for the target server. This user need not be an admin.
     */
    @JsonProperty(value = "targetServerUsername")
    private String targetServerUsername;

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

    /**
     * Get the adminCredentials property: Admin credentials for source and target servers.
     *
     * @return the adminCredentials value.
     */
    public AdminCredentials adminCredentials() {
        return this.adminCredentials;
    }

    /**
     * Set the adminCredentials property: Admin credentials for source and target servers.
     *
     * @param adminCredentials the adminCredentials value to set.
     * @return the MigrationSecretParameters object itself.
     */
    public MigrationSecretParameters withAdminCredentials(AdminCredentials adminCredentials) {
        this.adminCredentials = adminCredentials;
        return this;
    }

    /**
     * Get the sourceServerUsername property: Gets or sets the username for the source server. This user need not be an
     * admin.
     *
     * @return the sourceServerUsername value.
     */
    public String sourceServerUsername() {
        return this.sourceServerUsername;
    }

    /**
     * Set the sourceServerUsername property: Gets or sets the username for the source server. This user need not be an
     * admin.
     *
     * @param sourceServerUsername the sourceServerUsername value to set.
     * @return the MigrationSecretParameters object itself.
     */
    public MigrationSecretParameters withSourceServerUsername(String sourceServerUsername) {
        this.sourceServerUsername = sourceServerUsername;
        return this;
    }

    /**
     * Get the targetServerUsername property: Gets or sets the username for the target server. This user need not be an
     * admin.
     *
     * @return the targetServerUsername value.
     */
    public String targetServerUsername() {
        return this.targetServerUsername;
    }

    /**
     * Set the targetServerUsername property: Gets or sets the username for the target server. This user need not be an
     * admin.
     *
     * @param targetServerUsername the targetServerUsername value to set.
     * @return the MigrationSecretParameters object itself.
     */
    public MigrationSecretParameters withTargetServerUsername(String targetServerUsername) {
        this.targetServerUsername = targetServerUsername;
        return this;
    }

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

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