Skip to main content

nominal_api/conjure/objects/scout/notebook/api/
update_notebook_request.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 UpdateNotebookRequest {
13    #[builder(into)]
14    #[serde(rename = "stateAsJson")]
15    state_as_json: String,
16    #[builder(default, into)]
17    #[serde(rename = "charts", skip_serializing_if = "Option::is_none", default)]
18    charts: Option<Vec<super::ChartWithOverlays>>,
19    #[builder(
20        custom(
21            type = super::super::super::layout::api::WorkbookLayout,
22            convert = Box::new
23        )
24    )]
25    #[serde(rename = "layout")]
26    layout: Box<super::super::super::layout::api::WorkbookLayout>,
27    #[builder(
28        default,
29        custom(
30            type = impl
31            Into<Option<super::super::super::workbookcommon::api::WorkbookContent>>,
32            convert = |v|v.into().map(Box::new)
33        )
34    )]
35    #[serde(rename = "content", skip_serializing_if = "Option::is_none", default)]
36    content: Option<Box<super::super::super::workbookcommon::api::WorkbookContent>>,
37    #[builder(
38        default,
39        custom(
40            type = impl
41            Into<Option<super::super::super::workbookcommon::api::UnifiedWorkbookContent>>,
42            convert = |v|v.into().map(Box::new)
43        )
44    )]
45    #[serde(rename = "contentV2", skip_serializing_if = "Option::is_none", default)]
46    content_v2: Option<
47        Box<super::super::super::workbookcommon::api::UnifiedWorkbookContent>,
48    >,
49    #[builder(default, into)]
50    #[serde(
51        rename = "latestSnapshotRid",
52        skip_serializing_if = "Option::is_none",
53        default
54    )]
55    latest_snapshot_rid: Option<super::super::super::rids::api::SnapshotRid>,
56    #[builder(
57        default,
58        set(item(type = super::super::super::workbookcommon::api::EventReference))
59    )]
60    #[serde(
61        rename = "eventRefs",
62        skip_serializing_if = "std::collections::BTreeSet::is_empty",
63        default
64    )]
65    event_refs: std::collections::BTreeSet<
66        super::super::super::workbookcommon::api::EventReference,
67    >,
68    #[builder(default, into)]
69    #[serde(rename = "checkAlertRefs", skip_serializing_if = "Option::is_none", default)]
70    check_alert_refs: Option<
71        std::collections::BTreeSet<
72            super::super::super::workbookcommon::api::CheckAlertReference,
73        >,
74    >,
75}
76impl UpdateNotebookRequest {
77    /// Constructs a new instance of the type.
78    #[inline]
79    pub fn new(
80        state_as_json: impl Into<String>,
81        layout: super::super::super::layout::api::WorkbookLayout,
82    ) -> Self {
83        Self::builder().state_as_json(state_as_json).layout(layout).build()
84    }
85    #[inline]
86    pub fn state_as_json(&self) -> &str {
87        &*self.state_as_json
88    }
89    #[deprecated(note = "charts are now stored in contentV2")]
90    #[inline]
91    pub fn charts(&self) -> Option<&[super::ChartWithOverlays]> {
92        self.charts.as_ref().map(|o| &**o)
93    }
94    #[inline]
95    pub fn layout(&self) -> &super::super::super::layout::api::WorkbookLayout {
96        &*self.layout
97    }
98    #[deprecated(note = "use contentV2 instead")]
99    #[inline]
100    pub fn content(
101        &self,
102    ) -> Option<&super::super::super::workbookcommon::api::WorkbookContent> {
103        self.content.as_ref().map(|o| &**o)
104    }
105    /// Optional for backcompatibility
106    #[inline]
107    pub fn content_v2(
108        &self,
109    ) -> Option<&super::super::super::workbookcommon::api::UnifiedWorkbookContent> {
110        self.content_v2.as_ref().map(|o| &**o)
111    }
112    /// If provided, will only update the notebook if the latest snapshot matches the provided snapshot rid,
113    /// and throws SaveNotebookConflict otherwise.
114    #[inline]
115    pub fn latest_snapshot_rid(
116        &self,
117    ) -> Option<&super::super::super::rids::api::SnapshotRid> {
118        self.latest_snapshot_rid.as_ref().map(|o| &*o)
119    }
120    /// Replace existing pinned events on the workbook.
121    #[inline]
122    pub fn event_refs(
123        &self,
124    ) -> &std::collections::BTreeSet<
125        super::super::super::workbookcommon::api::EventReference,
126    > {
127        &self.event_refs
128    }
129    /// Field to pin check alerts to a workbook on creation.
130    /// If not provided, will keep the set of check alerts on the workbook unchanged.
131    /// Providing an empty set will remove all check alerts from the workbook.
132    /// Any specified CheckAlertReference will be added to the workbook along with it's corresponding EventReference.
133    #[deprecated(
134        note = "CheckAlerts are no longer supported and will be removed in the future.\nUse eventRefs to pin events to workbooks instead.\n"
135    )]
136    #[inline]
137    pub fn check_alert_refs(
138        &self,
139    ) -> Option<
140        &std::collections::BTreeSet<
141            super::super::super::workbookcommon::api::CheckAlertReference,
142        >,
143    > {
144        self.check_alert_refs.as_ref().map(|o| &*o)
145    }
146}