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

批量更新

说明

object template.massupdate(object parameters)

此方法允许同时替换或删除相关对象并更新多个模板上的属性。

参数

(object)参数包含需要更新的模板ID以及需要更新的属性。

standard template properties之外,该方法接受以下参数。

参数 类 说明
templates
(required 必须)
object/array模 需要更新的模板。
必须已定义templateid属性。
groups object/array 替换所属模板的当前主机组。
主机组必须已定义groupid属性。
hosts object/array 替换当前链接模板的主机和模板。
主机和模板都必须使用hostid属性传递唯一ID。
macros object/array 替换指定模板上的当前用户宏。
templates_clear object/array 从指定模板中取消链接并清除数据。
模板必须已定义templateid属性。
templates_link object/array 替换当前链接的模板。
模板必须已定义templateid属性。

返回值

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

范例

替换主机组

从指定的模板中取消链接并清除ID为"10091"的模板。

Request 请求:

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

Response 响应:

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

参考

源码

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