aws_sdk_waf/types/
_http_request.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>The response from a <code>GetSampledRequests</code> request includes an <code>HTTPRequest</code> complex type that appears as <code>Request</code> in the response syntax. <code>HTTPRequest</code> contains information about one of the web requests that were returned by <code>GetSampledRequests</code>.</p>
8#[non_exhaustive]
9#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::fmt::Debug)]
10pub struct HttpRequest {
11    /// <p>The IP address that the request originated from. If the <code>WebACL</code> is associated with a CloudFront distribution, this is the value of one of the following fields in CloudFront access logs:</p>
12    /// <ul>
13    /// <li>
14    /// <p><code>c-ip</code>, if the viewer did not use an HTTP proxy or a load balancer to send the request</p></li>
15    /// <li>
16    /// <p><code>x-forwarded-for</code>, if the viewer did use an HTTP proxy or a load balancer to send the request</p></li>
17    /// </ul>
18    pub client_ip: ::std::option::Option<::std::string::String>,
19    /// <p>The two-letter country code for the country that the request originated from. For a current list of country codes, see the Wikipedia entry <a href="https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2">ISO 3166-1 alpha-2</a>.</p>
20    pub country: ::std::option::Option<::std::string::String>,
21    /// <p>The part of a web request that identifies the resource, for example, <code>/images/daily-ad.jpg</code>.</p>
22    pub uri: ::std::option::Option<::std::string::String>,
23    /// <p>The HTTP method specified in the sampled web request. CloudFront supports the following methods: <code>DELETE</code>, <code>GET</code>, <code>HEAD</code>, <code>OPTIONS</code>, <code>PATCH</code>, <code>POST</code>, and <code>PUT</code>.</p>
24    pub method: ::std::option::Option<::std::string::String>,
25    /// <p>The HTTP version specified in the sampled web request, for example, <code>HTTP/1.1</code>.</p>
26    pub http_version: ::std::option::Option<::std::string::String>,
27    /// <p>A complex type that contains two values for each header in the sampled web request: the name of the header and the value of the header.</p>
28    pub headers: ::std::option::Option<::std::vec::Vec<crate::types::HttpHeader>>,
29}
30impl HttpRequest {
31    /// <p>The IP address that the request originated from. If the <code>WebACL</code> is associated with a CloudFront distribution, this is the value of one of the following fields in CloudFront access logs:</p>
32    /// <ul>
33    /// <li>
34    /// <p><code>c-ip</code>, if the viewer did not use an HTTP proxy or a load balancer to send the request</p></li>
35    /// <li>
36    /// <p><code>x-forwarded-for</code>, if the viewer did use an HTTP proxy or a load balancer to send the request</p></li>
37    /// </ul>
38    pub fn client_ip(&self) -> ::std::option::Option<&str> {
39        self.client_ip.as_deref()
40    }
41    /// <p>The two-letter country code for the country that the request originated from. For a current list of country codes, see the Wikipedia entry <a href="https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2">ISO 3166-1 alpha-2</a>.</p>
42    pub fn country(&self) -> ::std::option::Option<&str> {
43        self.country.as_deref()
44    }
45    /// <p>The part of a web request that identifies the resource, for example, <code>/images/daily-ad.jpg</code>.</p>
46    pub fn uri(&self) -> ::std::option::Option<&str> {
47        self.uri.as_deref()
48    }
49    /// <p>The HTTP method specified in the sampled web request. CloudFront supports the following methods: <code>DELETE</code>, <code>GET</code>, <code>HEAD</code>, <code>OPTIONS</code>, <code>PATCH</code>, <code>POST</code>, and <code>PUT</code>.</p>
50    pub fn method(&self) -> ::std::option::Option<&str> {
51        self.method.as_deref()
52    }
53    /// <p>The HTTP version specified in the sampled web request, for example, <code>HTTP/1.1</code>.</p>
54    pub fn http_version(&self) -> ::std::option::Option<&str> {
55        self.http_version.as_deref()
56    }
57    /// <p>A complex type that contains two values for each header in the sampled web request: the name of the header and the value of the header.</p>
58    ///
59    /// If no value was sent for this field, a default will be set. If you want to determine if no value was sent, use `.headers.is_none()`.
60    pub fn headers(&self) -> &[crate::types::HttpHeader] {
61        self.headers.as_deref().unwrap_or_default()
62    }
63}
64impl HttpRequest {
65    /// Creates a new builder-style object to manufacture [`HttpRequest`](crate::types::HttpRequest).
66    pub fn builder() -> crate::types::builders::HttpRequestBuilder {
67        crate::types::builders::HttpRequestBuilder::default()
68    }
69}
70
71/// A builder for [`HttpRequest`](crate::types::HttpRequest).
72#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::default::Default, ::std::fmt::Debug)]
73#[non_exhaustive]
74pub struct HttpRequestBuilder {
75    pub(crate) client_ip: ::std::option::Option<::std::string::String>,
76    pub(crate) country: ::std::option::Option<::std::string::String>,
77    pub(crate) uri: ::std::option::Option<::std::string::String>,
78    pub(crate) method: ::std::option::Option<::std::string::String>,
79    pub(crate) http_version: ::std::option::Option<::std::string::String>,
80    pub(crate) headers: ::std::option::Option<::std::vec::Vec<crate::types::HttpHeader>>,
81}
82impl HttpRequestBuilder {
83    /// <p>The IP address that the request originated from. If the <code>WebACL</code> is associated with a CloudFront distribution, this is the value of one of the following fields in CloudFront access logs:</p>
84    /// <ul>
85    /// <li>
86    /// <p><code>c-ip</code>, if the viewer did not use an HTTP proxy or a load balancer to send the request</p></li>
87    /// <li>
88    /// <p><code>x-forwarded-for</code>, if the viewer did use an HTTP proxy or a load balancer to send the request</p></li>
89    /// </ul>
90    pub fn client_ip(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
91        self.client_ip = ::std::option::Option::Some(input.into());
92        self
93    }
94    /// <p>The IP address that the request originated from. If the <code>WebACL</code> is associated with a CloudFront distribution, this is the value of one of the following fields in CloudFront access logs:</p>
95    /// <ul>
96    /// <li>
97    /// <p><code>c-ip</code>, if the viewer did not use an HTTP proxy or a load balancer to send the request</p></li>
98    /// <li>
99    /// <p><code>x-forwarded-for</code>, if the viewer did use an HTTP proxy or a load balancer to send the request</p></li>
100    /// </ul>
101    pub fn set_client_ip(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
102        self.client_ip = input;
103        self
104    }
105    /// <p>The IP address that the request originated from. If the <code>WebACL</code> is associated with a CloudFront distribution, this is the value of one of the following fields in CloudFront access logs:</p>
106    /// <ul>
107    /// <li>
108    /// <p><code>c-ip</code>, if the viewer did not use an HTTP proxy or a load balancer to send the request</p></li>
109    /// <li>
110    /// <p><code>x-forwarded-for</code>, if the viewer did use an HTTP proxy or a load balancer to send the request</p></li>
111    /// </ul>
112    pub fn get_client_ip(&self) -> &::std::option::Option<::std::string::String> {
113        &self.client_ip
114    }
115    /// <p>The two-letter country code for the country that the request originated from. For a current list of country codes, see the Wikipedia entry <a href="https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2">ISO 3166-1 alpha-2</a>.</p>
116    pub fn country(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
117        self.country = ::std::option::Option::Some(input.into());
118        self
119    }
120    /// <p>The two-letter country code for the country that the request originated from. For a current list of country codes, see the Wikipedia entry <a href="https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2">ISO 3166-1 alpha-2</a>.</p>
121    pub fn set_country(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
122        self.country = input;
123        self
124    }
125    /// <p>The two-letter country code for the country that the request originated from. For a current list of country codes, see the Wikipedia entry <a href="https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2">ISO 3166-1 alpha-2</a>.</p>
126    pub fn get_country(&self) -> &::std::option::Option<::std::string::String> {
127        &self.country
128    }
129    /// <p>The part of a web request that identifies the resource, for example, <code>/images/daily-ad.jpg</code>.</p>
130    pub fn uri(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
131        self.uri = ::std::option::Option::Some(input.into());
132        self
133    }
134    /// <p>The part of a web request that identifies the resource, for example, <code>/images/daily-ad.jpg</code>.</p>
135    pub fn set_uri(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
136        self.uri = input;
137        self
138    }
139    /// <p>The part of a web request that identifies the resource, for example, <code>/images/daily-ad.jpg</code>.</p>
140    pub fn get_uri(&self) -> &::std::option::Option<::std::string::String> {
141        &self.uri
142    }
143    /// <p>The HTTP method specified in the sampled web request. CloudFront supports the following methods: <code>DELETE</code>, <code>GET</code>, <code>HEAD</code>, <code>OPTIONS</code>, <code>PATCH</code>, <code>POST</code>, and <code>PUT</code>.</p>
144    pub fn method(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
145        self.method = ::std::option::Option::Some(input.into());
146        self
147    }
148    /// <p>The HTTP method specified in the sampled web request. CloudFront supports the following methods: <code>DELETE</code>, <code>GET</code>, <code>HEAD</code>, <code>OPTIONS</code>, <code>PATCH</code>, <code>POST</code>, and <code>PUT</code>.</p>
149    pub fn set_method(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
150        self.method = input;
151        self
152    }
153    /// <p>The HTTP method specified in the sampled web request. CloudFront supports the following methods: <code>DELETE</code>, <code>GET</code>, <code>HEAD</code>, <code>OPTIONS</code>, <code>PATCH</code>, <code>POST</code>, and <code>PUT</code>.</p>
154    pub fn get_method(&self) -> &::std::option::Option<::std::string::String> {
155        &self.method
156    }
157    /// <p>The HTTP version specified in the sampled web request, for example, <code>HTTP/1.1</code>.</p>
158    pub fn http_version(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
159        self.http_version = ::std::option::Option::Some(input.into());
160        self
161    }
162    /// <p>The HTTP version specified in the sampled web request, for example, <code>HTTP/1.1</code>.</p>
163    pub fn set_http_version(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
164        self.http_version = input;
165        self
166    }
167    /// <p>The HTTP version specified in the sampled web request, for example, <code>HTTP/1.1</code>.</p>
168    pub fn get_http_version(&self) -> &::std::option::Option<::std::string::String> {
169        &self.http_version
170    }
171    /// Appends an item to `headers`.
172    ///
173    /// To override the contents of this collection use [`set_headers`](Self::set_headers).
174    ///
175    /// <p>A complex type that contains two values for each header in the sampled web request: the name of the header and the value of the header.</p>
176    pub fn headers(mut self, input: crate::types::HttpHeader) -> Self {
177        let mut v = self.headers.unwrap_or_default();
178        v.push(input);
179        self.headers = ::std::option::Option::Some(v);
180        self
181    }
182    /// <p>A complex type that contains two values for each header in the sampled web request: the name of the header and the value of the header.</p>
183    pub fn set_headers(mut self, input: ::std::option::Option<::std::vec::Vec<crate::types::HttpHeader>>) -> Self {
184        self.headers = input;
185        self
186    }
187    /// <p>A complex type that contains two values for each header in the sampled web request: the name of the header and the value of the header.</p>
188    pub fn get_headers(&self) -> &::std::option::Option<::std::vec::Vec<crate::types::HttpHeader>> {
189        &self.headers
190    }
191    /// Consumes the builder and constructs a [`HttpRequest`](crate::types::HttpRequest).
192    pub fn build(self) -> crate::types::HttpRequest {
193        crate::types::HttpRequest {
194            client_ip: self.client_ip,
195            country: self.country,
196            uri: self.uri,
197            method: self.method,
198            http_version: self.http_version,
199            headers: self.headers,
200        }
201    }
202}