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

package com.azure.resourcemanager.providerhub.models;

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

/** The ThrottlingMetric model. */
@Fluent
public final class ThrottlingMetric {
    /*
     * The type property.
     */
    @JsonProperty(value = "type", required = true)
    private ThrottlingMetricType type;

    /*
     * The limit property.
     */
    @JsonProperty(value = "limit", required = true)
    private long limit;

    /*
     * The interval property.
     */
    @JsonProperty(value = "interval")
    private Duration interval;

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

    /**
     * Get the type property: The type property.
     *
     * @return the type value.
     */
    public ThrottlingMetricType type() {
        return this.type;
    }

    /**
     * Set the type property: The type property.
     *
     * @param type the type value to set.
     * @return the ThrottlingMetric object itself.
     */
    public ThrottlingMetric withType(ThrottlingMetricType type) {
        this.type = type;
        return this;
    }

    /**
     * Get the limit property: The limit property.
     *
     * @return the limit value.
     */
    public long limit() {
        return this.limit;
    }

    /**
     * Set the limit property: The limit property.
     *
     * @param limit the limit value to set.
     * @return the ThrottlingMetric object itself.
     */
    public ThrottlingMetric withLimit(long limit) {
        this.limit = limit;
        return this;
    }

    /**
     * Get the interval property: The interval property.
     *
     * @return the interval value.
     */
    public Duration interval() {
        return this.interval;
    }

    /**
     * Set the interval property: The interval property.
     *
     * @param interval the interval value to set.
     * @return the ThrottlingMetric object itself.
     */
    public ThrottlingMetric withInterval(Duration interval) {
        this.interval = interval;
        return this;
    }

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

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