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

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

/**
 * ApiKey authentication gives a name and a value that can be included in either the request header or query parameters.
 */
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "type")
@JsonTypeName("ApiKey")
@Fluent
public final class ApiKeyAuthentication extends RestRequestAuthentication {
    /*
     * The key name of the authentication key/value pair.
     */
    @JsonProperty(value = "name", required = true)
    private String name;

    /*
     * The location of the authentication key/value pair in the request.
     */
    @JsonProperty(value = "in", required = true)
    private RestAuthLocation in;

    /*
     * The value of the authentication key/value pair.
     */
    @JsonProperty(value = "value", required = true)
    private String value;

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

    /**
     * Get the name property: The key name of the authentication key/value pair.
     *
     * @return the name value.
     */
    public String name() {
        return this.name;
    }

    /**
     * Set the name property: The key name of the authentication key/value pair.
     *
     * @param name the name value to set.
     * @return the ApiKeyAuthentication object itself.
     */
    public ApiKeyAuthentication withName(String name) {
        this.name = name;
        return this;
    }

    /**
     * Get the in property: The location of the authentication key/value pair in the request.
     *
     * @return the in value.
     */
    public RestAuthLocation in() {
        return this.in;
    }

    /**
     * Set the in property: The location of the authentication key/value pair in the request.
     *
     * @param in the in value to set.
     * @return the ApiKeyAuthentication object itself.
     */
    public ApiKeyAuthentication withIn(RestAuthLocation in) {
        this.in = in;
        return this;
    }

    /**
     * Get the value property: The value of the authentication key/value pair.
     *
     * @return the value value.
     */
    public String value() {
        return this.value;
    }

    /**
     * Set the value property: The value of the authentication key/value pair.
     *
     * @param value the value value to set.
     * @return the ApiKeyAuthentication object itself.
     */
    public ApiKeyAuthentication withValue(String value) {
        this.value = value;
        return this;
    }

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

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