Skip to main content

SecurityPolicyRule

Struct SecurityPolicyRule 

Source
#[non_exhaustive]
pub struct SecurityPolicyRule { pub action: Option<String>, pub description: Option<String>, pub header_action: Option<SecurityPolicyRuleHttpHeaderAction>, pub kind: Option<String>, pub match: Option<SecurityPolicyRuleMatcher>, pub network_match: Option<SecurityPolicyRuleNetworkMatcher>, pub preconfigured_waf_config: Option<SecurityPolicyRulePreconfiguredWafConfig>, pub preview: Option<bool>, pub priority: Option<i32>, pub rate_limit_options: Option<SecurityPolicyRuleRateLimitOptions>, pub redirect_options: Option<SecurityPolicyRuleRedirectOptions>, /* private fields */ }
Available on crate features organization-security-policies or region-security-policies or security-policies only.
Expand description

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).

Fields (Non-exhaustive)§

This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§action: Option<String>

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.
  • fairshare (preview only): when traffic reaches the threshold limit, requests from the clients matching this rule begin to be rate-limited using the Fair Share algorithm. This action is only allowed in security policies of type CLOUD_ARMOR_INTERNAL_SERVICE.
§description: Option<String>

An optional description of this resource. Provide this property when you create the resource.

§header_action: Option<SecurityPolicyRuleHttpHeaderAction>

Optional, additional actions that are performed on headers. This field is only supported in Global Security Policies of type CLOUD_ARMOR.

§kind: Option<String>

Output only. [Output only] Type of the resource. Alwayscompute#securityPolicyRule for security policy rules

§match: Option<SecurityPolicyRuleMatcher>

A match condition that incoming traffic is evaluated against. If it evaluates to true, the corresponding ‘action’ is enforced.

§network_match: Option<SecurityPolicyRuleNetworkMatcher>

A match condition that incoming packets are evaluated against for CLOUD_ARMOR_NETWORK security policies. If it matches, the corresponding ‘action’ is enforced.

The match criteria for a rule consists of built-in match fields (like ‘srcIpRanges’) and potentially multiple user-defined match fields (‘userDefinedFields’).

Field values may be extracted directly from the packet or derived from it (e.g. ‘srcRegionCodes’). Some fields may not be present in every packet (e.g. ‘srcPorts’). A user-defined field is only present if the base header is found in the packet and the entire field is in bounds.

Each match field may specify which values can match it, listing one or more ranges, prefixes, or exact values that are considered a match for the field. A field value must be present in order to match a specified match field. If no match values are specified for a match field, then any field value is considered to match it, and it’s not required to be present. For strings specifying ‘*’ is also equivalent to match all.

For a packet to match a rule, all specified match fields must match the corresponding field values derived from the packet.

Example:

networkMatch: srcIpRanges:

  • “192.0.2.0/24”
  • “198.51.100.0/24” userDefinedFields:
  • name: “ipv4_fragment_offset” values:
    • “1-0x1fff”

The above match condition matches packets with a source IP in 192.0.2.0/24 or 198.51.100.0/24 and a user-defined field named “ipv4_fragment_offset” with a value between 1 and 0x1fff inclusive.

§preconfigured_waf_config: Option<SecurityPolicyRulePreconfiguredWafConfig>

Preconfigured WAF configuration to be applied for the rule. If the rule does not evaluate preconfigured WAF rules, i.e., if evaluatePreconfiguredWaf() is not used, this field will have no effect.

§preview: Option<bool>

If set to true, the specified action is not enforced.

§priority: Option<i32>

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.

§rate_limit_options: Option<SecurityPolicyRuleRateLimitOptions>

Must be specified if the action is “rate_based_ban” or “throttle” or “fairshare”. Cannot be specified for any other actions.

§redirect_options: Option<SecurityPolicyRuleRedirectOptions>

Parameters defining the redirect action. Cannot be specified for any other actions. This field is only supported in Global Security Policies of type CLOUD_ARMOR.

Implementations§

Source§

impl SecurityPolicyRule

Source

pub fn new() -> Self

Source

pub fn set_action<T>(self, v: T) -> Self
where T: Into<String>,

