sort all property lookup tables
Required, because we use binary sreach to find items.
This commit is contained in:
@ -1,5 +1,6 @@
|
||||
use failure::*;
|
||||
|
||||
use proxmox::{sortable, identity};
|
||||
use proxmox::tools::fs::{file_get_contents, file_set_contents};
|
||||
use proxmox::tools::*; // required to use IPRE!() macro ???
|
||||
|
||||
@ -107,24 +108,25 @@ fn get_dns(
|
||||
read_etc_resolv_conf()
|
||||
}
|
||||
|
||||
#[sortable]
|
||||
pub const ROUTER: Router = Router::new()
|
||||
.get(
|
||||
&ApiMethod::new(
|
||||
&ApiHandler::Sync(&get_dns),
|
||||
&ObjectSchema::new(
|
||||
"Read DNS settings.",
|
||||
&[ ("node", false, &NODE_SCHEMA) ],
|
||||
&sorted!([ ("node", false, &NODE_SCHEMA) ]),
|
||||
)
|
||||
).returns(
|
||||
&ObjectSchema::new(
|
||||
"Returns DNS server IPs and sreach domain.",
|
||||
&[
|
||||
&sorted!([
|
||||
("digest", false, &PVE_CONFIG_DIGEST_SCHEMA),
|
||||
("search", true, &SEARCH_DOMAIN_SCHEMA),
|
||||
("dns1", true, &FIRST_DNS_SERVER_SCHEMA),
|
||||
("dns2", true, &SECOND_DNS_SERVER_SCHEMA),
|
||||
("dns3", true, &THIRD_DNS_SERVER_SCHEMA),
|
||||
],
|
||||
]),
|
||||
).schema()
|
||||
)
|
||||
)
|
||||
@ -133,14 +135,14 @@ pub const ROUTER: Router = Router::new()
|
||||
&ApiHandler::Sync(&update_dns),
|
||||
&ObjectSchema::new(
|
||||
"Returns DNS server IPs and sreach domain.",
|
||||
&[
|
||||
&sorted!([
|
||||
("node", false, &NODE_SCHEMA),
|
||||
("search", false, &SEARCH_DOMAIN_SCHEMA),
|
||||
("dns1", true, &FIRST_DNS_SERVER_SCHEMA),
|
||||
("dns2", true, &SECOND_DNS_SERVER_SCHEMA),
|
||||
("dns3", true, &THIRD_DNS_SERVER_SCHEMA),
|
||||
("digest", true, &PVE_CONFIG_DIGEST_SCHEMA),
|
||||
],
|
||||
]),
|
||||
)
|
||||
).protected(true)
|
||||
);
|
||||
|
@ -1,5 +1,7 @@
|
||||
use failure::*;
|
||||
|
||||
use proxmox::{sortable, identity};
|
||||
|
||||
use crate::tools;
|
||||
use crate::api_schema::*;
|
||||
use crate::api_schema::router::*;
|
||||
@ -218,6 +220,7 @@ const SERVICE_ID_SCHEMA: Schema = StringSchema::new("Service ID.")
|
||||
.max_length(256)
|
||||
.schema();
|
||||
|
||||
#[sortable]
|
||||
const SERVICE_SUBDIRS: SubdirMap = &[
|
||||
(
|
||||
"reload", &Router::new()
|
||||
@ -226,10 +229,10 @@ const SERVICE_SUBDIRS: SubdirMap = &[
|
||||
&ApiHandler::Sync(&reload_service),
|
||||
&ObjectSchema::new(
|
||||
"Reload service.",
|
||||
&[
|
||||
&sorted!([
|
||||
("node", false, &NODE_SCHEMA),
|
||||
("service", false, &SERVICE_ID_SCHEMA),
|
||||
],
|
||||
]),
|
||||
)
|
||||
).protected(true)
|
||||
)
|
||||
@ -241,10 +244,10 @@ const SERVICE_SUBDIRS: SubdirMap = &[
|
||||
&ApiHandler::Sync(&restart_service),
|
||||
&ObjectSchema::new(
|
||||
"Restart service.",
|
||||
&[
|
||||
&sorted!([
|
||||
("node", false, &NODE_SCHEMA),
|
||||
("service", false, &SERVICE_ID_SCHEMA),
|
||||
],
|
||||
]),
|
||||
)
|
||||
).protected(true)
|
||||
)
|
||||
@ -256,10 +259,10 @@ const SERVICE_SUBDIRS: SubdirMap = &[
|
||||
&ApiHandler::Sync(&start_service),
|
||||
&ObjectSchema::new(
|
||||
"Start service.",
|
||||
&[
|
||||
&sorted!([
|
||||
("node", false, &NODE_SCHEMA),
|
||||
("service", false, &SERVICE_ID_SCHEMA),
|
||||
],
|
||||
]),
|
||||
)
|
||||
).protected(true)
|
||||
)
|
||||
@ -271,10 +274,10 @@ const SERVICE_SUBDIRS: SubdirMap = &[
|
||||
&ApiHandler::Sync(&get_service_state),
|
||||
&ObjectSchema::new(
|
||||
"Read service properties.",
|
||||
&[
|
||||
&sorted!([
|
||||
("node", false, &NODE_SCHEMA),
|
||||
("service", false, &SERVICE_ID_SCHEMA),
|
||||
],
|
||||
]),
|
||||
)
|
||||
)
|
||||
)
|
||||
@ -286,10 +289,10 @@ const SERVICE_SUBDIRS: SubdirMap = &[
|
||||
&ApiHandler::Sync(&stop_service),
|
||||
&ObjectSchema::new(
|
||||
"Stop service.",
|
||||
&[
|
||||
&sorted!([
|
||||
("node", false, &NODE_SCHEMA),
|
||||
("service", false, &SERVICE_ID_SCHEMA),
|
||||
],
|
||||
]),
|
||||
)
|
||||
).protected(true)
|
||||
)
|
||||
@ -300,25 +303,26 @@ const SERVICE_ROUTER: Router = Router::new()
|
||||
.get(&list_subdirs_api_method!(SERVICE_SUBDIRS))
|
||||
.subdirs(SERVICE_SUBDIRS);
|
||||
|
||||
#[sortable]
|
||||
pub const ROUTER: Router = Router::new()
|
||||
.get(
|
||||
&ApiMethod::new(
|
||||
&ApiHandler::Sync(&list_services),
|
||||
&ObjectSchema::new(
|
||||
"Service list.",
|
||||
&[ ("node", false, &NODE_SCHEMA) ],
|
||||
&sorted!([ ("node", false, &NODE_SCHEMA) ]),
|
||||
)
|
||||
).returns(
|
||||
&ArraySchema::new(
|
||||
"Returns a list of systemd services.",
|
||||
&ObjectSchema::new(
|
||||
"Service details.",
|
||||
&[
|
||||
&sorted!([
|
||||
("service", false, &SERVICE_ID_SCHEMA),
|
||||
("name", false, &StringSchema::new("systemd service name.").schema()),
|
||||
("desc", false, &StringSchema::new("systemd service description.").schema()),
|
||||
("state", false, &StringSchema::new("systemd service 'SubState'.").schema()),
|
||||
],
|
||||
]),
|
||||
).schema()
|
||||
).schema()
|
||||
)
|
||||
|
@ -1,5 +1,7 @@
|
||||
use failure::*;
|
||||
|
||||
use proxmox::{sortable, identity};
|
||||
|
||||
use crate::api_schema::*;
|
||||
use crate::api_schema::router::*;
|
||||
use crate::api2::types::*;
|
||||
@ -87,13 +89,14 @@ 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)
|
||||
@ -115,15 +118,15 @@ pub const ROUTER: Router = Router::new()
|
||||
.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)
|
||||
);
|
||||
|
@ -1,12 +1,14 @@
|
||||
use failure::*;
|
||||
|
||||
use crate::tools;
|
||||
use crate::api_schema::*;
|
||||
use crate::api_schema::router::*;
|
||||
use serde_json::{json, Value};
|
||||
use std::fs::File;
|
||||
use std::io::{BufRead,BufReader};
|
||||
|
||||
use proxmox::{sortable, identity};
|
||||
|
||||
use crate::tools;
|
||||
use crate::api_schema::*;
|
||||
use crate::api_schema::router::*;
|
||||
use crate::api2::types::*;
|
||||
use crate::server::{self, UPID};
|
||||
|
||||
@ -169,6 +171,7 @@ const UPID_SCHEMA: Schema = StringSchema::new("Unique Process/Task ID.")
|
||||
.max_length(256)
|
||||
.schema();
|
||||
|
||||
#[sortable]
|
||||
const UPID_API_SUBDIRS: SubdirMap = &[
|
||||
(
|
||||
"log", &Router::new()
|
||||
@ -177,7 +180,7 @@ const UPID_API_SUBDIRS: SubdirMap = &[
|
||||
&ApiHandler::Sync(&read_task_log),
|
||||
&ObjectSchema::new(
|
||||
"Read task log.",
|
||||
&[
|
||||
&sorted!([
|
||||
("node", false, &NODE_SCHEMA),
|
||||
("upid", false, &UPID_SCHEMA),
|
||||
("start", true, &IntegerSchema::new("Start at this line.")
|
||||
@ -190,7 +193,7 @@ const UPID_API_SUBDIRS: SubdirMap = &[
|
||||
.default(50)
|
||||
.schema()
|
||||
),
|
||||
],
|
||||
]),
|
||||
)
|
||||
)
|
||||
)
|
||||
@ -202,16 +205,17 @@ const UPID_API_SUBDIRS: SubdirMap = &[
|
||||
&ApiHandler::Sync(&get_task_status),
|
||||
&ObjectSchema::new(
|
||||
"Get task status.",
|
||||
&[
|
||||
&sorted!([
|
||||
("node", false, &NODE_SCHEMA),
|
||||
("upid", false, &UPID_SCHEMA),
|
||||
],
|
||||
]),
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
];
|
||||
|
||||
#[sortable]
|
||||
pub const UPID_API_ROUTER: Router = Router::new()
|
||||
.get(&list_subdirs_api_method!(UPID_API_SUBDIRS))
|
||||
.delete(
|
||||
@ -219,22 +223,23 @@ pub const UPID_API_ROUTER: Router = Router::new()
|
||||
&ApiHandler::Sync(&stop_task),
|
||||
&ObjectSchema::new(
|
||||
"Try to stop a task.",
|
||||
&[
|
||||
&sorted!([
|
||||
("node", false, &NODE_SCHEMA),
|
||||
("upid", false, &UPID_SCHEMA),
|
||||
],
|
||||
]),
|
||||
)
|
||||
).protected(true)
|
||||
)
|
||||
.subdirs(&UPID_API_SUBDIRS);
|
||||
|
||||
#[sortable]
|
||||
pub const ROUTER: Router = Router::new()
|
||||
.get(
|
||||
&ApiMethod::new(
|
||||
&ApiHandler::Sync(&list_tasks),
|
||||
&ObjectSchema::new(
|
||||
"List tasks.",
|
||||
&[
|
||||
&sorted!([
|
||||
("node", false, &NODE_SCHEMA),
|
||||
("start", true, &IntegerSchema::new("List tasks beginning from this offset.")
|
||||
.minimum(0)
|
||||
@ -248,7 +253,7 @@ pub const ROUTER: Router = Router::new()
|
||||
),
|
||||
("errors", true, &BooleanSchema::new("Only list erroneous tasks.").schema()),
|
||||
("userfilter", true, &StringSchema::new("Only list tasks from this user.").schema()),
|
||||
],
|
||||
]),
|
||||
)
|
||||
)
|
||||
)
|
||||
|
@ -4,6 +4,7 @@ use chrono::prelude::*;
|
||||
use failure::*;
|
||||
use serde_json::{json, Value};
|
||||
|
||||
use proxmox::{sortable, identity};
|
||||
use proxmox::tools::fs::{file_read_firstline, file_set_contents};
|
||||
|
||||
use crate::api2::types::*;
|
||||
@ -80,18 +81,19 @@ fn set_timezone(
|
||||
Ok(Value::Null)
|
||||
}
|
||||
|
||||
#[sortable]
|
||||
pub const ROUTER: Router = Router::new()
|
||||
.get(
|
||||
&ApiMethod::new(
|
||||
&ApiHandler::Sync(&get_time),
|
||||
&ObjectSchema::new(
|
||||
"Read server time and time zone settings.",
|
||||
&[ ("node", false, &NODE_SCHEMA) ],
|
||||
&sorted!([ ("node", false, &NODE_SCHEMA) ]),
|
||||
)
|
||||
).returns(
|
||||
&ObjectSchema::new(
|
||||
"Returns server time and timezone.",
|
||||
&[
|
||||
&sorted!([
|
||||
("timezone", false, &StringSchema::new("Time zone").schema()),
|
||||
("time", false, &IntegerSchema::new("Seconds since 1970-01-01 00:00:00 UTC.")
|
||||
.minimum(1_297_163_644)
|
||||
@ -101,7 +103,7 @@ pub const ROUTER: Router = Router::new()
|
||||
.minimum(1_297_163_644)
|
||||
.schema()
|
||||
),
|
||||
],
|
||||
]),
|
||||
).schema()
|
||||
)
|
||||
)
|
||||
@ -110,13 +112,13 @@ pub const ROUTER: Router = Router::new()
|
||||
&ApiHandler::Sync(&set_timezone),
|
||||
&ObjectSchema::new(
|
||||
"Set time zone.",
|
||||
&[
|
||||
&sorted!([
|
||||
("node", false, &NODE_SCHEMA),
|
||||
("timezone", false, &StringSchema::new(
|
||||
"Time zone. The file '/usr/share/zoneinfo/zone.tab' contains the list of valid names.")
|
||||
.schema()
|
||||
),
|
||||
],
|
||||
]),
|
||||
)
|
||||
).protected(true).reload_timezone(true)
|
||||
);
|
||||
|
Reference in New Issue
Block a user