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

批量删除

Description 说明

object template.massremove(object parameters)

This method allows to remove related objects from multiple templates. 方法允许从多个模板中删除相关对象。

Parameters 参数

(object) Parameters containing the IDs of the templates to update and the objects that should be removed. (object)参数包含需要更新的模板ID以及需要删除的对象。

Parameter 参数 T pe 类型 Des ription 说明
templateids
(required 必须)
string/array 字符串/数组 IDs f the templates to be updated. 将要更新的模板ID。
groupids string/array 字符串/数组 Host groups to remove the given templates from. 从指定的模板中删除主机组。
hostids string/array 字符串/数组 Host or templates to unlink the given templates from (downstream). 从主机或模板中取消指定模板(下游)的链接。
macros string/array 字符串/数组 User macros to delete from the given templates. 删除指定模板的用户宏。
templateids_clear string/array 字符串/数组 Temp ates to unlink and clear from the given templates (upstream). 从指定模板(上游)中取消模板链接并清除数据。
templateids_link string/array 字符串/数组 Temp ates to unlink from the given templates (upstream). 从指定模板(上游)中取消模板链接。

Return values 返回值

(object) Returns an object containing the IDs of the updated templates under the templateids property. (object)返回一个对象,此对象包含在templateids中已更新模板的ID。

Examples 范例

Removing templates from a group 从组中删除模板

Remove two templates from group "2". 从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
       }

Unlinking templates from a host 主机中取消模板链接

Unlink template "10085" from two hosts. 从两台主机中取消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
       }

See also 参考

Source 源码

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