hostgroup.massadd

Description

object hostgroup.massadd(object **parameters**)

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

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.

ParameterTypeDescription
groups
(required)
object/arrayHost groups to be updated.

The host groups must have the groupid property defined.
hostsobject/arrayHosts to add to all host groups.

The hosts must have the hostid property defined.
templatesobject/arrayTemplates to add to all host groups.

The templates must have the templateid 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:

  1. {
  2. "jsonrpc": "2.0",
  3. "method": "hostgroup.massadd",
  4. "params": {
  5. "groups": [
  6. {
  7. "groupid": "5"
  8. },
  9. {
  10. "groupid": "6"
  11. }
  12. ],
  13. "hosts": [
  14. {
  15. "hostid": "30050"
  16. },
  17. {
  18. "hostid": "30001"
  19. }
  20. ]
  21. },
  22. "auth": "f223adf833b2bf2ff38574a67bba6372",
  23. "id": 1
  24. }

Response:

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

See also

Source

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