feat: drop support for Uptime Kuma versions < 1.21.3

BREAKING CHANGE: Uptime Kuma versions < 1.21.3 are not supported in uptime-kuma-api 1.x.x
This commit is contained in:
lucasheld 2023-05-20 12:43:57 +02:00
parent 77630e96b7
commit f0c5f2ba9d
10 changed files with 57 additions and 177 deletions

View file

@ -1,17 +1,10 @@
import unittest
from packaging.version import parse as parse_version
from uptime_kuma_api import DockerType, UptimeKumaException
from uptime_kuma_api import UptimeKumaException
from uptime_kuma_test_case import UptimeKumaTestCase
class TestApiKey(UptimeKumaTestCase):
def setUp(self):
super(TestApiKey, self).setUp()
if parse_version(self.api.version) < parse_version("1.21"):
super(TestApiKey, self).tearDown()
self.skipTest("Unsupported in this Uptime Kuma version")
def test_api_key(self):
# get empty list to make sure that future accesses will also work
self.api.get_api_keys()

View file

@ -1,17 +1,10 @@
import unittest
from packaging.version import parse as parse_version
from uptime_kuma_api import DockerType, UptimeKumaException
from uptime_kuma_test_case import UptimeKumaTestCase
class TestDockerHost(UptimeKumaTestCase):
def setUp(self):
super(TestDockerHost, self).setUp()
if parse_version(self.api.version) < parse_version("1.18"):
super(TestDockerHost, self).tearDown()
self.skipTest("Unsupported in this Uptime Kuma version")
def test_docker_host(self):
# get empty list to make sure that future accesses will also work
self.api.get_docker_hosts()

View file

@ -1,17 +1,9 @@
import unittest
from packaging.version import parse as parse_version
from uptime_kuma_test_case import UptimeKumaTestCase
class TestGameList(UptimeKumaTestCase):
def setUp(self):
super(TestGameList, self).setUp()
if parse_version(self.api.version) < parse_version("1.20"):
super(TestGameList, self).tearDown()
self.skipTest("Unsupported in this Uptime Kuma version")
def test_game_list(self):
game_list = self.api.get_game_list()
self.assertTrue("keys" in game_list[0])

View file

