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



object template.update(object/array templates)

This method allows to update existing templates此方法允许更新现有模板.


(object/array) Template properties to be updated要更新的模板属性.

The templateid property must be defined for each template, all other properties are optional. Only the given properties will be updated, all others will remain unchanged. 必须为每个模板定义templateid属性,所有其他属性都是可选的。只有给定的属性将被更新,所有其他属性将保持不变。

Additionally to the standard template properties, the method accepts the following parameters. 除standard template properties之外,该方法接受以下参数。

Parameter参数 T pe类型 Des ription说明
groups object/array Host groups to replace the current host groups the templates belong to主机组替换模板所属的当前主机组.

The host groups must have the groupid property defined主机组必须定义groupid属性.
hosts object/array Hosts and templates to replace the ones the templates are currently linked to主机和模板来替换当前链接到的模板.

Both hosts and templates must use the hostid property to pass an ID主机和模板都必须使用hostid属性传递一个ID.
macros object/array User macros to replace the current user macros on the given templates用户宏替换给定模板上的当前用户宏.
templates object/array Templates to replace the currently linked templates. Templates that are not passed are only unlinked.用于替换当前链接的模板的模板,不通过的模板仅被取消链接

The templates must have the templateid property defined模板必须定义templateid属性.
templates_clear object/array Templates to unlink and clear from the given templates从指定模板中取消链接和清除的模板.

The templates must have the templateid property defined模板必须定义templateid属性.

Return values返回值

(object) Returns an object containing the IDs of the updated templates under the templateids property. (object)返回一个对象,它包含templateids属性下更新的模板的ID.


Renaming a template重命名模板

Rename the template to "Template OS Linux"将模板重命名为"Template OS Linux".


           "jsonrpc": "2.0",
           "method": "template.update",
           "params": {
               "templateid": "10086",
               "name": "Template OS Linux"
           "auth": "038e1d7b1735c6a5436ee9eae095879e",
           "id": 1


           "jsonrpc": "2.0",
           "result": {
               "templateids": [
           "id": 1


CTemplate::update() in frontends/php/include/classes/api/services/CTemplate.php.