o
    gZh]Q                     @   sL   d dl Zd dlmZ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TextApiResponse   )NamespacedClient)SKIP_IN_PATH_quote_rewrite_parametersc                '   @   s  e Zd Ze ddddddejeeje f 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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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
 dej	ejddef  dej	ejddef  dej	e
 dej	e 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def  d	efddZe dddddddddd	dej	ejeej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
 dej	ejdde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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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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jeeje f  d(ej	ejeej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jeeje f  dej	ejeeje f  d,ej	e
 dej	e
 d-ej	e
 d.ej	e
 d/ej	ejd0ef  dej	ejddef  dej	e
 dej	ejddef  d1ej	eje  d	eej f$d2d3Ze dddddddd4dej	ejeej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
 dej	ejddef  d	eej fd5d6ZdS )7NodesClientN)error_tracefilter_pathhumanprettynode_idmax_archive_versionr
   r   r   r   returnc          
      C   s   |t v rtd|t v rtddt| dt| }i }|dur&||d< |dur.||d< |dur6||d< |dur>||d	< d
di}	| jd|||	dS )a  
        Removes the archived repositories metering information present in the cluster.

        `<https://www.elastic.co/guide/en/elasticsearch/reference/8.11/clear-repositories-metering-archive-api.html>`_

        :param node_id: Comma-separated list of node IDs or names used to limit returned
            information. All the nodes selective options are explained [here](https://www.elastic.co/guide/en/elasticsearch/reference/current/cluster.html#cluster-nodes).
        :param max_archive_version: Specifies the maximum [archive_version](https://www.elastic.co/guide/en/elasticsearch/reference/current/get-repositories-metering-api.html#get-repositories-metering-api-response-body)
            to be cleared from the archive.
        *Empty value passed for parameter 'node_id'z6Empty value passed for parameter 'max_archive_version'/_nodes/z/_repositories_metering/Nr
   r   r   r   acceptapplication/jsonDELETEparamsheadersr   
ValueErrorr   perform_request)
selfr   r   r
   r   r   r   _NodesClient__path_NodesClient__query_NodesClient__headers r    W/var/www/html/lang_env/lib/python3.10/site-packages/elasticsearch/_sync/client/nodes.py#clear_repositories_metering_archive   s$   z/NodesClient.clear_repositories_metering_archivec          	      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  
        Returns cluster repositories metering information.

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

        :param node_id: Comma-separated list of node IDs or names used to limit returned
            information. All the nodes selective options are explained [here](https://www.elastic.co/guide/en/elasticsearch/reference/current/cluster.html#cluster-nodes).
        r   r   z/_repositories_meteringNr
   r   r   r   r   r   GETr   r   )	r   r   r
   r   r   r   r   r   r   r    r    r!   get_repositories_metering_infoC   s    z*NodesClient.get_repositories_metering_info)r   r
   r   r   ignore_idle_threadsintervalmaster_timeoutr   	snapshotssortthreadstimeouttyper%   r&   zt.Literal[-1]zt.Literal[0]r'   r(   r)   z/t.Literal['block', 'cpu', 'gpu', 'mem', 'wait']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urI||d< |	durQ|	|d< |
durY|
|d< |dura||d< |duri||d< |durq||d< ddi}| jd|||dS )az  
        Returns information about hot threads on each node in the cluster.

        `<https://www.elastic.co/guide/en/elasticsearch/reference/8.11/cluster-nodes-hot-threads.html>`_

        :param node_id: List of node IDs or names used to limit returned information.
        :param ignore_idle_threads: If true, known idle threads (e.g. waiting in a socket
            select, or to get a task from an empty queue) are filtered out.
        :param interval: The interval to do the second sampling of threads.
        :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 snapshots: Number of samples of thread stacktrace.
        :param sort: The sort order for 'cpu' type (default: total)
        :param threads: Specifies the number of hot threads to provide information for.
        :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 type: The type to sample.
        r   z/hot_threadsz/_nodes/hot_threadsNr
   r   r   r%   r&   r'   r   r(   r)   r*   r+   r,   r   z
text/plainr#   r   r   r   r   )r   r   r
   r   r   r%   r&   r'   r   r(   r)   r*   r+   r,   r   r   r   r    r    r!   hot_threadsf   s@   +zNodesClient.hot_threads)	r   metricr
   r   flat_settingsr   r'   r   r+   r/   r0   c       	         C   s   |t vr|t vrdt| dt| }
n|t vr!dt| }
n|t vr-dt| }
nd}
i }|dur9||d< |durA||d< |durI||d< |durQ||d< |durY||d	< |dura||d
< |	duri|	|d< ddi}| jd|
||dS )a]  
        Returns information about nodes in the cluster.

        `<https://www.elastic.co/guide/en/elasticsearch/reference/8.11/cluster-nodes-info.html>`_

        :param node_id: Comma-separated list of node IDs or names used to limit returned
            information.
        :param metric: Limits the information returned to the specific metrics. Supports
            a comma-separated list, such as http,ingest.
        :param flat_settings: If true, returns settings in flat format.
        :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   /z/_nodesNr
   r   r0   r   r'   r   r+   r   r   r#   r   r-   )r   r   r/   r
   r   r0   r   r'   r   r+   r   r   r   r    r    r!   info   s4    zNodesClient.infoT)Zbody_fields)r   r
   r   r   r   secure_settings_passwordr+   r3   c                C   s   |t vrdt| d}nd}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
