]> git.proxmox.com Git - proxmox-backup.git/blob - src/api2/access/role.rs
8d73e8af364335af09348377833833ed8f8391e8
[proxmox-backup.git] / src / api2 / access / role.rs
1 use failure::*;
2
3 use serde_json::{json, Value};
4
5 use proxmox::api::{api, Permission};
6 use proxmox::api::router::Router;
7
8 use crate::api2::types::*;
9 use crate::config::acl::ROLE_NAMES;
10
11 #[api(
12 returns: {
13 description: "List of roles.",
14 type: Array,
15 items: {
16 type: Object,
17 description: "User name with description.",
18 properties: {
19 role: {
20 schema: ACL_ROLE_SCHEMA,
21 },
22 comment: {
23 schema: SINGLE_LINE_COMMENT_SCHEMA,
24 optional: true,
25 },
26 },
27 }
28 },
29 access: {
30 permission: &Permission::Anybody,
31 }
32 )]
33 /// Role list
34 fn list_roles() -> Result<Value, Error> {
35 let mut list = Vec::new();
36
37 for (role, comment) in ROLE_NAMES.iter() {
38 list.push(json!({ "role": role, "comment": comment }));
39 }
40 Ok(list.into())
41 }
42
43 pub const ROUTER: Router = Router::new()
44 .get(&API_METHOD_LIST_ROLES);