I'm proposing to add functionality that allows users of the uptime-kuma-api API to delete all monitors at once. Currently, to perform this task, users need to delete each monitor individually, which can be quite time-consuming and error-prone in scenarios where there are a large number of monitors configured.
Motivation:
In test or development environments, it is common to need to restart the monitor configuration, removing all existing ones to start a new set of tests. The absence of a function that allows the mass deletion of monitors makes this process inefficient.
Proposed solution:
I added a function called delete_all_monitors in the api.py module, which iterates over all monitors returned by get_monitors() and deletes them individually. Additionally, I implemented a test for this new functionality in the tests/test_monitor.py module, ensuring that all monitors are deleted correctly.
Implementation Details:
Modified File: uptime_kuma_api/api.py
New Function: delete_all_monitors()
uptime_kuma_api/api.py
def delete_all_monitors(self, **kwargs) -> dict:
"""
Deletes all monitors.
:return: The server response.
:rtype: dict
:raises UptimeKumaException: If the server returns an error.
Example::
>>> api.delete_all_monitors()
{
'msg': 'Deleted Successfully.'
}
"""
data = self._build_monitor_data(**kwargs)
_convert_monitor_input(data)
_check_arguments_monitor(data)
for monitor in self.get_monitors():
self.delete_monitor(monitor["id"])
return self._call('deleteAllMonitors')
I believe this functionality will bring a huge improvement in terms of usability and efficiency to uptime-kuma-api. I am open to discussing this implementation and making adjustments as recommended by the community and project maintainers.
Feature Description:
I'm proposing to add functionality that allows users of the uptime-kuma-api API to delete all monitors at once. Currently, to perform this task, users need to delete each monitor individually, which can be quite time-consuming and error-prone in scenarios where there are a large number of monitors configured.
Motivation:
In test or development environments, it is common to need to restart the monitor configuration, removing all existing ones to start a new set of tests. The absence of a function that allows the mass deletion of monitors makes this process inefficient.
Proposed solution:
I added a function called delete_all_monitors in the api.py module, which iterates over all monitors returned by get_monitors() and deletes them individually. Additionally, I implemented a test for this new functionality in the tests/test_monitor.py module, ensuring that all monitors are deleted correctly.
Implementation Details:
Modified File: uptime_kuma_api/api.py New Function: delete_all_monitors()
uptime_kuma_api/api.py
tests/test_monitor.py
Final considerations:
I believe this functionality will bring a huge improvement in terms of usability and efficiency to uptime-kuma-api. I am open to discussing this implementation and making adjustments as recommended by the community and project maintainers.