post-calendar-event.asciidoc 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. [role="xpack"]
  2. [testenv="platinum"]
  3. [[ml-post-calendar-event]]
  4. === Add events to calendar API
  5. ++++
  6. <titleabbrev>Add events to calendar</titleabbrev>
  7. ++++
  8. Posts scheduled events in a calendar.
  9. [[ml-post-calendar-event-request]]
  10. ==== {api-request-title}
  11. `POST _ml/calendars/<calendar_id>/events`
  12. [[ml-post-calendar-event-desc]]
  13. ==== {api-description-title}
  14. This API accepts a list of {stack-ov}/ml-calendars.html[scheduled events], each
  15. of which must have a start time, end time, and description.
  16. [[ml-post-calendar-event-path-parms]]
  17. ==== {api-path-parms-title}
  18. `calendar_id` (required)::
  19. (string) Identifier for the calendar.
  20. [[ml-post-calendar-event-request-body]]
  21. ==== {api-request-body-title}
  22. `events`::
  23. (array) A list of one of more scheduled events. The event's start and end times
  24. may be specified as integer milliseconds since the epoch or as a string in ISO 8601
  25. format. See <<ml-event-resource>>.
  26. [[ml-post-calendar-event-prereqs]]
  27. ==== {api-prereq-title}
  28. You must have `manage_ml`, or `manage` cluster privileges to use this API.
  29. For more information, see
  30. {stack-ov}/security-privileges.html[Security privileges].
  31. [[ml-post-calendar-event-example]]
  32. ==== {api-examples-title}
  33. You can add scheduled events to the `planned-outages` calendar as follows:
  34. [source,js]
  35. --------------------------------------------------
  36. POST _ml/calendars/planned-outages/events
  37. {
  38. "events" : [
  39. {"description": "event 1", "start_time": 1513641600000, "end_time": 1513728000000},
  40. {"description": "event 2", "start_time": 1513814400000, "end_time": 1513900800000},
  41. {"description": "event 3", "start_time": 1514160000000, "end_time": 1514246400000}
  42. ]
  43. }
  44. --------------------------------------------------
  45. // CONSOLE
  46. // TEST[skip:setup:calendar_outages_addjob]
  47. The API returns the following results:
  48. [source,js]
  49. ----
  50. {
  51. "events": [
  52. {
  53. "description": "event 1",
  54. "start_time": 1513641600000,
  55. "end_time": 1513728000000,
  56. "calendar_id": "planned-outages"
  57. },
  58. {
  59. "description": "event 2",
  60. "start_time": 1513814400000,
  61. "end_time": 1513900800000,
  62. "calendar_id": "planned-outages"
  63. },
  64. {
  65. "description": "event 3",
  66. "start_time": 1514160000000,
  67. "end_time": 1514246400000,
  68. "calendar_id": "planned-outages"
  69. }
  70. ]
  71. }
  72. ----
  73. // TESTRESPONSE
  74. For more information about these properties, see
  75. <<ml-event-resource,Scheduled Event Resources>>.