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        bitwarden_api_base::process_with_empty_response(local_var_req_builder).await
165    }
166
167    async fn approve<'a>(&self, id: uuid::Uuid) -> Result<(), Error<ApproveError>> {
168        let local_var_configuration = &self.configuration;
169
170        let local_var_client = &local_var_configuration.client;
171
172        let local_var_uri_str = format!(
173            "{}/emergency-access/{id}/approve",
174            local_var_configuration.base_path,
175            id = id
176        );
177        let mut local_var_req_builder =
178            local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
179
180        local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
181
182        bitwarden_api_base::process_with_empty_response(local_var_req_builder).await
183    }
184
185    async fn confirm<'a>(
186        &self,
187        id: uuid::Uuid,
188        organization_user_confirm_request_model: Option<
189            models::OrganizationUserConfirmRequestModel,
190        >,
191    ) -> Result<(), Error<ConfirmError>> {
192        let local_var_configuration = &self.configuration;
193
194        let local_var_client = &local_var_configuration.client;
195
196        let local_var_uri_str = format!(
197            "{}/emergency-access/{id}/confirm",
198            local_var_configuration.base_path,
199            id = id
200        );
201        let mut local_var_req_builder =
202            local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
203
204        local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
205        local_var_req_builder =
206            local_var_req_builder.json(&organization_user_confirm_request_model);
207
208        bitwarden_api_base::process_with_empty_response(local_var_req_builder).await
209    }
210
211    async fn delete<'a>(&self, id: uuid::Uuid) -> Result<(), Error<DeleteError>> {
212        let local_var_configuration = &self.configuration;
213
214        let local_var_client = &local_var_configuration.client;
215
216        let local_var_uri_str = format!(
217            "{}/emergency-access/{id}",
218            local_var_configuration.base_path,
219            id = id
220        );
221        let mut local_var_req_builder =
222            local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str());
223
224        local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
225
226        bitwarden_api_base::process_with_empty_response(local_var_req_builder).await
227    }
228
229    async fn get<'a>(
230        &self,
231        id: uuid::Uuid,
232    ) -> Result<models::EmergencyAccessGranteeDetailsResponseModel, Error<GetError>> {
233        let local_var_configuration = &self.configuration;
234
235        let local_var_client = &local_var_configuration.client;
236
237        let local_var_uri_str = format!(
238            "{}/emergency-access/{id}",
239            local_var_configuration.base_path,
240            id = id
241        );
242        let mut local_var_req_builder =
243            local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
244
245        local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
246
247        bitwarden_api_base::process_with_json_response(local_var_req_builder).await
248    }
249
250    async fn get_attachment_data<'a>(
251        &self,
252        id: uuid::Uuid,
253        cipher_id: uuid::Uuid,
254        attachment_id: &'a str,
255    ) -> Result<models::AttachmentResponseModel, Error<GetAttachmentDataError>> {
256        let local_var_configuration = &self.configuration;
257
258        let local_var_client = &local_var_configuration.client;
259
260        let local_var_uri_str = format!(
261            "{}/emergency-access/{id}/{cipherId}/attachment/{attachmentId}",
262            local_var_configuration.base_path,
263            id = id,
264            cipherId = cipher_id,
265            attachmentId = crate::apis::urlencode(attachment_id)
266        );
267        let mut local_var_req_builder =
268            local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
269
270        local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
271
272        bitwarden_api_base::process_with_json_response(local_var_req_builder).await
273    }
274
275    async fn get_contacts(
276        &self,
277    ) -> Result<
278        models::EmergencyAccessGranteeDetailsResponseModelListResponseModel,
279        Error<GetContactsError>,
280    > {
281        let local_var_configuration = &self.configuration;
282
283        let local_var_client = &local_var_configuration.client;
284
285        let local_var_uri_str = format!(
286            "{}/emergency-access/trusted",
287            local_var_configuration.base_path
288        );
289        let mut local_var_req_builder =
290            local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
291
292        local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
293
294        bitwarden_api_base::process_with_json_response(local_var_req_builder).await
295    }
296
297    async fn get_grantees(
298        &self,
299    ) -> Result<
300        models::EmergencyAccessGrantorDetailsResponseModelListResponseModel,
301        Error<GetGranteesError>,
302    > {
303        let local_var_configuration = &self.configuration;
304
305        let local_var_client = &local_var_configuration.client;
306
307        let local_var_uri_str = format!(
308            "{}/emergency-access/granted",
309            local_var_configuration.base_path
310        );
311        let mut local_var_req_builder =
312            local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
313
314        local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
315
316        bitwarden_api_base::process_with_json_response(local_var_req_builder).await
317    }
318
319    async fn initiate<'a>(&self, id: uuid::Uuid) -> Result<(), Error<InitiateError>> {
320        let local_var_configuration = &self.configuration;
321
322        let local_var_client = &local_var_configuration.client;
323
324        let local_var_uri_str = format!(
325            "{}/emergency-access/{id}/initiate",
326            local_var_configuration.base_path,
327            id = id
328        );
329        let mut local_var_req_builder =
330            local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
331
332        local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
333
334        bitwarden_api_base::process_with_empty_response(local_var_req_builder).await
335    }
336
337    async fn invite<'a>(
338        &self,
339        emergency_access_invite_request_model: Option<models::EmergencyAccessInviteRequestModel>,
340    ) -> Result<(), Error<InviteError>> {
341        let local_var_configuration = &self.configuration;
342
343        let local_var_client = &local_var_configuration.client;
344
345        let local_var_uri_str = format!(
346            "{}/emergency-access/invite",
347            local_var_configuration.base_path
348        );
349        let mut local_var_req_builder =
350            local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
351
352        local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
353        local_var_req_builder = local_var_req_builder.json(&emergency_access_invite_request_model);
354
355        bitwarden_api_base::process_with_empty_response(local_var_req_builder).await
356    }
357
358    async fn password<'a>(
359        &self,
360        id: uuid::Uuid,
361        emergency_access_password_request_model: Option<
362            models::EmergencyAccessPasswordRequestModel,
363        >,
364    ) -> Result<(), Error<PasswordError>> {
365        let local_var_configuration = &self.configuration;
366
367        let local_var_client = &local_var_configuration.client;
368
369        let local_var_uri_str = format!(
370            "{}/emergency-access/{id}/password",
371            local_var_configuration.base_path,
372            id = id
373        );
374        let mut local_var_req_builder =
375            local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
376
377        local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
378        local_var_req_builder =
379            local_var_req_builder.json(&emergency_access_password_request_model);
380
381        bitwarden_api_base::process_with_empty_response(local_var_req_builder).await
382    }
383
384    async fn policies<'a>(
385        &self,
386        id: uuid::Uuid,
387    ) -> Result<models::PolicyResponseModelListResponseModel, Error<PoliciesError>> {
388        let local_var_configuration = &self.configuration;
389
390        let local_var_client = &local_var_configuration.client;
391
392        let local_var_uri_str = format!(
393            "{}/emergency-access/{id}/policies",
394            local_var_configuration.base_path,
395            id = id
396        );
397        let mut local_var_req_builder =
398            local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
399
400        local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
401
402        bitwarden_api_base::process_with_json_response(local_var_req_builder).await
403    }
404
405    async fn put<'a>(
406        &self,
407        id: uuid::Uuid,
408        emergency_access_update_request_model: Option<models::EmergencyAccessUpdateRequestModel>,
409    ) -> Result<(), Error<PutError>> {
410        let local_var_configuration = &self.configuration;
411
412        let local_var_client = &local_var_configuration.client;
413
414        let local_var_uri_str = format!(
415            "{}/emergency-access/{id}",
416            local_var_configuration.base_path,
417            id = id
418        );
419        let mut local_var_req_builder =
420            local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str());
421
422        local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
423        local_var_req_builder = local_var_req_builder.json(&emergency_access_update_request_model);
424
425        bitwarden_api_base::process_with_empty_response(local_var_req_builder).await
426    }
427
428    async fn reinvite<'a>(&self, id: uuid::Uuid) -> Result<(), Error<ReinviteError>> {
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!(
434            "{}/emergency-access/{id}/reinvite",
435            local_var_configuration.base_path,
436            id = id
437        );
438        let mut local_var_req_builder =
439            local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
440
441        local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
442
443        bitwarden_api_base::process_with_empty_response(local_var_req_builder).await
444    }
445
446    async fn reject<'a>(&self, id: uuid::Uuid) -> Result<(), Error<RejectError>> {
447        let local_var_configuration = &self.configuration;
448
449        let local_var_client = &local_var_configuration.client;
450
451        let local_var_uri_str = format!(
452            "{}/emergency-access/{id}/reject",
453            local_var_configuration.base_path,
454            id = id
455        );
456        let mut local_var_req_builder =
457            local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
458
459        local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
460
461        bitwarden_api_base::process_with_empty_response(local_var_req_builder).await
462    }
463
464    async fn takeover<'a>(
465        &self,
466        id: uuid::Uuid,
467    ) -> Result<models::EmergencyAccessTakeoverResponseModel, Error<TakeoverError>> {
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/{id}/takeover",
474            local_var_configuration.base_path,
475            id = id
476        );
477        let mut local_var_req_builder =
478            local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
479
480        local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
481
482        bitwarden_api_base::process_with_json_response(local_var_req_builder).await
483    }
484
485    async fn view_ciphers<'a>(
486        &self,
487        id: uuid::Uuid,
488    ) -> Result<models::EmergencyAccessViewResponseModel, Error<ViewCiphersError>> {
489        let local_var_configuration = &self.configuration;
490
491        let local_var_client = &local_var_configuration.client;
492
493        let local_var_uri_str = format!(
494            "{}/emergency-access/{id}/view",
495            local_var_configuration.base_path,
496            id = id
497        );
498        let mut local_var_req_builder =
499            local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
500
501        local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
502
503        bitwarden_api_base::process_with_json_response(local_var_req_builder).await
504    }
505}
506
507/// struct for typed errors of method [`EmergencyAccessApi::accept`]
508#[derive(Debug, Clone, Serialize, Deserialize)]
509#[serde(untagged)]
510pub enum AcceptError {
511    UnknownValue(serde_json::Value),
512}
513/// struct for typed errors of method [`EmergencyAccessApi::approve`]
514#[derive(Debug, Clone, Serialize, Deserialize)]
515#[serde(untagged)]
516pub enum ApproveError {
517    UnknownValue(serde_json::Value),
518}
519/// struct for typed errors of method [`EmergencyAccessApi::confirm`]
520#[derive(Debug, Clone, Serialize, Deserialize)]
521#[serde(untagged)]
522pub enum ConfirmError {
523    UnknownValue(serde_json::Value),
524}
525/// struct for typed errors of method [`EmergencyAccessApi::delete`]
526#[derive(Debug, Clone, Serialize, Deserialize)]
527#[serde(untagged)]
528pub enum DeleteError {
529    UnknownValue(serde_json::Value),
530}
531/// struct for typed errors of method [`EmergencyAccessApi::get`]
532#[derive(Debug, Clone, Serialize, Deserialize)]
533#[serde(untagged)]
534pub enum GetError {
535    UnknownValue(serde_json::Value),
536}
537/// struct for typed errors of method [`EmergencyAccessApi::get_attachment_data`]
538#[derive(Debug, Clone, Serialize, Deserialize)]
539#[serde(untagged)]
540pub enum GetAttachmentDataError {
541    UnknownValue(serde_json::Value),
542}
543/// struct for typed errors of method [`EmergencyAccessApi::get_contacts`]
544#[derive(Debug, Clone, Serialize, Deserialize)]
545#[serde(untagged)]
546pub enum GetContactsError {
547    UnknownValue(serde_json::Value),
548}
549/// struct for typed errors of method [`EmergencyAccessApi::get_grantees`]
550#[derive(Debug, Clone, Serialize, Deserialize)]
551#[serde(untagged)]
552pub enum GetGranteesError {
553    UnknownValue(serde_json::Value),
554}
555/// struct for typed errors of method [`EmergencyAccessApi::initiate`]
556#[derive(Debug, Clone, Serialize, Deserialize)]
557#[serde(untagged)]
558pub enum InitiateError {
559    UnknownValue(serde_json::Value),
560}
561/// struct for typed errors of method [`EmergencyAccessApi::invite`]
562#[derive(Debug, Clone, Serialize, Deserialize)]
563#[serde(untagged)]
564pub enum InviteError {
565    UnknownValue(serde_json::Value),
566}
567/// struct for typed errors of method [`EmergencyAccessApi::password`]
568#[derive(Debug, Clone, Serialize, Deserialize)]
569#[serde(untagged)]
570pub enum PasswordError {
571    UnknownValue(serde_json::Value),
572}
573/// struct for typed errors of method [`EmergencyAccessApi::policies`]
574#[derive(Debug, Clone, Serialize, Deserialize)]
575#[serde(untagged)]
576pub enum PoliciesError {
577    UnknownValue(serde_json::Value),
578}
579/// struct for typed errors of method [`EmergencyAccessApi::put`]
580#[derive(Debug, Clone, Serialize, Deserialize)]
581#[serde(untagged)]
582pub enum PutError {
583    UnknownValue(serde_json::Value),
584}
585/// struct for typed errors of method [`EmergencyAccessApi::reinvite`]
586#[derive(Debug, Clone, Serialize, Deserialize)]
587#[serde(untagged)]
588pub enum ReinviteError {
589    UnknownValue(serde_json::Value),
590}
591/// struct for typed errors of method [`EmergencyAccessApi::reject`]
592#[derive(Debug, Clone, Serialize, Deserialize)]
593#[serde(untagged)]
594pub enum RejectError {
595    UnknownValue(serde_json::Value),
596}
597/// struct for typed errors of method [`EmergencyAccessApi::takeover`]
598#[derive(Debug, Clone, Serialize, Deserialize)]
599#[serde(untagged)]
600pub enum TakeoverError {
601    UnknownValue(serde_json::Value),
602}
603/// struct for typed errors of method [`EmergencyAccessApi::view_ciphers`]
604#[derive(Debug, Clone, Serialize, Deserialize)]
605#[serde(untagged)]
606pub enum ViewCiphersError {
607    UnknownValue(serde_json::Value),
608}