aws_sdk_wafregional/types/
_predicate.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2
3/// <note>
4/// <p>This is <b>AWS WAF Classic</b> documentation. For more information, see <a href="https://docs.aws.amazon.com/waf/latest/developerguide/classic-waf-chapter.html">AWS WAF Classic</a> in the developer guide.</p>
5/// <p><b>For the latest version of AWS WAF</b>, use the AWS WAFV2 API and see the <a href="https://docs.aws.amazon.com/waf/latest/developerguide/waf-chapter.html">AWS WAF Developer Guide</a>. With the latest version, AWS WAF has a single set of endpoints for regional and global use.</p>
6/// </note>
7/// <p>Specifies the <code>ByteMatchSet</code>, <code>IPSet</code>, <code>SqlInjectionMatchSet</code>, <code>XssMatchSet</code>, <code>RegexMatchSet</code>, <code>GeoMatchSet</code>, and <code>SizeConstraintSet</code> objects that you want to add to a <code>Rule</code> and, for each object, indicates whether you want to negate the settings, for example, requests that do NOT originate from the IP address 192.0.2.44.</p>
8#[non_exhaustive]
9#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::fmt::Debug)]
10pub struct Predicate {
11    /// <p>Set <code>Negated</code> to <code>False</code> if you want AWS WAF to allow, block, or count requests based on the settings in the specified <code>ByteMatchSet</code>, <code>IPSet</code>, <code>SqlInjectionMatchSet</code>, <code>XssMatchSet</code>, <code>RegexMatchSet</code>, <code>GeoMatchSet</code>, or <code>SizeConstraintSet</code>. For example, if an <code>IPSet</code> includes the IP address <code>192.0.2.44</code>, AWS WAF will allow or block requests based on that IP address.</p>
12    /// <p>Set <code>Negated</code> to <code>True</code> if you want AWS WAF to allow or block a request based on the negation of the settings in the <code>ByteMatchSet</code>, <code>IPSet</code>, <code>SqlInjectionMatchSet</code>, <code>XssMatchSet</code>, <code>RegexMatchSet</code>, <code>GeoMatchSet</code>, or <code>SizeConstraintSet</code>. For example, if an <code>IPSet</code> includes the IP address <code>192.0.2.44</code>, AWS WAF will allow, block, or count requests based on all IP addresses <i>except</i> <code>192.0.2.44</code>.</p>
13    pub negated: bool,
14    /// <p>The type of predicate in a <code>Rule</code>, such as <code>ByteMatch</code> or <code>IPSet</code>.</p>
15    pub r#type: crate::types::PredicateType,
16    /// <p>A unique identifier for a predicate in a <code>Rule</code>, such as <code>ByteMatchSetId</code> or <code>IPSetId</code>. The ID is returned by the corresponding <code>Create</code> or <code>List</code> command.</p>
17    pub data_id: ::std::string::String,
18}
19impl Predicate {
20    /// <p>Set <code>Negated</code> to <code>False</code> if you want AWS WAF to allow, block, or count requests based on the settings in the specified <code>ByteMatchSet</code>, <code>IPSet</code>, <code>SqlInjectionMatchSet</code>, <code>XssMatchSet</code>, <code>RegexMatchSet</code>, <code>GeoMatchSet</code>, or <code>SizeConstraintSet</code>. For example, if an <code>IPSet</code> includes the IP address <code>192.0.2.44</code>, AWS WAF will allow or block requests based on that IP address.</p>
21    /// <p>Set <code>Negated</code> to <code>True</code> if you want AWS WAF to allow or block a request based on the negation of the settings in the <code>ByteMatchSet</code>, <code>IPSet</code>, <code>SqlInjectionMatchSet</code>, <code>XssMatchSet</code>, <code>RegexMatchSet</code>, <code>GeoMatchSet</code>, or <code>SizeConstraintSet</code>. For example, if an <code>IPSet</code> includes the IP address <code>192.0.2.44</code>, AWS WAF will allow, block, or count requests based on all IP addresses <i>except</i> <code>192.0.2.44</code>.</p>
22    pub fn negated(&self) -> bool {
23        self.negated
24    }
25    /// <p>The type of predicate in a <code>Rule</code>, such as <code>ByteMatch</code> or <code>IPSet</code>.</p>
26    pub fn r#type(&self) -> &crate::types::PredicateType {
27        &self.r#type
28    }
29    /// <p>A unique identifier for a predicate in a <code>Rule</code>, such as <code>ByteMatchSetId</code> or <code>IPSetId</code>. The ID is returned by the corresponding <code>Create</code> or <code>List</code> command.</p>
30    pub fn data_id(&self) -> &str {
31        use std::ops::Deref;
32        self.data_id.deref()
33    }
34}
35impl Predicate {
36    /// Creates a new builder-style object to manufacture [`Predicate`](crate::types::Predicate).
37    pub fn builder() -> crate::types::builders::PredicateBuilder {
38        crate::types::builders::PredicateBuilder::default()
39    }
40}
41
42/// A builder for [`Predicate`](crate::types::Predicate).
43#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::default::Default, ::std::fmt::Debug)]
44#[non_exhaustive]
45pub struct PredicateBuilder {
46    pub(crate) negated: ::std::option::Option<bool>,
47    pub(crate) r#type: ::std::option::Option<crate::types::PredicateType>,
48    pub(crate) data_id: ::std::option::Option<::std::string::String>,
49}
50impl PredicateBuilder {
51    /// <p>Set <code>Negated</code> to <code>False</code> if you want AWS WAF to allow, block, or count requests based on the settings in the specified <code>ByteMatchSet</code>, <code>IPSet</code>, <code>SqlInjectionMatchSet</code>, <code>XssMatchSet</code>, <code>RegexMatchSet</code>, <code>GeoMatchSet</code>, or <code>SizeConstraintSet</code>. For example, if an <code>IPSet</code> includes the IP address <code>192.0.2.44</code>, AWS WAF will allow or block requests based on that IP address.</p>
52    /// <p>Set <code>Negated</code> to <code>True</code> if you want AWS WAF to allow or block a request based on the negation of the settings in the <code>ByteMatchSet</code>, <code>IPSet</code>, <code>SqlInjectionMatchSet</code>, <code>XssMatchSet</code>, <code>RegexMatchSet</code>, <code>GeoMatchSet</code>, or <code>SizeConstraintSet</code>. For example, if an <code>IPSet</code> includes the IP address <code>192.0.2.44</code>, AWS WAF will allow, block, or count requests based on all IP addresses <i>except</i> <code>192.0.2.44</code>.</p>
53    /// This field is required.
54    pub fn negated(mut self, input: bool) -> Self {
55        self.negated = ::std::option::Option::Some(input);
56        self
57    }
58    /// <p>Set <code>Negated</code> to <code>False</code> if you want AWS WAF to allow, block, or count requests based on the settings in the specified <code>ByteMatchSet</code>, <code>IPSet</code>, <code>SqlInjectionMatchSet</code>, <code>XssMatchSet</code>, <code>RegexMatchSet</code>, <code>GeoMatchSet</code>, or <code>SizeConstraintSet</code>. For example, if an <code>IPSet</code> includes the IP address <code>192.0.2.44</code>, AWS WAF will allow or block requests based on that IP address.</p>
59    /// <p>Set <code>Negated</code> to <code>True</code> if you want AWS WAF to allow or block a request based on the negation of the settings in the <code>ByteMatchSet</code>, <code>IPSet</code>, <code>SqlInjectionMatchSet</code>, <code>XssMatchSet</code>, <code>RegexMatchSet</code>, <code>GeoMatchSet</code>, or <code>SizeConstraintSet</code>. For example, if an <code>IPSet</code> includes the IP address <code>192.0.2.44</code>, AWS WAF will allow, block, or count requests based on all IP addresses <i>except</i> <code>192.0.2.44</code>.</p>
60    pub fn set_negated(mut self, input: ::std::option::Option<bool>) -> Self {
61        self.negated = input;
62        self
63    }
64    /// <p>Set <code>Negated</code> to <code>False</code> if you want AWS WAF to allow, block, or count requests based on the settings in the specified <code>ByteMatchSet</code>, <code>IPSet</code>, <code>SqlInjectionMatchSet</code>, <code>XssMatchSet</code>, <code>RegexMatchSet</code>, <code>GeoMatchSet</code>, or <code>SizeConstraintSet</code>. For example, if an <code>IPSet</code> includes the IP address <code>192.0.2.44</code>, AWS WAF will allow or block requests based on that IP address.</p>
65    /// <p>Set <code>Negated</code> to <code>True</code> if you want AWS WAF to allow or block a request based on the negation of the settings in the <code>ByteMatchSet</code>, <code>IPSet</code>, <code>SqlInjectionMatchSet</code>, <code>XssMatchSet</code>, <code>RegexMatchSet</code>, <code>GeoMatchSet</code>, or <code>SizeConstraintSet</code>. For example, if an <code>IPSet</code> includes the IP address <code>192.0.2.44</code>, AWS WAF will allow, block, or count requests based on all IP addresses <i>except</i> <code>192.0.2.44</code>.</p>
66    pub fn get_negated(&self) -> &::std::option::Option<bool> {
67        &self.negated
68    }
69    /// <p>The type of predicate in a <code>Rule</code>, such as <code>ByteMatch</code> or <code>IPSet</code>.</p>
70    /// This field is required.
71    pub fn r#type(mut self, input: crate::types::PredicateType) -> Self {
72        self.r#type = ::std::option::Option::Some(input);
73        self
74    }
75    /// <p>The type of predicate in a <code>Rule</code>, such as <code>ByteMatch</code> or <code>IPSet</code>.</p>
76    pub fn set_type(mut self, input: ::std::option::Option<crate::types::PredicateType>) -> Self {
77        self.r#type = input;
78        self
79    }
80    /// <p>The type of predicate in a <code>Rule</code>, such as <code>ByteMatch</code> or <code>IPSet</code>.</p>
81    pub fn get_type(&self) -> &::std::option::Option<crate::types::PredicateType> {
82        &self.r#type
83    }
84    /// <p>A unique identifier for a predicate in a <code>Rule</code>, such as <code>ByteMatchSetId</code> or <code>IPSetId</code>. The ID is returned by the corresponding <code>Create</code> or <code>List</code> command.</p>
85    /// This field is required.
86    pub fn data_id(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
87        self.data_id = ::std::option::Option::Some(input.into());
88        self
89    }
90    /// <p>A unique identifier for a predicate in a <code>Rule</code>, such as <code>ByteMatchSetId</code> or <code>IPSetId</code>. The ID is returned by the corresponding <code>Create</code> or <code>List</code> command.</p>
91    pub fn set_data_id(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
92        self.data_id = input;
93        self
94    }
95    /// <p>A unique identifier for a predicate in a <code>Rule</code>, such as <code>ByteMatchSetId</code> or <code>IPSetId</code>. The ID is returned by the corresponding <code>Create</code> or <code>List</code> command.</p>
96    pub fn get_data_id(&self) -> &::std::option::Option<::std::string::String> {
97        &self.data_id
98    }
99    /// Consumes the builder and constructs a [`Predicate`](crate::types::Predicate).
100    /// This method will fail if any of the following fields are not set:
101    /// - [`negated`](crate::types::builders::PredicateBuilder::negated)
102    /// - [`r#type`](crate::types::builders::PredicateBuilder::type)
103    /// - [`data_id`](crate::types::builders::PredicateBuilder::data_id)
104    pub fn build(self) -> ::std::result::Result<crate::types::Predicate, ::aws_smithy_types::error::operation::BuildError> {
105        ::std::result::Result::Ok(crate::types::Predicate {
106            negated: self.negated.ok_or_else(|| {
107                ::aws_smithy_types::error::operation::BuildError::missing_field(
108                    "negated",
109                    "negated was not specified but it is required when building Predicate",
110                )
111            })?,
112            r#type: self.r#type.ok_or_else(|| {
113                ::aws_smithy_types::error::operation::BuildError::missing_field(
114                    "r#type",
115                    "r#type was not specified but it is required when building Predicate",
116                )
117            })?,
118            data_id: self.data_id.ok_or_else(|| {
119                ::aws_smithy_types::error::operation::BuildError::missing_field(
120                    "data_id",
121                    "data_id was not specified but it is required when building Predicate",
122                )
123            })?,
124        })
125    }
126}