template.create

描述

object template.create(object/array templates)

此方法允许create新模板。

此方法仅对管理员(Admin)超级管理员(Super admin)用户类型可用。调用该方法的权限可以在用户角色设置中撤销。更多信息请参见User roles

参数

(object/array) 用于创建的模板。

除了 模板 外, 该方法还接受以下参数。

参数 数据类型 描述
groups object/array 要添加到模板的 Template groups

模板组必须仅定义 groupid 属性。

参数行为
- 必填
tags object/array 模板标签
templates object/array 要链接到模板的 Templates

模板必须仅定义 templateid 属性。
macros object/array 为模板创建的 User macros

返回值

(object) 返回一个 object,其中包含在 templateids 属性下列出的已创建模板的 ID。返回的 ID 顺序与传入的模板顺序一致。

示例

创建模板

创建一个带有标签的模板,并将两个模板链接到此模板。

执行请求:

{
    "jsonrpc": "2.0",
    "method": "template.create",
    "params": {
        "host": "Linux template",
        "groups": {
            "groupid": 1
        },
        "templates": [
            {
                "templateid": "11115"
            },
            {
                "templateid": "11116"
            }
        ],
        "tags": [
            {
                "tag": "host-name",
                "value": "{HOST.NAME}"
            }
        ]
    },
    "id": 1
}

响应:

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

来源

CTemplate::create() 在 ui/include/classes/api/services/CTemplate.php 中。