< |
sGd}
ddi}|
durSd|d< | jd||	||
dS )a  
        Reloads secure settings.

        `<https://www.elastic.co/guide/en/elasticsearch/reference/8.11/secure-settings.html#reloadable-secure-settings>`_

        :param node_id: The names of particular nodes in the cluster to target.
        :param secure_settings_password: The password for the Elasticsearch keystore.
        :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   z/reload_secure_settingsz/_nodes/reload_secure_settingsNr
   r   r   r   r3   r+   r   r   zcontent-typePOST)r   r   bodyr-   )r   r   r
   r   r   r   r3   r+   r   r   Z_NodesClient__bodyr   r    r    r!   reload_secure_settings   s2   
z"NodesClient.reload_secure_settings)r   r/   index_metriccompletion_fieldsr
   fielddata_fieldsfieldsr   groupsr   include_segment_file_sizesinclude_unloaded_segmentslevelr'   r   r+   typesr7   r8   r9   r:   r;   r<   r=   r>   z)t.Literal['cluster', 'indices', 'shards']r?   c                C   s  |t vr|t vr|t vrdt| dt| dt| }nE|t vr3|t vr3dt| dt| }n0|t vrH|t vrHdt| dt| }n|t vrUdt| d}n|t vradt| }nd}i }|durm||d< |duru||d	< |dur}||d
< |dur||d< |dur||d< |	dur|	|d< |
dur|
|d< |dur||d< |dur||d< |dur||d< |dur||d< |dur||d< |dur||d< |dur||d< ddi}| jd|||dS )a  
        Returns statistical information about nodes in the cluster.

        `<https://www.elastic.co/guide/en/elasticsearch/reference/8.11/cluster-nodes-stats.html>`_

        :param node_id: Comma-separated list of node IDs or names used to limit returned
            information.
        :param metric: Limit the information returned to the specified metrics
        :param index_metric: Limit the information returned for indices metric to the
            specific index metrics. It can be used only if indices (or all) metric is
            specified.
        :param completion_fields: Comma-separated list or wildcard expressions of fields
            to include in fielddata and suggest statistics.
        :param fielddata_fields: Comma-separated list or wildcard expressions of fields
            to include in fielddata statistics.
        :param fields: Comma-separated list or wildcard expressions of fields to include
            in the statistics.
        :param groups: Comma-separated list of search groups to include in the search
            statistics.
        :param include_segment_file_sizes: If true, the call reports the aggregated disk
            usage of each one of the Lucene index files (only applies if segment stats
            are requested).
        :param include_unloaded_segments: If `true`, the response includes information
            from segments that are not loaded into memory.
        :param level: Indicates whether statistics are aggregated at the cluster, index,
            or shard level.
        :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.
        :param types: A comma-separated list of document types for the indexing index
            metric.
        r   z/stats/r1   z/_nodes/stats/z/statsz/_nodes/statsNr8   r
   r9   r:   r   r;   r   r<   r=   r>   r'   r   r+   r?   r   r   r#   r   r-   )r   r   r/   r7   r8   r
   r9   r:   r   r;   r   r<   r=   r>   r'   r   r+   r?   r   r   r   r    r    r!   stats"  s\   =$zNodesClient.stats)r   r/   r
   r   r   r   r+   c                C   s   |t vr|t vrdt| dt| }n|t vr"dt| d}n|t vr.dt| }nd}i }	|dur:||	d< |durB||	d< |durJ||	d	< |durR||	d
< |durZ||	d< ddi}
| jd||	|
dS )a  
        Returns low-level information about REST actions usage on nodes.

        `<https://www.elastic.co/guide/en/elasticsearch/reference/8.11/cluster-nodes-usage.html>`_

        :param node_id: A comma-separated list of node IDs or names to limit the returned
            information; use `_local` to return information from the node you're connecting
            to, leave empty to get information from all nodes
        :param metric: Limits the information returned to the specific metrics. A comma-separated
            list of the following options: `_all`, `rest_actions`.
        :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   z/usage/z/usagez/_nodes/usage/z/_nodes/usageNr
   r   r   r   r+   r   r   r#   r   r-   )r   r   r/   r
   r   r   r   r+   r   r   r   r    r    r!   usage  s,   zNodesClient.usage)__name__
__module____qualname__r   tUnionstrSequenceintOptionalboolr   Anyr"   r$   r   r.   r2   r6   r@   rA   r    r    r    r!   r	      s   	'"	L	;	
0	
m	
r	   )typingrE   Zelastic_transportr   r   _baser   utilsr   r   r   r	   r    r    r    r!   <module>   s
   