proxmox_api/generated/access/
tfa.rs1pub mod userid;
2#[derive(Debug, Clone)]
3pub struct TfaClient<T> {
4 client: T,
5 path: String,
6}
7impl<T> TfaClient<T>
8where
9 T: crate::client::Client,
10{
11 pub fn new(client: T, parent_path: &str) -> Self {
12 Self {
13 client,
14 path: format!("{}{}", parent_path, "/tfa"),
15 }
16 }
17}
18impl<T> TfaClient<T>
19where
20 T: crate::client::Client,
21{
22 #[doc = "List TFA configurations of users."]
23 #[doc = ""]
24 #[doc = "Returns all or just the logged-in user, depending on privileges."]
25 pub async fn get(&self) -> Result<Vec<GetOutputItems>, T::Error> {
26 let path = self.path.to_string();
27 let optional_vec: Option<Vec<GetOutputItems>> = self.client.get(&path, &()).await?;
28 Ok(optional_vec.unwrap_or_default())
29 }
30}
31impl EntriesGetOutputItemsEntriesItems {
32 pub fn new(created: i64, description: String, id: String, ty: Type) -> Self {
33 Self {
34 created,
35 description,
36 id,
37 ty,
38 enable: ::std::default::Default::default(),
39 additional_properties: ::std::default::Default::default(),
40 }
41 }
42}
43#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize)]
44pub struct EntriesGetOutputItemsEntriesItems {
45 #[serde(
46 serialize_with = "crate::types::serialize_int",
47 deserialize_with = "crate::types::deserialize_int"
48 )]
49 #[doc = "Creation time of this entry as unix epoch."]
50 #[doc = ""]
51 pub created: i64,
52 #[doc = "User chosen description for this entry."]
53 #[doc = ""]
54 pub description: String,
55 #[serde(
56 serialize_with = "crate::types::serialize_bool_optional",
57 deserialize_with = "crate::types::deserialize_bool_optional"
58 )]
59 #[serde(skip_serializing_if = "Option::is_none", default)]
60 #[doc = "Whether this TFA entry is currently enabled."]
61 #[doc = ""]
62 pub enable: Option<bool>,
63 #[doc = "The id used to reference this entry."]
64 #[doc = ""]
65 pub id: String,
66 #[serde(rename = "type")]
67 #[doc = "TFA Entry Type."]
68 #[doc = ""]
69 pub ty: Type,
70 #[serde(
71 flatten,
72 default,
73 skip_serializing_if = "::std::collections::HashMap::is_empty"
74 )]
75 pub additional_properties: ::std::collections::HashMap<String, ::serde_json::Value>,
76}
77impl GetOutputItems {
78 pub fn new(entries: Vec<EntriesGetOutputItemsEntriesItems>, userid: String) -> Self {
79 Self {
80 entries,
81 userid,
82 tfa_locked_until: ::std::default::Default::default(),
83 totp_locked: ::std::default::Default::default(),
84 additional_properties: ::std::default::Default::default(),
85 }
86 }
87}
88#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize)]
89pub struct GetOutputItems {
90 #[serde(skip_serializing_if = "::std::vec::Vec::is_empty", default)]
91 pub entries: Vec<EntriesGetOutputItemsEntriesItems>,
92 #[serde(rename = "tfa-locked-until")]
93 #[serde(
94 serialize_with = "crate::types::serialize_int_optional",
95 deserialize_with = "crate::types::deserialize_int_optional"
96 )]
97 #[serde(skip_serializing_if = "Option::is_none", default)]
98 #[doc = "Contains a timestamp until when a user is locked out of 2nd factors."]
99 #[doc = ""]
100 pub tfa_locked_until: Option<i64>,
101 #[serde(rename = "totp-locked")]
102 #[serde(
103 serialize_with = "crate::types::serialize_bool_optional",
104 deserialize_with = "crate::types::deserialize_bool_optional"
105 )]
106 #[serde(skip_serializing_if = "Option::is_none", default)]
107 #[doc = "True if the user is currently locked out of TOTP factors."]
108 #[doc = ""]
109 pub totp_locked: Option<bool>,
110 #[doc = "User this entry belongs to."]
111 #[doc = ""]
112 pub userid: String,
113 #[serde(
114 flatten,
115 default,
116 skip_serializing_if = "::std::collections::HashMap::is_empty"
117 )]
118 pub additional_properties: ::std::collections::HashMap<String, ::serde_json::Value>,
119}
120#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize, PartialEq)]
121#[doc = "TFA Entry Type."]
122#[doc = ""]
123pub enum Type {
124 #[serde(rename = "recovery")]
125 Recovery,
126 #[serde(rename = "totp")]
127 Totp,
128 #[serde(rename = "u2f")]
129 U2f,
130 #[serde(rename = "webauthn")]
131 Webauthn,
132 #[serde(rename = "yubico")]
133 Yubico,
134}
135impl TryFrom<&str> for Type {
136 type Error = String;
137 fn try_from(value: &str) -> Result<Self, <Self as TryFrom<&str>>::Error> {
138 match value {
139 "recovery" => Ok(Self::Recovery),
140 "totp" => Ok(Self::Totp),
141 "u2f" => Ok(Self::U2f),
142 "webauthn" => Ok(Self::Webauthn),
143 "yubico" => Ok(Self::Yubico),
144 v => Err(format!("Unknown variant {v}")),
145 }
146 }
147}
148impl<T> TfaClient<T>
149where
150 T: crate::client::Client,
151{
152 pub fn userid(&self, userid: &str) -> userid::UseridClient<T> {
153 userid::UseridClient::<T>::new(self.client.clone(), &self.path, userid)
154 }
155}