src/api2/subscription.rs: add access permissions
This commit is contained in:
		| @ -1,16 +1,39 @@ | ||||
| use failure::*; | ||||
| use serde_json::{json, Value}; | ||||
|  | ||||
| use proxmox::api::{ApiHandler, ApiMethod, Router, RpcEnvironment}; | ||||
| use proxmox::api::schema::ObjectSchema; | ||||
| use proxmox::api::{api, Router, Permission}; | ||||
|  | ||||
| use crate::tools; | ||||
| use crate::config::acl::PRIV_SYS_AUDIT; | ||||
|  | ||||
| fn get_subscription( | ||||
|     _param: Value, | ||||
|     _info: &ApiMethod, | ||||
|     _rpcenv: &mut dyn RpcEnvironment, | ||||
| ) -> Result<Value, Error> { | ||||
| #[api( | ||||
|     returns: { | ||||
|         description: "Subscription status.", | ||||
|         properties: { | ||||
|             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"; | ||||
|     Ok(json!({ | ||||
| @ -22,9 +45,4 @@ fn get_subscription( | ||||
| } | ||||
|  | ||||
| pub const ROUTER: Router = Router::new() | ||||
|     .get( | ||||
|         &ApiMethod::new( | ||||
|             &ApiHandler::Sync(&get_subscription), | ||||
|             &ObjectSchema::new("Read subscription info.", &[]) | ||||
|         ) | ||||
|     ); | ||||
|     .get(&API_METHOD_GET_SUBSCRIPTION); | ||||
|  | ||||
		Reference in New Issue
	
	Block a user