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

package com.azure.resourcemanager.networkcloud.models;

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

/** ImageRepositoryCredentials represents the credentials used to login to the image repository. */
@Fluent
public final class ImageRepositoryCredentials {
    /*
     * The password or token used to access an image in the target repository.
     */
    @JsonProperty(value = "password", required = true)
    private String password;

    /*
     * The URL of the authentication server used to validate the repository credentials.
     */
    @JsonProperty(value = "registryUrl", required = true)
    private String registryUrl;

    /*
     * The username used to access an image in the target repository.
     */
    @JsonProperty(value = "username", required = true)
    private String username;

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

    /**
     * Get the password property: The password or token used to access an image in the target repository.
     *
     * @return the password value.
     */
    public String password() {
        return this.password;
    }

    /**
     * Set the password property: The password or token used to access an image in the target repository.
     *
     * @param password the password value to set.
     * @return the ImageRepositoryCredentials object itself.
     */
    public ImageRepositoryCredentials withPassword(String password) {
        this.password = password;
        return this;
    }

    /**
     * Get the registryUrl property: The URL of the authentication server used to validate the repository credentials.
     *
     * @return the registryUrl value.
     */
    public String registryUrl() {
        return this.registryUrl;
    }

    /**
     * Set the registryUrl property: The URL of the authentication server used to validate the repository credentials.
     *
     * @param registryUrl the registryUrl value to set.
     * @return the ImageRepositoryCredentials object itself.
     */
    public ImageRepositoryCredentials withRegistryUrl(String registryUrl) {
        this.registryUrl = registryUrl;
        return this;
    }

    /**
     * Get the username property: The username used to access an image in the target repository.
     *
     * @return the username value.
     */
    public String username() {
        return this.username;
    }

    /**
     * Set the username property: The username used to access an image in the target repository.
     *
     * @param username the username value to set.
     * @return the ImageRepositoryCredentials object itself.
     */
    public ImageRepositoryCredentials withUsername(String username) {
        this.username = username;
        return this;
    }

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

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