// 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.management.Resource;
import com.azure.core.management.SystemData;
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;
import java.util.Map;

/** Service resource. Must be created in the same location as its parent mobile network. */
@Fluent
public final class ServiceInner extends Resource {
    /*
     * Service Properties.
     */
    @JsonProperty(value = "properties", required = true)
    private ServicePropertiesFormat innerProperties = new ServicePropertiesFormat();

    /*
     * Azure Resource Manager metadata containing createdBy and modifiedBy information.
     */
    @JsonProperty(value = "systemData", access = JsonProperty.Access.WRITE_ONLY)
    private SystemData systemData;

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

    /**
     * Get the innerProperties property: Service Properties.
     *
     * @return the innerProperties value.
     */
    private ServicePropertiesFormat innerProperties() {
        return this.innerProperties;
    }

    /**
     * Get the systemData property: Azure Resource Manager metadata containing createdBy and modifiedBy information.
     *
     * @return the systemData value.
     */
    public SystemData systemData() {
        return this.systemData;
    }

    /** {@inheritDoc} */
    @Override
    public ServiceInner withLocation(String location) {
        super.withLocation(location);
        return this;
    }

    /** {@inheritDoc} */
    @Override
    public ServiceInner withTags(Map<String, String> tags) {
        super.withTags(tags);
        return this;
    }

    /**
     * Get the provisioningState property: The provisioning state of the service resource.
     *
     * @return the provisioningState value.
     */
    public ProvisioningState provisioningState() {
        return this.innerProperties() == null ? null : this.innerProperties().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.innerProperties() == null ? 0 : this.innerProperties().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 ServiceInner object itself.
     */
    public ServiceInner withServicePrecedence(int servicePrecedence) {
        if (this.innerProperties() == null) {
            this.innerProperties = new ServicePropertiesFormat();
        }
        this.innerProperties().withServicePrecedence(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.innerProperties() == null ? null : this.innerProperties().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 ServiceInner object itself.
     */
    public ServiceInner withServiceQosPolicy(QosPolicy serviceQosPolicy) {
        if (this.innerProperties() == null) {
            this.innerProperties = new ServicePropertiesFormat();
        }
        this.innerProperties().withServiceQosPolicy(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.innerProperties() == null ? null : this.innerProperties().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 ServiceInner object itself.
     */
    public ServiceInner withPccRules(List<PccRuleConfiguration> pccRules) {
        if (this.innerProperties() == null) {
            this.innerProperties = new ServicePropertiesFormat();
        }
        this.innerProperties().withPccRules(pccRules);
        return this;
    }

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

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