// 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;

/** Settings controlling data network use. */
@Fluent
public final class DataNetworkConfiguration {
    /*
     * A reference to the data network that these settings apply to. The data network must be in the same location as
     * the SIM policy.
     */
    @JsonProperty(value = "dataNetwork", required = true)
    private DataNetworkResourceId dataNetwork;

    /*
     * Aggregate maximum bit rate across all non-GBR QoS flows of a given PDU session. See 3GPP TS23.501 section
     * 5.7.2.6 for a full description of the Session-AMBR.
     */
    @JsonProperty(value = "sessionAmbr", required = true)
    private Ambr sessionAmbr;

    /*
     * Default QoS Flow 5G QoS Indicator value. The 5QI identifies a specific QoS forwarding treatment to be provided
     * to a flow. This must not be a standardized 5QI value corresponding to a GBR (guaranteed bit rate) QoS Flow. The
     * illegal GBR 5QI values are: 1, 2, 3, 4, 65, 66, 67, 71, 72, 73, 74, 75, 76, 82, 83, 84, and 85. See 3GPP
     * TS23.501 section 5.7.2.1 for a full description of the 5QI parameter, and table 5.7.4-1 for the definition of
     * which are the GBR 5QI values.
     */
    @JsonProperty(value = "5qi")
    private Integer fiveQi;

    /*
     * Default QoS Flow allocation and retention priority (ARP) level. Flows with higher priority preempt flows with
     * lower priority, if the settings of `preemptionCapability` and `preemptionVulnerability` allow it. 1 is the
     * highest level of priority. If this field is not specified then `5qi` is used to derive the ARP value. See 3GPP
     * TS23.501 section 5.7.2.2 for a full description of the ARP parameters.
     */
    @JsonProperty(value = "allocationAndRetentionPriorityLevel")
    private Integer allocationAndRetentionPriorityLevel;

    /*
     * Default QoS Flow preemption capability. The preemption capability of a QoS Flow controls whether it can preempt
     * another QoS Flow with a lower priority level. See 3GPP TS23.501 section 5.7.2.2 for a full description of the
     * ARP parameters.
     */
    @JsonProperty(value = "preemptionCapability")
    private PreemptionCapability preemptionCapability;

    /*
     * Default QoS Flow preemption vulnerability. The preemption vulnerability of a QoS Flow controls whether it can be
     * preempted by a QoS Flow with a higher priority level. See 3GPP TS23.501 section 5.7.2.2 for a full description
     * of the ARP parameters.
     */
    @JsonProperty(value = "preemptionVulnerability")
    private PreemptionVulnerability preemptionVulnerability;

    /*
     * The default PDU session type, which is used if the UE does not request a specific session type.
     */
    @JsonProperty(value = "defaultSessionType")
    private PduSessionType defaultSessionType;

    /*
     * Allowed session types in addition to the default session type. Must not duplicate the default session type.
     */
    @JsonProperty(value = "additionalAllowedSessionTypes")
    private List<PduSessionType> additionalAllowedSessionTypes;

    /*
     * List of services that can be used as part of this SIM policy. The list must not contain duplicate items and must
     * contain at least one item. The services must be in the same location as the SIM policy.
     */
    @JsonProperty(value = "allowedServices", required = true)
    private List<ServiceResourceId> allowedServices;

    /*
     * The maximum number of downlink packets to buffer at the user plane for High Latency Communication - Extended
     * Buffering. See 3GPP TS29.272 v15.10.0 section 7.3.188 for a full description. This maximum is not guaranteed
     * because there is a internal limit on buffered packets across all PDU sessions.
     */
    @JsonProperty(value = "maximumNumberOfBufferedPackets")
    private Integer maximumNumberOfBufferedPackets;

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

    /**
     * Get the dataNetwork property: A reference to the data network that these settings apply to. The data network must
     * be in the same location as the SIM policy.
     *
     * @return the dataNetwork value.
     */
    public DataNetworkResourceId dataNetwork() {
        return this.dataNetwork;
    }

    /**
     * Set the dataNetwork property: A reference to the data network that these settings apply to. The data network must
     * be in the same location as the SIM policy.
     *
     * @param dataNetwork the dataNetwork value to set.
     * @return the DataNetworkConfiguration object itself.
     */
    public DataNetworkConfiguration withDataNetwork(DataNetworkResourceId dataNetwork) {
        this.dataNetwork = dataNetwork;
        return this;
    }

    /**
     * Get the sessionAmbr property: Aggregate maximum bit rate across all non-GBR QoS flows of a given PDU session. See
     * 3GPP TS23.501 section 5.7.2.6 for a full description of the Session-AMBR.
     *
     * @return the sessionAmbr value.
     */
    public Ambr sessionAmbr() {
        return this.sessionAmbr;
    }

