io_msgraph/v1/rest/users/calendars/
permanent_delete.rs1use alloc::format;
11
12use io_http::rfc6750::bearer::HttpAuthBearer;
13use log::{debug, trace};
14use url::Url;
15
16use crate::{
17 coroutine::*,
18 msgraph_try,
19 v1::send::{
20 MSGRAPH_API_BASE, MsgraphNoResponse, MsgraphSend, MsgraphSendError, MsgraphSendOutput,
21 path_segment, user_path,
22 },
23};
24
25pub struct MsgraphCalendarPermanentDelete {
27 send: MsgraphSend<MsgraphNoResponse>,
28}
29
30impl MsgraphCalendarPermanentDelete {
31 pub fn new(auth: &HttpAuthBearer, user_id: &str, id: &str) -> Result<Self, MsgraphSendError> {
33 debug!("prepare microsoft graph calendar permanent deletion");
34 trace!("id: {id:?}");
35
36 let user = user_path(user_id)?;
37 let url = Url::parse(MSGRAPH_API_BASE)?.join(&format!(
38 "{user}/calendars/{}/permanentDelete",
39 path_segment(id)?
40 ))?;
41 let body = b"{}".to_vec();
42 let send = MsgraphSend::with_method(auth, "POST", url, Some("application/json"), body);
43
44 Ok(Self { send })
45 }
46}
47
48impl MsgraphCoroutine for MsgraphCalendarPermanentDelete {
49 type Yield = MsgraphYield;
50 type Return = Result<MsgraphSendOutput<MsgraphNoResponse>, MsgraphSendError>;
51
52 fn resume(&mut self, arg: Option<&[u8]>) -> MsgraphCoroutineState<Self::Yield, Self::Return> {
53 let out = msgraph_try!(&mut self.send, arg);
54 debug!("calendar permanently deleted");
55 trace!("out: {out:?}");
56 MsgraphCoroutineState::Complete(Ok(out))
57 }
58}