template.massupdate

描述

object template.massupdate(object parameters)

此方法允许在多个模板上同时替换或删除相关的 objects 和 update 属性。

此方法仅对 Admin(管理员)Super admin(超级管理员) 用户类型可用。 调用该方法的权限可以在用户角色设置中撤销。更多信息请参见 User roles

参数

(object) 包含要update的模板ID以及替换模板的objects的参数。

该方法接受以下参数:

参数 数据类型 描述
templates object/array 要更新的Templates

模板必须仅定义了templateid属性。

参数行为:
- 必填
groups object/array 替换模板当前所属模板组的Template groups

模板组必须仅定义了groupid属性。
macros object/array 替换给定模板上所有当前用户宏的User macros
templates_clear object/array 从给定模板中解除关联并clear的Templates

模板必须仅定义了templateid属性。
templates_link object/array 替换当前已关联模板的Templates

模板必须仅定义了templateid属性。

返回值

(object) 返回一个 object,其中包含更新后的模板ID, 位于 templateids 属性下。

示例

解除模板关联

解除给定模板与clear模板“10091”的链接。

执行请求:

{
           "jsonrpc": "2.0",
           "method": "template.massupdate",
           "params": {
               "templates": [
                   {
                       "templateid": "10085"
                   },
                   {
                       "templateid": "10086"
                   }
               ],
               "templates_clear": [
                   {
                       "templateid": "10091"
                   }
               ]
           },
           "id": 1
       }

响应:

{
           "jsonrpc": "2.0",
           "result": {
               "templateids": [
                   "10085",
                   "10086"
               ]
           },
           "id": 1
       }

替换用户宏

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

执行请求:

{
           "jsonrpc": "2.0",
           "method": "template.massupdate",
           "params": {
               "templates": [
                   {
                       "templateid": "10074"
                   },
                   {
                       "templateid": "10075"
                   },
                   {
                       "templateid": "10076"
                   },
                   {
                       "templateid": "10077"
                   }
               ],
               "macros": [
                   {
                       "macro": "{$AGENT.TIMEOUT}",
                       "value": "5m",
                       "description": "Timeout after which agent is considered unavailable. Works only for agents reachable from Zabbix server/proxy (passive mode)."
                   }
               ]
           },
           "id": 1
       }

响应:

{
           "jsonrpc": "2.0",
           "result": {
               "templateids": [
                   "10074",
                   "10075",
                   "10076",
                   "10077"
               ]
           },
           "id": 1
       }

另请参阅

来源

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