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

package com.azure.resourcemanager.videoanalyzer.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;

/** Username and password credentials. */
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "@type")
@JsonTypeName("#Microsoft.VideoAnalyzer.UsernamePasswordCredentials")
@Fluent
public final class UsernamePasswordCredentials extends CredentialsBase {
    /*
     * Username to be presented as part of the credentials.
     */
    @JsonProperty(value = "username", required = true)
    private String username;

    /*
     * Password to be presented as part of the credentials. It is recommended
     * that this value is parameterized as a secret string in order to prevent
     * this value to be returned as part of the resource on API requests.
     */
    @JsonProperty(value = "password", required = true)
    private String password;

    /**
     * Get the username property: Username to be presented as part of the credentials.
     *
     * @return the username value.
     */
    public String username() {
        return this.username;
    }

    /**
     * Set the username property: Username to be presented as part of the credentials.
     *
     * @param username the username value to set.
     * @return the UsernamePasswordCredentials object itself.
     */
    public UsernamePasswordCredentials withUsername(String username) {
        this.username = username;
        return this;
    }

    /**
     * Get the password property: Password to be presented as part of the credentials. It is recommended that this value
     * is parameterized as a secret string in order to prevent this value to be returned as part of the resource on API
     * requests.
     *
     * @return the password value.
     */
    public String password() {
        return this.password;
    }

    /**
     * Set the password property: Password to be presented as part of the credentials. It is recommended that this value
     * is parameterized as a secret string in order to prevent this value to be returned as part of the resource on API
     * requests.
     *
     * @param password the password value to set.
     * @return the UsernamePasswordCredentials object itself.
     */
    public UsernamePasswordCredentials withPassword(String password) {
        this.password = password;
        return this;
    }

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

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