Skip to main content

nominal_api/conjure/objects/scout/run/api/
create_run_request.rs

1#[derive(
2    Debug,
3    Clone,
4    conjure_object::serde::Serialize,
5    conjure_object::serde::Deserialize,
6    PartialEq,
7    Eq,
8    PartialOrd,
9    Ord,
10    Hash
11)]
12#[serde(crate = "conjure_object::serde")]
13#[conjure_object::private::staged_builder::staged_builder]
14#[builder(crate = conjure_object::private::staged_builder, update, inline)]
15pub struct CreateRunRequest {
16    #[builder(into)]
17    #[serde(rename = "title")]
18    title: String,
19    #[builder(into)]
20    #[serde(rename = "description")]
21    description: String,
22    #[builder(custom(type = super::UtcTimestamp, convert = Box::new))]
23    #[serde(rename = "startTime")]
24    start_time: Box<super::UtcTimestamp>,
25    #[builder(
26        default,
27        custom(
28            type = impl
29            Into<Option<super::UtcTimestamp>>,
30            convert = |v|v.into().map(Box::new)
31        )
32    )]
33    #[serde(rename = "endTime", skip_serializing_if = "Option::is_none", default)]
34    end_time: Option<Box<super::UtcTimestamp>>,
35    #[builder(default, map(key(type = String, into), value(type = String, into)))]
36    #[serde(
37        rename = "properties",
38        skip_serializing_if = "std::collections::BTreeMap::is_empty",
39        default
40    )]
41    properties: std::collections::BTreeMap<String, String>,
42    #[builder(default, set(item(type = String, into)))]
43    #[serde(
44        rename = "labels",
45        skip_serializing_if = "std::collections::BTreeSet::is_empty",
46        default
47    )]
48    labels: std::collections::BTreeSet<String>,
49    #[builder(default, list(item(type = super::Link)))]
50    #[serde(rename = "links", skip_serializing_if = "Vec::is_empty", default)]
51    links: Vec<super::Link>,
52    #[builder(default, into)]
53    #[serde(rename = "runPrefix", skip_serializing_if = "Option::is_none", default)]
54    run_prefix: Option<String>,
55    #[builder(
56        default,
57        map(
58            key(type = super::super::super::api::DataSourceRefName),
59            value(type = super::CreateRunDataSource)
60        )
61    )]
62    #[serde(
63        rename = "dataSources",
64        skip_serializing_if = "std::collections::BTreeMap::is_empty",
65        default
66    )]
67    data_sources: std::collections::BTreeMap<
68        super::super::super::api::DataSourceRefName,
69        super::CreateRunDataSource,
70    >,
71    #[builder(default, set(item(type = conjure_object::ResourceIdentifier)))]
72    #[serde(
73        rename = "attachments",
74        skip_serializing_if = "std::collections::BTreeSet::is_empty",
75        default
76    )]
77    attachments: std::collections::BTreeSet<conjure_object::ResourceIdentifier>,
78    #[builder(default, into)]
79    #[serde(rename = "asset", skip_serializing_if = "Option::is_none", default)]
80    asset: Option<super::super::super::rids::api::AssetRid>,
81    #[builder(default, list(item(type = super::super::super::rids::api::AssetRid)))]
82    #[serde(rename = "assets", skip_serializing_if = "Vec::is_empty", default)]
83    assets: Vec<super::super::super::rids::api::AssetRid>,
84    #[builder(default, into)]
85    #[serde(rename = "workspace", skip_serializing_if = "Option::is_none", default)]
86    workspace: Option<conjure_object::ResourceIdentifier>,
87}
88impl CreateRunRequest {
89    /// Constructs a new instance of the type.
90    #[inline]
91    pub fn new(
92        title: impl Into<String>,
93        description: impl Into<String>,
94        start_time: super::UtcTimestamp,
95    ) -> Self {
96        Self::builder()
97            .title(title)
98            .description(description)
99            .start_time(start_time)
100            .build()
101    }
102    #[inline]
103    pub fn title(&self) -> &str {
104        &*self.title
105    }
106    #[inline]
107    pub fn description(&self) -> &str {
108        &*self.description
109    }
110    #[inline]
111    pub fn start_time(&self) -> &super::UtcTimestamp {
112        &*self.start_time
113    }
114    #[inline]
115    pub fn end_time(&self) -> Option<&super::UtcTimestamp> {
116        self.end_time.as_ref().map(|o| &**o)
117    }
118    #[inline]
119    pub fn properties(&self) -> &std::collections::BTreeMap<String, String> {
120        &self.properties
121    }
122    #[inline]
123    pub fn labels(&self) -> &std::collections::BTreeSet<String> {
124        &self.labels
125    }
126    #[inline]
127    pub fn links(&self) -> &[super::Link] {
128        &*self.links
129    }
130    #[inline]
131    pub fn run_prefix(&self) -> Option<&str> {
132        self.run_prefix.as_ref().map(|o| &**o)
133    }
134    #[inline]
135    pub fn data_sources(
136        &self,
137    ) -> &std::collections::BTreeMap<
138        super::super::super::api::DataSourceRefName,
139        super::CreateRunDataSource,
140    > {
141        &self.data_sources
142    }
143    #[inline]
144    pub fn attachments(
145        &self,
146    ) -> &std::collections::BTreeSet<conjure_object::ResourceIdentifier> {
147        &self.attachments
148    }
149    #[deprecated(note = "Use assets")]
150    #[inline]
151    pub fn asset(&self) -> Option<&super::super::super::rids::api::AssetRid> {
152        self.asset.as_ref().map(|o| &*o)
153    }
154    #[inline]
155    pub fn assets(&self) -> &[super::super::super::rids::api::AssetRid] {
156        &*self.assets
157    }
158    /// The workspace in which to create the run. If not provided, the run will be created in
159    /// the default workspace for the user's organization, if the default workspace for the
160    /// organization is configured.
161    /// All data sources, attachments, and assets must be in the same workspace.
162    #[inline]
163    pub fn workspace(&self) -> Option<&conjure_object::ResourceIdentifier> {
164        self.workspace.as_ref().map(|o| &*o)
165    }
166}