src/api2/admin/datastore.rs: cleanup - move schema defininition in front of rust method

This commit is contained in:
Dietmar Maurer 2019-12-06 12:36:41 +01:00
parent 1a0678b601
commit 0ab08ac980
1 changed files with 47 additions and 46 deletions

View File

@ -194,6 +194,17 @@ fn list_snapshots (
Ok(json!(snapshots))
}
#[sortable]
const API_METHOD_STATUS: ApiMethod = ApiMethod::new(
&ApiHandler::Sync(&status),
&ObjectSchema::new(
"Get datastore status.",
&sorted!([
("store", false, &StringSchema::new("Datastore name.").schema()),
]),
)
);
fn status(
param: Value,
_info: &ApiMethod,
@ -269,13 +280,16 @@ macro_rules! add_common_prune_prameters {
}
}
const API_METHOD_STATUS: ApiMethod = ApiMethod::new(
&ApiHandler::Sync(&status),
const API_METHOD_PRUNE: ApiMethod = ApiMethod::new(
&ApiHandler::Sync(&prune),
&ObjectSchema::new(
"Get datastore status.",
&[
"Prune the datastore.",
&add_common_prune_prameters!([
("backup-id", false, &BACKUP_ID_SCHEMA),
("backup-type", false, &BACKUP_TYPE_SCHEMA),
],[
("store", false, &StringSchema::new("Datastore name.").schema()),
],
])
)
);
@ -338,14 +352,12 @@ fn prune(
Ok(json!(null))
}
const API_METHOD_PRUNE: ApiMethod = ApiMethod::new(
&ApiHandler::Sync(&prune),
#[sortable]
pub const API_METHOD_START_GARBAGE_COLLECTION: ApiMethod = ApiMethod::new(
&ApiHandler::Sync(&start_garbage_collection),
&ObjectSchema::new(
"Prune the datastore.",
&add_common_prune_prameters!([
("backup-id", false, &BACKUP_ID_SCHEMA),
("backup-type", false, &BACKUP_TYPE_SCHEMA),
],[
"Start garbage collection.",
&sorted!([
("store", false, &StringSchema::new("Datastore name.").schema()),
])
)
@ -376,10 +388,10 @@ fn start_garbage_collection(
}
#[sortable]
pub const API_METHOD_START_GARBAGE_COLLECTION: ApiMethod = ApiMethod::new(
&ApiHandler::Sync(&start_garbage_collection),
pub const API_METHOD_GARBAGE_COLLECTION_STATUS: ApiMethod = ApiMethod::new(
&ApiHandler::Sync(&garbage_collection_status),
&ObjectSchema::new(
"Start garbage collection.",
"Garbage collection status.",
&sorted!([
("store", false, &StringSchema::new("Datastore name.").schema()),
])
@ -403,16 +415,6 @@ fn garbage_collection_status(
Ok(serde_json::to_value(&status)?)
}
#[sortable]
pub const API_METHOD_GARBAGE_COLLECTION_STATUS: ApiMethod = ApiMethod::new(
&ApiHandler::Sync(&garbage_collection_status),
&ObjectSchema::new(
"Garbage collection status.",
&sorted!([
("store", false, &StringSchema::new("Datastore name.").schema()),
])
)
);
fn get_datastore_list(
_param: Value,
@ -425,6 +427,23 @@ fn get_datastore_list(
Ok(config.convert_to_array("store"))
}
#[sortable]
pub const API_METHOD_DOWNLOAD_FILE: ApiMethod = ApiMethod::new(
&ApiHandler::AsyncHttp(&download_file),
&ObjectSchema::new(
"Download single raw file from backup snapshot.",
&sorted!([
("store", false, &StringSchema::new("Datastore name.").schema()),
("backup-type", false, &BACKUP_TYPE_SCHEMA),
("backup-id", false, &BACKUP_ID_SCHEMA),
("backup-time", false, &BACKUP_TIME_SCHEMA),
("file-name", false, &StringSchema::new("Raw file name.")
.format(&FILENAME_FORMAT)
.schema()
),
]),
)
);
fn download_file(
_parts: Parts,
@ -472,8 +491,8 @@ fn download_file(
}
#[sortable]
pub const API_METHOD_DOWNLOAD_FILE: ApiMethod = ApiMethod::new(
&ApiHandler::AsyncHttp(&download_file),
pub const API_METHOD_UPLOAD_BACKUP_LOG: ApiMethod = ApiMethod::new(
&ApiHandler::AsyncHttp(&upload_backup_log),
&ObjectSchema::new(
"Download single raw file from backup snapshot.",
&sorted!([
@ -481,10 +500,6 @@ pub const API_METHOD_DOWNLOAD_FILE: ApiMethod = ApiMethod::new(
("backup-type", false, &BACKUP_TYPE_SCHEMA),
("backup-id", false, &BACKUP_ID_SCHEMA),
("backup-time", false, &BACKUP_TIME_SCHEMA),
("file-name", false, &StringSchema::new("Raw file name.")
.format(&FILENAME_FORMAT)
.schema()
),
]),
)
);
@ -540,20 +555,6 @@ fn upload_backup_log(
}.boxed()
}
#[sortable]
pub const API_METHOD_UPLOAD_BACKUP_LOG: ApiMethod = ApiMethod::new(
&ApiHandler::AsyncHttp(&upload_backup_log),
&ObjectSchema::new(
"Download single raw file from backup snapshot.",
&sorted!([
("store", false, &StringSchema::new("Datastore name.").schema()),
("backup-type", false, &BACKUP_TYPE_SCHEMA),
("backup-id", false, &BACKUP_ID_SCHEMA),
("backup-time", false, &BACKUP_TIME_SCHEMA),
]),
)
);
const STORE_SCHEMA: Schema = StringSchema::new("Datastore name.").schema();
#[sortable]