diff options
author | Carpenter, Adam (CORP) <adam.carpenter@adp.com> | 2021-12-09 11:58:01 -0500 |
---|---|---|
committer | Carpenter, Adam (CORP) <adam.carpenter@adp.com> | 2021-12-09 11:58:01 -0500 |
commit | ab4a81cf5a794b9d84a854a4a5449a5ed622ebdd (patch) | |
tree | 909af0d16c682af33c1042d800fcec9a8b789582 | |
parent | 8cf1549a87c984337eb013a67e8e211cfe18cd24 (diff) | |
download | altruistic-angelshark-ab4a81cf5a794b9d84a854a4a5449a5ed622ebdd.tar.xz altruistic-angelshark-ab4a81cf5a794b9d84a854a4a5449a5ed622ebdd.zip |
feat: begin impl basic deprov filter
-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!() + } + } + } } |