aws_sdk_waf/operation/update_rate_based_rule/builders.rs
1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2pub use crate::operation::update_rate_based_rule::_update_rate_based_rule_output::UpdateRateBasedRuleOutputBuilder;
3
4pub use crate::operation::update_rate_based_rule::_update_rate_based_rule_input::UpdateRateBasedRuleInputBuilder;
5
6impl crate::operation::update_rate_based_rule::builders::UpdateRateBasedRuleInputBuilder {
7 /// Sends a request with this input using the given client.
8 pub async fn send_with(
9 self,
10 client: &crate::Client,
11 ) -> ::std::result::Result<
12 crate::operation::update_rate_based_rule::UpdateRateBasedRuleOutput,
13 ::aws_smithy_runtime_api::client::result::SdkError<
14 crate::operation::update_rate_based_rule::UpdateRateBasedRuleError,
15 ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
16 >,
17 > {
18 let mut fluent_builder = client.update_rate_based_rule();
19 fluent_builder.inner = self;
20 fluent_builder.send().await
21 }
22}
23/// Fluent builder constructing a request to `UpdateRateBasedRule`.
24///
25/// <note>
26/// <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>
27/// <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>
28/// </note>
29/// <p>Inserts or deletes <code>Predicate</code> objects in a rule and updates the <code>RateLimit</code> in the rule.</p>
30/// <p>Each <code>Predicate</code> object identifies a predicate, such as a <code>ByteMatchSet</code> or an <code>IPSet</code>, that specifies the web requests that you want to block or count. The <code>RateLimit</code> specifies the number of requests every five minutes that triggers the rule.</p>
31/// <p>If you add more than one predicate to a <code>RateBasedRule</code>, a request must match all the predicates and exceed the <code>RateLimit</code> to be counted or blocked. For example, suppose you add the following to a <code>RateBasedRule</code>:</p>
32/// <ul>
33/// <li>
34/// <p>An <code>IPSet</code> that matches the IP address <code>192.0.2.44/32</code></p></li>
35/// <li>
36/// <p>A <code>ByteMatchSet</code> that matches <code>BadBot</code> in the <code>User-Agent</code> header</p></li>
37/// </ul>
38/// <p>Further, you specify a <code>RateLimit</code> of 1,000.</p>
39/// <p>You then add the <code>RateBasedRule</code> to a <code>WebACL</code> and specify that you want to block requests that satisfy the rule. For a request to be blocked, it must come from the IP address 192.0.2.44 <i>and</i> the <code>User-Agent</code> header in the request must contain the value <code>BadBot</code>. Further, requests that match these two conditions much be received at a rate of more than 1,000 every five minutes. If the rate drops below this limit, AWS WAF no longer blocks the requests.</p>
40/// <p>As a second example, suppose you want to limit requests to a particular page on your site. To do this, you could add the following to a <code>RateBasedRule</code>:</p>
41/// <ul>
42/// <li>
43/// <p>A <code>ByteMatchSet</code> with <code>FieldToMatch</code> of <code>URI</code></p></li>
44/// <li>
45/// <p>A <code>PositionalConstraint</code> of <code>STARTS_WITH</code></p></li>
46/// <li>
47/// <p>A <code>TargetString</code> of <code>login</code></p></li>
48/// </ul>
49/// <p>Further, you specify a <code>RateLimit</code> of 1,000.</p>
50/// <p>By adding this <code>RateBasedRule</code> to a <code>WebACL</code>, you could limit requests to your login page without affecting the rest of your site.</p>
51#[derive(::std::clone::Clone, ::std::fmt::Debug)]
52pub struct UpdateRateBasedRuleFluentBuilder {
53 handle: ::std::sync::Arc<crate::client::Handle>,
54 inner: crate::operation::update_rate_based_rule::builders::UpdateRateBasedRuleInputBuilder,
55 config_override: ::std::option::Option<crate::config::Builder>,
56}
57impl
58 crate::client::customize::internal::CustomizableSend<
59 crate::operation::update_rate_based_rule::UpdateRateBasedRuleOutput,
60 crate::operation::update_rate_based_rule::UpdateRateBasedRuleError,
61 > for UpdateRateBasedRuleFluentBuilder
62{
63 fn send(
64 self,
65 config_override: crate::config::Builder,
66 ) -> crate::client::customize::internal::BoxFuture<
67 crate::client::customize::internal::SendResult<
68 crate::operation::update_rate_based_rule::UpdateRateBasedRuleOutput,
69 crate::operation::update_rate_based_rule::UpdateRateBasedRuleError,
70 >,
71 > {
72 ::std::boxed::Box::pin(async move { self.config_override(config_override).send().await })
73 }
74}
75impl UpdateRateBasedRuleFluentBuilder {
76 /// Creates a new `UpdateRateBasedRuleFluentBuilder`.
77 pub(crate) fn new(handle: ::std::sync::Arc<crate::client::Handle>) -> Self {
78 Self {
79 handle,
80 inner: ::std::default::Default::default(),
81 config_override: ::std::option::Option::None,
82 }
83 }
84 /// Access the UpdateRateBasedRule as a reference.
85 pub fn as_input(&self) -> &crate::operation::update_rate_based_rule::builders::UpdateRateBasedRuleInputBuilder {
86 &self.inner
87 }
88 /// Sends the request and returns the response.
89 ///
90 /// If an error occurs, an `SdkError` will be returned with additional details that
91 /// can be matched against.
92 ///
93 /// By default, any retryable failures will be retried twice. Retry behavior
94 /// is configurable with the [RetryConfig](aws_smithy_types::retry::RetryConfig), which can be
95 /// set when configuring the client.
96 pub async fn send(
97 self,
98 ) -> ::std::result::Result<
99 crate::operation::update_rate_based_rule::UpdateRateBasedRuleOutput,
100 ::aws_smithy_runtime_api::client::result::SdkError<
101 crate::operation::update_rate_based_rule::UpdateRateBasedRuleError,
102 ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
103 >,
104 > {
105 let input = self
106 .inner
107 .build()
108 .map_err(::aws_smithy_runtime_api::client::result::SdkError::construction_failure)?;
109 let runtime_plugins = crate::operation::update_rate_based_rule::UpdateRateBasedRule::operation_runtime_plugins(
110 self.handle.runtime_plugins.clone(),
111 &self.handle.conf,
112 self.config_override,
113 );
114 crate::operation::update_rate_based_rule::UpdateRateBasedRule::orchestrate(&runtime_plugins, input).await
115 }
116
117 /// Consumes this builder, creating a customizable operation that can be modified before being sent.
118 pub fn customize(
119 self,
120 ) -> crate::client::customize::CustomizableOperation<
121 crate::operation::update_rate_based_rule::UpdateRateBasedRuleOutput,
122 crate::operation::update_rate_based_rule::UpdateRateBasedRuleError,
123 Self,
124 > {
125 crate::client::customize::CustomizableOperation::new(self)
126 }
127 pub(crate) fn config_override(mut self, config_override: impl ::std::convert::Into<crate::config::Builder>) -> Self {
128 self.set_config_override(::std::option::Option::Some(config_override.into()));
129 self
130 }
131
132 pub(crate) fn set_config_override(&mut self, config_override: ::std::option::Option<crate::config::Builder>) -> &mut Self {
133 self.config_override = config_override;
134 self
135 }
136 /// <p>The <code>RuleId</code> of the <code>RateBasedRule</code> that you want to update. <code>RuleId</code> is returned by <code>CreateRateBasedRule</code> and by <code>ListRateBasedRules</code>.</p>
137 pub fn rule_id(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
138 self.inner = self.inner.rule_id(input.into());
139 self
140 }
141 /// <p>The <code>RuleId</code> of the <code>RateBasedRule</code> that you want to update. <code>RuleId</code> is returned by <code>CreateRateBasedRule</code> and by <code>ListRateBasedRules</code>.</p>
142 pub fn set_rule_id(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
143 self.inner = self.inner.set_rule_id(input);
144 self
145 }
146 /// <p>The <code>RuleId</code> of the <code>RateBasedRule</code> that you want to update. <code>RuleId</code> is returned by <code>CreateRateBasedRule</code> and by <code>ListRateBasedRules</code>.</p>
147 pub fn get_rule_id(&self) -> &::std::option::Option<::std::string::String> {
148 self.inner.get_rule_id()
149 }
150 /// <p>The value returned by the most recent call to <code>GetChangeToken</code>.</p>
151 pub fn change_token(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
152 self.inner = self.inner.change_token(input.into());
153 self
154 }
155 /// <p>The value returned by the most recent call to <code>GetChangeToken</code>.</p>
156 pub fn set_change_token(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
157 self.inner = self.inner.set_change_token(input);
158 self
159 }
160 /// <p>The value returned by the most recent call to <code>GetChangeToken</code>.</p>
161 pub fn get_change_token(&self) -> &::std::option::Option<::std::string::String> {
162 self.inner.get_change_token()
163 }
164 ///
165 /// Appends an item to `Updates`.
166 ///
167 /// To override the contents of this collection use [`set_updates`](Self::set_updates).
168 ///
169 /// <p>An array of <code>RuleUpdate</code> objects that you want to insert into or delete from a <code>RateBasedRule</code>.</p>
170 pub fn updates(mut self, input: crate::types::RuleUpdate) -> Self {
171 self.inner = self.inner.updates(input);
172 self
173 }
174 /// <p>An array of <code>RuleUpdate</code> objects that you want to insert into or delete from a <code>RateBasedRule</code>.</p>
175 pub fn set_updates(mut self, input: ::std::option::Option<::std::vec::Vec<crate::types::RuleUpdate>>) -> Self {
176 self.inner = self.inner.set_updates(input);
177 self
178 }
179 /// <p>An array of <code>RuleUpdate</code> objects that you want to insert into or delete from a <code>RateBasedRule</code>.</p>
180 pub fn get_updates(&self) -> &::std::option::Option<::std::vec::Vec<crate::types::RuleUpdate>> {
181 self.inner.get_updates()
182 }
183 /// <p>The maximum number of requests, which have an identical value in the field specified by the <code>RateKey</code>, allowed in a five-minute period. If the number of requests exceeds the <code>RateLimit</code> and the other predicates specified in the rule are also met, AWS WAF triggers the action that is specified for this rule.</p>
184 pub fn rate_limit(mut self, input: i64) -> Self {
185 self.inner = self.inner.rate_limit(input);
186 self
187 }
188 /// <p>The maximum number of requests, which have an identical value in the field specified by the <code>RateKey</code>, allowed in a five-minute period. If the number of requests exceeds the <code>RateLimit</code> and the other predicates specified in the rule are also met, AWS WAF triggers the action that is specified for this rule.</p>
189 pub fn set_rate_limit(mut self, input: ::std::option::Option<i64>) -> Self {
190 self.inner = self.inner.set_rate_limit(input);
191 self
192 }
193 /// <p>The maximum number of requests, which have an identical value in the field specified by the <code>RateKey</code>, allowed in a five-minute period. If the number of requests exceeds the <code>RateLimit</code> and the other predicates specified in the rule are also met, AWS WAF triggers the action that is specified for this rule.</p>
194 pub fn get_rate_limit(&self) -> &::std::option::Option<i64> {
195 self.inner.get_rate_limit()
196 }
197}