From a2479cfa1a7060df07b7dada061be0e1406e0524 Mon Sep 17 00:00:00 2001 From: Wolfgang Bumiller Date: Thu, 21 Nov 2019 14:36:28 +0100 Subject: [PATCH] api/compat: drop more compat imports from api_schema.rs Signed-off-by: Wolfgang Bumiller --- src/api2/access.rs | 1 - src/api2/backup/environment.rs | 2 +- src/api2/backup/upload_chunk.rs | 4 ++-- src/api2/config/datastore.rs | 14 +++++++------- src/api2/node/dns.rs | 19 ++++++++----------- src/api2/node/network.rs | 7 +++---- src/api2/node/syslog.rs | 10 +++++----- src/api2/reader/environment.rs | 3 ++- src/api2/subscription.rs | 8 ++++---- src/api2/version.rs | 6 +++--- src/api_schema.rs | 5 ----- src/api_schema/config.rs | 4 ++-- src/api_schema/format.rs | 7 +++---- src/bin/proxmox-backup-api.rs | 2 +- src/bin/proxmox-backup-proxy.rs | 21 ++++++++++----------- src/cli/command.rs | 6 +++--- src/cli/environment.rs | 4 ++-- src/server/environment.rs | 4 ++-- src/server/formatter.rs | 4 ++-- src/server/h2service.rs | 3 +-- src/server/rest.rs | 10 ++++++---- 21 files changed, 67 insertions(+), 77 deletions(-) diff --git a/src/api2/access.rs b/src/api2/access.rs index 3d81f2a8..2d77a946 100644 --- a/src/api2/access.rs +++ b/src/api2/access.rs @@ -1,6 +1,5 @@ use failure::*; -use hyper::StatusCode; use serde_json::{json, Value}; use proxmox::{sortable, identity}; diff --git a/src/api2/backup/environment.rs b/src/api2/backup/environment.rs index c0feda5a..278ca251 100644 --- a/src/api2/backup/environment.rs +++ b/src/api2/backup/environment.rs @@ -8,8 +8,8 @@ use proxmox::tools::{ digest_to_hex, fs::file_set_contents, }; +use proxmox::api::{RpcEnvironment, RpcEnvironmentType}; -use crate::api_schema::router::{RpcEnvironment, RpcEnvironmentType}; use crate::server::WorkerTask; use crate::backup::*; use crate::server::formatter::*; diff --git a/src/api2/backup/upload_chunk.rs b/src/api2/backup/upload_chunk.rs index 80125d05..620dff5e 100644 --- a/src/api2/backup/upload_chunk.rs +++ b/src/api2/backup/upload_chunk.rs @@ -9,10 +9,10 @@ use hyper::http::request::Parts; use serde_json::{json, Value}; use proxmox::{sortable, identity}; +use proxmox::api::{ApiFuture, ApiHandler, ApiMethod, RpcEnvironment}; +use proxmox::api::schema::*; use crate::api2::types::*; -use crate::api_schema::*; -use crate::api_schema::router::*; use crate::backup::*; use crate::tools; diff --git a/src/api2/config/datastore.rs b/src/api2/config/datastore.rs index e5de4df2..e58212e7 100644 --- a/src/api2/config/datastore.rs +++ b/src/api2/config/datastore.rs @@ -1,12 +1,12 @@ -use failure::*; -//use std::collections::HashMap; - -use crate::api_schema::*; -use crate::api_schema::router::*; -use crate::backup::*; -use serde_json::{json, Value}; use std::path::PathBuf; +use failure::*; +use serde_json::{json, Value}; + +use proxmox::api::{ApiHandler, ApiMethod, Router, RpcEnvironment}; +use proxmox::api::schema::*; + +use crate::backup::*; use crate::config::datastore; pub const GET: ApiMethod = ApiMethod::new( diff --git a/src/api2/node/dns.rs b/src/api2/node/dns.rs index e6aa8aab..c4f7ac06 100644 --- a/src/api2/node/dns.rs +++ b/src/api2/node/dns.rs @@ -1,22 +1,19 @@ +use std::sync::{Arc, Mutex}; + use failure::*; +use lazy_static::lazy_static; +use openssl::sha; +use regex::Regex; +use serde_json::{json, Value}; use proxmox::{sortable, identity}; +use proxmox::api::{ApiHandler, ApiMethod, Router, RpcEnvironment}; +use proxmox::api::schema::*; use proxmox::tools::fs::{file_get_contents, file_set_contents}; use proxmox::tools::*; // required to use IPRE!() macro ??? -use crate::api2::*; -use crate::api_schema::*; -//use crate::api_schema::router::*; use crate::api2::types::*; -use lazy_static::lazy_static; - -use std::sync::{Arc, Mutex}; -use openssl::sha; -use regex::Regex; - -use serde_json::{json, Value}; - static RESOLV_CONF_FN: &str = "/etc/resolv.conf"; fn read_etc_resolv_conf() -> Result { diff --git a/src/api2/node/network.rs b/src/api2/node/network.rs index ee3b7049..0cef10d2 100644 --- a/src/api2/node/network.rs +++ b/src/api2/node/network.rs @@ -1,10 +1,9 @@ use failure::*; - -//use crate::tools; -use crate::api_schema::*; -use crate::api_schema::router::*; use serde_json::{json, Value}; +use proxmox::api::{ApiHandler, ApiMethod, Router, RpcEnvironment}; +use proxmox::api::schema::ObjectSchema; + use crate::api2::types::*; fn get_network_config( diff --git a/src/api2/node/syslog.rs b/src/api2/node/syslog.rs index 62856480..3a3b9fbd 100644 --- a/src/api2/node/syslog.rs +++ b/src/api2/node/syslog.rs @@ -1,14 +1,14 @@ +use std::process::{Command, Stdio}; + use failure::*; +use serde_json::{json, Value}; use proxmox::{sortable, identity}; +use proxmox::api::{ApiHandler, ApiMethod, Router, RpcEnvironment}; +use proxmox::api::schema::*; -use crate::api_schema::*; -use crate::api_schema::router::*; use crate::api2::types::*; -use serde_json::{json, Value}; -use std::process::{Command, Stdio}; - fn dump_journal( start: Option, limit: Option, diff --git a/src/api2/reader/environment.rs b/src/api2/reader/environment.rs index 082973d3..b56d9e6e 100644 --- a/src/api2/reader/environment.rs +++ b/src/api2/reader/environment.rs @@ -4,7 +4,8 @@ use std::collections::HashMap; use serde_json::Value; -use crate::api_schema::router::{RpcEnvironment, RpcEnvironmentType}; +use proxmox::api::{RpcEnvironment, RpcEnvironmentType}; + use crate::server::WorkerTask; use crate::backup::*; use crate::server::formatter::*; diff --git a/src/api2/subscription.rs b/src/api2/subscription.rs index 35965771..86b0b040 100644 --- a/src/api2/subscription.rs +++ b/src/api2/subscription.rs @@ -1,10 +1,10 @@ use failure::*; - -use crate::tools; -use crate::api_schema::*; -use crate::api_schema::router::*; use serde_json::{json, Value}; +use proxmox::api::{ApiHandler, ApiMethod, Router, RpcEnvironment}; +use proxmox::api::schema::ObjectSchema; + +use crate::tools; fn get_subscription( _param: Value, diff --git a/src/api2/version.rs b/src/api2/version.rs index 597dc4b5..2e0d20e7 100644 --- a/src/api2/version.rs +++ b/src/api2/version.rs @@ -1,9 +1,9 @@ use failure::*; - -use crate::api_schema::*; -use crate::api_schema::router::*; use serde_json::{json, Value}; +use proxmox::api::{ApiHandler, ApiMethod, Router, RpcEnvironment}; +use proxmox::api::schema::ObjectSchema; + pub const PROXMOX_PKG_VERSION: &str = concat!( env!("CARGO_PKG_VERSION_MAJOR"), diff --git a/src/api_schema.rs b/src/api_schema.rs index 571fa29c..9d6d7606 100644 --- a/src/api_schema.rs +++ b/src/api_schema.rs @@ -21,8 +21,3 @@ pub mod format; pub use proxmox::api::schema::*; pub use proxmox::api::*; - -pub mod router { - pub use super::{ApiHandler, ApiMethod, HttpError, RpcEnvironment, RpcEnvironmentType}; - pub use proxmox::api::router::*; -} diff --git a/src/api_schema/config.rs b/src/api_schema/config.rs index 74f95e8b..d9aa076c 100644 --- a/src/api_schema/config.rs +++ b/src/api_schema/config.rs @@ -1,10 +1,10 @@ -use crate::api_schema::router::*; - use std::collections::HashMap; use std::path::{PathBuf}; use hyper::Method; +use proxmox::api::{ApiMethod, Router, RpcEnvironmentType}; + pub struct ApiConfig { basedir: PathBuf, router: &'static Router, diff --git a/src/api_schema/format.rs b/src/api_schema/format.rs index cf3c23bb..01011e98 100644 --- a/src/api_schema/format.rs +++ b/src/api_schema/format.rs @@ -1,11 +1,10 @@ use failure::*; use std::io::Write; -//use super::*; -use super::router::*; -use super::schema::*; -//use super::api_handler::*; +use proxmox::api::{ApiHandler, ApiMethod}; +use proxmox::api::router::{Router, SubRoute}; +use proxmox::api::schema::*; #[derive(Copy, Clone)] pub enum ParameterDisplayStyle { diff --git a/src/bin/proxmox-backup-api.rs b/src/bin/proxmox-backup-api.rs index b9a9f1fc..bcaa2122 100644 --- a/src/bin/proxmox-backup-api.rs +++ b/src/bin/proxmox-backup-api.rs @@ -2,9 +2,9 @@ use failure::*; use futures::*; use proxmox::tools::try_block; +use proxmox::api::RpcEnvironmentType; //use proxmox_backup::tools; -use proxmox_backup::api_schema::router::*; use proxmox_backup::api_schema::config::*; use proxmox_backup::server::rest::*; use proxmox_backup::server; diff --git a/src/bin/proxmox-backup-proxy.rs b/src/bin/proxmox-backup-proxy.rs index b7f5b3f1..f7d346bc 100644 --- a/src/bin/proxmox-backup-proxy.rs +++ b/src/bin/proxmox-backup-proxy.rs @@ -1,22 +1,21 @@ +use std::sync::Arc; + +use failure::*; +use futures::*; +use hyper; +use openssl::ssl::{SslMethod, SslAcceptor, SslFiletype}; + +use proxmox::tools::try_block; +use proxmox::api::RpcEnvironmentType; + use proxmox_backup::configdir; use proxmox_backup::buildcfg; use proxmox_backup::server; use proxmox_backup::tools::daemon; -use proxmox_backup::api_schema::router::*; use proxmox_backup::api_schema::config::*; use proxmox_backup::server::rest::*; use proxmox_backup::auth_helpers::*; -use failure::*; -use proxmox::tools::try_block; - -use futures::*; - -use openssl::ssl::{SslMethod, SslAcceptor, SslFiletype}; -use std::sync::Arc; - -use hyper; - #[tokio::main] async fn main() { if let Err(err) = run().await { diff --git a/src/cli/command.rs b/src/cli/command.rs index f877885d..69750d24 100644 --- a/src/cli/command.rs +++ b/src/cli/command.rs @@ -3,10 +3,10 @@ use serde_json::Value; use std::collections::{HashMap, HashSet}; -use crate::api_schema::*; -use crate::api_schema::router::*; +use proxmox::api::schema::*; +use proxmox::api::{ApiHandler, ApiMethod}; + use crate::api_schema::format::*; -//use crate::api_schema::config::*; use super::environment::CliEnvironment; use super::getopts; diff --git a/src/cli/environment.rs b/src/cli/environment.rs index 3b5b8725..ad40ca1a 100644 --- a/src/cli/environment.rs +++ b/src/cli/environment.rs @@ -1,8 +1,8 @@ -use crate::api_schema::router::*; - use std::collections::HashMap; use serde_json::Value; +use proxmox::api::{RpcEnvironment, RpcEnvironmentType}; + /// `RpcEnvironmet` implementation for command line tools pub struct CliEnvironment { result_attributes: HashMap, diff --git a/src/server/environment.rs b/src/server/environment.rs index b002b24f..9e026997 100644 --- a/src/server/environment.rs +++ b/src/server/environment.rs @@ -1,8 +1,8 @@ -use crate::api_schema::router::*; - use std::collections::HashMap; use serde_json::Value; +use proxmox::api::{RpcEnvironment, RpcEnvironmentType}; + /// Encapsulates information about the runtime environment pub struct RestEnvironment { env_type: RpcEnvironmentType, diff --git a/src/server/formatter.rs b/src/server/formatter.rs index ca2a6e73..2daf4dbf 100644 --- a/src/server/formatter.rs +++ b/src/server/formatter.rs @@ -1,11 +1,11 @@ use failure::*; use serde_json::{json, Value}; -use crate::api_schema::router::{HttpError, RpcEnvironment}; - use hyper::{Body, Response, StatusCode}; use hyper::header; +use proxmox::api::{HttpError, RpcEnvironment}; + /// Extension to set error message for server side logging pub struct ErrorMessageExtension(pub String); diff --git a/src/server/h2service.rs b/src/server/h2service.rs index a9abf4f3..c8a1f839 100644 --- a/src/server/h2service.rs +++ b/src/server/h2service.rs @@ -7,10 +7,9 @@ use std::task::{Context, Poll}; use futures::*; use hyper::{Body, Request, Response, StatusCode}; -use proxmox::api::{http_err, ApiFuture}; +use proxmox::api::{http_err, ApiFuture, ApiHandler, HttpError, Router, RpcEnvironment}; use crate::tools; -use crate::api_schema::router::*; use crate::server::formatter::*; use crate::server::WorkerTask; diff --git a/src/server/rest.rs b/src/server/rest.rs index f583afaa..55e010b6 100644 --- a/src/server/rest.rs +++ b/src/server/rest.rs @@ -16,13 +16,15 @@ use serde_json::{json, Value}; use tokio::fs::File; use url::form_urlencoded; +use proxmox::api::http_err; +use proxmox::api::{ApiFuture, ApiHandler, ApiMethod, HttpError}; +use proxmox::api::{RpcEnvironment, RpcEnvironmentType}; +use proxmox::api::schema::{parse_simple_value, verify_json_object, parse_parameter_strings}; + use super::environment::RestEnvironment; use super::formatter::*; -use crate::api_schema::rpc_environment::*; -use crate::api_schema::config::*; -use crate::api_schema::router::*; -use crate::api_schema::*; use crate::auth_helpers::*; +use crate::api_schema::config::ApiConfig; use crate::tools; extern "C" { fn tzset(); }