post-calendar-event.asciidoc 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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. ==== Request
  10. `POST _ml/calendars/<calendar_id>/events`
  11. ==== Description
  12. This API accepts a list of {xpack-ref}/ml-calendars.html[scheduled events], each
  13. of which must have a start time, end time, and description.
  14. ==== Path Parameters
  15. `calendar_id` (required)::
  16. (string) Identifier for the calendar.
  17. ==== Request Body
  18. `events`::
  19. (array) A list of one of more scheduled events. The event's start and end times
  20. may be specified as integer milliseconds since the epoch or as a string in ISO 8601
  21. format. See <<ml-event-resource>>.
  22. ==== Authorization
  23. You must have `manage_ml`, or `manage` cluster privileges to use this API.
  24. For more information, see
  25. {xpack-ref}/security-privileges.html[Security Privileges].
  26. ==== Examples
  27. You can add scheduled events to the `planned-outages` calendar as follows:
  28. [source,js]
  29. --------------------------------------------------
  30. POST _ml/calendars/planned-outages/events
  31. {
  32. "events" : [
  33. {"description": "event 1", "start_time": 1513641600000, "end_time": 1513728000000},
  34. {"description": "event 2", "start_time": 1513814400000, "end_time": 1513900800000},
  35. {"description": "event 3", "start_time": 1514160000000, "end_time": 1514246400000}
  36. ]
  37. }
  38. --------------------------------------------------
  39. // CONSOLE
  40. // TEST[skip:setup:calendar_outages_addjob]
  41. The API returns the following results:
  42. [source,js]
  43. ----
  44. {
  45. "events": [
  46. {
  47. "description": "event 1",
  48. "start_time": 1513641600000,
  49. "end_time": 1513728000000,
  50. "calendar_id": "planned-outages"
  51. },
  52. {
  53. "description": "event 2",
  54. "start_time": 1513814400000,
  55. "end_time": 1513900800000,
  56. "calendar_id": "planned-outages"
  57. },
  58. {
  59. "description": "event 3",
  60. "start_time": 1514160000000,
  61. "end_time": 1514246400000,
  62. "calendar_id": "planned-outages"
  63. }
  64. ]
  65. }
  66. ----
  67. // TESTRESPONSE
  68. For more information about these properties, see
  69. <<ml-event-resource,Scheduled Event Resources>>.