Gettign monitors from status page API

This commit is contained in:
2026-04-28 00:44:14 -07:00
parent 61ae0359a8
commit dc50007725

View File

@@ -30,14 +30,16 @@ pub struct KumaStatusPage {
impl KumaStatusPage { impl KumaStatusPage {
fn get_monitors(json: &Value) -> Vec<KumaMonitor> { fn get_monitors(json: &Value) -> Vec<KumaMonitor> {
let monitor_list = &json["publicGroupList"]["monitorList"]; let mut monitors = vec![];
return match monitor_list.as_array() { for group in json["publicGroupList"].as_array().unwrap_or(&vec![]) {
Some(list) => list.iter().map(|mon| KumaMonitor { for monitor in group["monitorList"].as_array().unwrap_or(&vec![]) {
id: mon["id"].as_i64().unwrap_or(0), monitors.push(KumaMonitor {
name: mon["name"].to_string() id: monitor["id"].as_i64().unwrap_or(0),
}).collect(), name: monitor["name"].to_string()
None => vec![] });
}; }
}
return monitors;
} }
pub async fn get(slug: &str) -> Result<Self, Error> { pub async fn get(slug: &str) -> Result<Self, Error> {