#[derive(
    Debug,
    Clone,
    conjure_object::serde::Serialize,
    conjure_object::serde::Deserialize,
    conjure_object::private::DeriveWith
)]
#[serde(crate = "conjure_object::serde")]
#[derive_with(PartialEq, Eq, PartialOrd, Ord, Hash)]
#[conjure_object::private::staged_builder::staged_builder]
#[builder(crate = conjure_object::private::staged_builder, update, inline)]
pub struct CommitTemplateRequest {
    #[builder(default, into)]
    #[serde(rename = "charts", skip_serializing_if = "Option::is_none", default)]
    charts: Option<Vec<super::super::super::rids::api::VersionedVizId>>,
    #[builder(
        custom(
            type = super::super::super::layout::api::WorkbookLayout,
            convert = Box::new
        )
    )]
    #[serde(rename = "layout")]
    layout: Box<super::super::super::layout::api::WorkbookLayout>,
    #[builder(
        custom(
            type = super::super::super::workbookcommon::api::WorkbookContent,
            convert = Box::new
        )
    )]
    #[serde(rename = "content")]
    content: Box<super::super::super::workbookcommon::api::WorkbookContent>,
    #[builder(into)]
    #[serde(rename = "message")]
    message: String,
    #[builder(default, into)]
    #[serde(rename = "latestCommit", skip_serializing_if = "Option::is_none", default)]
    latest_commit: Option<super::super::super::versioning::api::CommitId>,
}
impl CommitTemplateRequest {
    /// Constructs a new instance of the type.
    #[inline]
    pub fn new(
        layout: super::super::super::layout::api::WorkbookLayout,
        content: super::super::super::workbookcommon::api::WorkbookContent,
        message: impl Into<String>,
    ) -> Self {
        Self::builder().layout(layout).content(content).message(message).build()
    }
    #[deprecated(
        note = "charts are no longer versioned resources. They are stored in workbook content."
    )]
    #[inline]
    pub fn charts(&self) -> Option<&[super::super::super::rids::api::VersionedVizId]> {
        self.charts.as_ref().map(|o| &**o)
    }
    #[inline]
    pub fn layout(&self) -> &super::super::super::layout::api::WorkbookLayout {
        &*self.layout
    }
    #[inline]
    pub fn content(&self) -> &super::super::super::workbookcommon::api::WorkbookContent {
        &*self.content
    }
    #[inline]
    pub fn message(&self) -> &str {
        &*self.message
    }
    /// If present, will validate that the latest commit matches this id,
    /// and otherwise throw CommitConflict.
    #[inline]
    pub fn latest_commit(
        &self,
    ) -> Option<&super::super::super::versioning::api::CommitId> {
        self.latest_commit.as_ref().map(|o| &*o)
    }
}
