post-calendar-event.asciidoc 2.6 KB

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