hostgroup.massupdate

Description

object hostgroup.massupdate(object **parameters**)

This method allows to simultaneously replace or remove related objects for multiple host groups.

Parameters

(object) Parameters containing the IDs of the host groups to update and the objects that should be updated.

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

The host groups must have the groupid property defined.
hostsobject/arrayHosts to replace the current hosts on the given host groups.

The hosts must have the hostid property defined.
templatesobject/arrayTemplates to replace the current templates on the given 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

Replacing hosts in a host group

Replace all hosts in the host group with ID.

Request:

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

Response:

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

See also

Source

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