批量更新

描述

object template.massupdate(object parameters)

该方法允许同时替换或移除相关对象,并更新多个模板的属性。

这个方法只有 管理员超级管理员 两个用户类型可用。可以在用户角色设置中取消调用该方法的权限。查看 [用户角色(/manual/web_interface/frontend_sections/users/user_roles) 获取更多信息。

参数

(object) 参数包含要更新的模板的ID以及要替换的对象。

这个方法接受下列参数。

参数类型描述
templatesobject/array要更新的模版

模版必须有已定义的 templateid 属性。

参数行为:
- 必需
groupsobject/array要替换模版所属的当前模版组的模版组。

模版组必须有已经定义的 groupid 属性。
macrosobject/array要替换给定模版上所有当前用户宏的用户宏用户宏
templates_clearobject/array要从给定模版中取消链接并清除的模版

模版必须有已定义的 templateid 属性。
templates_linkobject/array要替换当前链接的模版

模版必须有已定义的 templateid 属性。

返回值

(object) 返回一个对象,该对象包含templateids属性下已更新模板的ID。

示例

取消模板的链接

从给定的模板中取消链接并清除模板 “10091”。

请求:

  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. }

响应:

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

替换用户宏

在多个模板上用给定的用户宏替换所有用户宏。

请求:

  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. }

响应:

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

参阅

来源

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