1
0

get-lifecycle.asciidoc 2.1 KB

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