From c74804ea9302b4bdc7cf387815efbd3a42d11c8f Mon Sep 17 00:00:00 2001 From: lucasheld Date: Tue, 29 Aug 2023 22:02:11 +0200 Subject: [PATCH] feat: add support for uptime kuma 1.23.0 and 1.23.1 --- plugins/modules/monitor.py | 70 ++++++++++++++- plugins/modules/monitor_info.py | 85 +++++++++++++++++++ plugins/modules/notification_info.py | 56 ++++++++++++ plugins/modules/settings.py | 8 ++ plugins/modules/settings_info.py | 10 +++ plugins/modules/status_page_info.py | 7 +- run_tests.sh | 3 +- .../unit/plugins/module_utils/test_monitor.py | 16 ++++ .../plugins/module_utils/test_status_page.py | 1 + 9 files changed, 251 insertions(+), 5 deletions(-) diff --git a/plugins/modules/monitor.py b/plugins/modules/monitor.py index 286ac21..775e0d7 100644 --- a/plugins/modules/monitor.py +++ b/plugins/modules/monitor.py @@ -46,7 +46,7 @@ type: description: The type of the monitor. type: str - choices: ["http", "port", "ping", "keyword", "grpc-keyword", "dns", "docker", "push", "steam", "gamedig", "mqtt", "sqlserver", "postgres", "mysql", "mongodb", "radius", "redis", "group"] + choices: ["group", "http", "port", "ping", "keyword", "json-query", "grpc-keyword", "dns", "docker", "real-browser", "push", "steam", "gamedig", "mqtt", "kafka-producer", "sqlserver", "postgres", "mysql", "mongodb", "radius", "redis", "tailscale-ping"] interval: description: The heartbeat interval of the monitor. type: int @@ -126,7 +126,7 @@ authMethod: description: The auth method of the monitor. type: str - choices: ["", "basic", "ntlm", "mtls"] + choices: ["", "basic", "ntlm", "mtls", "oauth2-cc"] tlsCert: description: The tls cert of the monitor. type: str @@ -148,9 +148,30 @@ authWorkstation: description: The auth workstation of the monitor. type: str + oauth_auth_method: + description: Authentication Method + type: str + oauth_token_url: + description: OAuth Token URL + type: str + oauth_client_id: + description: Client ID + type: str + oauth_client_secret: + description: Client Secret + type: str + oauth_scopes: + description: OAuth Scope + type: str + timeout: + description: Request Timeout + type: int keyword: description: The keyword of the monitor. type: str + invertKeyword: + description: Invert Keyword. Look for the keyword to be absent rather than present. + type: bool grpcUrl: description: The grpc url of the monitor. type: str @@ -236,6 +257,33 @@ game: description: The game of the monitor. type: str + gamedigGivenPortOnly: + description: Guess Gamedig Port. The port used by Valve Server Query Protocol may be different from the client port. Try this if the monitor cannot connect to your server. + type: bool + jsonPath: + description: Json Query + type: str + expectedValue: + description: Expected Value + type: str + kafkaProducerBrokers: + description: Kafka Broker list + type: str + kafkaProducerTopic: + description: Kafka Topic Name + type: str + kafkaProducerMessage: + description: Kafka Producer Message + type: str + kafkaProducerSsl: + description: Enable Kafka SSL + type: bool + kafkaProducerAllowAutoTopicCreation: + description: Enable Kafka Producer Auto Topic Creation + type: bool + kafkaProducerSaslOptions: + description: Kafka SASL Options + type: dict state: description: - Set to C(present) to create/update a monitor. @@ -423,7 +471,7 @@ def main(): method=dict(type="str"), body=dict(type="str"), headers=dict(type="str"), - authMethod=dict(type="str", choices=["", "basic", "ntlm", "mtls"]), + authMethod=dict(type="str", choices=["", "basic", "ntlm", "mtls", "oauth2-cc"]), tlsCert=dict(type="str"), tlsKey=dict(type="str"), tlsCa=dict(type="str"), @@ -431,9 +479,16 @@ def main(): basic_auth_pass=dict(type="str", no_log=True), authDomain=dict(type="str"), authWorkstation=dict(type="str"), + oauth_auth_method=dict(type="str"), + oauth_token_url=dict(type="str"), + oauth_client_id=dict(type="str"), + oauth_client_secret=dict(type="str"), + oauth_scopes=dict(type="str"), + timeout=dict(type="int"), # KEYWORD keyword=dict(type="str"), + invertKeyword=dict(type="bool"), # GRPC_KEYWORD grpcUrl=dict(type="str"), @@ -483,6 +538,15 @@ def main(): # GAMEDIG game=dict(type="str"), + gamedigGivenPortOnly=dict(type="bool"), + jsonPath=dict(type="str"), + expectedValue=dict(type="str"), + kafkaProducerBrokers=dict(type="str"), + kafkaProducerTopic=dict(type="str"), + kafkaProducerMessage=dict(type="str"), + kafkaProducerSsl=dict(type="bool"), + kafkaProducerAllowAutoTopicCreation=dict(type="bool"), + kafkaProducerSaslOptions=dict(type="dict"), state=dict(type="str", default="present", choices=["present", "absent", "paused", "resumed"]) ) diff --git a/plugins/modules/monitor_info.py b/plugins/modules/monitor_info.py index bc9b869..5ecea13 100644 --- a/plugins/modules/monitor_info.py +++ b/plugins/modules/monitor_info.py @@ -377,6 +377,91 @@ returned: always type: str sample: None + expectedValue: + description: Expected Value + returned: always + type: str + sample: None + gamedigGivenPortOnly: + description: Guess Gamedig Port. The port used by Valve Server Query Protocol may be different from the client port. Try this if the monitor cannot connect to your server. + returned: always + type: bool + sample: True + invertKeyword: + description: Invert Keyword + returned: always + type: bool + sample: False + jsonPath: + description: Json Query + returned: always + type: str + sample: None + kafkaProducerAllowAutoTopicCreation: + description: Enable Kafka Producer Auto Topic Creation + returned: always + type: bool + sample: False + kafkaProducerBrokers: + description: Kafka Broker list + returned: always + type: list + sample: None + kafkaProducerMessage: + description: Kafka Producer Message + returned: always + type: str + sample: None + kafkaProducerSaslOptions: + description: Kafka SASL Options + returned: always + type: dict + sample: None + kafkaProducerSsl: + description: Enable Kafka SSL + returned: always + type: bool + sample: False + kafkaProducerTopic: + description: Kafka Topic Name + returned: always + type: str + sample: None + oauth_auth_method: + description: Authentication Method + returned: always + type: str + sample: None + oauth_client_id: + description: Client ID + returned: always + type: str + sample: None + oauth_client_secret: + description: Client Secret + returned: always + type: str + sample: None + oauth_scopes: + description: OAuth Scope + returned: always + type: str + sample: None + oauth_token_url: + description: OAuth Token URL + returned: always + type: str + sample: None + screenshot: + description: Path to the screenshot + returned: always + type: str + sample: None + timeout: + description: Request Timeout + returned: always + type: int + sample: 48 ''' import traceback diff --git a/plugins/modules/notification_info.py b/plugins/modules/notification_info.py index a9826b4..d75e38b 100644 --- a/plugins/modules/notification_info.py +++ b/plugins/modules/notification_info.py @@ -184,6 +184,14 @@ description: Feishu provider option. returned: if type is Feishu type: str + flashdutySeverity: + description: FlashDuty provider option. + returned: if type is FlashDuty + type: str + flashdutyIntegrationKey: + description: FlashDuty provider option. + returned: if type is FlashDuty + type: str freemobileUser: description: FreeMobile provider option. returned: if type is FreeMobile @@ -320,6 +328,18 @@ description: mattermost provider option. returned: if type is mattermost type: str + sender: + description: nostr provider option. + returned: if type is nostr + type: str + recipients: + description: nostr provider option. + returned: if type is nostr + type: str + relays: + description: nostr provider option. + returned: if type is nostr + type: str ntfyAuthenticationMethod: description: ntfy provider option. returned: if type is ntfy @@ -460,6 +480,10 @@ description: pushbullet provider option. returned: if type is pushbullet type: str + pushdeerServer: + description: PushDeer provider option. + returned: if type is PushDeer + type: str pushdeerKey: description: PushDeer provider option. returned: if type is PushDeer @@ -548,6 +572,10 @@ description: signal provider option. returned: if type is signal type: str + slackchannelnotify: + description: slack provider option. + returned: if type is slack + type: bool slackchannel: description: slack provider option. returned: if type is slack @@ -564,6 +592,26 @@ description: slack provider option. returned: if type is slack type: str + smscTranslit: + description: smsc provider option. + returned: if type is smsc + type: str + smscLogin: + description: smsc provider option. + returned: if type is smsc + type: str + smscPassword: + description: smsc provider option. + returned: if type is smsc + type: str + smscToNumber: + description: smsc provider option. + returned: if type is smsc + type: str + smscSenderName: + description: smsc provider option. + returned: if type is smsc + type: str smseagleEncoding: description: SMSEagle provider option. returned: if type is SMSEagle @@ -720,6 +768,10 @@ description: twilio provider option. returned: if type is twilio type: str + twilioApiKey: + description: twilio provider option. + returned: if type is twilio + type: str twilioAuthToken: description: twilio provider option. returned: if type is twilio @@ -736,6 +788,10 @@ description: webhook provider option. returned: if type is webhook type: str + webhookCustomBody: + description: webhook provider option. + returned: if type is webhook + type: str webhookAdditionalHeaders: description: webhook provider option. returned: if type is webhook diff --git a/plugins/modules/settings.py b/plugins/modules/settings.py index 424b575..34323fe 100644 --- a/plugins/modules/settings.py +++ b/plugins/modules/settings.py @@ -49,9 +49,15 @@ steamAPIKey: description: The Steam API key for monitoring a Steam game server. type: str + nscd: + description: Enable NSCD (Name Service Cache Daemon) for caching all DNS requests + type: bool dnsCache: description: True if dns cache should be enabled. type: bool + chromeExecutable: + description: Chrome/Chromium Executable + type: str tlsExpiryNotifyDays: description: HTTPS monitors trigger notification when the TLS certificate expires in the specified days. type: list @@ -117,7 +123,9 @@ def main(): searchEngineIndex=dict(type="bool"), primaryBaseURL=dict(type="str"), steamAPIKey=dict(type="str"), + nscd=dict(type="bool"), dnsCache=dict(type="bool"), + chromeExecutable=dict(type="str"), # notifications tlsExpiryNotifyDays=dict(type="list", elements="int"), # security diff --git a/plugins/modules/settings_info.py b/plugins/modules/settings_info.py index 545d1db..3d7cb8d 100644 --- a/plugins/modules/settings_info.py +++ b/plugins/modules/settings_info.py @@ -95,6 +95,16 @@ returned: always type: bool sample: false + chromeExecutable: + description: Value of the chromeExecutable setting. + returned: always + type: str + sample: '' + nscd: + description: Value of the nscd setting. + returned: always + type: bool + sample: false ''' import traceback diff --git a/plugins/modules/status_page_info.py b/plugins/modules/status_page_info.py index b9445c4..8e111a7 100644 --- a/plugins/modules/status_page_info.py +++ b/plugins/modules/status_page_info.py @@ -75,6 +75,11 @@ returned: always type: bool sample: True + showCertificateExpiry: + description: Show Certificate Expiry. + returned: always + type: bool + sample: False showTags: description: True if the show tags is enabled. returned: always @@ -119,7 +124,7 @@ description: The public group list of the status page. returned: always type: list - sample: [{'id': 5, 'name': 'Services', 'weight': 1, 'monitorList': [{'id': 18, 'name': 'sample monitor'}]}] + sample: [{'id': 5, 'name': 'Services', 'weight': 1, 'monitorList': [{'id': 18, 'name': 'sample monitor', 'type': 'http'}]}] ''' import traceback diff --git a/run_tests.sh b/run_tests.sh index 9037bc0..ec31dfc 100755 --- a/run_tests.sh +++ b/run_tests.sh @@ -27,7 +27,7 @@ if [ $version ] && [ "$version" != "all" ] then versions=("$version") else - versions=(1.22.1 1.22.0 1.21.3) + versions=(1.23.1 1.23.0 1.22.1 1.22.0 1.21.3) fi unit_targets="" @@ -61,6 +61,7 @@ do echo "Stopping uptime kuma..." docker stop uptimekuma > /dev/null + sleep 1 echo "" done diff --git a/tests/unit/plugins/module_utils/test_monitor.py b/tests/unit/plugins/module_utils/test_monitor.py index befd08c..fe5e9df 100644 --- a/tests/unit/plugins/module_utils/test_monitor.py +++ b/tests/unit/plugins/module_utils/test_monitor.py @@ -46,7 +46,14 @@ def setUp(self): "basic_auth_pass": None, "authDomain": None, "authWorkstation": None, + "oauth_auth_method": None, + "oauth_token_url": None, + "oauth_client_id": None, + "oauth_client_secret": None, + "oauth_scopes": None, + "timeout": None, "keyword": None, + "invertKeyword": None, "grpcUrl": None, "grpcEnableTls": None, "grpcServiceName": None, @@ -74,6 +81,15 @@ def setUp(self): "radiusCalledStationId": None, "radiusCallingStationId": None, "game": None, + "gamedigGivenPortOnly": None, + "jsonPath": None, + "expectedValue": None, + "kafkaProducerBrokers": None, + "kafkaProducerTopic": None, + "kafkaProducerMessage": None, + "kafkaProducerSsl": None, + "kafkaProducerAllowAutoTopicCreation": None, + "kafkaProducerSaslOptions": None, "state": "present" } diff --git a/tests/unit/plugins/module_utils/test_status_page.py b/tests/unit/plugins/module_utils/test_status_page.py index 5150cb9..f61a5b9 100644 --- a/tests/unit/plugins/module_utils/test_status_page.py +++ b/tests/unit/plugins/module_utils/test_status_page.py @@ -79,6 +79,7 @@ def test_status_page(self): for j in i.get("monitorList", []): j.pop("sendUrl", None) j["name"] = None + j.pop("type", None) self.assertEqual(public_group_list, self.params["publicGroupList"]) result = self.run_module(module, self.params)