post-calendar-event.asciidoc 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  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. <<security-privileges>> and {ml-docs-setup-privileges}.
  17. [[ml-post-calendar-event-desc]]
  18. == {api-description-title}
  19. This API accepts a list of {ml-docs}/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)
  25. include::../../ml-shared.asciidoc[tag=calendar-id]
  26. [role="child_attributes"]
  27. [[ml-post-calendar-event-request-body]]
  28. == {api-request-body-title}
  29. `events`::
  30. (Required, array) A list of one of more scheduled events. The event's start and
  31. end times may be specified as integer milliseconds since the epoch or as a
  32. string in ISO 8601 format.
  33. +
  34. .Properties of events
  35. [%collapsible%open]
  36. ====
  37. `description`:::
  38. (Optional, string) A description of the scheduled event.
  39. `end_time`:::
  40. (Required, date) The timestamp for the end of the scheduled event in
  41. milliseconds since the epoch or ISO 8601 format.
  42. `start_time`:::
  43. (Required, date) The timestamp for the beginning of the scheduled event in
  44. milliseconds since the epoch or ISO 8601 format.
  45. ====
  46. [[ml-post-calendar-event-example]]
  47. == {api-examples-title}
  48. [source,console]
  49. --------------------------------------------------
  50. POST _ml/calendars/planned-outages/events
  51. {
  52. "events" : [
  53. {"description": "event 1", "start_time": 1513641600000, "end_time": 1513728000000},
  54. {"description": "event 2", "start_time": 1513814400000, "end_time": 1513900800000},
  55. {"description": "event 3", "start_time": 1514160000000, "end_time": 1514246400000}
  56. ]
  57. }
  58. --------------------------------------------------
  59. // TEST[skip:setup:calendar_outages_addjob]
  60. The API returns the following results:
  61. [source,console-result]
  62. ----
  63. {
  64. "events": [
  65. {
  66. "description": "event 1",
  67. "start_time": 1513641600000,
  68. "end_time": 1513728000000,
  69. "calendar_id": "planned-outages"
  70. },
  71. {
  72. "description": "event 2",
  73. "start_time": 1513814400000,
  74. "end_time": 1513900800000,
  75. "calendar_id": "planned-outages"
  76. },
  77. {
  78. "description": "event 3",
  79. "start_time": 1514160000000,
  80. "end_time": 1514246400000,
  81. "calendar_id": "planned-outages"
  82. }
  83. ]
  84. }
  85. ----