proxmox-backup/src/api2/version.rs

37 lines
981 B
Rust
Raw Normal View History

use anyhow::{Error};
2018-12-08 13:44:55 +00:00
use serde_json::{json, Value};
2020-04-16 08:01:59 +00:00
use proxmox::api::{ApiHandler, ApiMethod, Router, RpcEnvironment, Permission};
use proxmox::api::schema::ObjectSchema;
2019-10-26 09:36:01 +00:00
pub const PROXMOX_PKG_VERSION: &str =
concat!(
env!("CARGO_PKG_VERSION_MAJOR"),
".",
env!("CARGO_PKG_VERSION_MINOR"),
);
2019-10-26 09:36:01 +00:00
pub const PROXMOX_PKG_RELEASE: &str = env!("CARGO_PKG_VERSION_PATCH");
pub const PROXMOX_PKG_REPOID: &str = env!("CARGO_PKG_REPOSITORY");
2018-12-08 13:44:55 +00:00
fn get_version(
_param: Value,
_info: &ApiMethod,
_rpcenv: &mut dyn RpcEnvironment,
) -> Result<Value, Error> {
2018-12-08 13:44:55 +00:00
Ok(json!({
"version": PROXMOX_PKG_VERSION,
"release": PROXMOX_PKG_RELEASE,
"repoid": PROXMOX_PKG_REPOID
}))
}
2019-11-21 08:36:41 +00:00
pub const ROUTER: Router = Router::new()
.get(
&ApiMethod::new(
&ApiHandler::Sync(&get_version),
&ObjectSchema::new("Proxmox Backup Server API version.", &[])
2020-04-16 08:01:59 +00:00
).access(None, &Permission::Anybody)
2019-11-21 08:36:41 +00:00
);