hostgroup.create

Description

object hostgroup.create(object/array hostGroups)

This method allows to create new host groups.

This method is only available to Super admin user type. Permissions to call the method can be revoked in user role settings. See User roles for more information.

Parameters

(object/array) Host groups to create. The method accepts host groups with the standard host group properties.

Return values

(object) Returns an object containing the IDs of the created host groups under the groupids property. The order of the returned IDs matches the order of the passed host groups.

Examples

Creating a host group

Create a host group called “Linux servers”.

Request:

  1. {
  2. "jsonrpc": "2.0",
  3. "method": "hostgroup.create",
  4. "params": {
  5. "name": "Linux servers"
  6. },
  7. "auth": "038e1d7b1735c6a5436ee9eae095879e",
  8. "id": 1
  9. }

Response:

  1. {
  2. "jsonrpc": "2.0",
  3. "result": {
  4. "groupids": [
  5. "107819"
  6. ]
  7. },
  8. "id": 1
  9. }

Source

CHostGroup::create() in ui/include/classes/api/services/CHostGroup.php.