Skip to main content

aws_sdk_applicationautoscaling/types/
_customized_metric_specification.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2
3/// <p>Represents a CloudWatch metric of your choosing for a target tracking scaling policy to use with Application Auto Scaling.</p>
4/// <p>For information about the available metrics for a service, see <a href="https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/aws-services-cloudwatch-metrics.html">Amazon Web Services services that publish CloudWatch metrics</a> in the <i>Amazon CloudWatch User Guide</i>.</p>
5/// <p>To create your customized metric specification:</p>
6/// <ul>
7/// <li>
8/// <p>Add values for each required parameter from CloudWatch. You can use an existing metric, or a new metric that you create. To use your own metric, you must first publish the metric to CloudWatch. For more information, see <a href="https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/publishingMetrics.html">Publish custom metrics</a> in the <i>Amazon CloudWatch User Guide</i>.</p></li>
9/// <li>
10/// <p>Choose a metric that changes proportionally with capacity. The value of the metric should increase or decrease in inverse proportion to the number of capacity units. That is, the value of the metric should decrease when capacity increases, and increase when capacity decreases.</p></li>
11/// </ul>
12/// <p>For more information about the CloudWatch terminology below, see <a href="https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/cloudwatch_concepts.html">Amazon CloudWatch concepts</a> in the <i>Amazon CloudWatch User Guide</i>.</p>
13#[non_exhaustive]
14#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::fmt::Debug)]
15pub struct CustomizedMetricSpecification {
16    /// <p>The name of the metric. To get the exact metric name, namespace, and dimensions, inspect the <a href="https://docs.aws.amazon.com/AmazonCloudWatch/latest/APIReference/API_Metric.html">Metric</a> object that's returned by a call to <a href="https://docs.aws.amazon.com/AmazonCloudWatch/latest/APIReference/API_ListMetrics.html">ListMetrics</a>.</p>
17    pub metric_name: ::std::option::Option<::std::string::String>,
18    /// <p>The namespace of the metric.</p>
19    pub namespace: ::std::option::Option<::std::string::String>,
20    /// <p>The dimensions of the metric.</p>
21    /// <p>Conditional: If you published your metric with dimensions, you must specify the same dimensions in your scaling policy.</p>
22    pub dimensions: ::std::option::Option<::std::vec::Vec<crate::types::MetricDimension>>,
23    /// <p>The statistic of the metric.</p>
24    pub statistic: ::std::option::Option<crate::types::MetricStatistic>,
25    /// <p>The unit of the metric. For a complete list of the units that CloudWatch supports, see the <a href="https://docs.aws.amazon.com/AmazonCloudWatch/latest/APIReference/API_MetricDatum.html">MetricDatum</a> data type in the <i>Amazon CloudWatch API Reference</i>.</p>
26    pub unit: ::std::option::Option<::std::string::String>,
27    /// <p>The metrics to include in the target tracking scaling policy, as a metric data query. This can include both raw metric and metric math expressions.</p>
28    pub metrics: ::std::option::Option<::std::vec::Vec<crate::types::TargetTrackingMetricDataQuery>>,
29}
30impl CustomizedMetricSpecification {
31    /// <p>The name of the metric. To get the exact metric name, namespace, and dimensions, inspect the <a href="https://docs.aws.amazon.com/AmazonCloudWatch/latest/APIReference/API_Metric.html">Metric</a> object that's returned by a call to <a href="https://docs.aws.amazon.com/AmazonCloudWatch/latest/APIReference/API_ListMetrics.html">ListMetrics</a>.</p>
32    pub fn metric_name(&self) -> ::std::option::Option<&str> {
33        self.metric_name.as_deref()
34    }
35    /// <p>The namespace of the metric.</p>
36    pub fn namespace(&self) -> ::std::option::Option<&str> {
37        self.namespace.as_deref()
38    }
39    /// <p>The dimensions of the metric.</p>
40    /// <p>Conditional: If you published your metric with dimensions, you must specify the same dimensions in your scaling policy.</p>
41    ///
42    /// If no value was sent for this field, a default will be set. If you want to determine if no value was sent, use `.dimensions.is_none()`.
43    pub fn dimensions(&self) -> &[crate::types::MetricDimension] {
44        self.dimensions.as_deref().unwrap_or_default()
45    }
46    /// <p>The statistic of the metric.</p>
47    pub fn statistic(&self) -> ::std::option::Option<&crate::types::MetricStatistic> {
48        self.statistic.as_ref()
49    }
50    /// <p>The unit of the metric. For a complete list of the units that CloudWatch supports, see the <a href="https://docs.aws.amazon.com/AmazonCloudWatch/latest/APIReference/API_MetricDatum.html">MetricDatum</a> data type in the <i>Amazon CloudWatch API Reference</i>.</p>
51    pub fn unit(&self) -> ::std::option::Option<&str> {
52        self.unit.as_deref()
53    }
54    /// <p>The metrics to include in the target tracking scaling policy, as a metric data query. This can include both raw metric and metric math expressions.</p>
55    ///
56    /// If no value was sent for this field, a default will be set. If you want to determine if no value was sent, use `.metrics.is_none()`.
57    pub fn metrics(&self) -> &[crate::types::TargetTrackingMetricDataQuery] {
58        self.metrics.as_deref().unwrap_or_default()
59    }
60}
61impl CustomizedMetricSpecification {
62    /// Creates a new builder-style object to manufacture [`CustomizedMetricSpecification`](crate::types::CustomizedMetricSpecification).
63    pub fn builder() -> crate::types::builders::CustomizedMetricSpecificationBuilder {
64        crate::types::builders::CustomizedMetricSpecificationBuilder::default()
65    }
66}
67
68/// A builder for [`CustomizedMetricSpecification`](crate::types::CustomizedMetricSpecification).
69#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::default::Default, ::std::fmt::Debug)]
70#[non_exhaustive]
71pub struct CustomizedMetricSpecificationBuilder {
72    pub(crate) metric_name: ::std::option::Option<::std::string::String>,
73    pub(crate) namespace: ::std::option::Option<::std::string::String>,
74    pub(crate) dimensions: ::std::option::Option<::std::vec::Vec<crate::types::MetricDimension>>,
75    pub(crate) statistic: ::std::option::Option<crate::types::MetricStatistic>,
76    pub(crate) unit: ::std::option::Option<::std::string::String>,
77    pub(crate) metrics: ::std::option::Option<::std::vec::Vec<crate::types::TargetTrackingMetricDataQuery>>,
78}
79impl CustomizedMetricSpecificationBuilder {
80    /// <p>The name of the metric. To get the exact metric name, namespace, and dimensions, inspect the <a href="https://docs.aws.amazon.com/AmazonCloudWatch/latest/APIReference/API_Metric.html">Metric</a> object that's returned by a call to <a href="https://docs.aws.amazon.com/AmazonCloudWatch/latest/APIReference/API_ListMetrics.html">ListMetrics</a>.</p>
81    pub fn metric_name(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
82        self.metric_name = ::std::option::Option::Some(input.into());
83        self
84    }
85    /// <p>The name of the metric. To get the exact metric name, namespace, and dimensions, inspect the <a href="https://docs.aws.amazon.com/AmazonCloudWatch/latest/APIReference/API_Metric.html">Metric</a> object that's returned by a call to <a href="https://docs.aws.amazon.com/AmazonCloudWatch/latest/APIReference/API_ListMetrics.html">ListMetrics</a>.</p>
86    pub fn set_metric_name(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
87        self.metric_name = input;
88        self
89    }
90    /// <p>The name of the metric. To get the exact metric name, namespace, and dimensions, inspect the <a href="https://docs.aws.amazon.com/AmazonCloudWatch/latest/APIReference/API_Metric.html">Metric</a> object that's returned by a call to <a href="https://docs.aws.amazon.com/AmazonCloudWatch/latest/APIReference/API_ListMetrics.html">ListMetrics</a>.</p>
91    pub fn get_metric_name(&self) -> &::std::option::Option<::std::string::String> {
92        &self.metric_name
93    }
94    /// <p>The namespace of the metric.</p>
95    pub fn namespace(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
96        self.namespace = ::std::option::Option::Some(input.into());
97        self
98    }
99    /// <p>The namespace of the metric.</p>
100    pub fn set_namespace(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
101        self.namespace = input;
102        self
103    }
104    /// <p>The namespace of the metric.</p>
105    pub fn get_namespace(&self) -> &::std::option::Option<::std::string::String> {
106        &self.namespace
107    }
108    /// Appends an item to `dimensions`.
109    ///
110    /// To override the contents of this collection use [`set_dimensions`](Self::set_dimensions).
111    ///
112    /// <p>The dimensions of the metric.</p>
113    /// <p>Conditional: If you published your metric with dimensions, you must specify the same dimensions in your scaling policy.</p>
114    pub fn dimensions(mut self, input: crate::types::MetricDimension) -> Self {
115        let mut v = self.dimensions.unwrap_or_default();
116        v.push(input);
117        self.dimensions = ::std::option::Option::Some(v);
118        self
119    }
120    /// <p>The dimensions of the metric.</p>
121    /// <p>Conditional: If you published your metric with dimensions, you must specify the same dimensions in your scaling policy.</p>
122    pub fn set_dimensions(mut self, input: ::std::option::Option<::std::vec::Vec<crate::types::MetricDimension>>) -> Self {
123        self.dimensions = input;
124        self
125    }
126    /// <p>The dimensions of the metric.</p>
127    /// <p>Conditional: If you published your metric with dimensions, you must specify the same dimensions in your scaling policy.</p>
128    pub fn get_dimensions(&self) -> &::std::option::Option<::std::vec::Vec<crate::types::MetricDimension>> {
129        &self.dimensions
130    }
131    /// <p>The statistic of the metric.</p>
132    pub fn statistic(mut self, input: crate::types::MetricStatistic) -> Self {
133        self.statistic = ::std::option::Option::Some(input);
134        self
135    }
136    /// <p>The statistic of the metric.</p>
137    pub fn set_statistic(mut self, input: ::std::option::Option<crate::types::MetricStatistic>) -> Self {
138        self.statistic = input;
139        self
140    }
141    /// <p>The statistic of the metric.</p>
142    pub fn get_statistic(&self) -> &::std::option::Option<crate::types::MetricStatistic> {
143        &self.statistic
144    }
145    /// <p>The unit of the metric. For a complete list of the units that CloudWatch supports, see the <a href="https://docs.aws.amazon.com/AmazonCloudWatch/latest/APIReference/API_MetricDatum.html">MetricDatum</a> data type in the <i>Amazon CloudWatch API Reference</i>.</p>
146    pub fn unit(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
147        self.unit = ::std::option::Option::Some(input.into());
148        self
149    }
150    /// <p>The unit of the metric. For a complete list of the units that CloudWatch supports, see the <a href="https://docs.aws.amazon.com/AmazonCloudWatch/latest/APIReference/API_MetricDatum.html">MetricDatum</a> data type in the <i>Amazon CloudWatch API Reference</i>.</p>
151    pub fn set_unit(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
152        self.unit = input;
153        self
154    }
155    /// <p>The unit of the metric. For a complete list of the units that CloudWatch supports, see the <a href="https://docs.aws.amazon.com/AmazonCloudWatch/latest/APIReference/API_MetricDatum.html">MetricDatum</a> data type in the <i>Amazon CloudWatch API Reference</i>.</p>
156    pub fn get_unit(&self) -> &::std::option::Option<::std::string::String> {
157        &self.unit
158    }
159    /// Appends an item to `metrics`.
160    ///
161    /// To override the contents of this collection use [`set_metrics`](Self::set_metrics).
162    ///
163    /// <p>The metrics to include in the target tracking scaling policy, as a metric data query. This can include both raw metric and metric math expressions.</p>
164    pub fn metrics(mut self, input: crate::types::TargetTrackingMetricDataQuery) -> Self {
165        let mut v = self.metrics.unwrap_or_default();
166        v.push(input);
167        self.metrics = ::std::option::Option::Some(v);
168        self
169    }
170    /// <p>The metrics to include in the target tracking scaling policy, as a metric data query. This can include both raw metric and metric math expressions.</p>
171    pub fn set_metrics(mut self, input: ::std::option::Option<::std::vec::Vec<crate::types::TargetTrackingMetricDataQuery>>) -> Self {
172        self.metrics = input;
173        self
174    }
175    /// <p>The metrics to include in the target tracking scaling policy, as a metric data query. This can include both raw metric and metric math expressions.</p>
176    pub fn get_metrics(&self) -> &::std::option::Option<::std::vec::Vec<crate::types::TargetTrackingMetricDataQuery>> {
177        &self.metrics
178    }
179    /// Consumes the builder and constructs a [`CustomizedMetricSpecification`](crate::types::CustomizedMetricSpecification).
180    pub fn build(self) -> crate::types::CustomizedMetricSpecification {
181        crate::types::CustomizedMetricSpecification {
182            metric_name: self.metric_name,
183            namespace: self.namespace,
184            dimensions: self.dimensions,
185            statistic: self.statistic,
186            unit: self.unit,
187            metrics: self.metrics,
188        }
189    }
190}