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(default, set(item(type = conjure_object::ResourceIdentifier)))]
61    #[serde(
62        rename = "attachments",
63        skip_serializing_if = "std::collections::BTreeSet::is_empty",
64        default
65    )]
66    attachments: std::collections::BTreeSet<conjure_object::ResourceIdentifier>,
67    #[builder(default, into)]
68    #[serde(rename = "type", skip_serializing_if = "Option::is_none", default)]
69    type_: Option<super::super::super::rids::api::TypeRid>,
70    #[serde(rename = "isStaged")]
71    is_staged: bool,
72    #[serde(rename = "isArchived")]
73    is_archived: bool,
74}
75impl Asset {
76    #[inline]
77    pub fn rid(&self) -> &super::super::super::rids::api::AssetRid {
78        &self.rid
79    }
80    #[inline]
81    pub fn title(&self) -> &str {
82        &*self.title
83    }
84    #[inline]
85    pub fn description(&self) -> Option<&str> {
86        self.description.as_ref().map(|o| &**o)
87    }
88    #[inline]
89    pub fn properties(
90        &self,
91    ) -> &std::collections::BTreeMap<
92        super::super::super::super::api::PropertyName,
93        super::super::super::super::api::PropertyValue,
94    > {
95        &self.properties
96    }
97    /// Labels associated with the asset. These labels do not have a time dimension.
98    /// To associate labels with a range of time, create a time range on the asset with labels.
99    #[inline]
100    pub fn labels(
101        &self,
102    ) -> &std::collections::BTreeSet<super::super::super::super::api::Label> {
103        &self.labels
104    }
105    /// Links associated with the asset. These links do not have a time dimension.
106    /// To associate links with a range of time, create a time range on the asset with links.
107    #[inline]
108    pub fn links(&self) -> &[super::super::super::run::api::Link] {
109        &*self.links
110    }
111    /// The data scopes associated with the asset.
112    #[inline]
113    pub fn data_scopes(&self) -> &[super::DataScope] {
114        &*self.data_scopes
115    }
116    #[inline]
117    pub fn created_by(&self) -> Option<&conjure_object::ResourceIdentifier> {
118        self.created_by.as_ref().map(|o| &*o)
119    }
120    #[inline]
121    pub fn created_at(&self) -> conjure_object::DateTime<conjure_object::Utc> {
122        self.created_at
123    }
124    #[inline]
125    pub fn updated_at(&self) -> conjure_object::DateTime<conjure_object::Utc> {
126        self.updated_at
127    }
128    #[inline]
129    pub fn attachments(
130        &self,
131    ) -> &std::collections::BTreeSet<conjure_object::ResourceIdentifier> {
132        &self.attachments
133    }
134    #[inline]
135    pub fn type_(&self) -> Option<&super::super::super::rids::api::TypeRid> {
136        self.type_.as_ref().map(|o| &*o)
137    }
138    /// Auto created assets are considered staged by default.
139    #[inline]
140    pub fn is_staged(&self) -> bool {
141        self.is_staged
142    }
143    #[inline]
144    pub fn is_archived(&self) -> bool {
145        self.is_archived
146    }
147}