@ -1,18 +1,10 @@
import unittest
from packaging.version import parse as parse_version
from uptime_kuma_api import UptimeKumaException, MaintenanceStrategy
from uptime_kuma_test_case import UptimeKumaTestCase
class TestMaintenance(UptimeKumaTestCase):
def setUp(self):
super(TestMaintenance, self).setUp()
if parse_version(self.api.version) < parse_version("1.19"):
super(TestMaintenance, self).tearDown()
self.skipTest("Unsupported in this Uptime Kuma version")
def test_maintenance(self):
expected_maintenance = {
"title": "maintenance 1",
@ -25,13 +17,9 @@ class TestMaintenance(UptimeKumaTestCase):
"2022-12-29 22:36:00"
],
"weekdays": [],
"daysOfMonth": []
}
if parse_version(self.api.version) >= parse_version("1.21.2"):
expected_maintenance.update({
"daysOfMonth": [],
"timezoneOption": "Europe/Berlin"
})
}
# add maintenance
r = self.api.add_maintenance(**expected_maintenance)
@ -225,9 +213,6 @@ class TestMaintenance(UptimeKumaTestCase):
self.do_test_maintenance_strategy(expected_maintenance)
def test_maintenance_strategy_cron(self):
if parse_version(self.api.version) < parse_version("1.21.2"):
self.skipTest("Unsupported in this Uptime Kuma version")
expected_maintenance = {
"title": "test",
"description": "test",

View file

@ -1,5 +1,4 @@
import unittest
from packaging.version import parse as parse_version
from uptime_kuma_api import UptimeKumaException, MonitorType, AuthMethod
from uptime_kuma_test_case import UptimeKumaTestCase
@ -21,12 +20,9 @@ class TestMonitor(UptimeKumaTestCase):
"maxretries": 0,
"notificationIDList": [notification_id_1, notification_id_2],
"upsideDown": False,
"url": "http://127.0.0.1"
}
if parse_version(self.api.version) >= parse_version("1.18"):
expected_monitor.update({
"url": "http://127.0.0.1",
"resendInterval": 0
})
}
# add monitor
r = self.api.add_monitor(**expected_monitor)
@ -132,7 +128,6 @@ class TestMonitor(UptimeKumaTestCase):
}
self.do_test_monitor_type(expected_monitor)
if parse_version(self.api.version) >= parse_version("1.21"):
expected_monitor = {
"type": MonitorType.HTTP,
"name": "monitor 1",
@ -157,12 +152,9 @@ class TestMonitor(UptimeKumaTestCase):
expected_monitor = {
"type": MonitorType.PING,
"name": "monitor 1",
"hostname": "127.0.0.1"
}
if parse_version(self.api.version) >= parse_version("1.20"):
expected_monitor.update({
"hostname": "127.0.0.1",
"packetSize": 56
})
}
self.do_test_monitor_type(expected_monitor)
def test_monitor_type_keyword(self):
@ -175,9 +167,6 @@ class TestMonitor(UptimeKumaTestCase):
self.do_test_monitor_type(expected_monitor)
def test_monitor_type_grpc_keyword(self):
if parse_version(self.api.version) < parse_version("1.19"):
self.skipTest("Unsupported in this Uptime Kuma version")
expected_monitor = {
"type": MonitorType.GRPC_KEYWORD,
"name": "monitor 1",
@ -200,9 +189,6 @@ class TestMonitor(UptimeKumaTestCase):
self.do_test_monitor_type(expected_monitor)
def test_monitor_type_docker(self):
if parse_version(self.api.version) < parse_version("1.18"):
self.skipTest("Unsupported in this Uptime Kuma version")
docker_host_id = self.add_docker_host()
expected_monitor = {
"type": MonitorType.DOCKER,
@ -232,9 +218,6 @@ class TestMonitor(UptimeKumaTestCase):
self.do_test_monitor_type(expected_monitor)
def test_monitor_type_gamedig(self):
if parse_version(self.api.version) < parse_version("1.20"):
self.skipTest("Unsupported in this Uptime Kuma version")
game_list = self.api.get_game_list()
game = game_list[0]["keys"][0]
expected_monitor = {
@ -270,9 +253,6 @@ class TestMonitor(UptimeKumaTestCase):
self.do_test_monitor_type(expected_monitor)
def test_monitor_type_postgres(self):
if parse_version(self.api.version) < parse_version("1.18"):
self.skipTest("Unsupported in this Uptime Kuma version")
expected_monitor = {
"type": MonitorType.POSTGRES,
"name": "monitor 1",
@ -282,9 +262,6 @@ class TestMonitor(UptimeKumaTestCase):
self.do_test_monitor_type(expected_monitor)
def test_monitor_type_mysql(self):
if parse_version(self.api.version) < parse_version("1.19"):
self.skipTest("Unsupported in this Uptime Kuma version")
expected_monitor = {
"type": MonitorType.MYSQL,
"name": "monitor 1",
@ -294,9 +271,6 @@ class TestMonitor(UptimeKumaTestCase):
self.do_test_monitor_type(expected_monitor)
def test_monitor_type_mongodb(self):
if parse_version(self.api.version) < parse_version("1.20"):
self.skipTest("Unsupported in this Uptime Kuma version")
expected_monitor = {
"type": MonitorType.MONGODB,
"name": "monitor 1",
@ -305,9 +279,6 @@ class TestMonitor(UptimeKumaTestCase):
self.do_test_monitor_type(expected_monitor)
def test_monitor_type_radius(self):
if parse_version(self.api.version) < parse_version("1.18"):
self.skipTest("Unsupported in this Uptime Kuma version")
expected_monitor = {
"type": MonitorType.RADIUS,
"name": "monitor 1",
@ -320,9 +291,6 @@ class TestMonitor(UptimeKumaTestCase):
self.do_test_monitor_type(expected_monitor)
def test_monitor_type_redis(self):
if parse_version(self.api.version) < parse_version("1.20"):
self.skipTest("Unsupported in this Uptime Kuma version")
expected_monitor = {
"type": MonitorType.REDIS,
"name": "monitor 1",

View file

@ -1,6 +1,5 @@
import json
import unittest
from packaging.version import parse as parse_version
from uptime_kuma_test_case import UptimeKumaTestCase
@ -16,19 +15,11 @@ class TestSettings(UptimeKumaTestCase):
"primaryBaseURL": "",
"steamAPIKey": "",
"tlsExpiryNotifyDays": [7, 14, 21],
"disableAuth": False
}
if parse_version(self.api.version) >= parse_version("1.18"):
expected_settings.update({
"trustProxy": False
})
if parse_version(self.api.version) >= parse_version("1.19"):
expected_settings.update({
"disableAuth": False,
"trustProxy": False,
"serverTimezone": "Europe/Berlin",
"dnsCache": True,
})
"dnsCache": True
}
# set settings
r = self.api.set_settings(self.password, **expected_settings)

View file

@ -1,7 +1,5 @@
import unittest
from packaging.version import parse as parse_version
from uptime_kuma_api import UptimeKumaException, IncidentStyle
from uptime_kuma_test_case import UptimeKumaTestCase
@ -36,12 +34,9 @@ class TestStatusPage(UptimeKumaTestCase):
}
]
}
]
}
if parse_version(self.api.version) >= parse_version("1.20"):
expected_status_page.update({
],
"googleAnalyticsId": ""
})
}
# add status page
r = self.api.add_status_page(slug, expected_status_page["title"])

View file

@ -1,7 +1,5 @@
import unittest
from packaging.version import parse as parse_version
from uptime_kuma_api import UptimeKumaException
from uptime_kuma_test_case import UptimeKumaTestCase
@ -28,7 +26,6 @@ class TestTag(UptimeKumaTestCase):
self.assertIsNotNone(tag)
self.compare(tag, expected_tag)
if parse_version(self.api.version) >= parse_version("1.20"):
# edit tag
expected_tag["name"] = "tag 1 new"
expected_tag["color"] = "#000000"

