Skip to main content

nominal_api/conjure/objects/scout/asset/api/
asset.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 Asset {
16    #[serde(rename = "rid")]
17    rid: super::super::super::rids::api::AssetRid,
18    #[builder(into)]
19    #[serde(rename = "title")]
20    title: String,
21    #[builder(default, into)]
22    #[serde(rename = "description", skip_serializing_if = "Option::is_none", default)]
23    description: Option<String>,
24    #[builder(
25        default,
26        map(
27            key(type = super::super::super::super::api::PropertyName),
28            value(type = super::super::super::super::api::PropertyValue)
29        )
30    )]
31    #[serde(
32        rename = "properties",
33        skip_serializing_if = "std::collections::BTreeMap::is_empty",
34        default
35    )]
36    properties: std::collections::BTreeMap<
37        super::super::super::super::api::PropertyName,
38        super::super::super::super::api::PropertyValue,
39    >,
40    #[builder(default, set(item(type = super::super::super::super::api::Label)))]
41    #[serde(
42        rename = "labels",
43        skip_serializing_if = "std::collections::BTreeSet::is_empty",
44        default
45    )]
46    labels: std::collections::BTreeSet<super::super::super::super::api::Label>,
47    #[builder(default, list(item(type = super::super::super::run::api::Link)))]
48    #[serde(rename = "links", skip_serializing_if = "Vec::is_empty", default)]
49    links: Vec<super::super::super::run::api::Link>,
50    #[builder(default, list(item(type = super::DataScope)))]
51    #[serde(rename = "dataScopes", skip_serializing_if = "Vec::is_empty", default)]
52    data_scopes: Vec<super::DataScope>,
53    #[builder(default, into)]
54    #[serde(rename = "createdBy", skip_serializing_if = "Option::is_none", default)]
55    created_by: Option<conjure_object::ResourceIdentifier>,
56    #[serde(rename = "createdAt")]
57    created_at: conjure_object::DateTime<conjure_object::Utc>,
58    #[serde(rename = "updatedAt")]
59    updated_at: conjure_object::DateTime<conjure_object::Utc>,
60    #[builder(
61        default,
62        set(item(type = super::super::super::super::api::rids::AttachmentRid))
63    )]
64    #[serde(
65        rename = "attachments",
66        skip_serializing_if = "std::collections::BTreeSet::is_empty",
67        default
68    )]
69    attachments: std::collections::BTreeSet<
70        super::super::super::super::api::rids::AttachmentRid,
71    >,
72    #[builder(default, into)]
73    #[serde(rename = "type", skip_serializing_if = "Option::is_none", default)]
74    type_: Option<super::super::super::rids::api::TypeRid>,
75    #[serde(rename = "isStaged")]
76    is_staged: bool,
77    #[serde(rename = "isArchived")]
78    is_archived: bool,
79}
80impl Asset {
81    #[inline]
82    pub fn rid(&self) -> &super::super::super::rids::api::AssetRid {
83        &self.rid
84    }
85    #[inline]
86    pub fn title(&self) -> &str {
87        &*self.title
88    }
89    #[inline]
90    pub fn description(&self) -> Option<&str> {
91        self.description.as_ref().map(|o| &**o)
92    }
93    #[inline]
94    pub fn properties(
95        &self,
96    ) -> &std::collections::BTreeMap<
97        super::super::super::super::api::PropertyName,
98        super::super::super::super::api::PropertyValue,
99    > {
100        &self.properties
101    }
102    /// Labels associated with the asset. These labels do not have a time dimension.
103    /// To associate labels with a range of time, create a time range on the asset with labels.
104    #[inline]
105    pub fn labels(
106        &self,
107    ) -> &std::collections::BTreeSet<super::super::super::super::api::Label> {
108        &self.labels
109    }
110    /// Links associated with the asset. These links do not have a time dimension.
111    /// To associate links with a range of time, create a time range on the asset with links.
112    #[inline]
113    pub fn links(&self) -> &[super::super::super::run::api::Link] {
114        &*self.links
115    }
116    /// The data scopes associated with the asset.
117    #[inline]
118    pub fn data_scopes(&self) -> &[super::DataScope] {
119        &*self.data_scopes
120    }
121    #[inline]
122    pub fn created_by(&self) -> Option<&conjure_object::ResourceIdentifier> {
123        self.created_by.as_ref().map(|o| &*o)
124    }
125    #[inline]
126    pub fn created_at(&self) -> conjure_object::DateTime<conjure_object::Utc> {
127        self.created_at
128    }
129    #[inline]
130    pub fn updated_at(&self) -> conjure_object::DateTime<conjure_object::Utc> {
131        self.updated_at
132    }
133    #[inline]
134    pub fn attachments(
135        &self,
136    ) -> &std::collections::BTreeSet<
137        super::super::super::super::api::rids::AttachmentRid,
138    > {
139        &self.attachments
140    }
141    #[inline]
142    pub fn type_(&self) -> Option<&super::super::super::rids::api::TypeRid> {
143        self.type_.as_ref().map(|o| &*o)
144    }
145    /// Auto created assets are considered staged by default.
146    #[inline]
147    pub fn is_staged(&self) -> bool {
148        self.is_staged
149    }
150    #[inline]
151    pub fn is_archived(&self) -> bool {
152        self.is_archived
153    }
154}