Yes, you need to use a different url for downtimes:
url = https://monitoring.server/master/check_mk/view.py
Then you need to figure out if a downtime already set, maybe something like this:
params = {
'_username': 'automation',
'_secret': 'secret',
'output_format': 'JSON',
'host_regex': 'host01',
'view_name': 'downtimes'
}
response = requests.get(url, params=params).txt
response_json = json.loads(response)
if len(response_json) == 1:
host_is_down = False
else:
host_is_down = True
If no downtime is set, you can set one:
params = {
'_do_confirm': 'yes',
'_do_actions': 'yes',
'_transid': '-1',
'_username': 'automation',
'_secret': 'secret',
'output_format': 'JSON'
'view_name': 'host',
'host': 'host01',
'_on_hosts': 'on',
'_downrange__next_year': 'This+year',
'_down_comment': 'my comment'
}
response = requests.post(url, params=params)
I hope this help