You are viewing documentation for the development version, it may be incomplete.
Join our translation project and help translate Zabbix documentation into your native language.

hostgroup.massadd

Description

object hostgroup.massadd(object parameters)

This method allows to simultaneously add multiple related objects to all the given host groups.

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

Parameters

(object) Parameters containing the IDs of the host groups to update and the objects to add to all the host groups.

The method accepts the following parameters.

Parameter Type Description
groups object/array Host groups to be updated.

The host groups must have only the groupid property defined.

Parameter behavior:
- required
hosts object/array Hosts to add to all host groups.

The hosts must have only the hostid property defined.

Return values

(object) Returns an object containing the IDs of the updated host groups under the groupids property.

Examples

Adding hosts to host groups

Add two hosts to host groups with IDs 5 and 6.

Request:

{
           "jsonrpc": "2.0",
           "method": "hostgroup.massadd",
           "params": {
               "groups": [
                   {
                       "groupid": "5"
                   },
                   {
                       "groupid": "6"
                   }
               ],
               "hosts": [
                   {
                       "hostid": "30050"
                   },
                   {
                       "hostid": "30001"
                   }
               ]
           },
           "id": 1
       }

Response:

{
           "jsonrpc": "2.0",
           "result": {
               "groupids": [
                   "5",
                   "6"
               ]
           },
           "id": 1
       }

See also

Source

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