ruma_client_api/room/
upgrade_room.rs

1//! `POST /_matrix/client/*/rooms/{roomId}/upgrade`
2//!
3//! Upgrades a room to a particular version.
4
5pub mod v3 {
6    //! `/v3/` ([spec])
7    //!
8    //! [spec]: https://spec.matrix.org/latest/client-server-api/#post_matrixclientv3roomsroomidupgrade
9
10    use ruma_common::{
11        api::{request, response, Metadata},
12        metadata, OwnedRoomId, RoomVersionId,
13    };
14
15    const METADATA: Metadata = metadata! {
16        method: POST,
17        rate_limited: false,
18        authentication: AccessToken,
19        history: {
20            1.0 => "/_matrix/client/r0/rooms/:room_id/upgrade",
21            1.1 => "/_matrix/client/v3/rooms/:room_id/upgrade",
22        }
23    };
24
25    /// Request type for the `upgrade_room` endpoint.
26    #[request(error = crate::Error)]
27    pub struct Request {
28        /// ID of the room to be upgraded.
29        #[ruma_api(path)]
30        pub room_id: OwnedRoomId,
31
32        /// New version for the room.
33        pub new_version: RoomVersionId,
34    }
35
36    /// Response type for the `upgrade_room` endpoint.
37    #[response(error = crate::Error)]
38    pub struct Response {
39        /// ID of the new room.
40        pub replacement_room: OwnedRoomId,
41    }
42
43    impl Request {
44        /// Creates a new `Request` with the given room ID and new room version.
45        pub fn new(room_id: OwnedRoomId, new_version: RoomVersionId) -> Self {
46            Self { room_id, new_version }
47        }
48    }
49
50    impl Response {
51        /// Creates a new `Response` with the given room ID.
52        pub fn new(replacement_room: OwnedRoomId) -> Self {
53            Self { replacement_room }
54        }
55    }
56}