1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192 |
- [role="xpack"]
- [testenv="platinum"]
- [[ml-post-calendar-event]]
- === Add events to calendar API
- ++++
- <titleabbrev>Add events to calendar</titleabbrev>
- ++++
- Posts scheduled events in a calendar.
- [[ml-post-calendar-event-request]]
- ==== {api-request-title}
- `POST _ml/calendars/<calendar_id>/events`
- [[ml-post-calendar-event-desc]]
- ==== {api-description-title}
- This API accepts a list of {stack-ov}/ml-calendars.html[scheduled events], each
- of which must have a start time, end time, and description.
- [[ml-post-calendar-event-path-parms]]
- ==== {api-path-parms-title}
- `calendar_id` (required)::
- (string) Identifier for the calendar.
- [[ml-post-calendar-event-request-body]]
- ==== {api-request-body-title}
- `events`::
- (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. See <<ml-event-resource>>.
- [[ml-post-calendar-event-prereqs]]
- ==== {api-prereq-title}
- You must have `manage_ml`, or `manage` cluster privileges to use this API.
- For more information, see
- {stack-ov}/security-privileges.html[Security privileges].
- [[ml-post-calendar-event-example]]
- ==== {api-examples-title}
- You can add scheduled events to the `planned-outages` calendar as follows:
- [source,js]
- --------------------------------------------------
- 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}
- ]
- }
- --------------------------------------------------
- // CONSOLE
- // TEST[skip:setup:calendar_outages_addjob]
- The API returns the following results:
- [source,js]
- ----
- {
- "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"
- }
- ]
- }
- ----
- // TESTRESPONSE
- For more information about these properties, see
- <<ml-event-resource,Scheduled Event Resources>>.
|