template.massupdate

Description

object template.massupdate(object parameters)

This method allows to simultaneously replace or remove related objects and update properties on multiple templates.

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 templates to update and the objects to replace for the templates.

The method accepts the following parameters.

ParameterTypeDescription
templatesobject/arrayTemplates to be updated.

The templates must have the templateid property defined.

Parameter behavior:
- required
groupsobject/arrayTemplate groups to replace the current template groups the templates belong to.

The template groups must have the groupid property defined.
macrosobject/arrayUser macros to replace all of the current user macros on the given templates.
templates_clearobject/arrayTemplates to unlink and clear from the given templates.

The templates must have the templateid property defined.
templates_linkobject/arrayTemplates to replace the currently linked templates.

The templates must have the templateid property defined.

Return values

(object) Returns an object containing the IDs of the updated templates under the templateids property.

Examples

Unlinking a template

Unlink and clear template “10091” from the given templates.

Request:

  1. {
  2. "jsonrpc": "2.0",
  3. "method": "template.massupdate",
  4. "params": {
  5. "templates": [
  6. {
  7. "templateid": "10085"
  8. },
  9. {
  10. "templateid": "10086"
  11. }
  12. ],
  13. "templates_clear": [
  14. {
  15. "templateid": "10091"
  16. }
  17. ]
  18. },
  19. "id": 1
  20. }

Response:

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

Replacing user macros

Replace all user macros with the given user macro on multiple templates.

Request:

  1. {
  2. "jsonrpc": "2.0",
  3. "method": "template.massupdate",
  4. "params": {
  5. "templates": [
  6. {
  7. "templateid": "10074"
  8. },
  9. {
  10. "templateid": "10075"
  11. },
  12. {
  13. "templateid": "10076"
  14. },
  15. {
  16. "templateid": "10077"
  17. }
  18. ],
  19. "macros": [
  20. {
  21. "macro": "{$AGENT.TIMEOUT}",
  22. "value": "5m",
  23. "description": "Timeout after which agent is considered unavailable. Works only for agents reachable from Zabbix server/proxy (passive mode)."
  24. }
  25. ]
  26. },
  27. "id": 1
  28. }

Response:

  1. {
  2. "jsonrpc": "2.0",
  3. "result": {
  4. "templateids": [
  5. "10074",
  6. "10075",
  7. "10076",
  8. "10077"
  9. ]
  10. },
  11. "id": 1
  12. }

See also

Source

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