stix_rs/observables/
user_account.rs1use serde::{Deserialize, Serialize};
2
3#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
4#[serde(rename_all = "snake_case")]
5pub struct UserAccount {
6 pub user_id: Option<String>,
7 pub account_login: Option<String>,
8 pub display_name: Option<String>,
9 #[serde(flatten)]
10 pub custom_properties: std::collections::HashMap<String, serde_json::Value>,
11}
12
13impl UserAccount {
14 pub fn builder() -> UserAccountBuilder {
15 UserAccountBuilder::default()
16 }
17}
18
19#[derive(Debug, Default)]
20pub struct UserAccountBuilder {
21 user_id: Option<String>,
22 account_login: Option<String>,
23 display_name: Option<String>,
24 custom_properties: std::collections::HashMap<String, serde_json::Value>,
25}
26
27impl UserAccountBuilder {
28 pub fn user_id(mut self, u: impl Into<String>) -> Self {
29 self.user_id = Some(u.into());
30 self
31 }
32 pub fn account_login(mut self, a: impl Into<String>) -> Self {
33 self.account_login = Some(a.into());
34 self
35 }
36 pub fn display_name(mut self, d: impl Into<String>) -> Self {
37 self.display_name = Some(d.into());
38 self
39 }
40 pub fn property(mut self, k: impl Into<String>, v: impl Into<serde_json::Value>) -> Self {
41 self.custom_properties.insert(k.into(), v.into());
42 self
43 }
44 pub fn build(self) -> UserAccount {
45 UserAccount {
46 user_id: self.user_id,
47 account_login: self.account_login,
48 display_name: self.display_name,
49 custom_properties: self.custom_properties,
50 }
51 }
52}
53
54impl From<UserAccount> for crate::StixObjectEnum {
55 fn from(u: UserAccount) -> Self {
56 crate::StixObjectEnum::UserAccount(u)
57 }
58}