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

package com.azure.resourcemanager.mobilenetwork.models;

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

/** Data flow policy rule configuration. */
@Fluent
public final class PccRuleConfiguration {
    /*
     * The name of the rule. This must be unique within the parent service. You must not use any of the following
     * reserved strings - `default`, `requested` or `service`.
     */
    @JsonProperty(value = "ruleName", required = true)
    private String ruleName;

    /*
     * A precedence value that is used to decide between data flow policy rules when identifying the QoS values to use
     * for a particular SIM. A lower value means a higher priority. This value should be unique among all data flow
     * policy rules configured in the mobile network.
     */
    @JsonProperty(value = "rulePrecedence", required = true)
    private int rulePrecedence;

    /*
     * The QoS policy to use for packets matching this rule. If this field is null then the parent service will define
     * the QoS settings.
     */
    @JsonProperty(value = "ruleQosPolicy")
    private PccRuleQosPolicy ruleQosPolicy;

    /*
     * Determines whether flows that match this data flow policy rule are permitted.
     */
    @JsonProperty(value = "trafficControl")
    private TrafficControlPermission trafficControl;

    /*
     * The set of data flow templates to use for this data flow policy rule.
     */
    @JsonProperty(value = "serviceDataFlowTemplates", required = true)
    private List<ServiceDataFlowTemplate> serviceDataFlowTemplates;

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

    /**
     * Get the ruleName property: The name of the rule. This must be unique within the parent service. You must not use
     * any of the following reserved strings - `default`, `requested` or `service`.
     *
     * @return the ruleName value.
     */
    public String ruleName() {
        return this.ruleName;
    }

    /**
     * Set the ruleName property: The name of the rule. This must be unique within the parent service. You must not use
     * any of the following reserved strings - `default`, `requested` or `service`.
     *
     * @param ruleName the ruleName value to set.
     * @return the PccRuleConfiguration object itself.
     */
    public PccRuleConfiguration withRuleName(String ruleName) {
        this.ruleName = ruleName;
        return this;
    }

    /**
     * Get the rulePrecedence property: A precedence value that is used to decide between data flow policy rules when
     * identifying the QoS values to use for a particular SIM. A lower value means a higher priority. This value should
     * be unique among all data flow policy rules configured in the mobile network.
     *
     * @return the rulePrecedence value.
     */
    public int rulePrecedence() {
        return this.rulePrecedence;
    }

    /**
     * Set the rulePrecedence property: A precedence value that is used to decide between data flow policy rules when
     * identifying the QoS values to use for a particular SIM. A lower value means a higher priority. This value should
     * be unique among all data flow policy rules configured in the mobile network.
     *
     * @param rulePrecedence the rulePrecedence value to set.
     * @return the PccRuleConfiguration object itself.
     */
    public PccRuleConfiguration withRulePrecedence(int rulePrecedence) {
        this.rulePrecedence = rulePrecedence;
        return this;
    }

    /**
     * Get the ruleQosPolicy property: The QoS policy to use for packets matching this rule. If this field is null then
     * the parent service will define the QoS settings.
     *
     * @return the ruleQosPolicy value.
     */
    public PccRuleQosPolicy ruleQosPolicy() {
        return this.ruleQosPolicy;
    }

    /**
     * Set the ruleQosPolicy property: The QoS policy to use for packets matching this rule. If this field is null then
     * the parent service will define the QoS settings.
     *
     * @param ruleQosPolicy the ruleQosPolicy value to set.
     * @return the PccRuleConfiguration object itself.
     */
    public PccRuleConfiguration withRuleQosPolicy(PccRuleQosPolicy ruleQosPolicy) {
        this.ruleQosPolicy = ruleQosPolicy;
        return this;
    }

    /**
     * Get the trafficControl property: Determines whether flows that match this data flow policy rule are permitted.
     *
     * @return the trafficControl value.
     */
    public TrafficControlPermission trafficControl() {
        return this.trafficControl;
    }

    /**
     * Set the trafficControl property: Determines whether flows that match this data flow policy rule are permitted.
     *
     * @param trafficControl the trafficControl value to set.
     * @return the PccRuleConfiguration object itself.
     */
    public PccRuleConfiguration withTrafficControl(TrafficControlPermission trafficControl) {
        this.trafficControl = trafficControl;
        return this;
    }

    /**
     * Get the serviceDataFlowTemplates property: The set of data flow templates to use for this data flow policy rule.
     *
     * @return the serviceDataFlowTemplates value.
     */
    public List<ServiceDataFlowTemplate> serviceDataFlowTemplates() {
        return this.serviceDataFlowTemplates;
    }

    /**
     * Set the serviceDataFlowTemplates property: The set of data flow templates to use for this data flow policy rule.
     *
     * @param serviceDataFlowTemplates the serviceDataFlowTemplates value to set.
     * @return the PccRuleConfiguration object itself.
     */
    public PccRuleConfiguration withServiceDataFlowTemplates(List<ServiceDataFlowTemplate> serviceDataFlowTemplates) {
        this.serviceDataFlowTemplates = serviceDataFlowTemplates;
        return this;
    }

    /**
     * Validates the instance.
     *
     * @throws IllegalArgumentException thrown if the instance is not valid.
     */
    public void validate() {
        if (ruleName() == null) {
            throw LOGGER
                .logExceptionAsError(
                    new IllegalArgumentException("Missing required property ruleName in model PccRuleConfiguration"));
        }
        if (ruleQosPolicy() != null) {
            ruleQosPolicy().validate();
        }
        if (serviceDataFlowTemplates() == null) {
            throw LOGGER
                .logExceptionAsError(
                    new IllegalArgumentException(
                        "Missing required property serviceDataFlowTemplates in model PccRuleConfiguration"));
        } else {
            serviceDataFlowTemplates().forEach(e -> e.validate());
        }
    }

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