添加事件到日历 API
编辑添加事件到日历 API
编辑在日历中发布计划事件。
请求
编辑POST _ml/calendars/<calendar_id>/events
前提条件
编辑需要 manage_ml
集群权限。此权限包含在 machine_learning_admin
内置角色中。
路径参数
编辑-
<calendar_id>
- (必需,字符串) 唯一标识日历的字符串。
请求体
编辑-
events
-
(必需,数组) 一个或多个计划事件的列表。事件的开始和结束时间可以指定为自 epoch 以来的整数毫秒数,或以 ISO 8601 格式的字符串。
事件的属性
-
description
- (可选,字符串) 计划事件的描述。
-
end_time
- (必需,日期) 计划事件结束的时间戳,以自 epoch 以来的毫秒数或 ISO 8601 格式表示。
-
start_time
- (必需,日期) 计划事件开始的时间戳,以自 epoch 以来的毫秒数或 ISO 8601 格式表示。
-
示例
编辑resp = client.ml.post_calendar_events( calendar_id="planned-outages", events=[ { "description": "event 1", "start_time": 1513641600000, "end_time": 1513728000000 }, { "description": "event 2", "start_time": 1513814400000, "end_time": 1513900800000 }, { "description": "event 3", "start_time": 1514160000000, "end_time": 1514246400000 } ], ) print(resp)
response = client.ml.post_calendar_events( calendar_id: 'planned-outages', body: { events: [ { description: 'event 1', start_time: 1_513_641_600_000, end_time: 1_513_728_000_000 }, { description: 'event 2', start_time: 1_513_814_400_000, end_time: 1_513_900_800_000 }, { description: 'event 3', start_time: 1_514_160_000_000, end_time: 1_514_246_400_000 } ] } ) puts response
const response = await client.ml.postCalendarEvents({ calendar_id: "planned-outages", events: [ { description: "event 1", start_time: 1513641600000, end_time: 1513728000000, }, { description: "event 2", start_time: 1513814400000, end_time: 1513900800000, }, { description: "event 3", start_time: 1514160000000, end_time: 1514246400000, }, ], }); console.log(response);
POST _ml/calendars/planned-outages/events { "events" : [ {"description": "event 1", "start_time": 1513641600000, "end_time": 1513728000000}, {"description": "event 2", "start_time": 1513814400000, "end_time": 1513900800000}, {"description": "event 3", "start_time": 1514160000000, "end_time": 1514246400000} ] }
该 API 返回以下结果
{ "events": [ { "description": "event 1", "start_time": 1513641600000, "end_time": 1513728000000, "calendar_id": "planned-outages" }, { "description": "event 2", "start_time": 1513814400000, "end_time": 1513900800000, "calendar_id": "planned-outages" }, { "description": "event 3", "start_time": 1514160000000, "end_time": 1514246400000, "calendar_id": "planned-outages" } ] }