
    j,                        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y)    )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y)Connectionszr
    Class responsible for holding connections to different clusters. Used as a
    singleton in this module.
    elasticsearch_classc                .    i | _         i | _        || _        y )N)_kwargs_connsr   )selfr   s     |/var/www/internaltesting/Shamanth/prverification/HIS_auto/venv/lib/python3.12/site-packages/elasticsearch/dsl/connections.py__init__zConnections.__init__    s    ')%'-@     kwargsreturnNc                     t        | j                        D ]@  }|| j                  v r#|j                  |d      | j                  |   k(  r4| j                  |= B || _        y)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%   sY      dkk" 	ADLL VZZ4%8DLLO%KA		
 r   aliasconnc                 @    | j                  |      | j                  |<   y)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Er   c                     d}| j                   | j                  fD ]  }	 ||=  |dk(  rt        d|d      y# t        $ r |dz  }Y .w xY w)zn
        Remove connection from the registry. Raises ``KeyError`` if connection
        wasn't found.
        r   r   r	   "There is no connection with alias .N)r   r   KeyError)r   r    errorsds       r   remove_connectionzConnections.remove_connectionB   sn    
 ++t||, 	AeH	 Q;?yJKK   !s   9A
	A
c                     |j                  dt                | j                  di |x}| j                  |<   | 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_connectionQ   sH    
 	,
3$<D$<$<$Fv$FFt{{5!$$T**r   c                     t        |t              s| j                  |      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(   r/   r   )r   r    s     r   get_connectionzConnections.get_connectionZ   s     %%((//	;;u%% 			L)4))%G4<<3FGG 	L?yJKK	Ls   2 	>>A" "A;c                    t        |d      rw|j                  j                  }|r|j                  j                         |_        |j                  j	                  ddt
         i       |r|j                  j                          |S )N_headersz
user-agentzelasticsearch-dsl-py/)hasattrr5   frozencopyupdater   freeze)r   r!   	is_frozens      r   r#   zConnections._with_user_agentu   so    4$,,I $ 2 2 4MM  !6~6FGH $$&r   )default)__name__
__module____qualname____doc__r   r   r   r   r   r2   r$   r+   r/   r   r3   r#   r-   r   r   r   r      s    
AtBx A
# $ .9C 9r 9d 9Ls Lt L+s +# +" +LE#r'N L2 L6R B r   r   c                   0     e Zd Zeddee   f fdZ xZS )ElasticsearchConnectionsr   r   c                &    t         |   |       y )NrC   )superr   )r   r   	__class__s     r   r   z!ElasticsearchConnections.__init__   s    -@Ar   )r=   r>   r?   r
   r   r   __classcell__)rF   s   @r   rB   rB      s    ER BtM/B B Br   rB   N)typingr   r   r   r   r   r    r
   r   r   r   r   rB   connectionsr   r$   r+   r/   r3   r-   r   r   <module>rK      s   $ < ; , "T]f'"+ fRB{=9 B
 '(!!	++11 11 ++r   