1use std::sync::Arc;
12
13use async_trait::async_trait;
14#[cfg(feature = "mockall")]
15use mockall::automock;
16use reqwest;
17use serde::{Deserialize, Serialize, de::Error as _};
18
19use super::{Error, configuration};
20use crate::{
21 apis::{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 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 async fn approve<'a>(&self, id: uuid::Uuid) -> Result<(), Error<ApproveError>>;
38
39 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 async fn delete<'a>(&self, id: uuid::Uuid) -> Result<(), Error<DeleteError>>;
50
51 async fn get<'a>(
53 &self,
54 id: uuid::Uuid,
55 ) -> Result<models::EmergencyAccessGranteeDetailsResponseModel, Error<GetError>>;
56
57 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 async fn get_contacts(
67 &self,
68 ) -> Result<
69 models::EmergencyAccessGranteeDetailsResponseModelListResponseModel,
70 Error<GetContactsError>,
71 >;
72
73 async fn get_grantees(
75 &self,
76 ) -> Result<
77 models::EmergencyAccessGrantorDetailsResponseModelListResponseModel,
78 Error<GetGranteesError>,
79 >;
80
81 async fn initiate<'a>(&self, id: uuid::Uuid) -> Result<(), Error<InitiateError>>;
83
84 async fn invite<'a>(
86 &self,
87 emergency_access_invite_request_model: Option<models::EmergencyAccessInviteRequestModel>,
88 ) -> Result<(), Error<InviteError>>;
89
90 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 async fn policies<'a>(
101 &self,
102 id: uuid::Uuid,
103 ) -> Result<models::PolicyResponseModelListResponseModel, Error<PoliciesError>>;
104
105 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 async fn reinvite<'a>(&self, id: uuid::Uuid) -> Result<(), Error<ReinviteError>>;
114
115 async fn reject<'a>(&self, id: uuid::Uuid) -> Result<(), Error<RejectError>>;
117
118 async fn takeover<'a>(
120 &self,
121 id: uuid::Uuid,
122 ) -> Result<models::EmergencyAccessTakeoverResponseModel, Error<TakeoverError>>;
123
124 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 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
162 local_var_req_builder = local_var_req_builder
163 .header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
164 }
165 if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
166 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
167 };
168 local_var_req_builder = local_var_req_builder.json(&organization_user_accept_request_model);
169
170 let local_var_req = local_var_req_builder.build()?;
171 let local_var_resp = local_var_client.execute(local_var_req).await?;
172
173 let local_var_status = local_var_resp.status();
174 let local_var_content = local_var_resp.text().await?;
175
176 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
177 Ok(())
178 } else {
179 let local_var_entity: Option<AcceptError> =
180 serde_json::from_str(&local_var_content).ok();
181 let local_var_error = ResponseContent {
182 status: local_var_status,
183 content: local_var_content,
184 entity: local_var_entity,
185 };
186 Err(Error::ResponseError(local_var_error))
187 }
188 }
189
190 async fn approve<'a>(&self, id: uuid::Uuid) -> Result<(), Error<ApproveError>> {
191 let local_var_configuration = &self.configuration;
192
193 let local_var_client = &local_var_configuration.client;
194
195 let local_var_uri_str = format!(
196 "{}/emergency-access/{id}/approve",
197 local_var_configuration.base_path,
198 id = id
199 );
200 let mut local_var_req_builder =
201 local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
202
203 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
204 local_var_req_builder = local_var_req_builder
205 .header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
206 }
207 if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
208 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
209 };
210
211 let local_var_req = local_var_req_builder.build()?;
212 let local_var_resp = local_var_client.execute(local_var_req).await?;
213
214 let local_var_status = local_var_resp.status();
215 let local_var_content = local_var_resp.text().await?;
216
217 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
218 Ok(())
219 } else {
220 let local_var_entity: Option<ApproveError> =
221 serde_json::from_str(&local_var_content).ok();
222 let local_var_error = ResponseContent {
223 status: local_var_status,
224 content: local_var_content,
225 entity: local_var_entity,
226 };
227 Err(Error::ResponseError(local_var_error))
228 }
229 }
230
231 async fn confirm<'a>(
232 &self,
233 id: uuid::Uuid,
234 organization_user_confirm_request_model: Option<
235 models::OrganizationUserConfirmRequestModel,
236 >,
237 ) -> Result<(), Error<ConfirmError>> {
238 let local_var_configuration = &self.configuration;
239
240 let local_var_client = &local_var_configuration.client;
241
242 let local_var_uri_str = format!(
243 "{}/emergency-access/{id}/confirm",
244 local_var_configuration.base_path,
245 id = id
246 );
247 let mut local_var_req_builder =
248 local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
249
250 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
251 local_var_req_builder = local_var_req_builder
252 .header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
253 }
254 if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
255 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
256 };
257 local_var_req_builder =
258 local_var_req_builder.json(&organization_user_confirm_request_model);
259
260 let local_var_req = local_var_req_builder.build()?;
261 let local_var_resp = local_var_client.execute(local_var_req).await?;
262
263 let local_var_status = local_var_resp.status();
264 let local_var_content = local_var_resp.text().await?;
265
266 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
267 Ok(())
268 } else {
269 let local_var_entity: Option<ConfirmError> =
270 serde_json::from_str(&local_var_content).ok();
271 let local_var_error = ResponseContent {
272 status: local_var_status,
273 content: local_var_content,
274 entity: local_var_entity,
275 };
276 Err(Error::ResponseError(local_var_error))
277 }
278 }
279
280 async fn delete<'a>(&self, id: uuid::Uuid) -> Result<(), Error<DeleteError>> {
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/{id}",
287 local_var_configuration.base_path,
288 id = id
289 );
290 let mut local_var_req_builder =
291 local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str());
292
293 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
294 local_var_req_builder = local_var_req_builder
295 .header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
296 }
297 if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
298 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
299 };
300
301 let local_var_req = local_var_req_builder.build()?;
302 let local_var_resp = local_var_client.execute(local_var_req).await?;
303
304 let local_var_status = local_var_resp.status();
305 let local_var_content = local_var_resp.text().await?;
306
307 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
308 Ok(())
309 } else {
310 let local_var_entity: Option<DeleteError> =
311 serde_json::from_str(&local_var_content).ok();
312 let local_var_error = ResponseContent {
313 status: local_var_status,
314 content: local_var_content,
315 entity: local_var_entity,
316 };
317 Err(Error::ResponseError(local_var_error))
318 }
319 }
320
321 async fn get<'a>(
322 &self,
323 id: uuid::Uuid,
324 ) -> Result<models::EmergencyAccessGranteeDetailsResponseModel, Error<GetError>> {
325 let local_var_configuration = &self.configuration;
326
327 let local_var_client = &local_var_configuration.client;
328
329 let local_var_uri_str = format!(
330 "{}/emergency-access/{id}",
331 local_var_configuration.base_path,
332 id = id
333 );
334 let mut local_var_req_builder =
335 local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
336
337 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
338 local_var_req_builder = local_var_req_builder
339 .header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
340 }
341 if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
342 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
343 };
344
345 let local_var_req = local_var_req_builder.build()?;
346 let local_var_resp = local_var_client.execute(local_var_req).await?;
347
348 let local_var_status = local_var_resp.status();
349 let local_var_content_type = local_var_resp
350 .headers()
351 .get("content-type")
352 .and_then(|v| v.to_str().ok())
353 .unwrap_or("application/octet-stream");
354 let local_var_content_type = super::ContentType::from(local_var_content_type);
355 let local_var_content = local_var_resp.text().await?;
356
357 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
358 match local_var_content_type {
359 ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from),
360 ContentType::Text => {
361 return Err(Error::from(serde_json::Error::custom(
362 "Received `text/plain` content type response that cannot be converted to `models::EmergencyAccessGranteeDetailsResponseModel`",
363 )));
364 }
365 ContentType::Unsupported(local_var_unknown_type) => {
366 return Err(Error::from(serde_json::Error::custom(format!(
367 "Received `{local_var_unknown_type}` content type response that cannot be converted to `models::EmergencyAccessGranteeDetailsResponseModel`"
368 ))));
369 }
370 }
371 } else {
372 let local_var_entity: Option<GetError> = serde_json::from_str(&local_var_content).ok();
373 let local_var_error = ResponseContent {
374 status: local_var_status,
375 content: local_var_content,
376 entity: local_var_entity,
377 };
378 Err(Error::ResponseError(local_var_error))
379 }
380 }
381
382 async fn get_attachment_data<'a>(
383 &self,
384 id: uuid::Uuid,
385 cipher_id: uuid::Uuid,
386 attachment_id: &'a str,
387 ) -> Result<models::AttachmentResponseModel, Error<GetAttachmentDataError>> {
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}/{cipherId}/attachment/{attachmentId}",
394 local_var_configuration.base_path,
395 id = id,
396 cipherId = cipher_id,
397 attachmentId = crate::apis::urlencode(attachment_id)
398 );
399 let mut local_var_req_builder =
400 local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
401
402 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
403 local_var_req_builder = local_var_req_builder
404 .header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
405 }
406 if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
407 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
408 };
409
410 let local_var_req = local_var_req_builder.build()?;
411 let local_var_resp = local_var_client.execute(local_var_req).await?;
412
413 let local_var_status = local_var_resp.status();
414 let local_var_content_type = local_var_resp
415 .headers()
416 .get("content-type")
417 .and_then(|v| v.to_str().ok())
418 .unwrap_or("application/octet-stream");
419 let local_var_content_type = super::ContentType::from(local_var_content_type);
420 let local_var_content = local_var_resp.text().await?;
421
422 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
423 match local_var_content_type {
424 ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from),
425 ContentType::Text => {
426 return Err(Error::from(serde_json::Error::custom(
427 "Received `text/plain` content type response that cannot be converted to `models::AttachmentResponseModel`",
428 )));
429 }
430 ContentType::Unsupported(local_var_unknown_type) => {
431 return Err(Error::from(serde_json::Error::custom(format!(
432 "Received `{local_var_unknown_type}` content type response that cannot be converted to `models::AttachmentResponseModel`"
433 ))));
434 }
435 }
436 } else {
437 let local_var_entity: Option<GetAttachmentDataError> =
438 serde_json::from_str(&local_var_content).ok();
439 let local_var_error = ResponseContent {
440 status: local_var_status,
441 content: local_var_content,
442 entity: local_var_entity,
443 };
444 Err(Error::ResponseError(local_var_error))
445 }
446 }
447
448 async fn get_contacts(
449 &self,
450 ) -> Result<
451 models::EmergencyAccessGranteeDetailsResponseModelListResponseModel,
452 Error<GetContactsError>,
453 > {
454 let local_var_configuration = &self.configuration;
455
456 let local_var_client = &local_var_configuration.client;
457
458 let local_var_uri_str = format!(
459 "{}/emergency-access/trusted",
460 local_var_configuration.base_path
461 );
462 let mut local_var_req_builder =
463 local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
464
465 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
466 local_var_req_builder = local_var_req_builder
467 .header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
468 }
469 if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
470 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
471 };
472
473 let local_var_req = local_var_req_builder.build()?;
474 let local_var_resp = local_var_client.execute(local_var_req).await?;
475
476 let local_var_status = local_var_resp.status();
477 let local_var_content_type = local_var_resp
478 .headers()
479 .get("content-type")
480 .and_then(|v| v.to_str().ok())
481 .unwrap_or("application/octet-stream");
482 let local_var_content_type = super::ContentType::from(local_var_content_type);
483 let local_var_content = local_var_resp.text().await?;
484
485 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
486 match local_var_content_type {
487 ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from),
488 ContentType::Text => {
489 return Err(Error::from(serde_json::Error::custom(
490 "Received `text/plain` content type response that cannot be converted to `models::EmergencyAccessGranteeDetailsResponseModelListResponseModel`",
491 )));
492 }
493 ContentType::Unsupported(local_var_unknown_type) => {
494 return Err(Error::from(serde_json::Error::custom(format!(
495 "Received `{local_var_unknown_type}` content type response that cannot be converted to `models::EmergencyAccessGranteeDetailsResponseModelListResponseModel`"
496 ))));
497 }
498 }
499 } else {
500 let local_var_entity: Option<GetContactsError> =
501 serde_json::from_str(&local_var_content).ok();
502 let local_var_error = ResponseContent {
503 status: local_var_status,
504 content: local_var_content,
505 entity: local_var_entity,
506 };
507 Err(Error::ResponseError(local_var_error))
508 }
509 }
510
511 async fn get_grantees(
512 &self,
513 ) -> Result<
514 models::EmergencyAccessGrantorDetailsResponseModelListResponseModel,
515 Error<GetGranteesError>,
516 > {
517 let local_var_configuration = &self.configuration;
518
519 let local_var_client = &local_var_configuration.client;
520
521 let local_var_uri_str = format!(
522 "{}/emergency-access/granted",
523 local_var_configuration.base_path
524 );
525 let mut local_var_req_builder =
526 local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
527
528 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
529 local_var_req_builder = local_var_req_builder
530 .header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
531 }
532 if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
533 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
534 };
535
536 let local_var_req = local_var_req_builder.build()?;
537 let local_var_resp = local_var_client.execute(local_var_req).await?;
538
539 let local_var_status = local_var_resp.status();
540 let local_var_content_type = local_var_resp
541 .headers()
542 .get("content-type")
543 .and_then(|v| v.to_str().ok())
544 .unwrap_or("application/octet-stream");
545 let local_var_content_type = super::ContentType::from(local_var_content_type);
546 let local_var_content = local_var_resp.text().await?;
547
548 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
549 match local_var_content_type {
550 ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from),
551 ContentType::Text => {
552 return Err(Error::from(serde_json::Error::custom(
553 "Received `text/plain` content type response that cannot be converted to `models::EmergencyAccessGrantorDetailsResponseModelListResponseModel`",
554 )));
555 }
556 ContentType::Unsupported(local_var_unknown_type) => {
557 return Err(Error::from(serde_json::Error::custom(format!(
558 "Received `{local_var_unknown_type}` content type response that cannot be converted to `models::EmergencyAccessGrantorDetailsResponseModelListResponseModel`"
559 ))));
560 }
561 }
562 } else {
563 let local_var_entity: Option<GetGranteesError> =
564 serde_json::from_str(&local_var_content).ok();
565 let local_var_error = ResponseContent {
566 status: local_var_status,
567 content: local_var_content,
568 entity: local_var_entity,
569 };
570 Err(Error::ResponseError(local_var_error))
571 }
572 }
573
574 async fn initiate<'a>(&self, id: uuid::Uuid) -> Result<(), Error<InitiateError>> {
575 let local_var_configuration = &self.configuration;
576
577 let local_var_client = &local_var_configuration.client;
578
579 let local_var_uri_str = format!(
580 "{}/emergency-access/{id}/initiate",
581 local_var_configuration.base_path,
582 id = id
583 );
584 let mut local_var_req_builder =
585 local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
586
587 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
588 local_var_req_builder = local_var_req_builder
589 .header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
590 }
591 if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
592 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
593 };
594
595 let local_var_req = local_var_req_builder.build()?;
596 let local_var_resp = local_var_client.execute(local_var_req).await?;
597
598 let local_var_status = local_var_resp.status();
599 let local_var_content = local_var_resp.text().await?;
600
601 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
602 Ok(())
603 } else {
604 let local_var_entity: Option<InitiateError> =
605 serde_json::from_str(&local_var_content).ok();
606 let local_var_error = ResponseContent {
607 status: local_var_status,
608 content: local_var_content,
609 entity: local_var_entity,
610 };
611 Err(Error::ResponseError(local_var_error))
612 }
613 }
614
615 async fn invite<'a>(
616 &self,
617 emergency_access_invite_request_model: Option<models::EmergencyAccessInviteRequestModel>,
618 ) -> Result<(), Error<InviteError>> {
619 let local_var_configuration = &self.configuration;
620
621 let local_var_client = &local_var_configuration.client;
622
623 let local_var_uri_str = format!(
624 "{}/emergency-access/invite",
625 local_var_configuration.base_path
626 );
627 let mut local_var_req_builder =
628 local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
629
630 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
631 local_var_req_builder = local_var_req_builder
632 .header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
633 }
634 if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
635 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
636 };
637 local_var_req_builder = local_var_req_builder.json(&emergency_access_invite_request_model);
638
639 let local_var_req = local_var_req_builder.build()?;
640 let local_var_resp = local_var_client.execute(local_var_req).await?;
641
642 let local_var_status = local_var_resp.status();
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 Ok(())
647 } else {
648 let local_var_entity: Option<InviteError> =
649 serde_json::from_str(&local_var_content).ok();
650 let local_var_error = ResponseContent {
651 status: local_var_status,
652 content: local_var_content,
653 entity: local_var_entity,
654 };
655 Err(Error::ResponseError(local_var_error))
656 }
657 }
658
659 async fn password<'a>(
660 &self,
661 id: uuid::Uuid,
662 emergency_access_password_request_model: Option<
663 models::EmergencyAccessPasswordRequestModel,
664 >,
665 ) -> Result<(), Error<PasswordError>> {
666 let local_var_configuration = &self.configuration;
667
668 let local_var_client = &local_var_configuration.client;
669
670 let local_var_uri_str = format!(
671 "{}/emergency-access/{id}/password",
672 local_var_configuration.base_path,
673 id = id
674 );
675 let mut local_var_req_builder =
676 local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
677
678 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
679 local_var_req_builder = local_var_req_builder
680 .header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
681 }
682 if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
683 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
684 };
685 local_var_req_builder =
686 local_var_req_builder.json(&emergency_access_password_request_model);
687
688 let local_var_req = local_var_req_builder.build()?;
689 let local_var_resp = local_var_client.execute(local_var_req).await?;
690
691 let local_var_status = local_var_resp.status();
692 let local_var_content = local_var_resp.text().await?;
693
694 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
695 Ok(())
696 } else {
697 let local_var_entity: Option<PasswordError> =
698 serde_json::from_str(&local_var_content).ok();
699 let local_var_error = ResponseContent {
700 status: local_var_status,
701 content: local_var_content,
702 entity: local_var_entity,
703 };
704 Err(Error::ResponseError(local_var_error))
705 }
706 }
707
708 async fn policies<'a>(
709 &self,
710 id: uuid::Uuid,
711 ) -> Result<models::PolicyResponseModelListResponseModel, Error<PoliciesError>> {
712 let local_var_configuration = &self.configuration;
713
714 let local_var_client = &local_var_configuration.client;
715
716 let local_var_uri_str = format!(
717 "{}/emergency-access/{id}/policies",
718 local_var_configuration.base_path,
719 id = id
720 );
721 let mut local_var_req_builder =
722 local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
723
724 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
725 local_var_req_builder = local_var_req_builder
726 .header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
727 }
728 if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
729 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
730 };
731
732 let local_var_req = local_var_req_builder.build()?;
733 let local_var_resp = local_var_client.execute(local_var_req).await?;
734
735 let local_var_status = local_var_resp.status();
736 let local_var_content_type = local_var_resp
737 .headers()
738 .get("content-type")
739 .and_then(|v| v.to_str().ok())
740 .unwrap_or("application/octet-stream");
741 let local_var_content_type = super::ContentType::from(local_var_content_type);
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 match local_var_content_type {
746 ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from),
747 ContentType::Text => {
748 return Err(Error::from(serde_json::Error::custom(
749 "Received `text/plain` content type response that cannot be converted to `models::PolicyResponseModelListResponseModel`",
750 )));
751 }
752 ContentType::Unsupported(local_var_unknown_type) => {
753 return Err(Error::from(serde_json::Error::custom(format!(
754 "Received `{local_var_unknown_type}` content type response that cannot be converted to `models::PolicyResponseModelListResponseModel`"
755 ))));
756 }
757 }
758 } else {
759 let local_var_entity: Option<PoliciesError> =
760 serde_json::from_str(&local_var_content).ok();
761 let local_var_error = ResponseContent {
762 status: local_var_status,
763 content: local_var_content,
764 entity: local_var_entity,
765 };
766 Err(Error::ResponseError(local_var_error))
767 }
768 }
769
770 async fn put<'a>(
771 &self,
772 id: uuid::Uuid,
773 emergency_access_update_request_model: Option<models::EmergencyAccessUpdateRequestModel>,
774 ) -> Result<(), Error<PutError>> {
775 let local_var_configuration = &self.configuration;
776
777 let local_var_client = &local_var_configuration.client;
778
779 let local_var_uri_str = format!(
780 "{}/emergency-access/{id}",
781 local_var_configuration.base_path,
782 id = id
783 );
784 let mut local_var_req_builder =
785 local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str());
786
787 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
788 local_var_req_builder = local_var_req_builder
789 .header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
790 }
791 if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
792 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
793 };
794 local_var_req_builder = local_var_req_builder.json(&emergency_access_update_request_model);
795
796 let local_var_req = local_var_req_builder.build()?;
797 let local_var_resp = local_var_client.execute(local_var_req).await?;
798
799 let local_var_status = local_var_resp.status();
800 let local_var_content = local_var_resp.text().await?;
801
802 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
803 Ok(())
804 } else {
805 let local_var_entity: Option<PutError> = serde_json::from_str(&local_var_content).ok();
806 let local_var_error = ResponseContent {
807 status: local_var_status,
808 content: local_var_content,
809 entity: local_var_entity,
810 };
811 Err(Error::ResponseError(local_var_error))
812 }
813 }
814
815 async fn reinvite<'a>(&self, id: uuid::Uuid) -> Result<(), Error<ReinviteError>> {
816 let local_var_configuration = &self.configuration;
817
818 let local_var_client = &local_var_configuration.client;
819
820 let local_var_uri_str = format!(
821 "{}/emergency-access/{id}/reinvite",
822 local_var_configuration.base_path,
823 id = id
824 );
825 let mut local_var_req_builder =
826 local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
827
828 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
829 local_var_req_builder = local_var_req_builder
830 .header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
831 }
832 if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
833 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
834 };
835
836 let local_var_req = local_var_req_builder.build()?;
837 let local_var_resp = local_var_client.execute(local_var_req).await?;
838
839 let local_var_status = local_var_resp.status();
840 let local_var_content = local_var_resp.text().await?;
841
842 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
843 Ok(())
844 } else {
845 let local_var_entity: Option<ReinviteError> =
846 serde_json::from_str(&local_var_content).ok();
847 let local_var_error = ResponseContent {
848 status: local_var_status,
849 content: local_var_content,
850 entity: local_var_entity,
851 };
852 Err(Error::ResponseError(local_var_error))
853 }
854 }
855
856 async fn reject<'a>(&self, id: uuid::Uuid) -> Result<(), Error<RejectError>> {
857 let local_var_configuration = &self.configuration;
858
859 let local_var_client = &local_var_configuration.client;
860
861 let local_var_uri_str = format!(
862 "{}/emergency-access/{id}/reject",
863 local_var_configuration.base_path,
864 id = id
865 );
866 let mut local_var_req_builder =
867 local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
868
869 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
870 local_var_req_builder = local_var_req_builder
871 .header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
872 }
873 if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
874 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
875 };
876
877 let local_var_req = local_var_req_builder.build()?;
878 let local_var_resp = local_var_client.execute(local_var_req).await?;
879
880 let local_var_status = local_var_resp.status();
881 let local_var_content = local_var_resp.text().await?;
882
883 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
884 Ok(())
885 } else {
886 let local_var_entity: Option<RejectError> =
887 serde_json::from_str(&local_var_content).ok();
888 let local_var_error = ResponseContent {
889 status: local_var_status,
890 content: local_var_content,
891 entity: local_var_entity,
892 };
893 Err(Error::ResponseError(local_var_error))
894 }
895 }
896
897 async fn takeover<'a>(
898 &self,
899 id: uuid::Uuid,
900 ) -> Result<models::EmergencyAccessTakeoverResponseModel, Error<TakeoverError>> {
901 let local_var_configuration = &self.configuration;
902
903 let local_var_client = &local_var_configuration.client;
904
905 let local_var_uri_str = format!(
906 "{}/emergency-access/{id}/takeover",
907 local_var_configuration.base_path,
908 id = id
909 );
910 let mut local_var_req_builder =
911 local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
912
913 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
914 local_var_req_builder = local_var_req_builder
915 .header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
916 }
917 if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
918 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
919 };
920
921 let local_var_req = local_var_req_builder.build()?;
922 let local_var_resp = local_var_client.execute(local_var_req).await?;
923
924 let local_var_status = local_var_resp.status();
925 let local_var_content_type = local_var_resp
926 .headers()
927 .get("content-type")
928 .and_then(|v| v.to_str().ok())
929 .unwrap_or("application/octet-stream");
930 let local_var_content_type = super::ContentType::from(local_var_content_type);
931 let local_var_content = local_var_resp.text().await?;
932
933 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
934 match local_var_content_type {
935 ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from),
936 ContentType::Text => {
937 return Err(Error::from(serde_json::Error::custom(
938 "Received `text/plain` content type response that cannot be converted to `models::EmergencyAccessTakeoverResponseModel`",
939 )));
940 }
941 ContentType::Unsupported(local_var_unknown_type) => {
942 return Err(Error::from(serde_json::Error::custom(format!(
943 "Received `{local_var_unknown_type}` content type response that cannot be converted to `models::EmergencyAccessTakeoverResponseModel`"
944 ))));
945 }
946 }
947 } else {
948 let local_var_entity: Option<TakeoverError> =
949 serde_json::from_str(&local_var_content).ok();
950 let local_var_error = ResponseContent {
951 status: local_var_status,
952 content: local_var_content,
953 entity: local_var_entity,
954 };
955 Err(Error::ResponseError(local_var_error))
956 }
957 }
958
959 async fn view_ciphers<'a>(
960 &self,
961 id: uuid::Uuid,
962 ) -> Result<models::EmergencyAccessViewResponseModel, Error<ViewCiphersError>> {
963 let local_var_configuration = &self.configuration;
964
965 let local_var_client = &local_var_configuration.client;
966
967 let local_var_uri_str = format!(
968 "{}/emergency-access/{id}/view",
969 local_var_configuration.base_path,
970 id = id
971 );
972 let mut local_var_req_builder =
973 local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
974
975 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
976 local_var_req_builder = local_var_req_builder
977 .header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
978 }
979 if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
980 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
981 };
982
983 let local_var_req = local_var_req_builder.build()?;
984 let local_var_resp = local_var_client.execute(local_var_req).await?;
985
986 let local_var_status = local_var_resp.status();
987 let local_var_content_type = local_var_resp
988 .headers()
989 .get("content-type")
990 .and_then(|v| v.to_str().ok())
991 .unwrap_or("application/octet-stream");
992 let local_var_content_type = super::ContentType::from(local_var_content_type);
993 let local_var_content = local_var_resp.text().await?;
994
995 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
996 match local_var_content_type {
997 ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from),
998 ContentType::Text => {
999 return Err(Error::from(serde_json::Error::custom(
1000 "Received `text/plain` content type response that cannot be converted to `models::EmergencyAccessViewResponseModel`",
1001 )));
1002 }
1003 ContentType::Unsupported(local_var_unknown_type) => {
1004 return Err(Error::from(serde_json::Error::custom(format!(
1005 "Received `{local_var_unknown_type}` content type response that cannot be converted to `models::EmergencyAccessViewResponseModel`"
1006 ))));
1007 }
1008 }
1009 } else {
1010 let local_var_entity: Option<ViewCiphersError> =
1011 serde_json::from_str(&local_var_content).ok();
1012 let local_var_error = ResponseContent {
1013 status: local_var_status,
1014 content: local_var_content,
1015 entity: local_var_entity,
1016 };
1017 Err(Error::ResponseError(local_var_error))
1018 }
1019 }
1020}
1021
1022#[derive(Debug, Clone, Serialize, Deserialize)]
1024#[serde(untagged)]
1025pub enum AcceptError {
1026 UnknownValue(serde_json::Value),
1027}
1028#[derive(Debug, Clone, Serialize, Deserialize)]
1030#[serde(untagged)]
1031pub enum ApproveError {
1032 UnknownValue(serde_json::Value),
1033}
1034#[derive(Debug, Clone, Serialize, Deserialize)]
1036#[serde(untagged)]
1037pub enum ConfirmError {
1038 UnknownValue(serde_json::Value),
1039}
1040#[derive(Debug, Clone, Serialize, Deserialize)]
1042#[serde(untagged)]
1043pub enum DeleteError {
1044 UnknownValue(serde_json::Value),
1045}
1046#[derive(Debug, Clone, Serialize, Deserialize)]
1048#[serde(untagged)]
1049pub enum GetError {
1050 UnknownValue(serde_json::Value),
1051}
1052#[derive(Debug, Clone, Serialize, Deserialize)]
1054#[serde(untagged)]
1055pub enum GetAttachmentDataError {
1056 UnknownValue(serde_json::Value),
1057}
1058#[derive(Debug, Clone, Serialize, Deserialize)]
1060#[serde(untagged)]
1061pub enum GetContactsError {
1062 UnknownValue(serde_json::Value),
1063}
1064#[derive(Debug, Clone, Serialize, Deserialize)]
1066#[serde(untagged)]
1067pub enum GetGranteesError {
1068 UnknownValue(serde_json::Value),
1069}
1070#[derive(Debug, Clone, Serialize, Deserialize)]
1072#[serde(untagged)]
1073pub enum InitiateError {
1074 UnknownValue(serde_json::Value),
1075}
1076#[derive(Debug, Clone, Serialize, Deserialize)]
1078#[serde(untagged)]
1079pub enum InviteError {
1080 UnknownValue(serde_json::Value),
1081}
1082#[derive(Debug, Clone, Serialize, Deserialize)]
1084#[serde(untagged)]
1085pub enum PasswordError {
1086 UnknownValue(serde_json::Value),
1087}
1088#[derive(Debug, Clone, Serialize, Deserialize)]
1090#[serde(untagged)]
1091pub enum PoliciesError {
1092 UnknownValue(serde_json::Value),
1093}
1094#[derive(Debug, Clone, Serialize, Deserialize)]
1096#[serde(untagged)]
1097pub enum PutError {
1098 UnknownValue(serde_json::Value),
1099}
1100#[derive(Debug, Clone, Serialize, Deserialize)]
1102#[serde(untagged)]
1103pub enum ReinviteError {
1104 UnknownValue(serde_json::Value),
1105}
1106#[derive(Debug, Clone, Serialize, Deserialize)]
1108#[serde(untagged)]
1109pub enum RejectError {
1110 UnknownValue(serde_json::Value),
1111}
1112#[derive(Debug, Clone, Serialize, Deserialize)]
1114#[serde(untagged)]
1115pub enum TakeoverError {
1116 UnknownValue(serde_json::Value),
1117}
1118#[derive(Debug, Clone, Serialize, Deserialize)]
1120#[serde(untagged)]
1121pub enum ViewCiphersError {
1122 UnknownValue(serde_json::Value),
1123}