put-lifecycle.asciidoc 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. [role="xpack"]
  2. [testenv="basic"]
  3. [[ilm-put-lifecycle]]
  4. === Create or update lifecycle policy API
  5. ++++
  6. <titleabbrev>Create or update lifecycle policy</titleabbrev>
  7. ++++
  8. Creates or updates lifecycle policy. See <<ilm-policy-definition>> for
  9. definitions of policy components.
  10. [[ilm-put-lifecycle-request]]
  11. ==== {api-request-title}
  12. `PUT _ilm/policy/<policy_id>`
  13. [[ilm-put-lifecycle-prereqs]]
  14. ==== {api-prereq-title}
  15. * If the {es} {security-features} are enabled, you must have the `manage_ilm`
  16. cluster privilege to use this API. You must also have the `manage` index
  17. privilege on all indices being managed by `policy`. {ilm-init} performs
  18. operations as the user who last updated the policy. {ilm-init} only has the
  19. <<defining-roles,roles>> assigned to the user at the time of the last policy
  20. update.
  21. [[ilm-put-lifecycle-desc]]
  22. ==== {api-description-title}
  23. Creates a lifecycle policy. If the specified policy exists, the policy is
  24. replaced and the policy version is incremented.
  25. NOTE: Only the latest version of the policy is stored, you cannot revert to
  26. previous versions.
  27. [[ilm-put-lifecycle-path-params]]
  28. ==== {api-path-parms-title}
  29. `<policy_id>`::
  30. (Required, string) Identifier for the policy.
  31. [[ilm-put-lifecycle-query-params]]
  32. ==== {api-query-parms-title}
  33. include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=timeoutparms]
  34. [[ilm-put-lifecycle-example]]
  35. ==== {api-examples-title}
  36. The following example creates a new policy named `my_policy`:
  37. [source,console]
  38. --------------------------------------------------
  39. PUT _ilm/policy/my_policy
  40. {
  41. "policy": {
  42. "phases": {
  43. "warm": {
  44. "min_age": "10d",
  45. "actions": {
  46. "forcemerge": {
  47. "max_num_segments": 1
  48. }
  49. }
  50. },
  51. "delete": {
  52. "min_age": "30d",
  53. "actions": {
  54. "delete": {}
  55. }
  56. }
  57. }
  58. }
  59. }
  60. --------------------------------------------------
  61. If the request succeeds, you receive the following result:
  62. [source,console-result]
  63. ----
  64. {
  65. "acknowledged": true
  66. }
  67. ----