From ab4a81cf5a794b9d84a854a4a5449a5ed622ebdd Mon Sep 17 00:00:00 2001 From: "Carpenter, Adam (CORP)" Date: Thu, 9 Dec 2021 11:58:01 -0500 Subject: feat: begin impl basic deprov filter --- angelsharkd/src/routes/extensions/simple_deprov.rs | 35 ++++++++++++++++++++-- 1 file 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 + Clone { +pub fn filter(runner: AcmRunner) -> impl Filter + 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 { + Ok("") +} + +type Entries = Vec; + +#[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 for Vec { + fn from(entry: Entry) -> Self { + match entry { + Entry::StationUser { acm, ext } => { + vec![Message::new(&format!("clear amw all {}", ext))] + } + Entry::AgentLoginId { acm, ext } => { + todo!() + } + } + } } -- cgit v1.2.3