2019-05-09 05:44:09 +00:00
|
|
|
use failure::*;
|
|
|
|
use lazy_static::lazy_static;
|
|
|
|
use std::sync::Arc;
|
|
|
|
|
|
|
|
use crate::api_schema::*;
|
2019-08-03 14:44:31 +00:00
|
|
|
use proxmox::tools::common_regex;
|
2019-05-09 05:44:09 +00:00
|
|
|
|
|
|
|
lazy_static!{
|
|
|
|
|
2019-05-15 05:14:08 +00:00
|
|
|
// File names: may not contain slashes, may not start with "."
|
|
|
|
pub static ref FILENAME_FORMAT: Arc<ApiStringFormat> = Arc::new(ApiStringFormat::VerifyFn(|name| {
|
|
|
|
if name.starts_with('.') {
|
|
|
|
bail!("file names may not start with '.'");
|
|
|
|
}
|
|
|
|
if name.contains('/') {
|
|
|
|
bail!("file names may not contain slashes");
|
|
|
|
}
|
|
|
|
Ok(())
|
|
|
|
})).into();
|
|
|
|
|
2019-05-09 05:44:09 +00:00
|
|
|
pub static ref IP_FORMAT: Arc<ApiStringFormat> = ApiStringFormat::Pattern(&common_regex::IP_REGEX).into();
|
|
|
|
|
|
|
|
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-06-13 05:30:42 +00:00
|
|
|
pub static ref CHUNK_DIGEST_FORMAT: Arc<ApiStringFormat> =
|
|
|
|
ApiStringFormat::Pattern(&common_regex::SHA256_HEX_REGEX).into();
|
|
|
|
|
|
|
|
pub static ref CHUNK_DIGEST_SCHEMA: Arc<Schema> =
|
|
|
|
StringSchema::new("Chunk digest (SHA256).")
|
|
|
|
.format(CHUNK_DIGEST_FORMAT.clone()).into();
|
|
|
|
|
2019-05-09 05:44:09 +00:00
|
|
|
pub static ref NODE_SCHEMA: Arc<Schema> = Arc::new(
|
|
|
|
StringSchema::new("Node name (or 'localhost')")
|
|
|
|
.format(
|
|
|
|
Arc::new(ApiStringFormat::VerifyFn(|node| {
|
2019-08-03 15:06:23 +00:00
|
|
|
if node == "localhost" || node == proxmox::tools::nodename() {
|
2019-05-09 05:44:09 +00:00
|
|
|
Ok(())
|
|
|
|
} else {
|
2019-05-15 05:14:08 +00:00
|
|
|
bail!("no such node '{}'", node);
|
2019-05-09 05:44:09 +00:00
|
|
|
}
|
|
|
|
}))
|
|
|
|
)
|
|
|
|
.into()
|
|
|
|
);
|
|
|
|
|
|
|
|
pub static ref SEARCH_DOMAIN_SCHEMA: Arc<Schema> =
|
|
|
|
StringSchema::new("Search domain for host-name lookup.").into();
|
|
|
|
|
|
|
|
pub static ref FIRST_DNS_SERVER_SCHEMA: Arc<Schema> =
|
|
|
|
StringSchema::new("First name server IP address.")
|
|
|
|
.format(IP_FORMAT.clone()).into();
|
|
|
|
|
|
|
|
pub static ref SECOND_DNS_SERVER_SCHEMA: Arc<Schema> =
|
|
|
|
StringSchema::new("Second name server IP address.")
|
|
|
|
.format(IP_FORMAT.clone()).into();
|
|
|
|
|
|
|
|
pub static ref THIRD_DNS_SERVER_SCHEMA: Arc<Schema> =
|
|
|
|
StringSchema::new("Third name server IP address.")
|
|
|
|
.format(IP_FORMAT.clone()).into();
|
|
|
|
|
2019-05-15 05:14:08 +00:00
|
|
|
pub static ref BACKUP_ARCHIVE_NAME_SCHEMA: Arc<Schema> =
|
|
|
|
StringSchema::new("Backup archive name.")
|
|
|
|
.format(FILENAME_FORMAT.clone()).into();
|
2019-05-09 05:44:09 +00:00
|
|
|
|
2019-07-26 07:07:29 +00:00
|
|
|
pub static ref BACKUP_TYPE_SCHEMA: Arc<Schema> =
|
|
|
|
StringSchema::new("Backup type.")
|
|
|
|
.format(Arc::new(ApiStringFormat::Enum(&["vm", "ct", "host"])))
|
|
|
|
.into();
|
|
|
|
|
|
|
|
pub static ref BACKUP_ID_SCHEMA: Arc<Schema> =
|
|
|
|
StringSchema::new("Backup ID.")
|
|
|
|
.format(FILENAME_FORMAT.clone())
|
|
|
|
.into();
|
|
|
|
|
|
|
|
pub static ref BACKUP_TIME_SCHEMA: Arc<Schema> =
|
|
|
|
IntegerSchema::new("Backup time (Unix epoch.)")
|
2019-10-26 09:36:01 +00:00
|
|
|
.minimum(1_547_797_308)
|
2019-07-26 07:07:29 +00:00
|
|
|
.into();
|
|
|
|
|
2019-05-09 05:44:09 +00:00
|
|
|
}
|