Skip to main content

nominal_api/conjure/objects/scout/workbookcommon/api/
workbook_settings.rs

1#[derive(
2    Debug,
3    Clone,
4    conjure_object::serde::Serialize,
5    conjure_object::serde::Deserialize,
6    conjure_object::private::DeriveWith
7)]
8#[serde(crate = "conjure_object::serde")]
9#[derive_with(PartialEq, Eq, PartialOrd, Ord, Hash)]
10#[conjure_object::private::staged_builder::staged_builder]
11#[builder(crate = conjure_object::private::staged_builder, update, inline)]
12pub struct WorkbookSettings {
13    #[builder(default, into)]
14    #[serde(rename = "assetSettings", skip_serializing_if = "Option::is_none", default)]
15    asset_settings: Option<
16        std::collections::BTreeMap<
17            super::super::super::rids::api::AssetRid,
18            super::AssetSettings,
19        >,
20    >,
21    #[builder(default, into)]
22    #[serde(rename = "runSettings", skip_serializing_if = "Option::is_none", default)]
23    run_settings: Option<
24        std::collections::BTreeMap<
25            super::super::super::run::api::RunRid,
26            super::RunSettings,
27        >,
28    >,
29    #[builder(
30        default,
31        custom(
32            type = impl
33            Into<Option<super::WorkbookTimeSettings>>,
34            convert = |v|v.into().map(Box::new)
35        )
36    )]
37    #[serde(rename = "timeSettings", skip_serializing_if = "Option::is_none", default)]
38    time_settings: Option<Box<super::WorkbookTimeSettings>>,
39    #[builder(
40        default,
41        custom(
42            type = impl
43            Into<Option<super::WorkbookOffsets>>,
44            convert = |v|v.into().map(Box::new)
45        )
46    )]
47    #[serde(rename = "offsets", skip_serializing_if = "Option::is_none", default)]
48    offsets: Option<Box<super::WorkbookOffsets>>,
49    #[builder(
50        default,
51        custom(
52            type = impl
53            Into<Option<super::super::super::chartdefinition::api::StalenessConfiguration>>,
54            convert = |v|v.into().map(Box::new)
55        )
56    )]
57    #[serde(
58        rename = "defaultStalenessConfiguration",
59        skip_serializing_if = "Option::is_none",
60        default
61    )]
62    default_staleness_configuration: Option<
63        Box<super::super::super::chartdefinition::api::StalenessConfiguration>,
64    >,
65}
66impl WorkbookSettings {
67    /// Constructs a new instance of the type.
68    #[inline]
69    pub fn new() -> Self {
70        Self::builder().build()
71    }
72    /// Settings for assets to be used in the workbook. This should be present for asset workbooks.
73    #[inline]
74    pub fn asset_settings(
75        &self,
76    ) -> Option<
77        &std::collections::BTreeMap<
78            super::super::super::rids::api::AssetRid,
79            super::AssetSettings,
80        >,
81    > {
82        self.asset_settings.as_ref().map(|o| &*o)
83    }
84    /// Settings for runs to be used in the workbook. This should be present for run workbooks.
85    #[inline]
86    pub fn run_settings(
87        &self,
88    ) -> Option<
89        &std::collections::BTreeMap<
90            super::super::super::run::api::RunRid,
91            super::RunSettings,
92        >,
93    > {
94        self.run_settings.as_ref().map(|o| &*o)
95    }
96    /// Time range settings when users access a workbook. Time range URL query params will take precedence
97    /// over persisted the global time range.
98    #[inline]
99    pub fn time_settings(&self) -> Option<&super::WorkbookTimeSettings> {
100        self.time_settings.as_ref().map(|o| &**o)
101    }
102    /// Time offsets that can be applied to the workbook.
103    #[inline]
104    pub fn offsets(&self) -> Option<&super::WorkbookOffsets> {
105        self.offsets.as_ref().map(|o| &**o)
106    }
107    /// Default staleness configuration for new time series panels in the workbook.
108    /// When set, new time series panels will use this instead of the 1-second default.
109    #[inline]
110    pub fn default_staleness_configuration(
111        &self,
112    ) -> Option<&super::super::super::chartdefinition::api::StalenessConfiguration> {
113        self.default_staleness_configuration.as_ref().map(|o| &**o)
114    }
115}