post-calendar-event.asciidoc 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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 _xpack/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. See <<ml-event-resource>>.
  20. ==== Authorization
  21. You must have `manage_ml`, or `manage` cluster privileges to use this API.
  22. For more information, see
  23. {xpack-ref}/security-privileges.html[Security Privileges].
  24. ==== Examples
  25. You can add scheduled events to the `planned-outages` calendar as follows:
  26. [source,js]
  27. --------------------------------------------------
  28. POST _xpack/ml/calendars/planned-outages/events
  29. {
  30. "events" : [
  31. {"description": "event 1", "start_time": 1513641600000, "end_time": 1513728000000},
  32. {"description": "event 2", "start_time": 1513814400000, "end_time": 1513900800000},
  33. {"description": "event 3", "start_time": 1514160000000, "end_time": 1514246400000}
  34. ]
  35. }
  36. --------------------------------------------------
  37. // CONSOLE
  38. // TEST[skip:setup:calendar_outages_addjob]
  39. The API returns the following results:
  40. [source,js]
  41. ----
  42. {
  43. "events": [
  44. {
  45. "description": "event 1",
  46. "start_time": 1513641600000,
  47. "end_time": 1513728000000,
  48. "calendar_id": "planned-outages"
  49. },
  50. {
  51. "description": "event 2",
  52. "start_time": 1513814400000,
  53. "end_time": 1513900800000,
  54. "calendar_id": "planned-outages"
  55. },
  56. {
  57. "description": "event 3",
  58. "start_time": 1514160000000,
  59. "end_time": 1514246400000,
  60. "calendar_id": "planned-outages"
  61. }
  62. ]
  63. }
  64. ----
  65. // TESTRESPONSE
  66. For more information about these properties, see
  67. <<ml-event-resource,Scheduled Event Resources>>.