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