]> git.proxmox.com Git - proxmox-backup.git/blame - src/api2/types.rs
src/api2/backup.rs: new required backup-time parameter
[proxmox-backup.git] / src / api2 / types.rs
CommitLineData
4ebf0eab
DM
1use failure::*;
2use lazy_static::lazy_static;
3use std::sync::Arc;
4
5use crate::api_schema::*;
6use crate::tools::{self, common_regex};
7
8lazy_static!{
9
4e93f8c1
DM
10 // File names: may not contain slashes, may not start with "."
11 pub static ref FILENAME_FORMAT: Arc<ApiStringFormat> = Arc::new(ApiStringFormat::VerifyFn(|name| {
12 if name.starts_with('.') {
13 bail!("file names may not start with '.'");
14 }
15 if name.contains('/') {
16 bail!("file names may not contain slashes");
17 }
18 Ok(())
19 })).into();
20
4ebf0eab
DM
21 pub static ref IP_FORMAT: Arc<ApiStringFormat> = ApiStringFormat::Pattern(&common_regex::IP_REGEX).into();
22
23 pub static ref PVE_CONFIG_DIGEST_FORMAT: Arc<ApiStringFormat> =
24 ApiStringFormat::Pattern(&common_regex::SHA256_HEX_REGEX).into();
25
26 pub static ref PVE_CONFIG_DIGEST_SCHEMA: Arc<Schema> =
27 StringSchema::new("Prevent changes if current configuration file has different SHA256 digest. This can be used to prevent concurrent modifications.")
28 .format(PVE_CONFIG_DIGEST_FORMAT.clone()).into();
29
6762db70
DM
30 pub static ref CHUNK_DIGEST_FORMAT: Arc<ApiStringFormat> =
31 ApiStringFormat::Pattern(&common_regex::SHA256_HEX_REGEX).into();
32
33 pub static ref CHUNK_DIGEST_SCHEMA: Arc<Schema> =
34 StringSchema::new("Chunk digest (SHA256).")
35 .format(CHUNK_DIGEST_FORMAT.clone()).into();
36
4ebf0eab
DM
37 pub static ref NODE_SCHEMA: Arc<Schema> = Arc::new(
38 StringSchema::new("Node name (or 'localhost')")
39 .format(
40 Arc::new(ApiStringFormat::VerifyFn(|node| {
41 if node == "localhost" || node == tools::nodename() {
42 Ok(())
43 } else {
4e93f8c1 44 bail!("no such node '{}'", node);
4ebf0eab
DM
45 }
46 }))
47 )
48 .into()
49 );
50
51 pub static ref SEARCH_DOMAIN_SCHEMA: Arc<Schema> =
52 StringSchema::new("Search domain for host-name lookup.").into();
53
54 pub static ref FIRST_DNS_SERVER_SCHEMA: Arc<Schema> =
55 StringSchema::new("First name server IP address.")
56 .format(IP_FORMAT.clone()).into();
57
58 pub static ref SECOND_DNS_SERVER_SCHEMA: Arc<Schema> =
59 StringSchema::new("Second name server IP address.")
60 .format(IP_FORMAT.clone()).into();
61
62 pub static ref THIRD_DNS_SERVER_SCHEMA: Arc<Schema> =
63 StringSchema::new("Third name server IP address.")
64 .format(IP_FORMAT.clone()).into();
65
4e93f8c1
DM
66 pub static ref BACKUP_ARCHIVE_NAME_SCHEMA: Arc<Schema> =
67 StringSchema::new("Backup archive name.")
68 .format(FILENAME_FORMAT.clone()).into();
4ebf0eab
DM
69
70}