get-lifecycle.asciidoc 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. [role="xpack"]
  2. [testenv="basic"]
  3. [[ilm-get-lifecycle]]
  4. === Get Lifecycle Policy API
  5. ++++
  6. <titleabbrev>Get Policy</titleabbrev>
  7. ++++
  8. beta[]
  9. Retrieves a lifecycle policy.
  10. ==== Request
  11. `GET _ilm/policy`
  12. `GET _ilm/policy/<policy_id>`
  13. ==== Description
  14. Returns the specified policy definition. Includes the policy version and last
  15. modified date. If no policy is specified, returns all defined policies.
  16. ==== Path Parameters
  17. `policy` (optional)::
  18. (string) Identifier for the policy.
  19. ==== Request Parameters
  20. include::{docdir}/rest-api/timeoutparms.asciidoc[]
  21. ==== Authorization
  22. include::ilm-cluster-mgt-privilege.asciidoc[]
  23. ==== Examples
  24. The following example retrieves `my_policy`:
  25. //////////////////////////
  26. [source,js]
  27. --------------------------------------------------
  28. PUT _ilm/policy/my_policy
  29. {
  30. "policy": {
  31. "phases": {
  32. "warm": {
  33. "min_age": "10d",
  34. "actions": {
  35. "forcemerge": {
  36. "max_num_segments": 1
  37. }
  38. }
  39. },
  40. "delete": {
  41. "min_age": "30d",
  42. "actions": {
  43. "delete": {}
  44. }
  45. }
  46. }
  47. }
  48. }
  49. --------------------------------------------------
  50. // CONSOLE
  51. // TEST
  52. //////////////////////////
  53. [source,js]
  54. --------------------------------------------------
  55. GET _ilm/policy
  56. --------------------------------------------------
  57. // CONSOLE
  58. // TEST[continued]
  59. If the request succeeds, the body of the response contains the policy definition:
  60. [source,js]
  61. --------------------------------------------------
  62. {
  63. "my_policy": {
  64. "version": 1, <1>
  65. "modified_date": 82392349, <2>
  66. "policy": {
  67. "phases": {
  68. "warm": {
  69. "min_age": "10d",
  70. "actions": {
  71. "forcemerge": {
  72. "max_num_segments": 1
  73. }
  74. }
  75. },
  76. "delete": {
  77. "min_age": "30d",
  78. "actions": {
  79. "delete": {}
  80. }
  81. }
  82. }
  83. }
  84. }
  85. }
  86. --------------------------------------------------
  87. // CONSOLE
  88. // TESTRESPONSE[s/"modified_date": 82392349/"modified_date": $body.my_policy.modified_date/]
  89. <1> The policy version is incremented whenever the policy is updated
  90. <2> When this policy was last modified