Werk #4018: WATO Web-API: new functions to manage host, service and contactgroups

KomponenteWATO
TitelWATO Web-API: new functions to manage host, service and contactgroups
Datum2017-02-02 11:47:18
Checkmk EditionCheckmk Raw Edition (CRE)
Checkmk Version1.4.0b1
LevelTrivial Change
KlasseNew Feature
KompatibilitätKompatibel - benötigt kein manuelles Eingreifen

A few new functions to manage host, service and contact groups have been introduced.

Example calls:

You can get all groups of a specific type with the action get_all_{groupname}
curl http://localhost/heute/check_mk/webapi.py?action=get_all_hostgroups&_username=automation&_secret=1122

curl http://localhost/heute/check_mk/webapi.py?action=get_all_servicegroups&_username=automation&_secret=1122

curl http://localhost/heute/check_mk/webapi.py?action=get_all_contactgroups&_username=automation&_secret=1122


Furthermore you can add, edit and delete these groups

# All group types can be managed with similar requests

# Add group
curl "http://localhost/heute/check_mk/webapi.py?action=add_hostgroup&_username=automation&_secret=1122" -d 'request={"groupname": "hostgroup1", "alias": "the hg alias"}'

curl "http://localhost/heute/check_mk/webapi.py?action=add_servicegroup&_username=automation&_secret=1122" -d 'request={"groupname": "servicegroup1", "alias": "the sg alias"}'

curl "http://localhost/heute/check_mk/webapi.py?action=add_contactgroup&_username=automation&_secret=1122" -d 'request={"groupname": "contactgroup1", "alias": "the cg alias"}'

# Edit group
curl "http://localhost/heute/check_mk/webapi.py?action=edit_hostgroup&_username=automation&_secret=1122" -d 'request={"groupname": "hostgroup1", "alias": "the hg alias"}'

curl "http://localhost/heute/check_mk/webapi.py?action=edit_servicegroup&_username=automation&_secret=1122" -d 'request={"groupname": "servicegroup1", "alias": "the sg alias"}'

curl "http://localhost/heute/check_mk/webapi.py?action=edit_contactgroup&_username=automation&_secret=1122" -d 'request={"groupname": "contactgroup1", "alias": "the cg alias"}'

# Delete group
curl "http://localhost/heute/check_mk/webapi.py?action=delete_hostgroup&_username=automation&_secret=1122" -d 'request={"groupname": "hostgroup1"}'

curl "http://localhost/heute/check_mk/webapi.py?action=delete_servicegroup&_username=automation&_secret=1122" -d 'request={"groupname": "servicegroup1"}'

curl "http://localhost/heute/check_mk/webapi.py?action=delete_contactgroup&_username=automation&_secret=1122" -d 'request={"groupname": "contactgroup1"}'

# For contact groups you may also specify a list of nagvis maps in the extra attribute nagivs_maps
curl "http://localhost/heute/check_mk/webapi.py?action=add_contactgroup&_username=automation&_secret=1122" -d 'request={"groupname": "newgroup2", "alias": "the alias", "nagvis_maps": ["dfdf"]}'

Please note: A more elaborate version of these new web api calls will be added to our manual soon. :)