#[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 UpdateNotebookRequest {
    #[builder(into)]
    #[serde(rename = "stateAsJson")]
    state_as_json: String,
    #[builder(default, into)]
    #[serde(rename = "charts", skip_serializing_if = "Option::is_none", default)]
    charts: Option<Vec<super::ChartWithOverlays>>,
    #[builder(
        custom(
            type = super::super::super::layout::api::WorkbookLayout,
            convert = Box::new
        )
    )]
    #[serde(rename = "layout")]
    layout: Box<super::super::super::layout::api::WorkbookLayout>,
    #[builder(
        default,
        custom(
            type = impl
            Into<Option<super::super::super::workbookcommon::api::WorkbookContent>>,
            convert = |v|v.into().map(Box::new)
        )
    )]
    #[serde(rename = "content", skip_serializing_if = "Option::is_none", default)]
    content: Option<Box<super::super::super::workbookcommon::api::WorkbookContent>>,
    #[builder(
        default,
        custom(
            type = impl
            Into<Option<super::super::super::workbookcommon::api::UnifiedWorkbookContent>>,
            convert = |v|v.into().map(Box::new)
        )
    )]
    #[serde(rename = "contentV2", skip_serializing_if = "Option::is_none", default)]
    content_v2: Option<
        Box<super::super::super::workbookcommon::api::UnifiedWorkbookContent>,
    >,
    #[builder(default, into)]
    #[serde(
        rename = "latestSnapshotRid",
        skip_serializing_if = "Option::is_none",
        default
    )]
    latest_snapshot_rid: Option<super::super::super::rids::api::SnapshotRid>,
    #[builder(
        default,
        set(item(type = super::super::super::workbookcommon::api::EventReference))
    )]
    #[serde(
        rename = "eventRefs",
        skip_serializing_if = "std::collections::BTreeSet::is_empty",
        default
    )]
    event_refs: std::collections::BTreeSet<
        super::super::super::workbookcommon::api::EventReference,
    >,
    #[builder(default, into)]
    #[serde(rename = "checkAlertRefs", skip_serializing_if = "Option::is_none", default)]
    check_alert_refs: Option<
        std::collections::BTreeSet<
            super::super::super::workbookcommon::api::CheckAlertReference,
        >,
    >,
}
impl UpdateNotebookRequest {
    /// Constructs a new instance of the type.
    #[inline]
    pub fn new(
        state_as_json: impl Into<String>,
        layout: super::super::super::layout::api::WorkbookLayout,
    ) -> Self {
        Self::builder().state_as_json(state_as_json).layout(layout).build()
    }
    #[inline]
    pub fn state_as_json(&self) -> &str {
        &*self.state_as_json
    }
    #[deprecated(note = "charts are now stored in contentV2")]
    #[inline]
    pub fn charts(&self) -> Option<&[super::ChartWithOverlays]> {
        self.charts.as_ref().map(|o| &**o)
    }
    #[inline]
    pub fn layout(&self) -> &super::super::super::layout::api::WorkbookLayout {
        &*self.layout
    }
    #[deprecated(note = "use contentV2 instead")]
    #[inline]
    pub fn content(
        &self,
    ) -> Option<&super::super::super::workbookcommon::api::WorkbookContent> {
        self.content.as_ref().map(|o| &**o)
    }
    /// Optional for backcompatibility
    #[inline]
    pub fn content_v2(
        &self,
    ) -> Option<&super::super::super::workbookcommon::api::UnifiedWorkbookContent> {
        self.content_v2.as_ref().map(|o| &**o)
    }
    /// If provided, will only update the notebook if the latest snapshot matches the provided snapshot rid,
    /// and throws SaveNotebookConflict otherwise.
    #[inline]
    pub fn latest_snapshot_rid(
        &self,
    ) -> Option<&super::super::super::rids::api::SnapshotRid> {
        self.latest_snapshot_rid.as_ref().map(|o| &*o)
    }
    /// Replace existing pinned events on the workbook.
    #[inline]
    pub fn event_refs(
        &self,
    ) -> &std::collections::BTreeSet<
        super::super::super::workbookcommon::api::EventReference,
    > {
        &self.event_refs
    }
    /// Field to pin check alerts to a workbook on creation.
    /// If not provided, will keep the set of check alerts on the workbook unchanged.
    /// Providing an empty set will remove all check alerts from the workbook.
    /// Any specified CheckAlertReference will be added to the workbook along with it's corresponding EventReference.
    #[deprecated(
        note = "CheckAlerts are no longer supported and will be removed in the future.\nUse eventRefs to pin events to workbooks instead.\n"
    )]
    #[inline]
    pub fn check_alert_refs(
        &self,
    ) -> Option<
        &std::collections::BTreeSet<
            super::super::super::workbookcommon::api::CheckAlertReference,
        >,
    > {
        self.check_alert_refs.as_ref().map(|o| &*o)
    }
}
