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

package com.azure.resourcemanager.servicefabric.models;

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

/** Specifies a metric to load balance a service during runtime. */
@Fluent
public final class ServiceLoadMetricDescription {
    /*
     * The name of the metric. If the service chooses to report load during runtime, the load metric name should match
     * the name that is specified in Name exactly. Note that metric names are case sensitive.
     */
    @JsonProperty(value = "name", required = true)
    private String name;

    /*
     * The service load metric relative weight, compared to other metrics configured for this service, as a number.
     */
    @JsonProperty(value = "weight")
    private ServiceLoadMetricWeight weight;

    /*
     * Used only for Stateful services. The default amount of load, as a number, that this service creates for this
     * metric when it is a Primary replica.
     */
    @JsonProperty(value = "primaryDefaultLoad")
    private Integer primaryDefaultLoad;

    /*
     * Used only for Stateful services. The default amount of load, as a number, that this service creates for this
     * metric when it is a Secondary replica.
     */
    @JsonProperty(value = "secondaryDefaultLoad")
    private Integer secondaryDefaultLoad;

    /*
     * Used only for Stateless services. The default amount of load, as a number, that this service creates for this
     * metric.
     */
    @JsonProperty(value = "defaultLoad")
    private Integer defaultLoad;

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

    /**
     * Get the name property: The name of the metric. If the service chooses to report load during runtime, the load
     * metric name should match the name that is specified in Name exactly. Note that metric names are case sensitive.
     *
     * @return the name value.
     */
    public String name() {
        return this.name;
    }

    /**
     * Set the name property: The name of the metric. If the service chooses to report load during runtime, the load
     * metric name should match the name that is specified in Name exactly. Note that metric names are case sensitive.
     *
     * @param name the name value to set.
     * @return the ServiceLoadMetricDescription object itself.
     */
    public ServiceLoadMetricDescription withName(String name) {
        this.name = name;
        return this;
    }

    /**
     * Get the weight property: The service load metric relative weight, compared to other metrics configured for this
     * service, as a number.
     *
     * @return the weight value.
     */
    public ServiceLoadMetricWeight weight() {
        return this.weight;
    }

    /**
     * Set the weight property: The service load metric relative weight, compared to other metrics configured for this
     * service, as a number.
     *
     * @param weight the weight value to set.
     * @return the ServiceLoadMetricDescription object itself.
     */
    public ServiceLoadMetricDescription withWeight(ServiceLoadMetricWeight weight) {
        this.weight = weight;
        return this;
    }

    /**
     * Get the primaryDefaultLoad property: Used only for Stateful services. The default amount of load, as a number,
     * that this service creates for this metric when it is a Primary replica.
     *
     * @return the primaryDefaultLoad value.
     */
    public Integer primaryDefaultLoad() {
        return this.primaryDefaultLoad;
    }

    /**
     * Set the primaryDefaultLoad property: Used only for Stateful services. The default amount of load, as a number,
     * that this service creates for this metric when it is a Primary replica.
     *
     * @param primaryDefaultLoad the primaryDefaultLoad value to set.
     * @return the ServiceLoadMetricDescription object itself.
     */
    public ServiceLoadMetricDescription withPrimaryDefaultLoad(Integer primaryDefaultLoad) {
        this.primaryDefaultLoad = primaryDefaultLoad;
        return this;
    }

    /**
     * Get the secondaryDefaultLoad property: Used only for Stateful services. The default amount of load, as a number,
     * that this service creates for this metric when it is a Secondary replica.
     *
     * @return the secondaryDefaultLoad value.
     */
    public Integer secondaryDefaultLoad() {
        return this.secondaryDefaultLoad;
    }

    /**
     * Set the secondaryDefaultLoad property: Used only for Stateful services. The default amount of load, as a number,
     * that this service creates for this metric when it is a Secondary replica.
     *
     * @param secondaryDefaultLoad the secondaryDefaultLoad value to set.
     * @return the ServiceLoadMetricDescription object itself.
     */
    public ServiceLoadMetricDescription withSecondaryDefaultLoad(Integer secondaryDefaultLoad) {
        this.secondaryDefaultLoad = secondaryDefaultLoad;
        return this;
    }

    /**
     * Get the defaultLoad property: Used only for Stateless services. The default amount of load, as a number, that
     * this service creates for this metric.
     *
     * @return the defaultLoad value.
     */
    public Integer defaultLoad() {
        return this.defaultLoad;
    }

    /**
     * Set the defaultLoad property: Used only for Stateless services. The default amount of load, as a number, that
     * this service creates for this metric.
     *
     * @param defaultLoad the defaultLoad value to set.
     * @return the ServiceLoadMetricDescription object itself.
     */
    public ServiceLoadMetricDescription withDefaultLoad(Integer defaultLoad) {
        this.defaultLoad = defaultLoad;
        return this;
    }

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

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