]>
Commit | Line | Data |
---|---|---|
f7d4e4b5 | 1 | use anyhow::{Error}; |
7e13b2d6 DM |
2 | use serde_json::{json, Value}; |
3 | ||
9626c286 | 4 | use proxmox::api::{api, Router, RpcEnvironment, Permission}; |
a2479cfa WB |
5 | |
6 | use crate::tools; | |
1bfc1efa | 7 | use crate::config::acl::PRIV_SYS_AUDIT; |
9626c286 FG |
8 | use crate::config::cached_user_info::CachedUserInfo; |
9 | use crate::api2::types::{NODE_SCHEMA, Userid}; | |
7e13b2d6 | 10 | |
1bfc1efa | 11 | #[api( |
113c9b59 SR |
12 | input: { |
13 | properties: { | |
14 | node: { | |
15 | schema: NODE_SCHEMA, | |
16 | }, | |
17 | }, | |
18 | }, | |
1bfc1efa DM |
19 | returns: { |
20 | description: "Subscription status.", | |
21 | properties: { | |
22 | status: { | |
23 | type: String, | |
24 | description: "'NotFound', 'active' or 'inactive'." | |
25 | }, | |
26 | message: { | |
27 | type: String, | |
28 | description: "Human readable problem description.", | |
29 | }, | |
30 | serverid: { | |
31 | type: String, | |
9626c286 | 32 | description: "The unique server ID, if permitted to access.", |
1bfc1efa DM |
33 | }, |
34 | url: { | |
35 | type: String, | |
36 | description: "URL to Web Shop.", | |
37 | }, | |
38 | }, | |
39 | }, | |
40 | access: { | |
9626c286 | 41 | permission: &Permission::Anybody, |
1bfc1efa DM |
42 | }, |
43 | )] | |
44 | /// Read subscription info. | |
9626c286 FG |
45 | fn get_subscription( |
46 | _param: Value, | |
47 | rpcenv: &mut dyn RpcEnvironment, | |
48 | ) -> Result<Value, Error> { | |
49 | let userid: Userid = rpcenv.get_user().unwrap().parse()?; | |
50 | let user_info = CachedUserInfo::new()?; | |
51 | let user_privs = user_info.lookup_privs(&userid, &[]); | |
52 | let server_id = if (user_privs & PRIV_SYS_AUDIT) != 0 { | |
53 | tools::get_hardware_address()? | |
54 | } else { | |
55 | "hidden".to_string() | |
56 | }; | |
7e13b2d6 DM |
57 | |
58 | let url = "https://www.proxmox.com/en/proxmox-backup-server/pricing"; | |
59 | Ok(json!({ | |
60 | "status": "NotFound", | |
9626c286 FG |
61 | "message": "There is no subscription key", |
62 | "serverid": server_id, | |
63 | "url": url, | |
7e13b2d6 DM |
64 | })) |
65 | } | |
66 | ||
255f378a | 67 | pub const ROUTER: Router = Router::new() |
1bfc1efa | 68 | .get(&API_METHOD_GET_SUBSCRIPTION); |