2019-01-30 17:25:37 +00:00
|
|
|
//use failure::*;
|
2019-01-22 12:56:27 +00:00
|
|
|
|
2019-02-17 09:16:33 +00:00
|
|
|
use crate::api_schema::*;
|
2019-02-17 08:59:20 +00:00
|
|
|
use crate::api_schema::router::*;
|
2019-01-25 09:15:32 +00:00
|
|
|
use std::sync::Arc;
|
2019-01-22 12:56:27 +00:00
|
|
|
|
|
|
|
pub mod config;
|
|
|
|
pub mod admin;
|
2019-01-23 12:05:32 +00:00
|
|
|
pub mod node;
|
2019-01-22 12:56:27 +00:00
|
|
|
mod version;
|
|
|
|
mod subscription;
|
2019-01-30 14:14:20 +00:00
|
|
|
mod access;
|
2019-01-22 12:56:27 +00:00
|
|
|
|
2019-01-25 09:15:32 +00:00
|
|
|
use lazy_static::lazy_static;
|
|
|
|
use crate::tools::common_regex;
|
|
|
|
|
|
|
|
// common schema definitions
|
|
|
|
|
|
|
|
lazy_static! {
|
|
|
|
pub static ref IP_FORMAT: Arc<ApiStringFormat> = ApiStringFormat::Pattern(&common_regex::IP_REGEX).into();
|
|
|
|
|
2019-01-25 10:38:59 +00:00
|
|
|
pub static ref PVE_CONFIG_DIGEST_FORMAT: Arc<ApiStringFormat> =
|
|
|
|
ApiStringFormat::Pattern(&common_regex::SHA256_HEX_REGEX).into();
|
|
|
|
|
|
|
|
pub static ref PVE_CONFIG_DIGEST_SCHEMA: Arc<Schema> =
|
|
|
|
StringSchema::new("Prevent changes if current configuration file has different SHA256 digest. This can be used to prevent concurrent modifications.")
|
|
|
|
.format(PVE_CONFIG_DIGEST_FORMAT.clone()).into();
|
2019-01-25 09:15:32 +00:00
|
|
|
}
|
|
|
|
|
2019-01-22 12:56:27 +00:00
|
|
|
pub fn router() -> Router {
|
|
|
|
|
|
|
|
let nodes = Router::new()
|
2019-04-09 12:43:30 +00:00
|
|
|
.match_all("node", node::router());
|
2019-01-22 12:56:27 +00:00
|
|
|
|
|
|
|
let route = Router::new()
|
2019-01-30 14:14:20 +00:00
|
|
|
.subdir("access", access::router())
|
2019-01-22 12:56:27 +00:00
|
|
|
.subdir("admin", admin::router())
|
|
|
|
.subdir("config", config::router())
|
|
|
|
.subdir("nodes", nodes)
|
|
|
|
.subdir("subscription", subscription::router())
|
2019-04-16 10:07:02 +00:00
|
|
|
.subdir("version", version::router())
|
|
|
|
.list_subdirs();
|
2019-01-22 12:56:27 +00:00
|
|
|
|
|
|
|
route
|
|
|
|
}
|