template.massupdate

描述

object template.massupdate(object parameters)

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

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

参数

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

该方法接受以下参数。

Parameter Type Description
templates object/array 要更新的模板

模板必须仅定义 templateid 属性。

参数行为
- required
groups object/array 要替换模板当前所属模板组的对象。

模板组必须仅定义 groupid 属性。
macros object/array 用于替换给定模板上所有当前用户宏的用户宏
templates_clear object/array 要从给定模板中取消关联并清除的模板

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

模板必须仅定义 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 中。