Source code for opensearchpy.plugins.index_management
# SPDX-License-Identifier: Apache-2.0## The OpenSearch Contributors require contributions made to# this file be licensed under the Apache-2.0 license or a# compatible open source license.## Modifications Copyright OpenSearch Contributors. See# GitHub history for details.fromtypingimportAnyfrom..client.utilsimportSKIP_IN_PATH,NamespacedClient,_make_path,query_params
[docs]@query_params()defput_policy(self,policy:Any,body:Any=None,params:Any=None,headers:Any=None)->Any:""" Creates, or updates, a policy. :arg policy: The name of the policy """ifpolicyinSKIP_IN_PATH:raiseValueError("Empty value passed for a required argument 'policy'.")returnself.transport.perform_request("PUT",_make_path("_plugins","_ism","policies",policy),params=params,headers=headers,body=body,)
[docs]@query_params()defadd_policy(self,index:Any,body:Any=None,params:Any=None,headers:Any=None)->Any:""" Adds a policy to an index. This operation does not change the policy if the index already has one. :arg index: The name of the index to add policy on """ifindexinSKIP_IN_PATH:raiseValueError("Empty value passed for a required argument 'index'.")returnself.transport.perform_request("POST",_make_path("_plugins","_ism","add",index),params=params,headers=headers,body=body,)
[docs]@query_params()defget_policy(self,policy:Any=None,params:Any=None,headers:Any=None)->Any:""" Gets the policy by `policy_id`; returns all policies if no policy_id is provided. :arg policy: The name of the policy """returnself.transport.perform_request("GET",_make_path("_plugins","_ism","policies",policy),params=params,headers=headers,)
[docs]@query_params()defremove_policy_from_index(self,index:Any,params:Any=None,headers:Any=None)->Any:""" Removes any ISM policy from the index. :arg index: The name of the index to remove policy on """ifindexinSKIP_IN_PATH:raiseValueError("Empty value passed for a required argument 'index'.")returnself.transport.perform_request("POST",_make_path("_plugins","_ism","remove",index),params=params,headers=headers,)
[docs]@query_params()defchange_policy(self,index:Any,body:Any=None,params:Any=None,headers:Any=None)->Any:""" Updates the managed index policy to a new policy (or to a new version of the policy). :arg index: The name of the index to change policy on """ifindexinSKIP_IN_PATH:raiseValueError("Empty value passed for a required argument 'index'.")returnself.transport.perform_request("POST",_make_path("_plugins","_ism","change_policy",index),params=params,headers=headers,body=body,)
[docs]@query_params()defretry(self,index:Any,body:Any=None,params:Any=None,headers:Any=None)->Any:""" Retries the failed action for an index. :arg index: The name of the index whose is in a failed state """ifindexinSKIP_IN_PATH:raiseValueError("Empty value passed for a required argument 'index'.")returnself.transport.perform_request("POST",_make_path("_plugins","_ism","retry",index),params=params,headers=headers,body=body,)
[docs]@query_params("show_policy")defexplain_index(self,index:Any,params:Any=None,headers:Any=None)->Any:""" Gets the current state of the index. :arg index: The name of the index to explain """ifindexinSKIP_IN_PATH:raiseValueError("Empty value passed for a required argument 'index'.")returnself.transport.perform_request("GET",_make_path("_plugins","_ism","explain",index),params=params,headers=headers,)
[docs]@query_params()defdelete_policy(self,policy:Any,params:Any=None,headers:Any=None)->Any:""" Deletes the policy by `policy_id`. :arg policy: The name of the policy to delete """ifpolicyinSKIP_IN_PATH:raiseValueError("Empty value passed for a required argument 'policy'.")returnself.transport.perform_request("DELETE",_make_path("_plugins","_ism","policies",policy),params=params,headers=headers,)