src/api2/types.rs: factor out DATASTORE_SCHEMA
This commit is contained in:
parent
567d3e00fb
commit
66c49c21c3
|
@ -200,7 +200,7 @@ const API_METHOD_STATUS: ApiMethod = ApiMethod::new(
|
|||
&ObjectSchema::new(
|
||||
"Get datastore status.",
|
||||
&sorted!([
|
||||
("store", false, &StringSchema::new("Datastore name.").schema()),
|
||||
("store", false, &DATASTORE_SCHEMA),
|
||||
]),
|
||||
)
|
||||
);
|
||||
|
@ -299,7 +299,7 @@ const API_METHOD_PRUNE: ApiMethod = ApiMethod::new(
|
|||
.schema()
|
||||
),
|
||||
],[
|
||||
("store", false, &StringSchema::new("Datastore name.").schema()),
|
||||
("store", false, &DATASTORE_SCHEMA),
|
||||
])
|
||||
)
|
||||
);
|
||||
|
@ -388,7 +388,7 @@ pub const API_METHOD_START_GARBAGE_COLLECTION: ApiMethod = ApiMethod::new(
|
|||
&ObjectSchema::new(
|
||||
"Start garbage collection.",
|
||||
&sorted!([
|
||||
("store", false, &StringSchema::new("Datastore name.").schema()),
|
||||
("store", false, &DATASTORE_SCHEMA),
|
||||
])
|
||||
)
|
||||
);
|
||||
|
@ -423,7 +423,7 @@ pub const API_METHOD_GARBAGE_COLLECTION_STATUS: ApiMethod = ApiMethod::new(
|
|||
&ObjectSchema::new(
|
||||
"Garbage collection status.",
|
||||
&sorted!([
|
||||
("store", false, &StringSchema::new("Datastore name.").schema()),
|
||||
("store", false, &DATASTORE_SCHEMA),
|
||||
])
|
||||
)
|
||||
);
|
||||
|
@ -463,7 +463,7 @@ pub const API_METHOD_DOWNLOAD_FILE: ApiMethod = ApiMethod::new(
|
|||
&ObjectSchema::new(
|
||||
"Download single raw file from backup snapshot.",
|
||||
&sorted!([
|
||||
("store", false, &StringSchema::new("Datastore name.").schema()),
|
||||
("store", false, &DATASTORE_SCHEMA),
|
||||
("backup-type", false, &BACKUP_TYPE_SCHEMA),
|
||||
("backup-id", false, &BACKUP_ID_SCHEMA),
|
||||
("backup-time", false, &BACKUP_TIME_SCHEMA),
|
||||
|
@ -526,7 +526,7 @@ pub const API_METHOD_UPLOAD_BACKUP_LOG: ApiMethod = ApiMethod::new(
|
|||
&ObjectSchema::new(
|
||||
"Download single raw file from backup snapshot.",
|
||||
&sorted!([
|
||||
("store", false, &StringSchema::new("Datastore name.").schema()),
|
||||
("store", false, &DATASTORE_SCHEMA),
|
||||
("backup-type", false, &BACKUP_TYPE_SCHEMA),
|
||||
("backup-id", false, &BACKUP_ID_SCHEMA),
|
||||
("backup-time", false, &BACKUP_TIME_SCHEMA),
|
||||
|
@ -585,8 +585,6 @@ fn upload_backup_log(
|
|||
}.boxed()
|
||||
}
|
||||
|
||||
const STORE_SCHEMA: Schema = StringSchema::new("Datastore name.").schema();
|
||||
|
||||
#[sortable]
|
||||
const DATASTORE_INFO_SUBDIRS: SubdirMap = &[
|
||||
(
|
||||
|
@ -603,7 +601,7 @@ const DATASTORE_INFO_SUBDIRS: SubdirMap = &[
|
|||
&ObjectSchema::new(
|
||||
"List snapshot files.",
|
||||
&sorted!([
|
||||
("store", false, &STORE_SCHEMA),
|
||||
("store", false, &DATASTORE_SCHEMA),
|
||||
("backup-type", false, &BACKUP_TYPE_SCHEMA),
|
||||
("backup-id", false, &BACKUP_ID_SCHEMA),
|
||||
("backup-time", false, &BACKUP_TIME_SCHEMA),
|
||||
|
@ -626,7 +624,7 @@ const DATASTORE_INFO_SUBDIRS: SubdirMap = &[
|
|||
&ApiHandler::Sync(&list_groups),
|
||||
&ObjectSchema::new(
|
||||
"List backup groups.",
|
||||
&sorted!([ ("store", false, &STORE_SCHEMA) ]),
|
||||
&sorted!([ ("store", false, &DATASTORE_SCHEMA) ]),
|
||||
)
|
||||
)
|
||||
)
|
||||
|
@ -645,7 +643,7 @@ const DATASTORE_INFO_SUBDIRS: SubdirMap = &[
|
|||
&ObjectSchema::new(
|
||||
"List backup groups.",
|
||||
&sorted!([
|
||||
("store", false, &STORE_SCHEMA),
|
||||
("store", false, &DATASTORE_SCHEMA),
|
||||
("backup-type", true, &BACKUP_TYPE_SCHEMA),
|
||||
("backup-id", true, &BACKUP_ID_SCHEMA),
|
||||
]),
|
||||
|
@ -658,7 +656,7 @@ const DATASTORE_INFO_SUBDIRS: SubdirMap = &[
|
|||
&ObjectSchema::new(
|
||||
"Delete backup snapshot.",
|
||||
&sorted!([
|
||||
("store", false, &STORE_SCHEMA),
|
||||
("store", false, &DATASTORE_SCHEMA),
|
||||
("backup-type", false, &BACKUP_TYPE_SCHEMA),
|
||||
("backup-id", false, &BACKUP_ID_SCHEMA),
|
||||
("backup-time", false, &BACKUP_TIME_SCHEMA),
|
||||
|
|
|
@ -32,7 +32,7 @@ pub const API_METHOD_UPGRADE_BACKUP: ApiMethod = ApiMethod::new(
|
|||
&ObjectSchema::new(
|
||||
concat!("Upgraded to backup protocol ('", PROXMOX_BACKUP_PROTOCOL_ID_V1!(), "')."),
|
||||
&sorted!([
|
||||
("store", false, &StringSchema::new("Datastore name.").schema()),
|
||||
("store", false, &DATASTORE_SCHEMA),
|
||||
("backup-type", false, &BACKUP_TYPE_SCHEMA),
|
||||
("backup-id", false, &BACKUP_ID_SCHEMA),
|
||||
("backup-time", false, &BACKUP_TIME_SCHEMA),
|
||||
|
|
|
@ -6,6 +6,7 @@ use serde_json::{json, Value};
|
|||
use proxmox::api::{ApiHandler, ApiMethod, Router, RpcEnvironment};
|
||||
use proxmox::api::schema::*;
|
||||
|
||||
use crate::api2::types::*;
|
||||
use crate::backup::*;
|
||||
use crate::config::datastore;
|
||||
|
||||
|
@ -30,7 +31,7 @@ pub const POST: ApiMethod = ApiMethod::new(
|
|||
&ObjectSchema::new(
|
||||
"Create new datastore.",
|
||||
&[
|
||||
("name", false, &StringSchema::new("Datastore name.").schema()),
|
||||
("name", false, &DATASTORE_SCHEMA),
|
||||
("path", false, &StringSchema::new("Directory path (must exist).").schema()),
|
||||
],
|
||||
)
|
||||
|
@ -71,7 +72,7 @@ pub const DELETE: ApiMethod = ApiMethod::new(
|
|||
&ObjectSchema::new(
|
||||
"Remove a datastore configuration.",
|
||||
&[
|
||||
("name", false, &StringSchema::new("Datastore name.").schema()),
|
||||
("name", false, &DATASTORE_SCHEMA),
|
||||
],
|
||||
)
|
||||
);
|
||||
|
|
|
@ -280,7 +280,7 @@ pub const ROUTER: Router = Router::new()
|
|||
.default(50)
|
||||
.schema()
|
||||
),
|
||||
("store", true, &StringSchema::new("Only lists tasks for datastore name.").schema()),
|
||||
("store", true, &DATASTORE_SCHEMA),
|
||||
("running", true, &BooleanSchema::new("Only list running tasks.").schema()),
|
||||
("errors", true, &BooleanSchema::new("Only list erroneous tasks.").schema()),
|
||||
("userfilter", true, &StringSchema::new("Only list tasks from this user.").schema()),
|
||||
|
|
|
@ -28,7 +28,7 @@ pub const API_METHOD_UPGRADE_BACKUP: ApiMethod = ApiMethod::new(
|
|||
&ObjectSchema::new(
|
||||
concat!("Upgraded to backup protocol ('", PROXMOX_BACKUP_READER_PROTOCOL_ID_V1!(), "')."),
|
||||
&sorted!([
|
||||
("store", false, &StringSchema::new("Datastore name.").schema()),
|
||||
("store", false, &DATASTORE_SCHEMA),
|
||||
("backup-type", false, &StringSchema::new("Backup type.")
|
||||
.format(&ApiStringFormat::Enum(&["vm", "ct", "host"]))
|
||||
.schema()
|
||||
|
|
|
@ -101,3 +101,7 @@ pub const BACKUP_TIME_SCHEMA: Schema =
|
|||
pub const UPID_SCHEMA: Schema = StringSchema::new("Unique Process/Task ID.")
|
||||
.max_length(256)
|
||||
.schema();
|
||||
|
||||
pub const DATASTORE_SCHEMA: Schema = StringSchema::new("Datastore name.")
|
||||
.max_length(32)
|
||||
.schema();
|
||||
|
|
Loading…
Reference in New Issue