post-calendar-event.asciidoc 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  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-prereqs]]
  13. ==== {api-prereq-title}
  14. * If the {es} {security-features} are enabled, you must have `manage_ml` or
  15. `manage` cluster privileges to use this API. See
  16. {stack-ov}/security-privileges.html[Security privileges].
  17. [[ml-post-calendar-event-desc]]
  18. ==== {api-description-title}
  19. This API accepts a list of {stack-ov}/ml-calendars.html[scheduled events], each
  20. of which must have a start time, end time, and description.
  21. [[ml-post-calendar-event-path-parms]]
  22. ==== {api-path-parms-title}
  23. `<calendar_id>`::
  24. (Required, string) Identifier for the calendar.
  25. [[ml-post-calendar-event-request-body]]
  26. ==== {api-request-body-title}
  27. `events`::
  28. (Required, array) A list of one of more scheduled events. The event's start
  29. and end times may be specified as integer milliseconds since the epoch or as a
  30. string in ISO 8601 format. An event resource has the following properties:
  31. `calendar_id`:::
  32. (Optional, string) An identifier for the calendar that contains the scheduled
  33. event.
  34. `description`:::
  35. (Optional, string) A description of the scheduled event.
  36. `end_time`:::
  37. (Required, date) The timestamp for the end of the scheduled event
  38. in milliseconds since the epoch or ISO 8601 format.
  39. `start_time`:::
  40. (Required, date) The timestamp for the beginning of the scheduled event
  41. in milliseconds since the epoch or ISO 8601 format.
  42. [[ml-post-calendar-event-example]]
  43. ==== {api-examples-title}
  44. You can add scheduled events to the `planned-outages` calendar as follows:
  45. [source,js]
  46. --------------------------------------------------
  47. POST _ml/calendars/planned-outages/events
  48. {
  49. "events" : [
  50. {"description": "event 1", "start_time": 1513641600000, "end_time": 1513728000000},
  51. {"description": "event 2", "start_time": 1513814400000, "end_time": 1513900800000},
  52. {"description": "event 3", "start_time": 1514160000000, "end_time": 1514246400000}
  53. ]
  54. }
  55. --------------------------------------------------
  56. // CONSOLE
  57. // TEST[skip:setup:calendar_outages_addjob]
  58. The API returns the following results:
  59. [source,console-result]
  60. ----
  61. {
  62. "events": [
  63. {
  64. "description": "event 1",
  65. "start_time": 1513641600000,
  66. "end_time": 1513728000000,
  67. "calendar_id": "planned-outages"
  68. },
  69. {
  70. "description": "event 2",
  71. "start_time": 1513814400000,
  72. "end_time": 1513900800000,
  73. "calendar_id": "planned-outages"
  74. },
  75. {
  76. "description": "event 3",
  77. "start_time": 1514160000000,
  78. "end_time": 1514246400000,
  79. "calendar_id": "planned-outages"
  80. }
  81. ]
  82. }
  83. ----