diff --git a/src/api2/node/syslog.rs b/src/api2/node/syslog.rs index 3a3b9fbd..2a43ece7 100644 --- a/src/api2/node/syslog.rs +++ b/src/api2/node/syslog.rs @@ -3,9 +3,7 @@ use std::process::{Command, Stdio}; use failure::*; use serde_json::{json, Value}; -use proxmox::{sortable, identity}; -use proxmox::api::{ApiHandler, ApiMethod, Router, RpcEnvironment}; -use proxmox::api::schema::*; +use proxmox::api::{api, ApiMethod, Router, RpcEnvironment}; use crate::api2::types::*; @@ -71,6 +69,61 @@ fn dump_journal( Ok((count, lines)) } +#[api( + protected: true, + input: { + properties: { + node: { + schema: NODE_SCHEMA, + }, + start: { + type: Integer, + description: "Start line number.", + minimum: 0, + optional: true, + }, + limit: { + type: Integer, + description: "Max. number of lines.", + optional: true, + minimum: 0, + }, + since: { + type: String, + optional: true, + description: "Display all log since this date-time string.", + format: &SYSTEMD_DATETIME_FORMAT, + }, + until: { + type: String, + optional: true, + description: "Display all log until this date-time string.", + format: &SYSTEMD_DATETIME_FORMAT, + }, + service: { + type: String, + optional: true, + description: "Service ID.", + max_length: 128, + }, + }, + }, + returns: { + type: Object, + description: "Returns a list of syslog entries.", + properties: { + n: { + type: Integer, + description: "Line number.", + }, + t: { + type: String, + description: "Line text.", + } + }, + }, +)] +/// Read syslog entries. fn get_syslog( param: Value, _info: &ApiMethod, @@ -89,45 +142,6 @@ fn get_syslog( Ok(json!(lines)) } -#[sortable] pub const ROUTER: Router = Router::new() - .get( - &ApiMethod::new( - &ApiHandler::Sync(&get_syslog), - &ObjectSchema::new( - "Read server time and time zone settings.", - &sorted!([ - ("node", false, &NODE_SCHEMA), - ("start", true, &IntegerSchema::new("Start line number.") - .minimum(0) - .schema() - ), - ("limit", true, &IntegerSchema::new("Max. number of lines.") - .minimum(0) - .schema() - ), - ("since", true, &StringSchema::new("Display all log since this date-time string.") - .format(&SYSTEMD_DATETIME_FORMAT) - .schema() - ), - ("until", true, &StringSchema::new("Display all log until this date-time string.") - .format(&SYSTEMD_DATETIME_FORMAT) - .schema() - ), - ("service", true, &StringSchema::new("Service ID.") - .max_length(128) - .schema() - ), - ]), - ) - ).returns( - &ObjectSchema::new( - "Returns a list of syslog entries.", - &sorted!([ - ("n", false, &IntegerSchema::new("Line number.").schema()), - ("t", false, &StringSchema::new("Line text.").schema()), - ]), - ).schema() - ).protected(true) - ); + .get(&API_METHOD_GET_SYSLOG);