ruma_client_api/backup/
delete_backup_keys_for_room.rs

1//! `DELETE /_matrix/client/*/room_keys/keys/{roomId}`
2//!
3//! Delete keys from a backup for a given room.
4
5pub mod v3 {
6    //! `/v3/` ([spec])
7    //!
8    //! [spec]: https://spec.matrix.org/latest/client-server-api/#delete_matrixclientv3room_keyskeysroomid
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}",
23            1.0 => "/_matrix/client/r0/room_keys/keys/{room_id}",
24            1.1 => "/_matrix/client/v3/room_keys/keys/{room_id}",
25        }
26    }
27
28    /// Request type for the `delete_backup_keys_for_room` 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
40    /// Response type for the `delete_backup_keys_for_room` endpoint.
41    #[response(error = crate::Error)]
42    pub struct Response {
43        /// An opaque string representing stored keys in the backup.
44        ///
45        /// Clients can compare it with the etag value they received in the request of their last
46        /// key storage request.
47        pub etag: String,
48
49        /// The number of keys stored in the backup.
50        pub count: UInt,
51    }
52
53    impl Request {
54        /// Creates a new `Request` with the given version and room_id.
55        pub fn new(version: String, room_id: OwnedRoomId) -> Self {
56            Self { version, room_id }
57        }
58    }
59
60    impl Response {
61        /// Creates an new `Response` with the given etag and count.
62        pub fn new(etag: String, count: UInt) -> Self {
63            Self { etag, count }
64        }
65    }
66}