Skip to main content

clientapi_pve/apis/
access_users_api.rs

1/*
2 * Proxmox Virtual Environment API
3 *
4 * Generated from apidoc.js. NOT an official Proxmox specification. See https://pve.proxmox.com/pve-docs/api-viewer/ for the upstream documentation.
5 *
6 * The version of the OpenAPI document: 9.x
7 * 
8 * Generated by: https://openapi-generator.tech
9 */
10
11
12use reqwest;
13use serde::{Deserialize, Serialize, de::Error as _};
14use crate::{apis::ResponseContent, models};
15use super::{Error, configuration, ContentType};
16
17
18/// struct for typed errors of method [`access_users_create_user`]
19#[derive(Debug, Clone, Serialize, Deserialize)]
20#[serde(untagged)]
21pub enum AccessUsersCreateUserError {
22    Status400(models::PveError),
23    Status401(models::PveError),
24    Status403(models::PveError),
25    Status404(models::PveError),
26    Status500(models::PveError),
27    Status501(models::PveError),
28    Status503(models::PveError),
29    UnknownValue(serde_json::Value),
30}
31
32/// struct for typed errors of method [`access_users_delete_user`]
33#[derive(Debug, Clone, Serialize, Deserialize)]
34#[serde(untagged)]
35pub enum AccessUsersDeleteUserError {
36    Status400(models::PveError),
37    Status401(models::PveError),
38    Status403(models::PveError),
39    Status404(models::PveError),
40    Status500(models::PveError),
41    Status501(models::PveError),
42    Status503(models::PveError),
43    UnknownValue(serde_json::Value),
44}
45
46/// struct for typed errors of method [`access_users_generate_token`]
47#[derive(Debug, Clone, Serialize, Deserialize)]
48#[serde(untagged)]
49pub enum AccessUsersGenerateTokenError {
50    Status400(models::PveError),
51    Status401(models::PveError),
52    Status403(models::PveError),
53    Status404(models::PveError),
54    Status500(models::PveError),
55    Status501(models::PveError),
56    Status503(models::PveError),
57    UnknownValue(serde_json::Value),
58}
59
60/// struct for typed errors of method [`access_users_get_users`]
61#[derive(Debug, Clone, Serialize, Deserialize)]
62#[serde(untagged)]
63pub enum AccessUsersGetUsersError {
64    Status400(models::PveError),
65    Status401(models::PveError),
66    Status403(models::PveError),
67    Status404(models::PveError),
68    Status500(models::PveError),
69    Status501(models::PveError),
70    Status503(models::PveError),
71    UnknownValue(serde_json::Value),
72}
73
74/// struct for typed errors of method [`access_users_read_token`]
75#[derive(Debug, Clone, Serialize, Deserialize)]
76#[serde(untagged)]
77pub enum AccessUsersReadTokenError {
78    Status400(models::PveError),
79    Status401(models::PveError),
80    Status403(models::PveError),
81    Status404(models::PveError),
82    Status500(models::PveError),
83    Status501(models::PveError),
84    Status503(models::PveError),
85    UnknownValue(serde_json::Value),
86}
87
88/// struct for typed errors of method [`access_users_read_user`]
89#[derive(Debug, Clone, Serialize, Deserialize)]
90#[serde(untagged)]
91pub enum AccessUsersReadUserError {
92    Status400(models::PveError),
93    Status401(models::PveError),
94    Status403(models::PveError),
95    Status404(models::PveError),
96    Status500(models::PveError),
97    Status501(models::PveError),
98    Status503(models::PveError),
99    UnknownValue(serde_json::Value),
100}
101
102/// struct for typed errors of method [`access_users_read_user_tfa_type`]
103#[derive(Debug, Clone, Serialize, Deserialize)]
104#[serde(untagged)]
105pub enum AccessUsersReadUserTfaTypeError {
106    Status400(models::PveError),
107    Status401(models::PveError),
108    Status403(models::PveError),
109    Status404(models::PveError),
110    Status500(models::PveError),
111    Status501(models::PveError),
112    Status503(models::PveError),
113    UnknownValue(serde_json::Value),
114}
115
116/// struct for typed errors of method [`access_users_remove_token`]
117#[derive(Debug, Clone, Serialize, Deserialize)]
118#[serde(untagged)]
119pub enum AccessUsersRemoveTokenError {
120    Status400(models::PveError),
121    Status401(models::PveError),
122    Status403(models::PveError),
123    Status404(models::PveError),
124    Status500(models::PveError),
125    Status501(models::PveError),
126    Status503(models::PveError),
127    UnknownValue(serde_json::Value),
128}
129
130/// struct for typed errors of method [`access_users_token_index`]
131#[derive(Debug, Clone, Serialize, Deserialize)]
132#[serde(untagged)]
133pub enum AccessUsersTokenIndexError {
134    Status400(models::PveError),
135    Status401(models::PveError),
136    Status403(models::PveError),
137    Status404(models::PveError),
138    Status500(models::PveError),
139    Status501(models::PveError),
140    Status503(models::PveError),
141    UnknownValue(serde_json::Value),
142}
143
144/// struct for typed errors of method [`access_users_unlock_tfa`]
145#[derive(Debug, Clone, Serialize, Deserialize)]
146#[serde(untagged)]
147pub enum AccessUsersUnlockTfaError {
148    Status400(models::PveError),
149    Status401(models::PveError),
150    Status403(models::PveError),
151    Status404(models::PveError),
152    Status500(models::PveError),
153    Status501(models::PveError),
154    Status503(models::PveError),
155    UnknownValue(serde_json::Value),
156}
157
158/// struct for typed errors of method [`access_users_update_token_info`]
159#[derive(Debug, Clone, Serialize, Deserialize)]
160#[serde(untagged)]
161pub enum AccessUsersUpdateTokenInfoError {
162    Status400(models::PveError),
163    Status401(models::PveError),
164    Status403(models::PveError),
165    Status404(models::PveError),
166    Status500(models::PveError),
167    Status501(models::PveError),
168    Status503(models::PveError),
169    UnknownValue(serde_json::Value),
170}
171
172/// struct for typed errors of method [`access_users_update_user`]
173#[derive(Debug, Clone, Serialize, Deserialize)]
174#[serde(untagged)]
175pub enum AccessUsersUpdateUserError {
176    Status400(models::PveError),
177    Status401(models::PveError),
178    Status403(models::PveError),
179    Status404(models::PveError),
180    Status500(models::PveError),
181    Status501(models::PveError),
182    Status503(models::PveError),
183    UnknownValue(serde_json::Value),
184}
185
186
187/// Create new user.  Permissions: You need 'Realm.AllocateUser' on '/access/realm/<realm>' on the realm of user <userid>, and 'User.Modify' permissions to '/access/groups/<group>' for any group specified (or 'User.Modify' on '/access/groups' if you pass no groups.
188pub async fn access_users_create_user(configuration: &configuration::Configuration, access_users_create_user_request: models::AccessUsersCreateUserRequest) -> Result<models::AccessUsersCreateUserResponse, Error<AccessUsersCreateUserError>> {
189    // add a prefix to parameters to efficiently prevent name collisions
190    let p_body_access_users_create_user_request = access_users_create_user_request;
191
192    let uri_str = format!("{}/access/users", configuration.base_path);
193    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
194
195    if let Some(ref user_agent) = configuration.user_agent {
196        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
197    }
198    if let Some(ref apikey) = configuration.api_key {
199        let key = apikey.key.clone();
200        let value = match apikey.prefix {
201            Some(ref prefix) => format!("{} {}", prefix, key),
202            None => key,
203        };
204        req_builder = req_builder.header("Authorization", value);
205    };
206    if let Some(ref apikey) = configuration.api_key {
207        let key = apikey.key.clone();
208        let value = match apikey.prefix {
209            Some(ref prefix) => format!("{} {}", prefix, key),
210            None => key,
211        };
212        req_builder = req_builder.header("CSRFPreventionToken", value);
213    };
214    req_builder = req_builder.json(&p_body_access_users_create_user_request);
215
216    let req = req_builder.build()?;
217    let resp = configuration.client.execute(req).await?;
218
219    let status = resp.status();
220    let content_type = resp
221        .headers()
222        .get("content-type")
223        .and_then(|v| v.to_str().ok())
224        .unwrap_or("application/octet-stream");
225    let content_type = super::ContentType::from(content_type);
226
227    if !status.is_client_error() && !status.is_server_error() {
228        let content = resp.text().await?;
229        match content_type {
230            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
231            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::AccessUsersCreateUserResponse`"))),
232            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::AccessUsersCreateUserResponse`")))),
233        }
234    } else {
235        let content = resp.text().await?;
236        let entity: Option<AccessUsersCreateUserError> = serde_json::from_str(&content).ok();
237        Err(Error::ResponseError(ResponseContent { status, content, entity }))
238    }
239}
240
241/// Delete user.
242pub async fn access_users_delete_user(configuration: &configuration::Configuration, userid: &str) -> Result<models::AccessUsersDeleteUserResponse, Error<AccessUsersDeleteUserError>> {
243    // add a prefix to parameters to efficiently prevent name collisions
244    let p_path_userid = userid;
245
246    let uri_str = format!("{}/access/users/{userid}", configuration.base_path, userid=crate::apis::urlencode(p_path_userid));
247    let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
248
249    if let Some(ref user_agent) = configuration.user_agent {
250        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
251    }
252    if let Some(ref apikey) = configuration.api_key {
253        let key = apikey.key.clone();
254        let value = match apikey.prefix {
255            Some(ref prefix) => format!("{} {}", prefix, key),
256            None => key,
257        };
258        req_builder = req_builder.header("Authorization", value);
259    };
260    if let Some(ref apikey) = configuration.api_key {
261        let key = apikey.key.clone();
262        let value = match apikey.prefix {
263            Some(ref prefix) => format!("{} {}", prefix, key),
264            None => key,
265        };
266        req_builder = req_builder.header("CSRFPreventionToken", value);
267    };
268
269    let req = req_builder.build()?;
270    let resp = configuration.client.execute(req).await?;
271
272    let status = resp.status();
273    let content_type = resp
274        .headers()
275        .get("content-type")
276        .and_then(|v| v.to_str().ok())
277        .unwrap_or("application/octet-stream");
278    let content_type = super::ContentType::from(content_type);
279
280    if !status.is_client_error() && !status.is_server_error() {
281        let content = resp.text().await?;
282        match content_type {
283            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
284            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::AccessUsersDeleteUserResponse`"))),
285            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::AccessUsersDeleteUserResponse`")))),
286        }
287    } else {
288        let content = resp.text().await?;
289        let entity: Option<AccessUsersDeleteUserError> = serde_json::from_str(&content).ok();
290        Err(Error::ResponseError(ResponseContent { status, content, entity }))
291    }
292}
293
294/// 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!
295pub async fn access_users_generate_token(configuration: &configuration::Configuration, tokenid: &str, userid: &str, access_users_generate_token_request: Option<models::AccessUsersGenerateTokenRequest>) -> Result<models::AccessUsersGenerateTokenResponse, Error<AccessUsersGenerateTokenError>> {
296    // add a prefix to parameters to efficiently prevent name collisions
297    let p_path_tokenid = tokenid;
298    let p_path_userid = userid;
299    let p_body_access_users_generate_token_request = access_users_generate_token_request;
300
301    let uri_str = format!("{}/access/users/{userid}/token/{tokenid}", configuration.base_path, tokenid=crate::apis::urlencode(p_path_tokenid), userid=crate::apis::urlencode(p_path_userid));
302    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
303
304    if let Some(ref user_agent) = configuration.user_agent {
305        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
306    }
307    if let Some(ref apikey) = configuration.api_key {
308        let key = apikey.key.clone();
309        let value = match apikey.prefix {
310            Some(ref prefix) => format!("{} {}", prefix, key),
311            None => key,
312        };
313        req_builder = req_builder.header("Authorization", value);
314    };
315    if let Some(ref apikey) = configuration.api_key {
316        let key = apikey.key.clone();
317        let value = match apikey.prefix {
318            Some(ref prefix) => format!("{} {}", prefix, key),
319            None => key,
320        };
321        req_builder = req_builder.header("CSRFPreventionToken", value);
322    };
323    req_builder = req_builder.json(&p_body_access_users_generate_token_request);
324
325    let req = req_builder.build()?;
326    let resp = configuration.client.execute(req).await?;
327
328    let status = resp.status();
329    let content_type = resp
330        .headers()
331        .get("content-type")
332        .and_then(|v| v.to_str().ok())
333        .unwrap_or("application/octet-stream");
334    let content_type = super::ContentType::from(content_type);
335
336    if !status.is_client_error() && !status.is_server_error() {
337        let content = resp.text().await?;
338        match content_type {
339            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
340            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::AccessUsersGenerateTokenResponse`"))),
341            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::AccessUsersGenerateTokenResponse`")))),
342        }
343    } else {
344        let content = resp.text().await?;
345        let entity: Option<AccessUsersGenerateTokenError> = serde_json::from_str(&content).ok();
346        Err(Error::ResponseError(ResponseContent { status, content, entity }))
347    }
348}
349
350/// User index.  Permissions: The returned list is restricted to users where you have 'User.Modify' or 'Sys.Audit' permissions on '/access/groups' or on a group the user belongs too. But it always includes the current (authenticated) user.
351pub async fn access_users_get_users(configuration: &configuration::Configuration, enabled: Option<models::PveBoolean>, full: Option<models::PveBoolean>) -> Result<models::AccessUsersGetUsersResponse, Error<AccessUsersGetUsersError>> {
352    // add a prefix to parameters to efficiently prevent name collisions
353    let p_query_enabled = enabled;
354    let p_query_full = full;
355
356    let uri_str = format!("{}/access/users", configuration.base_path);
357    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
358
359    if let Some(ref param_value) = p_query_enabled {
360        req_builder = req_builder.query(&[("enabled", &param_value.to_string())]);
361    }
362    if let Some(ref param_value) = p_query_full {
363        req_builder = req_builder.query(&[("full", &param_value.to_string())]);
364    }
365    if let Some(ref user_agent) = configuration.user_agent {
366        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
367    }
368    if let Some(ref apikey) = configuration.api_key {
369        let key = apikey.key.clone();
370        let value = match apikey.prefix {
371            Some(ref prefix) => format!("{} {}", prefix, key),
372            None => key,
373        };
374        req_builder = req_builder.header("Authorization", value);
375    };
376    if let Some(ref apikey) = configuration.api_key {
377        let key = apikey.key.clone();
378        let value = match apikey.prefix {
379            Some(ref prefix) => format!("{} {}", prefix, key),
380            None => key,
381        };
382        req_builder = req_builder.header("CSRFPreventionToken", value);
383    };
384
385    let req = req_builder.build()?;
386    let resp = configuration.client.execute(req).await?;
387
388    let status = resp.status();
389    let content_type = resp
390        .headers()
391        .get("content-type")
392        .and_then(|v| v.to_str().ok())
393        .unwrap_or("application/octet-stream");
394    let content_type = super::ContentType::from(content_type);
395
396    if !status.is_client_error() && !status.is_server_error() {
397        let content = resp.text().await?;
398        match content_type {
399            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
400            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::AccessUsersGetUsersResponse`"))),
401            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::AccessUsersGetUsersResponse`")))),
402        }
403    } else {
404        let content = resp.text().await?;
405        let entity: Option<AccessUsersGetUsersError> = serde_json::from_str(&content).ok();
406        Err(Error::ResponseError(ResponseContent { status, content, entity }))
407    }
408}
409
410/// Get specific API token information.
411pub async fn access_users_read_token(configuration: &configuration::Configuration, tokenid: &str, userid: &str) -> Result<models::AccessUsersReadTokenResponse, Error<AccessUsersReadTokenError>> {
412    // add a prefix to parameters to efficiently prevent name collisions
413    let p_path_tokenid = tokenid;
414    let p_path_userid = userid;
415
416    let uri_str = format!("{}/access/users/{userid}/token/{tokenid}", configuration.base_path, tokenid=crate::apis::urlencode(p_path_tokenid), userid=crate::apis::urlencode(p_path_userid));
417    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
418
419    if let Some(ref user_agent) = configuration.user_agent {
420        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
421    }
422    if let Some(ref apikey) = configuration.api_key {
423        let key = apikey.key.clone();
424        let value = match apikey.prefix {
425            Some(ref prefix) => format!("{} {}", prefix, key),
426            None => key,
427        };
428        req_builder = req_builder.header("Authorization", value);
429    };
430    if let Some(ref apikey) = configuration.api_key {
431        let key = apikey.key.clone();
432        let value = match apikey.prefix {
433            Some(ref prefix) => format!("{} {}", prefix, key),
434            None => key,
435        };
436        req_builder = req_builder.header("CSRFPreventionToken", value);
437    };
438
439    let req = req_builder.build()?;
440    let resp = configuration.client.execute(req).await?;
441
442    let status = resp.status();
443    let content_type = resp
444        .headers()
445        .get("content-type")
446        .and_then(|v| v.to_str().ok())
447        .unwrap_or("application/octet-stream");
448    let content_type = super::ContentType::from(content_type);
449
450    if !status.is_client_error() && !status.is_server_error() {
451        let content = resp.text().await?;
452        match content_type {
453            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
454            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::AccessUsersReadTokenResponse`"))),
455            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::AccessUsersReadTokenResponse`")))),
456        }
457    } else {
458        let content = resp.text().await?;
459        let entity: Option<AccessUsersReadTokenError> = serde_json::from_str(&content).ok();
460        Err(Error::ResponseError(ResponseContent { status, content, entity }))
461    }
462}
463
464/// Get user configuration.
465pub async fn access_users_read_user(configuration: &configuration::Configuration, userid: &str) -> Result<models::AccessUsersReadUserResponse, Error<AccessUsersReadUserError>> {
466    // add a prefix to parameters to efficiently prevent name collisions
467    let p_path_userid = userid;
468
469    let uri_str = format!("{}/access/users/{userid}", configuration.base_path, userid=crate::apis::urlencode(p_path_userid));
470    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
471
472    if let Some(ref user_agent) = configuration.user_agent {
473        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
474    }
475    if let Some(ref apikey) = configuration.api_key {
476        let key = apikey.key.clone();
477        let value = match apikey.prefix {
478            Some(ref prefix) => format!("{} {}", prefix, key),
479            None => key,
480        };
481        req_builder = req_builder.header("Authorization", value);
482    };
483    if let Some(ref apikey) = configuration.api_key {
484        let key = apikey.key.clone();
485        let value = match apikey.prefix {
486            Some(ref prefix) => format!("{} {}", prefix, key),
487            None => key,
488        };
489        req_builder = req_builder.header("CSRFPreventionToken", value);
490    };
491
492    let req = req_builder.build()?;
493    let resp = configuration.client.execute(req).await?;
494
495    let status = resp.status();
496    let content_type = resp
497        .headers()
498        .get("content-type")
499        .and_then(|v| v.to_str().ok())
500        .unwrap_or("application/octet-stream");
501    let content_type = super::ContentType::from(content_type);
502
503    if !status.is_client_error() && !status.is_server_error() {
504        let content = resp.text().await?;
505        match content_type {
506            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
507            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::AccessUsersReadUserResponse`"))),
508            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::AccessUsersReadUserResponse`")))),
509        }
510    } else {
511        let content = resp.text().await?;
512        let entity: Option<AccessUsersReadUserError> = serde_json::from_str(&content).ok();
513        Err(Error::ResponseError(ResponseContent { status, content, entity }))
514    }
515}
516
517/// Get user TFA types (Personal and Realm).
518pub async fn access_users_read_user_tfa_type(configuration: &configuration::Configuration, userid: &str, multiple: Option<&str>) -> Result<models::AccessUsersReadUserTfaTypeResponse, Error<AccessUsersReadUserTfaTypeError>> {
519    // add a prefix to parameters to efficiently prevent name collisions
520    let p_path_userid = userid;
521    let p_query_multiple = multiple;
522
523    let uri_str = format!("{}/access/users/{userid}/tfa", configuration.base_path, userid=crate::apis::urlencode(p_path_userid));
524    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
525
526    if let Some(ref param_value) = p_query_multiple {
527        req_builder = req_builder.query(&[("multiple", &param_value.to_string())]);
528    }
529    if let Some(ref user_agent) = configuration.user_agent {
530        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
531    }
532    if let Some(ref apikey) = configuration.api_key {
533        let key = apikey.key.clone();
534        let value = match apikey.prefix {
535            Some(ref prefix) => format!("{} {}", prefix, key),
536            None => key,
537        };
538        req_builder = req_builder.header("Authorization", value);
539    };
540    if let Some(ref apikey) = configuration.api_key {
541        let key = apikey.key.clone();
542        let value = match apikey.prefix {
543            Some(ref prefix) => format!("{} {}", prefix, key),
544            None => key,
545        };
546        req_builder = req_builder.header("CSRFPreventionToken", value);
547    };
548
549    let req = req_builder.build()?;
550    let resp = configuration.client.execute(req).await?;
551
552    let status = resp.status();
553    let content_type = resp
554        .headers()
555        .get("content-type")
556        .and_then(|v| v.to_str().ok())
557        .unwrap_or("application/octet-stream");
558    let content_type = super::ContentType::from(content_type);
559
560    if !status.is_client_error() && !status.is_server_error() {
561        let content = resp.text().await?;
562        match content_type {
563            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
564            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::AccessUsersReadUserTfaTypeResponse`"))),
565            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::AccessUsersReadUserTfaTypeResponse`")))),
566        }
567    } else {
568        let content = resp.text().await?;
569        let entity: Option<AccessUsersReadUserTfaTypeError> = serde_json::from_str(&content).ok();
570        Err(Error::ResponseError(ResponseContent { status, content, entity }))
571    }
572}
573
574/// Remove API token for a specific user.
575pub async fn access_users_remove_token(configuration: &configuration::Configuration, tokenid: &str, userid: &str) -> Result<models::AccessUsersRemoveTokenResponse, Error<AccessUsersRemoveTokenError>> {
576    // add a prefix to parameters to efficiently prevent name collisions
577    let p_path_tokenid = tokenid;
578    let p_path_userid = userid;
579
580    let uri_str = format!("{}/access/users/{userid}/token/{tokenid}", configuration.base_path, tokenid=crate::apis::urlencode(p_path_tokenid), userid=crate::apis::urlencode(p_path_userid));
581    let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
582
583    if let Some(ref user_agent) = configuration.user_agent {
584        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
585    }
586    if let Some(ref apikey) = configuration.api_key {
587        let key = apikey.key.clone();
588        let value = match apikey.prefix {
589            Some(ref prefix) => format!("{} {}", prefix, key),
590            None => key,
591        };
592        req_builder = req_builder.header("Authorization", value);
593    };
594    if let Some(ref apikey) = configuration.api_key {
595        let key = apikey.key.clone();
596        let value = match apikey.prefix {
597            Some(ref prefix) => format!("{} {}", prefix, key),
598            None => key,
599        };
600        req_builder = req_builder.header("CSRFPreventionToken", value);
601    };
602
603    let req = req_builder.build()?;
604    let resp = configuration.client.execute(req).await?;
605
606    let status = resp.status();
607    let content_type = resp
608        .headers()
609        .get("content-type")
610        .and_then(|v| v.to_str().ok())
611        .unwrap_or("application/octet-stream");
612    let content_type = super::ContentType::from(content_type);
613
614    if !status.is_client_error() && !status.is_server_error() {
615        let content = resp.text().await?;
616        match content_type {
617            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
618            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::AccessUsersRemoveTokenResponse`"))),
619            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::AccessUsersRemoveTokenResponse`")))),
620        }
621    } else {
622        let content = resp.text().await?;
623        let entity: Option<AccessUsersRemoveTokenError> = serde_json::from_str(&content).ok();
624        Err(Error::ResponseError(ResponseContent { status, content, entity }))
625    }
626}
627
628/// Get user API tokens.
629pub async fn access_users_token_index(configuration: &configuration::Configuration, userid: &str) -> Result<models::AccessUsersTokenIndexResponse, Error<AccessUsersTokenIndexError>> {
630    // add a prefix to parameters to efficiently prevent name collisions
631    let p_path_userid = userid;
632
633    let uri_str = format!("{}/access/users/{userid}/token", configuration.base_path, userid=crate::apis::urlencode(p_path_userid));
634    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
635
636    if let Some(ref user_agent) = configuration.user_agent {
637        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
638    }
639    if let Some(ref apikey) = configuration.api_key {
640        let key = apikey.key.clone();
641        let value = match apikey.prefix {
642            Some(ref prefix) => format!("{} {}", prefix, key),
643            None => key,
644        };
645        req_builder = req_builder.header("Authorization", value);
646    };
647    if let Some(ref apikey) = configuration.api_key {
648        let key = apikey.key.clone();
649        let value = match apikey.prefix {
650            Some(ref prefix) => format!("{} {}", prefix, key),
651            None => key,
652        };
653        req_builder = req_builder.header("CSRFPreventionToken", value);
654    };
655
656    let req = req_builder.build()?;
657    let resp = configuration.client.execute(req).await?;
658
659    let status = resp.status();
660    let content_type = resp
661        .headers()
662        .get("content-type")
663        .and_then(|v| v.to_str().ok())
664        .unwrap_or("application/octet-stream");
665    let content_type = super::ContentType::from(content_type);
666
667    if !status.is_client_error() && !status.is_server_error() {
668        let content = resp.text().await?;
669        match content_type {
670            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
671            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::AccessUsersTokenIndexResponse`"))),
672            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::AccessUsersTokenIndexResponse`")))),
673        }
674    } else {
675        let content = resp.text().await?;
676        let entity: Option<AccessUsersTokenIndexError> = serde_json::from_str(&content).ok();
677        Err(Error::ResponseError(ResponseContent { status, content, entity }))
678    }
679}
680
681/// Unlock a user's TFA authentication.
682pub async fn access_users_unlock_tfa(configuration: &configuration::Configuration, userid: &str) -> Result<models::AccessUsersUnlockTfaResponse, Error<AccessUsersUnlockTfaError>> {
683    // add a prefix to parameters to efficiently prevent name collisions
684    let p_path_userid = userid;
685
686    let uri_str = format!("{}/access/users/{userid}/unlock-tfa", configuration.base_path, userid=crate::apis::urlencode(p_path_userid));
687    let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
688
689    if let Some(ref user_agent) = configuration.user_agent {
690        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
691    }
692    if let Some(ref apikey) = configuration.api_key {
693        let key = apikey.key.clone();
694        let value = match apikey.prefix {
695            Some(ref prefix) => format!("{} {}", prefix, key),
696            None => key,
697        };
698        req_builder = req_builder.header("Authorization", value);
699    };
700    if let Some(ref apikey) = configuration.api_key {
701        let key = apikey.key.clone();
702        let value = match apikey.prefix {
703            Some(ref prefix) => format!("{} {}", prefix, key),
704            None => key,
705        };
706        req_builder = req_builder.header("CSRFPreventionToken", value);
707    };
708
709    let req = req_builder.build()?;
710    let resp = configuration.client.execute(req).await?;
711
712    let status = resp.status();
713    let content_type = resp
714        .headers()
715        .get("content-type")
716        .and_then(|v| v.to_str().ok())
717        .unwrap_or("application/octet-stream");
718    let content_type = super::ContentType::from(content_type);
719
720    if !status.is_client_error() && !status.is_server_error() {
721        let content = resp.text().await?;
722        match content_type {
723            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
724            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::AccessUsersUnlockTfaResponse`"))),
725            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::AccessUsersUnlockTfaResponse`")))),
726        }
727    } else {
728        let content = resp.text().await?;
729        let entity: Option<AccessUsersUnlockTfaError> = serde_json::from_str(&content).ok();
730        Err(Error::ResponseError(ResponseContent { status, content, entity }))
731    }
732}
733
734/// Update API token for a specific user. NOTE: when 'regenerate' is set, the returned token value needs to be stored as it cannot be retrieved afterwards!
735pub async fn access_users_update_token_info(configuration: &configuration::Configuration, tokenid: &str, userid: &str, access_users_update_token_info_request: Option<models::AccessUsersUpdateTokenInfoRequest>) -> Result<models::AccessUsersUpdateTokenInfoResponse, Error<AccessUsersUpdateTokenInfoError>> {
736    // add a prefix to parameters to efficiently prevent name collisions
737    let p_path_tokenid = tokenid;
738    let p_path_userid = userid;
739    let p_body_access_users_update_token_info_request = access_users_update_token_info_request;
740
741    let uri_str = format!("{}/access/users/{userid}/token/{tokenid}", configuration.base_path, tokenid=crate::apis::urlencode(p_path_tokenid), userid=crate::apis::urlencode(p_path_userid));
742    let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
743
744    if let Some(ref user_agent) = configuration.user_agent {
745        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
746    }
747    if let Some(ref apikey) = configuration.api_key {
748        let key = apikey.key.clone();
749        let value = match apikey.prefix {
750            Some(ref prefix) => format!("{} {}", prefix, key),
751            None => key,
752        };
753        req_builder = req_builder.header("Authorization", value);
754    };
755    if let Some(ref apikey) = configuration.api_key {
756        let key = apikey.key.clone();
757        let value = match apikey.prefix {
758            Some(ref prefix) => format!("{} {}", prefix, key),
759            None => key,
760        };
761        req_builder = req_builder.header("CSRFPreventionToken", value);
762    };
763    req_builder = req_builder.json(&p_body_access_users_update_token_info_request);
764
765    let req = req_builder.build()?;
766    let resp = configuration.client.execute(req).await?;
767
768    let status = resp.status();
769    let content_type = resp
770        .headers()
771        .get("content-type")
772        .and_then(|v| v.to_str().ok())
773        .unwrap_or("application/octet-stream");
774    let content_type = super::ContentType::from(content_type);
775
776    if !status.is_client_error() && !status.is_server_error() {
777        let content = resp.text().await?;
778        match content_type {
779            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
780            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::AccessUsersUpdateTokenInfoResponse`"))),
781            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::AccessUsersUpdateTokenInfoResponse`")))),
782        }
783    } else {
784        let content = resp.text().await?;
785        let entity: Option<AccessUsersUpdateTokenInfoError> = serde_json::from_str(&content).ok();
786        Err(Error::ResponseError(ResponseContent { status, content, entity }))
787    }
788}
789
790/// Update user configuration.
791pub async fn access_users_update_user(configuration: &configuration::Configuration, userid: &str, access_users_update_user_request: Option<models::AccessUsersUpdateUserRequest>) -> Result<models::AccessUsersUpdateUserResponse, Error<AccessUsersUpdateUserError>> {
792    // add a prefix to parameters to efficiently prevent name collisions
793    let p_path_userid = userid;
794    let p_body_access_users_update_user_request = access_users_update_user_request;
795
796    let uri_str = format!("{}/access/users/{userid}", configuration.base_path, userid=crate::apis::urlencode(p_path_userid));
797    let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
798
799    if let Some(ref user_agent) = configuration.user_agent {
800        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
801    }
802    if let Some(ref apikey) = configuration.api_key {
803        let key = apikey.key.clone();
804        let value = match apikey.prefix {
805            Some(ref prefix) => format!("{} {}", prefix, key),
806            None => key,
807        };
808        req_builder = req_builder.header("Authorization", value);
809    };
810    if let Some(ref apikey) = configuration.api_key {
811        let key = apikey.key.clone();
812        let value = match apikey.prefix {
813            Some(ref prefix) => format!("{} {}", prefix, key),
814            None => key,
815        };
816        req_builder = req_builder.header("CSRFPreventionToken", value);
817    };
818    req_builder = req_builder.json(&p_body_access_users_update_user_request);
819
820    let req = req_builder.build()?;
821    let resp = configuration.client.execute(req).await?;
822
823    let status = resp.status();
824    let content_type = resp
825        .headers()
826        .get("content-type")
827        .and_then(|v| v.to_str().ok())
828        .unwrap_or("application/octet-stream");
829    let content_type = super::ContentType::from(content_type);
830
831    if !status.is_client_error() && !status.is_server_error() {
832        let content = resp.text().await?;
833        match content_type {
834            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
835            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::AccessUsersUpdateUserResponse`"))),
836            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::AccessUsersUpdateUserResponse`")))),
837        }
838    } else {
839        let content = resp.text().await?;
840        let entity: Option<AccessUsersUpdateUserError> = serde_json::from_str(&content).ok();
841        Err(Error::ResponseError(ResponseContent { status, content, entity }))
842    }
843}
844