1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.

/// <p>The configuration for inspecting IP addresses in an HTTP header that you specify, instead of using the IP address that's reported by the web request origin. Commonly, this is the X-Forwarded-For (XFF) header, but you can specify any header name.</p><note>
/// <p>If the specified header isn't present in the request, WAF doesn't apply the rule to the web request at all.</p>
/// </note>
/// <p>This configuration is used for <code>GeoMatchStatement</code> and <code>RateBasedStatement</code>. For <code>IPSetReferenceStatement</code>, use <code>IPSetForwardedIPConfig</code> instead.</p>
/// <p>WAF only evaluates the first IP address found in the specified HTTP header.</p>
#[non_exhaustive]
#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::fmt::Debug)]
pub struct ForwardedIpConfig {
    /// <p>The name of the HTTP header to use for the IP address. For example, to use the X-Forwarded-For (XFF) header, set this to <code>X-Forwarded-For</code>.</p><note>
    /// <p>If the specified header isn't present in the request, WAF doesn't apply the rule to the web request at all.</p>
    /// </note>
    pub header_name: ::std::string::String,
    /// <p>The match status to assign to the web request if the request doesn't have a valid IP address in the specified position.</p><note>
    /// <p>If the specified header isn't present in the request, WAF doesn't apply the rule to the web request at all.</p>
    /// </note>
    /// <p>You can specify the following fallback behaviors:</p>
    /// <ul>
    /// <li>
    /// <p><code>MATCH</code> - Treat the web request as matching the rule statement. WAF applies the rule action to the request.</p></li>
    /// <li>
    /// <p><code>NO_MATCH</code> - Treat the web request as not matching the rule statement.</p></li>
    /// </ul>
    pub fallback_behavior: crate::types::FallbackBehavior,
}
impl ForwardedIpConfig {
    /// <p>The name of the HTTP header to use for the IP address. For example, to use the X-Forwarded-For (XFF) header, set this to <code>X-Forwarded-For</code>.</p><note>
    /// <p>If the specified header isn't present in the request, WAF doesn't apply the rule to the web request at all.</p>
    /// </note>
    pub fn header_name(&self) -> &str {
        use std::ops::Deref;
        self.header_name.deref()
    }
    /// <p>The match status to assign to the web request if the request doesn't have a valid IP address in the specified position.</p><note>
    /// <p>If the specified header isn't present in the request, WAF doesn't apply the rule to the web request at all.</p>
    /// </note>
    /// <p>You can specify the following fallback behaviors:</p>
    /// <ul>
    /// <li>
    /// <p><code>MATCH</code> - Treat the web request as matching the rule statement. WAF applies the rule action to the request.</p></li>
    /// <li>
    /// <p><code>NO_MATCH</code> - Treat the web request as not matching the rule statement.</p></li>
    /// </ul>
    pub fn fallback_behavior(&self) -> &crate::types::FallbackBehavior {
        &self.fallback_behavior
    }
}
impl ForwardedIpConfig {
    /// Creates a new builder-style object to manufacture [`ForwardedIpConfig`](crate::types::ForwardedIpConfig).
    pub fn builder() -> crate::types::builders::ForwardedIpConfigBuilder {
        crate::types::builders::ForwardedIpConfigBuilder::default()
    }
}

