Skip to main content

bitwarden_api_api/apis/
two_factor_api.rs

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