// 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.fluent.models;

import com.azure.core.annotation.Fluent;
import com.azure.core.util.logging.ClientLogger;
import com.azure.resourcemanager.mobilenetwork.models.PccRuleConfiguration;
import com.azure.resourcemanager.mobilenetwork.models.ProvisioningState;
import com.azure.resourcemanager.mobilenetwork.models.QosPolicy;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.List;

/** Service properties. */
@Fluent
public final class ServicePropertiesFormat {
    /*
     * The provisioning state of the service resource.
     */
    @JsonProperty(value = "provisioningState", access = JsonProperty.Access.WRITE_ONLY)
    private ProvisioningState provisioningState;

    /*
     * A precedence value that is used to decide between services 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 services configured
     * in the mobile network.
     */
    @JsonProperty(value = "servicePrecedence", required = true)
    private int servicePrecedence;

    /*
     * The QoS policy to use for packets matching this service. This can be overridden for particular flows using the
     * ruleQosPolicy field in a PccRuleConfiguration. If this field is null then the UE's SIM policy will define the
     * QoS settings.
     */
    @JsonProperty(value = "serviceQosPolicy")
    private QosPolicy serviceQosPolicy;

    /*
     * The set of data flow policy rules that make up this service.
     */
    @JsonProperty(value = "pccRules", required = true)
    private List<PccRuleConfiguration> pccRules;

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

    /**
     * Get the provisioningState property: The provisioning state of the service resource.
     *
     * @return the provisioningState value.
     */
    public ProvisioningState provisioningState() {
        return this.provisioningState;
    }

    /**
     * Get the servicePrecedence property: A precedence value that is used to decide between services 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 services configured in the mobile network.
     *
     * @return the servicePrecedence value.
     */
    public int servicePrecedence() {
        return this.servicePrecedence;
    }

    /**
     * Set the servicePrecedence property: A precedence value that is used to decide between services 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 services configured in the mobile network.
     *
     * @param servicePrecedence the servicePrecedence value to set.
     * @return the ServicePropertiesFormat object itself.
     */
    public ServicePropertiesFormat withServicePrecedence(int servicePrecedence) {
        this.servicePrecedence = servicePrecedence;
        return this;
    }

    /**
     * Get the serviceQosPolicy property: The QoS policy to use for packets matching this service. This can be
     * overridden for particular flows using the ruleQosPolicy field in a PccRuleConfiguration. If this field is null
     * then the UE's SIM policy will define the QoS settings.
     *
     * @return the serviceQosPolicy value.
     */
    public QosPolicy serviceQosPolicy() {
        return this.serviceQosPolicy;
    }

    /**
     * Set the serviceQosPolicy property: The QoS policy to use for packets matching this service. This can be
     * overridden for particular flows using the ruleQosPolicy field in a PccRuleConfiguration. If this field is null
     * then the UE's SIM policy will define the QoS settings.
     *
     * @param serviceQosPolicy the serviceQosPolicy value to set.
     * @return the ServicePropertiesFormat object itself.
     */
    public ServicePropertiesFormat withServiceQosPolicy(QosPolicy serviceQosPolicy) {
        this.serviceQosPolicy = serviceQosPolicy;
        return this;
    }

    /**
     * Get the pccRules property: The set of data flow policy rules that make up this service.
     *
     * @return the pccRules value.
     */
    public List<PccRuleConfiguration> pccRules() {
        return this.pccRules;
    }

    /**
     * Set the pccRules property: The set of data flow policy rules that make up this service.
     *
     * @param pccRules the pccRules value to set.
     * @return the ServicePropertiesFormat object itself.
     */
    public ServicePropertiesFormat withPccRules(List<PccRuleConfiguration> pccRules) {
        this.pccRules = pccRules;
        return this;
    }

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

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