from .utils import NamespacedClient, query_params, _make_path, SKIP_IN_PATH class IlmClient(NamespacedClient): @query_params() def delete_lifecycle(self, policy, params=None): """ ``_ :arg policy: The name of the index lifecycle policy """ if policy in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument 'policy'.") return self.transport.perform_request( "DELETE", _make_path("_ilm", "policy", policy), params=params ) @query_params("only_errors", "only_managed") def explain_lifecycle(self, index, params=None): """ ``_ :arg index: The name of the index to explain :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 """ if index in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument 'index'.") return self.transport.perform_request( "GET", _make_path(index, "_ilm", "explain"), params=params ) @query_params() def get_lifecycle(self, policy=None, params=None): """ ``_ :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): """ ``_ """ return self.transport.perform_request("GET", "/_ilm/status", params=params) @query_params() def move_to_step(self, index, body=None, params=None): """ ``_ :arg index: The name of the index whose lifecycle step is to change :arg body: The new lifecycle step to move to """ if index in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument 'index'.") return self.transport.perform_request( "POST", _make_path("_ilm", "move", index), params=params, body=body ) @query_params() def put_lifecycle(self, policy, body=None, params=None): """ ``_ :arg policy: The name of the index lifecycle policy :arg body: The lifecycle policy definition to register """ if policy in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument 'policy'.") return self.transport.perform_request( "PUT", _make_path("_ilm", "policy", policy), params=params, body=body ) @query_params() def remove_policy(self, index, params=None): """ ``_ :arg index: The name of the index to remove policy on """ if index in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument 'index'.") return self.transport.perform_request( "POST", _make_path(index, "_ilm", "remove"), params=params ) @query_params() def retry(self, index, params=None): """ ``_ :arg index: The name of the indices (comma-separated) whose failed lifecycle step is to be retry """ if index in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument 'index'.") return self.transport.perform_request( "POST", _make_path(index, "_ilm", "retry"), params=params ) @query_params() def start(self, params=None): """ ``_ """ return self.transport.perform_request("POST", "/_ilm/start", params=params) @query_params() def stop(self, params=None): """ ``_ """ return self.transport.perform_request("POST", "/_ilm/stop", params=params)