aws_sdk_waf/operation/create_rule/
builders.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2pub use crate::operation::create_rule::_create_rule_output::CreateRuleOutputBuilder;
3
4pub use crate::operation::create_rule::_create_rule_input::CreateRuleInputBuilder;
5
6impl crate::operation::create_rule::builders::CreateRuleInputBuilder {
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::create_rule::CreateRuleOutput,
13        ::aws_smithy_runtime_api::client::result::SdkError<
14            crate::operation::create_rule::CreateRuleError,
15            ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
16        >,
17    > {
18        let mut fluent_builder = client.create_rule();
19        fluent_builder.inner = self;
20        fluent_builder.send().await
21    }
22}
23/// Fluent builder constructing a request to `CreateRule`.
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>Creates a <code>Rule</code>, which contains the <code>IPSet</code> objects, <code>ByteMatchSet</code> objects, and other predicates that identify the requests that you want to block. If you add more than one predicate to a <code>Rule</code>, a request must match all of the specifications to be allowed or blocked. For example, suppose that you add the following to a <code>Rule</code>:</p>
30/// <ul>
31/// <li>
32/// <p>An <code>IPSet</code> that matches the IP address <code>192.0.2.44/32</code></p></li>
33/// <li>
34/// <p>A <code>ByteMatchSet</code> that matches <code>BadBot</code> in the <code>User-Agent</code> header</p></li>
35/// </ul>
36/// <p>You then add the <code>Rule</code> to a <code>WebACL</code> and specify that you want to blocks requests that satisfy the <code>Rule</code>. 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>.</p>
37/// <p>To create and configure a <code>Rule</code>, perform the following steps:</p>
38/// <ol>
39/// <li>
40/// <p>Create and update the predicates that you want to include in the <code>Rule</code>. For more information, see <code>CreateByteMatchSet</code>, <code>CreateIPSet</code>, and <code>CreateSqlInjectionMatchSet</code>.</p></li>
41/// <li>
42/// <p>Use <code>GetChangeToken</code> to get the change token that you provide in the <code>ChangeToken</code> parameter of a <code>CreateRule</code> request.</p></li>
43/// <li>
44/// <p>Submit a <code>CreateRule</code> request.</p></li>
45/// <li>
46/// <p>Use <code>GetChangeToken</code> to get the change token that you provide in the <code>ChangeToken</code> parameter of an <code>UpdateRule</code> request.</p></li>
47/// <li>
48/// <p>Submit an <code>UpdateRule</code> request to specify the predicates that you want to include in the <code>Rule</code>.</p></li>
49/// <li>
50/// <p>Create and update a <code>WebACL</code> that contains the <code>Rule</code>. For more information, see <code>CreateWebACL</code>.</p></li>
51/// </ol>
52/// <p>For more information about how to use the AWS WAF API to allow or block HTTP requests, see the <a href="https://docs.aws.amazon.com/waf/latest/developerguide/">AWS WAF Developer Guide</a>.</p>
53#[derive(::std::clone::Clone, ::std::fmt::Debug)]
54pub struct CreateRuleFluentBuilder {
55    handle: ::std::sync::Arc<crate::client::Handle>,
56    inner: crate::operation::create_rule::builders::CreateRuleInputBuilder,
57    config_override: ::std::option::Option<crate::config::Builder>,
58}
59impl
60    crate::client::customize::internal::CustomizableSend<
61        crate::operation::create_rule::CreateRuleOutput,
62        crate::operation::create_rule::CreateRuleError,
63    > for CreateRuleFluentBuilder
64{
65    fn send(
66        self,
67        config_override: crate::config::Builder,
68    ) -> crate::client::customize::internal::BoxFuture<
69        crate::client::customize::internal::SendResult<
70            crate::operation::create_rule::CreateRuleOutput,
71            crate::operation::create_rule::CreateRuleError,
72        >,
73    > {
74        ::std::boxed::Box::pin(async move { self.config_override(config_override).send().await })
75    }
76}
77impl CreateRuleFluentBuilder {
78    /// Creates a new `CreateRuleFluentBuilder`.
79    pub(crate) fn new(handle: ::std::sync::Arc<crate::client::Handle>) -> Self {
80        Self {
81            handle,
82            inner: ::std::default::Default::default(),
83            config_override: ::std::option::Option::None,
84        }
85    }
86    /// Access the CreateRule as a reference.
87    pub fn as_input(&self) -> &crate::operation::create_rule::builders::CreateRuleInputBuilder {
88        &self.inner
89    }
90    /// Sends the request and returns the response.
91    ///
92    /// If an error occurs, an `SdkError` will be returned with additional details that
93    /// can be matched against.
94    ///
95    /// By default, any retryable failures will be retried twice. Retry behavior
96    /// is configurable with the [RetryConfig](aws_smithy_types::retry::RetryConfig), which can be
97    /// set when configuring the client.
98    pub async fn send(
99        self,
100    ) -> ::std::result::Result<
101        crate::operation::create_rule::CreateRuleOutput,
102        ::aws_smithy_runtime_api::client::result::SdkError<
103            crate::operation::create_rule::CreateRuleError,
104            ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
105        >,
106    > {
107        let input = self
108            .inner
109            .build()
110            .map_err(::aws_smithy_runtime_api::client::result::SdkError::construction_failure)?;
111        let runtime_plugins = crate::operation::create_rule::CreateRule::operation_runtime_plugins(
112            self.handle.runtime_plugins.clone(),
113            &self.handle.conf,
114            self.config_override,
115        );
116        crate::operation::create_rule::CreateRule::orchestrate(&runtime_plugins, input).await
117    }
118
119    /// Consumes this builder, creating a customizable operation that can be modified before being sent.
120    pub fn customize(
121        self,
122    ) -> crate::client::customize::CustomizableOperation<
123        crate::operation::create_rule::CreateRuleOutput,
124        crate::operation::create_rule::CreateRuleError,
125        Self,
126    > {
127        crate::client::customize::CustomizableOperation::new(self)
128    }
129    pub(crate) fn config_override(mut self, config_override: impl ::std::convert::Into<crate::config::Builder>) -> Self {
130        self.set_config_override(::std::option::Option::Some(config_override.into()));
131        self
132    }
133
134    pub(crate) fn set_config_override(&mut self, config_override: ::std::option::Option<crate::config::Builder>) -> &mut Self {
135        self.config_override = config_override;
136        self
137    }
138    /// <p>A friendly name or description of the <code>Rule</code>. You can't change the name of a <code>Rule</code> after you create it.</p>
139    pub fn name(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
140        self.inner = self.inner.name(input.into());
141        self
142    }
143    /// <p>A friendly name or description of the <code>Rule</code>. You can't change the name of a <code>Rule</code> after you create it.</p>
144    pub fn set_name(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
145        self.inner = self.inner.set_name(input);
146        self
147    }
148    /// <p>A friendly name or description of the <code>Rule</code>. You can't change the name of a <code>Rule</code> after you create it.</p>
149    pub fn get_name(&self) -> &::std::option::Option<::std::string::String> {
150        self.inner.get_name()
151    }
152    /// <p>A friendly name or description for the metrics for this <code>Rule</code>. The name can contain only alphanumeric characters (A-Z, a-z, 0-9), with maximum length 128 and minimum length one. It can't contain whitespace or metric names reserved for AWS WAF, including "All" and "Default_Action." You can't change the name of the metric after you create the <code>Rule</code>.</p>
153    pub fn metric_name(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
154        self.inner = self.inner.metric_name(input.into());
155        self
156    }
157    /// <p>A friendly name or description for the metrics for this <code>Rule</code>. The name can contain only alphanumeric characters (A-Z, a-z, 0-9), with maximum length 128 and minimum length one. It can't contain whitespace or metric names reserved for AWS WAF, including "All" and "Default_Action." You can't change the name of the metric after you create the <code>Rule</code>.</p>
158    pub fn set_metric_name(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
159        self.inner = self.inner.set_metric_name(input);
160        self
161    }
162    /// <p>A friendly name or description for the metrics for this <code>Rule</code>. The name can contain only alphanumeric characters (A-Z, a-z, 0-9), with maximum length 128 and minimum length one. It can't contain whitespace or metric names reserved for AWS WAF, including "All" and "Default_Action." You can't change the name of the metric after you create the <code>Rule</code>.</p>
163    pub fn get_metric_name(&self) -> &::std::option::Option<::std::string::String> {
164        self.inner.get_metric_name()
165    }
166    /// <p>The value returned by the most recent call to <code>GetChangeToken</code>.</p>
167    pub fn change_token(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
168        self.inner = self.inner.change_token(input.into());
169        self
170    }
171    /// <p>The value returned by the most recent call to <code>GetChangeToken</code>.</p>
172    pub fn set_change_token(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
173        self.inner = self.inner.set_change_token(input);
174        self
175    }
176    /// <p>The value returned by the most recent call to <code>GetChangeToken</code>.</p>
177    pub fn get_change_token(&self) -> &::std::option::Option<::std::string::String> {
178        self.inner.get_change_token()
179    }
180    ///
181    /// Appends an item to `Tags`.
182    ///
183    /// To override the contents of this collection use [`set_tags`](Self::set_tags).
184    ///
185    /// <p></p>
186    pub fn tags(mut self, input: crate::types::Tag) -> Self {
187        self.inner = self.inner.tags(input);
188        self
189    }
190    /// <p></p>
191    pub fn set_tags(mut self, input: ::std::option::Option<::std::vec::Vec<crate::types::Tag>>) -> Self {
192        self.inner = self.inner.set_tags(input);
193        self
194    }
195    /// <p></p>
196    pub fn get_tags(&self) -> &::std::option::Option<::std::vec::Vec<crate::types::Tag>> {
197        self.inner.get_tags()
198    }
199}