Skip to main content

nominal_api/conjure/objects/scout/notebook/api/
duplicate_notebook_request.rs

1/// Request to duplicate a workbook. All content fields (layout, charts, contentV2, eventRefs) are
2/// copied from the source workbook. Metadata fields can be optionally overridden; if not provided,
3/// they default to the source workbook's values (except isDraft which defaults to true, and
4/// isLocked which defaults to false).
5#[derive(
6    Debug,
7    Clone,
8    conjure_object::serde::Serialize,
9    conjure_object::serde::Deserialize,
10    PartialEq,
11    Eq,
12    PartialOrd,
13    Ord,
14    Hash
15)]
16#[serde(crate = "conjure_object::serde")]
17#[conjure_object::private::staged_builder::staged_builder]
18#[builder(crate = conjure_object::private::staged_builder, update, inline)]
19pub struct DuplicateNotebookRequest {
20    #[builder(default, into)]
21    #[serde(rename = "title", skip_serializing_if = "Option::is_none", default)]
22    title: Option<String>,
23    #[builder(default, into)]
24    #[serde(rename = "titleSuffix", skip_serializing_if = "Option::is_none", default)]
25    title_suffix: Option<String>,
26    #[builder(default, into)]
27    #[serde(rename = "description", skip_serializing_if = "Option::is_none", default)]
28    description: Option<String>,
29    #[builder(
30        default,
31        custom(
32            type = impl
33            Into<Option<super::NotebookDataScope>>,
34            convert = |v|v.into().map(Box::new)
35        )
36    )]
37    #[serde(rename = "dataScope", skip_serializing_if = "Option::is_none", default)]
38    data_scope: Option<Box<super::NotebookDataScope>>,
39    #[builder(default, into)]
40    #[serde(rename = "isDraft", skip_serializing_if = "Option::is_none", default)]
41    is_draft: Option<bool>,
42    #[builder(default, into)]
43    #[serde(rename = "isLocked", skip_serializing_if = "Option::is_none", default)]
44    is_locked: Option<bool>,
45    #[serde(rename = "workspace")]
46    workspace: super::super::super::super::api::rids::WorkspaceRid,
47    #[builder(default, into)]
48    #[serde(rename = "labels", skip_serializing_if = "Option::is_none", default)]
49    labels: Option<std::collections::BTreeSet<super::super::super::super::api::Label>>,
50    #[builder(default, into)]
51    #[serde(rename = "properties", skip_serializing_if = "Option::is_none", default)]
52    properties: Option<
53        std::collections::BTreeMap<
54            super::super::super::super::api::PropertyName,
55            super::super::super::super::api::PropertyValue,
56        >,
57    >,
58    #[builder(
59        default,
60        custom(
61            type = impl
62            Into<Option<super::super::super::super::api::ThemeAwareImage>>,
63            convert = |v|v.into().map(Box::new)
64        )
65    )]
66    #[serde(rename = "previewImage", skip_serializing_if = "Option::is_none", default)]
67    preview_image: Option<Box<super::super::super::super::api::ThemeAwareImage>>,
68}
69impl DuplicateNotebookRequest {
70    /// Constructs a new instance of the type.
71    #[inline]
72    pub fn new(workspace: super::super::super::super::api::rids::WorkspaceRid) -> Self {
73        Self::builder().workspace(workspace).build()
74    }
75    /// Override the title of the duplicated workbook. If not provided, generates a copy title
76    /// from the source using the titleSuffix.
77    #[inline]
78    pub fn title(&self) -> Option<&str> {
79        self.title.as_ref().map(|o| &**o)
80    }
81    /// Custom suffix for generating the copy title (e.g., "Run analysis").
82    /// Defaults to "copy". Ignored if title is explicitly provided.
83    #[inline]
84    pub fn title_suffix(&self) -> Option<&str> {
85        self.title_suffix.as_ref().map(|o| &**o)
86    }
87    /// Override description. Defaults to the source workbook's description.
88    #[inline]
89    pub fn description(&self) -> Option<&str> {
90        self.description.as_ref().map(|o| &**o)
91    }
92    /// Override data scope. Defaults to the source workbook's data scope.
93    #[inline]
94    pub fn data_scope(&self) -> Option<&super::NotebookDataScope> {
95        self.data_scope.as_ref().map(|o| &**o)
96    }
97    /// Override draft status. Defaults to true — even published (and locked) workbooks become
98    /// drafts when duplicated, since the copy is a new working version for the caller to review
99    /// before publishing.
100    #[inline]
101    pub fn is_draft(&self) -> Option<bool> {
102        self.is_draft.as_ref().map(|o| *o)
103    }
104    /// Override lock status. Defaults to false — locked workbooks are unlocked when duplicated,
105    /// since the copy is a new draft for the caller to iterate on.
106    #[inline]
107    pub fn is_locked(&self) -> Option<bool> {
108        self.is_locked.as_ref().map(|o| *o)
109    }
110    /// The workspace for the duplicated workbook.
111    #[inline]
112    pub fn workspace(&self) -> &super::super::super::super::api::rids::WorkspaceRid {
113        &self.workspace
114    }
115    /// Override labels. Defaults to the source workbook's labels.
116    #[inline]
117    pub fn labels(
118        &self,
119    ) -> Option<&std::collections::BTreeSet<super::super::super::super::api::Label>> {
120        self.labels.as_ref().map(|o| &*o)
121    }
122    /// Override properties. Defaults to the source workbook's properties.
123    #[inline]
124    pub fn properties(
125        &self,
126    ) -> Option<
127        &std::collections::BTreeMap<
128            super::super::super::super::api::PropertyName,
129            super::super::super::super::api::PropertyValue,
130        >,
131    > {
132        self.properties.as_ref().map(|o| &*o)
133    }
134    /// Override preview image. Defaults to the source workbook's preview image.
135    #[inline]
136    pub fn preview_image(
137        &self,
138    ) -> Option<&super::super::super::super::api::ThemeAwareImage> {
139        self.preview_image.as_ref().map(|o| &**o)
140    }
141}