This documentation contains work-in-progress information for future Elastic Stack and Cloud releases. Use the version selector to view supported release docs. It also contains some Elastic Cloud serverless information. Check out our serverless docs for more details.
Add events to calendar API
editAdd events to calendar API
editPosts scheduled events in a calendar.
Request
editPOST _ml/calendars/<calendar_id>/events
Prerequisites
editRequires the manage_ml
cluster privilege. This privilege is included in the
machine_learning_admin
built-in role.
Description
editThis API accepts a list of scheduled events, each of which must have a start time, end time, and description.
Path parameters
edit-
<calendar_id>
- (Required, string) A string that uniquely identifies a calendar.
Request body
edit-
events
-
(Required, array) A list of one of more scheduled events. The event’s start and end times may be specified as integer milliseconds since the epoch or as a string in ISO 8601 format.
Properties of events
-
description
- (Optional, string) A description of the scheduled event.
-
end_time
- (Required, date) The timestamp for the end of the scheduled event in milliseconds since the epoch or ISO 8601 format.
-
start_time
- (Required, date) The timestamp for the beginning of the scheduled event in milliseconds since the epoch or ISO 8601 format.
-
Examples
editresp = 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} ] }
The API returns the following results:
{ "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" } ] }