1use std::sync::Arc;
12
13use async_trait::async_trait;
14#[cfg(feature = "mockall")]
15use mockall::automock;
16use reqwest;
17use serde::{Deserialize, Serialize, de::Error as _};
18
19use super::{Error, configuration};
20use crate::{
21 apis::{AuthRequired, ContentType, ResponseContent},
22 models,
23};
24
25#[cfg_attr(feature = "mockall", automock)]
26#[cfg_attr(target_arch = "wasm32", async_trait(?Send))]
27#[cfg_attr(not(target_arch = "wasm32"), async_trait)]
28pub trait TwoFactorApi: Send + Sync {
29 async fn delete_web_authn<'a>(
31 &self,
32 two_factor_web_authn_delete_request_model: Option<
33 models::TwoFactorWebAuthnDeleteRequestModel,
34 >,
35 ) -> Result<models::TwoFactorWebAuthnResponseModel, Error<DeleteWebAuthnError>>;
36
37 async fn disable_authenticator<'a>(
39 &self,
40 two_factor_authenticator_disable_request_model: Option<
41 models::TwoFactorAuthenticatorDisableRequestModel,
42 >,
43 ) -> Result<models::TwoFactorProviderResponseModel, Error<DisableAuthenticatorError>>;
44
45 async fn get(
47 &self,
48 ) -> Result<models::TwoFactorProviderResponseModelListResponseModel, Error<GetError>>;
49
50 async fn get_authenticator<'a>(
52 &self,
53 secret_verification_request_model: Option<models::SecretVerificationRequestModel>,
54 ) -> Result<models::TwoFactorAuthenticatorResponseModel, Error<GetAuthenticatorError>>;
55
56 async fn get_duo<'a>(
58 &self,
59 secret_verification_request_model: Option<models::SecretVerificationRequestModel>,
60 ) -> Result<models::TwoFactorDuoResponseModel, Error<GetDuoError>>;
61
62 async fn get_email<'a>(
64 &self,
65 secret_verification_request_model: Option<models::SecretVerificationRequestModel>,
66 ) -> Result<models::TwoFactorEmailResponseModel, Error<GetEmailError>>;
67
68 async fn get_organization<'a>(
70 &self,
71 id: &'a str,
72 ) -> Result<models::TwoFactorProviderResponseModelListResponseModel, Error<GetOrganizationError>>;
73
74 async fn get_organization_duo<'a>(
76 &self,
77 id: &'a str,
78 secret_verification_request_model: Option<models::SecretVerificationRequestModel>,
79 ) -> Result<models::TwoFactorDuoResponseModel, Error<GetOrganizationDuoError>>;
80
81 async fn get_recover<'a>(
83 &self,
84 secret_verification_request_model: Option<models::SecretVerificationRequestModel>,
85 ) -> Result<models::TwoFactorRecoverResponseModel, Error<GetRecoverError>>;
86
87 async fn get_web_authn<'a>(
89 &self,
90 secret_verification_request_model: Option<models::SecretVerificationRequestModel>,
91 ) -> Result<models::TwoFactorWebAuthnResponseModel, Error<GetWebAuthnError>>;
92
93 async fn get_yubi_key<'a>(
95 &self,
96 secret_verification_request_model: Option<models::SecretVerificationRequestModel>,
97 ) -> Result<models::TwoFactorYubiKeyResponseModel, Error<GetYubiKeyError>>;
98
99 async fn put_authenticator<'a>(
101 &self,
102 update_two_factor_authenticator_request_model: Option<
103 models::UpdateTwoFactorAuthenticatorRequestModel,
104 >,
105 ) -> Result<models::TwoFactorAuthenticatorResponseModel, Error<PutAuthenticatorError>>;
106
107 async fn put_disable<'a>(
109 &self,
110 two_factor_provider_request_model: Option<models::TwoFactorProviderRequestModel>,
111 ) -> Result<models::TwoFactorProviderResponseModel, Error<PutDisableError>>;
112
113 async fn put_duo<'a>(
115 &self,
116 update_two_factor_duo_request_model: Option<models::UpdateTwoFactorDuoRequestModel>,
117 ) -> Result<models::TwoFactorDuoResponseModel, Error<PutDuoError>>;
118
119 async fn put_email<'a>(
121 &self,
122 update_two_factor_email_request_model: Option<models::UpdateTwoFactorEmailRequestModel>,
123 ) -> Result<models::TwoFactorEmailResponseModel, Error<PutEmailError>>;
124
125 async fn put_organization_disable<'a>(
127 &self,
128 id: &'a str,
129 two_factor_provider_request_model: Option<models::TwoFactorProviderRequestModel>,
130 ) -> Result<models::TwoFactorProviderResponseModel, Error<PutOrganizationDisableError>>;
131
132 async fn put_organization_duo<'a>(
134 &self,
135 id: &'a str,
136 update_two_factor_duo_request_model: Option<models::UpdateTwoFactorDuoRequestModel>,
137 ) -> Result<models::TwoFactorDuoResponseModel, Error<PutOrganizationDuoError>>;
138
139 async fn put_web_authn<'a>(
141 &self,
142 two_factor_web_authn_request_model: Option<models::TwoFactorWebAuthnRequestModel>,
143 ) -> Result<models::TwoFactorWebAuthnResponseModel, Error<PutWebAuthnError>>;
144
145 async fn put_yubi_key<'a>(
147 &self,
148 update_two_factor_yubico_otp_request_model: Option<
149 models::UpdateTwoFactorYubicoOtpRequestModel,
150 >,
151 ) -> Result<models::TwoFactorYubiKeyResponseModel, Error<PutYubiKeyError>>;
152
153 async fn send_email<'a>(
155 &self,
156 two_factor_email_request_model: Option<models::TwoFactorEmailRequestModel>,
157 ) -> Result<(), Error<SendEmailError>>;
158
159 async fn send_email_login<'a>(
161 &self,
162 two_factor_email_request_model: Option<models::TwoFactorEmailRequestModel>,
163 ) -> Result<(), Error<SendEmailLoginError>>;
164}
165
166pub struct TwoFactorApiClient {
167 configuration: Arc<configuration::Configuration>,
168}
169
170impl TwoFactorApiClient {
171 pub fn new(configuration: Arc<configuration::Configuration>) -> Self {
172 Self { configuration }
173 }
174}
175
176#[cfg_attr(target_arch = "wasm32", async_trait(?Send))]
177#[cfg_attr(not(target_arch = "wasm32"), async_trait)]
178impl TwoFactorApi for TwoFactorApiClient {
179 async fn delete_web_authn<'a>(
180 &self,
181 two_factor_web_authn_delete_request_model: Option<
182 models::TwoFactorWebAuthnDeleteRequestModel,
183 >,
184 ) -> Result<models::TwoFactorWebAuthnResponseModel, Error<DeleteWebAuthnError>> {
185 let local_var_configuration = &self.configuration;
186
187 let local_var_client = &local_var_configuration.client;
188
189 let local_var_uri_str =
190 format!("{}/two-factor/webauthn", local_var_configuration.base_path);
191 let mut local_var_req_builder =
192 local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str());
193
194 if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
195 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
196 };
197 local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
198 local_var_req_builder =
199 local_var_req_builder.json(&two_factor_web_authn_delete_request_model);
200
201 let local_var_req = local_var_req_builder.build()?;
202 let local_var_resp = local_var_client.execute(local_var_req).await?;
203
204 let local_var_status = local_var_resp.status();
205 let local_var_content_type = local_var_resp
206 .headers()
207 .get("content-type")
208 .and_then(|v| v.to_str().ok())
209 .unwrap_or("application/octet-stream");
210 let local_var_content_type = super::ContentType::from(local_var_content_type);
211 let local_var_content = local_var_resp.text().await?;
212
213 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
214 match local_var_content_type {
215 ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from),
216 ContentType::Text => {
217 return Err(Error::from(serde_json::Error::custom(
218 "Received `text/plain` content type response that cannot be converted to `models::TwoFactorWebAuthnResponseModel`",
219 )));
220 }
221 ContentType::Unsupported(local_var_unknown_type) => {
222 return Err(Error::from(serde_json::Error::custom(format!(
223 "Received `{local_var_unknown_type}` content type response that cannot be converted to `models::TwoFactorWebAuthnResponseModel`"
224 ))));
225 }
226 }
227 } else {
228 let local_var_entity: Option<DeleteWebAuthnError> =
229 serde_json::from_str(&local_var_content).ok();
230 let local_var_error = ResponseContent {
231 status: local_var_status,
232 content: local_var_content,
233 entity: local_var_entity,
234 };
235 Err(Error::ResponseError(local_var_error))
236 }
237 }
238
239 async fn disable_authenticator<'a>(
240 &self,
241 two_factor_authenticator_disable_request_model: Option<
242 models::TwoFactorAuthenticatorDisableRequestModel,
243 >,
244 ) -> Result<models::TwoFactorProviderResponseModel, Error<DisableAuthenticatorError>> {
245 let local_var_configuration = &self.configuration;
246
247 let local_var_client = &local_var_configuration.client;
248
249 let local_var_uri_str = format!(
250 "{}/two-factor/authenticator",
251 local_var_configuration.base_path
252 );
253 let mut local_var_req_builder =
254 local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str());
255
256 if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
257 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
258 };
259 local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
260 local_var_req_builder =
261 local_var_req_builder.json(&two_factor_authenticator_disable_request_model);
262
263 let local_var_req = local_var_req_builder.build()?;
264 let local_var_resp = local_var_client.execute(local_var_req).await?;
265
266 let local_var_status = local_var_resp.status();
267 let local_var_content_type = local_var_resp
268 .headers()
269 .get("content-type")
270 .and_then(|v| v.to_str().ok())
271 .unwrap_or("application/octet-stream");
272 let local_var_content_type = super::ContentType::from(local_var_content_type);
273 let local_var_content = local_var_resp.text().await?;
274
275 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
276 match local_var_content_type {
277 ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from),
278 ContentType::Text => {
279 return Err(Error::from(serde_json::Error::custom(
280 "Received `text/plain` content type response that cannot be converted to `models::TwoFactorProviderResponseModel`",
281 )));
282 }
283 ContentType::Unsupported(local_var_unknown_type) => {
284 return Err(Error::from(serde_json::Error::custom(format!(
285 "Received `{local_var_unknown_type}` content type response that cannot be converted to `models::TwoFactorProviderResponseModel`"
286 ))));
287 }
288 }
289 } else {
290 let local_var_entity: Option<DisableAuthenticatorError> =
291 serde_json::from_str(&local_var_content).ok();
292 let local_var_error = ResponseContent {
293 status: local_var_status,
294 content: local_var_content,
295 entity: local_var_entity,
296 };
297 Err(Error::ResponseError(local_var_error))
298 }
299 }
300
301 async fn get(
302 &self,
303 ) -> Result<models::TwoFactorProviderResponseModelListResponseModel, Error<GetError>> {
304 let local_var_configuration = &self.configuration;
305
306 let local_var_client = &local_var_configuration.client;
307
308 let local_var_uri_str = format!("{}/two-factor", local_var_configuration.base_path);
309 let mut local_var_req_builder =
310 local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
311
312 if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
313 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
314 };
315 local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
316
317 let local_var_req = local_var_req_builder.build()?;
318 let local_var_resp = local_var_client.execute(local_var_req).await?;
319
320 let local_var_status = local_var_resp.status();
321 let local_var_content_type = local_var_resp
322 .headers()
323 .get("content-type")
324 .and_then(|v| v.to_str().ok())
325 .unwrap_or("application/octet-stream");
326 let local_var_content_type = super::ContentType::from(local_var_content_type);
327 let local_var_content = local_var_resp.text().await?;
328
329 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
330 match local_var_content_type {
331 ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from),
332 ContentType::Text => {
333 return Err(Error::from(serde_json::Error::custom(
334 "Received `text/plain` content type response that cannot be converted to `models::TwoFactorProviderResponseModelListResponseModel`",
335 )));
336 }
337 ContentType::Unsupported(local_var_unknown_type) => {
338 return Err(Error::from(serde_json::Error::custom(format!(
339 "Received `{local_var_unknown_type}` content type response that cannot be converted to `models::TwoFactorProviderResponseModelListResponseModel`"
340 ))));
341 }
342 }
343 } else {
344 let local_var_entity: Option<GetError> = serde_json::from_str(&local_var_content).ok();
345 let local_var_error = ResponseContent {
346 status: local_var_status,
347 content: local_var_content,
348 entity: local_var_entity,
349 };
350 Err(Error::ResponseError(local_var_error))
351 }
352 }
353
354 async fn get_authenticator<'a>(
355 &self,
356 secret_verification_request_model: Option<models::SecretVerificationRequestModel>,
357 ) -> Result<models::TwoFactorAuthenticatorResponseModel, Error<GetAuthenticatorError>> {
358 let local_var_configuration = &self.configuration;
359
360 let local_var_client = &local_var_configuration.client;
361
362 let local_var_uri_str = format!(
363 "{}/two-factor/get-authenticator",
364 local_var_configuration.base_path
365 );
366 let mut local_var_req_builder =
367 local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
368
369 if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
370 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
371 };
372 local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
373 local_var_req_builder = local_var_req_builder.json(&secret_verification_request_model);
374
375 let local_var_req = local_var_req_builder.build()?;
376 let local_var_resp = local_var_client.execute(local_var_req).await?;
377
378 let local_var_status = local_var_resp.status();
379 let local_var_content_type = local_var_resp
380 .headers()
381 .get("content-type")
382 .and_then(|v| v.to_str().ok())
383 .unwrap_or("application/octet-stream");
384 let local_var_content_type = super::ContentType::from(local_var_content_type);
385 let local_var_content = local_var_resp.text().await?;
386
387 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
388 match local_var_content_type {
389 ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from),
390 ContentType::Text => {
391 return Err(Error::from(serde_json::Error::custom(
392 "Received `text/plain` content type response that cannot be converted to `models::TwoFactorAuthenticatorResponseModel`",
393 )));
394 }
395 ContentType::Unsupported(local_var_unknown_type) => {
396 return Err(Error::from(serde_json::Error::custom(format!(
397 "Received `{local_var_unknown_type}` content type response that cannot be converted to `models::TwoFactorAuthenticatorResponseModel`"
398 ))));
399 }
400 }
401 } else {
402 let local_var_entity: Option<GetAuthenticatorError> =
403 serde_json::from_str(&local_var_content).ok();
404 let local_var_error = ResponseContent {
405 status: local_var_status,
406 content: local_var_content,
407 entity: local_var_entity,
408 };
409 Err(Error::ResponseError(local_var_error))
410 }
411 }
412
413 async fn get_duo<'a>(
414 &self,
415 secret_verification_request_model: Option<models::SecretVerificationRequestModel>,
416 ) -> Result<models::TwoFactorDuoResponseModel, Error<GetDuoError>> {
417 let local_var_configuration = &self.configuration;
418
419 let local_var_client = &local_var_configuration.client;
420
421 let local_var_uri_str = format!("{}/two-factor/get-duo", local_var_configuration.base_path);
422 let mut local_var_req_builder =
423 local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
424
425 if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
426 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
427 };
428 local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
429 local_var_req_builder = local_var_req_builder.json(&secret_verification_request_model);
430
431 let local_var_req = local_var_req_builder.build()?;
432 let local_var_resp = local_var_client.execute(local_var_req).await?;
433
434 let local_var_status = local_var_resp.status();
435 let local_var_content_type = local_var_resp
436 .headers()
437 .get("content-type")
438 .and_then(|v| v.to_str().ok())
439 .unwrap_or("application/octet-stream");
440 let local_var_content_type = super::ContentType::from(local_var_content_type);
441 let local_var_content = local_var_resp.text().await?;
442
443 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
444 match local_var_content_type {
445 ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from),
446 ContentType::Text => {
447 return Err(Error::from(serde_json::Error::custom(
448 "Received `text/plain` content type response that cannot be converted to `models::TwoFactorDuoResponseModel`",
449 )));
450 }
451 ContentType::Unsupported(local_var_unknown_type) => {
452 return Err(Error::from(serde_json::Error::custom(format!(
453 "Received `{local_var_unknown_type}` content type response that cannot be converted to `models::TwoFactorDuoResponseModel`"
454 ))));
455 }
456 }
457 } else {
458 let local_var_entity: Option<GetDuoError> =
459 serde_json::from_str(&local_var_content).ok();
460 let local_var_error = ResponseContent {
461 status: local_var_status,
462 content: local_var_content,
463 entity: local_var_entity,
464 };
465 Err(Error::ResponseError(local_var_error))
466 }
467 }
468
469 async fn get_email<'a>(
470 &self,
471 secret_verification_request_model: Option<models::SecretVerificationRequestModel>,
472 ) -> Result<models::TwoFactorEmailResponseModel, Error<GetEmailError>> {
473 let local_var_configuration = &self.configuration;
474
475 let local_var_client = &local_var_configuration.client;
476
477 let local_var_uri_str =
478 format!("{}/two-factor/get-email", local_var_configuration.base_path);
479 let mut local_var_req_builder =
480 local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
481
482 if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
483 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
484 };
485 local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
486 local_var_req_builder = local_var_req_builder.json(&secret_verification_request_model);
487
488 let local_var_req = local_var_req_builder.build()?;
489 let local_var_resp = local_var_client.execute(local_var_req).await?;
490
491 let local_var_status = local_var_resp.status();
492 let local_var_content_type = local_var_resp
493 .headers()
494 .get("content-type")
495 .and_then(|v| v.to_str().ok())
496 .unwrap_or("application/octet-stream");
497 let local_var_content_type = super::ContentType::from(local_var_content_type);
498 let local_var_content = local_var_resp.text().await?;
499
500 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
501 match local_var_content_type {
502 ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from),
503 ContentType::Text => {
504 return Err(Error::from(serde_json::Error::custom(
505 "Received `text/plain` content type response that cannot be converted to `models::TwoFactorEmailResponseModel`",
506 )));
507 }
508 ContentType::Unsupported(local_var_unknown_type) => {
509 return Err(Error::from(serde_json::Error::custom(format!(
510 "Received `{local_var_unknown_type}` content type response that cannot be converted to `models::TwoFactorEmailResponseModel`"
511 ))));
512 }
513 }
514 } else {
515 let local_var_entity: Option<GetEmailError> =
516 serde_json::from_str(&local_var_content).ok();
517 let local_var_error = ResponseContent {
518 status: local_var_status,
519 content: local_var_content,
520 entity: local_var_entity,
521 };
522 Err(Error::ResponseError(local_var_error))
523 }
524 }
525
526 async fn get_organization<'a>(
527 &self,
528 id: &'a str,
529 ) -> Result<models::TwoFactorProviderResponseModelListResponseModel, Error<GetOrganizationError>>
530 {
531 let local_var_configuration = &self.configuration;
532
533 let local_var_client = &local_var_configuration.client;
534
535 let local_var_uri_str = format!(
536 "{}/organizations/{id}/two-factor",
537 local_var_configuration.base_path,
538 id = crate::apis::urlencode(id)
539 );
540 let mut local_var_req_builder =
541 local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
542
543 if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
544 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
545 };
546 local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
547
548 let local_var_req = local_var_req_builder.build()?;
549 let local_var_resp = local_var_client.execute(local_var_req).await?;
550
551 let local_var_status = local_var_resp.status();
552 let local_var_content_type = local_var_resp
553 .headers()
554 .get("content-type")
555 .and_then(|v| v.to_str().ok())
556 .unwrap_or("application/octet-stream");
557 let local_var_content_type = super::ContentType::from(local_var_content_type);
558 let local_var_content = local_var_resp.text().await?;
559
560 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
561 match local_var_content_type {
562 ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from),
563 ContentType::Text => {
564 return Err(Error::from(serde_json::Error::custom(
565 "Received `text/plain` content type response that cannot be converted to `models::TwoFactorProviderResponseModelListResponseModel`",
566 )));
567 }
568 ContentType::Unsupported(local_var_unknown_type) => {
569 return Err(Error::from(serde_json::Error::custom(format!(
570 "Received `{local_var_unknown_type}` content type response that cannot be converted to `models::TwoFactorProviderResponseModelListResponseModel`"
571 ))));
572 }
573 }
574 } else {
575 let local_var_entity: Option<GetOrganizationError> =
576 serde_json::from_str(&local_var_content).ok();
577 let local_var_error = ResponseContent {
578 status: local_var_status,
579 content: local_var_content,
580 entity: local_var_entity,
581 };
582 Err(Error::ResponseError(local_var_error))
583 }
584 }
585
586 async fn get_organization_duo<'a>(
587 &self,
588 id: &'a str,
589 secret_verification_request_model: Option<models::SecretVerificationRequestModel>,
590 ) -> Result<models::TwoFactorDuoResponseModel, Error<GetOrganizationDuoError>> {
591 let local_var_configuration = &self.configuration;
592
593 let local_var_client = &local_var_configuration.client;
594
595 let local_var_uri_str = format!(
596 "{}/organizations/{id}/two-factor/get-duo",
597 local_var_configuration.base_path,
598 id = crate::apis::urlencode(id)
599 );
600 let mut local_var_req_builder =
601 local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
602
603 if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
604 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
605 };
606 local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
607 local_var_req_builder = local_var_req_builder.json(&secret_verification_request_model);
608
609 let local_var_req = local_var_req_builder.build()?;
610 let local_var_resp = local_var_client.execute(local_var_req).await?;
611
612 let local_var_status = local_var_resp.status();
613 let local_var_content_type = local_var_resp
614 .headers()
615 .get("content-type")
616 .and_then(|v| v.to_str().ok())
617 .unwrap_or("application/octet-stream");
618 let local_var_content_type = super::ContentType::from(local_var_content_type);
619 let local_var_content = local_var_resp.text().await?;
620
621 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
622 match local_var_content_type {
623 ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from),
624 ContentType::Text => {
625 return Err(Error::from(serde_json::Error::custom(
626 "Received `text/plain` content type response that cannot be converted to `models::TwoFactorDuoResponseModel`",
627 )));
628 }
629 ContentType::Unsupported(local_var_unknown_type) => {
630 return Err(Error::from(serde_json::Error::custom(format!(
631 "Received `{local_var_unknown_type}` content type response that cannot be converted to `models::TwoFactorDuoResponseModel`"
632 ))));
633 }
634 }
635 } else {
636 let local_var_entity: Option<GetOrganizationDuoError> =
637 serde_json::from_str(&local_var_content).ok();
638 let local_var_error = ResponseContent {
639 status: local_var_status,
640 content: local_var_content,
641 entity: local_var_entity,
642 };
643 Err(Error::ResponseError(local_var_error))
644 }
645 }
646
647 async fn get_recover<'a>(
648 &self,
649 secret_verification_request_model: Option<models::SecretVerificationRequestModel>,
650 ) -> Result<models::TwoFactorRecoverResponseModel, Error<GetRecoverError>> {
651 let local_var_configuration = &self.configuration;
652
653 let local_var_client = &local_var_configuration.client;
654
655 let local_var_uri_str = format!(
656 "{}/two-factor/get-recover",
657 local_var_configuration.base_path
658 );
659 let mut local_var_req_builder =
660 local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
661
662 if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
663 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
664 };
665 local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
666 local_var_req_builder = local_var_req_builder.json(&secret_verification_request_model);
667
668 let local_var_req = local_var_req_builder.build()?;
669 let local_var_resp = local_var_client.execute(local_var_req).await?;
670
671 let local_var_status = local_var_resp.status();
672 let local_var_content_type = local_var_resp
673 .headers()
674 .get("content-type")
675 .and_then(|v| v.to_str().ok())
676 .unwrap_or("application/octet-stream");
677 let local_var_content_type = super::ContentType::from(local_var_content_type);
678 let local_var_content = local_var_resp.text().await?;
679
680 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
681 match local_var_content_type {
682 ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from),
683 ContentType::Text => {
684 return Err(Error::from(serde_json::Error::custom(
685 "Received `text/plain` content type response that cannot be converted to `models::TwoFactorRecoverResponseModel`",
686 )));
687 }
688 ContentType::Unsupported(local_var_unknown_type) => {
689 return Err(Error::from(serde_json::Error::custom(format!(
690 "Received `{local_var_unknown_type}` content type response that cannot be converted to `models::TwoFactorRecoverResponseModel`"
691 ))));
692 }
693 }
694 } else {
695 let local_var_entity: Option<GetRecoverError> =
696 serde_json::from_str(&local_var_content).ok();
697 let local_var_error = ResponseContent {
698 status: local_var_status,
699 content: local_var_content,
700 entity: local_var_entity,
701 };
702 Err(Error::ResponseError(local_var_error))
703 }
704 }
705
706 async fn get_web_authn<'a>(
707 &self,
708 secret_verification_request_model: Option<models::SecretVerificationRequestModel>,
709 ) -> Result<models::TwoFactorWebAuthnResponseModel, Error<GetWebAuthnError>> {
710 let local_var_configuration = &self.configuration;
711
712 let local_var_client = &local_var_configuration.client;
713
714 let local_var_uri_str = format!(
715 "{}/two-factor/get-webauthn",
716 local_var_configuration.base_path
717 );
718 let mut local_var_req_builder =
719 local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
720
721 if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
722 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
723 };
724 local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
725 local_var_req_builder = local_var_req_builder.json(&secret_verification_request_model);
726
727 let local_var_req = local_var_req_builder.build()?;
728 let local_var_resp = local_var_client.execute(local_var_req).await?;
729
730 let local_var_status = local_var_resp.status();
731 let local_var_content_type = local_var_resp
732 .headers()
733 .get("content-type")
734 .and_then(|v| v.to_str().ok())
735 .unwrap_or("application/octet-stream");
736 let local_var_content_type = super::ContentType::from(local_var_content_type);
737 let local_var_content = local_var_resp.text().await?;
738
739 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
740 match local_var_content_type {
741 ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from),
742 ContentType::Text => {
743 return Err(Error::from(serde_json::Error::custom(
744 "Received `text/plain` content type response that cannot be converted to `models::TwoFactorWebAuthnResponseModel`",
745 )));
746 }
747 ContentType::Unsupported(local_var_unknown_type) => {
748 return Err(Error::from(serde_json::Error::custom(format!(
749 "Received `{local_var_unknown_type}` content type response that cannot be converted to `models::TwoFactorWebAuthnResponseModel`"
750 ))));
751 }
752 }
753 } else {
754 let local_var_entity: Option<GetWebAuthnError> =
755 serde_json::from_str(&local_var_content).ok();
756 let local_var_error = ResponseContent {
757 status: local_var_status,
758 content: local_var_content,
759 entity: local_var_entity,
760 };
761 Err(Error::ResponseError(local_var_error))
762 }
763 }
764
765 async fn get_yubi_key<'a>(
766 &self,
767 secret_verification_request_model: Option<models::SecretVerificationRequestModel>,
768 ) -> Result<models::TwoFactorYubiKeyResponseModel, Error<GetYubiKeyError>> {
769 let local_var_configuration = &self.configuration;
770
771 let local_var_client = &local_var_configuration.client;
772
773 let local_var_uri_str = format!(
774 "{}/two-factor/get-yubikey",
775 local_var_configuration.base_path
776 );
777 let mut local_var_req_builder =
778 local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
779
780 if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
781 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
782 };
783 local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
784 local_var_req_builder = local_var_req_builder.json(&secret_verification_request_model);
785
786 let local_var_req = local_var_req_builder.build()?;
787 let local_var_resp = local_var_client.execute(local_var_req).await?;
788
789 let local_var_status = local_var_resp.status();
790 let local_var_content_type = local_var_resp
791 .headers()
792 .get("content-type")
793 .and_then(|v| v.to_str().ok())
794 .unwrap_or("application/octet-stream");
795 let local_var_content_type = super::ContentType::from(local_var_content_type);
796 let local_var_content = local_var_resp.text().await?;
797
798 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
799 match local_var_content_type {
800 ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from),
801 ContentType::Text => {
802 return Err(Error::from(serde_json::Error::custom(
803 "Received `text/plain` content type response that cannot be converted to `models::TwoFactorYubiKeyResponseModel`",
804 )));
805 }
806 ContentType::Unsupported(local_var_unknown_type) => {
807 return Err(Error::from(serde_json::Error::custom(format!(
808 "Received `{local_var_unknown_type}` content type response that cannot be converted to `models::TwoFactorYubiKeyResponseModel`"
809 ))));
810 }
811 }
812 } else {
813 let local_var_entity: Option<GetYubiKeyError> =
814 serde_json::from_str(&local_var_content).ok();
815 let local_var_error = ResponseContent {
816 status: local_var_status,
817 content: local_var_content,
818 entity: local_var_entity,
819 };
820 Err(Error::ResponseError(local_var_error))
821 }
822 }
823
824 async fn put_authenticator<'a>(
825 &self,
826 update_two_factor_authenticator_request_model: Option<
827 models::UpdateTwoFactorAuthenticatorRequestModel,
828 >,
829 ) -> Result<models::TwoFactorAuthenticatorResponseModel, Error<PutAuthenticatorError>> {
830 let local_var_configuration = &self.configuration;
831
832 let local_var_client = &local_var_configuration.client;
833
834 let local_var_uri_str = format!(
835 "{}/two-factor/authenticator",
836 local_var_configuration.base_path
837 );
838 let mut local_var_req_builder =
839 local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str());
840
841 if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
842 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
843 };
844 local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
845 local_var_req_builder =
846 local_var_req_builder.json(&update_two_factor_authenticator_request_model);
847
848 let local_var_req = local_var_req_builder.build()?;
849 let local_var_resp = local_var_client.execute(local_var_req).await?;
850
851 let local_var_status = local_var_resp.status();
852 let local_var_content_type = local_var_resp
853 .headers()
854 .get("content-type")
855 .and_then(|v| v.to_str().ok())
856 .unwrap_or("application/octet-stream");
857 let local_var_content_type = super::ContentType::from(local_var_content_type);
858 let local_var_content = local_var_resp.text().await?;
859
860 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
861 match local_var_content_type {
862 ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from),
863 ContentType::Text => {
864 return Err(Error::from(serde_json::Error::custom(
865 "Received `text/plain` content type response that cannot be converted to `models::TwoFactorAuthenticatorResponseModel`",
866 )));
867 }
868 ContentType::Unsupported(local_var_unknown_type) => {
869 return Err(Error::from(serde_json::Error::custom(format!(
870 "Received `{local_var_unknown_type}` content type response that cannot be converted to `models::TwoFactorAuthenticatorResponseModel`"
871 ))));
872 }
873 }
874 } else {
875 let local_var_entity: Option<PutAuthenticatorError> =
876 serde_json::from_str(&local_var_content).ok();
877 let local_var_error = ResponseContent {
878 status: local_var_status,
879 content: local_var_content,
880 entity: local_var_entity,
881 };
882 Err(Error::ResponseError(local_var_error))
883 }
884 }
885
886 async fn put_disable<'a>(
887 &self,
888 two_factor_provider_request_model: Option<models::TwoFactorProviderRequestModel>,
889 ) -> Result<models::TwoFactorProviderResponseModel, Error<PutDisableError>> {
890 let local_var_configuration = &self.configuration;
891
892 let local_var_client = &local_var_configuration.client;
893
894 let local_var_uri_str = format!("{}/two-factor/disable", local_var_configuration.base_path);
895 let mut local_var_req_builder =
896 local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str());
897
898 if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
899 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
900 };
901 local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
902 local_var_req_builder = local_var_req_builder.json(&two_factor_provider_request_model);
903
904 let local_var_req = local_var_req_builder.build()?;
905 let local_var_resp = local_var_client.execute(local_var_req).await?;
906
907 let local_var_status = local_var_resp.status();
908 let local_var_content_type = local_var_resp
909 .headers()
910 .get("content-type")
911 .and_then(|v| v.to_str().ok())
912 .unwrap_or("application/octet-stream");
913 let local_var_content_type = super::ContentType::from(local_var_content_type);
914 let local_var_content = local_var_resp.text().await?;
915
916 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
917 match local_var_content_type {
918 ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from),
919 ContentType::Text => {
920 return Err(Error::from(serde_json::Error::custom(
921 "Received `text/plain` content type response that cannot be converted to `models::TwoFactorProviderResponseModel`",
922 )));
923 }
924 ContentType::Unsupported(local_var_unknown_type) => {
925 return Err(Error::from(serde_json::Error::custom(format!(
926 "Received `{local_var_unknown_type}` content type response that cannot be converted to `models::TwoFactorProviderResponseModel`"
927 ))));
928 }
929 }
930 } else {
931 let local_var_entity: Option<PutDisableError> =
932 serde_json::from_str(&local_var_content).ok();
933 let local_var_error = ResponseContent {
934 status: local_var_status,
935 content: local_var_content,
936 entity: local_var_entity,
937 };
938 Err(Error::ResponseError(local_var_error))
939 }
940 }
941
942 async fn put_duo<'a>(
943 &self,
944 update_two_factor_duo_request_model: Option<models::UpdateTwoFactorDuoRequestModel>,
945 ) -> Result<models::TwoFactorDuoResponseModel, Error<PutDuoError>> {
946 let local_var_configuration = &self.configuration;
947
948 let local_var_client = &local_var_configuration.client;
949
950 let local_var_uri_str = format!("{}/two-factor/duo", local_var_configuration.base_path);
951 let mut local_var_req_builder =
952 local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str());
953
954 if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
955 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
956 };
957 local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
958 local_var_req_builder = local_var_req_builder.json(&update_two_factor_duo_request_model);
959
960 let local_var_req = local_var_req_builder.build()?;
961 let local_var_resp = local_var_client.execute(local_var_req).await?;
962
963 let local_var_status = local_var_resp.status();
964 let local_var_content_type = local_var_resp
965 .headers()
966 .get("content-type")
967 .and_then(|v| v.to_str().ok())
968 .unwrap_or("application/octet-stream");
969 let local_var_content_type = super::ContentType::from(local_var_content_type);
970 let local_var_content = local_var_resp.text().await?;
971
972 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
973 match local_var_content_type {
974 ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from),
975 ContentType::Text => {
976 return Err(Error::from(serde_json::Error::custom(
977 "Received `text/plain` content type response that cannot be converted to `models::TwoFactorDuoResponseModel`",
978 )));
979 }
980 ContentType::Unsupported(local_var_unknown_type) => {
981 return Err(Error::from(serde_json::Error::custom(format!(
982 "Received `{local_var_unknown_type}` content type response that cannot be converted to `models::TwoFactorDuoResponseModel`"
983 ))));
984 }
985 }
986 } else {
987 let local_var_entity: Option<PutDuoError> =
988 serde_json::from_str(&local_var_content).ok();
989 let local_var_error = ResponseContent {
990 status: local_var_status,
991 content: local_var_content,
992 entity: local_var_entity,
993 };
994 Err(Error::ResponseError(local_var_error))
995 }
996 }
997
998 async fn put_email<'a>(
999 &self,
1000 update_two_factor_email_request_model: Option<models::UpdateTwoFactorEmailRequestModel>,
1001 ) -> Result<models::TwoFactorEmailResponseModel, Error<PutEmailError>> {
1002 let local_var_configuration = &self.configuration;
1003
1004 let local_var_client = &local_var_configuration.client;
1005
1006 let local_var_uri_str = format!("{}/two-factor/email", local_var_configuration.base_path);
1007 let mut local_var_req_builder =
1008 local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str());
1009
1010 if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
1011 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
1012 };
1013 local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
1014 local_var_req_builder = local_var_req_builder.json(&update_two_factor_email_request_model);
1015
1016 let local_var_req = local_var_req_builder.build()?;
1017 let local_var_resp = local_var_client.execute(local_var_req).await?;
1018
1019 let local_var_status = local_var_resp.status();
1020 let local_var_content_type = local_var_resp
1021 .headers()
1022 .get("content-type")
1023 .and_then(|v| v.to_str().ok())
1024 .unwrap_or("application/octet-stream");
1025 let local_var_content_type = super::ContentType::from(local_var_content_type);
1026 let local_var_content = local_var_resp.text().await?;
1027
1028 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
1029 match local_var_content_type {
1030 ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from),
1031 ContentType::Text => {
1032 return Err(Error::from(serde_json::Error::custom(
1033 "Received `text/plain` content type response that cannot be converted to `models::TwoFactorEmailResponseModel`",
1034 )));
1035 }
1036 ContentType::Unsupported(local_var_unknown_type) => {
1037 return Err(Error::from(serde_json::Error::custom(format!(
1038 "Received `{local_var_unknown_type}` content type response that cannot be converted to `models::TwoFactorEmailResponseModel`"
1039 ))));
1040 }
1041 }
1042 } else {
1043 let local_var_entity: Option<PutEmailError> =
1044 serde_json::from_str(&local_var_content).ok();
1045 let local_var_error = ResponseContent {
1046 status: local_var_status,
1047 content: local_var_content,
1048 entity: local_var_entity,
1049 };
1050 Err(Error::ResponseError(local_var_error))
1051 }
1052 }
1053
1054 async fn put_organization_disable<'a>(
1055 &self,
1056 id: &'a str,
1057 two_factor_provider_request_model: Option<models::TwoFactorProviderRequestModel>,
1058 ) -> Result<models::TwoFactorProviderResponseModel, Error<PutOrganizationDisableError>> {
1059 let local_var_configuration = &self.configuration;
1060
1061 let local_var_client = &local_var_configuration.client;
1062
1063 let local_var_uri_str = format!(
1064 "{}/organizations/{id}/two-factor/disable",
1065 local_var_configuration.base_path,
1066 id = crate::apis::urlencode(id)
1067 );
1068 let mut local_var_req_builder =
1069 local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str());
1070
1071 if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
1072 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
1073 };
1074 local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
1075 local_var_req_builder = local_var_req_builder.json(&two_factor_provider_request_model);
1076
1077 let local_var_req = local_var_req_builder.build()?;
1078 let local_var_resp = local_var_client.execute(local_var_req).await?;
1079
1080 let local_var_status = local_var_resp.status();
1081 let local_var_content_type = local_var_resp
1082 .headers()
1083 .get("content-type")
1084 .and_then(|v| v.to_str().ok())
1085 .unwrap_or("application/octet-stream");
1086 let local_var_content_type = super::ContentType::from(local_var_content_type);
1087 let local_var_content = local_var_resp.text().await?;
1088
1089 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
1090 match local_var_content_type {
1091 ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from),
1092 ContentType::Text => {
1093 return Err(Error::from(serde_json::Error::custom(
1094 "Received `text/plain` content type response that cannot be converted to `models::TwoFactorProviderResponseModel`",
1095 )));
1096 }
1097 ContentType::Unsupported(local_var_unknown_type) => {
1098 return Err(Error::from(serde_json::Error::custom(format!(
1099 "Received `{local_var_unknown_type}` content type response that cannot be converted to `models::TwoFactorProviderResponseModel`"
1100 ))));
1101 }
1102 }
1103 } else {
1104 let local_var_entity: Option<PutOrganizationDisableError> =
1105 serde_json::from_str(&local_var_content).ok();
1106 let local_var_error = ResponseContent {
1107 status: local_var_status,
1108 content: local_var_content,
1109 entity: local_var_entity,
1110 };
1111 Err(Error::ResponseError(local_var_error))
1112 }
1113 }
1114
1115 async fn put_organization_duo<'a>(
1116 &self,
1117 id: &'a str,
1118 update_two_factor_duo_request_model: Option<models::UpdateTwoFactorDuoRequestModel>,
1119 ) -> Result<models::TwoFactorDuoResponseModel, Error<PutOrganizationDuoError>> {
1120 let local_var_configuration = &self.configuration;
1121
1122 let local_var_client = &local_var_configuration.client;
1123
1124 let local_var_uri_str = format!(
1125 "{}/organizations/{id}/two-factor/duo",
1126 local_var_configuration.base_path,
1127 id = crate::apis::urlencode(id)
1128 );
1129 let mut local_var_req_builder =
1130 local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str());
1131
1132 if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
1133 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
1134 };
1135 local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
1136 local_var_req_builder = local_var_req_builder.json(&update_two_factor_duo_request_model);
1137
1138 let local_var_req = local_var_req_builder.build()?;
1139 let local_var_resp = local_var_client.execute(local_var_req).await?;
1140
1141 let local_var_status = local_var_resp.status();
1142 let local_var_content_type = local_var_resp
1143 .headers()
1144 .get("content-type")
1145 .and_then(|v| v.to_str().ok())
1146 .unwrap_or("application/octet-stream");
1147 let local_var_content_type = super::ContentType::from(local_var_content_type);
1148 let local_var_content = local_var_resp.text().await?;
1149
1150 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
1151 match local_var_content_type {
1152 ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from),
1153 ContentType::Text => {
1154 return Err(Error::from(serde_json::Error::custom(
1155 "Received `text/plain` content type response that cannot be converted to `models::TwoFactorDuoResponseModel`",
1156 )));
1157 }
1158 ContentType::Unsupported(local_var_unknown_type) => {
1159 return Err(Error::from(serde_json::Error::custom(format!(
1160 "Received `{local_var_unknown_type}` content type response that cannot be converted to `models::TwoFactorDuoResponseModel`"
1161 ))));
1162 }
1163 }
1164 } else {
1165 let local_var_entity: Option<PutOrganizationDuoError> =
1166 serde_json::from_str(&local_var_content).ok();
1167 let local_var_error = ResponseContent {
1168 status: local_var_status,
1169 content: local_var_content,
1170 entity: local_var_entity,
1171 };
1172 Err(Error::ResponseError(local_var_error))
1173 }
1174 }
1175
1176 async fn put_web_authn<'a>(
1177 &self,
1178 two_factor_web_authn_request_model: Option<models::TwoFactorWebAuthnRequestModel>,
1179 ) -> Result<models::TwoFactorWebAuthnResponseModel, Error<PutWebAuthnError>> {
1180 let local_var_configuration = &self.configuration;
1181
1182 let local_var_client = &local_var_configuration.client;
1183
1184 let local_var_uri_str =
1185 format!("{}/two-factor/webauthn", local_var_configuration.base_path);
1186 let mut local_var_req_builder =
1187 local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str());
1188
1189 if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
1190 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
1191 };
1192 local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
1193 local_var_req_builder = local_var_req_builder.json(&two_factor_web_authn_request_model);
1194
1195 let local_var_req = local_var_req_builder.build()?;
1196 let local_var_resp = local_var_client.execute(local_var_req).await?;
1197
1198 let local_var_status = local_var_resp.status();
1199 let local_var_content_type = local_var_resp
1200 .headers()
1201 .get("content-type")
1202 .and_then(|v| v.to_str().ok())
1203 .unwrap_or("application/octet-stream");
1204 let local_var_content_type = super::ContentType::from(local_var_content_type);
1205 let local_var_content = local_var_resp.text().await?;
1206
1207 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
1208 match local_var_content_type {
1209 ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from),
1210 ContentType::Text => {
1211 return Err(Error::from(serde_json::Error::custom(
1212 "Received `text/plain` content type response that cannot be converted to `models::TwoFactorWebAuthnResponseModel`",
1213 )));
1214 }
1215 ContentType::Unsupported(local_var_unknown_type) => {
1216 return Err(Error::from(serde_json::Error::custom(format!(
1217 "Received `{local_var_unknown_type}` content type response that cannot be converted to `models::TwoFactorWebAuthnResponseModel`"
1218 ))));
1219 }
1220 }
1221 } else {
1222 let local_var_entity: Option<PutWebAuthnError> =
1223 serde_json::from_str(&local_var_content).ok();
1224 let local_var_error = ResponseContent {
1225 status: local_var_status,
1226 content: local_var_content,
1227 entity: local_var_entity,
1228 };
1229 Err(Error::ResponseError(local_var_error))
1230 }
1231 }
1232
1233 async fn put_yubi_key<'a>(
1234 &self,
1235 update_two_factor_yubico_otp_request_model: Option<
1236 models::UpdateTwoFactorYubicoOtpRequestModel,
1237 >,
1238 ) -> Result<models::TwoFactorYubiKeyResponseModel, Error<PutYubiKeyError>> {
1239 let local_var_configuration = &self.configuration;
1240
1241 let local_var_client = &local_var_configuration.client;
1242
1243 let local_var_uri_str = format!("{}/two-factor/yubikey", local_var_configuration.base_path);
1244 let mut local_var_req_builder =
1245 local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str());
1246
1247 if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
1248 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
1249 };
1250 local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
1251 local_var_req_builder =
1252 local_var_req_builder.json(&update_two_factor_yubico_otp_request_model);
1253
1254 let local_var_req = local_var_req_builder.build()?;
1255 let local_var_resp = local_var_client.execute(local_var_req).await?;
1256
1257 let local_var_status = local_var_resp.status();
1258 let local_var_content_type = local_var_resp
1259 .headers()
1260 .get("content-type")
1261 .and_then(|v| v.to_str().ok())
1262 .unwrap_or("application/octet-stream");
1263 let local_var_content_type = super::ContentType::from(local_var_content_type);
1264 let local_var_content = local_var_resp.text().await?;
1265
1266 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
1267 match local_var_content_type {
1268 ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from),
1269 ContentType::Text => {
1270 return Err(Error::from(serde_json::Error::custom(
1271 "Received `text/plain` content type response that cannot be converted to `models::TwoFactorYubiKeyResponseModel`",
1272 )));
1273 }
1274 ContentType::Unsupported(local_var_unknown_type) => {
1275 return Err(Error::from(serde_json::Error::custom(format!(
1276 "Received `{local_var_unknown_type}` content type response that cannot be converted to `models::TwoFactorYubiKeyResponseModel`"
1277 ))));
1278 }
1279 }
1280 } else {
1281 let local_var_entity: Option<PutYubiKeyError> =
1282 serde_json::from_str(&local_var_content).ok();
1283 let local_var_error = ResponseContent {
1284 status: local_var_status,
1285 content: local_var_content,
1286 entity: local_var_entity,
1287 };
1288 Err(Error::ResponseError(local_var_error))
1289 }
1290 }
1291
1292 async fn send_email<'a>(
1293 &self,
1294 two_factor_email_request_model: Option<models::TwoFactorEmailRequestModel>,
1295 ) -> Result<(), Error<SendEmailError>> {
1296 let local_var_configuration = &self.configuration;
1297
1298 let local_var_client = &local_var_configuration.client;
1299
1300 let local_var_uri_str = format!(
1301 "{}/two-factor/send-email",
1302 local_var_configuration.base_path
1303 );
1304 let mut local_var_req_builder =
1305 local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
1306
1307 if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
1308 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
1309 };
1310 local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
1311 local_var_req_builder = local_var_req_builder.json(&two_factor_email_request_model);
1312
1313 let local_var_req = local_var_req_builder.build()?;
1314 let local_var_resp = local_var_client.execute(local_var_req).await?;
1315
1316 let local_var_status = local_var_resp.status();
1317 let local_var_content = local_var_resp.text().await?;
1318
1319 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
1320 Ok(())
1321 } else {
1322 let local_var_entity: Option<SendEmailError> =
1323 serde_json::from_str(&local_var_content).ok();
1324 let local_var_error = ResponseContent {
1325 status: local_var_status,
1326 content: local_var_content,
1327 entity: local_var_entity,
1328 };
1329 Err(Error::ResponseError(local_var_error))
1330 }
1331 }
1332
1333 async fn send_email_login<'a>(
1334 &self,
1335 two_factor_email_request_model: Option<models::TwoFactorEmailRequestModel>,
1336 ) -> Result<(), Error<SendEmailLoginError>> {
1337 let local_var_configuration = &self.configuration;
1338
1339 let local_var_client = &local_var_configuration.client;
1340
1341 let local_var_uri_str = format!(
1342 "{}/two-factor/send-email-login",
1343 local_var_configuration.base_path
1344 );
1345 let mut local_var_req_builder =
1346 local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
1347
1348 if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
1349 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
1350 };
1351 local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
1352 local_var_req_builder = local_var_req_builder.json(&two_factor_email_request_model);
1353
1354 let local_var_req = local_var_req_builder.build()?;
1355 let local_var_resp = local_var_client.execute(local_var_req).await?;
1356
1357 let local_var_status = local_var_resp.status();
1358 let local_var_content = local_var_resp.text().await?;
1359
1360 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
1361 Ok(())
1362 } else {
1363 let local_var_entity: Option<SendEmailLoginError> =
1364 serde_json::from_str(&local_var_content).ok();
1365 let local_var_error = ResponseContent {
1366 status: local_var_status,
1367 content: local_var_content,
1368 entity: local_var_entity,
1369 };
1370 Err(Error::ResponseError(local_var_error))
1371 }
1372 }
1373}
1374
1375#[derive(Debug, Clone, Serialize, Deserialize)]
1377#[serde(untagged)]
1378pub enum DeleteWebAuthnError {
1379 UnknownValue(serde_json::Value),
1380}
1381#[derive(Debug, Clone, Serialize, Deserialize)]
1383#[serde(untagged)]
1384pub enum DisableAuthenticatorError {
1385 UnknownValue(serde_json::Value),
1386}
1387#[derive(Debug, Clone, Serialize, Deserialize)]
1389#[serde(untagged)]
1390pub enum GetError {
1391 UnknownValue(serde_json::Value),
1392}
1393#[derive(Debug, Clone, Serialize, Deserialize)]
1395#[serde(untagged)]
1396pub enum GetAuthenticatorError {
1397 UnknownValue(serde_json::Value),
1398}
1399#[derive(Debug, Clone, Serialize, Deserialize)]
1401#[serde(untagged)]
1402pub enum GetDuoError {
1403 UnknownValue(serde_json::Value),
1404}
1405#[derive(Debug, Clone, Serialize, Deserialize)]
1407#[serde(untagged)]
1408pub enum GetEmailError {
1409 UnknownValue(serde_json::Value),
1410}
1411#[derive(Debug, Clone, Serialize, Deserialize)]
1413#[serde(untagged)]
1414pub enum GetOrganizationError {
1415 UnknownValue(serde_json::Value),
1416}
1417#[derive(Debug, Clone, Serialize, Deserialize)]
1419#[serde(untagged)]
1420pub enum GetOrganizationDuoError {
1421 UnknownValue(serde_json::Value),
1422}
1423#[derive(Debug, Clone, Serialize, Deserialize)]
1425#[serde(untagged)]
1426pub enum GetRecoverError {
1427 UnknownValue(serde_json::Value),
1428}
1429#[derive(Debug, Clone, Serialize, Deserialize)]
1431#[serde(untagged)]
1432pub enum GetWebAuthnError {
1433 UnknownValue(serde_json::Value),
1434}
1435#[derive(Debug, Clone, Serialize, Deserialize)]
1437#[serde(untagged)]
1438pub enum GetYubiKeyError {
1439 UnknownValue(serde_json::Value),
1440}
1441#[derive(Debug, Clone, Serialize, Deserialize)]
1443#[serde(untagged)]
1444pub enum PutAuthenticatorError {
1445 UnknownValue(serde_json::Value),
1446}
1447#[derive(Debug, Clone, Serialize, Deserialize)]
1449#[serde(untagged)]
1450pub enum PutDisableError {
1451 UnknownValue(serde_json::Value),
1452}
1453#[derive(Debug, Clone, Serialize, Deserialize)]
1455#[serde(untagged)]
1456pub enum PutDuoError {
1457 UnknownValue(serde_json::Value),
1458}
1459#[derive(Debug, Clone, Serialize, Deserialize)]
1461#[serde(untagged)]
1462pub enum PutEmailError {
1463 UnknownValue(serde_json::Value),
1464}
1465#[derive(Debug, Clone, Serialize, Deserialize)]
1467#[serde(untagged)]
1468pub enum PutOrganizationDisableError {
1469 UnknownValue(serde_json::Value),
1470}
1471#[derive(Debug, Clone, Serialize, Deserialize)]
1473#[serde(untagged)]
1474pub enum PutOrganizationDuoError {
1475 UnknownValue(serde_json::Value),
1476}
1477#[derive(Debug, Clone, Serialize, Deserialize)]
1479#[serde(untagged)]
1480pub enum PutWebAuthnError {
1481 UnknownValue(serde_json::Value),
1482}
1483#[derive(Debug, Clone, Serialize, Deserialize)]
1485#[serde(untagged)]
1486pub enum PutYubiKeyError {
1487 UnknownValue(serde_json::Value),
1488}
1489#[derive(Debug, Clone, Serialize, Deserialize)]
1491#[serde(untagged)]
1492pub enum SendEmailError {
1493 UnknownValue(serde_json::Value),
1494}
1495#[derive(Debug, Clone, Serialize, Deserialize)]
1497#[serde(untagged)]
1498pub enum SendEmailLoginError {
1499 UnknownValue(serde_json::Value),
1500}