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

/// SecurityPolicyRule : 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, Debug, PartialEq, Default, Serialize, Deserialize)]
pub struct SecurityPolicyRule {
    /// The Action to perform when the rule is matched. The following are the valid actions: - allow: allow access to target. - deny(STATUS): deny access to target, returns the HTTP response code specified. Valid values for `STATUS` are 403, 404, and 502. - rate_based_ban: limit client traffic to the configured threshold and ban the client if the traffic exceeds the threshold. Configure parameters for this action in RateLimitOptions. Requires rate_limit_options to be set. - redirect: redirect to a different target. This can either be an internal reCAPTCHA redirect, or an external URL-based redirect via a 302 response. Parameters for this action can be configured via redirectOptions. This action is only supported in Global Security Policies of type CLOUD_ARMOR. - throttle: limit client traffic to the configured threshold. Configure parameters for this action in rateLimitOptions. Requires rate_limit_options to be set for this.
    #[serde(rename = "action", skip_serializing_if = "Option::is_none")]
    pub action: Option<String>,
    /// An optional description of this resource. Provide this property when you create the resource.
    #[serde(rename = "description", skip_serializing_if = "Option::is_none")]
    pub description: Option<String>,
    #[serde(rename = "headerAction", skip_serializing_if = "Option::is_none")]
    pub header_action: Option<
        Box<crate::google_rest_apis::compute_v1::models::SecurityPolicyRuleHttpHeaderAction>,
    >,
    /// [Output only] Type of the resource. Always compute#securityPolicyRule for security 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<crate::google_rest_apis::compute_v1::models::SecurityPolicyRuleMatcher>>,
    #[serde(rename = "networkMatch", skip_serializing_if = "Option::is_none")]
    pub network_match:
        Option<Box<crate::google_rest_apis::compute_v1::models::SecurityPolicyRuleNetworkMatcher>>,
    #[serde(
        rename = "preconfiguredWafConfig",
        skip_serializing_if = "Option::is_none"
    )]
    pub preconfigured_waf_config: Option<
        Box<crate::google_rest_apis::compute_v1::models::SecurityPolicyRulePreconfiguredWafConfig>,
    >,
    /// If set to true, the specified action is not enforced.
    #[serde(rename = "preview", skip_serializing_if = "Option::is_none")]
    pub preview: Option<bool>,
    /// 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 priority.
    #[serde(rename = "priority", skip_serializing_if = "Option::is_none")]
    pub priority: Option<i32>,
    #[serde(rename = "rateLimitOptions", skip_serializing_if = "Option::is_none")]
    pub rate_limit_options: Option<
        Box<crate::google_rest_apis::compute_v1::models::SecurityPolicyRuleRateLimitOptions>,
    >,
    #[serde(rename = "redirectOptions", skip_serializing_if = "Option::is_none")]
    pub redirect_options:
        Option<Box<crate::google_rest_apis::compute_v1::models::SecurityPolicyRuleRedirectOptions>>,
}

impl SecurityPolicyRule {
    /// 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() -> SecurityPolicyRule {
        SecurityPolicyRule {
            action: None,
            description: None,
            header_action: None,
            kind: None,
            r#match: None,
            network_match: None,
            preconfigured_waf_config: None,
            preview: None,
            priority: None,
            rate_limit_options: None,
            redirect_options: None,
        }
    }
}