Sets the value of action.

§Example
let x = SecurityPolicyRule::new().set_action("example");
Source

pub fn set_or_clear_action<T>(self, v: Option<T>) -> Self
where T: Into<String>,

Sets or clears the value of action.

§Example
let x = SecurityPolicyRule::new().set_or_clear_action(Some("example"));
let x = SecurityPolicyRule::new().set_or_clear_action(None::<String>);
Source

pub fn set_description<T>(self, v: T) -> Self
where T: Into<String>,

Sets the value of description.

§Example
let x = SecurityPolicyRule::new().set_description("example");
Source

pub fn set_or_clear_description<T>(self, v: Option<T>) -> Self
where T: Into<String>,

Sets or clears the value of description.

§Example
let x = SecurityPolicyRule::new().set_or_clear_description(Some("example"));
let x = SecurityPolicyRule::new().set_or_clear_description(None::<String>);
Source

pub fn set_header_action<T>(self, v: T) -> Self

Sets the value of header_action.

§Example
use google_cloud_compute_v1::model::SecurityPolicyRuleHttpHeaderAction;
let x = SecurityPolicyRule::new().set_header_action(SecurityPolicyRuleHttpHeaderAction::default()/* use setters */);
Source

pub fn set_or_clear_header_action<T>(self, v: Option<T>) -> Self

Sets or clears the value of header_action.

§Example
use google_cloud_compute_v1::model::SecurityPolicyRuleHttpHeaderAction;
let x = SecurityPolicyRule::new().set_or_clear_header_action(Some(SecurityPolicyRuleHttpHeaderAction::default()/* use setters */));
let x = SecurityPolicyRule::new().set_or_clear_header_action(None::<SecurityPolicyRuleHttpHeaderAction>);
Source

pub fn set_kind<T>(self, v: T) -> Self
where T: Into<String>,

Sets the value of kind.

§Example
let x = SecurityPolicyRule::new().set_kind("example");
Source

pub fn set_or_clear_kind<T>(self, v: Option<T>) -> Self
where T: Into<String>,

Sets or clears the value of kind.

§Example
let x = SecurityPolicyRule::new().set_or_clear_kind(Some("example"));
let x = SecurityPolicyRule::new().set_or_clear_kind(None::<String>);
Source

pub fn set_match<T>(self, v: T) -> Self

Sets the value of r#match.

§Example
use google_cloud_compute_v1::model::SecurityPolicyRuleMatcher;
let x = SecurityPolicyRule::new().set_match(SecurityPolicyRuleMatcher::default()/* use setters */);
Source

pub fn set_or_clear_match<T>(self, v: Option<T>) -> Self

Sets or clears the value of r#match.

§Example
use google_cloud_compute_v1::model::SecurityPolicyRuleMatcher;
let x = SecurityPolicyRule::new().set_or_clear_match(Some(SecurityPolicyRuleMatcher::default()/* use setters */));
let x = SecurityPolicyRule::new().set_or_clear_match(None::<SecurityPolicyRuleMatcher>);
Source

pub fn set_network_match<T>(self, v: T) -> Self

Sets the value of network_match.

§Example
use google_cloud_compute_v1::model::SecurityPolicyRuleNetworkMatcher;
let x = SecurityPolicyRule::new().set_network_match(SecurityPolicyRuleNetworkMatcher::default()/* use setters */);
Source

pub fn set_or_clear_network_match<T>(self, v: Option<T>) -> Self

Sets or clears the value of network_match.

§Example
use google_cloud_compute_v1::model::SecurityPolicyRuleNetworkMatcher;
let x = SecurityPolicyRule::new().set_or_clear_network_match(Some(SecurityPolicyRuleNetworkMatcher::default()/* use setters */));
let x = SecurityPolicyRule::new().set_or_clear_network_match(None::<SecurityPolicyRuleNetworkMatcher>);
Source

pub fn set_preconfigured_waf_config<T>(self, v: T) -> Self

Sets the value of preconfigured_waf_config.

