Skip to main content

proxmox_api/generated/access/users/userid/
tfa.rs

1#[derive(Debug, Clone)]
2pub struct TfaClient<T> {
3    client: T,
4    path: String,
5}
6impl<T> TfaClient<T>
7where
8    T: crate::client::Client,
9{
10    pub fn new(client: T, parent_path: &str) -> Self {
11        Self {
12            client,
13            path: format!("{}{}", parent_path, "/tfa"),
14        }
15    }
16}
17impl<T> TfaClient<T>
18where
19    T: crate::client::Client,
20{
21    #[doc = "Get user TFA types (Personal and Realm)."]
22    #[doc = ""]
23    #[doc = "Permission check: or(userid-param(\"self\"), userid-group([\"User.Modify\", \"Sys.Audit\"]))"]
24    pub async fn get(&self, params: GetParams) -> Result<GetOutput, T::Error> {
25        let path = self.path.to_string();
26        self.client.get(&path, &params).await
27    }
28}
29#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize, Default)]
30pub struct GetOutput {
31    #[serde(skip_serializing_if = "Option::is_none", default)]
32    #[doc = "The type of TFA the users realm has set, if any."]
33    #[doc = ""]
34    pub realm: Option<Realm>,
35    #[serde(skip_serializing_if = "::std::vec::Vec::is_empty", default)]
36    #[doc = "Array of the user configured TFA types, if any. Only available if 'multiple' was not passed."]
37    #[doc = ""]
38    pub types: Vec<Types>,
39    #[serde(skip_serializing_if = "Option::is_none", default)]
40    #[doc = "The type of TFA the user has set, if any. Only set if 'multiple' was not passed."]
41    #[doc = ""]
42    pub user: Option<User>,
43}
44#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize, Default)]
45pub struct GetParams {
46    #[serde(
47        serialize_with = "crate::types::serialize_bool_optional",
48        deserialize_with = "crate::types::deserialize_bool_optional"
49    )]
50    #[serde(skip_serializing_if = "Option::is_none", default)]
51    #[doc = "Request all entries as an array."]
52    #[doc = ""]
53    pub multiple: Option<bool>,
54    #[serde(
55        flatten,
56        default,
57        skip_serializing_if = "::std::collections::HashMap::is_empty"
58    )]
59    pub additional_properties: ::std::collections::HashMap<String, ::serde_json::Value>,
60}
61#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize, PartialEq)]
62#[doc = "The type of TFA the users realm has set, if any."]
63#[doc = ""]
64pub enum Realm {
65    #[serde(rename = "oath")]
66    Oath,
67    #[serde(rename = "yubico")]
68    Yubico,
69}
70impl TryFrom<&str> for Realm {
71    type Error = String;
72    fn try_from(value: &str) -> Result<Self, <Self as TryFrom<&str>>::Error> {
73        match value {
74            "oath" => Ok(Self::Oath),
75            "yubico" => Ok(Self::Yubico),
76            v => Err(format!("Unknown variant {v}")),
77        }
78    }
79}
80#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize, PartialEq)]
81#[doc = "A TFA type."]
82#[doc = ""]
83pub enum Types {
84    #[serde(rename = "recovedry")]
85    Recovedry,
86    #[serde(rename = "totp")]
87    Totp,
88    #[serde(rename = "u2f")]
89    U2f,
90    #[serde(rename = "webauthn")]
91    Webauthn,
92    #[serde(rename = "yubico")]
93    Yubico,
94}
95impl TryFrom<&str> for Types {
96    type Error = String;
97    fn try_from(value: &str) -> Result<Self, <Self as TryFrom<&str>>::Error> {
98        match value {
99            "recovedry" => Ok(Self::Recovedry),
100            "totp" => Ok(Self::Totp),
101            "u2f" => Ok(Self::U2f),
102            "webauthn" => Ok(Self::Webauthn),
103            "yubico" => Ok(Self::Yubico),
104            v => Err(format!("Unknown variant {v}")),
105        }
106    }
107}
108#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize, PartialEq)]
109#[doc = "The type of TFA the user has set, if any. Only set if 'multiple' was not passed."]
110#[doc = ""]
111pub enum User {
112    #[serde(rename = "oath")]
113    Oath,
114    #[serde(rename = "u2f")]
115    U2f,
116}
117impl TryFrom<&str> for User {
118    type Error = String;
119    fn try_from(value: &str) -> Result<Self, <Self as TryFrom<&str>>::Error> {
120        match value {
121            "oath" => Ok(Self::Oath),
122            "u2f" => Ok(Self::U2f),
123            v => Err(format!("Unknown variant {v}")),
124        }
125    }
126}