proxmox_api/generated/access/users/userid/token/
tokenid.rs1#[derive(Debug, Clone)]
2pub struct TokenidClient<T> {
3 client: T,
4 path: String,
5}
6impl<T> TokenidClient<T>
7where
8 T: crate::client::Client,
9{
10 pub fn new(client: T, parent_path: &str, tokenid: &str) -> Self {
11 Self {
12 client,
13 path: format!("{}/{}", parent_path, tokenid),
14 }
15 }
16}
17impl<T> TokenidClient<T>
18where
19 T: crate::client::Client,
20{
21 #[doc = "Remove API token for a specific user."]
22 #[doc = ""]
23 #[doc = "Permission check: or(userid-param(\"self\"), userid-group([\"User.Modify\"]))"]
24 pub async fn delete(&self) -> Result<(), T::Error> {
25 let path = self.path.to_string();
26 self.client.delete(&path, &()).await
27 }
28}
29impl<T> TokenidClient<T>
30where
31 T: crate::client::Client,
32{
33 #[doc = "Get specific API token information."]
34 #[doc = ""]
35 #[doc = "Permission check: or(userid-param(\"self\"), userid-group([\"User.Modify\"]))"]
36 pub async fn get(&self) -> Result<GetOutput, T::Error> {
37 let path = self.path.to_string();
38 self.client.get(&path, &()).await
39 }
40}
41impl<T> TokenidClient<T>
42where
43 T: crate::client::Client,
44{
45 #[doc = "Generate a new API token for a specific user. NOTE: returns API token value, which needs to be stored as it cannot be retrieved afterwards!"]
46 #[doc = ""]
47 #[doc = "Permission check: or(userid-param(\"self\"), userid-group([\"User.Modify\"]))"]
48 pub async fn post(&self, params: PostParams) -> Result<PostOutput, T::Error> {
49 let path = self.path.to_string();
50 self.client.post(&path, ¶ms).await
51 }
52}
53impl<T> TokenidClient<T>
54where
55 T: crate::client::Client,
56{
57 #[doc = "Update API token for a specific user."]
58 #[doc = ""]
59 #[doc = "Permission check: or(userid-param(\"self\"), userid-group([\"User.Modify\"]))"]
60 pub async fn put(&self, params: PutParams) -> Result<PutOutput, T::Error> {
61 let path = self.path.to_string();
62 self.client.put(&path, ¶ms).await
63 }
64}
65#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize, Default)]
66pub struct GetOutput {
67 #[serde(skip_serializing_if = "Option::is_none", default)]
68 pub comment: Option<String>,
69 #[serde(
70 serialize_with = "crate::types::serialize_unsigned_int_optional",
71 deserialize_with = "crate::types::deserialize_unsigned_int_optional"
72 )]
73 #[serde(skip_serializing_if = "Option::is_none", default)]
74 #[doc = "API token expiration date (seconds since epoch). '0' means no expiration date."]
75 #[doc = ""]
76 pub expire: Option<u64>,
77 #[serde(
78 serialize_with = "crate::types::serialize_bool_optional",
79 deserialize_with = "crate::types::deserialize_bool_optional"
80 )]
81 #[serde(skip_serializing_if = "Option::is_none", default)]
82 #[doc = "Restrict API token privileges with separate ACLs (default), or give full privileges of corresponding user."]
83 #[doc = ""]
84 pub privsep: Option<bool>,
85 #[serde(
86 flatten,
87 default,
88 skip_serializing_if = "::std::collections::HashMap::is_empty"
89 )]
90 pub additional_properties: ::std::collections::HashMap<String, ::serde_json::Value>,
91}
92#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize, Default)]
93pub struct InfoPostOutputInfo {
94 #[serde(skip_serializing_if = "Option::is_none", default)]
95 pub comment: Option<String>,
96 #[serde(
97 serialize_with = "crate::types::serialize_unsigned_int_optional",
98 deserialize_with = "crate::types::deserialize_unsigned_int_optional"
99 )]
100 #[serde(skip_serializing_if = "Option::is_none", default)]
101 #[doc = "API token expiration date (seconds since epoch). '0' means no expiration date."]
102 #[doc = ""]
103 pub expire: Option<u64>,
104 #[serde(
105 serialize_with = "crate::types::serialize_bool_optional",
106 deserialize_with = "crate::types::deserialize_bool_optional"
107 )]
108 #[serde(skip_serializing_if = "Option::is_none", default)]
109 #[doc = "Restrict API token privileges with separate ACLs (default), or give full privileges of corresponding user."]
110 #[doc = ""]
111 pub privsep: Option<bool>,
112 #[serde(
113 flatten,
114 default,
115 skip_serializing_if = "::std::collections::HashMap::is_empty"
116 )]
117 pub additional_properties: ::std::collections::HashMap<String, ::serde_json::Value>,
118}
119impl PostOutput {
120 pub fn new(full_tokenid: String, info: InfoPostOutputInfo, value: String) -> Self {
121 Self {
122 full_tokenid,
123 info,
124 value,
125 }
126 }
127}
128#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize)]
129pub struct PostOutput {
130 #[serde(rename = "full-tokenid")]
131 #[doc = "The full token id."]
132 #[doc = ""]
133 pub full_tokenid: String,
134 pub info: InfoPostOutputInfo,
135 #[doc = "API token value used for authentication."]
136 #[doc = ""]
137 pub value: String,
138}
139#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize, Default)]
140pub struct PostParams {
141 #[serde(skip_serializing_if = "Option::is_none", default)]
142 pub comment: Option<String>,
143 #[serde(
144 serialize_with = "crate::types::serialize_unsigned_int_optional",
145 deserialize_with = "crate::types::deserialize_unsigned_int_optional"
146 )]
147 #[serde(skip_serializing_if = "Option::is_none", default)]
148 #[doc = "API token expiration date (seconds since epoch). '0' means no expiration date."]
149 #[doc = ""]
150 pub expire: Option<u64>,
151 #[serde(
152 serialize_with = "crate::types::serialize_bool_optional",
153 deserialize_with = "crate::types::deserialize_bool_optional"
154 )]
155 #[serde(skip_serializing_if = "Option::is_none", default)]
156 #[doc = "Restrict API token privileges with separate ACLs (default), or give full privileges of corresponding user."]
157 #[doc = ""]
158 pub privsep: Option<bool>,
159 #[serde(
160 flatten,
161 default,
162 skip_serializing_if = "::std::collections::HashMap::is_empty"
163 )]
164 pub additional_properties: ::std::collections::HashMap<String, ::serde_json::Value>,
165}
166#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize, Default)]
167pub struct PutOutput {
168 #[serde(skip_serializing_if = "Option::is_none", default)]
169 pub comment: Option<String>,
170 #[serde(
171 serialize_with = "crate::types::serialize_unsigned_int_optional",
172 deserialize_with = "crate::types::deserialize_unsigned_int_optional"
173 )]
174 #[serde(skip_serializing_if = "Option::is_none", default)]
175 #[doc = "API token expiration date (seconds since epoch). '0' means no expiration date."]
176 #[doc = ""]
177 pub expire: Option<u64>,
178 #[serde(
179 serialize_with = "crate::types::serialize_bool_optional",
180 deserialize_with = "crate::types::deserialize_bool_optional"
181 )]
182 #[serde(skip_serializing_if = "Option::is_none", default)]
183 #[doc = "Restrict API token privileges with separate ACLs (default), or give full privileges of corresponding user."]
184 #[doc = ""]
185 pub privsep: Option<bool>,
186 #[serde(
187 flatten,
188 default,
189 skip_serializing_if = "::std::collections::HashMap::is_empty"
190 )]
191 pub additional_properties: ::std::collections::HashMap<String, ::serde_json::Value>,
192}
193#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize, Default)]
194pub struct PutParams {
195 #[serde(skip_serializing_if = "Option::is_none", default)]
196 pub comment: Option<String>,
197 #[serde(skip_serializing_if = "Option::is_none", default)]
198 #[doc = "A list of settings you want to delete."]
199 #[doc = ""]
200 pub delete: Option<String>,
201 #[serde(
202 serialize_with = "crate::types::serialize_unsigned_int_optional",
203 deserialize_with = "crate::types::deserialize_unsigned_int_optional"
204 )]
205 #[serde(skip_serializing_if = "Option::is_none", default)]
206 #[doc = "API token expiration date (seconds since epoch). '0' means no expiration date."]
207 #[doc = ""]
208 pub expire: Option<u64>,
209 #[serde(
210 serialize_with = "crate::types::serialize_bool_optional",
211 deserialize_with = "crate::types::deserialize_bool_optional"
212 )]
213 #[serde(skip_serializing_if = "Option::is_none", default)]
214 #[doc = "Restrict API token privileges with separate ACLs (default), or give full privileges of corresponding user."]
215 #[doc = ""]
216 pub privsep: Option<bool>,
217 #[serde(
218 flatten,
219 default,
220 skip_serializing_if = "::std::collections::HashMap::is_empty"
221 )]
222 pub additional_properties: ::std::collections::HashMap<String, ::serde_json::Value>,
223}