I created a PowerShell script to scheduld downtime on a server plus it’s services for use with Cluster Aware Updating as a Pre-Updating script.
The next part would be the Post-Updating script which will remove the set downtimes.
However, for some insane reason you need to filter the host, the services linked to it and then loop over all the ID returned so remove them one by one.
Why is this so ridiculous? Scheduling a downtime is as easy as specifying the host in the Uri, and use “child_options = 2”. Why can’t the same be used for remove-downtime?
calling something insane/ridiculous adds a bad tone on your question, and you might not get good answers. Keep that in mind when asking for help in our community, the FAQ holds some more hints for a nice and gentle conversation.
remove-downtime needs the previously generated downtime names/IDs or a provided filter. This specific filter must match - if there are no matches because of
wrong filter or not existing objects
missing permissions
then you’ll receive a 404. That leads to the question of a list of the downtimes, e.g. via GET from /v1/objects/downtimes. Also, the ApiUser object with basic auth should have permissions set, please share the configuration snippet.
Last but not least, please add the exact version of Icinga 2 where you’re targeting the API requests onto.