/// Time range configuration for workbooks
#[derive(
    Debug,
    Clone,
    conjure_object::serde::Serialize,
    conjure_object::serde::Deserialize,
    PartialEq,
    Eq,
    PartialOrd,
    Ord,
    Hash
)]
#[serde(crate = "conjure_object::serde")]
#[conjure_object::private::staged_builder::staged_builder]
#[builder(crate = conjure_object::private::staged_builder, update, inline)]
pub struct WorkbookTimeSettingsV1 {
    #[serde(rename = "timeRangeType")]
    time_range_type: super::WorkbookTimeRangeType,
    #[builder(
        default,
        custom(
            type = impl
            Into<Option<super::TimeRange>>,
            convert = |v|v.into().map(Box::new)
        )
    )]
    #[serde(
        rename = "globalTimeRange",
        skip_serializing_if = "Option::is_none",
        default
    )]
    global_time_range: Option<Box<super::TimeRange>>,
    #[serde(rename = "isGlobalTime")]
    is_global_time: bool,
    #[builder(default, map(key(type = String, into), value(type = super::TimeRange)))]
    #[serde(
        rename = "tabTimeRanges",
        skip_serializing_if = "std::collections::BTreeMap::is_empty",
        default
    )]
    tab_time_ranges: std::collections::BTreeMap<String, super::TimeRange>,
}
impl WorkbookTimeSettingsV1 {
    /// Constructs a new instance of the type.
    #[inline]
    pub fn new(
        time_range_type: super::WorkbookTimeRangeType,
        is_global_time: bool,
    ) -> Self {
        Self::builder()
            .time_range_type(time_range_type)
            .is_global_time(is_global_time)
            .build()
    }
    /// The time range type of the workbook
    #[inline]
    pub fn time_range_type(&self) -> &super::WorkbookTimeRangeType {
        &self.time_range_type
    }
    /// The global time range a workbook falls back to.
    #[inline]
    pub fn global_time_range(&self) -> Option<&super::TimeRange> {
        self.global_time_range.as_ref().map(|o| &**o)
    }
    /// If true, workbook will default to globalTimeRange for all tabs.
    /// If false, will attempt to use tabTime to populate the workbook time range.
    #[inline]
    pub fn is_global_time(&self) -> bool {
        self.is_global_time
    }
    #[inline]
    pub fn tab_time_ranges(
        &self,
    ) -> &std::collections::BTreeMap<String, super::TimeRange> {
        &self.tab_time_ranges
    }
}
