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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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ejejeeje f  deje	 deje	 dejejejejdef  ejdef 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
ej fddZeddddddddddddd
dede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e  dejejeejf  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	 de
ej fd d!Ze 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
ej fd%d&ZdS )'SearchableSnapshotsClientN)node_iderror_tracefilter_pathhumanmaster_timeoutprettyr	   r
   r   r   r   zt.Literal[-1]zt.Literal[0]r   returnc          
      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
di}	| jd|||	dS )a  
        Retrieve node-level cache statistics about searchable snapshots.

        `<https://www.elastic.co/guide/en/elasticsearch/reference/8.11/searchable-snapshots-apis.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 master_timeout:
        z/_searchable_snapshots/z/cache/statsz"/_searchable_snapshots/cache/statsNr
   r   r   r   r   acceptapplication/jsonGETparamsheadersr   r   perform_request)
selfr	   r
   r   r   r   r    _SearchableSnapshotsClient__path!_SearchableSnapshotsClient__query#_SearchableSnapshotsClient__headers r   f/var/www/html/lang_env/lib/python3.10/site-packages/elasticsearch/_sync/client/searchable_snapshots.pycache_stats   s$   z%SearchableSnapshotsClient.cache_stats)indexallow_no_indicesr
   expand_wildcardsr   r   ignore_unavailabler   r   r    r!   z4t.Literal['all', 'closed', 'hidden', 'none', 'open']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di}| jd|	|
|dS )a  
        Clear the cache of searchable snapshots.

        `<https://www.elastic.co/guide/en/elasticsearch/reference/8.11/searchable-snapshots-apis.html>`_

        :param index: A comma-separated list of index names
        :param allow_no_indices: Whether to ignore if a wildcard indices expression resolves
            into no concrete indices. (This includes `_all` string or when no indices
            have been specified)
        :param expand_wildcards: Whether to expand wildcard expression to concrete indices
            that are open, closed or both.
        :param ignore_unavailable: Whether specified concrete indices should be ignored
            when unavailable (missing or closed)
        /z"/_searchable_snapshots/cache/clearNr    r
   r!   r   r   r"   r   r   r   POSTr   r   )r   r   r    r
   r!   r   r   r"   r   r   r   r   r   r   r   clear_cacheF   s,   "z%SearchableSnapshotsClient.clear_cacheT)Zbody_fields)
r
   r   r   ignore_index_settingsindex_settingsr   r   renamed_indexstoragewait_for_completion
repositorysnapshotr&   r'   r(   r)   r*   c                C   s   |t v rtd|t v rtd|du rtddt| dt| d}i }i }|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ury||d< |dur||d< ddd}| jd||||dS )aD  
        Mount a snapshot as a searchable index.

        `<https://www.elastic.co/guide/en/elasticsearch/reference/8.11/searchable-snapshots-api-mount-snapshot.html>`_

        :param repository: The name of the repository containing the snapshot of the
            index to mount
        :param snapshot: The name of the snapshot of the index to mount
        :param index:
        :param ignore_index_settings:
        :param index_settings:
        :param master_timeout: Explicit operation timeout for connection to master node
        :param renamed_index:
        :param storage: Selects the kind of local storage used to accelerate searches.
            Experimental, and defaults to `full_copy`
        :param wait_for_completion: Should this request wait until the operation has
            completed before returning
        z-Empty value passed for parameter 'repository'z+Empty value passed for parameter 'snapshot'Nz(Empty value passed for parameter 'index'z/_snapshot/r#   z/_mountr   r
   r   r   r&   r'   r   r   r(   r)   r*   r   )r   zcontent-typer$   )r   r   body)r   
ValueErrorr   r   )r   r+   r,   r   r
   r   r   r&   r'   r   r   r(   r)   r*   r   Z _SearchableSnapshotsClient__bodyr   r   r   r   r   mount   sF   (

zSearchableSnapshotsClient.mount)r   r
   r   r   levelr   r0   z)t.Literal['cluster', 'indices', 'shards']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	d
i}	| jd|||	dS )aC  
        Retrieve shard-level statistics about searchable snapshots.

        `<https://www.elastic.co/guide/en/elasticsearch/reference/8.11/searchable-snapshots-apis.html>`_

        :param index: A comma-separated list of index names
        :param level: Return stats aggregated at cluster, index or shard level
        r#   z/_searchable_snapshots/statsNr
   r   r   r0   r   r   r   r   r   r   )
r   r   r
   r   r   r0   r   r   r   r   r   r   r   stats   s$   zSearchableSnapshotsClient.stats)__name__
__module____qualname__r   tOptionalUnionstrSequenceboolr   Anyr   r%   Mappingr/   r1   r   r   r   r   r      s   
*9		
I
r   )typingr5   Zelastic_transportr   _baser   utilsr   r   r   r   r   r   r   r   <module>   s
   