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<conjure_object::ResourceIdentifier>,
95    #[builder(default, into)]
96    #[serde(rename = "labels", skip_serializing_if = "Option::is_none", default)]
97    labels: Option<std::collections::BTreeSet<String>>,
98    #[builder(default, into)]
99    #[serde(rename = "properties", skip_serializing_if = "Option::is_none", default)]
100    properties: Option<std::collections::BTreeMap<String, String>>,
101    #[builder(
102        default,
103        custom(
104            type = impl
105            Into<Option<super::super::super::super::api::ThemeAwareImage>>,
106            convert = |v|v.into().map(Box::new)
107        )
108    )]
109    #[serde(rename = "previewImage", skip_serializing_if = "Option::is_none", default)]
110    preview_image: Option<Box<super::super::super::super::api::ThemeAwareImage>>,
111}
112impl CreateNotebookRequest {
113    #[inline]
114    pub fn title(&self) -> &str {
115        &*self.title
116    }
117    #[inline]
118    pub fn description(&self) -> &str {
119        &*self.description
120    }
121    /// Optional for backcompatibility. Default is a normal workbook.
122    #[inline]
123    pub fn notebook_type(&self) -> Option<&super::NotebookType> {
124        self.notebook_type.as_ref().map(|o| &*o)
125    }
126    #[inline]
127    pub fn is_draft(&self) -> bool {
128        self.is_draft
129    }
130    #[inline]
131    pub fn state_as_json(&self) -> &str {
132        &*self.state_as_json
133    }
134    #[deprecated(note = "charts are now stored in contentV2")]
135    #[inline]
136    pub fn charts(&self) -> Option<&[super::ChartWithOverlays]> {
137        self.charts.as_ref().map(|o| &**o)
138    }
139    /// deprecated. Use dataScope instead
140    #[inline]
141    pub fn run_rid(&self) -> Option<&super::super::super::run::api::RunRid> {
142        self.run_rid.as_ref().map(|o| &*o)
143    }
144    /// Optional for back-compatibility.
145    #[inline]
146    pub fn data_scope(&self) -> Option<&super::NotebookDataScope> {
147        self.data_scope.as_ref().map(|o| &**o)
148    }
149    #[inline]
150    pub fn layout(&self) -> &super::super::super::layout::api::WorkbookLayout {
151        &*self.layout
152    }
153    #[deprecated(note = "use contentV2 instead")]
154    #[inline]
155    pub fn content(
156        &self,
157    ) -> Option<&super::super::super::workbookcommon::api::WorkbookContent> {
158        self.content.as_ref().map(|o| &**o)
159    }
160    /// Optional for backcompatibility
161    #[inline]
162    pub fn content_v2(
163        &self,
164    ) -> Option<&super::super::super::workbookcommon::api::UnifiedWorkbookContent> {
165        self.content_v2.as_ref().map(|o| &**o)
166    }
167    /// Field to pin events to a workbook on creation.
168    #[inline]
169    pub fn event_refs(
170        &self,
171    ) -> &std::collections::BTreeSet<
172        super::super::super::workbookcommon::api::EventReference,
173    > {
174        &self.event_refs
175    }
176    /// Field to pin check alerts to a workbook on creation.
177    /// Any specified CheckAlertReference will be added to the workbook along with it's corresponding EventReference.
178    #[deprecated(
179        note = "CheckAlerts are no longer supported and will be removed in the future.\nUse eventRefs to pin events to workbooks instead.\n"
180    )]
181    #[inline]
182    pub fn check_alert_refs(
183        &self,
184    ) -> Option<
185        &std::collections::BTreeSet<
186            super::super::super::workbookcommon::api::CheckAlertReference,
187        >,
188    > {
189        self.check_alert_refs.as_ref().map(|o| &*o)
190    }
191    /// The workspace in which to create the workbook. If not provided, the workbook will be created in the default workspace for
192    /// the user's organization, if the default workspace for the organization is configured.
193    #[inline]
194    pub fn workspace(&self) -> Option<&conjure_object::ResourceIdentifier> {
195        self.workspace.as_ref().map(|o| &*o)
196    }
197    /// Labels to apply to the workbook on creation. Defaults to empty if not provided.
198    #[inline]
199    pub fn labels(&self) -> Option<&std::collections::BTreeSet<String>> {
200        self.labels.as_ref().map(|o| &*o)
201    }
202    /// Properties to apply to the workbook on creation. Defaults to empty if not provided.
203    #[inline]
204    pub fn properties(&self) -> Option<&std::collections::BTreeMap<String, String>> {
205        self.properties.as_ref().map(|o| &*o)
206    }
207    /// Theme-aware preview image for the workbook. Falls back to a default illustration if not provided.
208    #[inline]
209    pub fn preview_image(
210        &self,
211    ) -> Option<&super::super::super::super::api::ThemeAwareImage> {
212        self.preview_image.as_ref().map(|o| &**o)
213    }
214}