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