ruma_client_api/device/
delete_device.rs

1//! `DELETE /_matrix/client/*/devices/{deviceId}`
2//!
3//! Delete a device for authenticated user.
4
5pub mod v3 {
6    //! `/v3/` ([spec])
7    //!
8    //! [spec]: https://spec.matrix.org/latest/client-server-api/#delete_matrixclientv3devicesdeviceid
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: DELETE,
20        rate_limited: false,
21        authentication: AccessToken,
22        history: {
23            1.0 => "/_matrix/client/r0/devices/{device_id}",
24            1.1 => "/_matrix/client/v3/devices/{device_id}",
25        }
26    }
27
28    /// Request type for the `delete_device` endpoint.
29    #[request(error = UiaaResponse)]
30    pub struct Request {
31        /// The device to delete.
32        #[ruma_api(path)]
33        pub device_id: OwnedDeviceId,
34
35        /// Additional authentication information for the user-interactive authentication API.
36        #[serde(skip_serializing_if = "Option::is_none")]
37        pub auth: Option<AuthData>,
38    }
39
40    /// Response type for the `delete_device` endpoint.
41    #[response(error = UiaaResponse)]
42    #[derive(Default)]
43    pub struct Response {}
44
45    impl Request {
46        /// Creates a new `Request` with the given device ID.
47        pub fn new(device_id: OwnedDeviceId) -> Self {
48            Self { device_id, auth: None }
49        }
50    }
51
52    impl Response {
53        /// Creates an empty `Response`.
54        pub fn new() -> Self {
55            Self {}
56        }
57    }
58}