mirror of
https://git.proxmox.com/git/proxmox
synced 2025-05-10 06:41:07 +00:00
api: move ApiMethod from router to top level
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
This commit is contained in:
parent
c0266a17cd
commit
c38d18484d
@ -1,5 +1,6 @@
|
|||||||
//! Proxmox API module. This provides utilities for HTTP and command line APIs.
|
//! Proxmox API module. This provides utilities for HTTP and command line APIs.
|
||||||
|
|
||||||
|
use std::fmt;
|
||||||
use std::future::Future;
|
use std::future::Future;
|
||||||
|
|
||||||
use failure::Error;
|
use failure::Error;
|
||||||
@ -16,7 +17,7 @@ pub mod schema;
|
|||||||
pub use rpc_environment::{RpcEnvironment, RpcEnvironmentType};
|
pub use rpc_environment::{RpcEnvironment, RpcEnvironmentType};
|
||||||
|
|
||||||
#[doc(inline)]
|
#[doc(inline)]
|
||||||
pub use router::ApiMethod;
|
pub use router::Router;
|
||||||
|
|
||||||
#[doc(inline)]
|
#[doc(inline)]
|
||||||
pub use error::HttpError;
|
pub use error::HttpError;
|
||||||
@ -46,3 +47,29 @@ pub enum ApiHandler {
|
|||||||
Sync(ApiHandlerFn),
|
Sync(ApiHandlerFn),
|
||||||
Async(ApiAsyncHandlerFn),
|
Async(ApiAsyncHandlerFn),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// This struct defines synchronous API call which returns the restulkt as json `Value`
|
||||||
|
pub struct ApiMethod {
|
||||||
|
/// The protected flag indicates that the provides function should be forwarded
|
||||||
|
/// to the deaemon running in priviledged mode.
|
||||||
|
pub protected: bool,
|
||||||
|
/// This flag indicates that the provided method may change the local timezone, so the server
|
||||||
|
/// should do a tzset afterwards
|
||||||
|
pub reload_timezone: bool,
|
||||||
|
/// Parameter type Schema
|
||||||
|
pub parameters: &'static schema::ObjectSchema,
|
||||||
|
/// Return type Schema
|
||||||
|
pub returns: &'static schema::Schema,
|
||||||
|
/// Handler function
|
||||||
|
pub handler: &'static ApiHandler,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl std::fmt::Debug for ApiMethod {
|
||||||
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
|
write!(f, "ApiMethod {{ ")?;
|
||||||
|
write!(f, " parameters: {:?}", self.parameters)?;
|
||||||
|
write!(f, " returns: {:?}", self.returns)?;
|
||||||
|
write!(f, " handler: {:p}", &self.handler)?;
|
||||||
|
write!(f, "}}")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -1,38 +1,11 @@
|
|||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use std::fmt;
|
|
||||||
|
|
||||||
use failure::Error;
|
use failure::Error;
|
||||||
use hyper::Method;
|
use hyper::Method;
|
||||||
use serde_json::Value;
|
use serde_json::Value;
|
||||||
|
|
||||||
use crate::schema::{ObjectSchema, Schema};
|
use crate::schema::{ObjectSchema, Schema};
|
||||||
use crate::{ApiHandler, RpcEnvironment};
|
use crate::{ApiHandler, ApiMethod, RpcEnvironment};
|
||||||
|
|
||||||
/// This struct defines synchronous API call which returns the restulkt as json `Value`
|
|
||||||
pub struct ApiMethod {
|
|
||||||
/// The protected flag indicates that the provides function should be forwarded
|
|
||||||
/// to the deaemon running in priviledged mode.
|
|
||||||
pub protected: bool,
|
|
||||||
/// This flag indicates that the provided method may change the local timezone, so the server
|
|
||||||
/// should do a tzset afterwards
|
|
||||||
pub reload_timezone: bool,
|
|
||||||
/// Parameter type Schema
|
|
||||||
pub parameters: &'static ObjectSchema,
|
|
||||||
/// Return type Schema
|
|
||||||
pub returns: &'static Schema,
|
|
||||||
/// Handler function
|
|
||||||
pub handler: &'static ApiHandler,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl std::fmt::Debug for ApiMethod {
|
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
|
||||||
write!(f, "ApiMethod {{ ")?;
|
|
||||||
write!(f, " parameters: {:?}", self.parameters)?;
|
|
||||||
write!(f, " returns: {:?}", self.returns)?;
|
|
||||||
write!(f, " handler: {:p}", &self.handler)?;
|
|
||||||
write!(f, "}}")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const NULL_SCHEMA: Schema = Schema::Null;
|
const NULL_SCHEMA: Schema = Schema::Null;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user