aws_sdk_cloudwatch/operation/put_anomaly_detector/
builders.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2pub use crate::operation::put_anomaly_detector::_put_anomaly_detector_output::PutAnomalyDetectorOutputBuilder;
3
4pub use crate::operation::put_anomaly_detector::_put_anomaly_detector_input::PutAnomalyDetectorInputBuilder;
5
6impl crate::operation::put_anomaly_detector::builders::PutAnomalyDetectorInputBuilder {
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::put_anomaly_detector::PutAnomalyDetectorOutput,
13        ::aws_smithy_runtime_api::client::result::SdkError<
14            crate::operation::put_anomaly_detector::PutAnomalyDetectorError,
15            ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
16        >,
17    > {
18        let mut fluent_builder = client.put_anomaly_detector();
19        fluent_builder.inner = self;
20        fluent_builder.send().await
21    }
22}
23/// Fluent builder constructing a request to `PutAnomalyDetector`.
24///
25/// <p>Creates an anomaly detection model for a CloudWatch metric. You can use the model to display a band of expected normal values when the metric is graphed.</p>
26/// <p>If you have enabled unified cross-account observability, and this account is a monitoring account, the metric can be in the same account or a source account. You can specify the account ID in the object you specify in the <code>SingleMetricAnomalyDetector</code> parameter.</p>
27/// <p>For more information, see <a href="https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch_Anomaly_Detection.html">CloudWatch Anomaly Detection</a>.</p>
28#[derive(::std::clone::Clone, ::std::fmt::Debug)]
29pub struct PutAnomalyDetectorFluentBuilder {
30    handle: ::std::sync::Arc<crate::client::Handle>,
31    inner: crate::operation::put_anomaly_detector::builders::PutAnomalyDetectorInputBuilder,
32    config_override: ::std::option::Option<crate::config::Builder>,
33}
34impl
35    crate::client::customize::internal::CustomizableSend<
36        crate::operation::put_anomaly_detector::PutAnomalyDetectorOutput,
37        crate::operation::put_anomaly_detector::PutAnomalyDetectorError,
38    > for PutAnomalyDetectorFluentBuilder
39{
40    fn send(
41        self,
42        config_override: crate::config::Builder,
43    ) -> crate::client::customize::internal::BoxFuture<
44        crate::client::customize::internal::SendResult<
45            crate::operation::put_anomaly_detector::PutAnomalyDetectorOutput,
46            crate::operation::put_anomaly_detector::PutAnomalyDetectorError,
47        >,
48    > {
49        ::std::boxed::Box::pin(async move { self.config_override(config_override).send().await })
50    }
51}
52impl PutAnomalyDetectorFluentBuilder {
53    /// Creates a new `PutAnomalyDetectorFluentBuilder`.
54    pub(crate) fn new(handle: ::std::sync::Arc<crate::client::Handle>) -> Self {
55        Self {
56            handle,
57            inner: ::std::default::Default::default(),
58            config_override: ::std::option::Option::None,
59        }
60    }
61    /// Access the PutAnomalyDetector as a reference.
62    pub fn as_input(&self) -> &crate::operation::put_anomaly_detector::builders::PutAnomalyDetectorInputBuilder {
63        &self.inner
64    }
65    /// Sends the request and returns the response.
66    ///
67    /// If an error occurs, an `SdkError` will be returned with additional details that
68    /// can be matched against.
69    ///
70    /// By default, any retryable failures will be retried twice. Retry behavior
71    /// is configurable with the [RetryConfig](aws_smithy_types::retry::RetryConfig), which can be
72    /// set when configuring the client.
73    pub async fn send(
74        self,
75    ) -> ::std::result::Result<
76        crate::operation::put_anomaly_detector::PutAnomalyDetectorOutput,
77        ::aws_smithy_runtime_api::client::result::SdkError<
78            crate::operation::put_anomaly_detector::PutAnomalyDetectorError,
79            ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
80        >,
81    > {
82        let input = self
83            .inner
84            .build()
85            .map_err(::aws_smithy_runtime_api::client::result::SdkError::construction_failure)?;
86        let runtime_plugins = crate::operation::put_anomaly_detector::PutAnomalyDetector::operation_runtime_plugins(
87            self.handle.runtime_plugins.clone(),
88            &self.handle.conf,
89            self.config_override,
90        );
91        crate::operation::put_anomaly_detector::PutAnomalyDetector::orchestrate(&runtime_plugins, input).await
92    }
93
94    /// Consumes this builder, creating a customizable operation that can be modified before being sent.
95    pub fn customize(
96        self,
97    ) -> crate::client::customize::CustomizableOperation<
98        crate::operation::put_anomaly_detector::PutAnomalyDetectorOutput,
99        crate::operation::put_anomaly_detector::PutAnomalyDetectorError,
100        Self,
101    > {
102        crate::client::customize::CustomizableOperation::new(self)
103    }
104    pub(crate) fn config_override(mut self, config_override: impl ::std::convert::Into<crate::config::Builder>) -> Self {
105        self.set_config_override(::std::option::Option::Some(config_override.into()));
106        self
107    }
108
109    pub(crate) fn set_config_override(&mut self, config_override: ::std::option::Option<crate::config::Builder>) -> &mut Self {
110        self.config_override = config_override;
111        self
112    }
113    /// <p>The namespace of the metric to create the anomaly detection model for.</p>
114    #[deprecated(note = "Use SingleMetricAnomalyDetector.")]
115    pub fn namespace(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
116        self.inner = self.inner.namespace(input.into());
117        self
118    }
119    /// <p>The namespace of the metric to create the anomaly detection model for.</p>
120    #[deprecated(note = "Use SingleMetricAnomalyDetector.")]
121    pub fn set_namespace(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
122        self.inner = self.inner.set_namespace(input);
123        self
124    }
125    /// <p>The namespace of the metric to create the anomaly detection model for.</p>
126    #[deprecated(note = "Use SingleMetricAnomalyDetector.")]
127    pub fn get_namespace(&self) -> &::std::option::Option<::std::string::String> {
128        self.inner.get_namespace()
129    }
130    /// <p>The name of the metric to create the anomaly detection model for.</p>
131    #[deprecated(note = "Use SingleMetricAnomalyDetector.")]
132    pub fn metric_name(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
133        self.inner = self.inner.metric_name(input.into());
134        self
135    }
136    /// <p>The name of the metric to create the anomaly detection model for.</p>
137    #[deprecated(note = "Use SingleMetricAnomalyDetector.")]
138    pub fn set_metric_name(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
139        self.inner = self.inner.set_metric_name(input);
140        self
141    }
142    /// <p>The name of the metric to create the anomaly detection model for.</p>
143    #[deprecated(note = "Use SingleMetricAnomalyDetector.")]
144    pub fn get_metric_name(&self) -> &::std::option::Option<::std::string::String> {
145        self.inner.get_metric_name()
146    }
147    ///
148    /// Appends an item to `Dimensions`.
149    ///
150    /// To override the contents of this collection use [`set_dimensions`](Self::set_dimensions).
151    ///
152    /// <p>The metric dimensions to create the anomaly detection model for.</p>
153    #[deprecated(note = "Use SingleMetricAnomalyDetector.")]
154    pub fn dimensions(mut self, input: crate::types::Dimension) -> Self {
155        self.inner = self.inner.dimensions(input);
156        self
157    }
158    /// <p>The metric dimensions to create the anomaly detection model for.</p>
159    #[deprecated(note = "Use SingleMetricAnomalyDetector.")]
160    pub fn set_dimensions(mut self, input: ::std::option::Option<::std::vec::Vec<crate::types::Dimension>>) -> Self {
161        self.inner = self.inner.set_dimensions(input);
162        self
163    }
164    /// <p>The metric dimensions to create the anomaly detection model for.</p>
165    #[deprecated(note = "Use SingleMetricAnomalyDetector.")]
166    pub fn get_dimensions(&self) -> &::std::option::Option<::std::vec::Vec<crate::types::Dimension>> {
167        self.inner.get_dimensions()
168    }
169    /// <p>The statistic to use for the metric and the anomaly detection model.</p>
170    #[deprecated(note = "Use SingleMetricAnomalyDetector.")]
171    pub fn stat(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
172        self.inner = self.inner.stat(input.into());
173        self
174    }
175    /// <p>The statistic to use for the metric and the anomaly detection model.</p>
176    #[deprecated(note = "Use SingleMetricAnomalyDetector.")]
177    pub fn set_stat(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
178        self.inner = self.inner.set_stat(input);
179        self
180    }
181    /// <p>The statistic to use for the metric and the anomaly detection model.</p>
182    #[deprecated(note = "Use SingleMetricAnomalyDetector.")]
183    pub fn get_stat(&self) -> &::std::option::Option<::std::string::String> {
184        self.inner.get_stat()
185    }
186    /// <p>The configuration specifies details about how the anomaly detection model is to be trained, including time ranges to exclude when training and updating the model. You can specify as many as 10 time ranges.</p>
187    /// <p>The configuration can also include the time zone to use for the metric.</p>
188    pub fn configuration(mut self, input: crate::types::AnomalyDetectorConfiguration) -> Self {
189        self.inner = self.inner.configuration(input);
190        self
191    }
192    /// <p>The configuration specifies details about how the anomaly detection model is to be trained, including time ranges to exclude when training and updating the model. You can specify as many as 10 time ranges.</p>
193    /// <p>The configuration can also include the time zone to use for the metric.</p>
194    pub fn set_configuration(mut self, input: ::std::option::Option<crate::types::AnomalyDetectorConfiguration>) -> Self {
195        self.inner = self.inner.set_configuration(input);
196        self
197    }
198    /// <p>The configuration specifies details about how the anomaly detection model is to be trained, including time ranges to exclude when training and updating the model. You can specify as many as 10 time ranges.</p>
199    /// <p>The configuration can also include the time zone to use for the metric.</p>
200    pub fn get_configuration(&self) -> &::std::option::Option<crate::types::AnomalyDetectorConfiguration> {
201        self.inner.get_configuration()
202    }
203    /// <p>Use this object to include parameters to provide information about your metric to CloudWatch to help it build more accurate anomaly detection models. Currently, it includes the <code>PeriodicSpikes</code> parameter.</p>
204    pub fn metric_characteristics(mut self, input: crate::types::MetricCharacteristics) -> Self {
205        self.inner = self.inner.metric_characteristics(input);
206        self
207    }
208    /// <p>Use this object to include parameters to provide information about your metric to CloudWatch to help it build more accurate anomaly detection models. Currently, it includes the <code>PeriodicSpikes</code> parameter.</p>
209    pub fn set_metric_characteristics(mut self, input: ::std::option::Option<crate::types::MetricCharacteristics>) -> Self {
210        self.inner = self.inner.set_metric_characteristics(input);
211        self
212    }
213    /// <p>Use this object to include parameters to provide information about your metric to CloudWatch to help it build more accurate anomaly detection models. Currently, it includes the <code>PeriodicSpikes</code> parameter.</p>
214    pub fn get_metric_characteristics(&self) -> &::std::option::Option<crate::types::MetricCharacteristics> {
215        self.inner.get_metric_characteristics()
216    }
217    /// <p>A single metric anomaly detector to be created.</p>
218    /// <p>When using <code>SingleMetricAnomalyDetector</code>, you cannot include the following parameters in the same operation:</p>
219    /// <ul>
220    /// <li>
221    /// <p><code>Dimensions</code></p></li>
222    /// <li>
223    /// <p><code>MetricName</code></p></li>
224    /// <li>
225    /// <p><code>Namespace</code></p></li>
226    /// <li>
227    /// <p><code>Stat</code></p></li>
228    /// <li>
229    /// <p>the <code>MetricMathAnomalyDetector</code> parameters of <code>PutAnomalyDetectorInput</code></p></li>
230    /// </ul>
231    /// <p>Instead, specify the single metric anomaly detector attributes as part of the property <code>SingleMetricAnomalyDetector</code>.</p>
232    pub fn single_metric_anomaly_detector(mut self, input: crate::types::SingleMetricAnomalyDetector) -> Self {
233        self.inner = self.inner.single_metric_anomaly_detector(input);
234        self
235    }
236    /// <p>A single metric anomaly detector to be created.</p>
237    /// <p>When using <code>SingleMetricAnomalyDetector</code>, you cannot include the following parameters in the same operation:</p>
238    /// <ul>
239    /// <li>
240    /// <p><code>Dimensions</code></p></li>
241    /// <li>
242    /// <p><code>MetricName</code></p></li>
243    /// <li>
244    /// <p><code>Namespace</code></p></li>
245    /// <li>
246    /// <p><code>Stat</code></p></li>
247    /// <li>
248    /// <p>the <code>MetricMathAnomalyDetector</code> parameters of <code>PutAnomalyDetectorInput</code></p></li>
249    /// </ul>
250    /// <p>Instead, specify the single metric anomaly detector attributes as part of the property <code>SingleMetricAnomalyDetector</code>.</p>
251    pub fn set_single_metric_anomaly_detector(mut self, input: ::std::option::Option<crate::types::SingleMetricAnomalyDetector>) -> Self {
252        self.inner = self.inner.set_single_metric_anomaly_detector(input);
253        self
254    }
255    /// <p>A single metric anomaly detector to be created.</p>
256    /// <p>When using <code>SingleMetricAnomalyDetector</code>, you cannot include the following parameters in the same operation:</p>
257    /// <ul>
258    /// <li>
259    /// <p><code>Dimensions</code></p></li>
260    /// <li>
261    /// <p><code>MetricName</code></p></li>
262    /// <li>
263    /// <p><code>Namespace</code></p></li>
264    /// <li>
265    /// <p><code>Stat</code></p></li>
266    /// <li>
267    /// <p>the <code>MetricMathAnomalyDetector</code> parameters of <code>PutAnomalyDetectorInput</code></p></li>
268    /// </ul>
269    /// <p>Instead, specify the single metric anomaly detector attributes as part of the property <code>SingleMetricAnomalyDetector</code>.</p>
270    pub fn get_single_metric_anomaly_detector(&self) -> &::std::option::Option<crate::types::SingleMetricAnomalyDetector> {
271        self.inner.get_single_metric_anomaly_detector()
272    }
273    /// <p>The metric math anomaly detector to be created.</p>
274    /// <p>When using <code>MetricMathAnomalyDetector</code>, you cannot include the following parameters in the same operation:</p>
275    /// <ul>
276    /// <li>
277    /// <p><code>Dimensions</code></p></li>
278    /// <li>
279    /// <p><code>MetricName</code></p></li>
280    /// <li>
281    /// <p><code>Namespace</code></p></li>
282    /// <li>
283    /// <p><code>Stat</code></p></li>
284    /// <li>
285    /// <p>the <code>SingleMetricAnomalyDetector</code> parameters of <code>PutAnomalyDetectorInput</code></p></li>
286    /// </ul>
287    /// <p>Instead, specify the metric math anomaly detector attributes as part of the property <code>MetricMathAnomalyDetector</code>.</p>
288    pub fn metric_math_anomaly_detector(mut self, input: crate::types::MetricMathAnomalyDetector) -> Self {
289        self.inner = self.inner.metric_math_anomaly_detector(input);
290        self
291    }
292    /// <p>The metric math anomaly detector to be created.</p>
293    /// <p>When using <code>MetricMathAnomalyDetector</code>, you cannot include the following parameters in the same operation:</p>
294    /// <ul>
295    /// <li>
296    /// <p><code>Dimensions</code></p></li>
297    /// <li>
298    /// <p><code>MetricName</code></p></li>
299    /// <li>
300    /// <p><code>Namespace</code></p></li>
301    /// <li>
302    /// <p><code>Stat</code></p></li>
303    /// <li>
304    /// <p>the <code>SingleMetricAnomalyDetector</code> parameters of <code>PutAnomalyDetectorInput</code></p></li>
305    /// </ul>
306    /// <p>Instead, specify the metric math anomaly detector attributes as part of the property <code>MetricMathAnomalyDetector</code>.</p>
307    pub fn set_metric_math_anomaly_detector(mut self, input: ::std::option::Option<crate::types::MetricMathAnomalyDetector>) -> Self {
308        self.inner = self.inner.set_metric_math_anomaly_detector(input);
309        self
310    }
311    /// <p>The metric math anomaly detector to be created.</p>
312    /// <p>When using <code>MetricMathAnomalyDetector</code>, you cannot include the following parameters in the same operation:</p>
313    /// <ul>
314    /// <li>
315    /// <p><code>Dimensions</code></p></li>
316    /// <li>
317    /// <p><code>MetricName</code></p></li>
318    /// <li>
319    /// <p><code>Namespace</code></p></li>
320    /// <li>
321    /// <p><code>Stat</code></p></li>
322    /// <li>
323    /// <p>the <code>SingleMetricAnomalyDetector</code> parameters of <code>PutAnomalyDetectorInput</code></p></li>
324    /// </ul>
325    /// <p>Instead, specify the metric math anomaly detector attributes as part of the property <code>MetricMathAnomalyDetector</code>.</p>
326    pub fn get_metric_math_anomaly_detector(&self) -> &::std::option::Option<crate::types::MetricMathAnomalyDetector> {
327        self.inner.get_metric_math_anomaly_detector()
328    }
329}