o
    gZh(                     @   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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jdef  d	eje d
ejejdef  de
ej fddZe dd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jdef  d	eje d
ejejdef  de
ej fddZeddddddddddddededejdef deje deje dejejeej	e f  deje dejejdef  d	eje deje d
ejejdef  de
ej fddZdS )ShutdownClientN)error_tracefilter_pathhumanmaster_timeoutprettytimeoutnode_idr	   r
   r   r   z6t.Literal['d', 'h', 'm', 'micros', 'ms', 'nanos', 's']r   r   returnc                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ur:||	d	< |durB||	d
< ddi}
| jd||	|
dS )a  
        Removes a node from the shutdown list. Designed for indirect use by ECE/ESS and
        ECK. Direct use is not supported.

        `<https://www.elastic.co/guide/en/elasticsearch/reference/current>`_

        :param node_id: The node id of node to be removed from the shutdown state
        :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 timeout: Period to wait for a response. If no response is received before
            the timeout expires, the request fails and returns an error.
        *Empty value passed for parameter 'node_id'/_nodes/	/shutdownNr	   r
   r   r   r   r   acceptapplication/jsonDELETEparamsheadersr   
ValueErrorr   perform_requestselfr   r	   r
   r   r   r   r   _ShutdownClient__path_ShutdownClient__query_ShutdownClient__headers r"   Z/var/www/html/lang_env/lib/python3.10/site-packages/elasticsearch/_sync/client/shutdown.pydelete_node   s(   zShutdownClient.delete_node)r   r	   r
   r   r   r   r   c                C   s   |t vrdt| d}nd}i }	|dur||	d< |dur!||	d< |dur)||	d< |dur1||	d< |dur9||	d	< |durA||	d
< ddi}
| jd||	|
dS )a  
        Retrieve status of a node or nodes that are currently marked as shutting down.
        Designed for indirect use by ECE/ESS and ECK. Direct use is not supported.

        `<https://www.elastic.co/guide/en/elasticsearch/reference/current>`_

        :param node_id: Which node for which to retrieve the shutdown status
        :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 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   z/_nodes/shutdownNr	   r
   r   r   r   r   r   r   GETr   )r   r   r   r   r"   r"   r#   get_nodeM   s(   zShutdownClient.get_nodeT)Zbody_fields)allocation_delayr	   r
   r   r   r   target_node_namer   reasontypez)t.Literal['remove', 'replace', 'restart']r'   r(   c                C   s  |t v rtd|du rtd|du rtddt| d}i }i }|dur,||d< |dur4||d< |dur<||d	< |durD||d
< |durL||d< |durT||d< |dur\||d< |	durd|	|d< |
durl|
|d< |durt||d< ddd}| jd||||dS )a
  
        Adds a node to be shut down. Designed for indirect use by ECE/ESS and ECK. Direct
        use is not supported.

        `<https://www.elastic.co/guide/en/elasticsearch/reference/current>`_

        :param node_id: The node id of node to be shut down
        :param reason: A human-readable reason that the node is being shut down. This
            field provides information for other cluster operators; it does not affect
            the shut down process.
        :param type: Valid values are restart, remove, or replace. Use restart when you
            need to temporarily shut down a node to perform an upgrade, make configuration
            changes, or perform other maintenance. Because the node is expected to rejoin
            the cluster, data is not migrated off of the node. Use remove when you need
            to permanently remove a node from the cluster. The node is not marked ready
            for shutdown until data is migrated off of the node Use replace to do a 1:1
            replacement of a node with another node. Certain allocation decisions will
            be ignored (such as disk watermarks) in the interest of true replacement
            of the source node with the target node. During a replace-type shutdown,
            rollover and index creation may result in unassigned shards, and shrink may
            fail until the replacement is complete.
        :param allocation_delay: Only valid if type is restart. Controls how long Elasticsearch
            will wait for the node to restart and join the cluster before reassigning
            its shards to other nodes. This works the same as delaying allocation with
            the index.unassigned.node_left.delayed_timeout setting. If you specify both
            a restart allocation delay and an index-level allocation delay, the longer
            of the two is used.
        :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 target_node_name: Only valid if type is replace. Specifies the name of
            the node that is replacing the node being shut down. Shards from the shut
            down node are only allowed to be allocated to the target node, and no other
            data will be allocated to the target node. During relocation of data certain
            allocation rules are ignored, such as disk watermarks or user attribute filtering
            rules.
        :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   Nz)Empty value passed for parameter 'reason'z'Empty value passed for parameter 'type'r   r   r)   r*   r'   r	   r
   r   r   r   r(   r   r   )r   zcontent-typePUT)r   r   bodyr   )r   r   r)   r*   r'   r	   r
   r   r   r   r(   r   r   Z_ShutdownClient__bodyr    r!   r"   r"   r#   put_node   sB   =

zShutdownClient.put_node)__name__
__module____qualname__r   strtOptionalboolUnionSequencer   Anyr$   r&   r-   r"   r"   r"   r#   r      s    
1
2		
r   )typingr2   Zelastic_transportr   _baser   utilsr   r   r   r   r"   r"   r"   r#   <module>   s
   