From a9f2b6d894503fdcbb402353fb5aa76ec5eeb0df Mon Sep 17 00:00:00 2001 From: lucasheld Date: Tue, 2 May 2023 20:36:49 +0200 Subject: [PATCH] feat: implement `get_monitor_status` helper method --- uptime_kuma_api/api.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/uptime_kuma_api/api.py b/uptime_kuma_api/api.py index 4355de4..e35d739 100644 --- a/uptime_kuma_api/api.py +++ b/uptime_kuma_api/api.py @@ -3560,3 +3560,13 @@ class UptimeKumaApi(object): """ with self.wait_for_event(Event.API_KEY_LIST): return self._call('deleteAPIKey', id_) + + # helper methods + + def get_monitor_status(self, monitor_id: int) -> MonitorStatus: + heartbeats = self.get_heartbeats() + for heartbeat in heartbeats: + if int(heartbeat["id"]) == monitor_id: + status = heartbeat["data"][-1]["status"] + return MonitorStatus(status) + raise UptimeKumaException("monitor does not exist")