1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
//! [GET /_synapse/admin/v1/users/:user_id/admin](https://github.com/matrix-org/synapse/blob/master/docs/admin_api/user_admin_api.rst#get-whether-a-user-is-a-server-administrator-or-not)

use ruma::{api::ruma_api, UserId};

ruma_api! {
    metadata: {
        description: "is admin endpoint",
        method: GET,
        name: "is_user_admin_v1",
        unstable_path: "/_synapse/admin/v1/users/:user_id/admin",
        rate_limited: false,
        authentication: AccessToken,
    }

    request: {
        /// User to check.
        #[ruma_api(path)]
        pub user_id: &'a UserId,
    }

    response: {
        /// Whether the requested user ID is an admin.
        pub admin: bool,
    }

}

impl<'a> Request<'a> {
    /// Creates an `Request` with the given user ID.
    pub fn new(user_id: &'a UserId) -> Self {
        Self { user_id }
    }
}

impl Response {
    /// Creates a `Response` with the given admin flag.
    pub fn new(admin: bool) -> Self {
        Self { admin }
    }
}