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

package com.azure.resourcemanager.paloaltonetworks.ngfw.fluent.models;

import com.azure.core.annotation.Fluent;
import com.azure.core.util.logging.ClientLogger;
import com.azure.resourcemanager.paloaltonetworks.ngfw.models.ActionEnum;
import com.azure.resourcemanager.paloaltonetworks.ngfw.models.BooleanEnum;
import com.azure.resourcemanager.paloaltonetworks.ngfw.models.Category;
import com.azure.resourcemanager.paloaltonetworks.ngfw.models.DecryptionRuleTypeEnum;
import com.azure.resourcemanager.paloaltonetworks.ngfw.models.DestinationAddr;
import com.azure.resourcemanager.paloaltonetworks.ngfw.models.ProvisioningState;
import com.azure.resourcemanager.paloaltonetworks.ngfw.models.SourceAddr;
import com.azure.resourcemanager.paloaltonetworks.ngfw.models.StateEnum;
import com.azure.resourcemanager.paloaltonetworks.ngfw.models.TagInfo;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.List;

/** definition of rule. */
@Fluent
public final class RuleEntry {
    /*
     * etag info
     */
    @JsonProperty(value = "etag")
    private String etag;

    /*
     * rule name
     */
    @JsonProperty(value = "ruleName", required = true)
    private String ruleName;

    /*
     * The priority property.
     */
    @JsonProperty(value = "priority", access = JsonProperty.Access.WRITE_ONLY)
    private Integer priority;

    /*
     * rule description
     */
    @JsonProperty(value = "description")
    private String description;

    /*
     * state of this rule
     */
    @JsonProperty(value = "ruleState")
    private StateEnum ruleState;

    /*
     * source address
     */
    @JsonProperty(value = "source")
    private SourceAddr source;

    /*
     * cidr should not be 'any'
     */
    @JsonProperty(value = "negateSource")
    private BooleanEnum negateSource;

    /*
     * destination address
     */
    @JsonProperty(value = "destination")
    private DestinationAddr destination;

    /*
     * cidr should not be 'any'
     */
    @JsonProperty(value = "negateDestination")
    private BooleanEnum negateDestination;

    /*
     * array of rule applications
     */
    @JsonProperty(value = "applications")
    private List<String> applications;

    /*
     * rule category
     */
    @JsonProperty(value = "category")
    private Category category;

    /*
     * any, application-default, TCP:number, UDP:number
     */
    @JsonProperty(value = "protocol")
    private String protocol;

    /*
     * prot port list
     */
    @JsonProperty(value = "protocolPortList")
    private List<String> protocolPortList;

    /*
     * inbound Inspection Certificate
     */
    @JsonProperty(value = "inboundInspectionCertificate")
    private String inboundInspectionCertificate;

    /*
     * rule comment
     */
    @JsonProperty(value = "auditComment")
    private String auditComment;

    /*
     * rule action
     */
    @JsonProperty(value = "actionType")
    private ActionEnum actionType;

    /*
     * enable or disable logging
     */
    @JsonProperty(value = "enableLogging")
    private StateEnum enableLogging;

    /*
     * enable or disable decryption
     */
    @JsonProperty(value = "decryptionRuleType")
    private DecryptionRuleTypeEnum decryptionRuleType;

    /*
     * tag for rule
     */
    @JsonProperty(value = "tags")
    private List<TagInfo> tags;

    /*
     * Provisioning state of the resource.
     */
    @JsonProperty(value = "provisioningState", access = JsonProperty.Access.WRITE_ONLY)
    private ProvisioningState provisioningState;

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

    /**
     * Get the etag property: etag info.
     *
     * @return the etag value.
     */
    public String etag() {
        return this.etag;
    }

    /**
     * Set the etag property: etag info.
     *
     * @param etag the etag value to set.
     * @return the RuleEntry object itself.
     */
    public RuleEntry withEtag(String etag) {
        this.etag = etag;
        return this;
    }

