#[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 CreateRunRequest {
    #[builder(into)]
    #[serde(rename = "title")]
    title: String,
    #[builder(into)]
    #[serde(rename = "description")]
    description: String,
    #[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>,
    #[builder(default, into)]
    #[serde(rename = "runPrefix", skip_serializing_if = "Option::is_none", default)]
    run_prefix: Option<String>,
    #[builder(
        default,
        map(
            key(type = super::super::super::api::DataSourceRefName),
            value(type = super::CreateRunDataSource)
        )
    )]
    #[serde(
        rename = "dataSources",
        skip_serializing_if = "std::collections::BTreeMap::is_empty",
        default
    )]
    data_sources: std::collections::BTreeMap<
        super::super::super::api::DataSourceRefName,
        super::CreateRunDataSource,
    >,
    #[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>,
    #[builder(default, into)]
    #[serde(rename = "workspace", skip_serializing_if = "Option::is_none", default)]
    workspace: Option<conjure_object::ResourceIdentifier>,
}
impl CreateRunRequest {
    /// Constructs a new instance of the type.
    #[inline]
    pub fn new(
        title: impl Into<String>,
        description: impl Into<String>,
        start_time: super::UtcTimestamp,
    ) -> Self {
        Self::builder()
            .title(title)
            .description(description)
            .start_time(start_time)
            .build()
    }
    #[inline]
    pub fn title(&self) -> &str {
        &*self.title
    }
    #[inline]
    pub fn description(&self) -> &str {
        &*self.description
    }
    #[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 run_prefix(&self) -> Option<&str> {
        self.run_prefix.as_ref().map(|o| &**o)
    }
    #[inline]
    pub fn data_sources(
        &self,
    ) -> &std::collections::BTreeMap<
        super::super::super::api::DataSourceRefName,
        super::CreateRunDataSource,
    > {
        &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
    }
    /// The workspace in which to create the run. If not provided, the run will be created in
    /// the default workspace for the user's organization, if the default workspace for the
    /// organization is configured.
    /// All data sources, attachments, and assets must be in the same workspace.
    #[inline]
    pub fn workspace(&self) -> Option<&conjure_object::ResourceIdentifier> {
        self.workspace.as_ref().map(|o| &*o)
    }
}
