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

package com.azure.resourcemanager.iotcentral.models;

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

/** Network Rule Set Properties of this IoT Central application. */
@Fluent
public final class NetworkRuleSets {
    /*
     * Whether these rules apply for device connectivity to IoT Hub and Device
     * Provisioning service associated with this application.
     */
    @JsonProperty(value = "applyToDevices")
    private Boolean applyToDevices;

    /*
     * Whether these rules apply for connectivity via IoT Central web portal
     * and APIs.
     */
    @JsonProperty(value = "applyToIoTCentral")
    private Boolean applyToIoTCentral;

    /*
     * The default network action to apply.
     */
    @JsonProperty(value = "defaultAction")
    private NetworkAction defaultAction;

    /*
     * List of IP rules.
     */
    @JsonProperty(value = "ipRules")
    private List<NetworkRuleSetIpRule> ipRules;

    /**
     * Get the applyToDevices property: Whether these rules apply for device connectivity to IoT Hub and Device
     * Provisioning service associated with this application.
     *
     * @return the applyToDevices value.
     */
    public Boolean applyToDevices() {
        return this.applyToDevices;
    }

    /**
     * Set the applyToDevices property: Whether these rules apply for device connectivity to IoT Hub and Device
     * Provisioning service associated with this application.
     *
     * @param applyToDevices the applyToDevices value to set.
     * @return the NetworkRuleSets object itself.
     */
    public NetworkRuleSets withApplyToDevices(Boolean applyToDevices) {
        this.applyToDevices = applyToDevices;
        return this;
    }

    /**
     * Get the applyToIoTCentral property: Whether these rules apply for connectivity via IoT Central web portal and
     * APIs.
     *
     * @return the applyToIoTCentral value.
     */
    public Boolean applyToIoTCentral() {
        return this.applyToIoTCentral;
    }

    /**
     * Set the applyToIoTCentral property: Whether these rules apply for connectivity via IoT Central web portal and
     * APIs.
     *
     * @param applyToIoTCentral the applyToIoTCentral value to set.
     * @return the NetworkRuleSets object itself.
     */
    public NetworkRuleSets withApplyToIoTCentral(Boolean applyToIoTCentral) {
        this.applyToIoTCentral = applyToIoTCentral;
        return this;
    }

    /**
     * Get the defaultAction property: The default network action to apply.
     *
     * @return the defaultAction value.
     */
    public NetworkAction defaultAction() {
        return this.defaultAction;
    }

    /**
     * Set the defaultAction property: The default network action to apply.
     *
     * @param defaultAction the defaultAction value to set.
     * @return the NetworkRuleSets object itself.
     */
    public NetworkRuleSets withDefaultAction(NetworkAction defaultAction) {
        this.defaultAction = defaultAction;
        return this;
    }

    /**
     * Get the ipRules property: List of IP rules.
     *
     * @return the ipRules value.
     */
    public List<NetworkRuleSetIpRule> ipRules() {
        return this.ipRules;
    }

    /**
     * Set the ipRules property: List of IP rules.
     *
     * @param ipRules the ipRules value to set.
     * @return the NetworkRuleSets object itself.
     */
    public NetworkRuleSets withIpRules(List<NetworkRuleSetIpRule> ipRules) {
        this.ipRules = ipRules;
        return this;
    }

    /**
     * Validates the instance.
     *
     * @throws IllegalArgumentException thrown if the instance is not valid.
     */
    public void validate() {
        if (ipRules() != null) {
            ipRules().forEach(e -> e.validate());
        }
    }
}
