On this page
/api/annotation/bulk
*注意:(2.1 版)*批量端点允许在单个调用中添加,更新或删除多个 Comments。注解更新必须通过 PUT 或 POST 作为内容数据发送。 POST
或GET
不支持查询字符串请求。每个 Comments 都将单独处理并与后端同步。如果其中一个 Comments 有错误(例如缺少字段),则将返回异常,并且某些 Comments 可能不会写入存储。在这种情况下,错误的 Comments 应该被修复,所有的 Comments 都应重新发送。
在指定的时间范围内,注解也可以批量删除。如果提供一个或多个 TSUID 的列表,则属于指定 TSUID 且属于指定时间范围的start time
的 Comments 将被删除。或者,可以设置global
标志,并且将删除该范围内的所有全局 Comments(与时间序列不相关的 Comments)。
Verbs
POST-创建或修改 Comments
PUT-创建或替换 Comments
删除-删除时间范围内的 Comments
Requests
用于发布或更新 Comments 的字段记录在/api/annotation上
批量删除请求的字段定义如下:
Name | Data Type | Required | Description | Default | QS | RW | Example |
---|---|---|---|---|---|---|---|
startTime | Integer | Required | 请求开始的时间戳。根据日期和时间,时间戳可以是相对的或绝对的。 | start_time | RO | 1369141261 | |
endTime | Integer | Optional | 事件的可选结束时间(如果已完成或已解决)。根据日期和时间,时间戳可以是相对的或绝对的。 | end_time | RO | 1369141262 | |
tsuids | Array | Optional | 带有应删除的带有 Comments 的 TSUID 的列表。对于 JSON,它可以为空或为 null(在 JSON 中),应设置global 标志。使用查询字符串时,请用逗号分隔 TSUID。 |
tsuids | RO | 000001000001000001, 000001000001000002 | |
global | Boolean | Optional | 是否应删除该范围的全局 Comments | false | global | RO | true |
Warning
如果您的请求使用PUT
,那么您未随请求提供的任何字段都将被其默认值覆盖。例如,description
字段将被设置为空字符串,而custom
字段将被重置为null
。
POST/PUT 请求示例
[
{
"startTime":"1369141261",
"tsuid":"000001000001000001",
"description": "Testing Annotations",
"notes": "These would be details about the event, the description is just a summary",
"custom": {
"owner": "jdoe",
"dept": "ops"
}
},
{
"startTime":"1369141261",
"tsuid":"000001000001000002",
"description": "Second annotation on different TSUID",
"notes": "Additional details"
}
]
DELETE QS 请求示例
/api/annotation/bulk?start_time=1d-ago&end_time=1h-ago&method_override=delete&tsuids=000001000001000001,000001000001000002
删除请求示例
{
"tsuids": [
"000001000001000001",
"000001000001000002"
],
"global": false,
"startTime": 1389740544690,
"endTime": 1389823344698,
"totalDeleted": 0
}
Response
对POST
或PUT
请求的成功响应将在同步后返回 Comments 列表(即,如果发出POST
调用,则现有对象将与新对象合并)。删除请求将返回一个带有删除查询的对象和一个totalDeleted
字段,该字段的整数表示已删除的 Comments 总数。如果提供了无效数据,将在错误对象的details
字段中返回400
错误以及引起错误的特定 Comments。
POST/PUT 响应示例
[
{
"tsuid": "000001000001000001",
"description": "Testing Annotations",
"notes": "These would be details about the event, the description is just a summary",
"custom": {
"owner": "jdoe",
"dept": "ops"
},
"endTime": 0,
"startTime": 1369141261
},
{
"tsuid": "000001000001000002",
"description": "Second annotation on different TSUID",
"notes": "Additional details",
"custom": null,
"endTime": 0,
"startTime": 1369141261
}
]
删除响应示例
{
"tsuids": [
"000001000001000001",
"000001000001000002"
],
"global": false,
"startTime": 1389740544690,
"endTime": 1389823344698,
"totalDeleted": 42
}