Files
opensearch-pyd/elasticsearch/client/ilm.py
T

131 lines
4.7 KiB
Python
Raw Normal View History

from .utils import NamespacedClient, query_params, _make_path, SKIP_IN_PATH
2019-03-29 09:25:23 -06:00
class IlmClient(NamespacedClient):
@query_params()
2019-12-17 22:31:35 +01:00
def delete_lifecycle(self, policy, params=None):
2019-03-29 09:25:23 -06:00
"""
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/ilm-delete-lifecycle.html>`_
:arg policy: The name of the index lifecycle policy
"""
2019-12-17 22:31:35 +01:00
if policy in SKIP_IN_PATH:
raise ValueError("Empty value passed for a required argument 'policy'.")
2019-03-29 09:25:23 -06:00
return self.transport.perform_request(
"DELETE", _make_path("_ilm", "policy", policy), params=params
)
2019-12-17 22:31:35 +01:00
@query_params("only_errors", "only_managed")
def explain_lifecycle(self, index, params=None):
2019-03-29 09:25:23 -06:00
"""
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/ilm-explain-lifecycle.html>`_
:arg index: The name of the index to explain
2019-12-17 22:31:35 +01:00
:arg only_errors: filters the indices included in the response
to ones in an ILM error state, implies only_managed
:arg only_managed: filters the indices included in the response
to ones managed by ILM
2019-03-29 09:25:23 -06:00
"""
2019-12-17 22:31:35 +01:00
if index in SKIP_IN_PATH:
raise ValueError("Empty value passed for a required argument 'index'.")
2019-03-29 09:25:23 -06:00
return self.transport.perform_request(
"GET", _make_path(index, "_ilm", "explain"), params=params
)
@query_params()
def get_lifecycle(self, policy=None, params=None):
"""
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/ilm-get-lifecycle.html>`_
:arg policy: The name of the index lifecycle policy
"""
return self.transport.perform_request(
"GET", _make_path("_ilm", "policy", policy), params=params
)
@query_params()
def get_status(self, params=None):
"""
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/ilm-get-status.html>`_
2019-12-17 22:31:35 +01:00
2019-03-29 09:25:23 -06:00
"""
return self.transport.perform_request("GET", "/_ilm/status", params=params)
@query_params()
2019-12-17 22:31:35 +01:00
def move_to_step(self, index, body=None, params=None):
2019-03-29 09:25:23 -06:00
"""
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/ilm-move-to-step.html>`_
2019-12-17 22:31:35 +01:00
:arg index: The name of the index whose lifecycle step is to
change
2019-03-29 09:25:23 -06:00
:arg body: The new lifecycle step to move to
"""
2019-12-17 22:31:35 +01:00
if index in SKIP_IN_PATH:
raise ValueError("Empty value passed for a required argument 'index'.")
2019-03-29 09:25:23 -06:00
return self.transport.perform_request(
"POST", _make_path("_ilm", "move", index), params=params, body=body
)
@query_params()
2019-12-17 22:31:35 +01:00
def put_lifecycle(self, policy, body=None, params=None):
2019-03-29 09:25:23 -06:00
"""
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/ilm-put-lifecycle.html>`_
:arg policy: The name of the index lifecycle policy
:arg body: The lifecycle policy definition to register
"""
2019-12-17 22:31:35 +01:00
if policy in SKIP_IN_PATH:
raise ValueError("Empty value passed for a required argument 'policy'.")
2019-03-29 09:25:23 -06:00
return self.transport.perform_request(
"PUT", _make_path("_ilm", "policy", policy), params=params, body=body
)
@query_params()
2019-12-17 22:31:35 +01:00
def remove_policy(self, index, params=None):
2019-03-29 09:25:23 -06:00
"""
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/ilm-remove-policy.html>`_
:arg index: The name of the index to remove policy on
"""
2019-12-17 22:31:35 +01:00
if index in SKIP_IN_PATH:
raise ValueError("Empty value passed for a required argument 'index'.")
2019-03-29 09:25:23 -06:00
return self.transport.perform_request(
"POST", _make_path(index, "_ilm", "remove"), params=params
)
@query_params()
2019-12-17 22:31:35 +01:00
def retry(self, index, params=None):
2019-03-29 09:25:23 -06:00
"""
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/ilm-retry-policy.html>`_
2019-12-17 22:31:35 +01:00
:arg index: The name of the indices (comma-separated) whose
failed lifecycle step is to be retry
2019-03-29 09:25:23 -06:00
"""
2019-12-17 22:31:35 +01:00
if index in SKIP_IN_PATH:
raise ValueError("Empty value passed for a required argument 'index'.")
2019-03-29 09:25:23 -06:00
return self.transport.perform_request(
"POST", _make_path(index, "_ilm", "retry"), params=params
)
@query_params()
def start(self, params=None):
"""
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/ilm-start.html>`_
2019-12-17 22:31:35 +01:00
2019-03-29 09:25:23 -06:00
"""
return self.transport.perform_request("POST", "/_ilm/start", params=params)
@query_params()
def stop(self, params=None):
"""
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/ilm-stop.html>`_
2019-12-17 22:31:35 +01:00
2019-03-29 09:25:23 -06:00
"""
return self.transport.perform_request("POST", "/_ilm/stop", params=params)