Closed AMDTonyRyzen closed 1 year ago
Here is a full example.
First you need to add the monitors themselves.
Then add a status page and save it with the publicGroupList
parameter. It consists of a name
(the title of the monitor section inside the status page), a weight
(to define the order if you have multiple monitor sections) and a monitorList
(the ids of the monitors you want to add to this status page section).
from uptime_kuma_api import UptimeKumaApi, MonitorType
username = "admin"
password = "secret123"
api = UptimeKumaApi("http://127.0.0.1:3001")
if api.need_setup():
api.setup(username, password)
api.login(username, password)
monitor_id_1 = api.add_monitor(
type=MonitorType.HTTP,
url="http://127.0.0.1",
name="monitor1"
)["monitorID"]
monitor_id_2 = api.add_monitor(
type=MonitorType.HTTP,
url="http://127.0.0.2",
name="monitor2"
)["monitorID"]
slug = "statuspage1"
api.add_status_page(
slug=slug,
title="Status Page 1"
)
api.save_status_page(
slug=slug,
publicGroupList=[
{
'name': 'Services',
'weight': 1,
'monitorList': [
{
"id": monitor_id_1
},
{
"id": monitor_id_2
}
]
}
]
)
api.disconnect()
Thank you so much for the detailed answer, at the time of receipt I still get an error, but I think I can handle it over time, I understood the main principle. By the way, if you need help writing a manual, I can help in my free time. you can infiltrate me in tg @Ynot_Frost.
Hi, can you tell me how I can change the status_page data using the python api. Apparently, the following function save_status_page(self, slug: str, **kwargs) is used for this, but I don't quite understand how to insert data into it correctly. print(api.save_status_page(slug="google", data={'domainNameList': ["google.com"]})) I get html code and requests.exceptions.JSONDecodeError: [Errno Expecting value] <!DOCTYPE html>