更新

描述

object template.update(object/array templates)

这个方法可以更新已经存在的模版。

这个方法只有 管理员超级管理员 用户类型可以使用。可以在用户角色设置中取消调用该方法的权限。查看 用户角色获取更多信息。

参数

(object/array) 要更新的模版属性。

每个模版必须定义 templateid属性,其他所有的属性都是可选的。只有给定的属性将被更新,其他所有属性将保持不变。

除了 标准模版属性, 这个方法还接受下列参数。

参数类型描述
groupsobject/array模版组 用于替换当前模版所属的模版组。

模板组必须只定义 groupid 属性。
tagsobject/array模版标签 用于替换当前模版的标签。
macrosobject/array用户宏用于替换当前给定模版的用户宏。
templatesobject/array模版 用于替换当前链接的模版。未传递的模版将只是取消链接。

模版必需只定义 templateid 属性。
templates_clearobject/array模版 用于取消链接并清除给定的模版。

模版必须只定义templateid属性。

返回值

(object) 返回一个对象,该对象包含templateids属性下已更新模板的ID。

示例

重命名模版

将模版重命名为 “Template OS Linux”。

请求:

  1. {
  2. "jsonrpc": "2.0",
  3. "method": "template.update",
  4. "params": {
  5. "templateid": "10086",
  6. "name": "Template OS Linux"
  7. },
  8. "id": 1
  9. }

响应:

  1. {
  2. "jsonrpc": "2.0",
  3. "result": {
  4. "templateids": [
  5. "10086"
  6. ]
  7. },
  8. "id": 1
  9. }

更新模版标签

用一个新的标签替换所有模板标签。

请求:

  1. {
  2. "jsonrpc": "2.0",
  3. "method": "template.update",
  4. "params": {
  5. "templateid": "10086",
  6. "tags": [
  7. {
  8. "tag": "Host name",
  9. "value": "{HOST.NAME}"
  10. }
  11. ]
  12. },
  13. "id": 1
  14. }

响应:

  1. {
  2. "jsonrpc": "2.0",
  3. "result": {
  4. "templateids": [
  5. "10086"
  6. ]
  7. },
  8. "id": 1
  9. }

来源

CTemplate::update() 在 ui/include/classes/api/services/CTemplate.php.