Skip to content

Templates API ​

Template endpoints 用于管理 project 的 root template、groups、topics 和 rules。

GET /api/projects/:fullname/templates ​

返回 project templates。

参数:

参数位置说明
fullnamePathProject fullname。

Payload: 无。

响应:ProjectTemplate[]。

GET /api/projects/:fullname/template ​

返回 project root template。

参数:

参数位置说明
fullnamePathProject fullname。

Payload: 无。

响应:ProjectTemplate,或 not found。

POST /api/projects/:fullname/templates ​

为 project 创建 template/group。

参数:

参数位置说明
fullnamePathProject fullname。

Payload:

字段必填说明
project是Project fullname。
schema是Template inputs schema。
groups是Template groups 数组。
topics是Topics 数组。
rules是将 topics 绑定到 triggers 的 rules 数组。
meta.title是Template title。
meta.description是Template description。

响应:ProjectTemplate。

GET /api/projects/:fullname/templates/:id ​

返回 template。

参数:

参数位置说明
fullnamePathProject fullname。
idPathTemplate id。

Payload: 无。

响应:ProjectTemplate。

PUT /api/projects/:fullname/templates/:id ​

更新 template。

参数:

参数位置说明
fullnamePathProject fullname。
idPathTemplate id。

Payload: 与 POST /api/projects/:fullname/templates 相同结构。

响应:ProjectTemplate。

DELETE /api/projects/:fullname/templates/:id ​

删除 template。

参数:

参数位置说明
fullnamePathProject fullname。
idPathTemplate id。

Payload: 无。

响应:OperationResult。

Template Payload Details ​

groups ​

每个 group:

字段必填说明
name是Group name。
meta.title是可见标题。
meta.description是描述。

topics ​

每个 topic:

字段必填说明
name是Topic name。
group是Group name/fullname。
selectedByDefault是Topic 是否在 subscription wizard 中默认选中。
meta.title是可见标题。
meta.description否描述。

rules ​

每个 rule:

字段必填说明
id是Rule id。
trigger是Trigger fullname。
topic是Topic name。
inputs否Static input mapping 或 null。
policy否`{ type: "filter"
conditions否Conditions object 或 null。
deprecated是Rule 是否 deprecated。
requiredValues是此 rule 需要的 input keys。