ruma_client_api/device/
delete_devices.rs

1//! `POST /_matrix/client/*/delete_devices`
2//!
3//! Delete specified devices.
4
5pub mod v3 {
6    //! `/v3/` ([spec])
7    //!
8    //! [spec]: https://spec.matrix.org/latest/client-server-api/#post_matrixclientv3delete_devices
9
10    use ruma_common::{
11        OwnedDeviceId,
12        api::{auth_scheme::AccessToken, request, response},
13        metadata,
14    };
15
16    use crate::uiaa::{AuthData, UiaaResponse};
17
18    metadata! {
19        method: POST,
20        rate_limited: false,
21        authentication: AccessToken,
22        history: {
23            1.0 => "/_matrix/client/r0/delete_devices",
24            1.1 => "/_matrix/client/v3/delete_devices",
25        }
26    }
27
28    /// Request type for the `delete_devices` endpoint.
29    #[request(error = UiaaResponse)]
30    pub struct Request {
31        /// List of devices to delete.
32        pub devices: Vec<OwnedDeviceId>,
33
34        /// Additional authentication information for the user-interactive authentication API.
35        #[serde(skip_serializing_if = "Option::is_none")]
36        pub auth: Option<AuthData>,
37    }
38
39    /// Response type for the `delete_devices` endpoint.
40    #[response(error = UiaaResponse)]
41    #[derive(Default)]
42    pub struct Response {}
43
44    impl Request {
45        /// Creates a new `Request` with the given device list.
46        pub fn new(devices: Vec<OwnedDeviceId>) -> Self {
47            Self { devices, auth: None }
48        }
49    }
50
51    impl Response {
52        /// Creates an empty `Response`.
53        pub fn new() -> Self {
54            Self {}
55        }
56    }
57}