Skip to main content

nominal_api/conjure/objects/scout/template/api/
commit_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 CommitTemplateRequest {
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(into)]
33    #[serde(rename = "message")]
34    message: String,
35    #[builder(default, into)]
36    #[serde(rename = "latestCommit", skip_serializing_if = "Option::is_none", default)]
37    latest_commit: Option<super::super::super::versioning::api::CommitId>,
38}
39impl CommitTemplateRequest {
40    /// Constructs a new instance of the type.
41    #[inline]
42    pub fn new(
43        layout: super::super::super::layout::api::WorkbookLayout,
44        content: super::super::super::workbookcommon::api::WorkbookContent,
45        message: impl Into<String>,
46    ) -> Self {
47        Self::builder().layout(layout).content(content).message(message).build()
48    }
49    #[deprecated(
50        note = "charts are no longer versioned resources. They are stored in workbook content."
51    )]
52    #[inline]
53    pub fn charts(&self) -> Option<&[super::super::super::rids::api::VersionedVizId]> {
54        self.charts.as_ref().map(|o| &**o)
55    }
56    #[inline]
57    pub fn layout(&self) -> &super::super::super::layout::api::WorkbookLayout {
58        &*self.layout
59    }
60    #[inline]
61    pub fn content(&self) -> &super::super::super::workbookcommon::api::WorkbookContent {
62        &*self.content
63    }
64    #[inline]
65    pub fn message(&self) -> &str {
66        &*self.message
67    }
68    /// If present, will validate that the latest commit matches this id,
69    /// and otherwise throw CommitConflict.
70    #[inline]
71    pub fn latest_commit(
72        &self,
73    ) -> Option<&super::super::super::versioning::api::CommitId> {
74        self.latest_commit.as_ref().map(|o| &*o)
75    }
76}