src/api2/node/syslog.rs: use api macro
This commit is contained in:
parent
87b4d953bf
commit
20197f7cf5
@ -3,9 +3,7 @@ use std::process::{Command, Stdio};
|
|||||||
use failure::*;
|
use failure::*;
|
||||||
use serde_json::{json, Value};
|
use serde_json::{json, Value};
|
||||||
|
|
||||||
use proxmox::{sortable, identity};
|
use proxmox::api::{api, ApiMethod, Router, RpcEnvironment};
|
||||||
use proxmox::api::{ApiHandler, ApiMethod, Router, RpcEnvironment};
|
|
||||||
use proxmox::api::schema::*;
|
|
||||||
|
|
||||||
use crate::api2::types::*;
|
use crate::api2::types::*;
|
||||||
|
|
||||||
@ -71,6 +69,61 @@ fn dump_journal(
|
|||||||
Ok((count, lines))
|
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(
|
fn get_syslog(
|
||||||
param: Value,
|
param: Value,
|
||||||
_info: &ApiMethod,
|
_info: &ApiMethod,
|
||||||
@ -89,45 +142,6 @@ fn get_syslog(
|
|||||||
Ok(json!(lines))
|
Ok(json!(lines))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[sortable]
|
|
||||||
pub const ROUTER: Router = Router::new()
|
pub const ROUTER: Router = Router::new()
|
||||||
.get(
|
.get(&API_METHOD_GET_SYSLOG);
|
||||||
&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)
|
|
||||||
);
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user