api: pass RpcEnvirnment to api handlers
This commit is contained in:
@ -18,10 +18,6 @@ use proxmox_backup::catar::decoder::*;
|
||||
|
||||
use proxmox_backup::tools::*;
|
||||
|
||||
fn required_string_param<'a>(param: &'a Value, name: &str) -> &'a str {
|
||||
param[name].as_str().expect(&format!("missing parameter '{}'", name))
|
||||
}
|
||||
|
||||
fn print_goodby_entries(buffer: &[u8]) -> Result<(), Error> {
|
||||
println!("GOODBY START: {}", buffer.len());
|
||||
|
||||
@ -53,9 +49,13 @@ fn print_goodby_entries(buffer: &[u8]) -> Result<(), Error> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn print_filenames(param: Value, _info: &ApiMethod) -> Result<Value, Error> {
|
||||
fn print_filenames(
|
||||
param: Value,
|
||||
_info: &ApiMethod,
|
||||
_rpcenv: &mut RpcEnvironment,
|
||||
) -> Result<Value, Error> {
|
||||
|
||||
let archive = required_string_param(¶m, "archive");
|
||||
let archive = tools::required_string_param(¶m, "archive")?;
|
||||
let file = std::fs::File::open(archive)?;
|
||||
|
||||
let mut reader = std::io::BufReader::new(file);
|
||||
@ -72,9 +72,13 @@ fn print_filenames(param: Value, _info: &ApiMethod) -> Result<Value, Error> {
|
||||
Ok(Value::Null)
|
||||
}
|
||||
|
||||
fn dump_archive(param: Value, _info: &ApiMethod) -> Result<Value, Error> {
|
||||
fn dump_archive(
|
||||
param: Value,
|
||||
_info: &ApiMethod,
|
||||
_rpcenv: &mut RpcEnvironment,
|
||||
) -> Result<Value, Error> {
|
||||
|
||||
let archive = required_string_param(¶m, "archive");
|
||||
let archive = tools::required_string_param(¶m, "archive")?;
|
||||
let mut file = std::fs::File::open(archive)?;
|
||||
|
||||
println!("CATAR {}", archive);
|
||||
@ -117,10 +121,14 @@ fn dump_archive(param: Value, _info: &ApiMethod) -> Result<Value, Error> {
|
||||
Ok(Value::Null)
|
||||
}
|
||||
|
||||
fn create_archive(param: Value, _info: &ApiMethod) -> Result<Value, Error> {
|
||||
fn create_archive(
|
||||
param: Value,
|
||||
_info: &ApiMethod,
|
||||
_rpcenv: &mut RpcEnvironment,
|
||||
) -> Result<Value, Error> {
|
||||
|
||||
let archive = required_string_param(¶m, "archive");
|
||||
let source = required_string_param(¶m, "source");
|
||||
let archive = tools::required_string_param(¶m, "archive")?;
|
||||
let source = tools::required_string_param(¶m, "source")?;
|
||||
|
||||
let source = std::path::PathBuf::from(source);
|
||||
|
||||
|
@ -65,7 +65,11 @@ fn backup_image(datastore: &DataStore, file: &std::fs::File, size: usize, target
|
||||
}
|
||||
*/
|
||||
|
||||
fn list_backups(param: Value, _info: &ApiMethod) -> Result<Value, Error> {
|
||||
fn list_backups(
|
||||
param: Value,
|
||||
_info: &ApiMethod,
|
||||
_rpcenv: &mut RpcEnvironment,
|
||||
) -> Result<Value, Error> {
|
||||
|
||||
let store = tools::required_string_param(¶m, "store")?;
|
||||
|
||||
@ -78,7 +82,11 @@ fn list_backups(param: Value, _info: &ApiMethod) -> Result<Value, Error> {
|
||||
Ok(result)
|
||||
}
|
||||
|
||||
fn create_backup(param: Value, _info: &ApiMethod) -> Result<Value, Error> {
|
||||
fn create_backup(
|
||||
param: Value,
|
||||
_info: &ApiMethod,
|
||||
_rpcenv: &mut RpcEnvironment,
|
||||
) -> Result<Value, Error> {
|
||||
|
||||
let filename = tools::required_string_param(¶m, "filename")?;
|
||||
let store = tools::required_string_param(¶m, "store")?;
|
||||
|
Reference in New Issue
Block a user