ruma_client_api/backup/
delete_backup_keys_for_session.rs

1//! `DELETE /_matrix/client/*/room_keys/keys/{roomId}/{sessionId}`
2//!
3//! Delete keys from a backup for a given session.
4
5pub mod v3 {
6    //! `/v3/` ([spec])
7    //!
8    //! [spec]: https://spec.matrix.org/latest/client-server-api/#delete_matrixclientv3room_keyskeysroomidsessionid
9
10    use js_int::UInt;
11    use ruma_common::{
12        OwnedRoomId,
13        api::{auth_scheme::AccessToken, request, response},
14        metadata,
15    };
16
17    metadata! {
18        method: DELETE,
19        rate_limited: true,
20        authentication: AccessToken,
21        history: {
22            unstable => "/_matrix/client/unstable/room_keys/keys/{room_id}/{session_id}",
23            1.0 => "/_matrix/client/r0/room_keys/keys/{room_id}/{session_id}",
24            1.1 => "/_matrix/client/v3/room_keys/keys/{room_id}/{session_id}",
25        }
26    }
27
28    /// Request type for the `delete_backup_keys_for_session` endpoint.
29    #[request(error = crate::Error)]
30    pub struct Request {
31        /// The backup version from which to delete keys.
32        #[ruma_api(query)]
33        pub version: String,
34
35        /// The ID of the room to delete keys from.
36        #[ruma_api(path)]
37        pub room_id: OwnedRoomId,
38
39        /// The ID of the megolm session to delete keys from.
40        #[ruma_api(path)]
41        pub session_id: String,
42    }
43
44    /// Response type for the `delete_backup_keys_for_session` endpoint.
45    #[response(error = crate::Error)]
46    pub struct Response {
47        /// An opaque string representing stored keys in the backup.
48        ///
49        /// Clients can compare it with  the etag value they received in the request of their last
50        /// key storage request.
51        pub etag: String,
52
53        /// The number of keys stored in the backup.
54        pub count: UInt,
55    }
56
57    impl Request {
58        /// Creates a new `Request` with the given version, room_id and session_id.
59        pub fn new(version: String, room_id: OwnedRoomId, session_id: String) -> Self {
60            Self { version, room_id, session_id }
61        }
62    }
63
64    impl Response {
65        /// Creates an new `Response` with the given etag and count.
66        pub fn new(etag: String, count: UInt) -> Self {
67            Self { etag, count }
68        }
69    }
70}