Skip to main content

bitwarden_api_api/apis/
emergency_access_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 EmergencyAccessApi: Send + Sync {
29    /// POST /emergency-access/{id}/accept
30    async fn accept<'a>(
31        &self,
32        id: uuid::Uuid,
33        organization_user_accept_request_model: Option<models::OrganizationUserAcceptRequestModel>,
34    ) -> Result<(), Error<AcceptError>>;
35
36    /// POST /emergency-access/{id}/approve
37    async fn approve<'a>(&self, id: uuid::Uuid) -> Result<(), Error<ApproveError>>;
38
39    /// POST /emergency-access/{id}/confirm
40    async fn confirm<'a>(
41        &self,
42        id: uuid::Uuid,
43        organization_user_confirm_request_model: Option<
44            models::OrganizationUserConfirmRequestModel,
45        >,
46    ) -> Result<(), Error<ConfirmError>>;
47
48    /// DELETE /emergency-access/{id}
49    async fn delete<'a>(&self, id: uuid::Uuid) -> Result<(), Error<DeleteError>>;
50
51    /// GET /emergency-access/{id}
52    async fn get<'a>(
53        &self,
54        id: uuid::Uuid,
55    ) -> Result<models::EmergencyAccessGranteeDetailsResponseModel, Error<GetError>>;
56
57    /// GET /emergency-access/{id}/{cipherId}/attachment/{attachmentId}
58    async fn get_attachment_data<'a>(
59        &self,
60        id: uuid::Uuid,
61        cipher_id: uuid::Uuid,
62        attachment_id: &'a str,
63    ) -> Result<models::AttachmentResponseModel, Error<GetAttachmentDataError>>;
64
65    /// GET /emergency-access/trusted
66    async fn get_contacts(
67        &self,
68    ) -> Result<
69        models::EmergencyAccessGranteeDetailsResponseModelListResponseModel,
70        Error<GetContactsError>,
71    >;
72
73    /// GET /emergency-access/granted
74    async fn get_grantees(
75        &self,
76    ) -> Result<
77        models::EmergencyAccessGrantorDetailsResponseModelListResponseModel,
78        Error<GetGranteesError>,
79    >;
80
81    /// POST /emergency-access/{id}/initiate
82    async fn initiate<'a>(&self, id: uuid::Uuid) -> Result<(), Error<InitiateError>>;
83
84    /// POST /emergency-access/invite
85    async fn invite<'a>(
86        &self,
87        emergency_access_invite_request_model: Option<models::EmergencyAccessInviteRequestModel>,
88    ) -> Result<(), Error<InviteError>>;
89
90    /// POST /emergency-access/{id}/password
91    async fn password<'a>(
92        &self,
93        id: uuid::Uuid,
94        emergency_access_password_request_model: Option<
95            models::EmergencyAccessPasswordRequestModel,
96        >,
97    ) -> Result<(), Error<PasswordError>>;
98
99    /// GET /emergency-access/{id}/policies
100    async fn policies<'a>(
101        &self,
102        id: uuid::Uuid,
103    ) -> Result<models::PolicyResponseModelListResponseModel, Error<PoliciesError>>;
104
105    /// PUT /emergency-access/{id}
106    async fn put<'a>(
107        &self,
108        id: uuid::Uuid,
109        emergency_access_update_request_model: Option<models::EmergencyAccessUpdateRequestModel>,
110    ) -> Result<(), Error<PutError>>;
111
112    /// POST /emergency-access/{id}/reinvite
113    async fn reinvite<'a>(&self, id: uuid::Uuid) -> Result<(), Error<ReinviteError>>;
114
115    /// POST /emergency-access/{id}/reject
116    async fn reject<'a>(&self, id: uuid::Uuid) -> Result<(), Error<RejectError>>;
117
118    /// POST /emergency-access/{id}/takeover
119    async fn takeover<'a>(
120        &self,
121        id: uuid::Uuid,
122    ) -> Result<models::EmergencyAccessTakeoverResponseModel, Error<TakeoverError>>;
123
124    /// POST /emergency-access/{id}/view
125    async fn view_ciphers<'a>(
126        &self,
127        id: uuid::Uuid,
128    ) -> Result<models::EmergencyAccessViewResponseModel, Error<ViewCiphersError>>;
129}
130
131pub struct EmergencyAccessApiClient {
132    configuration: Arc<configuration::Configuration>,
133}
134
135impl EmergencyAccessApiClient {
136    pub fn new(configuration: Arc<configuration::Configuration>) -> Self {
137        Self { configuration }
138    }
139}
140
141#[cfg_attr(target_arch = "wasm32", async_trait(?Send))]
142#[cfg_attr(not(target_arch = "wasm32"), async_trait)]
143impl EmergencyAccessApi for EmergencyAccessApiClient {
144    async fn accept<'a>(
145        &self,
146        id: uuid::Uuid,
147        organization_user_accept_request_model: Option<models::OrganizationUserAcceptRequestModel>,
148    ) -> Result<(), Error<AcceptError>> {
149        let local_var_configuration = &self.configuration;
150
151        let local_var_client = &local_var_configuration.client;
152
153        let local_var_uri_str = format!(
154            "{}/emergency-access/{id}/accept",
155            local_var_configuration.base_path,
156            id = id
157        );
158        let mut local_var_req_builder =
159            local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
160
161        local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
162        local_var_req_builder = local_var_req_builder.json(&organization_user_accept_request_model);
163
164        let local_var_resp = local_var_req_builder.send().await?;
165
166        let local_var_status = local_var_resp.status();
167        let local_var_content = local_var_resp.text().await?;
168
169        if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
170            Ok(())
171        } else {
172            let local_var_entity: Option<AcceptError> =
173                serde_json::from_str(&local_var_content).ok();
174            let local_var_error = ResponseContent {
175                status: local_var_status,
176                content: local_var_content,
177                entity: local_var_entity,
178            };
179            Err(Error::ResponseError(local_var_error))
180        }
181    }
182
183    async fn approve<'a>(&self, id: uuid::Uuid) -> Result<(), Error<ApproveError>> {
184        let local_var_configuration = &self.configuration;
185
186        let local_var_client = &local_var_configuration.client;
187
188        let local_var_uri_str = format!(
189            "{}/emergency-access/{id}/approve",
190            local_var_configuration.base_path,
191            id = id
192        );
193        let mut local_var_req_builder =
194            local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
195
196        local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
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 = local_var_resp.text().await?;
202
203        if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
204            Ok(())
205        } else {
206            let local_var_entity: Option<ApproveError> =
207                serde_json::from_str(&local_var_content).ok();
208            let local_var_error = ResponseContent {
209                status: local_var_status,
210                content: local_var_content,
211                entity: local_var_entity,
212            };
213            Err(Error::ResponseError(local_var_error))
214        }
215    }
216
217    async fn confirm<'a>(
218        &self,
219        id: uuid::Uuid,
220        organization_user_confirm_request_model: Option<
221            models::OrganizationUserConfirmRequestModel,
222        >,
223    ) -> Result<(), Error<ConfirmError>> {
224        let local_var_configuration = &self.configuration;
225
226        let local_var_client = &local_var_configuration.client;
227
228        let local_var_uri_str = format!(
229            "{}/emergency-access/{id}/confirm",
230            local_var_configuration.base_path,
231            id = id
232        );
233        let mut local_var_req_builder =
234            local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
235
236        local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
237        local_var_req_builder =
238            local_var_req_builder.json(&organization_user_confirm_request_model);
239
240        let local_var_resp = local_var_req_builder.send().await?;
241
242        let local_var_status = local_var_resp.status();
243        let local_var_content = local_var_resp.text().await?;
244
245        if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
246            Ok(())
247        } else {
248            let local_var_entity: Option<ConfirmError> =
249                serde_json::from_str(&local_var_content).ok();
250            let local_var_error = ResponseContent {
251                status: local_var_status,
252                content: local_var_content,
253                entity: local_var_entity,
254            };
255            Err(Error::ResponseError(local_var_error))
256        }
257    }
258
259    async fn delete<'a>(&self, id: uuid::Uuid) -> Result<(), Error<DeleteError>> {
260        let local_var_configuration = &self.configuration;
261
262        let local_var_client = &local_var_configuration.client;
263
264        let local_var_uri_str = format!(
265            "{}/emergency-access/{id}",
266            local_var_configuration.base_path,
267            id = id
268        );
269        let mut local_var_req_builder =
270            local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str());
271
272        local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
273
274        let local_var_resp = local_var_req_builder.send().await?;
275
276        let local_var_status = local_var_resp.status();
277        let local_var_content = local_var_resp.text().await?;
278
279        if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
280            Ok(())
281        } else {
282            let local_var_entity: Option<DeleteError> =
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<'a>(
294        &self,
295        id: uuid::Uuid,
296    ) -> Result<models::EmergencyAccessGranteeDetailsResponseModel, Error<GetError>> {
297        let local_var_configuration = &self.configuration;
298
299        let local_var_client = &local_var_configuration.client;
300
301        let local_var_uri_str = format!(
302            "{}/emergency-access/{id}",
303            local_var_configuration.base_path,
304            id = id
305        );
306        let mut local_var_req_builder =
307            local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
308
309        local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
310
311        let local_var_resp = local_var_req_builder.send().await?;
312
313        let local_var_status = local_var_resp.status();
314        let local_var_content_type = local_var_resp
315            .headers()
316            .get("content-type")
317            .and_then(|v| v.to_str().ok())
318            .unwrap_or("application/octet-stream");
319        let local_var_content_type = super::ContentType::from(local_var_content_type);
320        let local_var_content = local_var_resp.text().await?;
321
322        if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
323            match local_var_content_type {
324                ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from),
325                ContentType::Text => {
326                    return Err(Error::from(serde_json::Error::custom(
327                        "Received `text/plain` content type response that cannot be converted to `models::EmergencyAccessGranteeDetailsResponseModel`",
328                    )));
329                }
330                ContentType::Unsupported(local_var_unknown_type) => {
331                    return Err(Error::from(serde_json::Error::custom(format!(
332                        "Received `{local_var_unknown_type}` content type response that cannot be converted to `models::EmergencyAccessGranteeDetailsResponseModel`"
333                    ))));
334                }
335            }
336        } else {
337            let local_var_entity: Option<GetError> = serde_json::from_str(&local_var_content).ok();
338            let local_var_error = ResponseContent {
339                status: local_var_status,
340                content: local_var_content,
341                entity: local_var_entity,
342            };
343            Err(Error::ResponseError(local_var_error))
344        }
345    }
346
347    async fn get_attachment_data<'a>(
348        &self,
349        id: uuid::Uuid,
350        cipher_id: uuid::Uuid,
351        attachment_id: &'a str,
352    ) -> Result<models::AttachmentResponseModel, Error<GetAttachmentDataError>> {
353        let local_var_configuration = &self.configuration;
354
355        let local_var_client = &local_var_configuration.client;
356
357        let local_var_uri_str = format!(
358            "{}/emergency-access/{id}/{cipherId}/attachment/{attachmentId}",
359            local_var_configuration.base_path,
360            id = id,
361            cipherId = cipher_id,
362            attachmentId = crate::apis::urlencode(attachment_id)
363        );
364        let mut local_var_req_builder =
365            local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
366
367        local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
368
369        let local_var_resp = local_var_req_builder.send().await?;
370
371        let local_var_status = local_var_resp.status();
372        let local_var_content_type = local_var_resp
373            .headers()
374            .get("content-type")
375            .and_then(|v| v.to_str().ok())
376            .unwrap_or("application/octet-stream");
377        let local_var_content_type = super::ContentType::from(local_var_content_type);
378        let local_var_content = local_var_resp.text().await?;
379
380        if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
381            match local_var_content_type {
382                ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from),
383                ContentType::Text => {
384                    return Err(Error::from(serde_json::Error::custom(
385                        "Received `text/plain` content type response that cannot be converted to `models::AttachmentResponseModel`",
386                    )));
387                }
388                ContentType::Unsupported(local_var_unknown_type) => {
389                    return Err(Error::from(serde_json::Error::custom(format!(
390                        "Received `{local_var_unknown_type}` content type response that cannot be converted to `models::AttachmentResponseModel`"
391                    ))));
392                }
393            }
394        } else {
395            let local_var_entity: Option<GetAttachmentDataError> =
396                serde_json::from_str(&local_var_content).ok();
397            let local_var_error = ResponseContent {
398                status: local_var_status,
399                content: local_var_content,
400                entity: local_var_entity,
401            };
402            Err(Error::ResponseError(local_var_error))
403        }
404    }
405
406    async fn get_contacts(
407        &self,
408    ) -> Result<
409        models::EmergencyAccessGranteeDetailsResponseModelListResponseModel,
410        Error<GetContactsError>,
411    > {
412        let local_var_configuration = &self.configuration;
413
414        let local_var_client = &local_var_configuration.client;
415
416        let local_var_uri_str = format!(
417            "{}/emergency-access/trusted",
418            local_var_configuration.base_path
419        );
420        let mut local_var_req_builder =
421            local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
422
423        local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
424
425        let local_var_resp = local_var_req_builder.send().await?;
426
427        let local_var_status = local_var_resp.status();
428        let local_var_content_type = local_var_resp
429            .headers()
430            .get("content-type")
431            .and_then(|v| v.to_str().ok())
432            .unwrap_or("application/octet-stream");
433        let local_var_content_type = super::ContentType::from(local_var_content_type);
434        let local_var_content = local_var_resp.text().await?;
435
436        if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
437            match local_var_content_type {
438                ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from),
439                ContentType::Text => {
440                    return Err(Error::from(serde_json::Error::custom(
441                        "Received `text/plain` content type response that cannot be converted to `models::EmergencyAccessGranteeDetailsResponseModelListResponseModel`",
442                    )));
443                }
444                ContentType::Unsupported(local_var_unknown_type) => {
445                    return Err(Error::from(serde_json::Error::custom(format!(
446                        "Received `{local_var_unknown_type}` content type response that cannot be converted to `models::EmergencyAccessGranteeDetailsResponseModelListResponseModel`"
447                    ))));
448                }
449            }
450        } else {
451            let local_var_entity: Option<GetContactsError> =
452                serde_json::from_str(&local_var_content).ok();
453            let local_var_error = ResponseContent {
454                status: local_var_status,
455                content: local_var_content,
456                entity: local_var_entity,
457            };
458            Err(Error::ResponseError(local_var_error))
459        }
460    }
461
462    async fn get_grantees(
463        &self,
464    ) -> Result<
465        models::EmergencyAccessGrantorDetailsResponseModelListResponseModel,
466        Error<GetGranteesError>,
467    > {
468        let local_var_configuration = &self.configuration;
469
470        let local_var_client = &local_var_configuration.client;
471
472        let local_var_uri_str = format!(
473            "{}/emergency-access/granted",
474            local_var_configuration.base_path
475        );
476        let mut local_var_req_builder =
477            local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
478
479        local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
480
481        let local_var_resp = local_var_req_builder.send().await?;
482
483        let local_var_status = local_var_resp.status();
484        let local_var_content_type = local_var_resp
485            .headers()
486            .get("content-type")
487            .and_then(|v| v.to_str().ok())
488            .unwrap_or("application/octet-stream");
489        let local_var_content_type = super::ContentType::from(local_var_content_type);
490        let local_var_content = local_var_resp.text().await?;
491
492        if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
493            match local_var_content_type {
494                ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from),
495                ContentType::Text => {
496                    return Err(Error::from(serde_json::Error::custom(
497                        "Received `text/plain` content type response that cannot be converted to `models::EmergencyAccessGrantorDetailsResponseModelListResponseModel`",
498                    )));
499                }
500                ContentType::Unsupported(local_var_unknown_type) => {
501                    return Err(Error::from(serde_json::Error::custom(format!(
502                        "Received `{local_var_unknown_type}` content type response that cannot be converted to `models::EmergencyAccessGrantorDetailsResponseModelListResponseModel`"
503                    ))));
504                }
505            }
506        } else {
507            let local_var_entity: Option<GetGranteesError> =
508                serde_json::from_str(&local_var_content).ok();
509            let local_var_error = ResponseContent {
510                status: local_var_status,
511                content: local_var_content,
512                entity: local_var_entity,
513            };
514            Err(Error::ResponseError(local_var_error))
515        }
516    }
517
518    async fn initiate<'a>(&self, id: uuid::Uuid) -> Result<(), Error<InitiateError>> {
519        let local_var_configuration = &self.configuration;
520
521        let local_var_client = &local_var_configuration.client;
522
523        let local_var_uri_str = format!(
524            "{}/emergency-access/{id}/initiate",
525            local_var_configuration.base_path,
526            id = id
527        );
528        let mut local_var_req_builder =
529            local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
530
531        local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
532
533        let local_var_resp = local_var_req_builder.send().await?;
534
535        let local_var_status = local_var_resp.status();
536        let local_var_content = local_var_resp.text().await?;
537
538        if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
539            Ok(())
540        } else {
541            let local_var_entity: Option<InitiateError> =
542                serde_json::from_str(&local_var_content).ok();
543            let local_var_error = ResponseContent {
544                status: local_var_status,
545                content: local_var_content,
546                entity: local_var_entity,
547            };
548            Err(Error::ResponseError(local_var_error))
549        }
550    }
551
552    async fn invite<'a>(
553        &self,
554        emergency_access_invite_request_model: Option<models::EmergencyAccessInviteRequestModel>,
555    ) -> Result<(), Error<InviteError>> {
556        let local_var_configuration = &self.configuration;
557
558        let local_var_client = &local_var_configuration.client;
559
560        let local_var_uri_str = format!(
561            "{}/emergency-access/invite",
562            local_var_configuration.base_path
563        );
564        let mut local_var_req_builder =
565            local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
566
567        local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
568        local_var_req_builder = local_var_req_builder.json(&emergency_access_invite_request_model);
569
570        let local_var_resp = local_var_req_builder.send().await?;
571
572        let local_var_status = local_var_resp.status();
573        let local_var_content = local_var_resp.text().await?;
574
575        if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
576            Ok(())
577        } else {
578            let local_var_entity: Option<InviteError> =
579                serde_json::from_str(&local_var_content).ok();
580            let local_var_error = ResponseContent {
581                status: local_var_status,
582                content: local_var_content,
583                entity: local_var_entity,
584            };
585            Err(Error::ResponseError(local_var_error))
586        }
587    }
588
589    async fn password<'a>(
590        &self,
591        id: uuid::Uuid,
592        emergency_access_password_request_model: Option<
593            models::EmergencyAccessPasswordRequestModel,
594        >,
595    ) -> Result<(), Error<PasswordError>> {
596        let local_var_configuration = &self.configuration;
597
598        let local_var_client = &local_var_configuration.client;
599
600        let local_var_uri_str = format!(
601            "{}/emergency-access/{id}/password",
602            local_var_configuration.base_path,
603            id = id
604        );
605        let mut local_var_req_builder =
606            local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
607
608        local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
609        local_var_req_builder =
610            local_var_req_builder.json(&emergency_access_password_request_model);
611
612        let local_var_resp = local_var_req_builder.send().await?;
613
614        let local_var_status = local_var_resp.status();
615        let local_var_content = local_var_resp.text().await?;
616
617        if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
618            Ok(())
619        } else {
620            let local_var_entity: Option<PasswordError> =
621                serde_json::from_str(&local_var_content).ok();
622            let local_var_error = ResponseContent {
623                status: local_var_status,
624                content: local_var_content,
625                entity: local_var_entity,
626            };
627            Err(Error::ResponseError(local_var_error))
628        }
629    }
630
631    async fn policies<'a>(
632        &self,
633        id: uuid::Uuid,
634    ) -> Result<models::PolicyResponseModelListResponseModel, Error<PoliciesError>> {
635        let local_var_configuration = &self.configuration;
636
637        let local_var_client = &local_var_configuration.client;
638
639        let local_var_uri_str = format!(
640            "{}/emergency-access/{id}/policies",
641            local_var_configuration.base_path,
642            id = id
643        );
644        let mut local_var_req_builder =
645            local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
646
647        local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
648
649        let local_var_resp = local_var_req_builder.send().await?;
650
651        let local_var_status = local_var_resp.status();
652        let local_var_content_type = local_var_resp
653            .headers()
654            .get("content-type")
655            .and_then(|v| v.to_str().ok())
656            .unwrap_or("application/octet-stream");
657        let local_var_content_type = super::ContentType::from(local_var_content_type);
658        let local_var_content = local_var_resp.text().await?;
659
660        if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
661            match local_var_content_type {
662                ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from),
663                ContentType::Text => {
664                    return Err(Error::from(serde_json::Error::custom(
665                        "Received `text/plain` content type response that cannot be converted to `models::PolicyResponseModelListResponseModel`",
666                    )));
667                }
668                ContentType::Unsupported(local_var_unknown_type) => {
669                    return Err(Error::from(serde_json::Error::custom(format!(
670                        "Received `{local_var_unknown_type}` content type response that cannot be converted to `models::PolicyResponseModelListResponseModel`"
671                    ))));
672                }
673            }
674        } else {
675            let local_var_entity: Option<PoliciesError> =
676                serde_json::from_str(&local_var_content).ok();
677            let local_var_error = ResponseContent {
678                status: local_var_status,
679                content: local_var_content,
680                entity: local_var_entity,
681            };
682            Err(Error::ResponseError(local_var_error))
683        }
684    }
685
686    async fn put<'a>(
687        &self,
688        id: uuid::Uuid,
689        emergency_access_update_request_model: Option<models::EmergencyAccessUpdateRequestModel>,
690    ) -> Result<(), Error<PutError>> {
691        let local_var_configuration = &self.configuration;
692
693        let local_var_client = &local_var_configuration.client;
694
695        let local_var_uri_str = format!(
696            "{}/emergency-access/{id}",
697            local_var_configuration.base_path,
698            id = id
699        );
700        let mut local_var_req_builder =
701            local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str());
702
703        local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
704        local_var_req_builder = local_var_req_builder.json(&emergency_access_update_request_model);
705
706        let local_var_resp = local_var_req_builder.send().await?;
707
708        let local_var_status = local_var_resp.status();
709        let local_var_content = local_var_resp.text().await?;
710
711        if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
712            Ok(())
713        } else {
714            let local_var_entity: Option<PutError> = serde_json::from_str(&local_var_content).ok();
715            let local_var_error = ResponseContent {
716                status: local_var_status,
717                content: local_var_content,
718                entity: local_var_entity,
719            };
720            Err(Error::ResponseError(local_var_error))
721        }
722    }
723
724    async fn reinvite<'a>(&self, id: uuid::Uuid) -> Result<(), Error<ReinviteError>> {
725        let local_var_configuration = &self.configuration;
726
727        let local_var_client = &local_var_configuration.client;
728
729        let local_var_uri_str = format!(
730            "{}/emergency-access/{id}/reinvite",
731            local_var_configuration.base_path,
732            id = id
733        );
734        let mut local_var_req_builder =
735            local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
736
737        local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
738
739        let local_var_resp = local_var_req_builder.send().await?;
740
741        let local_var_status = local_var_resp.status();
742        let local_var_content = local_var_resp.text().await?;
743
744        if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
745            Ok(())
746        } else {
747            let local_var_entity: Option<ReinviteError> =
748                serde_json::from_str(&local_var_content).ok();
749            let local_var_error = ResponseContent {
750                status: local_var_status,
751                content: local_var_content,
752                entity: local_var_entity,
753            };
754            Err(Error::ResponseError(local_var_error))
755        }
756    }
757
758    async fn reject<'a>(&self, id: uuid::Uuid) -> Result<(), Error<RejectError>> {
759        let local_var_configuration = &self.configuration;
760
761        let local_var_client = &local_var_configuration.client;
762
763        let local_var_uri_str = format!(
764            "{}/emergency-access/{id}/reject",
765            local_var_configuration.base_path,
766            id = id
767        );
768        let mut local_var_req_builder =
769            local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
770
771        local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
772
773        let local_var_resp = local_var_req_builder.send().await?;
774
775        let local_var_status = local_var_resp.status();
776        let local_var_content = local_var_resp.text().await?;
777
778        if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
779            Ok(())
780        } else {
781            let local_var_entity: Option<RejectError> =
782                serde_json::from_str(&local_var_content).ok();
783            let local_var_error = ResponseContent {
784                status: local_var_status,
785                content: local_var_content,
786                entity: local_var_entity,
787            };
788            Err(Error::ResponseError(local_var_error))
789        }
790    }
791
792    async fn takeover<'a>(
793        &self,
794        id: uuid::Uuid,
795    ) -> Result<models::EmergencyAccessTakeoverResponseModel, Error<TakeoverError>> {
796        let local_var_configuration = &self.configuration;
797
798        let local_var_client = &local_var_configuration.client;
799
800        let local_var_uri_str = format!(
801            "{}/emergency-access/{id}/takeover",
802            local_var_configuration.base_path,
803            id = id
804        );
805        let mut local_var_req_builder =
806            local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
807
808        local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
809
810        let local_var_resp = local_var_req_builder.send().await?;
811
812        let local_var_status = local_var_resp.status();
813        let local_var_content_type = local_var_resp
814            .headers()
815            .get("content-type")
816            .and_then(|v| v.to_str().ok())
817            .unwrap_or("application/octet-stream");
818        let local_var_content_type = super::ContentType::from(local_var_content_type);
819        let local_var_content = local_var_resp.text().await?;
820
821        if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
822            match local_var_content_type {
823                ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from),
824                ContentType::Text => {
825                    return Err(Error::from(serde_json::Error::custom(
826                        "Received `text/plain` content type response that cannot be converted to `models::EmergencyAccessTakeoverResponseModel`",
827                    )));
828                }
829                ContentType::Unsupported(local_var_unknown_type) => {
830                    return Err(Error::from(serde_json::Error::custom(format!(
831                        "Received `{local_var_unknown_type}` content type response that cannot be converted to `models::EmergencyAccessTakeoverResponseModel`"
832                    ))));
833                }
834            }
835        } else {
836            let local_var_entity: Option<TakeoverError> =
837                serde_json::from_str(&local_var_content).ok();
838            let local_var_error = ResponseContent {
839                status: local_var_status,
840                content: local_var_content,
841                entity: local_var_entity,
842            };
843            Err(Error::ResponseError(local_var_error))
844        }
845    }
846
847    async fn view_ciphers<'a>(
848        &self,
849        id: uuid::Uuid,
850    ) -> Result<models::EmergencyAccessViewResponseModel, Error<ViewCiphersError>> {
851        let local_var_configuration = &self.configuration;
852
853        let local_var_client = &local_var_configuration.client;
854
855        let local_var_uri_str = format!(
856            "{}/emergency-access/{id}/view",
857            local_var_configuration.base_path,
858            id = id
859        );
860        let mut local_var_req_builder =
861            local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
862
863        local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
864
865        let local_var_resp = local_var_req_builder.send().await?;
866
867        let local_var_status = local_var_resp.status();
868        let local_var_content_type = local_var_resp
869            .headers()
870            .get("content-type")
871            .and_then(|v| v.to_str().ok())
872            .unwrap_or("application/octet-stream");
873        let local_var_content_type = super::ContentType::from(local_var_content_type);
874        let local_var_content = local_var_resp.text().await?;
875
876        if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
877            match local_var_content_type {
878                ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from),
879                ContentType::Text => {
880                    return Err(Error::from(serde_json::Error::custom(
881                        "Received `text/plain` content type response that cannot be converted to `models::EmergencyAccessViewResponseModel`",
882                    )));
883                }
884                ContentType::Unsupported(local_var_unknown_type) => {
885                    return Err(Error::from(serde_json::Error::custom(format!(
886                        "Received `{local_var_unknown_type}` content type response that cannot be converted to `models::EmergencyAccessViewResponseModel`"
887                    ))));
888                }
889            }
890        } else {
891            let local_var_entity: Option<ViewCiphersError> =
892                serde_json::from_str(&local_var_content).ok();
893            let local_var_error = ResponseContent {
894                status: local_var_status,
895                content: local_var_content,
896                entity: local_var_entity,
897            };
898            Err(Error::ResponseError(local_var_error))
899        }
900    }
901}
902
903/// struct for typed errors of method [`EmergencyAccessApi::accept`]
904#[derive(Debug, Clone, Serialize, Deserialize)]
905#[serde(untagged)]
906pub enum AcceptError {
907    UnknownValue(serde_json::Value),
908}
909/// struct for typed errors of method [`EmergencyAccessApi::approve`]
910#[derive(Debug, Clone, Serialize, Deserialize)]
911#[serde(untagged)]
912pub enum ApproveError {
913    UnknownValue(serde_json::Value),
914}
915/// struct for typed errors of method [`EmergencyAccessApi::confirm`]
916#[derive(Debug, Clone, Serialize, Deserialize)]
917#[serde(untagged)]
918pub enum ConfirmError {
919    UnknownValue(serde_json::Value),
920}
921/// struct for typed errors of method [`EmergencyAccessApi::delete`]
922#[derive(Debug, Clone, Serialize, Deserialize)]
923#[serde(untagged)]
924pub enum DeleteError {
925    UnknownValue(serde_json::Value),
926}
927/// struct for typed errors of method [`EmergencyAccessApi::get`]
928#[derive(Debug, Clone, Serialize, Deserialize)]
929#[serde(untagged)]
930pub enum GetError {
931    UnknownValue(serde_json::Value),
932}
933/// struct for typed errors of method [`EmergencyAccessApi::get_attachment_data`]
934#[derive(Debug, Clone, Serialize, Deserialize)]
935#[serde(untagged)]
936pub enum GetAttachmentDataError {
937    UnknownValue(serde_json::Value),
938}
939/// struct for typed errors of method [`EmergencyAccessApi::get_contacts`]
940#[derive(Debug, Clone, Serialize, Deserialize)]
941#[serde(untagged)]
942pub enum GetContactsError {
943    UnknownValue(serde_json::Value),
944}
945/// struct for typed errors of method [`EmergencyAccessApi::get_grantees`]
946#[derive(Debug, Clone, Serialize, Deserialize)]
947#[serde(untagged)]
948pub enum GetGranteesError {
949    UnknownValue(serde_json::Value),
950}
951/// struct for typed errors of method [`EmergencyAccessApi::initiate`]
952#[derive(Debug, Clone, Serialize, Deserialize)]
953#[serde(untagged)]
954pub enum InitiateError {
955    UnknownValue(serde_json::Value),
956}
957/// struct for typed errors of method [`EmergencyAccessApi::invite`]
958#[derive(Debug, Clone, Serialize, Deserialize)]
959#[serde(untagged)]
960pub enum InviteError {
961    UnknownValue(serde_json::Value),
962}
963/// struct for typed errors of method [`EmergencyAccessApi::password`]
964#[derive(Debug, Clone, Serialize, Deserialize)]
965#[serde(untagged)]
966pub enum PasswordError {
967    UnknownValue(serde_json::Value),
968}
969/// struct for typed errors of method [`EmergencyAccessApi::policies`]
970#[derive(Debug, Clone, Serialize, Deserialize)]
971#[serde(untagged)]
972pub enum PoliciesError {
973    UnknownValue(serde_json::Value),
974}
975/// struct for typed errors of method [`EmergencyAccessApi::put`]
976#[derive(Debug, Clone, Serialize, Deserialize)]
977#[serde(untagged)]
978pub enum PutError {
979    UnknownValue(serde_json::Value),
980}
981/// struct for typed errors of method [`EmergencyAccessApi::reinvite`]
982#[derive(Debug, Clone, Serialize, Deserialize)]
983#[serde(untagged)]
984pub enum ReinviteError {
985    UnknownValue(serde_json::Value),
986}
987/// struct for typed errors of method [`EmergencyAccessApi::reject`]
988#[derive(Debug, Clone, Serialize, Deserialize)]
989#[serde(untagged)]
990pub enum RejectError {
991    UnknownValue(serde_json::Value),
992}
993/// struct for typed errors of method [`EmergencyAccessApi::takeover`]
994#[derive(Debug, Clone, Serialize, Deserialize)]
995#[serde(untagged)]
996pub enum TakeoverError {
997    UnknownValue(serde_json::Value),
998}
999/// struct for typed errors of method [`EmergencyAccessApi::view_ciphers`]
1000#[derive(Debug, Clone, Serialize, Deserialize)]
1001#[serde(untagged)]
1002pub enum ViewCiphersError {
1003    UnknownValue(serde_json::Value),
1004}