src/api2/admin/datastore.rs: cleanup - move schema defininition in front of rust method
This commit is contained in:
parent
1a0678b601
commit
0ab08ac980
@ -194,6 +194,17 @@ fn list_snapshots (
|
|||||||
Ok(json!(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(
|
fn status(
|
||||||
param: Value,
|
param: Value,
|
||||||
_info: &ApiMethod,
|
_info: &ApiMethod,
|
||||||
@ -269,13 +280,16 @@ macro_rules! add_common_prune_prameters {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const API_METHOD_STATUS: ApiMethod = ApiMethod::new(
|
const API_METHOD_PRUNE: ApiMethod = ApiMethod::new(
|
||||||
&ApiHandler::Sync(&status),
|
&ApiHandler::Sync(&prune),
|
||||||
&ObjectSchema::new(
|
&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()),
|
("store", false, &StringSchema::new("Datastore name.").schema()),
|
||||||
],
|
])
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -338,14 +352,12 @@ fn prune(
|
|||||||
Ok(json!(null))
|
Ok(json!(null))
|
||||||
}
|
}
|
||||||
|
|
||||||
const API_METHOD_PRUNE: ApiMethod = ApiMethod::new(
|
#[sortable]
|
||||||
&ApiHandler::Sync(&prune),
|
pub const API_METHOD_START_GARBAGE_COLLECTION: ApiMethod = ApiMethod::new(
|
||||||
|
&ApiHandler::Sync(&start_garbage_collection),
|
||||||
&ObjectSchema::new(
|
&ObjectSchema::new(
|
||||||
"Prune the datastore.",
|
"Start garbage collection.",
|
||||||
&add_common_prune_prameters!([
|
&sorted!([
|
||||||
("backup-id", false, &BACKUP_ID_SCHEMA),
|
|
||||||
("backup-type", false, &BACKUP_TYPE_SCHEMA),
|
|
||||||
],[
|
|
||||||
("store", false, &StringSchema::new("Datastore name.").schema()),
|
("store", false, &StringSchema::new("Datastore name.").schema()),
|
||||||
])
|
])
|
||||||
)
|
)
|
||||||
@ -376,10 +388,10 @@ fn start_garbage_collection(
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[sortable]
|
#[sortable]
|
||||||
pub const API_METHOD_START_GARBAGE_COLLECTION: ApiMethod = ApiMethod::new(
|
pub const API_METHOD_GARBAGE_COLLECTION_STATUS: ApiMethod = ApiMethod::new(
|
||||||
&ApiHandler::Sync(&start_garbage_collection),
|
&ApiHandler::Sync(&garbage_collection_status),
|
||||||
&ObjectSchema::new(
|
&ObjectSchema::new(
|
||||||
"Start garbage collection.",
|
"Garbage collection status.",
|
||||||
&sorted!([
|
&sorted!([
|
||||||
("store", false, &StringSchema::new("Datastore name.").schema()),
|
("store", false, &StringSchema::new("Datastore name.").schema()),
|
||||||
])
|
])
|
||||||
@ -403,16 +415,6 @@ fn garbage_collection_status(
|
|||||||
Ok(serde_json::to_value(&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(
|
fn get_datastore_list(
|
||||||
_param: Value,
|
_param: Value,
|
||||||
@ -425,6 +427,23 @@ fn get_datastore_list(
|
|||||||
Ok(config.convert_to_array("store"))
|
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(
|
fn download_file(
|
||||||
_parts: Parts,
|
_parts: Parts,
|
||||||
@ -472,19 +491,15 @@ fn download_file(
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[sortable]
|
#[sortable]
|
||||||
pub const API_METHOD_DOWNLOAD_FILE: ApiMethod = ApiMethod::new(
|
pub const API_METHOD_UPLOAD_BACKUP_LOG: ApiMethod = ApiMethod::new(
|
||||||
&ApiHandler::AsyncHttp(&download_file),
|
&ApiHandler::AsyncHttp(&upload_backup_log),
|
||||||
&ObjectSchema::new(
|
&ObjectSchema::new(
|
||||||
"Download single raw file from backup snapshot.",
|
"Download single raw file from backup snapshot.",
|
||||||
&sorted!([
|
&sorted!([
|
||||||
("store", false, &StringSchema::new("Datastore name.").schema()),
|
("store", false, &StringSchema::new("Datastore name.").schema()),
|
||||||
("backup-type", false, &BACKUP_TYPE_SCHEMA),
|
("backup-type", false, &BACKUP_TYPE_SCHEMA),
|
||||||
("backup-id", false, &BACKUP_ID_SCHEMA),
|
("backup-id", false, &BACKUP_ID_SCHEMA),
|
||||||
("backup-time", false, &BACKUP_TIME_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()
|
}.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();
|
const STORE_SCHEMA: Schema = StringSchema::new("Datastore name.").schema();
|
||||||
|
|
||||||
#[sortable]
|
#[sortable]
|
||||||
|
Loading…
Reference in New Issue
Block a user