aws-sdk-codeguruprofiler 1.99.0

AWS SDK for Amazon CodeGuru Profiler
Documentation
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.

/// <p>Details about an anomaly in a specific metric of application profile. The anomaly is detected using analysis of the metric data over a period of time.</p>
#[non_exhaustive]
#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::fmt::Debug)]
pub struct Anomaly {
    /// <p>Details about the metric that the analysis used when it detected the anomaly. The metric includes the name of the frame that was analyzed with the type and thread states used to derive the metric value for that frame.</p>
    pub metric: ::std::option::Option<crate::types::Metric>,
    /// <p>The reason for which metric was flagged as anomalous.</p>
    pub reason: ::std::string::String,
    /// <p>A list of the instances of the detected anomalies during the requested period.</p>
    pub instances: ::std::vec::Vec<crate::types::AnomalyInstance>,
}
impl Anomaly {
    /// <p>Details about the metric that the analysis used when it detected the anomaly. The metric includes the name of the frame that was analyzed with the type and thread states used to derive the metric value for that frame.</p>
    pub fn metric(&self) -> ::std::option::Option<&crate::types::Metric> {
        self.metric.as_ref()
    }
    /// <p>The reason for which metric was flagged as anomalous.</p>
    pub fn reason(&self) -> &str {
        use std::ops::Deref;
        self.reason.deref()
    }
    /// <p>A list of the instances of the detected anomalies during the requested period.</p>
    pub fn instances(&self) -> &[crate::types::AnomalyInstance] {
        use std::ops::Deref;
        self.instances.deref()
    }
}
impl Anomaly {
    /// Creates a new builder-style object to manufacture [`Anomaly`](crate::types::Anomaly).
    pub fn builder() -> crate::types::builders::AnomalyBuilder {
        crate::types::builders::AnomalyBuilder::default()
    }
}

/// A builder for [`Anomaly`](crate::types::Anomaly).
#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::default::Default, ::std::fmt::Debug)]
#[non_exhaustive]
pub struct AnomalyBuilder {
    pub(crate) metric: ::std::option::Option<crate::types::Metric>,
    pub(crate) reason: ::std::option::Option<::std::string::String>,
    pub(crate) instances: ::std::option::Option<::std::vec::Vec<crate::types::AnomalyInstance>>,
}
impl AnomalyBuilder {
    /// <p>Details about the metric that the analysis used when it detected the anomaly. The metric includes the name of the frame that was analyzed with the type and thread states used to derive the metric value for that frame.</p>
    /// This field is required.
    pub fn metric(mut self, input: crate::types::Metric) -> Self {
        self.metric = ::std::option::Option::Some(input);
        self
    }
    /// <p>Details about the metric that the analysis used when it detected the anomaly. The metric includes the name of the frame that was analyzed with the type and thread states used to derive the metric value for that frame.</p>
    pub fn set_metric(mut self, input: ::std::option::Option<crate::types::Metric>) -> Self {
        self.metric = input;
        self
    }
    /// <p>Details about the metric that the analysis used when it detected the anomaly. The metric includes the name of the frame that was analyzed with the type and thread states used to derive the metric value for that frame.</p>
    pub fn get_metric(&self) -> &::std::option::Option<crate::types::Metric> {
        &self.metric
    }
    /// <p>The reason for which metric was flagged as anomalous.</p>
    /// This field is required.
    pub fn reason(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
        self.reason = ::std::option::Option::Some(input.into());
        self
    }
    /// <p>The reason for which metric was flagged as anomalous.</p>
    pub fn set_reason(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
        self.reason = input;
        self
    }
    /// <p>The reason for which metric was flagged as anomalous.</p>
    pub fn get_reason(&self) -> &::std::option::Option<::std::string::String> {
        &self.reason
    }
    /// Appends an item to `instances`.
    ///
    /// To override the contents of this collection use [`set_instances`](Self::set_instances).
    ///
    /// <p>A list of the instances of the detected anomalies during the requested period.</p>
    pub fn instances(mut self, input: crate::types::AnomalyInstance) -> Self {
        let mut v = self.instances.unwrap_or_default();
        v.push(input);
        self.instances = ::std::option::Option::Some(v);
        self
    }
    /// <p>A list of the instances of the detected anomalies during the requested period.</p>
    pub fn set_instances(mut self, input: ::std::option::Option<::std::vec::Vec<crate::types::AnomalyInstance>>) -> Self {
        self.instances = input;
        self
    }
    /// <p>A list of the instances of the detected anomalies during the requested period.</p>
    pub fn get_instances(&self) -> &::std::option::Option<::std::vec::Vec<crate::types::AnomalyInstance>> {
        &self.instances
    }
    /// Consumes the builder and constructs a [`Anomaly`](crate::types::Anomaly).
    /// This method will fail if any of the following fields are not set:
    /// - [`reason`](crate::types::builders::AnomalyBuilder::reason)
    /// - [`instances`](crate::types::builders::AnomalyBuilder::instances)
    pub fn build(self) -> ::std::result::Result<crate::types::Anomaly, ::aws_smithy_types::error::operation::BuildError> {
        ::std::result::Result::Ok(crate::types::Anomaly {
            metric: self.metric,
            reason: self.reason.ok_or_else(|| {
                ::aws_smithy_types::error::operation::BuildError::missing_field(
                    "reason",
                    "reason was not specified but it is required when building Anomaly",
                )
            })?,
            instances: self.instances.ok_or_else(|| {
                ::aws_smithy_types::error::operation::BuildError::missing_field(
                    "instances",
                    "instances was not specified but it is required when building Anomaly",
                )
            })?,
        })
    }
}