mirror of
git://git.proxmox.com/git/proxmox-backup.git
synced 2025-01-05 09:17:59 +03:00
move json_object_to_query to proxmox-http+http-helpers
it's used by the subscription code that will be extracted next. Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
This commit is contained in:
parent
87b7fa0226
commit
2b9cf927e3
8
debian/control
vendored
8
debian/control
vendored
@ -47,10 +47,10 @@ Build-Depends: debhelper (>= 12),
|
||||
librust-proxmox-borrow-1+default-dev,
|
||||
librust-proxmox-compression-0.1+default-dev (>= 0.1.1-~~),
|
||||
librust-proxmox-fuse-0.1+default-dev (>= 0.1.3-~~),
|
||||
librust-proxmox-http-0.6+client-dev (>= 0.6.1-~~),
|
||||
librust-proxmox-http-0.6+default-dev (>= 0.6.1-~~),
|
||||
librust-proxmox-http-0.6+http-helpers-dev (>= 0.6.1-~~),
|
||||
librust-proxmox-http-0.6+websocket-dev (>= 0.6.1-~~),
|
||||
librust-proxmox-http-0.6+client-dev (>= 0.6.3-~~),
|
||||
librust-proxmox-http-0.6+default-dev (>= 0.6.3-~~),
|
||||
librust-proxmox-http-0.6+http-helpers-dev (>= 0.6.3-~~),
|
||||
librust-proxmox-http-0.6+websocket-dev (>= 0.6.3-~~),
|
||||
librust-proxmox-io-1+default-dev (>= 1.0.1-~~),
|
||||
librust-proxmox-io-1+tokio-dev (>= 1.0.1-~~),
|
||||
librust-proxmox-lang-1+default-dev (>= 1.1-~~),
|
||||
|
@ -36,7 +36,7 @@ pathpatterns = "0.1.2"
|
||||
proxmox-async = "0.4"
|
||||
proxmox-compression = "0.1.1"
|
||||
proxmox-fuse = "0.1.3"
|
||||
proxmox-http = { version = "0.6", features = [ "client", "http-helpers", "websocket" ] }
|
||||
proxmox-http = { version = "0.6.3", features = [ "client", "http-helpers", "websocket" ] }
|
||||
proxmox-io = { version = "1.0.1", features = [ "tokio" ] }
|
||||
proxmox-lang = "1.1"
|
||||
proxmox-router = { version = "1.2.4", features = [ "cli" ] }
|
||||
|
@ -23,11 +23,10 @@ use proxmox_sys::linux::tty;
|
||||
|
||||
use proxmox_async::broadcast_future::BroadcastFuture;
|
||||
use proxmox_http::client::{HttpsConnector, RateLimiter};
|
||||
use proxmox_http::uri::build_authority;
|
||||
use proxmox_http::uri::{build_authority, json_object_to_query};
|
||||
|
||||
use pbs_api_types::percent_encoding::DEFAULT_ENCODE_SET;
|
||||
use pbs_api_types::{Authid, RateLimitConfig, Userid};
|
||||
use pbs_tools::json::json_object_to_query;
|
||||
use pbs_tools::ticket;
|
||||
|
||||
use super::pipe_to_stream::PipeToSendStream;
|
||||
|
@ -10,12 +10,12 @@ use anyhow::{bail, format_err, Context, Error};
|
||||
use serde_json::{json, Value};
|
||||
use xdg::BaseDirectories;
|
||||
|
||||
use proxmox_http::uri::json_object_to_query;
|
||||
use proxmox_router::cli::{complete_file_name, shellword_split};
|
||||
use proxmox_schema::*;
|
||||
use proxmox_sys::fs::file_get_json;
|
||||
|
||||
use pbs_api_types::{Authid, BackupNamespace, RateLimitConfig, UserWithTokens, BACKUP_REPO_URL};
|
||||
use pbs_tools::json::json_object_to_query;
|
||||
|
||||
use crate::{BackupRepository, HttpClient, HttpClientOptions};
|
||||
|
||||
|
@ -13,6 +13,7 @@ use serde_json::Value;
|
||||
use tokio::io::{AsyncRead, AsyncWrite, AsyncWriteExt, ReadBuf};
|
||||
use tokio::net::UnixStream;
|
||||
|
||||
use proxmox_http::uri::json_object_to_query;
|
||||
use proxmox_router::HttpError;
|
||||
|
||||
pub const DEFAULT_VSOCK_PORT: u16 = 807;
|
||||
@ -240,7 +241,7 @@ impl VsockClient {
|
||||
let request = builder.body(Body::from(data.to_string()))?;
|
||||
return Ok(request);
|
||||
} else {
|
||||
let query = pbs_tools::json::json_object_to_query(data)?;
|
||||
let query = json_object_to_query(data)?;
|
||||
let url: Uri =
|
||||
format!("vsock://{}:{}/{}?{}", self.cid, self.port, path, query).parse()?;
|
||||
let builder = make_builder("application/x-www-form-urlencoded", &url);
|
||||
|
@ -1,47 +1,5 @@
|
||||
use anyhow::{bail, format_err, Error};
|
||||
use anyhow::{bail, Error};
|
||||
use serde_json::Value;
|
||||
pub fn json_object_to_query(data: Value) -> Result<String, Error> {
|
||||
let mut query = url::form_urlencoded::Serializer::new(String::new());
|
||||
|
||||
let object = data.as_object().ok_or_else(|| {
|
||||
format_err!("json_object_to_query: got wrong data type (expected object).")
|
||||
})?;
|
||||
|
||||
for (key, value) in object {
|
||||
match value {
|
||||
Value::Bool(b) => {
|
||||
query.append_pair(key, &b.to_string());
|
||||
}
|
||||
Value::Number(n) => {
|
||||
query.append_pair(key, &n.to_string());
|
||||
}
|
||||
Value::String(s) => {
|
||||
query.append_pair(key, s);
|
||||
}
|
||||
Value::Array(arr) => {
|
||||
for element in arr {
|
||||
match element {
|
||||
Value::Bool(b) => {
|
||||
query.append_pair(key, &b.to_string());
|
||||
}
|
||||
Value::Number(n) => {
|
||||
query.append_pair(key, &n.to_string());
|
||||
}
|
||||
Value::String(s) => {
|
||||
query.append_pair(key, s);
|
||||
}
|
||||
_ => bail!(
|
||||
"json_object_to_query: unable to handle complex array data types."
|
||||
),
|
||||
}
|
||||
}
|
||||
}
|
||||
_ => bail!("json_object_to_query: unable to handle complex data types."),
|
||||
}
|
||||
}
|
||||
|
||||
Ok(query.finish())
|
||||
}
|
||||
|
||||
pub fn required_string_param<'a>(param: &'a Value, name: &str) -> Result<&'a str, Error> {
|
||||
match param[name].as_str() {
|
||||
|
@ -7,10 +7,9 @@ use serde_json::json;
|
||||
use proxmox_schema::api;
|
||||
|
||||
use proxmox_http::client::SimpleHttp;
|
||||
use proxmox_http::uri::json_object_to_query;
|
||||
use proxmox_sys::fs::{replace_file, CreateOptions};
|
||||
|
||||
use pbs_tools::json::json_object_to_query;
|
||||
|
||||
use crate::config::node;
|
||||
use crate::tools::{self, pbs_simple_http};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user