    /**
     * Get the ruleName property: rule name.
     *
     * @return the ruleName value.
     */
    public String ruleName() {
        return this.ruleName;
    }

    /**
     * Set the ruleName property: rule name.
     *
     * @param ruleName the ruleName value to set.
     * @return the RuleEntry object itself.
     */
    public RuleEntry withRuleName(String ruleName) {
        this.ruleName = ruleName;
        return this;
    }

    /**
     * Get the priority property: The priority property.
     *
     * @return the priority value.
     */
    public Integer priority() {
        return this.priority;
    }

    /**
     * Get the description property: rule description.
     *
     * @return the description value.
     */
    public String description() {
        return this.description;
    }

    /**
     * Set the description property: rule description.
     *
     * @param description the description value to set.
     * @return the RuleEntry object itself.
     */
    public RuleEntry withDescription(String description) {
        this.description = description;
        return this;
    }

    /**
     * Get the ruleState property: state of this rule.
     *
     * @return the ruleState value.
     */
    public StateEnum ruleState() {
        return this.ruleState;
    }

    /**
     * Set the ruleState property: state of this rule.
     *
     * @param ruleState the ruleState value to set.
     * @return the RuleEntry object itself.
     */
    public RuleEntry withRuleState(StateEnum ruleState) {
        this.ruleState = ruleState;
        return this;
    }

    /**
     * Get the source property: source address.
     *
     * @return the source value.
     */
    public SourceAddr source() {
        return this.source;
    }

    /**
     * Set the source property: source address.
     *
     * @param source the source value to set.
     * @return the RuleEntry object itself.
     */
    public RuleEntry withSource(SourceAddr source) {
        this.source = source;
        return this;
    }

    /**
     * Get the negateSource property: cidr should not be 'any'.
     *
     * @return the negateSource value.
     */
    public BooleanEnum negateSource() {
        return this.negateSource;
    }

    /**
     * Set the negateSource property: cidr should not be 'any'.
     *
     * @param negateSource the negateSource value to set.
     * @return the RuleEntry object itself.
     */
    public RuleEntry withNegateSource(BooleanEnum negateSource) {
        this.negateSource = negateSource;
        return this;
    }

    /**
     * Get the destination property: destination address.
     *
     * @return the destination value.
     */
    public DestinationAddr destination() {
        return this.destination;
    }

    /**
     * Set the destination property: destination address.
     *
     * @param destination the destination value to set.
     * @return the RuleEntry object itself.
     */
    public RuleEntry withDestination(DestinationAddr destination) {
        this.destination = destination;
        return this;
    }

    /**
     * Get the negateDestination property: cidr should not be 'any'.
     *
     * @return the negateDestination value.
     */
    public BooleanEnum negateDestination() {
        return this.negateDestination;
    }

    /**
     * Set the negateDestination property: cidr should not be 'any'.
     *
     * @param negateDestination the negateDestination value to set.
     * @return the RuleEntry object itself.
     */
    public RuleEntry withNegateDestination(BooleanEnum negateDestination) {
        this.negateDestination = negateDestination;
        return this;
    }

    /**
     * Get the applications property: array of rule applications.
     *
     * @return the applications value.
     */
    public List<String> applications() {
        return this.applications;
    }

    /**
     * Set the applications property: array of rule applications.
     *
     * @param applications the applications value to set.
     * @return the RuleEntry object itself.
     */
    public RuleEntry withApplications(List<String> applications) {
        this.applications = applications;
        return this;
    }

    /**
     * Get the category property: rule category.
     *
     * @return the category value.
     */
    public Category category() {
        return this.category;
    }

    /**
     * Set the category property: rule category.
     *
     * @param category the category value to set.
     * @return the RuleEntry object itself.
     */
    public RuleEntry withCategory(Category category) {
        this.category = category;
        return this;
    }

    /**
     * Get the protocol property: any, application-default, TCP:number, UDP:number.
     *
     * @return the protocol value.
     */
    public String protocol() {
        return this.protocol;
    }

