// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
pub use crate::operation::update_rate_based_rule::_update_rate_based_rule_input::UpdateRateBasedRuleInputBuilder;
pub use crate::operation::update_rate_based_rule::_update_rate_based_rule_output::UpdateRateBasedRuleOutputBuilder;
impl crate::operation::update_rate_based_rule::builders::UpdateRateBasedRuleInputBuilder {
/// Sends a request with this input using the given client.
pub async fn send_with(
self,
client: &crate::Client,
) -> ::std::result::Result<
crate::operation::update_rate_based_rule::UpdateRateBasedRuleOutput,
::aws_smithy_runtime_api::client::result::SdkError<
crate::operation::update_rate_based_rule::UpdateRateBasedRuleError,
::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
>,
> {
let mut fluent_builder = client.update_rate_based_rule();
fluent_builder.inner = self;
fluent_builder.send().await
}
}
/// Fluent builder constructing a request to `UpdateRateBasedRule`.
///
/// <note>
/// <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>
/// <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>
/// </note>
/// <p>Inserts or deletes <code>Predicate</code> objects in a rule and updates the <code>RateLimit</code> in the rule.</p>
/// <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>
/// <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>
/// <ul>
/// <li>
/// <p>An <code>IPSet</code> that matches the IP address <code>192.0.2.44/32</code></p></li>
/// <li>
/// <p>A <code>ByteMatchSet</code> that matches <code>BadBot</code> in the <code>User-Agent</code> header</p></li>
/// </ul>
/// <p>Further, you specify a <code>RateLimit</code> of 1,000.</p>
/// <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>
/// <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>
/// <ul>
/// <li>
/// <p>A <code>ByteMatchSet</code> with <code>FieldToMatch</code> of <code>URI</code></p></li>
/// <li>
/// <p>A <code>PositionalConstraint</code> of <code>STARTS_WITH</code></p></li>
/// <li>
/// <p>A <code>TargetString</code> of <code>login</code></p></li>
/// </ul>
/// <p>Further, you specify a <code>RateLimit</code> of 1,000.</p>
/// <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>
#[derive(::std::clone::Clone, ::std::fmt::Debug)]
pub struct UpdateRateBasedRuleFluentBuilder {
handle: ::std::sync::Arc<crate::client::Handle>,
inner: crate::operation::update_rate_based_rule::builders::UpdateRateBasedRuleInputBuilder,
config_override: ::std::option::Option<crate::config::Builder>,
}
impl
crate::client::customize::internal::CustomizableSend<
crate::operation::update_rate_based_rule::UpdateRateBasedRuleOutput,
crate::operation::update_rate_based_rule::UpdateRateBasedRuleError,
> for UpdateRateBasedRuleFluentBuilder
{
fn send(
self,
config_override: crate::config::Builder,
) -> crate::client::customize::internal::BoxFuture<
crate::client::customize::internal::SendResult<
crate::operation::update_rate_based_rule::UpdateRateBasedRuleOutput,
crate::operation::update_rate_based_rule::UpdateRateBasedRuleError,
>,
> {
::std::boxed::Box::pin(async move { self.config_override(config_override).send().await })
}
}
impl UpdateRateBasedRuleFluentBuilder {
/// Creates a new `UpdateRateBasedRuleFluentBuilder`.
pub(crate) fn new(handle: ::std::sync::Arc<crate::client::Handle>) -> Self {
Self {
handle,
inner: ::std::default::Default::default(),
config_override: ::std::option::Option::None,
}
}
/// Access the UpdateRateBasedRule as a reference.
pub fn as_input(&self) -> &crate::operation::update_rate_based_rule::builders::UpdateRateBasedRuleInputBuilder {
&self.inner
}
/// Sends the request and returns the response.
///
/// If an error occurs, an `SdkError` will be returned with additional details that
/// can be matched against.
///
/// By default, any retryable failures will be retried twice. Retry behavior
/// is configurable with the [RetryConfig](aws_smithy_types::retry::RetryConfig), which can be
/// set when configuring the client.
pub async fn send(
self,
) -> ::std::result::Result<
crate::operation::update_rate_based_rule::UpdateRateBasedRuleOutput,
::aws_smithy_runtime_api::client::result::SdkError<
crate::operation::update_rate_based_rule::UpdateRateBasedRuleError,
::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
>,
> {
let input = self
.inner
.build()
.map_err(::aws_smithy_runtime_api::client::result::SdkError::construction_failure)?;
let runtime_plugins = crate::operation::update_rate_based_rule::UpdateRateBasedRule::operation_runtime_plugins(
self.handle.runtime_plugins.clone(),
&self.handle.conf,
self.config_override,
);
crate::operation::update_rate_based_rule::UpdateRateBasedRule::orchestrate(&runtime_plugins, input).await
}
/// Consumes this builder, creating a customizable operation that can be modified before being sent.
pub fn customize(
self,
) -> crate::client::customize::CustomizableOperation<
crate::operation::update_rate_based_rule::UpdateRateBasedRuleOutput,
crate::operation::update_rate_based_rule::UpdateRateBasedRuleError,
Self,
> {
crate::client::customize::CustomizableOperation::new(self)
}
pub(crate) fn config_override(mut self, config_override: impl ::std::convert::Into<crate::config::Builder>) -> Self {
self.set_config_override(::std::option::Option::Some(config_override.into()));
self
}
pub(crate) fn set_config_override(&mut self, config_override: ::std::option::Option<crate::config::Builder>) -> &mut Self {
self.config_override = config_override;
self
}
/// <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>
pub fn rule_id(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
self.inner = self.inner.rule_id(input.into());
self
}
/// <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>
pub fn set_rule_id(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
self.inner = self.inner.set_rule_id(input);
self
}
/// <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>
pub fn get_rule_id(&self) -> &::std::option::Option<::std::string::String> {
self.inner.get_rule_id()
}
/// <p>The value returned by the most recent call to <code>GetChangeToken</code>.</p>
pub fn change_token(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
self.inner = self.inner.change_token(input.into());
self
}
/// <p>The value returned by the most recent call to <code>GetChangeToken</code>.</p>
pub fn set_change_token(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
self.inner = self.inner.set_change_token(input);
self
}
/// <p>The value returned by the most recent call to <code>GetChangeToken</code>.</p>
pub fn get_change_token(&self) -> &::std::option::Option<::std::string::String> {
self.inner.get_change_token()
}
///
/// Appends an item to `Updates`.
///
/// To override the contents of this collection use [`set_updates`](Self::set_updates).
///
/// <p>An array of <code>RuleUpdate</code> objects that you want to insert into or delete from a <code>RateBasedRule</code>.</p>
pub fn updates(mut self, input: crate::types::RuleUpdate) -> Self {
self.inner = self.inner.updates(input);
self
}
/// <p>An array of <code>RuleUpdate</code> objects that you want to insert into or delete from a <code>RateBasedRule</code>.</p>
pub fn set_updates(mut self, input: ::std::option::Option<::std::vec::Vec<crate::types::RuleUpdate>>) -> Self {
self.inner = self.inner.set_updates(input);
self
}
/// <p>An array of <code>RuleUpdate</code> objects that you want to insert into or delete from a <code>RateBasedRule</code>.</p>
pub fn get_updates(&self) -> &::std::option::Option<::std::vec::Vec<crate::types::RuleUpdate>> {
self.inner.get_updates()
}
/// <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>
pub fn rate_limit(mut self, input: i64) -> Self {
self.inner = self.inner.rate_limit(input);
self
}
/// <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>
pub fn set_rate_limit(mut self, input: ::std::option::Option<i64>) -> Self {
self.inner = self.inner.set_rate_limit(input);
self
}
/// <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>
pub fn get_rate_limit(&self) -> &::std::option::Option<i64> {
self.inner.get_rate_limit()
}
}