proxmox_api/generated/access/tfa/
userid.rs

1pub mod id;
2pub struct UseridClient<T> {
3    client: T,
4    path: String,
5}
6impl<T> UseridClient<T>
7where
8    T: crate::client::Client,
9{
10    pub fn new(client: T, parent_path: &str, userid: &str) -> Self {
11        Self {
12            client,
13            path: format!("{}/{}", parent_path, userid),
14        }
15    }
16}
17impl<T> UseridClient<T>
18where
19    T: crate::client::Client,
20{
21    #[doc = "List TFA configurations of users."]
22    pub fn get(&self) -> Result<Vec<GetOutputItems>, T::Error> {
23        let path = self.path.to_string();
24        self.client.get(&path, &())
25    }
26}
27impl<T> UseridClient<T>
28where
29    T: crate::client::Client,
30{
31    #[doc = "Add a TFA entry for a user."]
32    pub fn post(&self, params: PostParams) -> Result<PostOutput, T::Error> {
33        let path = self.path.to_string();
34        self.client.post(&path, &params)
35    }
36}
37impl GetOutputItems {
38    pub fn new(created: u64, description: String, id: String, ty: Type) -> Self {
39        Self {
40            created,
41            description,
42            id,
43            ty,
44            enable: Default::default(),
45            additional_properties: Default::default(),
46        }
47    }
48}
49#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize)]
50pub struct GetOutputItems {
51    #[serde(
52        serialize_with = "crate::types::serialize_int",
53        deserialize_with = "crate::types::deserialize_int"
54    )]
55    #[doc = "Creation time of this entry as unix epoch."]
56    pub created: u64,
57    #[doc = "User chosen description for this entry."]
58    pub description: String,
59    #[serde(
60        serialize_with = "crate::types::serialize_bool_optional",
61        deserialize_with = "crate::types::deserialize_bool_optional"
62    )]
63    #[serde(skip_serializing_if = "Option::is_none", default)]
64    #[doc = "Whether this TFA entry is currently enabled."]
65    pub enable: Option<bool>,
66    #[doc = "The id used to reference this entry."]
67    pub id: String,
68    #[serde(rename = "type")]
69    #[doc = "TFA Entry Type."]
70    pub ty: Type,
71    #[serde(
72        flatten,
73        default,
74        skip_serializing_if = "::std::collections::HashMap::is_empty"
75    )]
76    pub additional_properties: ::std::collections::HashMap<String, ::serde_json::Value>,
77}
78impl PostOutput {
79    pub fn new(id: String) -> Self {
80        Self {
81            id,
82            challenge: Default::default(),
83            recovery: Default::default(),
84            additional_properties: Default::default(),
85        }
86    }
87}
88#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize)]
89pub struct PostOutput {
90    #[serde(skip_serializing_if = "Option::is_none", default)]
91    #[doc = "When adding u2f entries, this contains a challenge the user must respond to in order to finish the registration."]
92    pub challenge: Option<String>,
93    #[doc = "The id of a newly added TFA entry."]
94    pub id: String,
95    #[serde(skip_serializing_if = "::std::vec::Vec::is_empty", default)]
96    #[doc = "When adding recovery codes, this contains the list of codes to be displayed to the user"]
97    pub recovery: Vec<String>,
98    #[serde(
99        flatten,
100        default,
101        skip_serializing_if = "::std::collections::HashMap::is_empty"
102    )]
103    pub additional_properties: ::std::collections::HashMap<String, ::serde_json::Value>,
104}
105impl PostParams {
106    pub fn new(ty: Type) -> Self {
107        Self {
108            ty,
109            challenge: Default::default(),
110            description: Default::default(),
111            password: Default::default(),
112            totp: Default::default(),
113            value: Default::default(),
114            additional_properties: Default::default(),
115        }
116    }
117}
118#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize)]
119pub struct PostParams {
120    #[serde(skip_serializing_if = "Option::is_none", default)]
121    #[doc = "When responding to a u2f challenge: the original challenge string"]
122    pub challenge: Option<String>,
123    #[serde(skip_serializing_if = "Option::is_none", default)]
124    #[doc = "A description to distinguish multiple entries from one another"]
125    pub description: Option<String>,
126    #[serde(skip_serializing_if = "Option::is_none", default)]
127    #[doc = "The current password of the user performing the change."]
128    pub password: Option<String>,
129    #[serde(skip_serializing_if = "Option::is_none", default)]
130    #[doc = "A totp URI."]
131    pub totp: Option<String>,
132    #[serde(rename = "type")]
133    #[doc = "TFA Entry Type."]
134    pub ty: Type,
135    #[serde(skip_serializing_if = "Option::is_none", default)]
136    #[doc = "The current value for the provided totp URI, or a Webauthn/U2F challenge response"]
137    pub value: Option<String>,
138    #[serde(
139        flatten,
140        default,
141        skip_serializing_if = "::std::collections::HashMap::is_empty"
142    )]
143    pub additional_properties: ::std::collections::HashMap<String, ::serde_json::Value>,
144}
145#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize)]
146pub enum Type {
147    #[serde(rename = "recovery")]
148    Recovery,
149    #[serde(rename = "totp")]
150    Totp,
151    #[serde(rename = "u2f")]
152    U2f,
153    #[serde(rename = "webauthn")]
154    Webauthn,
155    #[serde(rename = "yubico")]
156    Yubico,
157}
158impl<T> UseridClient<T>
159where
160    T: crate::client::Client,
161{
162    pub fn id(&self, id: &str) -> id::IdClient<T> {
163        id::IdClient::<T>::new(self.client.clone(), &self.path, id)
164    }
165}