#[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 Run {
    #[serde(rename = "rid")]
    rid: super::RunRid,
    #[serde(rename = "runNumber")]
    run_number: conjure_object::SafeLong,
    #[builder(default, into)]
    #[serde(rename = "runPrefix", skip_serializing_if = "Option::is_none", default)]
    run_prefix: Option<String>,
    #[builder(into)]
    #[serde(rename = "title")]
    title: String,
    #[builder(into)]
    #[serde(rename = "description")]
    description: String,
    #[builder(default, into)]
    #[serde(rename = "authorRid", skip_serializing_if = "Option::is_none", default)]
    author_rid: Option<super::super::super::rids::api::UserRid>,
    #[builder(custom(type = super::UtcTimestamp, convert = Box::new))]
    #[serde(rename = "startTime")]
    start_time: Box<super::UtcTimestamp>,
    #[builder(
        default,
        custom(
            type = impl
            Into<Option<super::UtcTimestamp>>,
            convert = |v|v.into().map(Box::new)
        )
    )]
    #[serde(rename = "endTime", skip_serializing_if = "Option::is_none", default)]
    end_time: Option<Box<super::UtcTimestamp>>,
    #[builder(default, map(key(type = String, into), value(type = String, into)))]
    #[serde(
        rename = "properties",
        skip_serializing_if = "std::collections::BTreeMap::is_empty",
        default
    )]
    properties: std::collections::BTreeMap<String, String>,
    #[builder(default, set(item(type = String, into)))]
    #[serde(
        rename = "labels",
        skip_serializing_if = "std::collections::BTreeSet::is_empty",
        default
    )]
    labels: std::collections::BTreeSet<String>,
    #[builder(default, list(item(type = super::Link)))]
    #[serde(rename = "links", skip_serializing_if = "Vec::is_empty", default)]
    links: Vec<super::Link>,
    #[serde(rename = "createdAt")]
    created_at: conjure_object::DateTime<conjure_object::Utc>,
    #[serde(rename = "updatedAt")]
    updated_at: conjure_object::DateTime<conjure_object::Utc>,
    #[builder(
        default,
        map(
            key(type = super::super::super::rids::api::AssetRid),
            value(type = super::DataScopes)
        )
    )]
    #[serde(
        rename = "assetDataScopesMap",
        skip_serializing_if = "std::collections::BTreeMap::is_empty",
        default
    )]
    asset_data_scopes_map: std::collections::BTreeMap<
        super::super::super::rids::api::AssetRid,
        super::DataScopes,
    >,
    #[builder(default, list(item(type = super::super::super::asset::api::DataScope)))]
    #[serde(rename = "assetDataScopes", skip_serializing_if = "Vec::is_empty", default)]
    asset_data_scopes: Vec<super::super::super::asset::api::DataScope>,
    #[builder(
        default,
        map(
            key(type = super::super::super::api::DataSourceRefName),
            value(type = super::RunDataSource)
        )
    )]
    #[serde(
        rename = "dataSources",
        skip_serializing_if = "std::collections::BTreeMap::is_empty",
        default
    )]
    data_sources: std::collections::BTreeMap<
        super::super::super::api::DataSourceRefName,
        super::RunDataSource,
    >,
    #[builder(default, set(item(type = conjure_object::ResourceIdentifier)))]
    #[serde(
        rename = "attachments",
        skip_serializing_if = "std::collections::BTreeSet::is_empty",
        default
    )]
    attachments: std::collections::BTreeSet<conjure_object::ResourceIdentifier>,
    #[builder(default, into)]
    #[serde(rename = "asset", skip_serializing_if = "Option::is_none", default)]
    asset: Option<super::super::super::rids::api::AssetRid>,
    #[builder(default, list(item(type = super::super::super::rids::api::AssetRid)))]
    #[serde(rename = "assets", skip_serializing_if = "Vec::is_empty", default)]
    assets: Vec<super::super::super::rids::api::AssetRid>,
    #[serde(rename = "isArchived")]
    is_archived: bool,
}
impl Run {
    #[inline]
    pub fn rid(&self) -> &super::RunRid {
        &self.rid
    }
    #[inline]
    pub fn run_number(&self) -> conjure_object::SafeLong {
        self.run_number
    }
    #[inline]
    pub fn run_prefix(&self) -> Option<&str> {
        self.run_prefix.as_ref().map(|o| &**o)
    }
    #[inline]
    pub fn title(&self) -> &str {
        &*self.title
    }
    #[inline]
    pub fn description(&self) -> &str {
        &*self.description
    }
    #[inline]
    pub fn author_rid(&self) -> Option<&super::super::super::rids::api::UserRid> {
        self.author_rid.as_ref().map(|o| &*o)
    }
    #[inline]
    pub fn start_time(&self) -> &super::UtcTimestamp {
        &*self.start_time
    }
    #[inline]
    pub fn end_time(&self) -> Option<&super::UtcTimestamp> {
        self.end_time.as_ref().map(|o| &**o)
    }
    #[inline]
    pub fn properties(&self) -> &std::collections::BTreeMap<String, String> {
        &self.properties
    }
    #[inline]
    pub fn labels(&self) -> &std::collections::BTreeSet<String> {
        &self.labels
    }
    #[inline]
    pub fn links(&self) -> &[super::Link] {
        &*self.links
    }
    #[inline]
    pub fn created_at(&self) -> conjure_object::DateTime<conjure_object::Utc> {
        self.created_at
    }
    #[inline]
    pub fn updated_at(&self) -> conjure_object::DateTime<conjure_object::Utc> {
        self.updated_at
    }
    /// Map from asset RIDs to their data scopes
    #[inline]
    pub fn asset_data_scopes_map(
        &self,
    ) -> &std::collections::BTreeMap<
        super::super::super::rids::api::AssetRid,
        super::DataScopes,
    > {
        &self.asset_data_scopes_map
    }
    #[deprecated(
        note = "Use assetDataScopesMap instead. Will be empty for multi-asset runs."
    )]
    #[inline]
    pub fn asset_data_scopes(&self) -> &[super::super::super::asset::api::DataScope] {
        &*self.asset_data_scopes
    }
    /// Map from refnames to run data sources. Will be empty for multi-asset runs.
    #[inline]
    pub fn data_sources(
        &self,
    ) -> &std::collections::BTreeMap<
        super::super::super::api::DataSourceRefName,
        super::RunDataSource,
    > {
        &self.data_sources
    }
    #[inline]
    pub fn attachments(
        &self,
    ) -> &std::collections::BTreeSet<conjure_object::ResourceIdentifier> {
        &self.attachments
    }
    #[deprecated(note = "Use assets")]
    #[inline]
    pub fn asset(&self) -> Option<&super::super::super::rids::api::AssetRid> {
        self.asset.as_ref().map(|o| &*o)
    }
    #[inline]
    pub fn assets(&self) -> &[super::super::super::rids::api::AssetRid] {
        &*self.assets
    }
    #[inline]
    pub fn is_archived(&self) -> bool {
        self.is_archived
    }
}
