get-lifecycle.asciidoc 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. [role="xpack"]
  2. [testenv="basic"]
  3. [[ilm-get-lifecycle]]
  4. === Get lifecycle policy API
  5. ++++
  6. <titleabbrev>Get policy</titleabbrev>
  7. ++++
  8. Retrieves a lifecycle policy.
  9. [[ilm-get-lifecycle-request]]
  10. ==== {api-request-title}
  11. `GET _ilm/policy`
  12. `GET _ilm/policy/<policy_id>`
  13. [[ilm-get-lifecycle-prereqs]]
  14. ==== {api-prereq-title}
  15. * If the {es} {security-features} are enabled, you must have the `manage_ilm` or
  16. `read_ilm` or both cluster privileges to use this API. For more information, see
  17. <<security-privileges>>.
  18. [[ilm-get-lifecycle-desc]]
  19. ==== {api-description-title}
  20. Returns the specified policy definition. Includes the policy version and last
  21. modified date. If no policy is specified, returns all defined policies.
  22. [[ilm-get-lifecycle-path-params]]
  23. ==== {api-path-parms-title}
  24. `<policy_id>`::
  25. (Optional, string) Identifier for the policy.
  26. [[ilm-get-lifecycle-query-params]]
  27. ==== {api-query-parms-title}
  28. include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=timeoutparms]
  29. [[ilm-get-lifecycle-example]]
  30. ==== {api-examples-title}
  31. The following example retrieves `my_policy`:
  32. //////////////////////////
  33. [source,console]
  34. --------------------------------------------------
  35. PUT _ilm/policy/my_policy
  36. {
  37. "policy": {
  38. "phases": {
  39. "warm": {
  40. "min_age": "10d",
  41. "actions": {
  42. "forcemerge": {
  43. "max_num_segments": 1
  44. }
  45. }
  46. },
  47. "delete": {
  48. "min_age": "30d",
  49. "actions": {
  50. "delete": {}
  51. }
  52. }
  53. }
  54. }
  55. }
  56. --------------------------------------------------
  57. //////////////////////////
  58. [source,console]
  59. --------------------------------------------------
  60. GET _ilm/policy/my_policy
  61. --------------------------------------------------
  62. // TEST[continued]
  63. If the request succeeds, the body of the response contains the policy definition:
  64. [source,console-result]
  65. --------------------------------------------------
  66. {
  67. "my_policy": {
  68. "version": 1, <1>
  69. "modified_date": 82392349, <2>
  70. "policy": {
  71. "phases": {
  72. "warm": {
  73. "min_age": "10d",
  74. "actions": {
  75. "forcemerge": {
  76. "max_num_segments": 1
  77. }
  78. }
  79. },
  80. "delete": {
  81. "min_age": "30d",
  82. "actions": {
  83. "delete": {
  84. "delete_searchable_snapshot": true
  85. }
  86. }
  87. }
  88. }
  89. }
  90. }
  91. }
  92. --------------------------------------------------
  93. // TESTRESPONSE[s/"modified_date": 82392349/"modified_date": $body.my_policy.modified_date/]
  94. <1> The policy version is incremented whenever the policy is updated
  95. <2> When this policy was last modified