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 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
/// <p>Part of the response from <code>GetSampledRequests</code>. This is a complex type that appears as <code>Request</code> in the response syntax. <code>HTTPRequest</code> contains information about one of the web requests.</p>
#[non_exhaustive]
#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::fmt::Debug)]
pub struct HttpRequest {
/// <p>The IP address that the request originated from. If the web ACL is associated with a CloudFront distribution, this is the value of one of the following fields in CloudFront access logs:</p>
/// <ul>
/// <li>
/// <p><code>c-ip</code>, if the viewer did not use an HTTP proxy or a load balancer to send the request</p></li>
/// <li>
/// <p><code>x-forwarded-for</code>, if the viewer did use an HTTP proxy or a load balancer to send the request</p></li>
/// </ul>
pub client_ip: ::std::option::Option<::std::string::String>,
/// <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>
pub country: ::std::option::Option<::std::string::String>,
/// <p>The URI path of the request, which identifies the resource, for example, <code>/images/daily-ad.jpg</code>.</p>
pub uri: ::std::option::Option<::std::string::String>,
/// <p>The HTTP method specified in the sampled web request.</p>
pub method: ::std::option::Option<::std::string::String>,
/// <p>The HTTP version specified in the sampled web request, for example, <code>HTTP/1.1</code>.</p>
pub http_version: ::std::option::Option<::std::string::String>,
/// <p>A complex type that contains the name and value for each header in the sampled web request.</p>
pub headers: ::std::option::Option<::std::vec::Vec<crate::types::HttpHeader>>,
}
impl HttpRequest {
/// <p>The IP address that the request originated from. If the web ACL is associated with a CloudFront distribution, this is the value of one of the following fields in CloudFront access logs:</p>
/// <ul>
/// <li>
/// <p><code>c-ip</code>, if the viewer did not use an HTTP proxy or a load balancer to send the request</p></li>
/// <li>
/// <p><code>x-forwarded-for</code>, if the viewer did use an HTTP proxy or a load balancer to send the request</p></li>
/// </ul>
pub fn client_ip(&self) -> ::std::option::Option<&str> {
self.client_ip.as_deref()
}
/// <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>
pub fn country(&self) -> ::std::option::Option<&str> {
self.country.as_deref()
}
/// <p>The URI path of the request, which identifies the resource, for example, <code>/images/daily-ad.jpg</code>.</p>
pub fn uri(&self) -> ::std::option::Option<&str> {
self.uri.as_deref()
}
/// <p>The HTTP method specified in the sampled web request.</p>
pub fn method(&self) -> ::std::option::Option<&str> {
self.method.as_deref()
}
/// <p>The HTTP version specified in the sampled web request, for example, <code>HTTP/1.1</code>.</p>
pub fn http_version(&self) -> ::std::option::Option<&str> {
self.http_version.as_deref()
}
/// <p>A complex type that contains the name and value for each header in the sampled web request.</p>
///
/// 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()`.
pub fn headers(&self) -> &[crate::types::HttpHeader] {
self.headers.as_deref().unwrap_or_default()
}
}
impl HttpRequest {
/// Creates a new builder-style object to manufacture [`HttpRequest`](crate::types::HttpRequest).
pub fn builder() -> crate::types::builders::HttpRequestBuilder {
crate::types::builders::HttpRequestBuilder::default()
}
}
/// A builder for [`HttpRequest`](crate::types::HttpRequest).
#[non_exhaustive]
#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::default::Default, ::std::fmt::Debug)]
pub struct HttpRequestBuilder {
pub(crate) client_ip: ::std::option::Option<::std::string::String>,
pub(crate) country: ::std::option::Option<::std::string::String>,
pub(crate) uri: ::std::option::Option<::std::string::String>,
pub(crate) method: ::std::option::Option<::std::string::String>,
pub(crate) http_version: ::std::option::Option<::std::string::String>,
pub(crate) headers: ::std::option::Option<::std::vec::Vec<crate::types::HttpHeader>>,
}
impl HttpRequestBuilder {
/// <p>The IP address that the request originated from. If the web ACL is associated with a CloudFront distribution, this is the value of one of the following fields in CloudFront access logs:</p>
/// <ul>
/// <li>
/// <p><code>c-ip</code>, if the viewer did not use an HTTP proxy or a load balancer to send the request</p></li>
/// <li>
/// <p><code>x-forwarded-for</code>, if the viewer did use an HTTP proxy or a load balancer to send the request</p></li>
/// </ul>
pub fn client_ip(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
self.client_ip = ::std::option::Option::Some(input.into());
self
}
/// <p>The IP address that the request originated from. If the web ACL is associated with a CloudFront distribution, this is the value of one of the following fields in CloudFront access logs:</p>
/// <ul>
/// <li>
/// <p><code>c-ip</code>, if the viewer did not use an HTTP proxy or a load balancer to send the request</p></li>
/// <li>
/// <p><code>x-forwarded-for</code>, if the viewer did use an HTTP proxy or a load balancer to send the request</p></li>
/// </ul>
pub fn set_client_ip(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
self.client_ip = input;
self
}
/// <p>The IP address that the request originated from. If the web ACL is associated with a CloudFront distribution, this is the value of one of the following fields in CloudFront access logs:</p>
/// <ul>
/// <li>
/// <p><code>c-ip</code>, if the viewer did not use an HTTP proxy or a load balancer to send the request</p></li>
/// <li>
/// <p><code>x-forwarded-for</code>, if the viewer did use an HTTP proxy or a load balancer to send the request</p></li>
/// </ul>
pub fn get_client_ip(&self) -> &::std::option::Option<::std::string::String> {
&self.client_ip
}
/// <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>
pub fn country(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
self.country = ::std::option::Option::Some(input.into());
self
}
/// <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>
pub fn set_country(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
self.country = input;
self
}
/// <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>
pub fn get_country(&self) -> &::std::option::Option<::std::string::String> {
&self.country
}
/// <p>The URI path of the request, which identifies the resource, for example, <code>/images/daily-ad.jpg</code>.</p>
pub fn uri(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
self.uri = ::std::option::Option::Some(input.into());
self
}
/// <p>The URI path of the request, which identifies the resource, for example, <code>/images/daily-ad.jpg</code>.</p>
pub fn set_uri(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
self.uri = input;
self
}
/// <p>The URI path of the request, which identifies the resource, for example, <code>/images/daily-ad.jpg</code>.</p>
pub fn get_uri(&self) -> &::std::option::Option<::std::string::String> {
&self.uri
}
/// <p>The HTTP method specified in the sampled web request.</p>
pub fn method(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
self.method = ::std::option::Option::Some(input.into());
self
}
/// <p>The HTTP method specified in the sampled web request.</p>
pub fn set_method(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
self.method = input;
self
}
/// <p>The HTTP method specified in the sampled web request.</p>
pub fn get_method(&self) -> &::std::option::Option<::std::string::String> {
&self.method
}
/// <p>The HTTP version specified in the sampled web request, for example, <code>HTTP/1.1</code>.</p>
pub fn http_version(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
self.http_version = ::std::option::Option::Some(input.into());
self
}
/// <p>The HTTP version specified in the sampled web request, for example, <code>HTTP/1.1</code>.</p>
pub fn set_http_version(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
self.http_version = input;
self
}
/// <p>The HTTP version specified in the sampled web request, for example, <code>HTTP/1.1</code>.</p>
pub fn get_http_version(&self) -> &::std::option::Option<::std::string::String> {
&self.http_version
}
/// Appends an item to `headers`.
///
/// To override the contents of this collection use [`set_headers`](Self::set_headers).
///
/// <p>A complex type that contains the name and value for each header in the sampled web request.</p>
pub fn headers(mut self, input: crate::types::HttpHeader) -> Self {
let mut v = self.headers.unwrap_or_default();
v.push(input);
self.headers = ::std::option::Option::Some(v);
self
}
/// <p>A complex type that contains the name and value for each header in the sampled web request.</p>
pub fn set_headers(mut self, input: ::std::option::Option<::std::vec::Vec<crate::types::HttpHeader>>) -> Self {
self.headers = input;
self
}
/// <p>A complex type that contains the name and value for each header in the sampled web request.</p>
pub fn get_headers(&self) -> &::std::option::Option<::std::vec::Vec<crate::types::HttpHeader>> {
&self.headers
}
/// Consumes the builder and constructs a [`HttpRequest`](crate::types::HttpRequest).
pub fn build(self) -> crate::types::HttpRequest {
crate::types::HttpRequest {
client_ip: self.client_ip,
country: self.country,
uri: self.uri,
method: self.method,
http_version: self.http_version,
headers: self.headers,
}
}
}