
    ci8                        d dl mZmZmZmZmZmZ d dlmZm	Z	 ddl
m
Z
  ed          Z G d dee                   Z G d d	ee                   Z e            Zej        Zej        Zej        Zej        Zej        Zd
S )    )AnyDictGenericTypeTypeVarUnion)Elasticsearch__versionstr__   )
serializer_Tc                       e Zd ZdZdee         fdZdeddfdZde	d	eddfd
Z
de	ddfdZdde	dedefdZddee	ef         defdZd	edefdZdS )Connectionszr
    Class responsible for holding connections to different clusters. Used as a
    singleton in this module.
    elasticsearch_classc                0    i | _         i | _        || _        d S )N)_kwargs_connsr   )selfr   s     ]/var/www/html/auto_sub_bot/venv/lib/python3.11/site-packages/elasticsearch/dsl/connections.py__init__zConnections.__init__!   s    ')%'-@       kwargsreturnNc                     t          | j                  D ]9}|| j        v r&|                    |d          | j        |         k    r1| j        |= :|| _        dS )a  
        Configure multiple connections at once, useful for passing in config
        dictionaries obtained from other sources, like Django's settings or a
        configuration management tool.

        Example::

            connections.configure(
                default={'hosts': 'localhost'},
                dev={'hosts': ['esdev1.example.com:9200'], 'sniff_on_start': True},
            )

        Connections will only be constructed lazily when requested through
        ``get_connection``.
        N)listr   r   get)r   r   ks      r   	configurezConnections.configure&   sa      dk"" 	 	ADL  VZZ4%8%8DLO%K%KAr   aliasconnc                 @    |                      |          | j        |<   dS )zK
        Add a connection object, it will be passed through as-is.
        N)_with_user_agentr   )r   r   r    s      r   add_connectionzConnections.add_connection=   s$     "22488Er   c                     d}| j         | j        fD ]}	 ||= # t          $ r |dz  }Y w xY w|dk    rt          d|d          dS )zn
        Remove connection from the registry. Raises ``KeyError`` if connection
        wasn't found.
        r   r      "There is no connection with alias .N)r   r   KeyError)r   r   errorsds       r   remove_connectionzConnections.remove_connectionC   s    
 +t|, 	 	AeHH   ! Q;;JJJJKKK ;s   **defaultc                     |                     dt                      | j        di |x}| j        |<   |                     |          S )zu
        Construct an instance of ``elasticsearch.Elasticsearch`` and register
        it under given alias.
        r    )
setdefaultr   r   r   r"   )r   r   r   r    s       r   create_connectionzConnections.create_connectionR   sR    
 	,
333$<D$<$F$Fv$F$FFt{5!$$T***r   c                    t          |t                    s|                     |          S 	 | j        |         S # t          $ r Y nw xY w	  | j        |fi | j        |         S # t          $ r t	          d|d          w xY w)aT  
        Retrieve a connection, construct it if necessary (only configuration
        was passed to us). If a non-string alias has been passed through we
        assume it's already a client instance and will just return it as-is.

        Raises ``KeyError`` if no client (or its definition) is registered
        under the alias.
        r&   r'   )
isinstancestrr"   r   r(   r0   r   )r   r   s     r   get_connectionzConnections.get_connection[   s     %%% 	0((///	;u%% 	 	 	D		L)4)%GG4<3FGGG 	L 	L 	LJJJJKKK	Ls   9 
AA
A# #Bc                     t          |d          rk|j        j        }|r|j                                        |_        |j                            ddt
           i           |r|j                                         |S )N_headersz
user-agentzelasticsearch-dsl-py/)hasattrr6   frozencopyupdater
   freeze)r   r    	is_frozens      r   r"   zConnections._with_user_agentv   s    4$$ 	',I 5 $ 2 2 4 4M  G~GGH    '$$&&&r   )r,   )__name__
__module____qualname____doc__r   r   r   r   r   r3   r#   r+   r0   r   r4   r"   r.   r   r   r   r      s;        
AtBx A A A A
# $    .9C 9r 9d 9 9 9 9Ls Lt L L L L+ +s +# +" + + + +L LE#r'N L2 L L L L6R B      r   r   c                   6     e Zd Zeddee         f fdZ xZS )ElasticsearchConnectionsr   r   c                L    t                                          |           d S )NrC   )superr   )r   r   	__class__s     r   r   z!ElasticsearchConnections.__init__   s%    -@AAAAAr   )r=   r>   r?   r	   r   r   __classcell__)rF   s   @r   rB   rB      sc        ER B B BtM/B B B B B B B B B B Br   rB   N)typingr   r   r   r   r   r   elasticsearchr	   r
   r   r   r   rB   connectionsr   r#   r+   r0   r4   r.   r   r   <module>rK      s  $ < ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; 7 7 7 7 7 7 7 7 " " " " " "WT]]f f f f f'"+ f f fRB B B B B{=9 B B B
 '&((!	+1 1 +r   