OpenSearch/docs/reference/ilm/apis/put-lifecycle.asciidoc

84 lines
1.9 KiB
Plaintext
Raw Normal View History

[role="xpack"]
[testenv="basic"]
[[ilm-put-lifecycle]]
2018-12-20 13:23:28 -05:00
=== Create lifecycle policy API
++++
2018-12-20 13:23:28 -05:00
<titleabbrev>Create policy</titleabbrev>
++++
2019-11-20 11:19:33 -05:00
Creates or updates lifecycle policy. See <<ilm-policy-definition>> for
definitions of policy components.
2019-11-20 11:19:33 -05:00
[[ilm-put-lifecycle-request]]
==== {api-request-title}
`PUT _ilm/policy/<policy_id>`
2019-11-20 11:19:33 -05:00
[[ilm-put-lifecycle-prereqs]]
==== {api-prereq-title}
* If the {es} {security-features} are enabled, you must have the `manage_ilm`
cluster privilege to use this API. You must also have the `manage` index
privilege on all indices being managed by `policy`. All operations executed by
{ilm} for a policy are executed as the user that put the latest version of a
policy. For more information, see <<security-privileges>>.
[[ilm-put-lifecycle-desc]]
==== {api-description-title}
Creates a lifecycle policy. If the specified policy exists, the policy is
replaced and the policy version is incremented.
NOTE: Only the latest version of the policy is stored, you cannot revert to
previous versions.
2019-11-20 11:19:33 -05:00
[[ilm-put-lifecycle-path-params]]
==== {api-path-parms-title}
2019-11-20 11:19:33 -05:00
`<policy_id>`::
(Required, string) Identifier for the policy.
2019-11-20 11:19:33 -05:00
[[ilm-put-lifecycle-query-params]]
==== {api-query-parms-title}
include::{docdir}/rest-api/common-parms.asciidoc[tag=timeoutparms]
2019-11-20 11:19:33 -05:00
[[ilm-put-lifecycle-example]]
==== {api-examples-title}
The following example creates a new policy named `my_policy`:
[source,console]
--------------------------------------------------
PUT _ilm/policy/my_policy
{
"policy": {
"phases": {
"warm": {
"min_age": "10d",
"actions": {
"forcemerge": {
"max_num_segments": 1
}
}
},
"delete": {
"min_age": "30d",
"actions": {
"delete": {}
}
}
}
}
}
--------------------------------------------------
If the request succeeds, you receive the following result:
[source,console-result]
----
{
"acknowledged": true
}
----