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

163 lines
6.3 KiB
Python
Raw Normal View History

2020-05-15 09:36:47 -05:00
# Licensed to Elasticsearch B.V under one or more agreements.
# Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
# See the LICENSE file in the project root for more information
from .utils import NamespacedClient, query_params, _make_path, SKIP_IN_PATH
class IlmClient(NamespacedClient):
@query_params()
2020-05-20 12:34:29 -05:00
async def delete_lifecycle(self, policy, params=None, headers=None):
2020-05-15 09:36:47 -05:00
"""
Deletes the specified lifecycle policy definition. A currently used policy
cannot be deleted.
2020-05-20 12:34:29 -05:00
`<https://www.elastic.co/guide/en/elasticsearch/reference/7.x/ilm-delete-lifecycle.html>`_
2020-05-15 09:36:47 -05:00
: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'.")
2020-05-20 12:34:29 -05:00
return await self.transport.perform_request(
2020-05-15 09:36:47 -05:00
"DELETE",
_make_path("_ilm", "policy", policy),
params=params,
headers=headers,
)
@query_params("only_errors", "only_managed")
2020-05-20 12:34:29 -05:00
async def explain_lifecycle(self, index, params=None, headers=None):
2020-05-15 09:36:47 -05:00
"""
Retrieves information about the index's current lifecycle state, such as the
currently executing phase, action, and step.
2020-05-20 12:34:29 -05:00
`<https://www.elastic.co/guide/en/elasticsearch/reference/7.x/ilm-explain-lifecycle.html>`_
2020-05-15 09:36:47 -05:00
: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'.")
2020-05-20 12:34:29 -05:00
return await self.transport.perform_request(
2020-05-15 09:36:47 -05:00
"GET", _make_path(index, "_ilm", "explain"), params=params, headers=headers
)
@query_params()
2020-05-20 12:34:29 -05:00
async def get_lifecycle(self, policy=None, params=None, headers=None):
2020-05-15 09:36:47 -05:00
"""
Returns the specified policy definition. Includes the policy version and last
modified date.
2020-05-20 12:34:29 -05:00
`<https://www.elastic.co/guide/en/elasticsearch/reference/7.x/ilm-get-lifecycle.html>`_
2020-05-15 09:36:47 -05:00
:arg policy: The name of the index lifecycle policy
"""
2020-05-20 12:34:29 -05:00
return await self.transport.perform_request(
2020-05-15 09:36:47 -05:00
"GET", _make_path("_ilm", "policy", policy), params=params, headers=headers
)
@query_params()
2020-05-20 12:34:29 -05:00
async def get_status(self, params=None, headers=None):
2020-05-15 09:36:47 -05:00
"""
Retrieves the current index lifecycle management (ILM) status.
2020-05-20 12:34:29 -05:00
`<https://www.elastic.co/guide/en/elasticsearch/reference/7.x/ilm-get-status.html>`_
2020-05-15 09:36:47 -05:00
"""
2020-05-20 12:34:29 -05:00
return await self.transport.perform_request(
2020-05-15 09:36:47 -05:00
"GET", "/_ilm/status", params=params, headers=headers
)
@query_params()
2020-05-20 12:34:29 -05:00
async def move_to_step(self, index, body=None, params=None, headers=None):
2020-05-15 09:36:47 -05:00
"""
Manually moves an index into the specified step and executes that step.
2020-05-20 12:34:29 -05:00
`<https://www.elastic.co/guide/en/elasticsearch/reference/7.x/ilm-move-to-step.html>`_
2020-05-15 09:36:47 -05:00
: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'.")
2020-05-20 12:34:29 -05:00
return await self.transport.perform_request(
2020-05-15 09:36:47 -05:00
"POST",
_make_path("_ilm", "move", index),
params=params,
headers=headers,
body=body,
)
@query_params()
2020-05-20 12:34:29 -05:00
async def put_lifecycle(self, policy, body=None, params=None, headers=None):
2020-05-15 09:36:47 -05:00
"""
Creates a lifecycle policy
2020-05-20 12:34:29 -05:00
`<https://www.elastic.co/guide/en/elasticsearch/reference/7.x/ilm-put-lifecycle.html>`_
2020-05-15 09:36:47 -05:00
: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'.")
2020-05-20 12:34:29 -05:00
return await self.transport.perform_request(
2020-05-15 09:36:47 -05:00
"PUT",
_make_path("_ilm", "policy", policy),
params=params,
headers=headers,
body=body,
)
@query_params()
2020-05-20 12:34:29 -05:00
async def remove_policy(self, index, params=None, headers=None):
2020-05-15 09:36:47 -05:00
"""
Removes the assigned lifecycle policy and stops managing the specified index
2020-05-20 12:34:29 -05:00
`<https://www.elastic.co/guide/en/elasticsearch/reference/7.x/ilm-remove-policy.html>`_
2020-05-15 09:36:47 -05:00
: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'.")
2020-05-20 12:34:29 -05:00
return await self.transport.perform_request(
2020-05-15 09:36:47 -05:00
"POST", _make_path(index, "_ilm", "remove"), params=params, headers=headers
)
@query_params()
2020-05-20 12:34:29 -05:00
async def retry(self, index, params=None, headers=None):
2020-05-15 09:36:47 -05:00
"""
Retries executing the policy for an index that is in the ERROR step.
2020-05-20 12:34:29 -05:00
`<https://www.elastic.co/guide/en/elasticsearch/reference/7.x/ilm-retry-policy.html>`_
2020-05-15 09:36:47 -05:00
: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'.")
2020-05-20 12:34:29 -05:00
return await self.transport.perform_request(
2020-05-15 09:36:47 -05:00
"POST", _make_path(index, "_ilm", "retry"), params=params, headers=headers
)
@query_params()
2020-05-20 12:34:29 -05:00
async def start(self, params=None, headers=None):
2020-05-15 09:36:47 -05:00
"""
Start the index lifecycle management (ILM) plugin.
2020-05-20 12:34:29 -05:00
`<https://www.elastic.co/guide/en/elasticsearch/reference/7.x/ilm-start.html>`_
2020-05-15 09:36:47 -05:00
"""
2020-05-20 12:34:29 -05:00
return await self.transport.perform_request(
2020-05-15 09:36:47 -05:00
"POST", "/_ilm/start", params=params, headers=headers
)
@query_params()
2020-05-20 12:34:29 -05:00
async def stop(self, params=None, headers=None):
2020-05-15 09:36:47 -05:00
"""
Halts all lifecycle management operations and stops the index lifecycle
management (ILM) plugin
2020-05-20 12:34:29 -05:00
`<https://www.elastic.co/guide/en/elasticsearch/reference/7.x/ilm-stop.html>`_
2020-05-15 09:36:47 -05:00
"""
2020-05-20 12:34:29 -05:00
return await self.transport.perform_request(
2020-05-15 09:36:47 -05:00
"POST", "/_ilm/stop", params=params, headers=headers
)