View file

@ -1,8 +1,7 @@
import unittest
import warnings
from packaging.version import parse as parse_version
from uptime_kuma_api import UptimeKumaApi, MonitorType, DockerType, UptimeKumaException
from uptime_kuma_api import UptimeKumaApi, MonitorType, DockerType
token = None
@ -74,19 +73,16 @@ class UptimeKumaTestCase(unittest.TestCase):
for status_page in status_pages:
self.api.delete_status_page(status_page["slug"])
if parse_version(self.api.version) >= parse_version("1.18"):
# delete docker hosts
docker_hosts = self.api.get_docker_hosts()
for docker_host in docker_hosts:
self.api.delete_docker_host(docker_host["id"])
if parse_version(self.api.version) >= parse_version("1.19"):
# delete maintenances
maintenances = self.api.get_maintenances()
for maintenance in maintenances:
self.api.delete_maintenance(maintenance["id"])
if parse_version(self.api.version) >= parse_version("1.21"):
# delete api keys
api_keys = self.api.get_api_keys()
for api_key in api_keys:

View file

@ -11,7 +11,6 @@ from typing import Any
import requests
import socketio
from packaging.version import parse as parse_version
from . import (AuthMethod,
DockerType,
@ -718,10 +717,6 @@ class UptimeKumaApi(object):
# GAMEDIG
game: str = None
) -> dict:
# https://github.com/louislam/uptime-kuma/compare/1.21.1...1.21.2#diff-f672603317047f3e6f27b0d7a44f6f244b7dbb5d0d0a85f1059a6b0bc2cb9aa0L910
if parse_version(self.version) < parse_version("1.21.2"):
maxretries = 0
data = {
"type": type,
"name": name,
@ -730,18 +725,10 @@ class UptimeKumaApi(object):
"maxretries": maxretries,
"notificationIDList": notificationIDList,
"upsideDown": upsideDown,
}
if parse_version(self.version) >= parse_version("1.18"):
data.update({
"resendInterval": resendInterval
})
if parse_version(self.version) >= parse_version("1.21"):
data.update({
"resendInterval": resendInterval,
"description": description,
"httpBodyEncoding": httpBodyEncoding
})
}
if type in [MonitorType.KEYWORD, MonitorType.GRPC_KEYWORD]:
data.update({
@ -799,7 +786,6 @@ class UptimeKumaApi(object):
})
# PING
if parse_version(self.version) >= parse_version("1.20"):
data.update({
"packetSize": packetSize,
})
@ -906,14 +892,11 @@ class UptimeKumaApi(object):
"strategy": strategy,
"weekdays": weekdays,
"daysOfMonth": daysOfMonth,
"timeRange": timeRange
}
if parse_version(self.version) >= parse_version("1.21.2"):
data.update({
"timeRange": timeRange,
"cron": cron,
"durationMinutes": durationMinutes,
"timezoneOption": timezoneOption,
})
"timezoneOption": timezoneOption
}
return data
# monitor
@ -1211,11 +1194,6 @@ class UptimeKumaApi(object):
]
"""
r = self._call('getGameList')
# Workaround, gamelist is not available on first call.
# Fixed in https://github.com/louislam/uptime-kuma/commit/7b8ed01f272fc4c6b69ff6299185e936a5e63735
# Exists in 1.20.0 - 1.21.0
if not r:
r = self._call('getGameList')
return r.get("gameList")
@append_docstring(monitor_docstring("add"))
@ -1769,11 +1747,8 @@ class UptimeKumaApi(object):
**config,
"incident": r2["incident"],
"publicGroupList": r2["publicGroupList"],
}
if parse_version(self.version) >= parse_version("1.19"):
data.update({
"maintenanceList": r2["maintenanceList"]
})
}
return data
def add_status_page(self, slug: str, title: str) -> dict:
@ -1878,7 +1853,6 @@ class UptimeKumaApi(object):
"""
status_page = self.get_status_page(slug)
status_page.pop("incident")
if parse_version(self.version) >= parse_version("1.19"):
status_page.pop("maintenanceList")
status_page.update(kwargs)
data = _build_status_page_data(**status_page)
@ -2237,7 +2211,6 @@ class UptimeKumaApi(object):
}
}
"""
# TODO: endless call if only ping monitors used
return self._get_event_data(Event.CERT_INFO)
# uptime
@ -2576,12 +2549,9 @@ class UptimeKumaApi(object):
"steamAPIKey": steamAPIKey,
"dnsCache": dnsCache,
"tlsExpiryNotifyDays": tlsExpiryNotifyDays,
"disableAuth": disableAuth
}
if parse_version(self.version) >= parse_version("1.18"):
data.update({
"disableAuth": disableAuth,
"trustProxy": trustProxy
})
}
return self._call('setSettings', (data, password))
def change_password(self, old_password: str, new_password: str) -> dict: