Skip to main content

nominal_api/conjure/objects/scout/comparisonnotebook/api/
range_aggregation_definition.rs

1/// Every range aggregation must be defined by a data scope and set of conditions. This type should be used by
2/// every comparison workbook viz definition.
3#[derive(
4    Debug,
5    Clone,
6    conjure_object::serde::Serialize,
7    conjure_object::serde::Deserialize,
8    conjure_object::private::DeriveWith
9)]
10#[serde(crate = "conjure_object::serde")]
11#[derive_with(PartialEq, Eq, PartialOrd, Ord, Hash)]
12#[conjure_object::private::staged_builder::staged_builder]
13#[builder(crate = conjure_object::private::staged_builder, update, inline)]
14pub struct RangeAggregationDefinition {
15    #[builder(custom(type = super::ComparisonWorkbookDataScope, convert = Box::new))]
16    #[serde(rename = "dataScope")]
17    data_scope: Box<super::ComparisonWorkbookDataScope>,
18    #[builder(custom(type = super::ComputeNodeWithContext, convert = Box::new))]
19    #[serde(rename = "condition")]
20    condition: Box<super::ComputeNodeWithContext>,
21    #[builder(
22        default,
23        custom(
24            type = impl
25            Into<Option<super::TimeWindow>>,
26            convert = |v|v.into().map(Box::new)
27        )
28    )]
29    #[serde(rename = "timeWindow", skip_serializing_if = "Option::is_none", default)]
30    time_window: Option<Box<super::TimeWindow>>,
31}
32impl RangeAggregationDefinition {
33    /// Constructs a new instance of the type.
34    #[inline]
35    pub fn new(
36        data_scope: super::ComparisonWorkbookDataScope,
37        condition: super::ComputeNodeWithContext,
38    ) -> Self {
39        Self::builder().data_scope(data_scope).condition(condition).build()
40    }
41    #[inline]
42    pub fn data_scope(&self) -> &super::ComparisonWorkbookDataScope {
43        &*self.data_scope
44    }
45    #[inline]
46    pub fn condition(&self) -> &super::ComputeNodeWithContext {
47        &*self.condition
48    }
49    /// determines the window of data included in the visualization. Currently only applied on assets.
50    #[inline]
51    pub fn time_window(&self) -> Option<&super::TimeWindow> {
52        self.time_window.as_ref().map(|o| &**o)
53    }
54}