From 3e56459fb244e922bbf385a87421856a21daa89a Mon Sep 17 00:00:00 2001 From: lucasheld Date: Tue, 17 Jan 2023 21:01:55 +0100 Subject: [PATCH] feat: add support for uptime kuma 1.19.5 --- README.md | 2 +- run_tests.sh | 2 +- scripts/build_notification_docstring.py | 2 +- uptime_kuma_api/api.py | 5 ++-- uptime_kuma_api/docstrings.py | 35 +++++++++++++++++++++-- uptime_kuma_api/notification_providers.py | 9 ++++++ 6 files changed, 47 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index c21ba14..071b204 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ This package was developed to configure Uptime Kuma with Ansible. The Ansible co Python version 3.6+ is required. -Supported Uptime Kuma versions: 1.17.0 - 1.19.4 +Supported Uptime Kuma versions: 1.17.0 - 1.19.5 Installation --- diff --git a/run_tests.sh b/run_tests.sh index e8204af..0492b74 100755 --- a/run_tests.sh +++ b/run_tests.sh @@ -5,7 +5,7 @@ if [ $version ] then versions=("$version") else - versions=(1.19.3 1.18.5 1.17.1) + versions=(1.19.5 1.18.5 1.17.1) fi for version in ${versions[*]} diff --git a/scripts/build_notification_docstring.py b/scripts/build_notification_docstring.py index 92af302..61705a8 100644 --- a/scripts/build_notification_docstring.py +++ b/scripts/build_notification_docstring.py @@ -4,4 +4,4 @@ for provider in notification_provider_options: provider_options = notification_provider_options[provider] for option in provider_options: type_ = provider_options[option]["type"] - print(f":param {type_} {option}: (optional) Notification option for ``type`` :attr:`~.NotificationType.{provider.name}`") + print(f":param {type_}, optional {option}: Notification option for ``type`` :attr:`~.NotificationType.{provider.name}`") diff --git a/uptime_kuma_api/api.py b/uptime_kuma_api/api.py index 428b2e7..e559a6b 100644 --- a/uptime_kuma_api/api.py +++ b/uptime_kuma_api/api.py @@ -189,7 +189,7 @@ def _build_maintenance_data( ) -> dict: if not dateRange: dateRange = [ - datetime.date.today().strftime("%Y-%m-%d 00:00") + datetime.date.today().strftime("%Y-%m-%d 00:00:00") ] if not timeRange: timeRange = [ @@ -338,6 +338,7 @@ def _check_arguments_maintenance(kwargs) -> None: ) _check_argument_conditions(conditions, kwargs) + class UptimeKumaApi(object): """This class is used to communicate with Uptime Kuma. @@ -2157,7 +2158,7 @@ class UptimeKumaApi(object): :param str, optional password: Password, defaults to None :param bool, optional checkUpdate: Show update if available, defaults to True :param bool, optional checkBeta: Also check beta release, defaults to False - :param int, optional keepDataPeriodDays: Keep monitor history data for X days., defaults to 180 + :param int, optional keepDataPeriodDays: Keep monitor history data for X days. Set to 0 for infinite retention., defaults to 180 :param str, optional serverTimezone: Server Timezone, defaults to "" :param str, optional entryPage: Entry Page, defaults to "dashboard" :param bool, optional searchEngineIndex: Search Engine Visibility, defaults to False diff --git a/uptime_kuma_api/docstrings.py b/uptime_kuma_api/docstrings.py index 4b60e6a..16d8b11 100644 --- a/uptime_kuma_api/docstrings.py +++ b/uptime_kuma_api/docstrings.py @@ -120,9 +120,17 @@ def notification_docstring(mode) -> str: :param str, optional pagerdutyIntegrationKey: Notification option for ``type`` :attr:`~.NotificationType.PAGERDUTY` :param str, optional promosmsLogin: Notification option for ``type`` :attr:`~.NotificationType.PROMOSMS` :param str, optional promosmsPassword: Notification option for ``type`` :attr:`~.NotificationType.PROMOSMS` - :param str, optional promosmsPhoneNumber: Notification option for ``type`` :attr:`~.NotificationType.PROMOSMS` - :param str, optional promosmsSMSType: Notification option for ``type`` :attr:`~.NotificationType.PROMOSMS` + :param str, optional promosmsPhoneNumber: Notification option for ``type`` :attr:`~.NotificationType.PROMOSMS`. Phone number (for Polish recipient You can skip area codes). + :param str, optional promosmsSMSType: Notification option for ``type`` :attr:`~.NotificationType.PROMOSMS`. + + Available values are: + + - ``0``: SMS FLASH - Message will automatically show on recipient device. Limited only to Polish recipients. + - ``1``: SMS ECO - cheap but slow and often overloaded. Limited only to Polish recipients. + - ``3``: SMS FULL - Premium tier of SMS, You can use your Sender Name (You need to register name first). Reliable for alerts. + - ``4``: SMS SPEED - Highest priority in system. Very quick and reliable but costly (about twice of SMS FULL price). :param str, optional promosmsSenderName: Notification option for ``type`` :attr:`~.NotificationType.PROMOSMS` + :param bool, optional promosmsAllowLongSMS: Notification option for ``type`` :attr:`~.NotificationType.PROMOSMS`. Allow long SMS. :param str, optional pushbulletAccessToken: Notification option for ``type`` :attr:`~.NotificationType.PUSHBULLET` :param str, optional pushdeerKey: Notification option for ``type`` :attr:`~.NotificationType.PUSHDEER` :param str, optional pushoveruserkey: Notification option for ``type`` :attr:`~.NotificationType.PUSHOVER` @@ -211,13 +219,34 @@ def notification_docstring(mode) -> str: :param str, optional ntfyserverurl: Notification option for ``type`` :attr:`~.NotificationType.NTFY` :param bool, optional smseagleEncoding: Notification option for ``type`` :attr:`~.NotificationType.SMSEAGLE`. True to send messages in unicode. :param int, optional smseaglePriority: Notification option for ``type`` :attr:`~.NotificationType.SMSEAGLE`. Message priority (0-9, default = 0). - :param str, optional smseagleRecipientType: Notification option for ``type`` :attr:`~.NotificationType.SMSEAGLE`. Recipient type. Available values are "smseagle-to" (Phone number(s)), "smseagle-group" (Phonebook group name(s)) and "smseagle-contact" (Phonebook contact name(s)). + :param str, optional smseagleRecipientType: Notification option for ``type`` :attr:`~.NotificationType.SMSEAGLE`. Recipient type. + + Available values are: + + - ``smseagle-to``: Phone number(s) + - ``smseagle-group``: Phonebook group name(s) + - ``smseagle-contact``: Phonebook contact name(s) :param str, optional smseagleToken: Notification option for ``type`` :attr:`~.NotificationType.SMSEAGLE`. API Access token. :param str, optional smseagleRecipient: Notification option for ``type`` :attr:`~.NotificationType.SMSEAGLE`. Recipient(s) (multiple must be separated with comma). :param str, optional smseagleUrl: Notification option for ``type`` :attr:`~.NotificationType.SMSEAGLE`. Your SMSEagle device URL. :param str, optional webhookUrl: Notification option for ``type`` :attr:`~.NotificationType.ZOHOCLIQ` :param str, optional kookGuildID: Notification option for ``type`` :attr:`~.NotificationType.KOOK` :param str, optional kookBotToken: Notification option for ``type`` :attr:`~.NotificationType.KOOK` + :param str, optional splunkAutoResolve: Notification option for ``type`` :attr:`~.NotificationType.SPLUNK`. Auto resolve or acknowledged. + + Available values are: + + - ``0``: do nothing + - ``ACKNOWLEDGEMENT``: auto acknowledged + - ``RECOVERY``: auto resolve + :param str, optional splunkSeverity: Notification option for ``type`` :attr:`~.NotificationType.SPLUNK`. Severity. + + Available values are: + + - ``INFO`` + - ``WARNING`` + - ``CRITICAL`` + :param str, optional splunkRestURL: Notification option for ``type`` :attr:`~.NotificationType.SPLUNK`. Splunk Rest URL. """ diff --git a/uptime_kuma_api/notification_providers.py b/uptime_kuma_api/notification_providers.py index a8a08f5..3d0a27d 100644 --- a/uptime_kuma_api/notification_providers.py +++ b/uptime_kuma_api/notification_providers.py @@ -142,6 +142,9 @@ class NotificationType(str, Enum): KOOK = "Kook" """Kook""" + SPLUNK = "Splunk" + """Splunk""" + notification_provider_options = { NotificationType.ALERTA: dict( @@ -236,6 +239,7 @@ notification_provider_options = { promosmsPhoneNumber=dict(type="str"), promosmsSMSType=dict(type="str"), promosmsSenderName=dict(type="str"), + promosmsAllowLongSMS=dict(type="bool"), ), NotificationType.PUSHBULLET: dict( pushbulletAccessToken=dict(type="str"), @@ -390,6 +394,11 @@ notification_provider_options = { kookGuildID=dict(type="str"), kookBotToken=dict(type="str") ), + NotificationType.SPLUNK: dict( + splunkAutoResolve=dict(type="str"), + splunkSeverity=dict(type="str"), + splunkRestURL=dict(type="str") + ) } notification_provider_conditions = dict(