-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add support for uptime kuma 1.20.0
- Loading branch information
Showing
29 changed files
with
296 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
# Copyright: (c) 2022, Lucas Held <[email protected]> | ||
# Copyright: (c) 2023, Lucas Held <[email protected]> | ||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) | ||
|
||
from __future__ import absolute_import, division, print_function | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
# Copyright: (c) 2022, Lucas Held <[email protected]> | ||
# Copyright: (c) 2023, Lucas Held <[email protected]> | ||
|
||
from __future__ import absolute_import, division, print_function | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
#!/usr/bin/python | ||
# -*- coding: utf-8 -*- | ||
|
||
# Copyright: (c) 2022, Lucas Held <[email protected]> | ||
# Copyright: (c) 2023, Lucas Held <[email protected]> | ||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) | ||
|
||
from __future__ import absolute_import, division, print_function | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
#!/usr/bin/python | ||
# -*- coding: utf-8 -*- | ||
|
||
# Copyright: (c) 2022, Lucas Held <[email protected]> | ||
# Copyright: (c) 2023, Lucas Held <[email protected]> | ||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) | ||
|
||
from __future__ import absolute_import, division, print_function | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
#!/usr/bin/python | ||
# -*- coding: utf-8 -*- | ||
|
||
# Copyright: (c) 2023, Lucas Held <[email protected]> | ||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) | ||
|
||
from __future__ import absolute_import, division, print_function | ||
|
||
__metaclass__ = type | ||
|
||
|
||
DOCUMENTATION = r''' | ||
--- | ||
extends_documentation_fragment: | ||
- lucasheld.uptime_kuma.uptime_kuma | ||
module: game_list_info | ||
author: Lucas Held (@lucasheld) | ||
short_description: Retrieves facts about the games that are supported by the GameDig monitor type. | ||
description: Retrieves facts about the games that are supported by the GameDig monitor type. | ||
''' | ||
|
||
EXAMPLES = r''' | ||
- name: get game list | ||
lucasheld.uptime_kuma.game_list_info: | ||
api_url: http://127.0.0.1:3001 | ||
api_username: admin | ||
api_password: secret123 | ||
register: result | ||
''' | ||
|
||
RETURN = r''' | ||
game_list: | ||
description: The game list | ||
returned: always | ||
type: complex | ||
contains: | ||
extra: | ||
description: The extra value of the game. | ||
returned: always | ||
type: dict | ||
sample: {} | ||
keys: | ||
description: The keys of the game. | ||
returned: always | ||
type: list | ||
elements: str | ||
sample: ["7d2d"] | ||
options: | ||
description: The options of the game. | ||
returned: always | ||
type: dict | ||
sample: {"port": 26900, "port_query_offset": 1, "protocol": "valve"} | ||
pretty: | ||
description: The title of the game. | ||
returned: always | ||
type: str | ||
sample: "7 Days to Die (2013)" | ||
''' | ||
|
||
import traceback | ||
|
||
from ansible.module_utils.basic import AnsibleModule | ||
from ansible_collections.lucasheld.uptime_kuma.plugins.module_utils.common import common_module_args | ||
from ansible.module_utils.basic import missing_required_lib | ||
|
||
try: | ||
from uptime_kuma_api import UptimeKumaApi | ||
HAS_UPTIME_KUMA_API = True | ||
except ImportError: | ||
HAS_UPTIME_KUMA_API = False | ||
|
||
|
||
def run(api, params, result): | ||
result["game_list"] = api.get_game_list() | ||
|
||
|
||
def main(): | ||
module_args = dict() | ||
module_args.update(common_module_args) | ||
|
||
module = AnsibleModule(module_args, supports_check_mode=True) | ||
params = module.params | ||
|
||
if not HAS_UPTIME_KUMA_API: | ||
module.fail_json(msg=missing_required_lib("uptime_kuma_api")) | ||
|
||
api = UptimeKumaApi(params["api_url"]) | ||
api_token = params.get("api_token") | ||
api_username = params.get("api_username") | ||
api_password = params.get("api_password") | ||
if api_token: | ||
api.login_by_token(api_token) | ||
elif api_username and api_password: | ||
api.login(api_username, api_password) | ||
else: | ||
# autoLogin for enabled disableAuth | ||
api.login() | ||
|
||
result = { | ||
"changed": False | ||
} | ||
|
||
try: | ||
run(api, params, result) | ||
|
||
api.disconnect() | ||
module.exit_json(**result) | ||
except Exception: | ||
api.disconnect() | ||
error = traceback.format_exc() | ||
module.fail_json(msg=error, **result) | ||
|
||
|
||
if __name__ == '__main__': | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
#!/usr/bin/python | ||
# -*- coding: utf-8 -*- | ||
|
||
# Copyright: (c) 2022, Lucas Held <[email protected]> | ||
# Copyright: (c) 2023, Lucas Held <[email protected]> | ||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) | ||
|
||
from __future__ import absolute_import, division, print_function | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
#!/usr/bin/python | ||
# -*- coding: utf-8 -*- | ||
|
||
# Copyright: (c) 2022, Lucas Held <[email protected]> | ||
# Copyright: (c) 2023, Lucas Held <[email protected]> | ||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) | ||
|
||
from __future__ import absolute_import, division, print_function | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
#!/usr/bin/python | ||
# -*- coding: utf-8 -*- | ||
|
||
# Copyright: (c) 2022, Lucas Held <[email protected]> | ||
# Copyright: (c) 2023, Lucas Held <[email protected]> | ||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) | ||
|
||
from __future__ import absolute_import, division, print_function | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
#!/usr/bin/python | ||
# -*- coding: utf-8 -*- | ||
|
||
# Copyright: (c) 2022, Lucas Held <[email protected]> | ||
# Copyright: (c) 2023, Lucas Held <[email protected]> | ||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) | ||
|
||
from __future__ import absolute_import, division, print_function | ||
|
@@ -33,7 +33,7 @@ | |
type: | ||
description: The type of the monitor. | ||
type: str | ||
choices: ["http", "port", "ping", "keyword", "grpc-keyword", "dns", "docker", "push", "steam", "mqtt", "sqlserver", "postgres", "mysql", "radius"] | ||
choices: ["http", "port", "ping", "keyword", "grpc-keyword", "dns", "docker", "push", "steam", "gamedig", "mqtt", "sqlserver", "postgres", "mysql", "mongodb", "radius", "redis"] | ||
interval: | ||
description: The heartbeat interval of the monitor. | ||
type: int | ||
|
@@ -148,6 +148,9 @@ | |
hostname: | ||
description: The hostname of the monitor. | ||
type: str | ||
packetSize: | ||
description: The packet size of the monitor. | ||
type: int | ||
port: | ||
description: The port of the monitor. | ||
type: int | ||
|
@@ -203,6 +206,9 @@ | |
radiusCallingStationId: | ||
description: The radius calling station id of the monitor. | ||
type: str | ||
game: | ||
description: The game of the monitor. | ||
type: str | ||
state: | ||
description: | ||
- Set to C(present) to create/update a monitor. | ||
|
@@ -289,6 +295,10 @@ def run(api, params, result): | |
params["databaseConnectionString"] = "postgres://username:password@host:port/database" | ||
elif params["type"] == MonitorType.MYSQL: | ||
params["databaseConnectionString"] = "mysql://username:password@host:port/database" | ||
elif params["type"] == MonitorType.MONGODB: | ||
params["databaseConnectionString"] = "mongodb://username:password@host:port/database" | ||
elif params["type"] == MonitorType.REDIS: | ||
params["databaseConnectionString"] = "redis://user:password@host:port" | ||
|
||
if not params["port"]: | ||
if type == MonitorType.DNS: | ||
|
@@ -353,7 +363,7 @@ def main(): | |
module_args = dict( | ||
id=dict(type="int"), | ||
name=dict(type="str"), | ||
type=dict(type="str", choices=["http", "port", "ping", "keyword", "dns", "docker", "push", "steam", "mqtt", "sqlserver", "postgres", "mysql", "radius"]), | ||
type=dict(type="str", choices=["http", "port", "ping", "keyword", "grpc-keyword", "dns", "docker", "push", "steam", "gamedig", "mqtt", "sqlserver", "postgres", "mysql", "mongodb", "radius", "redis"]), | ||
interval=dict(type="int"), | ||
retryInterval=dict(type="int"), | ||
resendInterval=dict(type="int"), | ||
|
@@ -397,6 +407,9 @@ def main(): | |
# PORT, PING, DNS, STEAM, MQTT | ||
hostname=dict(type="str"), | ||
|
||
# PING | ||
packetSize=dict(type="int"), | ||
|
||
# PORT, DNS, STEAM, MQTT, RADIUS | ||
port=dict(type="int"), | ||
|
||
|
@@ -410,8 +423,10 @@ def main(): | |
mqttTopic=dict(type="str"), | ||
mqttSuccessMessage=dict(type="str"), | ||
|
||
# SQLSERVER, POSTGRES, MYSQL | ||
# SQLSERVER, POSTGRES, MYSQL, MONGODB, REDIS | ||
databaseConnectionString=dict(type="str"), | ||
|
||
# SQLSERVER, POSTGRES, MYSQL | ||
databaseQuery=dict(type="str"), | ||
|
||
# DOCKER | ||
|
@@ -426,6 +441,9 @@ def main(): | |
radiusCalledStationId=dict(type="str"), | ||
radiusCallingStationId=dict(type="str"), | ||
|
||
# GAMEDIG | ||
game=dict(type="str"), | ||
|
||
state=dict(type="str", default="present", choices=["present", "absent", "paused", "resumed"]) | ||
) | ||
module_args.update(common_module_args) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
#!/usr/bin/python | ||
# -*- coding: utf-8 -*- | ||
|
||
# Copyright: (c) 2022, Lucas Held <[email protected]> | ||
# Copyright: (c) 2023, Lucas Held <[email protected]> | ||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) | ||
|
||
from __future__ import absolute_import, division, print_function | ||
|
@@ -277,6 +277,61 @@ | |
returned: always | ||
type: str | ||
sample: None | ||
radiusCalledStationId: | ||
description: The radiusCalledStationId of the monitor. | ||
returned: always | ||
type: str | ||
sample: None | ||
radiusCallingStationId: | ||
description: The radiusCallingStationId of the monitor. | ||
returned: always | ||
type: str | ||
sample: None | ||
radiusUsername: | ||
description: The radiusUsername of the monitor. | ||
returned: always | ||
type: str | ||
sample: None | ||
radiusPassword: | ||
description: The radiusPassword of the monitor. | ||
returned: always | ||
type: str | ||
sample: None | ||
radiusSecret: | ||
description: The radiusSecret of the monitor. | ||
returned: always | ||
type: str | ||
sample: None | ||
resendInterval: | ||
description: The resendInterval of the monitor. | ||
returned: always | ||
type: int | ||
sample: 0 | ||
packetSize: | ||
description: The packetSize of the monitor. | ||
returned: always | ||
type: int | ||
sample: 56 | ||
includeSensitiveData: | ||
description: The includeSensitiveData of the monitor. | ||
returned: always | ||
type: bool | ||
sample: True | ||
game: | ||
description: The game of the monitor. | ||
returned: always | ||
type: str | ||
sample: '7d2d' | ||
docker_host: | ||
description: The docker_host of the monitor. | ||
returned: always | ||
type: int | ||
sample: None | ||
docker_container: | ||
description: The docker_container of the monitor. | ||
returned: always | ||
type: str | ||
sample: "" | ||
''' | ||
|
||
import traceback | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
#!/usr/bin/python | ||
# -*- coding: utf-8 -*- | ||
|
||
# Copyright: (c) 2022, Lucas Held <[email protected]> | ||
# Copyright: (c) 2023, Lucas Held <[email protected]> | ||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) | ||
|
||
from __future__ import absolute_import, division, print_function | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
#!/usr/bin/python | ||
# -*- coding: utf-8 -*- | ||
|
||
# Copyright: (c) 2022, Lucas Held <[email protected]> | ||
# Copyright: (c) 2023, Lucas Held <[email protected]> | ||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) | ||
|
||
from __future__ import absolute_import, division, print_function | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
#!/usr/bin/python | ||
# -*- coding: utf-8 -*- | ||
|
||
# Copyright: (c) 2022, Lucas Held <[email protected]> | ||
# Copyright: (c) 2023, Lucas Held <[email protected]> | ||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) | ||
|
||
from __future__ import absolute_import, division, print_function | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
#!/usr/bin/python | ||
# -*- coding: utf-8 -*- | ||
|
||
# Copyright: (c) 2022, Lucas Held <[email protected]> | ||
# Copyright: (c) 2023, Lucas Held <[email protected]> | ||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) | ||
|
||
from __future__ import absolute_import, division, print_function | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
#!/usr/bin/python | ||
# -*- coding: utf-8 -*- | ||
|
||
# Copyright: (c) 2022, Lucas Held <[email protected]> | ||
# Copyright: (c) 2023, Lucas Held <[email protected]> | ||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) | ||
|
||
from __future__ import absolute_import, division, print_function | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
#!/usr/bin/python | ||
# -*- coding: utf-8 -*- | ||
|
||
# Copyright: (c) 2022, Lucas Held <[email protected]> | ||
# Copyright: (c) 2023, Lucas Held <[email protected]> | ||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) | ||
|
||
from __future__ import absolute_import, division, print_function | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
#!/usr/bin/python | ||
# -*- coding: utf-8 -*- | ||
|
||
# Copyright: (c) 2022, Lucas Held <[email protected]> | ||
# Copyright: (c) 2023, Lucas Held <[email protected]> | ||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) | ||
|
||
from __future__ import absolute_import, division, print_function | ||
|
Oops, something went wrong.