// 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;

/** The properties that make up a REST request. */
@Fluent
public final class RestRequest {
    /*
     * The HTTP method to use for the request.
     */
    @JsonProperty(value = "method", required = true)
    private RestRequestMethod method;

    /*
     * The HTTP URI to use for the request.
     */
    @JsonProperty(value = "uri", required = true)
    private String uri;

    /*
     * The authentication information required in the request to the health provider.
     */
    @JsonProperty(value = "authentication", required = true)
    private RestRequestAuthentication authentication;

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

    /**
     * Get the method property: The HTTP method to use for the request.
     *
     * @return the method value.
     */
    public RestRequestMethod method() {
        return this.method;
    }

    /**
     * Set the method property: The HTTP method to use for the request.
     *
     * @param method the method value to set.
     * @return the RestRequest object itself.
     */
    public RestRequest withMethod(RestRequestMethod method) {
        this.method = method;
        return this;
    }

    /**
     * Get the uri property: The HTTP URI to use for the request.
     *
     * @return the uri value.
     */
    public String uri() {
        return this.uri;
    }

    /**
     * Set the uri property: The HTTP URI to use for the request.
     *
     * @param uri the uri value to set.
     * @return the RestRequest object itself.
     */
    public RestRequest withUri(String uri) {
        this.uri = uri;
        return this;
    }

    /**
     * Get the authentication property: The authentication information required in the request to the health provider.
     *
     * @return the authentication value.
     */
    public RestRequestAuthentication authentication() {
        return this.authentication;
    }

    /**
     * Set the authentication property: The authentication information required in the request to the health provider.
     *
     * @param authentication the authentication value to set.
     * @return the RestRequest object itself.
     */
    public RestRequest withAuthentication(RestRequestAuthentication authentication) {
        this.authentication = authentication;
        return this;
    }

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

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