// 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.OperationEntityBaseContract;
import com.azure.resourcemanager.apimanagement.models.ParameterContract;
import com.azure.resourcemanager.apimanagement.models.RequestContract;
import com.azure.resourcemanager.apimanagement.models.ResponseContract;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.List;

/** Operation Contract Properties. */
@Fluent
public final class OperationContractProperties extends OperationEntityBaseContract {
    /*
     * Operation Name.
     */
    @JsonProperty(value = "displayName", required = true)
    private String displayName;

    /*
     * A Valid HTTP Operation Method. Typical Http Methods like GET, PUT, POST
     * but not limited by only them.
     */
    @JsonProperty(value = "method", required = true)
    private String method;

    /*
     * Relative URL template identifying the target resource for this
     * operation. May include parameters. Example:
     * /customers/{cid}/orders/{oid}/?date={date}
     */
    @JsonProperty(value = "urlTemplate", required = true)
    private String urlTemplate;

    /**
     * Get the displayName property: Operation Name.
     *
     * @return the displayName value.
     */
    public String displayName() {
        return this.displayName;
    }

    /**
     * Set the displayName property: Operation Name.
     *
     * @param displayName the displayName value to set.
     * @return the OperationContractProperties object itself.
     */
    public OperationContractProperties withDisplayName(String displayName) {
        this.displayName = displayName;
        return this;
    }

    /**
     * Get the method property: A Valid HTTP Operation Method. Typical Http Methods like GET, PUT, POST but not limited
     * by only them.
     *
     * @return the method value.
     */
    public String method() {
        return this.method;
    }

    /**
     * Set the method property: A Valid HTTP Operation Method. Typical Http Methods like GET, PUT, POST but not limited
     * by only them.
     *
     * @param method the method value to set.
     * @return the OperationContractProperties object itself.
     */
    public OperationContractProperties withMethod(String method) {
        this.method = method;
        return this;
    }

    /**
     * Get the urlTemplate property: Relative URL template identifying the target resource for this operation. May
     * include parameters. Example: /customers/{cid}/orders/{oid}/?date={date}.
     *
     * @return the urlTemplate value.
     */
    public String urlTemplate() {
        return this.urlTemplate;
    }

    /**
     * Set the urlTemplate property: Relative URL template identifying the target resource for this operation. May
     * include parameters. Example: /customers/{cid}/orders/{oid}/?date={date}.
     *
     * @param urlTemplate the urlTemplate value to set.
     * @return the OperationContractProperties object itself.
     */
    public OperationContractProperties withUrlTemplate(String urlTemplate) {
        this.urlTemplate = urlTemplate;
        return this;
    }

    /** {@inheritDoc} */
    @Override
    public OperationContractProperties withTemplateParameters(List<ParameterContract> templateParameters) {
        super.withTemplateParameters(templateParameters);
        return this;
    }

    /** {@inheritDoc} */
    @Override
    public OperationContractProperties withDescription(String description) {
        super.withDescription(description);
        return this;
    }

    /** {@inheritDoc} */
    @Override
    public OperationContractProperties withRequest(RequestContract request) {
        super.withRequest(request);
        return this;
    }

    /** {@inheritDoc} */
    @Override
    public OperationContractProperties withResponses(List<ResponseContract> responses) {
        super.withResponses(responses);
        return this;
    }

    /** {@inheritDoc} */
    @Override
    public OperationContractProperties withPolicies(String policies) {
        super.withPolicies(policies);
        return this;
    }

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

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