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 the metric that the analysis used when it detected the anomaly. The metric what is analyzed to create recommendations. It includes the name of the frame that was analyzed and the type and thread states used to derive the metric value for that frame.</p>
#[non_exhaustive]
#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::fmt::Debug)]
pub struct Metric {
    /// <p>The name of the method that appears as a frame in any stack in a profile.</p>
    pub frame_name: ::std::string::String,
    /// <p>A type that specifies how a metric for a frame is analyzed. The supported value <code>AggregatedRelativeTotalTime</code> is an aggregation of the metric value for one frame that is calculated across the occurences of all frames in a profile.</p>
    pub r#type: crate::types::MetricType,
    /// <p>The list of application runtime thread states that is used to calculate the metric value for the frame.</p>
    pub thread_states: ::std::vec::Vec<::std::string::String>,
}
impl Metric {
    /// <p>The name of the method that appears as a frame in any stack in a profile.</p>
    pub fn frame_name(&self) -> &str {
        use std::ops::Deref;
        self.frame_name.deref()
    }
    /// <p>A type that specifies how a metric for a frame is analyzed. The supported value <code>AggregatedRelativeTotalTime</code> is an aggregation of the metric value for one frame that is calculated across the occurences of all frames in a profile.</p>
    pub fn r#type(&self) -> &crate::types::MetricType {
        &self.r#type
    }
    /// <p>The list of application runtime thread states that is used to calculate the metric value for the frame.</p>
    pub fn thread_states(&self) -> &[::std::string::String] {
        use std::ops::Deref;
        self.thread_states.deref()
    }
}
impl Metric {
    /// Creates a new builder-style object to manufacture [`Metric`](crate::types::Metric).
    pub fn builder() -> crate::types::builders::MetricBuilder {
        crate::types::builders::MetricBuilder::default()
    }
}

/// A builder for [`Metric`](crate::types::Metric).
#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::default::Default, ::std::fmt::Debug)]
#[non_exhaustive]
pub struct MetricBuilder {
    pub(crate) frame_name: ::std::option::Option<::std::string::String>,
    pub(crate) r#type: ::std::option::Option<crate::types::MetricType>,
    pub(crate) thread_states: ::std::option::Option<::std::vec::Vec<::std::string::String>>,
}
impl MetricBuilder {
    /// <p>The name of the method that appears as a frame in any stack in a profile.</p>
    /// This field is required.
    pub fn frame_name(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
        self.frame_name = ::std::option::Option::Some(input.into());
        self
    }
    /// <p>The name of the method that appears as a frame in any stack in a profile.</p>
    pub fn set_frame_name(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
        self.frame_name = input;
        self
    }
    /// <p>The name of the method that appears as a frame in any stack in a profile.</p>
    pub fn get_frame_name(&self) -> &::std::option::Option<::std::string::String> {
        &self.frame_name
    }
    /// <p>A type that specifies how a metric for a frame is analyzed. The supported value <code>AggregatedRelativeTotalTime</code> is an aggregation of the metric value for one frame that is calculated across the occurences of all frames in a profile.</p>
    /// This field is required.
    pub fn r#type(mut self, input: crate::types::MetricType) -> Self {
        self.r#type = ::std::option::Option::Some(input);
        self
    }
    /// <p>A type that specifies how a metric for a frame is analyzed. The supported value <code>AggregatedRelativeTotalTime</code> is an aggregation of the metric value for one frame that is calculated across the occurences of all frames in a profile.</p>
    pub fn set_type(mut self, input: ::std::option::Option<crate::types::MetricType>) -> Self {
        self.r#type = input;
        self
    }
    /// <p>A type that specifies how a metric for a frame is analyzed. The supported value <code>AggregatedRelativeTotalTime</code> is an aggregation of the metric value for one frame that is calculated across the occurences of all frames in a profile.</p>
    pub fn get_type(&self) -> &::std::option::Option<crate::types::MetricType> {
        &self.r#type
    }
    /// Appends an item to `thread_states`.
    ///
    /// To override the contents of this collection use [`set_thread_states`](Self::set_thread_states).
    ///
    /// <p>The list of application runtime thread states that is used to calculate the metric value for the frame.</p>
    pub fn thread_states(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
        let mut v = self.thread_states.unwrap_or_default();
        v.push(input.into());
        self.thread_states = ::std::option::Option::Some(v);
        self
    }
    /// <p>The list of application runtime thread states that is used to calculate the metric value for the frame.</p>
    pub fn set_thread_states(mut self, input: ::std::option::Option<::std::vec::Vec<::std::string::String>>) -> Self {
        self.thread_states = input;
        self
    }
    /// <p>The list of application runtime thread states that is used to calculate the metric value for the frame.</p>
    pub fn get_thread_states(&self) -> &::std::option::Option<::std::vec::Vec<::std::string::String>> {
        &self.thread_states
    }
    /// Consumes the builder and constructs a [`Metric`](crate::types::Metric).
    /// This method will fail if any of the following fields are not set:
    /// - [`frame_name`](crate::types::builders::MetricBuilder::frame_name)
    /// - [`r#type`](crate::types::builders::MetricBuilder::type)
    /// - [`thread_states`](crate::types::builders::MetricBuilder::thread_states)
    pub fn build(self) -> ::std::result::Result<crate::types::Metric, ::aws_smithy_types::error::operation::BuildError> {
        ::std::result::Result::Ok(crate::types::Metric {
            frame_name: self.frame_name.ok_or_else(|| {
                ::aws_smithy_types::error::operation::BuildError::missing_field(
                    "frame_name",
                    "frame_name was not specified but it is required when building Metric",
                )
            })?,
            r#type: self.r#type.ok_or_else(|| {
                ::aws_smithy_types::error::operation::BuildError::missing_field(
                    "r#type",
                    "r#type was not specified but it is required when building Metric",
                )
            })?,
            thread_states: self.thread_states.ok_or_else(|| {
                ::aws_smithy_types::error::operation::BuildError::missing_field(
                    "thread_states",
                    "thread_states was not specified but it is required when building Metric",
                )
            })?,
        })
    }
}