Skip to main content

nominal_api/conjure/objects/scout/notebook/api/
create_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 CreateNotebookRequest {
13    #[builder(into)]
14    #[serde(rename = "title")]
15    title: String,
16    #[builder(into)]
17    #[serde(rename = "description")]
18    description: String,
19    #[builder(default, into)]
20    #[serde(rename = "notebookType", skip_serializing_if = "Option::is_none", default)]
21    notebook_type: Option<super::NotebookType>,
22    #[serde(rename = "isDraft")]
23    is_draft: bool,
24    #[builder(into)]
25    #[serde(rename = "stateAsJson")]
26    state_as_json: String,
27    #[builder(default, into)]
28    #[serde(rename = "charts", skip_serializing_if = "Option::is_none", default)]
29    charts: Option<Vec<super::ChartWithOverlays>>,
30    #[builder(default, into)]
31    #[serde(rename = "runRid", skip_serializing_if = "Option::is_none", default)]
32    run_rid: Option<super::super::super::run::api::RunRid>,
33    #[builder(
34        default,
35        custom(
36            type = impl
37            Into<Option<super::NotebookDataScope>>,
38            convert = |v|v.into().map(Box::new)
39        )
40    )]
41    #[serde(rename = "dataScope", skip_serializing_if = "Option::is_none", default)]
42    data_scope: Option<Box<super::NotebookDataScope>>,
43    #[builder(
44        custom(
45            type = super::super::super::layout::api::WorkbookLayout,
46            convert = Box::new
47        )
48    )]
49    #[serde(rename = "layout")]
50    layout: Box<super::super::super::layout::api::WorkbookLayout>,
51    #[builder(
52        default,
53        custom(
54            type = impl
55            Into<Option<super::super::super::workbookcommon::api::WorkbookContent>>,
56            convert = |v|v.into().map(Box::new)
57        )
58    )]
59    #[serde(rename = "content", skip_serializing_if = "Option::is_none", default)]
60    content: Option<Box<super::super::super::workbookcommon::api::WorkbookContent>>,
61    #[builder(
62        default,
63        custom(
64            type = impl
65            Into<Option<super::super::super::workbookcommon::api::UnifiedWorkbookContent>>,
66            convert = |v|v.into().map(Box::new)
67        )
68    )]
69    #[serde(rename = "contentV2", skip_serializing_if = "Option::is_none", default)]
70    content_v2: Option<
71        Box<super::super::super::workbookcommon::api::UnifiedWorkbookContent>,
72    >,
73    #[builder(
74        default,
75        set(item(type = super::super::super::workbookcommon::api::EventReference))
76    )]
77    #[serde(
78        rename = "eventRefs",
79        skip_serializing_if = "std::collections::BTreeSet::is_empty",
80        default
81    )]
82    event_refs: std::collections::BTreeSet<
83        super::super::super::workbookcommon::api::EventReference,
84    >,
85    #[builder(default, into)]
86    #[serde(rename = "checkAlertRefs", skip_serializing_if = "Option::is_none", default)]
87    check_alert_refs: Option<
88        std::collections::BTreeSet<
89            super::super::super::workbookcommon::api::CheckAlertReference,
90        >,
91    >,
92    #[builder(default, into)]
93    #[serde(rename = "workspace", skip_serializing_if = "Option::is_none", default)]
94    workspace: Option<super::super::super::super::api::rids::WorkspaceRid>,
95    #[builder(default, into)]
96    #[serde(rename = "labels", skip_serializing_if = "Option::is_none", default)]
97    labels: Option<std::collections::BTreeSet<super::super::super::super::api::Label>>,
98    #[builder(default, into)]
99    #[serde(rename = "properties", skip_serializing_if = "Option::is_none", default)]
100    properties: Option<
101        std::collections::BTreeMap<
102            super::super::super::super::api::PropertyName,
103            super::super::super::super::api::PropertyValue,
104        >,
105    >,
106    #[builder(
107        default,
108        custom(
109            type = impl
110            Into<Option<super::super::super::super::api::ThemeAwareImage>>,
111            convert = |v|v.into().map(Box::new)
112        )
113    )]
114    #[serde(rename = "previewImage", skip_serializing_if = "Option::is_none", default)]
115    preview_image: Option<Box<super::super::super::super::api::ThemeAwareImage>>,
116}
117impl CreateNotebookRequest {
118    #[inline]
119    pub fn title(&self) -> &str {
120        &*self.title
121    }
122    #[inline]
123    pub fn description(&self) -> &str {
124        &*self.description
125    }
126    /// Optional for backcompatibility. Default is a normal workbook.
127    #[inline]
128    pub fn notebook_type(&self) -> Option<&super::NotebookType> {
129        self.notebook_type.as_ref().map(|o| &*o)
130    }
131    #[inline]
132    pub fn is_draft(&self) -> bool {
133        self.is_draft
134    }
135    #[inline]
136    pub fn state_as_json(&self) -> &str {
137        &*self.state_as_json
138    }
139    #[deprecated(note = "charts are now stored in contentV2")]
140    #[inline]
141    pub fn charts(&self) -> Option<&[super::ChartWithOverlays]> {
142        self.charts.as_ref().map(|o| &**o)
143    }
144    /// deprecated. Use dataScope instead
145    #[inline]
146    pub fn run_rid(&self) -> Option<&super::super::super::run::api::RunRid> {
147        self.run_rid.as_ref().map(|o| &*o)
148    }
149    /// Optional for back-compatibility.
150    #[inline]
151    pub fn data_scope(&self) -> Option<&super::NotebookDataScope> {
152        self.data_scope.as_ref().map(|o| &**o)
153    }
154    #[inline]
155    pub fn layout(&self) -> &super::super::super::layout::api::WorkbookLayout {
156        &*self.layout
157    }
158    #[deprecated(note = "use contentV2 instead")]
159    #[inline]
160    pub fn content(
161        &self,
162    ) -> Option<&super::super::super::workbookcommon::api::WorkbookContent> {
163        self.content.as_ref().map(|o| &**o)
164    }
165    /// Optional for backcompatibility
166    #[inline]
167    pub fn content_v2(
168        &self,
169    ) -> Option<&super::super::super::workbookcommon::api::UnifiedWorkbookContent> {
170        self.content_v2.as_ref().map(|o| &**o)
171    }
172    /// Field to pin events to a workbook on creation.
173    #[inline]
174    pub fn event_refs(
175        &self,
176    ) -> &std::collections::BTreeSet<
177        super::super::super::workbookcommon::api::EventReference,
178    > {
179        &self.event_refs
180    }
181    /// Field to pin check alerts to a workbook on creation.
182    /// Any specified CheckAlertReference will be added to the workbook along with it's corresponding EventReference.
183    #[deprecated(
184        note = "CheckAlerts are no longer supported and will be removed in the future.\nUse eventRefs to pin events to workbooks instead.\n"
185    )]
186    #[inline]
187    pub fn check_alert_refs(
188        &self,
189    ) -> Option<
190        &std::collections::BTreeSet<
191            super::super::super::workbookcommon::api::CheckAlertReference,
192        >,
193    > {
194        self.check_alert_refs.as_ref().map(|o| &*o)
195    }
196    /// The workspace in which to create the workbook. If not provided, the workbook will be created in the default workspace for
197    /// the user's organization, if the default workspace for the organization is configured.
198    #[inline]
199    pub fn workspace(
200        &self,
201    ) -> Option<&super::super::super::super::api::rids::WorkspaceRid> {
202        self.workspace.as_ref().map(|o| &*o)
203    }
204    /// Labels to apply to the workbook on creation. Defaults to empty if not provided.
205    #[inline]
206    pub fn labels(
207        &self,
208    ) -> Option<&std::collections::BTreeSet<super::super::super::super::api::Label>> {
209        self.labels.as_ref().map(|o| &*o)
210    }
211    /// Properties to apply to the workbook on creation. Defaults to empty if not provided.
212    #[inline]
213    pub fn properties(
214        &self,
215    ) -> Option<
216        &std::collections::BTreeMap<
217            super::super::super::super::api::PropertyName,
218            super::super::super::super::api::PropertyValue,
219        >,
220    > {
221        self.properties.as_ref().map(|o| &*o)
222    }
223    /// Theme-aware preview image for the workbook. Falls back to a default illustration if not provided.
224    #[inline]
225    pub fn preview_image(
226        &self,
227    ) -> Option<&super::super::super::super::api::ThemeAwareImage> {
228        self.preview_image.as_ref().map(|o| &**o)
229    }
230}