/api/annotation/bulk

*注意:(2.1 版)*批量端点允许在单个调用中添加,更新或删除多个 Comments。注解更新必须通过 PUT 或 POST 作为内容数据发送。 POSTGET不支持查询字符串请求。每个 Comments 都将单独处理并与后端同步。如果其中一个 Comments 有错误(例如缺少字段),则将返回异常,并且某些 Comments 可能不会写入存储。在这种情况下,错误的 Comments 应该被修复,所有的 Comments 都应重新发送。

在指定的时间范围内,注解也可以批量删除。如果提供一个或多个 TSUID 的列表,则属于指定 TSUID 且属于指定时间范围的start time的 Comments 将被删除。或者,可以设置global标志,并且将删除该范围内的所有全局 Comments(与时间序列不相关的 Comments)。

Verbs

  • POST-创建或修改 Comments

  • PUT-创建或替换 Comments

  • 删除-删除时间范围内的 Comments

Requests

用于发布或更新 Comments 的字段记录在/api/annotation

批量删除请求的字段定义如下:

NameData TypeRequiredDescriptionDefaultQSRWExample
startTimeIntegerRequired请求开始的时间戳。根据日期和时间,时间戳可以是相对的或绝对的。 start_timeRO1369141261
endTimeIntegerOptional事件的可选结束时间(如果已完成或已解决)。根据日期和时间,时间戳可以是相对的或绝对的。 end_timeRO1369141262
tsuidsArrayOptional带有应删除的带有 Comments 的 TSUID 的列表。对于 JSON,它可以为空或为 null(在 JSON 中),应设置global标志。使用查询字符串时,请用逗号分隔 TSUID。 tsuidsRO000001000001000001, 000001000001000002
globalBooleanOptional是否应删除该范围的全局 CommentsfalseglobalROtrue

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

POSTPUT请求的成功响应将在同步后返回 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
}