Skip to main content

nominal_api/conjure/objects/scout/template/api/
save_template_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 SaveTemplateRequest {
13    #[builder(default, into)]
14    #[serde(rename = "charts", skip_serializing_if = "Option::is_none", default)]
15    charts: Option<Vec<super::super::super::rids::api::VersionedVizId>>,
16    #[builder(
17        custom(
18            type = super::super::super::layout::api::WorkbookLayout,
19            convert = Box::new
20        )
21    )]
22    #[serde(rename = "layout")]
23    layout: Box<super::super::super::layout::api::WorkbookLayout>,
24    #[builder(
25        custom(
26            type = super::super::super::workbookcommon::api::WorkbookContent,
27            convert = Box::new
28        )
29    )]
30    #[serde(rename = "content")]
31    content: Box<super::super::super::workbookcommon::api::WorkbookContent>,
32    #[builder(default, into)]
33    #[serde(rename = "latestCommit", skip_serializing_if = "Option::is_none", default)]
34    latest_commit: Option<super::super::super::versioning::api::CommitId>,
35}
36impl SaveTemplateRequest {
37    /// Constructs a new instance of the type.
38    #[inline]
39    pub fn new(
40        layout: super::super::super::layout::api::WorkbookLayout,
41        content: super::super::super::workbookcommon::api::WorkbookContent,
42    ) -> Self {
43        Self::builder().layout(layout).content(content).build()
44    }
45    #[deprecated(
46        note = "charts are no longer versioned resources. They are stored in workbook content."
47    )]
48    #[inline]
49    pub fn charts(&self) -> Option<&[super::super::super::rids::api::VersionedVizId]> {
50        self.charts.as_ref().map(|o| &**o)
51    }
52    #[inline]
53    pub fn layout(&self) -> &super::super::super::layout::api::WorkbookLayout {
54        &*self.layout
55    }
56    #[inline]
57    pub fn content(&self) -> &super::super::super::workbookcommon::api::WorkbookContent {
58        &*self.content
59    }
60    /// If present, will validate that the latest commit matches this id,
61    /// and otherwise throw CommitConflict.
62    #[inline]
63    pub fn latest_commit(
64        &self,
65    ) -> Option<&super::super::super::versioning::api::CommitId> {
66        self.latest_commit.as_ref().map(|o| &*o)
67    }
68}