move required_X_param to pbs_tools::json
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
This commit is contained in:
@ -74,6 +74,7 @@ use pbs_datastore::read_chunk::AsyncReadChunk;
|
||||
use pbs_datastore::prune::PruneOptions;
|
||||
use pbs_tools::sync::StdChannelWriter;
|
||||
use pbs_tools::tokio::TokioWriterAdapter;
|
||||
use pbs_tools::json;
|
||||
|
||||
use proxmox_backup::backup::{
|
||||
BufferedDynamicReader,
|
||||
@ -486,7 +487,7 @@ fn spawn_catalog_upload(
|
||||
encrypt: bool,
|
||||
) -> Result<CatalogUploadResult, Error> {
|
||||
let (catalog_tx, catalog_rx) = std::sync::mpsc::sync_channel(10); // allow to buffer 10 writes
|
||||
let catalog_stream = crate::tools::StdChannelStream(catalog_rx);
|
||||
let catalog_stream = tools::StdChannelStream(catalog_rx);
|
||||
let catalog_chunk_size = 512*1024;
|
||||
let catalog_chunk_stream = ChunkStream::new(catalog_stream, Some(catalog_chunk_size));
|
||||
|
||||
@ -616,7 +617,7 @@ async fn create_backup(
|
||||
|
||||
let repo = extract_repository_from_value(¶m)?;
|
||||
|
||||
let backupspec_list = tools::required_array_param(¶m, "backupspec")?;
|
||||
let backupspec_list = json::required_array_param(¶m, "backupspec")?;
|
||||
|
||||
let all_file_systems = param["all-file-systems"].as_bool().unwrap_or(false);
|
||||
|
||||
@ -1071,13 +1072,13 @@ async fn restore(param: Value) -> Result<Value, Error> {
|
||||
|
||||
let allow_existing_dirs = param["allow-existing-dirs"].as_bool().unwrap_or(false);
|
||||
|
||||
let archive_name = tools::required_string_param(¶m, "archive-name")?;
|
||||
let archive_name = json::required_string_param(¶m, "archive-name")?;
|
||||
|
||||
let client = connect(&repo)?;
|
||||
|
||||
record_repository(&repo);
|
||||
|
||||
let path = tools::required_string_param(¶m, "snapshot")?;
|
||||
let path = json::required_string_param(¶m, "snapshot")?;
|
||||
|
||||
let (backup_type, backup_id, backup_time) = if path.matches('/').count() == 1 {
|
||||
let group: BackupGroup = path.parse()?;
|
||||
@ -1087,7 +1088,7 @@ async fn restore(param: Value) -> Result<Value, Error> {
|
||||
(snapshot.group().backup_type().to_owned(), snapshot.group().backup_id().to_owned(), snapshot.backup_time())
|
||||
};
|
||||
|
||||
let target = tools::required_string_param(¶m, "target")?;
|
||||
let target = json::required_string_param(¶m, "target")?;
|
||||
let target = if target == "-" { None } else { Some(target) };
|
||||
|
||||
let crypto = crypto_parameters(¶m)?;
|
||||
|
@ -8,8 +8,8 @@ use proxmox::api::{api, cli::*, RpcEnvironment};
|
||||
|
||||
use pbs_client::{connect_to_localhost, display_task_log, view_task_result};
|
||||
use pbs_tools::percent_encoding::percent_encode_component;
|
||||
use pbs_tools::json::required_string_param;
|
||||
|
||||
use proxmox_backup::tools;
|
||||
use proxmox_backup::config;
|
||||
use proxmox_backup::api2::{self, types::* };
|
||||
use proxmox_backup::server::wait_for_local_worker;
|
||||
@ -35,7 +35,7 @@ async fn start_garbage_collection(param: Value) -> Result<Value, Error> {
|
||||
|
||||
let output_format = get_output_format(¶m);
|
||||
|
||||
let store = tools::required_string_param(¶m, "store")?;
|
||||
let store = required_string_param(¶m, "store")?;
|
||||
|
||||
let mut client = connect_to_localhost()?;
|
||||
|
||||
@ -66,7 +66,7 @@ async fn garbage_collection_status(param: Value) -> Result<Value, Error> {
|
||||
|
||||
let output_format = get_output_format(¶m);
|
||||
|
||||
let store = tools::required_string_param(¶m, "store")?;
|
||||
let store = required_string_param(¶m, "store")?;
|
||||
|
||||
let client = connect_to_localhost()?;
|
||||
|
||||
@ -166,7 +166,7 @@ async fn task_list(param: Value) -> Result<Value, Error> {
|
||||
/// Display the task log.
|
||||
async fn task_log(param: Value) -> Result<Value, Error> {
|
||||
|
||||
let upid = tools::required_string_param(¶m, "upid")?;
|
||||
let upid = required_string_param(¶m, "upid")?;
|
||||
|
||||
let mut client = connect_to_localhost()?;
|
||||
|
||||
@ -187,7 +187,7 @@ async fn task_log(param: Value) -> Result<Value, Error> {
|
||||
/// Try to stop a specific task.
|
||||
async fn task_stop(param: Value) -> Result<Value, Error> {
|
||||
|
||||
let upid_str = tools::required_string_param(¶m, "upid")?;
|
||||
let upid_str = required_string_param(¶m, "upid")?;
|
||||
|
||||
let mut client = connect_to_localhost()?;
|
||||
|
||||
|
@ -9,8 +9,7 @@ use proxmox::api::{api, cli::*};
|
||||
|
||||
use pbs_client::tools::key_source::get_encryption_key_password;
|
||||
use pbs_client::{BackupReader, RemoteChunkReader};
|
||||
|
||||
use proxmox_backup::tools;
|
||||
use pbs_tools::json::required_string_param;
|
||||
|
||||
use crate::{
|
||||
REPO_URL_SCHEMA,
|
||||
@ -66,7 +65,7 @@ async fn dump_catalog(param: Value) -> Result<Value, Error> {
|
||||
|
||||
let repo = extract_repository_from_value(¶m)?;
|
||||
|
||||
let path = tools::required_string_param(¶m, "snapshot")?;
|
||||
let path = required_string_param(¶m, "snapshot")?;
|
||||
let snapshot: BackupDir = path.parse()?;
|
||||
|
||||
let crypto = crypto_parameters(¶m)?;
|
||||
@ -160,8 +159,8 @@ async fn dump_catalog(param: Value) -> Result<Value, Error> {
|
||||
async fn catalog_shell(param: Value) -> Result<(), Error> {
|
||||
let repo = extract_repository_from_value(¶m)?;
|
||||
let client = connect(&repo)?;
|
||||
let path = tools::required_string_param(¶m, "snapshot")?;
|
||||
let archive_name = tools::required_string_param(¶m, "archive-name")?;
|
||||
let path = required_string_param(¶m, "snapshot")?;
|
||||
let archive_name = required_string_param(¶m, "archive-name")?;
|
||||
|
||||
let (backup_type, backup_id, backup_time) = if path.matches('/').count() == 1 {
|
||||
let group: BackupGroup = path.parse()?;
|
||||
|
@ -19,6 +19,7 @@ use proxmox::tools::fd::Fd;
|
||||
|
||||
use pbs_client::tools::key_source::get_encryption_key_password;
|
||||
use pbs_client::{BackupReader, RemoteChunkReader};
|
||||
use pbs_tools::json::required_string_param;
|
||||
|
||||
use proxmox_backup::tools;
|
||||
use proxmox_backup::backup::{
|
||||
@ -162,14 +163,14 @@ fn mount(
|
||||
|
||||
async fn mount_do(param: Value, pipe: Option<Fd>) -> Result<Value, Error> {
|
||||
let repo = extract_repository_from_value(¶m)?;
|
||||
let archive_name = tools::required_string_param(¶m, "archive-name")?;
|
||||
let archive_name = required_string_param(¶m, "archive-name")?;
|
||||
let client = connect(&repo)?;
|
||||
|
||||
let target = param["target"].as_str();
|
||||
|
||||
record_repository(&repo);
|
||||
|
||||
let path = tools::required_string_param(¶m, "snapshot")?;
|
||||
let path = required_string_param(¶m, "snapshot")?;
|
||||
let (backup_type, backup_id, backup_time) = if path.matches('/').count() == 1 {
|
||||
let group: BackupGroup = path.parse()?;
|
||||
api_datastore_latest_snapshot(&client, repo.store(), group).await?
|
||||
|
@ -9,9 +9,9 @@ use proxmox::{
|
||||
};
|
||||
|
||||
use pbs_client::tools::key_source::get_encryption_key_password;
|
||||
use pbs_tools::json::required_string_param;
|
||||
|
||||
use proxmox_backup::{
|
||||
tools,
|
||||
api2::types::*,
|
||||
backup::{
|
||||
CryptMode,
|
||||
@ -129,7 +129,7 @@ async fn list_snapshot_files(param: Value) -> Result<Value, Error> {
|
||||
|
||||
let repo = extract_repository_from_value(¶m)?;
|
||||
|
||||
let path = tools::required_string_param(¶m, "snapshot")?;
|
||||
let path = required_string_param(¶m, "snapshot")?;
|
||||
let snapshot: BackupDir = path.parse()?;
|
||||
|
||||
let output_format = get_output_format(¶m);
|
||||
@ -177,7 +177,7 @@ async fn forget_snapshots(param: Value) -> Result<Value, Error> {
|
||||
|
||||
let repo = extract_repository_from_value(¶m)?;
|
||||
|
||||
let path = tools::required_string_param(¶m, "snapshot")?;
|
||||
let path = required_string_param(¶m, "snapshot")?;
|
||||
let snapshot: BackupDir = path.parse()?;
|
||||
|
||||
let mut client = connect(&repo)?;
|
||||
@ -228,10 +228,10 @@ async fn forget_snapshots(param: Value) -> Result<Value, Error> {
|
||||
/// Upload backup log file.
|
||||
async fn upload_log(param: Value) -> Result<Value, Error> {
|
||||
|
||||
let logfile = tools::required_string_param(¶m, "logfile")?;
|
||||
let logfile = required_string_param(¶m, "logfile")?;
|
||||
let repo = extract_repository_from_value(¶m)?;
|
||||
|
||||
let snapshot = tools::required_string_param(¶m, "snapshot")?;
|
||||
let snapshot = required_string_param(¶m, "snapshot")?;
|
||||
let snapshot: BackupDir = snapshot.parse()?;
|
||||
|
||||
let mut client = connect(&repo)?;
|
||||
@ -291,7 +291,7 @@ async fn upload_log(param: Value) -> Result<Value, Error> {
|
||||
/// Show notes
|
||||
async fn show_notes(param: Value) -> Result<Value, Error> {
|
||||
let repo = extract_repository_from_value(¶m)?;
|
||||
let path = tools::required_string_param(¶m, "snapshot")?;
|
||||
let path = required_string_param(¶m, "snapshot")?;
|
||||
|
||||
let snapshot: BackupDir = path.parse()?;
|
||||
let client = connect(&repo)?;
|
||||
@ -347,8 +347,8 @@ async fn show_notes(param: Value) -> Result<Value, Error> {
|
||||
/// Update Notes
|
||||
async fn update_notes(param: Value) -> Result<Value, Error> {
|
||||
let repo = extract_repository_from_value(¶m)?;
|
||||
let path = tools::required_string_param(¶m, "snapshot")?;
|
||||
let notes = tools::required_string_param(¶m, "notes")?;
|
||||
let path = required_string_param(¶m, "snapshot")?;
|
||||
let notes = required_string_param(¶m, "notes")?;
|
||||
|
||||
let snapshot: BackupDir = path.parse()?;
|
||||
let mut client = connect(&repo)?;
|
||||
|
@ -3,10 +3,9 @@ use serde_json::{json, Value};
|
||||
|
||||
use proxmox::api::{api, cli::*};
|
||||
|
||||
use pbs_tools::percent_encoding::percent_encode_component;
|
||||
use pbs_client::display_task_log;
|
||||
|
||||
use proxmox_backup::tools;
|
||||
use pbs_tools::percent_encoding::percent_encode_component;
|
||||
use pbs_tools::json::required_string_param;
|
||||
|
||||
use proxmox_backup::api2::types::UPID_SCHEMA;
|
||||
|
||||
@ -97,7 +96,7 @@ async fn task_list(param: Value) -> Result<Value, Error> {
|
||||
async fn task_log(param: Value) -> Result<Value, Error> {
|
||||
|
||||
let repo = extract_repository_from_value(¶m)?;
|
||||
let upid = tools::required_string_param(¶m, "upid")?;
|
||||
let upid = required_string_param(¶m, "upid")?;
|
||||
|
||||
let mut client = connect(&repo)?;
|
||||
|
||||
@ -123,7 +122,7 @@ async fn task_log(param: Value) -> Result<Value, Error> {
|
||||
async fn task_stop(param: Value) -> Result<Value, Error> {
|
||||
|
||||
let repo = extract_repository_from_value(¶m)?;
|
||||
let upid_str = tools::required_string_param(¶m, "upid")?;
|
||||
let upid_str = required_string_param(¶m, "upid")?;
|
||||
|
||||
let mut client = connect(&repo)?;
|
||||
|
||||
|
@ -21,11 +21,11 @@ use proxmox::{identity, list_subdirs_api_method, sortable};
|
||||
|
||||
use pbs_client::pxar::{create_archive, Flags, PxarCreateOptions, ENCODER_MAX_ENTRIES};
|
||||
use pbs_tools::fs::read_subdir;
|
||||
use pbs_tools::json::required_string_param;
|
||||
use pbs_tools::zip::zip_directory;
|
||||
|
||||
use proxmox_backup::api2::types::*;
|
||||
use proxmox_backup::backup::DirEntryAttribute;
|
||||
use proxmox_backup::tools;
|
||||
|
||||
use pxar::encoder::aio::TokioWriter;
|
||||
|
||||
@ -264,7 +264,7 @@ fn extract(
|
||||
Err(_) => bail!("maximum concurrent download limit reached, please wait for another restore to finish before attempting a new one"),
|
||||
};
|
||||
|
||||
let path = tools::required_string_param(¶m, "path")?;
|
||||
let path = required_string_param(¶m, "path")?;
|
||||
let mut path = base64::decode(path)?;
|
||||
if let Some(b'/') = path.last() {
|
||||
path.pop();
|
||||
|
Reference in New Issue
Block a user