1use reqwest;
13use serde::{Deserialize, Serialize, de::Error as _};
14use crate::{apis::ResponseContent, models};
15use super::{Error, configuration, ContentType};
16
17
18#[derive(Debug, Clone, Serialize, Deserialize)]
20#[serde(untagged)]
21pub enum AccessTfaCreateTfaError {
22 Status400(models::PbsError),
23 Status401(models::PbsError),
24 Status403(models::PbsError),
25 Status404(models::PbsError),
26 Status500(models::PbsError),
27 Status501(models::PbsError),
28 Status503(models::PbsError),
29 UnknownValue(serde_json::Value),
30}
31
32#[derive(Debug, Clone, Serialize, Deserialize)]
34#[serde(untagged)]
35pub enum AccessTfaDeleteTfaError {
36 Status400(models::PbsError),
37 Status401(models::PbsError),
38 Status403(models::PbsError),
39 Status404(models::PbsError),
40 Status500(models::PbsError),
41 Status501(models::PbsError),
42 Status503(models::PbsError),
43 UnknownValue(serde_json::Value),
44}
45
46#[derive(Debug, Clone, Serialize, Deserialize)]
48#[serde(untagged)]
49pub enum AccessTfaGetAccessTfaByUseridError {
50 Status400(models::PbsError),
51 Status401(models::PbsError),
52 Status403(models::PbsError),
53 Status404(models::PbsError),
54 Status500(models::PbsError),
55 Status501(models::PbsError),
56 Status503(models::PbsError),
57 UnknownValue(serde_json::Value),
58}
59
60#[derive(Debug, Clone, Serialize, Deserialize)]
62#[serde(untagged)]
63pub enum AccessTfaGetAccessTfaByUseridByIdError {
64 Status400(models::PbsError),
65 Status401(models::PbsError),
66 Status403(models::PbsError),
67 Status404(models::PbsError),
68 Status500(models::PbsError),
69 Status501(models::PbsError),
70 Status503(models::PbsError),
71 UnknownValue(serde_json::Value),
72}
73
74#[derive(Debug, Clone, Serialize, Deserialize)]
76#[serde(untagged)]
77pub enum AccessTfaGetTfaError {
78 Status400(models::PbsError),
79 Status401(models::PbsError),
80 Status403(models::PbsError),
81 Status404(models::PbsError),
82 Status500(models::PbsError),
83 Status501(models::PbsError),
84 Status503(models::PbsError),
85 UnknownValue(serde_json::Value),
86}
87
88#[derive(Debug, Clone, Serialize, Deserialize)]
90#[serde(untagged)]
91pub enum AccessTfaUpdateTfaError {
92 Status400(models::PbsError),
93 Status401(models::PbsError),
94 Status403(models::PbsError),
95 Status404(models::PbsError),
96 Status500(models::PbsError),
97 Status501(models::PbsError),
98 Status503(models::PbsError),
99 UnknownValue(serde_json::Value),
100}
101
102
103pub async fn access_tfa_create_tfa(configuration: &configuration::Configuration, userid: &str, access_tfa_create_tfa_request: models::AccessTfaCreateTfaRequest) -> Result<models::AccessTfaCreateTfaResponse, Error<AccessTfaCreateTfaError>> {
105 let p_path_userid = userid;
107 let p_body_access_tfa_create_tfa_request = access_tfa_create_tfa_request;
108
109 let uri_str = format!("{}/access/tfa/{userid}", configuration.base_path, userid=crate::apis::urlencode(p_path_userid));
110 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
111
112 if let Some(ref user_agent) = configuration.user_agent {
113 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
114 }
115 if let Some(ref apikey) = configuration.api_key {
116 let key = apikey.key.clone();
117 let value = match apikey.prefix {
118 Some(ref prefix) => format!("{} {}", prefix, key),
119 None => key,
120 };
121 req_builder = req_builder.header("Authorization", value);
122 };
123 if let Some(ref apikey) = configuration.api_key {
124 let key = apikey.key.clone();
125 let value = match apikey.prefix {
126 Some(ref prefix) => format!("{} {}", prefix, key),
127 None => key,
128 };
129 req_builder = req_builder.header("CSRFPreventionToken", value);
130 };
131 req_builder = req_builder.json(&p_body_access_tfa_create_tfa_request);
132
133 let req = req_builder.build()?;
134 let resp = configuration.client.execute(req).await?;
135
136 let status = resp.status();
137 let content_type = resp
138 .headers()
139 .get("content-type")
140 .and_then(|v| v.to_str().ok())
141 .unwrap_or("application/octet-stream");
142 let content_type = super::ContentType::from(content_type);
143
144 if !status.is_client_error() && !status.is_server_error() {
145 let content = resp.text().await?;
146 match content_type {
147 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
148 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::AccessTfaCreateTfaResponse`"))),
149 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::AccessTfaCreateTfaResponse`")))),
150 }
151 } else {
152 let content = resp.text().await?;
153 let entity: Option<AccessTfaCreateTfaError> = serde_json::from_str(&content).ok();
154 Err(Error::ResponseError(ResponseContent { status, content, entity }))
155 }
156}
157
158pub async fn access_tfa_delete_tfa(configuration: &configuration::Configuration, id: &str, userid: &str, password: Option<&str>) -> Result<models::AccessTfaDeleteTfaResponse, Error<AccessTfaDeleteTfaError>> {
160 let p_path_id = id;
162 let p_path_userid = userid;
163 let p_query_password = password;
164
165 let uri_str = format!("{}/access/tfa/{userid}/{id}", configuration.base_path, id=crate::apis::urlencode(p_path_id), userid=crate::apis::urlencode(p_path_userid));
166 let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
167
168 if let Some(ref param_value) = p_query_password {
169 req_builder = req_builder.query(&[("password", ¶m_value.to_string())]);
170 }
171 if let Some(ref user_agent) = configuration.user_agent {
172 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
173 }
174 if let Some(ref apikey) = configuration.api_key {
175 let key = apikey.key.clone();
176 let value = match apikey.prefix {
177 Some(ref prefix) => format!("{} {}", prefix, key),
178 None => key,
179 };
180 req_builder = req_builder.header("Authorization", value);
181 };
182 if let Some(ref apikey) = configuration.api_key {
183 let key = apikey.key.clone();
184 let value = match apikey.prefix {
185 Some(ref prefix) => format!("{} {}", prefix, key),
186 None => key,
187 };
188 req_builder = req_builder.header("CSRFPreventionToken", value);
189 };
190
191 let req = req_builder.build()?;
192 let resp = configuration.client.execute(req).await?;
193
194 let status = resp.status();
195 let content_type = resp
196 .headers()
197 .get("content-type")
198 .and_then(|v| v.to_str().ok())
199 .unwrap_or("application/octet-stream");
200 let content_type = super::ContentType::from(content_type);
201
202 if !status.is_client_error() && !status.is_server_error() {
203 let content = resp.text().await?;
204 match content_type {
205 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
206 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::AccessTfaDeleteTfaResponse`"))),
207 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::AccessTfaDeleteTfaResponse`")))),
208 }
209 } else {
210 let content = resp.text().await?;
211 let entity: Option<AccessTfaDeleteTfaError> = serde_json::from_str(&content).ok();
212 Err(Error::ResponseError(ResponseContent { status, content, entity }))
213 }
214}
215
216pub async fn access_tfa_get_access_tfa_by_userid(configuration: &configuration::Configuration, userid: &str) -> Result<models::AccessTfaGetAccessTfaByUseridResponse, Error<AccessTfaGetAccessTfaByUseridError>> {
218 let p_path_userid = userid;
220
221 let uri_str = format!("{}/access/tfa/{userid}", configuration.base_path, userid=crate::apis::urlencode(p_path_userid));
222 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
223
224 if let Some(ref user_agent) = configuration.user_agent {
225 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
226 }
227 if let Some(ref apikey) = configuration.api_key {
228 let key = apikey.key.clone();
229 let value = match apikey.prefix {
230 Some(ref prefix) => format!("{} {}", prefix, key),
231 None => key,
232 };
233 req_builder = req_builder.header("Authorization", value);
234 };
235 if let Some(ref apikey) = configuration.api_key {
236 let key = apikey.key.clone();
237 let value = match apikey.prefix {
238 Some(ref prefix) => format!("{} {}", prefix, key),
239 None => key,
240 };
241 req_builder = req_builder.header("CSRFPreventionToken", value);
242 };
243
244 let req = req_builder.build()?;
245 let resp = configuration.client.execute(req).await?;
246
247 let status = resp.status();
248 let content_type = resp
249 .headers()
250 .get("content-type")
251 .and_then(|v| v.to_str().ok())
252 .unwrap_or("application/octet-stream");
253 let content_type = super::ContentType::from(content_type);
254
255 if !status.is_client_error() && !status.is_server_error() {
256 let content = resp.text().await?;
257 match content_type {
258 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
259 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::AccessTfaGetAccessTfaByUseridResponse`"))),
260 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::AccessTfaGetAccessTfaByUseridResponse`")))),
261 }
262 } else {
263 let content = resp.text().await?;
264 let entity: Option<AccessTfaGetAccessTfaByUseridError> = serde_json::from_str(&content).ok();
265 Err(Error::ResponseError(ResponseContent { status, content, entity }))
266 }
267}
268
269pub async fn access_tfa_get_access_tfa_by_userid_by_id(configuration: &configuration::Configuration, id: &str, userid: &str) -> Result<models::AccessTfaGetAccessTfaByUseridByIdResponse, Error<AccessTfaGetAccessTfaByUseridByIdError>> {
271 let p_path_id = id;
273 let p_path_userid = userid;
274
275 let uri_str = format!("{}/access/tfa/{userid}/{id}", configuration.base_path, id=crate::apis::urlencode(p_path_id), userid=crate::apis::urlencode(p_path_userid));
276 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
277
278 if let Some(ref user_agent) = configuration.user_agent {
279 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
280 }
281 if let Some(ref apikey) = configuration.api_key {
282 let key = apikey.key.clone();
283 let value = match apikey.prefix {
284 Some(ref prefix) => format!("{} {}", prefix, key),
285 None => key,
286 };
287 req_builder = req_builder.header("Authorization", value);
288 };
289 if let Some(ref apikey) = configuration.api_key {
290 let key = apikey.key.clone();
291 let value = match apikey.prefix {
292 Some(ref prefix) => format!("{} {}", prefix, key),
293 None => key,
294 };
295 req_builder = req_builder.header("CSRFPreventionToken", value);
296 };
297
298 let req = req_builder.build()?;
299 let resp = configuration.client.execute(req).await?;
300
301 let status = resp.status();
302 let content_type = resp
303 .headers()
304 .get("content-type")
305 .and_then(|v| v.to_str().ok())
306 .unwrap_or("application/octet-stream");
307 let content_type = super::ContentType::from(content_type);
308
309 if !status.is_client_error() && !status.is_server_error() {
310 let content = resp.text().await?;
311 match content_type {
312 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
313 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::AccessTfaGetAccessTfaByUseridByIdResponse`"))),
314 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::AccessTfaGetAccessTfaByUseridByIdResponse`")))),
315 }
316 } else {
317 let content = resp.text().await?;
318 let entity: Option<AccessTfaGetAccessTfaByUseridByIdError> = serde_json::from_str(&content).ok();
319 Err(Error::ResponseError(ResponseContent { status, content, entity }))
320 }
321}
322
323pub async fn access_tfa_get_tfa(configuration: &configuration::Configuration, ) -> Result<models::AccessTfaGetTfaResponse, Error<AccessTfaGetTfaError>> {
325
326 let uri_str = format!("{}/access/tfa", configuration.base_path);
327 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
328
329 if let Some(ref user_agent) = configuration.user_agent {
330 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
331 }
332 if let Some(ref apikey) = configuration.api_key {
333 let key = apikey.key.clone();
334 let value = match apikey.prefix {
335 Some(ref prefix) => format!("{} {}", prefix, key),
336 None => key,
337 };
338 req_builder = req_builder.header("Authorization", value);
339 };
340 if let Some(ref apikey) = configuration.api_key {
341 let key = apikey.key.clone();
342 let value = match apikey.prefix {
343 Some(ref prefix) => format!("{} {}", prefix, key),
344 None => key,
345 };
346 req_builder = req_builder.header("CSRFPreventionToken", value);
347 };
348
349 let req = req_builder.build()?;
350 let resp = configuration.client.execute(req).await?;
351
352 let status = resp.status();
353 let content_type = resp
354 .headers()
355 .get("content-type")
356 .and_then(|v| v.to_str().ok())
357 .unwrap_or("application/octet-stream");
358 let content_type = super::ContentType::from(content_type);
359
360 if !status.is_client_error() && !status.is_server_error() {
361 let content = resp.text().await?;
362 match content_type {
363 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
364 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::AccessTfaGetTfaResponse`"))),
365 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::AccessTfaGetTfaResponse`")))),
366 }
367 } else {
368 let content = resp.text().await?;
369 let entity: Option<AccessTfaGetTfaError> = serde_json::from_str(&content).ok();
370 Err(Error::ResponseError(ResponseContent { status, content, entity }))
371 }
372}
373
374pub async fn access_tfa_update_tfa(configuration: &configuration::Configuration, id: &str, userid: &str, access_tfa_update_tfa_request: Option<models::AccessTfaUpdateTfaRequest>) -> Result<models::AccessTfaUpdateTfaResponse, Error<AccessTfaUpdateTfaError>> {
376 let p_path_id = id;
378 let p_path_userid = userid;
379 let p_body_access_tfa_update_tfa_request = access_tfa_update_tfa_request;
380
381 let uri_str = format!("{}/access/tfa/{userid}/{id}", configuration.base_path, id=crate::apis::urlencode(p_path_id), userid=crate::apis::urlencode(p_path_userid));
382 let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
383
384 if let Some(ref user_agent) = configuration.user_agent {
385 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
386 }
387 if let Some(ref apikey) = configuration.api_key {
388 let key = apikey.key.clone();
389 let value = match apikey.prefix {
390 Some(ref prefix) => format!("{} {}", prefix, key),
391 None => key,
392 };
393 req_builder = req_builder.header("Authorization", value);
394 };
395 if let Some(ref apikey) = configuration.api_key {
396 let key = apikey.key.clone();
397 let value = match apikey.prefix {
398 Some(ref prefix) => format!("{} {}", prefix, key),
399 None => key,
400 };
401 req_builder = req_builder.header("CSRFPreventionToken", value);
402 };
403 req_builder = req_builder.json(&p_body_access_tfa_update_tfa_request);
404
405 let req = req_builder.build()?;
406 let resp = configuration.client.execute(req).await?;
407
408 let status = resp.status();
409 let content_type = resp
410 .headers()
411 .get("content-type")
412 .and_then(|v| v.to_str().ok())
413 .unwrap_or("application/octet-stream");
414 let content_type = super::ContentType::from(content_type);
415
416 if !status.is_client_error() && !status.is_server_error() {
417 let content = resp.text().await?;
418 match content_type {
419 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
420 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::AccessTfaUpdateTfaResponse`"))),
421 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::AccessTfaUpdateTfaResponse`")))),
422 }
423 } else {
424 let content = resp.text().await?;
425 let entity: Option<AccessTfaUpdateTfaError> = serde_json::from_str(&content).ok();
426 Err(Error::ResponseError(ResponseContent { status, content, entity }))
427 }
428}
429