use serde::{Deserialize, Serialize}; /*
                                      * Compute Engine API
                                      *
                                      * Creates and runs virtual machines on Google Cloud Platform.
                                      *
                                      * The version of the OpenAPI document: v1
                                      *
                                      * Generated by: https://openapi-generator.tech
                                      */

use crate::google_rest_apis::compute_v1::models;

/// FirewallPolicyRule : Represents a rule that describes one or more match conditions along with the action to be taken when traffic matches this condition (allow or deny).
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct FirewallPolicyRule {
    /// The Action to perform when the client connection triggers the rule. Valid actions are \"allow\", \"deny\" and \"goto_next\".
    #[serde(rename = "action", skip_serializing_if = "Option::is_none")]
    pub action: Option<String>,
    /// An optional description for this resource.
    #[serde(rename = "description", skip_serializing_if = "Option::is_none")]
    pub description: Option<String>,
    /// The direction in which this rule applies.
    #[serde(rename = "direction", skip_serializing_if = "Option::is_none")]
    pub direction: Option<Direction>,
    /// Denotes whether the firewall policy rule is disabled. When set to true, the firewall policy rule is not enforced and traffic behaves as if it did not exist. If this is unspecified, the firewall policy rule will be enabled.
    #[serde(rename = "disabled", skip_serializing_if = "Option::is_none")]
    pub disabled: Option<bool>,
    /// Denotes whether to enable logging for a particular rule. If logging is enabled, logs will be exported to the configured export destination in Stackdriver. Logs may be exported to BigQuery or Pub/Sub. Note: you cannot enable logging on \"goto_next\" rules.
    #[serde(rename = "enableLogging", skip_serializing_if = "Option::is_none")]
    pub enable_logging: Option<bool>,
    /// [Output only] Type of the resource. Always compute#firewallPolicyRule for firewall policy rules
    #[serde(rename = "kind", skip_serializing_if = "Option::is_none")]
    pub kind: Option<String>,
    #[serde(rename = "match", skip_serializing_if = "Option::is_none")]
    pub r#match: Option<Box<models::FirewallPolicyRuleMatcher>>,
    /// An integer indicating the priority of a rule in the list. The priority must be a positive value between 0 and 2147483647. Rules are evaluated from highest to lowest priority where 0 is the highest priority and 2147483647 is the lowest prority.
    #[serde(rename = "priority", skip_serializing_if = "Option::is_none")]
    pub priority: Option<i32>,
    /// An optional name for the rule. This field is not a unique identifier and can be updated.
    #[serde(rename = "ruleName", skip_serializing_if = "Option::is_none")]
    pub rule_name: Option<String>,
    /// [Output Only] Calculation of the complexity of a single firewall policy rule.
    #[serde(rename = "ruleTupleCount", skip_serializing_if = "Option::is_none")]
    pub rule_tuple_count: Option<i32>,
    /// A fully-qualified URL of a SecurityProfile resource instance. Example: https://networksecurity.googleapis.com/v1/projects/{project}/locations/{location}/securityProfileGroups/my-security-profile-group Must be specified if action = 'apply_security_profile_group' and cannot be specified for other actions.
    #[serde(
        rename = "securityProfileGroup",
        skip_serializing_if = "Option::is_none"
    )]
    pub security_profile_group: Option<String>,
    /// A list of network resource URLs to which this rule applies. This field allows you to control which network's VMs get this rule. If this field is left blank, all VMs within the organization will receive the rule.
    #[serde(rename = "targetResources", skip_serializing_if = "Option::is_none")]
    pub target_resources: Option<Vec<String>>,
    /// A list of secure tags that controls which instances the firewall rule applies to. If targetSecureTag are specified, then the firewall rule applies only to instances in the VPC network that have one of those EFFECTIVE secure tags, if all the target_secure_tag are in INEFFECTIVE state, then this rule will be ignored. targetSecureTag may not be set at the same time as targetServiceAccounts. If neither targetServiceAccounts nor targetSecureTag are specified, the firewall rule applies to all instances on the specified network. Maximum number of target label tags allowed is 256.
    #[serde(rename = "targetSecureTags", skip_serializing_if = "Option::is_none")]
    pub target_secure_tags: Option<Vec<models::FirewallPolicyRuleSecureTag>>,
    /// A list of service accounts indicating the sets of instances that are applied with this rule.
    #[serde(
        rename = "targetServiceAccounts",
        skip_serializing_if = "Option::is_none"
    )]
    pub target_service_accounts: Option<Vec<String>>,
    /// Boolean flag indicating if the traffic should be TLS decrypted. Can be set only if action = 'apply_security_profile_group' and cannot be set for other actions.
    #[serde(rename = "tlsInspect", skip_serializing_if = "Option::is_none")]
    pub tls_inspect: Option<bool>,
}

impl FirewallPolicyRule {
    /// Represents a rule that describes one or more match conditions along with the action to be taken when traffic matches this condition (allow or deny).
    pub fn new() -> FirewallPolicyRule {
        FirewallPolicyRule {
            action: None,
            description: None,
            direction: None,
            disabled: None,
            enable_logging: None,
            kind: None,
            r#match: None,
            priority: None,
            rule_name: None,
            rule_tuple_count: None,
            security_profile_group: None,
            target_resources: None,
            target_secure_tags: None,
            target_service_accounts: None,
            tls_inspect: None,
        }
    }
}
/// The direction in which this rule applies.
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum Direction {
    #[serde(rename = "EGRESS")]
    Egress,
    #[serde(rename = "INGRESS")]
    Ingress,
}

impl Default for Direction {
    fn default() -> Direction {
        Self::Egress
    }
}
