diff options
Diffstat (limited to 'angelsharkd/src/routes/extensions')
-rw-r--r-- | angelsharkd/src/routes/extensions/simple_deprov.rs | 35 |
1 files changed, 33 insertions, 2 deletions
diff --git a/angelsharkd/src/routes/extensions/simple_deprov.rs b/angelsharkd/src/routes/extensions/simple_deprov.rs index eeb27a0..de45d9b 100644 --- a/angelsharkd/src/routes/extensions/simple_deprov.rs +++ b/angelsharkd/src/routes/extensions/simple_deprov.rs @@ -1,12 +1,43 @@ +use std::{convert::Infallible, fmt::Display}; + +use libangelshark::{AcmRunner, Message}; +use serde::Deserialize; use warp::{ body::{content_length_limit, json}, post, Filter, Rejection, Reply, }; -pub fn filter() -> impl Filter<Extract = impl Reply, Error = Rejection> + Clone { +pub fn filter(runner: AcmRunner) -> impl Filter<Extract = impl Reply, Error = Rejection> + Clone { warp::path("deprov") .and(post()) .and(content_length_limit(1024 * 16)) .and(json()) - .map(|_: String| -> &str { todo!() }) // TODO: + .and_then(move |entries: Entries| remove_entries(entries, runner.to_owned())) +} + +async fn remove_entries(entries: Entries, runner: AcmRunner) -> Result<impl Reply, Infallible> { + Ok("") +} + +type Entries = Vec<Entry>; + +#[derive(Debug, Deserialize)] +enum Entry { + #[serde(rename(deserialize = "station-user"))] + StationUser { acm: String, ext: String }, + #[serde(rename(deserialize = "agent-loginid"))] + AgentLoginId { acm: String, ext: String }, +} + +impl From<Entry> for Vec<Message> { + fn from(entry: Entry) -> Self { + match entry { + Entry::StationUser { acm, ext } => { + vec![Message::new(&format!("clear amw all {}", ext))] + } + Entry::AgentLoginId { acm, ext } => { + todo!() + } + } + } } |