    /**
     * Set the protocol property: any, application-default, TCP:number, UDP:number.
     *
     * @param protocol the protocol value to set.
     * @return the RuleEntry object itself.
     */
    public RuleEntry withProtocol(String protocol) {
        this.protocol = protocol;
        return this;
    }

    /**
     * Get the protocolPortList property: prot port list.
     *
     * @return the protocolPortList value.
     */
    public List<String> protocolPortList() {
        return this.protocolPortList;
    }

    /**
     * Set the protocolPortList property: prot port list.
     *
     * @param protocolPortList the protocolPortList value to set.
     * @return the RuleEntry object itself.
     */
    public RuleEntry withProtocolPortList(List<String> protocolPortList) {
        this.protocolPortList = protocolPortList;
        return this;
    }

    /**
     * Get the inboundInspectionCertificate property: inbound Inspection Certificate.
     *
     * @return the inboundInspectionCertificate value.
     */
    public String inboundInspectionCertificate() {
        return this.inboundInspectionCertificate;
    }

    /**
     * Set the inboundInspectionCertificate property: inbound Inspection Certificate.
     *
     * @param inboundInspectionCertificate the inboundInspectionCertificate value to set.
     * @return the RuleEntry object itself.
     */
    public RuleEntry withInboundInspectionCertificate(String inboundInspectionCertificate) {
        this.inboundInspectionCertificate = inboundInspectionCertificate;
        return this;
    }

    /**
     * Get the auditComment property: rule comment.
     *
     * @return the auditComment value.
     */
    public String auditComment() {
        return this.auditComment;
    }

    /**
     * Set the auditComment property: rule comment.
     *
     * @param auditComment the auditComment value to set.
     * @return the RuleEntry object itself.
     */
    public RuleEntry withAuditComment(String auditComment) {
        this.auditComment = auditComment;
        return this;
    }

    /**
     * Get the actionType property: rule action.
     *
     * @return the actionType value.
     */
    public ActionEnum actionType() {
        return this.actionType;
    }

    /**
     * Set the actionType property: rule action.
     *
     * @param actionType the actionType value to set.
     * @return the RuleEntry object itself.
     */
    public RuleEntry withActionType(ActionEnum actionType) {
        this.actionType = actionType;
        return this;
    }

    /**
     * Get the enableLogging property: enable or disable logging.
     *
     * @return the enableLogging value.
     */
    public StateEnum enableLogging() {
        return this.enableLogging;
    }

    /**
     * Set the enableLogging property: enable or disable logging.
     *
     * @param enableLogging the enableLogging value to set.
     * @return the RuleEntry object itself.
     */
    public RuleEntry withEnableLogging(StateEnum enableLogging) {
        this.enableLogging = enableLogging;
        return this;
    }

    /**
     * Get the decryptionRuleType property: enable or disable decryption.
     *
     * @return the decryptionRuleType value.
     */
    public DecryptionRuleTypeEnum decryptionRuleType() {
        return this.decryptionRuleType;
    }

    /**
     * Set the decryptionRuleType property: enable or disable decryption.
     *
     * @param decryptionRuleType the decryptionRuleType value to set.
     * @return the RuleEntry object itself.
     */
    public RuleEntry withDecryptionRuleType(DecryptionRuleTypeEnum decryptionRuleType) {
        this.decryptionRuleType = decryptionRuleType;
        return this;
    }

    /**
     * Get the tags property: tag for rule.
     *
     * @return the tags value.
     */
    public List<TagInfo> tags() {
        return this.tags;
    }

    /**
     * Set the tags property: tag for rule.
     *
     * @param tags the tags value to set.
     * @return the RuleEntry object itself.
     */
    public RuleEntry withTags(List<TagInfo> tags) {
        this.tags = tags;
        return this;
    }

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

    /**
     * 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 RuleEntry"));
        }
        if (source() != null) {
            source().validate();
        }
        if (destination() != null) {
            destination().validate();
        }
        if (category() != null) {
            category().validate();
        }
        if (tags() != null) {
            tags().forEach(e -> e.validate());
        }
    }

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