object template.update(object/array templates)
这个方法可以更新已经存在的模版。
这个方法只有 管理员 和 超级管理员 用户类型可以使用。可以在用户角色设置中取消调用该方法的权限。查看 用户角色获取更多信息。
(object/array) 要更新的模版属性。
每个模版必须定义 templateid属性,其他所有的属性都是可选的。只有给定的属性将被更新,其他所有属性将保持不变。
除了 标准模版属性, 这个方法还接受下列参数。
| 参数 | 类型 | 描述 | 
|---|---|---|
| groups | object/array | 模版组 用于替换当前模版所属的模版组。 模板组必须只定义 groupid 属性。 | 
       
| tags | object/array | 模版标签 用于替换当前模版的标签。 | 
| macros | object/array | 用户宏用于替换当前给定模版的用户宏。 | 
| templates | object/array | 模版 用于替换当前链接的模版。未传递的模版将只是取消链接。 模版必需只定义 templateid 属性。 | 
       
| templates_clear | object/array | 模版 用于取消链接并清除给定的模版。 模版必须只定义 templateid属性。 | 
       
(object) 返回一个对象,该对象包含templateids属性下已更新模板的ID。
Change the technical name of the template to "Linux by Zabbix agent Custom", the visible name to "My template", and update the template description.
{
           "jsonrpc": "2.0",
           "method": "template.update",
           "params": {
               "templateid": "10086",
               "host": "Linux by Zabbix agent Custom",
               "name": "My template",
               "description": "This is a custom Linux template."
           },
           "id": 1
       }Response:
Replace all template groups for the given template with a different one.
{
           "jsonrpc": "2.0",
           "method": "template.update",
           "params": {
               "templateid": "10086",
               "groups": [
                   {
                       "groupid": "24"
                   } 
               ]
           },
           "id": 1
       }Response:
用一个新的标签替换所有模板标签。
请求:
{
           "jsonrpc": "2.0",
           "method": "template.update",
           "params": {
               "templateid": "10086",
               "tags": [
                   {
                       "tag": "Host name",
                       "value": "{HOST.NAME}"
                   }
               ]
           },
           "id": 1
       }响应:
Replace all template macros with a different one.
{
           "jsonrpc": "2.0",
           "method": "template.update",
           "params": {
               "templateid": "10086",
               "macros": [
                   {
                       "macro": "{$MY_MACRO}",
                       "value": "new_value"
                   }
               ]
           },
           "id": 1
       }Response:
Unlink (without clearing) all templates from the given template and link a different one to it.
{
           "jsonrpc": "2.0",
           "method": "template.update",
           "params": {
               "templateid": "10086",
               "templates": [
                   {
                       "templateid": "10087"
                   }
               ]
           },
           "id": 1
       }Response:
Unlink and clear the given template from a specific linked template.
{
           "jsonrpc": "2.0",
           "method": "template.update",
           "params": {
               "templateid": "10086",
               "templates_clear": [
                   {
                       "templateid": "10087"
                   }
               ]
           },
           "id": 1
       }Response:
CTemplate::update() 在 ui/include/classes/api/services/CTemplate.php.