aws_sdk_wafv2/types/
_rate_limit_label_namespace.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2
3/// <p>Specifies a label namespace to use as an aggregate key for a rate-based rule. Each distinct fully qualified label name that has the specified label namespace contributes to the aggregation instance. If you use just one label namespace as your custom key, then each label name fully defines an aggregation instance.</p>
4/// <p>This uses only labels that have been added to the request by rules that are evaluated before this rate-based rule in the web ACL.</p>
5/// <p>For information about label namespaces and names, see <a href="https://docs.aws.amazon.com/waf/latest/developerguide/waf-rule-label-requirements.html">Label syntax and naming requirements</a> in the <i>WAF Developer Guide</i>.</p>
6#[non_exhaustive]
7#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::fmt::Debug)]
8pub struct RateLimitLabelNamespace {
9    /// <p>The namespace to use for aggregation.</p>
10    pub namespace: ::std::string::String,
11}
12impl RateLimitLabelNamespace {
13    /// <p>The namespace to use for aggregation.</p>
14    pub fn namespace(&self) -> &str {
15        use std::ops::Deref;
16        self.namespace.deref()
17    }
18}
19impl RateLimitLabelNamespace {
20    /// Creates a new builder-style object to manufacture [`RateLimitLabelNamespace`](crate::types::RateLimitLabelNamespace).
21    pub fn builder() -> crate::types::builders::RateLimitLabelNamespaceBuilder {
22        crate::types::builders::RateLimitLabelNamespaceBuilder::default()
23    }
24}
25
26/// A builder for [`RateLimitLabelNamespace`](crate::types::RateLimitLabelNamespace).
27#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::default::Default, ::std::fmt::Debug)]
28#[non_exhaustive]
29pub struct RateLimitLabelNamespaceBuilder {
30    pub(crate) namespace: ::std::option::Option<::std::string::String>,
31}
32impl RateLimitLabelNamespaceBuilder {
33    /// <p>The namespace to use for aggregation.</p>
34    /// This field is required.
35    pub fn namespace(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
36        self.namespace = ::std::option::Option::Some(input.into());
37        self
38    }
39    /// <p>The namespace to use for aggregation.</p>
40    pub fn set_namespace(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
41        self.namespace = input;
42        self
43    }
44    /// <p>The namespace to use for aggregation.</p>
45    pub fn get_namespace(&self) -> &::std::option::Option<::std::string::String> {
46        &self.namespace
47    }
48    /// Consumes the builder and constructs a [`RateLimitLabelNamespace`](crate::types::RateLimitLabelNamespace).
49    /// This method will fail if any of the following fields are not set:
50    /// - [`namespace`](crate::types::builders::RateLimitLabelNamespaceBuilder::namespace)
51    pub fn build(self) -> ::std::result::Result<crate::types::RateLimitLabelNamespace, ::aws_smithy_types::error::operation::BuildError> {
52        ::std::result::Result::Ok(crate::types::RateLimitLabelNamespace {
53            namespace: self.namespace.ok_or_else(|| {
54                ::aws_smithy_types::error::operation::BuildError::missing_field(
55                    "namespace",
56                    "namespace was not specified but it is required when building RateLimitLabelNamespace",
57                )
58            })?,
59        })
60    }
61}