    /**
     * Set the sessionAmbr property: Aggregate maximum bit rate across all non-GBR QoS flows of a given PDU session. See
     * 3GPP TS23.501 section 5.7.2.6 for a full description of the Session-AMBR.
     *
     * @param sessionAmbr the sessionAmbr value to set.
     * @return the DataNetworkConfiguration object itself.
     */
    public DataNetworkConfiguration withSessionAmbr(Ambr sessionAmbr) {
        this.sessionAmbr = sessionAmbr;
        return this;
    }

    /**
     * Get the fiveQi property: Default QoS Flow 5G QoS Indicator value. The 5QI identifies a specific QoS forwarding
     * treatment to be provided to a flow. This must not be a standardized 5QI value corresponding to a GBR (guaranteed
     * bit rate) QoS Flow. The illegal GBR 5QI values are: 1, 2, 3, 4, 65, 66, 67, 71, 72, 73, 74, 75, 76, 82, 83, 84,
     * and 85. See 3GPP TS23.501 section 5.7.2.1 for a full description of the 5QI parameter, and table 5.7.4-1 for the
     * definition of which are the GBR 5QI values.
     *
     * @return the fiveQi value.
     */
    public Integer fiveQi() {
        return this.fiveQi;
    }

    /**
     * Set the fiveQi property: Default QoS Flow 5G QoS Indicator value. The 5QI identifies a specific QoS forwarding
     * treatment to be provided to a flow. This must not be a standardized 5QI value corresponding to a GBR (guaranteed
     * bit rate) QoS Flow. The illegal GBR 5QI values are: 1, 2, 3, 4, 65, 66, 67, 71, 72, 73, 74, 75, 76, 82, 83, 84,
     * and 85. See 3GPP TS23.501 section 5.7.2.1 for a full description of the 5QI parameter, and table 5.7.4-1 for the
     * definition of which are the GBR 5QI values.
     *
     * @param fiveQi the fiveQi value to set.
     * @return the DataNetworkConfiguration object itself.
     */
    public DataNetworkConfiguration withFiveQi(Integer fiveQi) {
        this.fiveQi = fiveQi;
        return this;
    }

    /**
     * Get the allocationAndRetentionPriorityLevel property: Default QoS Flow allocation and retention priority (ARP)
     * level. Flows with higher priority preempt flows with lower priority, if the settings of `preemptionCapability`
     * and `preemptionVulnerability` allow it. 1 is the highest level of priority. If this field is not specified then
     * `5qi` is used to derive the ARP value. See 3GPP TS23.501 section 5.7.2.2 for a full description of the ARP
     * parameters.
     *
     * @return the allocationAndRetentionPriorityLevel value.
     */
    public Integer allocationAndRetentionPriorityLevel() {
        return this.allocationAndRetentionPriorityLevel;
    }

    /**
     * Set the allocationAndRetentionPriorityLevel property: Default QoS Flow allocation and retention priority (ARP)
     * level. Flows with higher priority preempt flows with lower priority, if the settings of `preemptionCapability`
     * and `preemptionVulnerability` allow it. 1 is the highest level of priority. If this field is not specified then
     * `5qi` is used to derive the ARP value. See 3GPP TS23.501 section 5.7.2.2 for a full description of the ARP
     * parameters.
     *
     * @param allocationAndRetentionPriorityLevel the allocationAndRetentionPriorityLevel value to set.
     * @return the DataNetworkConfiguration object itself.
     */
    public DataNetworkConfiguration withAllocationAndRetentionPriorityLevel(
        Integer allocationAndRetentionPriorityLevel) {
        this.allocationAndRetentionPriorityLevel = allocationAndRetentionPriorityLevel;
        return this;
    }

    /**
     * Get the preemptionCapability property: Default QoS Flow preemption capability. The preemption capability of a QoS
     * Flow controls whether it can preempt another QoS Flow with a lower priority level. See 3GPP TS23.501 section
     * 5.7.2.2 for a full description of the ARP parameters.
     *
     * @return the preemptionCapability value.
     */
    public PreemptionCapability preemptionCapability() {
        return this.preemptionCapability;
    }

    /**
     * Set the preemptionCapability property: Default QoS Flow preemption capability. The preemption capability of a QoS
     * Flow controls whether it can preempt another QoS Flow with a lower priority level. See 3GPP TS23.501 section
     * 5.7.2.2 for a full description of the ARP parameters.
     *
     * @param preemptionCapability the preemptionCapability value to set.
     * @return the DataNetworkConfiguration object itself.
     */
    public DataNetworkConfiguration withPreemptionCapability(PreemptionCapability preemptionCapability) {
        this.preemptionCapability = preemptionCapability;
        return this;
    }