/// A builder for [`ForwardedIpConfig`](crate::types::ForwardedIpConfig).
#[non_exhaustive]
#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::default::Default, ::std::fmt::Debug)]
pub struct ForwardedIpConfigBuilder {
    pub(crate) header_name: ::std::option::Option<::std::string::String>,
    pub(crate) fallback_behavior: ::std::option::Option<crate::types::FallbackBehavior>,
}
impl ForwardedIpConfigBuilder {
    /// <p>The name of the HTTP header to use for the IP address. For example, to use the X-Forwarded-For (XFF) header, set this to <code>X-Forwarded-For</code>.</p><note>
    /// <p>If the specified header isn't present in the request, WAF doesn't apply the rule to the web request at all.</p>
    /// </note>
    /// This field is required.
    pub fn header_name(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
        self.header_name = ::std::option::Option::Some(input.into());
        self
    }
    /// <p>The name of the HTTP header to use for the IP address. For example, to use the X-Forwarded-For (XFF) header, set this to <code>X-Forwarded-For</code>.</p><note>
    /// <p>If the specified header isn't present in the request, WAF doesn't apply the rule to the web request at all.</p>
    /// </note>
    pub fn set_header_name(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
        self.header_name = input;
        self
    }
    /// <p>The name of the HTTP header to use for the IP address. For example, to use the X-Forwarded-For (XFF) header, set this to <code>X-Forwarded-For</code>.</p><note>
    /// <p>If the specified header isn't present in the request, WAF doesn't apply the rule to the web request at all.</p>
    /// </note>
    pub fn get_header_name(&self) -> &::std::option::Option<::std::string::String> {
        &self.header_name
    }
    /// <p>The match status to assign to the web request if the request doesn't have a valid IP address in the specified position.</p><note>
    /// <p>If the specified header isn't present in the request, WAF doesn't apply the rule to the web request at all.</p>
    /// </note>
    /// <p>You can specify the following fallback behaviors:</p>
    /// <ul>
    /// <li>
    /// <p><code>MATCH</code> - Treat the web request as matching the rule statement. WAF applies the rule action to the request.</p></li>
    /// <li>
    /// <p><code>NO_MATCH</code> - Treat the web request as not matching the rule statement.</p></li>
    /// </ul>
    /// This field is required.
    pub fn fallback_behavior(mut self, input: crate::types::FallbackBehavior) -> Self {
        self.fallback_behavior = ::std::option::Option::Some(input);
        self
    }
    /// <p>The match status to assign to the web request if the request doesn't have a valid IP address in the specified position.</p><note>
    /// <p>If the specified header isn't present in the request, WAF doesn't apply the rule to the web request at all.</p>
    /// </note>
    /// <p>You can specify the following fallback behaviors:</p>
    /// <ul>
    /// <li>
    /// <p><code>MATCH</code> - Treat the web request as matching the rule statement. WAF applies the rule action to the request.</p></li>
    /// <li>
    /// <p><code>NO_MATCH</code> - Treat the web request as not matching the rule statement.</p></li>
    /// </ul>
    pub fn set_fallback_behavior(mut self, input: ::std::option::Option<crate::types::FallbackBehavior>) -> Self {
        self.fallback_behavior = input;
        self
    }
    /// <p>The match status to assign to the web request if the request doesn't have a valid IP address in the specified position.</p><note>
    /// <p>If the specified header isn't present in the request, WAF doesn't apply the rule to the web request at all.</p>
    /// </note>
    /// <p>You can specify the following fallback behaviors:</p>
    /// <ul>
    /// <li>
    /// <p><code>MATCH</code> - Treat the web request as matching the rule statement. WAF applies the rule action to the request.</p></li>
    /// <li>
    /// <p><code>NO_MATCH</code> - Treat the web request as not matching the rule statement.</p></li>
    /// </ul>
    pub fn get_fallback_behavior(&self) -> &::std::option::Option<crate::types::FallbackBehavior> {
        &self.fallback_behavior
    }
    /// Consumes the builder and constructs a [`ForwardedIpConfig`](crate::types::ForwardedIpConfig).
    /// This method will fail if any of the following fields are not set:
    /// - [`header_name`](crate::types::builders::ForwardedIpConfigBuilder::header_name)
    /// - [`fallback_behavior`](crate::types::builders::ForwardedIpConfigBuilder::fallback_behavior)
    pub fn build(self) -> ::std::result::Result<crate::types::ForwardedIpConfig, ::aws_smithy_types::error::operation::BuildError> {
        ::std::result::Result::Ok(crate::types::ForwardedIpConfig {
            header_name: self.header_name.ok_or_else(|| {
                ::aws_smithy_types::error::operation::BuildError::missing_field(
                    "header_name",
                    "header_name was not specified but it is required when building ForwardedIpConfig",
                )
            })?,
            fallback_behavior: self.fallback_behavior.ok_or_else(|| {
                ::aws_smithy_types::error::operation::BuildError::missing_field(
                    "fallback_behavior",
                    "fallback_behavior was not specified but it is required when building ForwardedIpConfig",
                )
            })?,
        })
    }
}