o
    gZhY7                     @   sH   d dl Zd dlmZ ddlmZ ddlmZmZm	Z	 G dd deZ
dS )    N)ObjectApiResponse   )NamespacedClient)SKIP_IN_PATH_quote_rewrite_parametersc                   @   s
  e Zd Ze ddddddedeje dejejeej	e f  deje deje de
ej fd	d
Ze ddddddedeje dejejeej	e f  deje deje de
ej fddZe ddddddeje dejejeej	e f  deje deje de
ej f
ddZe dddddddejejeej	e f  deje dejejeej	e f  deje deje de
ej fddZe ddddddeje dejejeej	e f  deje deje de
ej f
ddZe ddddddeje dejejeej	e f  deje deje de
ej f
ddZedddddddddddddddedejejeejf  deje dejejeej	e f  deje dejejddef  deje deje deje dejejeejf  d eje d!ejejddef  de
ej fd"d#Ze ddddddeje dejejeej	e f  deje deje de
ej f
d$d%Ze ddddddeje dejejeej	e f  deje deje de
ej f
d&d'ZdS )(	SlmClientN)error_tracefilter_pathhumanpretty	policy_idr	   r
   r   r   returnc          	      C   s|   |t v rtddt| }i }|dur||d< |dur!||d< |dur)||d< |dur1||d< dd	i}| jd
|||dS )z
        Deletes an existing snapshot lifecycle policy.

        `<https://www.elastic.co/guide/en/elasticsearch/reference/8.11/slm-api-delete-policy.html>`_

        :param policy_id: The id of the snapshot lifecycle policy to remove
        ,Empty value passed for parameter 'policy_id'/_slm/policy/Nr	   r
   r   r   acceptapplication/jsonDELETEparamsheadersr   
ValueErrorr   perform_request	selfr   r	   r
   r   r   _SlmClient__path_SlmClient__query_SlmClient__headers r   U/var/www/html/lang_env/lib/python3.10/site-packages/elasticsearch/_sync/client/slm.pydelete_lifecycle   s    zSlmClient.delete_lifecyclec          	      C   s~   |t v rtddt| d}i }|dur||d< |dur"||d< |dur*||d< |dur2||d< d	d
i}| jd|||dS )a?  
        Immediately creates a snapshot according to the lifecycle policy, without waiting
        for the scheduled time.

        `<https://www.elastic.co/guide/en/elasticsearch/reference/8.11/slm-api-execute-lifecycle.html>`_

        :param policy_id: The id of the snapshot lifecycle policy to be executed
        r   r   z	/_executeNr	   r
   r   r   r   r   PUTr   r   r   r   r   r    execute_lifecycle=   s    zSlmClient.execute_lifecyclec                C   b   d}i }|dur||d< |dur||d< |dur||d< |dur$||d< ddi}| j d	|||d
S )z
        Deletes any snapshots that are expired according to the policy's retention rules.

        `<https://www.elastic.co/guide/en/elasticsearch/reference/8.11/slm-api-execute-retention.html>`_
        z/_slm/_execute_retentionNr	   r
   r   r   r   r   POSTr   r   r   r	   r
   r   r   r   r   r   r   r   r    execute_retention`      zSlmClient.execute_retention)r   r	   r
   r   r   c          	      C   sz   |t vrdt| }nd}i }|dur||d< |dur ||d< |dur(||d< |dur0||d< dd	i}| jd
|||dS )aG  
        Retrieves one or more snapshot lifecycle policy definitions and information about
        the latest snapshot attempts.

        `<https://www.elastic.co/guide/en/elasticsearch/reference/8.11/slm-api-get-policy.html>`_

        :param policy_id: Comma-separated list of snapshot lifecycle policies to retrieve
        r   z/_slm/policyNr	   r
   r   r   r   r   GETr   )r   r   r   r   r   r   r    get_lifecycle}   s    zSlmClient.get_lifecyclec                C   r$   )z
        Returns global and policy-level statistics about actions taken by snapshot lifecycle
        management.

        `<https://www.elastic.co/guide/en/elasticsearch/reference/8.11/slm-api-get-stats.html>`_
        z/_slm/statsNr	   r
   r   r   r   r   r*   r   r&   r'   r   r   r    	get_stats   s   zSlmClient.get_statsc                C   r$   )z
        Retrieves the status of snapshot lifecycle management (SLM).

        `<https://www.elastic.co/guide/en/elasticsearch/reference/8.11/slm-api-get-status.html>`_
        z/_slm/statusNr	   r
   r   r   r   r   r*   r   r&   r'   r   r   r    
get_status   r)   zSlmClient.get_statusT)Zbody_fields)configr	   r
   r   master_timeoutnamer   
repository	retentionscheduletimeoutr.   r/   zt.Literal[-1]zt.Literal[0]r0   r1   r2   r3   r4   c                C   s
  |t v rtddt| }i }i }|dur||d< |dur#||d< |dur+||d< |dur3||d< |dur;||d< |durC||d	< |durK||d
< |	durS|	|d< |
dur[|
|d< |durc||d< |durk||d< |sod}ddi}|dur{d|d< | jd||||dS )u  
        Creates or updates a snapshot lifecycle policy.

        `<https://www.elastic.co/guide/en/elasticsearch/reference/8.11/slm-api-put-policy.html>`_

        :param policy_id: ID for the snapshot lifecycle policy you want to create or
            update.
        :param config: Configuration for each snapshot created by the policy.
        :param master_timeout: Period to wait for a connection to the master node. If
            no response is received before the timeout expires, the request fails and
            returns an error.
        :param name: Name automatically assigned to each snapshot created by the policy.
            Date math is supported. To prevent conflicting snapshot names, a UUID is
            automatically appended to each snapshot name.
        :param repository: Repository used to store snapshots created by this policy.
            This repository must exist prior to the policy’s creation. You can create
            a repository using the snapshot repository API.
        :param retention: Retention rules used to retain and delete snapshots created
            by the policy.
        :param schedule: Periodic or absolute schedule at which the policy creates snapshots.
            SLM applies schedule changes immediately.
        :param timeout: Period to wait for a response. If no response is received before
            the timeout expires, the request fails and returns an error.
        r   r   Nr.   r	   r
   r   r/   r0   r   r1   r2   r3   r4   r   r   zcontent-typer"   )r   r   bodyr   )r   r   r.   r	   r
   r   r/   r0   r   r1   r2   r3   r4   r   Z_SlmClient__bodyr   r   r   r   r    put_lifecycle   sF   -
zSlmClient.put_lifecyclec                C   r$   )z
        Turns on snapshot lifecycle management (SLM).

        `<https://www.elastic.co/guide/en/elasticsearch/reference/8.11/slm-api-start.html>`_
        z/_slm/startNr	   r
   r   r   r   r   r%   r   r&   r'   r   r   r    start-  r)   zSlmClient.startc                C   r$   )z
        Turns off snapshot lifecycle management (SLM).

        `<https://www.elastic.co/guide/en/elasticsearch/reference/8.11/slm-api-stop.html>`_
        z
/_slm/stopNr	   r
   r   r   r   r   r%   r   r&   r'   r   r   r    stopJ  r)   zSlmClient.stop)__name__
__module____qualname__r   strtOptionalboolUnionSequencer   Anyr!   r#   r(   r+   r,   r-   Mappingr6   r7   r8   r   r   r   r    r      sf   !"#Nr   )typingr=   Zelastic_transportr   _baser   utilsr   r   r   r   r   r   r   r    <module>   s
   