    /**
     * Get the preemptionVulnerability property: Default QoS Flow preemption vulnerability. The preemption vulnerability
     * of a QoS Flow controls whether it can be preempted by a QoS Flow with a higher priority level. See 3GPP TS23.501
     * section 5.7.2.2 for a full description of the ARP parameters.
     *
     * @return the preemptionVulnerability value.
     */
    public PreemptionVulnerability preemptionVulnerability() {
        return this.preemptionVulnerability;
    }

    /**
     * Set the preemptionVulnerability property: Default QoS Flow preemption vulnerability. The preemption vulnerability
     * of a QoS Flow controls whether it can be preempted by a QoS Flow with a higher priority level. See 3GPP TS23.501
     * section 5.7.2.2 for a full description of the ARP parameters.
     *
     * @param preemptionVulnerability the preemptionVulnerability value to set.
     * @return the DataNetworkConfiguration object itself.
     */
    public DataNetworkConfiguration withPreemptionVulnerability(PreemptionVulnerability preemptionVulnerability) {
        this.preemptionVulnerability = preemptionVulnerability;
        return this;
    }

    /**
     * Get the defaultSessionType property: The default PDU session type, which is used if the UE does not request a
     * specific session type.
     *
     * @return the defaultSessionType value.
     */
    public PduSessionType defaultSessionType() {
        return this.defaultSessionType;
    }

    /**
     * Set the defaultSessionType property: The default PDU session type, which is used if the UE does not request a
     * specific session type.
     *
     * @param defaultSessionType the defaultSessionType value to set.
     * @return the DataNetworkConfiguration object itself.
     */
    public DataNetworkConfiguration withDefaultSessionType(PduSessionType defaultSessionType) {
        this.defaultSessionType = defaultSessionType;
        return this;
    }

    /**
     * Get the additionalAllowedSessionTypes property: Allowed session types in addition to the default session type.
     * Must not duplicate the default session type.
     *
     * @return the additionalAllowedSessionTypes value.
     */
    public List<PduSessionType> additionalAllowedSessionTypes() {
        return this.additionalAllowedSessionTypes;
    }

    /**
     * Set the additionalAllowedSessionTypes property: Allowed session types in addition to the default session type.
     * Must not duplicate the default session type.
     *
     * @param additionalAllowedSessionTypes the additionalAllowedSessionTypes value to set.
     * @return the DataNetworkConfiguration object itself.
     */
    public DataNetworkConfiguration withAdditionalAllowedSessionTypes(
        List<PduSessionType> additionalAllowedSessionTypes) {
        this.additionalAllowedSessionTypes = additionalAllowedSessionTypes;
        return this;
    }

    /**
     * Get the allowedServices property: List of services that can be used as part of this SIM policy. The list must not
     * contain duplicate items and must contain at least one item. The services must be in the same location as the SIM
     * policy.
     *
     * @return the allowedServices value.
     */
    public List<ServiceResourceId> allowedServices() {
        return this.allowedServices;
    }

    /**
     * Set the allowedServices property: List of services that can be used as part of this SIM policy. The list must not
     * contain duplicate items and must contain at least one item. The services must be in the same location as the SIM
     * policy.
     *
     * @param allowedServices the allowedServices value to set.
     * @return the DataNetworkConfiguration object itself.
     */
    public DataNetworkConfiguration withAllowedServices(List<ServiceResourceId> allowedServices) {
        this.allowedServices = allowedServices;
        return this;
    }

    /**
     * Get the maximumNumberOfBufferedPackets property: The maximum number of downlink packets to buffer at the user
     * plane for High Latency Communication - Extended Buffering. See 3GPP TS29.272 v15.10.0 section 7.3.188 for a full
     * description. This maximum is not guaranteed because there is a internal limit on buffered packets across all PDU
     * sessions.
     *
     * @return the maximumNumberOfBufferedPackets value.
     */
    public Integer maximumNumberOfBufferedPackets() {
        return this.maximumNumberOfBufferedPackets;
    }

    /**
     * Set the maximumNumberOfBufferedPackets property: The maximum number of downlink packets to buffer at the user
     * plane for High Latency Communication - Extended Buffering. See 3GPP TS29.272 v15.10.0 section 7.3.188 for a full
     * description. This maximum is not guaranteed because there is a internal limit on buffered packets across all PDU
     * sessions.
     *
     * @param maximumNumberOfBufferedPackets the maximumNumberOfBufferedPackets value to set.
     * @return the DataNetworkConfiguration object itself.
     */
    public DataNetworkConfiguration withMaximumNumberOfBufferedPackets(Integer maximumNumberOfBufferedPackets) {
        this.maximumNumberOfBufferedPackets = maximumNumberOfBufferedPackets;
        return this;
    }

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

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