这是原厂英文文档的翻译页面. 欢迎帮助我们 完善文档.
2022 Zabbix中国峰会
2022 Zabbix中国峰会

批量删除

说明

object template.massremove(object parameters)

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

参数

(object)参数包含需要更新的模板ID以及需要删除的对象。

参数 类 说明
templateids
(required 必须)
string/array 将要更新的模板ID。
groupids string/array 从指定的模板中删除主机组。
hostids string/array 从主机或模板中取消指定模板(下游)的链接。
macros string/array 删除指定模板的用户宏。
templateids_clear string/array 从指定模板(上游)中取消模板链接并清除数据。
templateids_link string/array 从指定模板(上游)中取消模板链接。

返回值

(object)返回一个对象,此对象包含在templateids中已更新模板的ID。

范例

从组中删除模板

从ID为"2"的组中删除两个模板。

Request 请求:

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

Response 响应:

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

主机中取消模板链接

从两台主机中取消ID为"10085"的模板链接。

Request 请求:

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

Response 响应:

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

参考

源码

CTemplate::massRemove()方法可在ui/include/classes/api/services/CTemplate.php中参考。