move src/server/environment.rs to proxmox-rest-server crate
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
committed by
Thomas Lamprecht
parent
8bca935f08
commit
d4d49f7325
@ -1,53 +0,0 @@
|
||||
use serde_json::{json, Value};
|
||||
|
||||
use proxmox::api::{RpcEnvironment, RpcEnvironmentType};
|
||||
|
||||
/// Encapsulates information about the runtime environment
|
||||
pub struct RestEnvironment {
|
||||
env_type: RpcEnvironmentType,
|
||||
result_attributes: Value,
|
||||
auth_id: Option<String>,
|
||||
client_ip: Option<std::net::SocketAddr>,
|
||||
}
|
||||
|
||||
impl RestEnvironment {
|
||||
pub fn new(env_type: RpcEnvironmentType) -> Self {
|
||||
Self {
|
||||
result_attributes: json!({}),
|
||||
auth_id: None,
|
||||
client_ip: None,
|
||||
env_type,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl RpcEnvironment for RestEnvironment {
|
||||
|
||||
fn result_attrib_mut (&mut self) -> &mut Value {
|
||||
&mut self.result_attributes
|
||||
}
|
||||
|
||||
fn result_attrib(&self) -> &Value {
|
||||
&self.result_attributes
|
||||
}
|
||||
|
||||
fn env_type(&self) -> RpcEnvironmentType {
|
||||
self.env_type
|
||||
}
|
||||
|
||||
fn set_auth_id(&mut self, auth_id: Option<String>) {
|
||||
self.auth_id = auth_id;
|
||||
}
|
||||
|
||||
fn get_auth_id(&self) -> Option<String> {
|
||||
self.auth_id.clone()
|
||||
}
|
||||
|
||||
fn set_client_ip(&mut self, client_ip: Option<std::net::SocketAddr>) {
|
||||
self.client_ip = client_ip;
|
||||
}
|
||||
|
||||
fn get_client_ip(&self) -> Option<std::net::SocketAddr> {
|
||||
self.client_ip
|
||||
}
|
||||
}
|
@ -46,9 +46,6 @@ pub fn our_ctrl_sock() -> String {
|
||||
ctrl_sock_from_pid(*PID)
|
||||
}
|
||||
|
||||
mod environment;
|
||||
pub use environment::*;
|
||||
|
||||
mod upid;
|
||||
pub use upid::*;
|
||||
|
||||
|
@ -34,9 +34,8 @@ use proxmox::tools::fs::CreateOptions;
|
||||
use pbs_tools::compression::{DeflateEncoder, Level};
|
||||
use pbs_tools::stream::AsyncReaderStream;
|
||||
use pbs_api_types::{Authid, Userid};
|
||||
use proxmox_rest_server::{ApiConfig, FileLogger, FileLogOptions, AuthError};
|
||||
use proxmox_rest_server::{ApiConfig, FileLogger, FileLogOptions, AuthError, RestEnvironment};
|
||||
|
||||
use super::environment::RestEnvironment;
|
||||
use super::formatter::*;
|
||||
|
||||
use crate::auth_helpers::*;
|
||||
|
Reference in New Issue
Block a user