src/api2/backup.rs: cleanup schema definitions
This commit is contained in:
parent
ca5d0b61ca
commit
bbf9e7e951
@ -2,6 +2,7 @@ use failure::*;
|
||||
use futures::*;
|
||||
|
||||
use crate::tools;
|
||||
use crate::api2::types::*;
|
||||
use crate::api_schema::*;
|
||||
use crate::api_schema::router::*;
|
||||
//use crate::server::rest::*;
|
||||
@ -458,12 +459,10 @@ pub fn api_method_download_file() -> ApiAsyncMethod {
|
||||
download_file,
|
||||
ObjectSchema::new("Download single raw file from backup snapshot.")
|
||||
.required("store", StringSchema::new("Datastore name."))
|
||||
.required("backup-type", StringSchema::new("Backup type.")
|
||||
.format(Arc::new(ApiStringFormat::Enum(&["ct", "host"]))))
|
||||
.required("backup-id", StringSchema::new("Backup ID."))
|
||||
.required("backup-time", IntegerSchema::new("Backup time (Unix epoch.)")
|
||||
.minimum(1547797308))
|
||||
.required("file-name", StringSchema::new("Raw file name."))
|
||||
.required("backup-type", BACKUP_TYPE_SCHEMA.clone())
|
||||
.required("backup-id", BACKUP_ID_SCHEMA.clone())
|
||||
.required("backup-time", BACKUP_TIME_SCHEMA.clone())
|
||||
.required("file-name", StringSchema::new("Raw file name.").format(FILENAME_FORMAT.clone()))
|
||||
)
|
||||
}
|
||||
|
||||
@ -525,11 +524,9 @@ pub fn api_method_upload_backup_log() -> ApiAsyncMethod {
|
||||
upload_backup_log,
|
||||
ObjectSchema::new("Download single raw file from backup snapshot.")
|
||||
.required("store", StringSchema::new("Datastore name."))
|
||||
.required("backup-type", StringSchema::new("Backup type.")
|
||||
.format(Arc::new(ApiStringFormat::Enum(&["ct", "host"]))))
|
||||
.required("backup-id", StringSchema::new("Backup ID."))
|
||||
.required("backup-time", IntegerSchema::new("Backup time (Unix epoch.)")
|
||||
.minimum(1547797308))
|
||||
.required("backup-type", BACKUP_TYPE_SCHEMA.clone())
|
||||
.required("backup-id", BACKUP_ID_SCHEMA.clone())
|
||||
.required("backup-time", BACKUP_TIME_SCHEMA.clone())
|
||||
)
|
||||
}
|
||||
|
||||
@ -563,10 +560,9 @@ pub fn router() -> Router {
|
||||
list_snapshot_files,
|
||||
ObjectSchema::new("List snapshot files.")
|
||||
.required("store", store_schema.clone())
|
||||
.required("backup-type", StringSchema::new("Backup type."))
|
||||
.required("backup-id", StringSchema::new("Backup ID."))
|
||||
.required("backup-time", IntegerSchema::new("Backup time (Unix epoch.)")
|
||||
.minimum(1547797308))
|
||||
.required("backup-type", BACKUP_TYPE_SCHEMA.clone())
|
||||
.required("backup-id", BACKUP_ID_SCHEMA.clone())
|
||||
.required("backup-time", BACKUP_TIME_SCHEMA.clone())
|
||||
)
|
||||
)
|
||||
)
|
||||
@ -585,8 +581,8 @@ pub fn router() -> Router {
|
||||
list_snapshots,
|
||||
ObjectSchema::new("List backup groups.")
|
||||
.required("store", store_schema.clone())
|
||||
.optional("backup-type", StringSchema::new("Backup type."))
|
||||
.optional("backup-id", StringSchema::new("Backup ID."))
|
||||
.optional("backup-type", BACKUP_TYPE_SCHEMA.clone())
|
||||
.optional("backup-id", BACKUP_ID_SCHEMA.clone())
|
||||
)
|
||||
)
|
||||
.delete(
|
||||
@ -594,11 +590,10 @@ pub fn router() -> Router {
|
||||
delete_snapshots,
|
||||
ObjectSchema::new("Delete backup snapshot.")
|
||||
.required("store", store_schema.clone())
|
||||
.required("backup-type", StringSchema::new("Backup type."))
|
||||
.required("backup-id", StringSchema::new("Backup ID."))
|
||||
.required("backup-time", IntegerSchema::new("Backup time (Unix epoch.)")
|
||||
.minimum(1547797308))
|
||||
)
|
||||
.required("backup-type", BACKUP_TYPE_SCHEMA.clone())
|
||||
.required("backup-id", BACKUP_ID_SCHEMA.clone())
|
||||
.required("backup-time", BACKUP_TIME_SCHEMA.clone())
|
||||
)
|
||||
)
|
||||
)
|
||||
.subdir(
|
||||
|
@ -1,7 +1,7 @@
|
||||
use failure::*;
|
||||
use lazy_static::lazy_static;
|
||||
|
||||
use std::sync::Arc;
|
||||
//use std::sync::Arc;
|
||||
|
||||
use futures::*;
|
||||
use hyper::header::{HeaderValue, UPGRADE};
|
||||
@ -34,11 +34,9 @@ pub fn api_method_upgrade_backup() -> ApiAsyncMethod {
|
||||
upgrade_to_backup_protocol,
|
||||
ObjectSchema::new(concat!("Upgraded to backup protocol ('", PROXMOX_BACKUP_PROTOCOL_ID_V1!(), "')."))
|
||||
.required("store", StringSchema::new("Datastore name."))
|
||||
.required("backup-type", StringSchema::new("Backup type.")
|
||||
.format(Arc::new(ApiStringFormat::Enum(&["vm", "ct", "host"]))))
|
||||
.required("backup-id", StringSchema::new("Backup ID."))
|
||||
.required("backup-time", IntegerSchema::new("Backup time (Unix epoch.)")
|
||||
.minimum(1547797308))
|
||||
.required("backup-type", BACKUP_TYPE_SCHEMA.clone())
|
||||
.required("backup-id", BACKUP_ID_SCHEMA.clone())
|
||||
.required("backup-time", BACKUP_TIME_SCHEMA.clone())
|
||||
.optional("debug", BooleanSchema::new("Enable verbose debug logging."))
|
||||
)
|
||||
}
|
||||
|
@ -67,4 +67,19 @@ lazy_static!{
|
||||
StringSchema::new("Backup archive name.")
|
||||
.format(FILENAME_FORMAT.clone()).into();
|
||||
|
||||
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.)")
|
||||
.minimum(1547797308)
|
||||
.into();
|
||||
|
||||
}
|
||||
|
@ -10,6 +10,7 @@ use std::io::Write;
|
||||
|
||||
use proxmox_backup::tools;
|
||||
use proxmox_backup::cli::*;
|
||||
use proxmox_backup::api2::types::*;
|
||||
use proxmox_backup::api_schema::*;
|
||||
use proxmox_backup::api_schema::router::*;
|
||||
use proxmox_backup::client::*;
|
||||
@ -434,9 +435,9 @@ fn create_backup(
|
||||
|
||||
let keyfile = param["keyfile"].as_str().map(|p| PathBuf::from(p));
|
||||
|
||||
let backup_id = param["host-id"].as_str().unwrap_or(&tools::nodename());
|
||||
let backup_id = param["backup-id"].as_str().unwrap_or(&tools::nodename());
|
||||
|
||||
let backup_type = "host";
|
||||
let backup_type = param["backup-type"].as_str().unwrap_or("host");
|
||||
|
||||
let include_dev = param["include-dev"].as_array();
|
||||
|
||||
@ -1327,12 +1328,16 @@ fn main() {
|
||||
"skip-lost-and-found",
|
||||
BooleanSchema::new("Skip lost+found directory").default(false))
|
||||
.optional(
|
||||
"host-id",
|
||||
StringSchema::new("Use specified ID for the backup group name ('host/<id>'). The default is the system hostname."))
|
||||
"backup-type",
|
||||
BACKUP_TYPE_SCHEMA.clone()
|
||||
)
|
||||
.optional(
|
||||
"backup-id",
|
||||
BACKUP_ID_SCHEMA.clone()
|
||||
)
|
||||
.optional(
|
||||
"backup-time",
|
||||
IntegerSchema::new("Backup time (Unix epoch.)")
|
||||
.minimum(1547797308)
|
||||
BACKUP_TIME_SCHEMA.clone()
|
||||
)
|
||||
.optional(
|
||||
"chunk-size",
|
||||
|
Loading…
Reference in New Issue
Block a user