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                   @   sB  e Zd Ze dddddddddd	dejejeef  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	e  d	eje 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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jejddef  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ejejeej	e f  deje
 deje
 dejejeej	e f  dejejdef  deje
 dejejddef  dejej	e  d	eje d
eje
 dejejddef  deje
 deej fddZdS )TasksClientN)	task_idactionserror_tracefilter_pathhumannodesparent_task_idprettywait_for_completionr	   r
   r   r   r   r   r   r   r   returnc       	            s   |t vrdt| d}
n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urJ||d< |	durR|	|d< ddi}| jd|
||dI dH S )a  
        Cancels a task, if it can be cancelled through an API.

        `<https://www.elastic.co/guide/en/elasticsearch/reference/8.11/tasks.html>`_

        :param task_id: ID of the task.
        :param actions: Comma-separated list or wildcard expression of actions used to
            limit the request.
        :param nodes: Comma-separated list of node IDs or names used to limit the request.
        :param parent_task_id: Parent task ID used to limit the tasks.
        :param wait_for_completion: Should the request block until the cancellation of
            the task and its descendant tasks is completed. Defaults to false
        /_tasks/z/_cancelz/_tasks/_cancelNr
   r   r   r   r   r   r   r   acceptapplication/jsonPOSTparamsheaders)r   r   perform_request)selfr	   r
   r   r   r   r   r   r   r   _TasksClient__path_TasksClient__query_TasksClient__headers r   X/var/www/html/lang_env/lib/python3.10/site-packages/elasticsearch/_async/client/tasks.pycancel   s2   zTasksClient.cancel)r   r   r   r   timeoutr   r"   zt.Literal[-1]zt.Literal[0]c                   s   |t v r	tddt| }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I dH S )a  
        Returns information about a task.

        `<https://www.elastic.co/guide/en/elasticsearch/reference/8.11/tasks.html>`_

        :param task_id: ID of the task.
        :param timeout: Period to wait for a response. If no response is received before
            the timeout expires, the request fails and returns an error.
        :param wait_for_completion: If `true`, the request blocks until the task has
            completed.
        z*Empty value passed for parameter 'task_id'r   Nr   r   r   r   r"   r   r   r   GETr   )r   
ValueErrorr   r   )r   r	   r   r   r   r   r"   r   r   r   r   r   r   r    getP   s*   zTasksClient.get)r
   detailedr   r   group_byr   master_timeoutnode_idr   r   r"   r   r&   r'   z%t.Literal['nodes', 'none', 'parents']r(   r)   c                   s   d}i }|dur||d< |dur||d< |dur||d< |dur%||d< |dur-||d< |dur5||d< |dur=||d	< |durE||d
< |	durM|	|d< |
durU|
|d< |dur]||d< |dure||d< ddi}| j d|||dI dH S )a  
        Returns a list of tasks.

        `<https://www.elastic.co/guide/en/elasticsearch/reference/8.11/tasks.html>`_

        :param actions: Comma-separated list or wildcard expression of actions used to
            limit the request.
        :param detailed: If `true`, the response includes detailed information about
            shard recoveries.
        :param group_by: Key used to group tasks in the response.
        :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 node_id: Comma-separated list of node IDs or names used to limit returned
            information.
        :param parent_task_id: Parent task ID used to limit returned information. To
            return all tasks, omit this parameter or use a value of `-1`.
        :param timeout: Period to wait for a response. If no response is received before
            the timeout expires, the request fails and returns an error.
        :param wait_for_completion: If `true`, the request blocks until the operation
            is complete.
        z/_tasksNr
   r&   r   r   r'   r   r(   r)   r   r   r"   r   r   r   r#   r   )r   )r   r
   r&   r   r   r'   r   r(   r)   r   r   r"   r   r   r   r   r   r   r    list|   s>   +zTasksClient.list)__name__
__module____qualname__r   tOptionalUnionintstrSequenceboolr   Anyr!   r%   r*   r   r   r   r    r      s    	
4	
+
r   )typingr.   Zelastic_transportr   _baser   utilsr   r   r   r   r   r   r   r    <module>   s
   