Skip to content
Snippets Groups Projects
Verified Commit 56728236 authored by Nik | Klampfradler's avatar Nik | Klampfradler
Browse files

[NSS] Allow JQ maps to be configured for endpoint subtypes and complete endpoints

parent 6d5f45f3
No related branches found
No related tags found
No related merge requests found
......@@ -151,8 +151,24 @@ fn get_data(conf: &Config, prefix: &str, endpoint: &str, param: String, token: &
.text()?)
}
fn get_jq_prog(conf: &Config, prefix: &str, endpoint: &str) -> Option<String> {
match get_optional(&conf, &full_key(vec![prefix, "maps", endpoint])) {
Some(v) => Some (v),
None => {
// Try falling back to more generic program
match endpoint.find('.') {
Some(i) => {
debug!("JQ mapping program for {} not found; trying more generic definition", endpoint);
get_jq_prog(conf, prefix, &endpoint[..i])
},
None => None
}
}
}
}
pub fn get_data_jq<T: for<'de> Deserialize<'de>>(conf: &Config, prefix: &str, endpoint: &str, param: String, token: &BasicTokenResponse, multi: bool) -> Result<T, Box<dyn error::Error>> {
let res: Option<String> = get_optional(&conf, &full_key(vec![prefix, "maps", endpoint]));
let res: Option<String> = get_jq_prog(&conf, prefix, endpoint);
let jq_code = match res {
Some(s) => {
debug!("Found jq mapping program for endpoint {}", endpoint);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment