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

124 lines
4.1 KiB
Python
Raw Normal View History

2019-12-17 22:31:35 +01:00
from .utils import NamespacedClient, query_params, _make_path, SKIP_IN_PATH
class SlmClient(NamespacedClient):
@query_params()
2020-03-11 16:33:15 -05:00
def delete_lifecycle(self, policy_id, params=None, headers=None):
2019-12-17 22:31:35 +01:00
"""
2020-03-13 13:44:46 -05:00
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/slm-api-delete-policy.html>`_
2019-12-17 22:31:35 +01:00
:arg policy_id: The id of the snapshot lifecycle policy to
remove
"""
if policy_id in SKIP_IN_PATH:
raise ValueError("Empty value passed for a required argument 'policy_id'.")
return self.transport.perform_request(
2020-03-11 16:33:15 -05:00
"DELETE",
_make_path("_slm", "policy", policy_id),
params=params,
headers=headers,
2019-12-17 22:31:35 +01:00
)
@query_params()
2020-03-11 16:33:15 -05:00
def execute_lifecycle(self, policy_id, params=None, headers=None):
2019-12-17 22:31:35 +01:00
"""
2020-03-13 13:44:46 -05:00
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/slm-api-execute-lifecycle.html>`_
2019-12-17 22:31:35 +01:00
:arg policy_id: The id of the snapshot lifecycle policy to be
executed
"""
if policy_id in SKIP_IN_PATH:
raise ValueError("Empty value passed for a required argument 'policy_id'.")
return self.transport.perform_request(
2020-03-11 16:33:15 -05:00
"PUT",
_make_path("_slm", "policy", policy_id, "_execute"),
params=params,
headers=headers,
2019-12-17 22:31:35 +01:00
)
@query_params()
2020-03-11 16:33:15 -05:00
def execute_retention(self, params=None, headers=None):
2019-12-17 22:31:35 +01:00
"""
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/slm-api-execute-retention.html>`_
"""
return self.transport.perform_request(
2020-03-11 16:33:15 -05:00
"POST", "/_slm/_execute_retention", params=params, headers=headers
2019-12-17 22:31:35 +01:00
)
@query_params()
2020-03-11 16:33:15 -05:00
def get_lifecycle(self, policy_id=None, params=None, headers=None):
2019-12-17 22:31:35 +01:00
"""
2020-03-13 13:44:46 -05:00
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/slm-api-get-policy.html>`_
2019-12-17 22:31:35 +01:00
:arg policy_id: Comma-separated list of snapshot lifecycle
policies to retrieve
"""
return self.transport.perform_request(
2020-03-11 16:33:15 -05:00
"GET",
_make_path("_slm", "policy", policy_id),
params=params,
headers=headers,
2019-12-17 22:31:35 +01:00
)
@query_params()
2020-03-11 16:33:15 -05:00
def get_stats(self, params=None, headers=None):
2019-12-17 22:31:35 +01:00
"""
2020-03-13 13:44:46 -05:00
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/slm-api-get-stats.html>`_
2019-12-17 22:31:35 +01:00
"""
2020-03-11 16:33:15 -05:00
return self.transport.perform_request(
"GET", "/_slm/stats", params=params, headers=headers
)
2019-12-17 22:31:35 +01:00
@query_params()
2020-03-11 16:33:15 -05:00
def put_lifecycle(self, policy_id, body=None, params=None, headers=None):
2019-12-17 22:31:35 +01:00
"""
2020-03-13 13:44:46 -05:00
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/slm-api-put-policy.html>`_
2019-12-17 22:31:35 +01:00
:arg policy_id: The id of the snapshot lifecycle policy
:arg body: The snapshot lifecycle policy definition to register
"""
if policy_id in SKIP_IN_PATH:
raise ValueError("Empty value passed for a required argument 'policy_id'.")
return self.transport.perform_request(
2020-03-11 16:33:15 -05:00
"PUT",
_make_path("_slm", "policy", policy_id),
params=params,
headers=headers,
body=body,
2019-12-17 22:31:35 +01:00
)
2020-01-09 16:43:28 +01:00
@query_params()
2020-03-11 16:33:15 -05:00
def get_status(self, params=None, headers=None):
2020-01-09 16:43:28 +01:00
"""
2020-03-13 13:44:46 -05:00
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/slm-api-get-status.html>`_
2020-01-09 16:43:28 +01:00
"""
2020-03-11 16:33:15 -05:00
return self.transport.perform_request(
"GET", "/_slm/status", params=params, headers=headers
)
2020-01-09 16:43:28 +01:00
@query_params()
2020-03-11 16:33:15 -05:00
def start(self, params=None, headers=None):
2020-01-09 16:43:28 +01:00
"""
2020-03-13 13:44:46 -05:00
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/slm-api-start.html>`_
2020-01-09 16:43:28 +01:00
"""
2020-03-11 16:33:15 -05:00
return self.transport.perform_request(
"POST", "/_slm/start", params=params, headers=headers
)
2020-01-09 16:43:28 +01:00
@query_params()
2020-03-11 16:33:15 -05:00
def stop(self, params=None, headers=None):
2020-01-09 16:43:28 +01:00
"""
2020-03-13 13:44:46 -05:00
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/slm-api-stop.html>`_
2020-01-09 16:43:28 +01:00
"""
2020-03-11 16:33:15 -05:00
return self.transport.perform_request(
"POST", "/_slm/stop", params=params, headers=headers
)