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

package com.azure.resourcemanager.apimanagement.fluent.models;

import com.azure.core.annotation.Fluent;
import com.azure.core.util.logging.ClientLogger;
import com.azure.resourcemanager.apimanagement.models.AppType;
import com.azure.resourcemanager.apimanagement.models.Confirmation;
import com.azure.resourcemanager.apimanagement.models.UserEntityBaseParameters;
import com.azure.resourcemanager.apimanagement.models.UserState;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.List;

/** Parameters supplied to the Create User operation. */
@Fluent
public final class UserCreateParameterProperties extends UserEntityBaseParameters {
    /*
     * Email address. Must not be empty and must be unique within the service
     * instance.
     */
    @JsonProperty(value = "email", required = true)
    private String email;

    /*
     * First name.
     */
    @JsonProperty(value = "firstName", required = true)
    private String firstName;

    /*
     * Last name.
     */
    @JsonProperty(value = "lastName", required = true)
    private String lastName;

    /*
     * User Password. If no value is provided, a default password is generated.
     */
    @JsonProperty(value = "password")
    private String password;

    /*
     * Determines the type of application which send the create user request.
     * Default is legacy portal.
     */
    @JsonProperty(value = "appType")
    private AppType appType;

    /*
     * Determines the type of confirmation e-mail that will be sent to the
     * newly created user.
     */
    @JsonProperty(value = "confirmation")
    private Confirmation confirmation;

    /**
     * Get the email property: Email address. Must not be empty and must be unique within the service instance.
     *
     * @return the email value.
     */
    public String email() {
        return this.email;
    }

    /**
     * Set the email property: Email address. Must not be empty and must be unique within the service instance.
     *
     * @param email the email value to set.
     * @return the UserCreateParameterProperties object itself.
     */
    public UserCreateParameterProperties withEmail(String email) {
        this.email = email;
        return this;
    }

    /**
     * Get the firstName property: First name.
     *
     * @return the firstName value.
     */
    public String firstName() {
        return this.firstName;
    }

    /**
     * Set the firstName property: First name.
     *
     * @param firstName the firstName value to set.
     * @return the UserCreateParameterProperties object itself.
     */
    public UserCreateParameterProperties withFirstName(String firstName) {
        this.firstName = firstName;
        return this;
    }

    /**
     * Get the lastName property: Last name.
     *
     * @return the lastName value.
     */
    public String lastName() {
        return this.lastName;
    }

    /**
     * Set the lastName property: Last name.
     *
     * @param lastName the lastName value to set.
     * @return the UserCreateParameterProperties object itself.
     */
    public UserCreateParameterProperties withLastName(String lastName) {
        this.lastName = lastName;
        return this;
    }

    /**
     * Get the password property: User Password. If no value is provided, a default password is generated.
     *
     * @return the password value.
     */
    public String password() {
        return this.password;
    }

    /**
     * Set the password property: User Password. If no value is provided, a default password is generated.
     *
     * @param password the password value to set.
     * @return the UserCreateParameterProperties object itself.
     */
    public UserCreateParameterProperties withPassword(String password) {
        this.password = password;
        return this;
    }

    /**
     * Get the appType property: Determines the type of application which send the create user request. Default is
     * legacy portal.
     *
     * @return the appType value.
     */
    public AppType appType() {
        return this.appType;
    }

    /**
     * Set the appType property: Determines the type of application which send the create user request. Default is
     * legacy portal.
     *
     * @param appType the appType value to set.
     * @return the UserCreateParameterProperties object itself.
     */
    public UserCreateParameterProperties withAppType(AppType appType) {
        this.appType = appType;
        return this;
    }

    /**
     * Get the confirmation property: Determines the type of confirmation e-mail that will be sent to the newly created
     * user.
     *
     * @return the confirmation value.
     */
    public Confirmation confirmation() {
        return this.confirmation;
    }

    /**
     * Set the confirmation property: Determines the type of confirmation e-mail that will be sent to the newly created
     * user.
     *
     * @param confirmation the confirmation value to set.
     * @return the UserCreateParameterProperties object itself.
     */
    public UserCreateParameterProperties withConfirmation(Confirmation confirmation) {
        this.confirmation = confirmation;
        return this;
    }

    /** {@inheritDoc} */
    @Override
    public UserCreateParameterProperties withState(UserState state) {
        super.withState(state);
        return this;
    }

    /** {@inheritDoc} */
    @Override
    public UserCreateParameterProperties withNote(String note) {
        super.withNote(note);
        return this;
    }

    /** {@inheritDoc} */
    @Override
    public UserCreateParameterProperties withIdentities(List<UserIdentityContractInner> identities) {
        super.withIdentities(identities);
        return this;
    }

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

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