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
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.

/// <p>Defines and enables Amazon CloudWatch metrics and web request sample collection.</p>
#[non_exhaustive]
#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::fmt::Debug)]
pub struct VisibilityConfig {
    /// <p>Indicates whether WAF should store a sampling of the web requests that match the rules. You can view the sampled requests through the WAF console.</p>
    pub sampled_requests_enabled: bool,
    /// <p>Indicates whether the associated resource sends metrics to Amazon CloudWatch. For the list of available metrics, see <a href="https://docs.aws.amazon.com/waf/latest/developerguide/monitoring-cloudwatch.html#waf-metrics">WAF Metrics</a> in the <i>WAF Developer Guide</i>.</p>
    /// <p>For web ACLs, the metrics are for web requests that have the web ACL default action applied. WAF applies the default action to web requests that pass the inspection of all rules in the web ACL without being either allowed or blocked. For more information, see <a href="https://docs.aws.amazon.com/waf/latest/developerguide/web-acl-default-action.html">The web ACL default action</a> in the <i>WAF Developer Guide</i>.</p>
    pub cloud_watch_metrics_enabled: bool,
    /// <p>A name of the Amazon CloudWatch metric dimension. The name can contain only the characters: A-Z, a-z, 0-9, - (hyphen), and _ (underscore). The name can be from one to 128 characters long. It can't contain whitespace or metric names that are reserved for WAF, for example <code>All</code> and <code>Default_Action</code>.</p>
    pub metric_name: ::std::string::String,
}
impl VisibilityConfig {
    /// <p>Indicates whether WAF should store a sampling of the web requests that match the rules. You can view the sampled requests through the WAF console.</p>
    pub fn sampled_requests_enabled(&self) -> bool {
        self.sampled_requests_enabled
    }
    /// <p>Indicates whether the associated resource sends metrics to Amazon CloudWatch. For the list of available metrics, see <a href="https://docs.aws.amazon.com/waf/latest/developerguide/monitoring-cloudwatch.html#waf-metrics">WAF Metrics</a> in the <i>WAF Developer Guide</i>.</p>
    /// <p>For web ACLs, the metrics are for web requests that have the web ACL default action applied. WAF applies the default action to web requests that pass the inspection of all rules in the web ACL without being either allowed or blocked. For more information, see <a href="https://docs.aws.amazon.com/waf/latest/developerguide/web-acl-default-action.html">The web ACL default action</a> in the <i>WAF Developer Guide</i>.</p>
    pub fn cloud_watch_metrics_enabled(&self) -> bool {
        self.cloud_watch_metrics_enabled
    }
    /// <p>A name of the Amazon CloudWatch metric dimension. The name can contain only the characters: A-Z, a-z, 0-9, - (hyphen), and _ (underscore). The name can be from one to 128 characters long. It can't contain whitespace or metric names that are reserved for WAF, for example <code>All</code> and <code>Default_Action</code>.</p>
    pub fn metric_name(&self) -> &str {
        use std::ops::Deref;
        self.metric_name.deref()
    }
}
impl VisibilityConfig {
    /// Creates a new builder-style object to manufacture [`VisibilityConfig`](crate::types::VisibilityConfig).
    pub fn builder() -> crate::types::builders::VisibilityConfigBuilder {
        crate::types::builders::VisibilityConfigBuilder::default()
    }
}

