move required_X_param to pbs_tools::json

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
This commit is contained in:
Wolfgang Bumiller
2021-07-20 11:06:53 +02:00
parent 6c221244df
commit 3c8c2827cb
17 changed files with 143 additions and 147 deletions

View File

@ -220,7 +220,7 @@ fn apt_get_changelog(
param: Value,
) -> Result<Value, Error> {
let name = crate::tools::required_string_param(&param, "name")?.to_owned();
let name = pbs_tools::json::required_string_param(&param, "name")?.to_owned();
let version = param["version"].as_str();
let pkg_info = apt::list_installed_apt_packages(|data| {

View File

@ -288,8 +288,8 @@ fn upgrade_to_websocket(
}
let userid = auth_id.user();
let ticket = tools::required_string_param(&param, "vncticket")?;
let port: u16 = tools::required_integer_param(&param, "port")? as u16;
let ticket = pbs_tools::json::required_string_param(&param, "vncticket")?;
let port: u16 = pbs_tools::json::required_integer_param(&param, "port")? as u16;
// will be checked again by termproxy
Ticket::<Empty>::parse(ticket)?

View File

@ -235,7 +235,7 @@ pub fn create_interface(
param: Value,
) -> Result<(), Error> {
let interface_type = crate::tools::required_string_param(&param, "type")?;
let interface_type = pbs_tools::json::required_string_param(&param, "type")?;
let interface_type: NetworkInterfaceType = serde_json::from_value(interface_type.into())?;
let _lock = open_file_locked(network::NETWORK_LOCKFILE, std::time::Duration::new(10, 0), true)?;

View File

@ -8,8 +8,6 @@ use proxmox::api::{api, Router, RpcEnvironment, Permission};
use proxmox::api::router::SubdirMap;
use proxmox::{identity, list_subdirs_api_method, sortable};
use crate::tools;
use crate::api2::types::*;
use crate::api2::pull::check_pull_privs;
@ -222,7 +220,7 @@ async fn get_task_status(
fn extract_upid(param: &Value) -> Result<UPID, Error> {
let upid_str = tools::required_string_param(&param, "upid")?;
let upid_str = pbs_tools::json::required_string_param(&param, "upid")?;
upid_str.parse::<UPID>()
}