§Example
use google_cloud_compute_v1::model::SecurityPolicyRulePreconfiguredWafConfig;
let x = SecurityPolicyRule::new().set_preconfigured_waf_config(SecurityPolicyRulePreconfiguredWafConfig::default()/* use setters */);
Source

pub fn set_or_clear_preconfigured_waf_config<T>(self, v: Option<T>) -> Self

Sets or clears the value of preconfigured_waf_config.

§Example
use google_cloud_compute_v1::model::SecurityPolicyRulePreconfiguredWafConfig;
let x = SecurityPolicyRule::new().set_or_clear_preconfigured_waf_config(Some(SecurityPolicyRulePreconfiguredWafConfig::default()/* use setters */));
let x = SecurityPolicyRule::new().set_or_clear_preconfigured_waf_config(None::<SecurityPolicyRulePreconfiguredWafConfig>);
Source

pub fn set_preview<T>(self, v: T) -> Self
where T: Into<bool>,

Sets the value of preview.

§Example
let x = SecurityPolicyRule::new().set_preview(true);
Source

pub fn set_or_clear_preview<T>(self, v: Option<T>) -> Self
where T: Into<bool>,

Sets or clears the value of preview.

§Example
let x = SecurityPolicyRule::new().set_or_clear_preview(Some(false));
let x = SecurityPolicyRule::new().set_or_clear_preview(None::<bool>);
Source

pub fn set_priority<T>(self, v: T) -> Self
where T: Into<i32>,

Sets the value of priority.

§Example
let x = SecurityPolicyRule::new().set_priority(42);
Source

pub fn set_or_clear_priority<T>(self, v: Option<T>) -> Self
where T: Into<i32>,

Sets or clears the value of priority.

§Example
let x = SecurityPolicyRule::new().set_or_clear_priority(Some(42));
let x = SecurityPolicyRule::new().set_or_clear_priority(None::<i32>);
Source

pub fn set_rate_limit_options<T>(self, v: T) -> Self

Sets the value of rate_limit_options.

§Example
use google_cloud_compute_v1::model::SecurityPolicyRuleRateLimitOptions;
let x = SecurityPolicyRule::new().set_rate_limit_options(SecurityPolicyRuleRateLimitOptions::default()/* use setters */);
Source

pub fn set_or_clear_rate_limit_options<T>(self, v: Option<T>) -> Self

Sets or clears the value of rate_limit_options.

§Example
use google_cloud_compute_v1::model::SecurityPolicyRuleRateLimitOptions;
let x = SecurityPolicyRule::new().set_or_clear_rate_limit_options(Some(SecurityPolicyRuleRateLimitOptions::default()/* use setters */));
let x = SecurityPolicyRule::new().set_or_clear_rate_limit_options(None::<SecurityPolicyRuleRateLimitOptions>);
Source

pub fn set_redirect_options<T>(self, v: T) -> Self

Sets the value of redirect_options.

§Example
use google_cloud_compute_v1::model::SecurityPolicyRuleRedirectOptions;
let x = SecurityPolicyRule::new().set_redirect_options(SecurityPolicyRuleRedirectOptions::default()/* use setters */);
Source

pub fn set_or_clear_redirect_options<T>(self, v: Option<T>) -> Self

Sets or clears the value of redirect_options.

§Example
use google_cloud_compute_v1::model::SecurityPolicyRuleRedirectOptions;
let x = SecurityPolicyRule::new().set_or_clear_redirect_options(Some(SecurityPolicyRuleRedirectOptions::default()/* use setters */));
let x = SecurityPolicyRule::new().set_or_clear_redirect_options(None::<SecurityPolicyRuleRedirectOptions>);

Trait Implementations§

Source§

impl Clone for SecurityPolicyRule

Source§

fn clone(&self) -> SecurityPolicyRule

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for SecurityPolicyRule

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for SecurityPolicyRule

Source§

fn default() -> SecurityPolicyRule

Returns the “default value” for a type. Read more
Source§

impl Message for SecurityPolicyRule

Source§

fn typename() -> &'static str

The typename of this message.
Source§

impl PartialEq for SecurityPolicyRule

Source§

fn eq(&self, other: &SecurityPolicyRule) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for SecurityPolicyRule

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,