get-calendar-event.asciidoc 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. [role="xpack"]
  2. [testenv="platinum"]
  3. [[ml-get-calendar-event]]
  4. === Get scheduled events API
  5. ++++
  6. <titleabbrev>Get scheduled events</titleabbrev>
  7. ++++
  8. Retrieves information about the scheduled events in calendars.
  9. [[ml-get-calendar-event-request]]
  10. ==== {api-request-title}
  11. `GET _ml/calendars/<calendar_id>/events` +
  12. `GET _ml/calendars/_all/events`
  13. [[ml-get-calendar-event-prereqs]]
  14. ==== {api-prereq-title}
  15. * If the {es} {security-features} are enabled, you must have `monitor_ml`,
  16. `monitor`, `manage_ml`, or `manage` cluster privileges to use this API. See
  17. <<security-privileges>>.
  18. [[ml-get-calendar-event-desc]]
  19. ==== {api-description-title}
  20. You can get scheduled event information for a single calendar or for all
  21. calendars by using `_all`.
  22. For more information, see
  23. {ml-docs}/ml-calendars.html[Calendars and scheduled events].
  24. [[ml-get-calendar-event-path-parms]]
  25. ==== {api-path-parms-title}
  26. `<calendar_id>`::
  27. (Required, string) Identifier for the calendar.
  28. [[ml-get-calendar-event-request-body]]
  29. ==== {api-request-body-title}
  30. `end`::
  31. (Optional, string) Specifies to get events with timestamps earlier than this
  32. time.
  33. `from`::
  34. (Optional, integer) Skips the specified number of events.
  35. `size`::
  36. (Optional, integer) Specifies the maximum number of events to obtain.
  37. `start`::
  38. (Optional, string) Specifies to get events with timestamps after this time.
  39. [[ml-get-calendar-event-results]]
  40. ==== {api-response-body-title}
  41. The API returns the following information:
  42. `events`::
  43. (array) An array of scheduled event resources. An events resource has the
  44. following properties:
  45. `calendar_id`:::
  46. (string) An identifier for the calendar that contains the scheduled
  47. event.
  48. `description`:::
  49. (string) A description of the scheduled event.
  50. `end_time`:::
  51. (date) The timestamp for the end of the scheduled event
  52. in milliseconds since the epoch or ISO 8601 format.
  53. `event_id`:::
  54. (string) An automatically-generated identifier for the scheduled event.
  55. `start_time`:::
  56. (date) The timestamp for the beginning of the scheduled event
  57. in milliseconds since the epoch or ISO 8601 format.
  58. [[ml-get-calendar-event-example]]
  59. ==== {api-examples-title}
  60. The following example gets information about the scheduled events in the
  61. `planned-outages` calendar:
  62. [source,console]
  63. --------------------------------------------------
  64. GET _ml/calendars/planned-outages/events
  65. --------------------------------------------------
  66. // TEST[skip:setup:calendar_outages_addevent]
  67. The API returns the following results:
  68. [source,console-result]
  69. ----
  70. {
  71. "count": 3,
  72. "events": [
  73. {
  74. "description": "event 1",
  75. "start_time": 1513641600000,
  76. "end_time": 1513728000000,
  77. "calendar_id": "planned-outages",
  78. "event_id": "LS8LJGEBMTCMA-qz49st"
  79. },
  80. {
  81. "description": "event 2",
  82. "start_time": 1513814400000,
  83. "end_time": 1513900800000,
  84. "calendar_id": "planned-outages",
  85. "event_id": "Li8LJGEBMTCMA-qz49st"
  86. },
  87. {
  88. "description": "event 3",
  89. "start_time": 1514160000000,
  90. "end_time": 1514246400000,
  91. "calendar_id": "planned-outages",
  92. "event_id": "Ly8LJGEBMTCMA-qz49st"
  93. }
  94. ]
  95. }
  96. ----
  97. // TESTRESPONSE[s/LS8LJGEBMTCMA-qz49st/$body.$_path/]
  98. // TESTRESPONSE[s/Li8LJGEBMTCMA-qz49st/$body.$_path/]
  99. // TESTRESPONSE[s/Ly8LJGEBMTCMA-qz49st/$body.$_path/]