/// A builder for [`VisibilityConfig`](crate::types::VisibilityConfig).
#[non_exhaustive]
#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::default::Default, ::std::fmt::Debug)]
pub struct VisibilityConfigBuilder {
    pub(crate) sampled_requests_enabled: ::std::option::Option<bool>,
    pub(crate) cloud_watch_metrics_enabled: ::std::option::Option<bool>,
    pub(crate) metric_name: ::std::option::Option<::std::string::String>,
}
impl VisibilityConfigBuilder {
    /// <p>Indicates whether WAF should store a sampling of the web requests that match the rules. You can view the sampled requests through the WAF console.</p>
    /// This field is required.
    pub fn sampled_requests_enabled(mut self, input: bool) -> Self {
        self.sampled_requests_enabled = ::std::option::Option::Some(input);
        self
    }
    /// <p>Indicates whether WAF should store a sampling of the web requests that match the rules. You can view the sampled requests through the WAF console.</p>
    pub fn set_sampled_requests_enabled(mut self, input: ::std::option::Option<bool>) -> Self {
        self.sampled_requests_enabled = input;
        self
    }
    /// <p>Indicates whether WAF should store a sampling of the web requests that match the rules. You can view the sampled requests through the WAF console.</p>
    pub fn get_sampled_requests_enabled(&self) -> &::std::option::Option<bool> {
        &self.sampled_requests_enabled
    }
    /// <p>Indicates whether the associated resource sends metrics to Amazon CloudWatch. For the list of available metrics, see <a href="https://docs.aws.amazon.com/waf/latest/developerguide/monitoring-cloudwatch.html#waf-metrics">WAF Metrics</a> in the <i>WAF Developer Guide</i>.</p>
    /// <p>For web ACLs, the metrics are for web requests that have the web ACL default action applied. WAF applies the default action to web requests that pass the inspection of all rules in the web ACL without being either allowed or blocked. For more information, see <a href="https://docs.aws.amazon.com/waf/latest/developerguide/web-acl-default-action.html">The web ACL default action</a> in the <i>WAF Developer Guide</i>.</p>
    /// This field is required.
    pub fn cloud_watch_metrics_enabled(mut self, input: bool) -> Self {
        self.cloud_watch_metrics_enabled = ::std::option::Option::Some(input);
        self
    }
    /// <p>Indicates whether the associated resource sends metrics to Amazon CloudWatch. For the list of available metrics, see <a href="https://docs.aws.amazon.com/waf/latest/developerguide/monitoring-cloudwatch.html#waf-metrics">WAF Metrics</a> in the <i>WAF Developer Guide</i>.</p>
    /// <p>For web ACLs, the metrics are for web requests that have the web ACL default action applied. WAF applies the default action to web requests that pass the inspection of all rules in the web ACL without being either allowed or blocked. For more information, see <a href="https://docs.aws.amazon.com/waf/latest/developerguide/web-acl-default-action.html">The web ACL default action</a> in the <i>WAF Developer Guide</i>.</p>
    pub fn set_cloud_watch_metrics_enabled(mut self, input: ::std::option::Option<bool>) -> Self {
        self.cloud_watch_metrics_enabled = input;
        self
    }
    /// <p>Indicates whether the associated resource sends metrics to Amazon CloudWatch. For the list of available metrics, see <a href="https://docs.aws.amazon.com/waf/latest/developerguide/monitoring-cloudwatch.html#waf-metrics">WAF Metrics</a> in the <i>WAF Developer Guide</i>.</p>
    /// <p>For web ACLs, the metrics are for web requests that have the web ACL default action applied. WAF applies the default action to web requests that pass the inspection of all rules in the web ACL without being either allowed or blocked. For more information, see <a href="https://docs.aws.amazon.com/waf/latest/developerguide/web-acl-default-action.html">The web ACL default action</a> in the <i>WAF Developer Guide</i>.</p>
    pub fn get_cloud_watch_metrics_enabled(&self) -> &::std::option::Option<bool> {
        &self.cloud_watch_metrics_enabled
    }
    /// <p>A name of the Amazon CloudWatch metric dimension. The name can contain only the characters: A-Z, a-z, 0-9, - (hyphen), and _ (underscore). The name can be from one to 128 characters long. It can't contain whitespace or metric names that are reserved for WAF, for example <code>All</code> and <code>Default_Action</code>.</p>
    /// This field is required.
    pub fn metric_name(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
        self.metric_name = ::std::option::Option::Some(input.into());
        self
    }
    /// <p>A name of the Amazon CloudWatch metric dimension. The name can contain only the characters: A-Z, a-z, 0-9, - (hyphen), and _ (underscore). The name can be from one to 128 characters long. It can't contain whitespace or metric names that are reserved for WAF, for example <code>All</code> and <code>Default_Action</code>.</p>
    pub fn set_metric_name(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
        self.metric_name = input;
        self
    }
    /// <p>A name of the Amazon CloudWatch metric dimension. The name can contain only the characters: A-Z, a-z, 0-9, - (hyphen), and _ (underscore). The name can be from one to 128 characters long. It can't contain whitespace or metric names that are reserved for WAF, for example <code>All</code> and <code>Default_Action</code>.</p>
    pub fn get_metric_name(&self) -> &::std::option::Option<::std::string::String> {
        &self.metric_name
    }
    /// Consumes the builder and constructs a [`VisibilityConfig`](crate::types::VisibilityConfig).
    /// This method will fail if any of the following fields are not set:
    /// - [`metric_name`](crate::types::builders::VisibilityConfigBuilder::metric_name)
    pub fn build(self) -> ::std::result::Result<crate::types::VisibilityConfig, ::aws_smithy_types::error::operation::BuildError> {
        ::std::result::Result::Ok(crate::types::VisibilityConfig {
            sampled_requests_enabled: self.sampled_requests_enabled.unwrap_or_default(),
            cloud_watch_metrics_enabled: self.cloud_watch_metrics_enabled.unwrap_or_default(),
            metric_name: self.metric_name.ok_or_else(|| {
                ::aws_smithy_types::error::operation::BuildError::missing_field(
                    "metric_name",
                    "metric_name was not specified but it is required when building VisibilityConfig",
                )
            })?,
        })
    }
}