Skip to main content

nominal_api_conjure/conjure/objects/scout/asset/api/
asset.rs

1#[derive(
2    Debug,
3    Clone,
4    conjure_object::serde::Serialize,
5    conjure_object::serde::Deserialize,
6    conjure_object::private::DeriveWith
7)]
8#[serde(crate = "conjure_object::serde")]
9#[derive_with(PartialEq, Eq, PartialOrd, Ord, Hash)]
10#[conjure_object::private::staged_builder::staged_builder]
11#[builder(crate = conjure_object::private::staged_builder, update, inline)]
12pub struct Asset {
13    #[serde(rename = "rid")]
14    rid: super::super::super::rids::api::AssetRid,
15    #[builder(into)]
16    #[serde(rename = "title")]
17    title: String,
18    #[builder(default, into)]
19    #[serde(rename = "description", skip_serializing_if = "Option::is_none", default)]
20    description: Option<String>,
21    #[builder(
22        default,
23        map(
24            key(type = super::super::super::super::api::PropertyName),
25            value(type = super::super::super::super::api::PropertyValue)
26        )
27    )]
28    #[serde(
29        rename = "properties",
30        skip_serializing_if = "std::collections::BTreeMap::is_empty",
31        default
32    )]
33    properties: std::collections::BTreeMap<
34        super::super::super::super::api::PropertyName,
35        super::super::super::super::api::PropertyValue,
36    >,
37    #[builder(
38        default,
39        map(
40            key(type = super::super::super::super::api::PropertyName),
41            value(type = super::super::super::super::api::TypedPropertyValue)
42        )
43    )]
44    #[serde(
45        rename = "typedProperties",
46        skip_serializing_if = "std::collections::BTreeMap::is_empty",
47        default
48    )]
49    typed_properties: std::collections::BTreeMap<
50        super::super::super::super::api::PropertyName,
51        super::super::super::super::api::TypedPropertyValue,
52    >,
53    #[builder(default, set(item(type = super::super::super::super::api::Label)))]
54    #[serde(
55        rename = "labels",
56        skip_serializing_if = "std::collections::BTreeSet::is_empty",
57        default
58    )]
59    labels: std::collections::BTreeSet<super::super::super::super::api::Label>,
60    #[builder(default, list(item(type = super::super::super::run::api::Link)))]
61    #[serde(rename = "links", skip_serializing_if = "Vec::is_empty", default)]
62    links: Vec<super::super::super::run::api::Link>,
63    #[builder(default, list(item(type = super::DataScope)))]
64    #[serde(rename = "dataScopes", skip_serializing_if = "Vec::is_empty", default)]
65    data_scopes: Vec<super::DataScope>,
66    #[builder(default, into)]
67    #[serde(rename = "createdBy", skip_serializing_if = "Option::is_none", default)]
68    created_by: Option<conjure_object::ResourceIdentifier>,
69    #[serde(rename = "createdAt")]
70    created_at: conjure_object::DateTime<conjure_object::Utc>,
71    #[serde(rename = "updatedAt")]
72    updated_at: conjure_object::DateTime<conjure_object::Utc>,
73    #[builder(
74        default,
75        set(item(type = super::super::super::super::api::rids::AttachmentRid))
76    )]
77    #[serde(
78        rename = "attachments",
79        skip_serializing_if = "std::collections::BTreeSet::is_empty",
80        default
81    )]
82    attachments: std::collections::BTreeSet<
83        super::super::super::super::api::rids::AttachmentRid,
84    >,
85    #[builder(default, into)]
86    #[serde(rename = "type", skip_serializing_if = "Option::is_none", default)]
87    type_: Option<super::super::super::rids::api::TypeRid>,
88    #[serde(rename = "isStaged")]
89    is_staged: bool,
90    #[serde(rename = "isArchived")]
91    is_archived: bool,
92}
93impl Asset {
94    #[inline]
95    pub fn rid(&self) -> &super::super::super::rids::api::AssetRid {
96        &self.rid
97    }
98    #[inline]
99    pub fn title(&self) -> &str {
100        &*self.title
101    }
102    #[inline]
103    pub fn description(&self) -> Option<&str> {
104        self.description.as_ref().map(|o| &**o)
105    }
106    #[deprecated(note = "use typedProperties")]
107    #[inline]
108    pub fn properties(
109        &self,
110    ) -> &std::collections::BTreeMap<
111        super::super::super::super::api::PropertyName,
112        super::super::super::super::api::PropertyValue,
113    > {
114        &self.properties
115    }
116    #[inline]
117    pub fn typed_properties(
118        &self,
119    ) -> &std::collections::BTreeMap<
120        super::super::super::super::api::PropertyName,
121        super::super::super::super::api::TypedPropertyValue,
122    > {
123        &self.typed_properties
124    }
125    /// Labels associated with the asset. These labels do not have a time dimension.
126    /// To associate labels with a range of time, create a time range on the asset with labels.
127    #[inline]
128    pub fn labels(
129        &self,
130    ) -> &std::collections::BTreeSet<super::super::super::super::api::Label> {
131        &self.labels
132    }
133    /// Links associated with the asset. These links do not have a time dimension.
134    /// To associate links with a range of time, create a time range on the asset with links.
135    #[inline]
136    pub fn links(&self) -> &[super::super::super::run::api::Link] {
137        &*self.links
138    }
139    /// The data scopes associated with the asset.
140    #[inline]
141    pub fn data_scopes(&self) -> &[super::DataScope] {
142        &*self.data_scopes
143    }
144    #[inline]
145    pub fn created_by(&self) -> Option<&conjure_object::ResourceIdentifier> {
146        self.created_by.as_ref().map(|o| &*o)
147    }
148    #[inline]
149    pub fn created_at(&self) -> conjure_object::DateTime<conjure_object::Utc> {
150        self.created_at
151    }
152    #[inline]
153    pub fn updated_at(&self) -> conjure_object::DateTime<conjure_object::Utc> {
154        self.updated_at
155    }
156    #[inline]
157    pub fn attachments(
158        &self,
159    ) -> &std::collections::BTreeSet<
160        super::super::super::super::api::rids::AttachmentRid,
161    > {
162        &self.attachments
163    }
164    #[inline]
165    pub fn type_(&self) -> Option<&super::super::super::rids::api::TypeRid> {
166        self.type_.as_ref().map(|o| &*o)
167    }
168    /// Auto created assets are considered staged by default.
169    #[inline]
170    pub fn is_staged(&self) -> bool {
171        self.is_staged
172    }
173    #[inline]
174    pub fn is_archived(&self) -> bool {
175        self.is_archived
176    }
177}