2022 Zabbix中国峰会
2022 Zabbix中国峰会

批量删除模板

描述

object template.massremove(object parameters)

该方法允许从多个模板中移除相关对象。

这个方法只有 管理员超级管理员 用户类型可用。 可以在用户角色设置中取消调用该方法的权限。 查看 用户角色获取更多信息。

参数

(object) 参数包含要更新的模版的ID以及应该被移除的对象。

参数 类型 描述
templateids ID/array 要更新的 模版 ID 。

参数行为:
- 必需
groupids ID/array 要从中移除给定模版的template groups的ID。
macros string/array 要从给定模版中删除的用户宏的ID。
templateids_clear ID/array 要从给定模版中取消链接并清除的模版的ID(upstream)。
templateids_link ID/array 要从给定模版中取消链接的模版的ID(upstream)。

返回值

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

示例

从一个组中移除模版

将两个模版从模版组 "2" 中移除。

请求:

{
           "jsonrpc": "2.0",
           "method": "template.massremove",
           "params": {
               "templateids": [
                   "10085",
                   "10086"
               ],
               "groupids": "2"
           },
           "id": 1
       }

响应:

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

从主机上取消链接模版

取消模版 "10085" 上的链接的模版 "10106" 和 "10104" 。

请求:

{
           "jsonrpc": "2.0",
           "method": "template.massremove",
           "params": {
               "templateids": "10085",
               "templateids_link": [
                   "10106",
                   "10104"
               ]
           },
           "id": 1
       }

响应:

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

参阅

来源

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