feat: implement get_monitor_status helper method

This commit is contained in:
lucasheld 2023-05-02 20:36:49 +02:00
parent b87eed2597
commit a9f2b6d894

View file

@ -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")