I’m having a hard time figuring out how to activate changes via the api. It seems I need to find an etag first. However, the endpoint to get all pending changes provides multiple IDs (if there are multiple changes) but nothing called an etag.
Is there a simple way to just tell it to activate all changes? This was much easier prior to cmk 2.0.
On another API related topic, I’m also trying to run discovery on hosts via the api. Is this possible? I’ve tried ‘new’, ‘refresh’, ‘fix_all’, and ‘tabula_rasa’ but none of them actually add any services. This was also much easier on the old API.
Ok, so I got around the activating changes issue. The ETag is not in the payload of the get pending changes end point. It is in the headers. Is this documented somewhere? If so, I have not found that document.
I still have no idea how to run discovery on hosts via the api. The documentation on that is either incorrect, or I am misinterpreting it.
I wish I could have the cmk 2.2 gui with the 1.5 api.
Yea its in the documentation, did you read it? I can agree that most API end-points are not well documented, but its clear that the eTag is an HTTP header, its even clear in the examples the documentation provides.
So what is the issue here? You just say its not working? I assume you have made an activate changes after the discovery as usual?
The value of the, to be modified, object’s ETag header. You can get this value by displaying the object it individually. To update this object the currently stored ETag needs to be the same as the one sent. The content of the ETag can potentially be anything and should be treated as semantically opaque.
There is no “get all pending changes”, I assume you mean “Activate pending changes” as was your original question?
If you have issues with discovery, perhaps that would help to post a separate post about that?
I have used both of these API end-points to enable new services and activate these and it works fine. not sure what version you are running as you did not mentioned that, so I assume its 2.2.0p17
It’s “show all pending changes.” That is the endpoint that has the ETag in it’s header. This is all the doc says:
Show all pending changes
This endpoint requires the following permissions:
Optionally:
Any of:
general.see_all: See all objects regardless of contacts and contact groups. If combined with ‘perform commands’ then commands may be done on all objects.
bi.see_all: With this permission set, the BI aggregation rules are applied to all hosts and services - not only those the user is a contact for. If you remove this permissions then the user will see incomplete aggregation trees with status based only on those items.
mkeventd.seeall: If a user lacks this permission then he/she can see only those events that originate from a host that he/she is a contact for.
A header specifying which type of content is in the request/response body. This is required when sending encoded data in a POST/PUT body. When the request body is empty, this header should not be sent.
X-Checkmk-Edition
required string
Example: “cre”
The checkmk edition.
X-Checkmk-Version
required string
Example: “2.2.0p10”
The checkmk version.
RESPONSE SCHEMA: application/json
links
required Array of objects (Link)
list of links to other resources.
domainType any
Default: “activation_run”
The domain type of the objects in the collection.
value Array of objects (ChangesFields)