template.update

Description说明

object template.update(object/array templates)

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

Parameters参数

(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参数 Type类型 Description说明
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.

Examples范例

Renaming a template重命名模板

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

Request请求:

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

Response响应:

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

Source来源

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