ID: 4018
Title: WATO WebAPI: new functions to manage host, service and contactgroups
Component: WATO
Level: 1
Class: New Feature
Version: 1.4.0i4
A few new functions to manage host, service and contact groups have been introduced.
First of all you can get all groups of a specific type with the url parameter
action=get_all_{groupname}
<tt>
Example calls:
curl
http://localhost/heute/check_mk/webapi.py?action=get_all_hostgroups&_us…
curl
http://localhost/heute/check_mk/webapi.py?action=get_all_servicegroups&…
curl
http://localhost/heute/check_mk/webapi.py?action=get_all_contactgroups&…
</tt>
Furthermore you can add, edit and delete these groups
<tt>
# All group types can be managed with similar requests
# Add
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"]}'
</tt>