#[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 WorkbookSettings {
    #[builder(default, into)]
    #[serde(rename = "assetSettings", skip_serializing_if = "Option::is_none", default)]
    asset_settings: Option<
        std::collections::BTreeMap<
            super::super::super::rids::api::AssetRid,
            super::AssetSettings,
        >,
    >,
    #[builder(default, into)]
    #[serde(rename = "runSettings", skip_serializing_if = "Option::is_none", default)]
    run_settings: Option<
        std::collections::BTreeMap<
            super::super::super::run::api::RunRid,
            super::RunSettings,
        >,
    >,
    #[builder(
        default,
        custom(
            type = impl
            Into<Option<super::WorkbookTimeSettings>>,
            convert = |v|v.into().map(Box::new)
        )
    )]
    #[serde(rename = "timeSettings", skip_serializing_if = "Option::is_none", default)]
    time_settings: Option<Box<super::WorkbookTimeSettings>>,
    #[builder(
        default,
        custom(
            type = impl
            Into<Option<super::WorkbookOffsets>>,
            convert = |v|v.into().map(Box::new)
        )
    )]
    #[serde(rename = "offsets", skip_serializing_if = "Option::is_none", default)]
    offsets: Option<Box<super::WorkbookOffsets>>,
    #[builder(
        default,
        custom(
            type = impl
            Into<Option<super::super::super::chartdefinition::api::StalenessConfiguration>>,
            convert = |v|v.into().map(Box::new)
        )
    )]
    #[serde(
        rename = "defaultStalenessConfiguration",
        skip_serializing_if = "Option::is_none",
        default
    )]
    default_staleness_configuration: Option<
        Box<super::super::super::chartdefinition::api::StalenessConfiguration>,
    >,
}
impl WorkbookSettings {
    /// Constructs a new instance of the type.
    #[inline]
    pub fn new() -> Self {
        Self::builder().build()
    }
    /// Settings for assets to be used in the workbook. This should be present for asset workbooks.
    #[inline]
    pub fn asset_settings(
        &self,
    ) -> Option<
        &std::collections::BTreeMap<
            super::super::super::rids::api::AssetRid,
            super::AssetSettings,
        >,
    > {
        self.asset_settings.as_ref().map(|o| &*o)
    }
    /// Settings for runs to be used in the workbook. This should be present for run workbooks.
    #[inline]
    pub fn run_settings(
        &self,
    ) -> Option<
        &std::collections::BTreeMap<
            super::super::super::run::api::RunRid,
            super::RunSettings,
        >,
    > {
        self.run_settings.as_ref().map(|o| &*o)
    }
    /// Time range settings when users access a workbook. Time range URL query params will take precedence
    /// over persisted the global time range.
    #[inline]
    pub fn time_settings(&self) -> Option<&super::WorkbookTimeSettings> {
        self.time_settings.as_ref().map(|o| &**o)
    }
    /// Time offsets that can be applied to the workbook.
    #[inline]
    pub fn offsets(&self) -> Option<&super::WorkbookOffsets> {
        self.offsets.as_ref().map(|o| &**o)
    }
    /// Default staleness configuration for new time series panels in the workbook.
    /// When set, new time series panels will use this instead of the 1-second default.
    #[inline]
    pub fn default_staleness_configuration(
        &self,
    ) -> Option<&super::super::super::chartdefinition::api::StalenessConfiguration> {
        self.default_staleness_configuration.as_ref().map(|o| &**o)
    }
}
