We are currently preparing our migration to CheckMK. For our on-call rotation, we use the custom stand-by attributes set in the CheckMK GUI.
From what I understand from the REST API documentation, It should be possible to update a user’s attribute by getting the user via the API edit the extension array and submit this array to the PUT api.
Below is a rudimentary python script to simulate this:
import requests
res = requests.get("https://cmk.server/master/check_mk/api/1.0/objects/user_config/vancas1", auth=(
"automation",
"------"
))
data = res.json()['extensions']
# Update the stand-by attribute
data['stand-by'] = "1"
res = requests.put("https://cmk.server/master/check_mk/api/1.0/objects/user_config/vancas1", auth=(
"automation",
"----"
), json=data)
print(res.json())
The response from the API seems to not know about our custom user attribute + complains about the Auth type being ldap …
I’ve done some digging myself in the CheckMK Source @Github. The validation class for CreateUser does contain a def validate_custom_attributes function, but none to be found on the UpdateUser class …
We have already made some changes in this area. You should now be able to update users that have custom attributes via the REST API on v2.2.0p11 or above. Please see werk user_config: allow update of custom user attributes.