src/api2/subscription.rs: add access permissions

This commit is contained in:
Dietmar Maurer 2020-04-17 15:14:28 +02:00
parent 73ce1d1146
commit 1bfc1efa50

View File

@ -1,16 +1,39 @@
use failure::*; use failure::*;
use serde_json::{json, Value}; use serde_json::{json, Value};
use proxmox::api::{ApiHandler, ApiMethod, Router, RpcEnvironment}; use proxmox::api::{api, Router, Permission};
use proxmox::api::schema::ObjectSchema;
use crate::tools; use crate::tools;
use crate::config::acl::PRIV_SYS_AUDIT;
fn get_subscription( #[api(
_param: Value, returns: {
_info: &ApiMethod, description: "Subscription status.",
_rpcenv: &mut dyn RpcEnvironment, properties: {
) -> Result<Value, Error> { status: {
type: String,
description: "'NotFound', 'active' or 'inactive'."
},
message: {
type: String,
description: "Human readable problem description.",
},
serverid: {
type: String,
description: "The unique server ID.",
},
url: {
type: String,
description: "URL to Web Shop.",
},
},
},
access: {
permission: &Permission::Privilege(&[], PRIV_SYS_AUDIT, false),
},
)]
/// Read subscription info.
fn get_subscription(_param: Value) -> Result<Value, Error> {
let url = "https://www.proxmox.com/en/proxmox-backup-server/pricing"; let url = "https://www.proxmox.com/en/proxmox-backup-server/pricing";
Ok(json!({ Ok(json!({
@ -22,9 +45,4 @@ fn get_subscription(
} }
pub const ROUTER: Router = Router::new() pub const ROUTER: Router = Router::new()
.get( .get(&API_METHOD_GET_SUBSCRIPTION);
&ApiMethod::new(
&ApiHandler::Sync(&get_subscription),
&ObjectSchema::new("Read subscription info.", &[])
)
);