/// For write requests, we want to allow for optional fields
#[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 CreateRunDataSource {
    #[builder(
        default,
        custom(
            type = impl
            Into<Option<super::DataSource>>,
            convert = |v|v.into().map(Box::new)
        )
    )]
    #[serde(rename = "dataSource", skip_serializing_if = "Option::is_none", default)]
    data_source: Option<Box<super::DataSource>>,
    #[builder(default, into)]
    #[serde(rename = "dataSourceRid", skip_serializing_if = "Option::is_none", default)]
    data_source_rid: Option<conjure_object::ResourceIdentifier>,
    #[builder(
        default,
        custom(
            type = impl
            Into<Option<super::Duration>>,
            convert = |v|v.into().map(Box::new)
        )
    )]
    #[serde(rename = "offset", skip_serializing_if = "Option::is_none", default)]
    offset: Option<Box<super::Duration>>,
    #[builder(default, map(key(type = String, into), value(type = String, into)))]
    #[serde(
        rename = "seriesTags",
        skip_serializing_if = "std::collections::BTreeMap::is_empty",
        default
    )]
    series_tags: std::collections::BTreeMap<String, String>,
}
impl CreateRunDataSource {
    /// Constructs a new instance of the type.
    #[inline]
    pub fn new() -> Self {
        Self::builder().build()
    }
    /// One of dataSource and dataSourceRid must be present.
    /// dataSourceRid takes precedence.
    #[deprecated(note = "Use dataSourceRid instead.")]
    #[inline]
    pub fn data_source(&self) -> Option<&super::DataSource> {
        self.data_source.as_ref().map(|o| &**o)
    }
    /// One of dataSource and dataSourceRid must be present.
    /// dataSourceRid takes precedence.
    #[inline]
    pub fn data_source_rid(&self) -> Option<&conjure_object::ResourceIdentifier> {
        self.data_source_rid.as_ref().map(|o| &*o)
    }
    #[inline]
    pub fn offset(&self) -> Option<&super::Duration> {
        self.offset.as_ref().map(|o| &**o)
    }
    /// Used to resolve logical series for this data source.
    #[inline]
    pub fn series_tags(&self) -> &std::collections::BTreeMap<String, String> {
        &self.series_tags
    }
}
