ruma_client_api/alias/
create_alias.rs

1//! `PUT /_matrix/client/*/directory/room/{roomAlias}`
2//!
3//! Add an alias to a room.
4
5pub mod v3 {
6    //! `/v3/` ([spec])
7    //!
8    //! [spec]: https://spec.matrix.org/latest/client-server-api/#put_matrixclientv3directoryroomroomalias
9
10    use ruma_common::{
11        OwnedRoomAliasId, OwnedRoomId,
12        api::{auth_scheme::AccessToken, request, response},
13        metadata,
14    };
15
16    metadata! {
17        method: PUT,
18        rate_limited: false,
19        authentication: AccessToken,
20        history: {
21            1.0 => "/_matrix/client/r0/directory/room/{room_alias}",
22            1.1 => "/_matrix/client/v3/directory/room/{room_alias}",
23        }
24    }
25
26    /// Request type for the `create_alias` endpoint.
27    #[request(error = crate::Error)]
28    pub struct Request {
29        /// The room alias to set.
30        #[ruma_api(path)]
31        pub room_alias: OwnedRoomAliasId,
32
33        /// The room ID to set.
34        pub room_id: OwnedRoomId,
35    }
36
37    /// Response type for the `create_alias` endpoint.
38    #[response(error = crate::Error)]
39    #[derive(Default)]
40    pub struct Response {}
41
42    impl Request {
43        /// Creates a new `Request` with the given room alias and room id.
44        pub fn new(room_alias: OwnedRoomAliasId, room_id: OwnedRoomId) -> Self {
45            Self { room_alias, room_id }
46        }
47    }
48
49    impl Response {
50        /// Creates an empty `Response`.
51        pub fn new() -> Self {
52            Self {}
53        }
54    }
55}