/// Summarizes the output of a series node. The output can be a numeric, enum, log, or cartesian series.
/// Summarization strategy should be specified.
#[derive(
    Debug,
    Clone,
    conjure_object::serde::Serialize,
    conjure_object::serde::Deserialize,
    conjure_object::private::DeriveWith
)]
#[serde(crate = "conjure_object::serde")]
#[derive_with(PartialEq, Eq, PartialOrd, Ord, Hash)]
#[conjure_object::private::staged_builder::staged_builder]
#[builder(crate = conjure_object::private::staged_builder, update, inline)]
pub struct SummarizeSeries {
    #[builder(custom(type = super::Series, convert = Box::new))]
    #[serde(rename = "input")]
    input: Box<super::Series>,
    #[builder(default, into)]
    #[serde(rename = "outputFormat", skip_serializing_if = "Option::is_none", default)]
    output_format: Option<super::OutputFormat>,
    #[builder(default, into)]
    #[serde(
        rename = "numericOutputFields",
        skip_serializing_if = "Option::is_none",
        default
    )]
    numeric_output_fields: Option<std::collections::BTreeSet<super::NumericOutputField>>,
    #[builder(
        default,
        map(key(type = String, into), value(type = super::NumericAggregationOperator))
    )]
    #[serde(
        rename = "numericAggregations",
        skip_serializing_if = "std::collections::BTreeMap::is_empty",
        default
    )]
    numeric_aggregations: std::collections::BTreeMap<
        String,
        super::NumericAggregationOperator,
    >,
    #[builder(default, into)]
    #[serde(
        rename = "numericOutputFieldsV2",
        skip_serializing_if = "Option::is_none",
        default
    )]
    numeric_output_fields_v2: Option<Vec<super::NumericOutputFieldV2>>,
    #[builder(default, into)]
    #[serde(rename = "resolution", skip_serializing_if = "Option::is_none", default)]
    resolution: Option<conjure_object::SafeLong>,
    #[builder(default, into)]
    #[serde(rename = "buckets", skip_serializing_if = "Option::is_none", default)]
    buckets: Option<i32>,
    #[builder(
        default,
        custom(
            type = impl
            Into<Option<super::SummarizationStrategy>>,
            convert = |v|v.into().map(Box::new)
        )
    )]
    #[serde(
        rename = "summarizationStrategy",
        skip_serializing_if = "Option::is_none",
        default
    )]
    summarization_strategy: Option<Box<super::SummarizationStrategy>>,
}
impl SummarizeSeries {
    /// Constructs a new instance of the type.
    #[inline]
    pub fn new(input: super::Series) -> Self {
        Self::builder().input(input).build()
    }
    #[inline]
    pub fn input(&self) -> &super::Series {
        &*self.input
    }
    /// The output format of the response. Defaults to LEGACY.
    #[inline]
    pub fn output_format(&self) -> Option<&super::OutputFormat> {
        self.output_format.as_ref().map(|o| &*o)
    }
    /// The fields to output from the summarization. Applies only to Arrow format numeric series.
    #[deprecated(note = "Use numericOutputFieldsV2 instead.\n")]
    #[inline]
    pub fn numeric_output_fields(
        &self,
    ) -> Option<&std::collections::BTreeSet<super::NumericOutputField>> {
        self.numeric_output_fields.as_ref().map(|o| &*o)
    }
    /// Additional numeric aggregations per decimation bucket (e.g. percentiles). Map key is the name of the column in the result.
    #[inline]
    pub fn numeric_aggregations(
        &self,
    ) -> &std::collections::BTreeMap<String, super::NumericAggregationOperator> {
        &self.numeric_aggregations
    }
    /// Numeric bucket output fields to return. Applies only to Arrow format numeric series.
    /// Defaults to MEAN when no numeric output selector is specified.
    /// Mutually exclusive with numericOutputFields and numericAggregations.
    #[inline]
    pub fn numeric_output_fields_v2(&self) -> Option<&[super::NumericOutputFieldV2]> {
        self.numeric_output_fields_v2.as_ref().map(|o| &**o)
    }
    /// Resolution of the output series specifying time interval between decimated points, in nanoseconds.
    #[deprecated(note = "Use summarizationStrategy instead.\n")]
    #[inline]
    pub fn resolution(&self) -> Option<conjure_object::SafeLong> {
        self.resolution.as_ref().map(|o| *o)
    }
    /// Number of points to generate in the output series.
    #[deprecated(note = "Use summarizationStrategy instead.\n")]
    #[inline]
    pub fn buckets(&self) -> Option<i32> {
        self.buckets.as_ref().map(|o| *o)
    }
    /// The strategy to use when summarizing the series.
    #[inline]
    pub fn summarization_strategy(&self) -> Option<&super::SummarizationStrategy> {
        self.summarization_strategy.as_ref().map(|o| &**o)
    }
}
