Skip to main content

nominal_api/conjure/objects/event/
create_event.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 CreateEvent {
16    #[builder(default, set(item(type = super::super::scout::rids::api::AssetRid)))]
17    #[serde(
18        rename = "assetRids",
19        skip_serializing_if = "std::collections::BTreeSet::is_empty",
20        default
21    )]
22    asset_rids: std::collections::BTreeSet<super::super::scout::rids::api::AssetRid>,
23    #[builder(default, set(item(type = super::EventOrigin)))]
24    #[serde(
25        rename = "origins",
26        skip_serializing_if = "std::collections::BTreeSet::is_empty",
27        default
28    )]
29    origins: std::collections::BTreeSet<super::EventOrigin>,
30    #[builder(custom(type = super::super::api::Timestamp, convert = Box::new))]
31    #[serde(rename = "timestamp")]
32    timestamp: Box<super::super::api::Timestamp>,
33    #[builder(
34        custom(type = super::super::scout::run::api::Duration, convert = Box::new)
35    )]
36    #[serde(rename = "duration")]
37    duration: Box<super::super::scout::run::api::Duration>,
38    #[builder(into)]
39    #[serde(rename = "name")]
40    name: String,
41    #[builder(default, into)]
42    #[serde(rename = "description", skip_serializing_if = "Option::is_none", default)]
43    description: Option<String>,
44    #[serde(rename = "type")]
45    type_: super::EventType,
46    #[builder(default, set(item(type = super::super::api::Label)))]
47    #[serde(
48        rename = "labels",
49        skip_serializing_if = "std::collections::BTreeSet::is_empty",
50        default
51    )]
52    labels: std::collections::BTreeSet<super::super::api::Label>,
53    #[builder(
54        default,
55        map(
56            key(type = super::super::api::PropertyName),
57            value(type = super::super::api::PropertyValue)
58        )
59    )]
60    #[serde(
61        rename = "properties",
62        skip_serializing_if = "std::collections::BTreeMap::is_empty",
63        default
64    )]
65    properties: std::collections::BTreeMap<
66        super::super::api::PropertyName,
67        super::super::api::PropertyValue,
68    >,
69    #[builder(
70        default,
71        custom(
72            type = impl
73            Into<Option<super::EventDisposition>>,
74            convert = |v|v.into().map(Box::new)
75        )
76    )]
77    #[serde(rename = "disposition", skip_serializing_if = "Option::is_none", default)]
78    disposition: Option<Box<super::EventDisposition>>,
79}
80impl CreateEvent {
81    /// Must contain at least one asset rid.
82    #[inline]
83    pub fn asset_rids(
84        &self,
85    ) -> &std::collections::BTreeSet<super::super::scout::rids::api::AssetRid> {
86        &self.asset_rids
87    }
88    /// If empty, will default to set<EventOrigin.api>.
89    #[inline]
90    pub fn origins(&self) -> &std::collections::BTreeSet<super::EventOrigin> {
91        &self.origins
92    }
93    #[inline]
94    pub fn timestamp(&self) -> &super::super::api::Timestamp {
95        &*self.timestamp
96    }
97    #[inline]
98    pub fn duration(&self) -> &super::super::scout::run::api::Duration {
99        &*self.duration
100    }
101    #[inline]
102    pub fn name(&self) -> &str {
103        &*self.name
104    }
105    /// If not provided, will default to an empty string.
106    #[inline]
107    pub fn description(&self) -> Option<&str> {
108        self.description.as_ref().map(|o| &**o)
109    }
110    #[inline]
111    pub fn type_(&self) -> &super::EventType {
112        &self.type_
113    }
114    #[inline]
115    pub fn labels(&self) -> &std::collections::BTreeSet<super::super::api::Label> {
116        &self.labels
117    }
118    #[inline]
119    pub fn properties(
120        &self,
121    ) -> &std::collections::BTreeMap<
122        super::super::api::PropertyName,
123        super::super::api::PropertyValue,
124    > {
125        &self.properties
126    }
127    #[inline]
128    pub fn disposition(&self) -> Option<&super::EventDisposition> {
129        self.disposition.as_ref().map(|o| &**o)
130    }
131}