src/api2/node/tasks.rs: use api macro features for default values
This commit is contained in:
parent
720af9f69b
commit
ca9dfe5fa4
@ -274,11 +274,13 @@ fn stop_task(
|
|||||||
type: bool,
|
type: bool,
|
||||||
description: "Only list running tasks.",
|
description: "Only list running tasks.",
|
||||||
optional: true,
|
optional: true,
|
||||||
|
default: false,
|
||||||
},
|
},
|
||||||
errors: {
|
errors: {
|
||||||
type: bool,
|
type: bool,
|
||||||
description: "Only list erroneous tasks.",
|
description: "Only list erroneous tasks.",
|
||||||
optional:true,
|
optional:true,
|
||||||
|
default: false,
|
||||||
},
|
},
|
||||||
userfilter: {
|
userfilter: {
|
||||||
optional:true,
|
optional:true,
|
||||||
@ -299,15 +301,14 @@ fn stop_task(
|
|||||||
)]
|
)]
|
||||||
/// List tasks.
|
/// List tasks.
|
||||||
pub fn list_tasks(
|
pub fn list_tasks(
|
||||||
|
start: u64,
|
||||||
|
limit: u64,
|
||||||
|
errors: bool,
|
||||||
|
running: bool,
|
||||||
param: Value,
|
param: Value,
|
||||||
rpcenv: &mut dyn RpcEnvironment,
|
rpcenv: &mut dyn RpcEnvironment,
|
||||||
) -> Result<Vec<TaskListItem>, Error> {
|
) -> Result<Vec<TaskListItem>, Error> {
|
||||||
|
|
||||||
let start = param["start"].as_u64().unwrap_or(0);
|
|
||||||
let limit = param["limit"].as_u64().unwrap_or(50);
|
|
||||||
let errors = param["errors"].as_bool().unwrap_or(false);
|
|
||||||
let running = param["running"].as_bool().unwrap_or(false);
|
|
||||||
|
|
||||||
let username = rpcenv.get_user().unwrap();
|
let username = rpcenv.get_user().unwrap();
|
||||||
let user_info = CachedUserInfo::new()?;
|
let user_info = CachedUserInfo::new()?;
|
||||||
let user_privs = user_info.lookup_privs(&username, &["system", "tasks"]);
|
let user_privs = user_info.lookup_privs(&username, &["system", "tasks"]);
|
||||||
|
Loading…
Reference in New Issue
Block a user