
    jF                       d dl mZ d dlmZ d dlmZ ddlmZmZ ddl	m
Z
mZmZmZ ddlmZ d Z G d	 d
          Z G d de          Z G d de          Z G d de          Z G d d          Z G d d          Z G d d          Z G d d          Z G d de          Z G d dee          Zd Z G d d e          Z G d! d"e          Z G d# d$e          Z G d% d&e          Z G d' d(e          Z d)S )*    )annotations)ABCMeta)Mapping   )deprecation_warnexperimental_warn)DEFAULT_DATABASETRUST_ALL_CERTIFICATES#TRUST_SYSTEM_CA_SIGNED_CERTIFICATESWRITE_ACCESS)ConfigurationErrorc              #     K   t          | d          r%|                                 D ]}|| |         fV  dS | D ]\  }}||fV  dS )a0   Iterate through all items (key-value pairs) within an iterable
    dictionary-like object. If the object has a `keys` method, this is
    used along with `__getitem__` to yield each pair in turn. If no
    `keys` method exists, each iterable element is assumed to be a
    2-tuple of key and value.
    keysN)hasattrr   )iterablekeyvalues      U/lsinfo/ai/hellotax_ai/base_platform/venv/lib/python3.11/site-packages/neo4j/_conf.py
iter_itemsr   #   s       x   ==?? 	% 	%Cx}$$$$$	% 	% # 	 	JCu*	 	    c                      e Zd ZdS )
TrustStoreN)__name__
__module____qualname__ r   r   r   r   2   s        Dr   r   c                      e Zd ZdZdS )TrustSystemCAsa  Used to configure the driver to trust system CAs (default).

    Trust server certificates that can be verified against the system
    certificate authority. This option is primarily intended for use with
    full certificates.

    For example::

        import neo4j

        driver = neo4j.GraphDatabase.driver(
            url, auth=auth, trusted_certificates=neo4j.TrustSystemCAs()
        )
    Nr   r   r   __doc__r   r   r   r   r   7   s          	Dr   r   c                      e Zd ZdZdS )TrustAlla  Used to configure the driver to trust all certificates.

    Trust any server certificate. This ensures that communication
    is encrypted but does not verify the server certificate against a
    certificate authority. This option is primarily intended for use with
    the default auto-generated server certificate.

    .. warning::
        This still leaves you vulnerable to man-in-the-middle attacks. It will
        just prevent eavesdropping "from the side-line" (i.e., without
        intercepting the connection).

    For example::

        import neo4j

        driver = neo4j.GraphDatabase.driver(
            url, auth=auth, trusted_certificates=neo4j.TrustAll()
        )
    Nr   r   r   r   r"   r"   I   s         ( 	Dr   r"   c                      e Zd ZdZd ZdS )TrustCustomCAsa  Used to configure the driver to trust custom CAs.

    Trust server certificates that can be verified against the certificate
    authority at the specified paths. This option is primarily intended for
    self-signed and custom certificates.

    :param certificates (str): paths to the certificates to trust.
        Those are not the certificates you expect to see from the server but
        the CA certificates you expect to be used to sign the server's
        certificate.

    For example::

        import neo4j

        driver = neo4j.GraphDatabase.driver(
            url, auth=auth,
            trusted_certificates=neo4j.TrustCustomCAs(
                "/path/to/ca1.crt", "/path/to/ca2.crt",
            )
        )
    c                    || _         d S N)certs)selfcertificatess     r   __init__zTrustCustomCAs.__init__x   s    !


r   Nr   r   r   r    r*   r   r   r   r$   r$   a   s-         ," " " " "r   r$   c                      e Zd ZdZd ZdS )DeprecatedAliasz+Used when a config option has been renamed.c                    || _         d S r&   )new)r(   r/   s     r   r*   zDeprecatedAlias.__init__   s    r   Nr+   r   r   r   r-   r-   |   s)        55    r   r-   c                      e Zd ZdZddZdS )DeprecatedAlternativezCUsed for deprecated config options that have a similar alternative.Nc                "    || _         || _        d S r&   )r/   	converter)r(   r/   r3   s      r   r*   zDeprecatedAlternative.__init__   s    "r   r&   r+   r   r   r   r1   r1      s.        MM# # # # # #r   r1   c                      e Zd ZdZd ZdS )DeprecatedOptionz7Used for deprecated config options without alternative.c                    || _         d S r&   r   r(   r   s     r   r*   zDeprecatedOption.__init__       


r   Nr+   r   r   r   r5   r5      s)        AA    r   r5   c                      e Zd ZdZd ZdS )ExperimentalOptionz%Used for experimental config options.c                    || _         d S r&   r7   r8   s     r   r*   zExperimentalOption.__init__   r9   r   Nr+   r   r   r   r;   r;      s)        //    r   r;   c                       e Zd Z fdZ xZS )
ConfigTypec                   g i i i i |D ]}t          |          | u r|                                z                      |                                                               |                                                               |                                                               |                                           |                                D ]\  }}|                    d          s+t          |          st          |t          t          f          rFt          |t                    r|j        |<   ft          |t                    r|j        |j        f|<                       |           t          |t$                    r|j        |<   |j        ||<   t          |t(                    r|j        |<   |j        ||<   fd}fdfd}fd}	fd}
fd}fd}|                    d	t          |                     |                    d
t          |                     |                    dt                               |                    dt          |	                     |                    dt          |
                     |                    dt          |                     |                    dt          |                     t-          t.          |                               | ||fd|                                D                       S )N_c                "    t                    S r&   )set)r@   fieldss    r   r   z ConfigType.__new__.<locals>.keys   s    v;;r   c                    t                                                    t                                                    z  S r&   )rB   r   )r@   deprecated_aliasesdeprecated_alternativess    r   _deprecated_keysz,ConfigType.__new__.<locals>._deprecated_keys   s=    *//11221668899: ;r   c                d                         |                     |d          d                   S )Nr&   r   )get)r@   r   rE   rF   s     r   _get_newz$ConfigType.__new__.<locals>._get_new   s6    %)),00g>>qA  r   c                    S r&   r   )r@   rE   s    r   _deprecated_aliasesz/ConfigType.__new__.<locals>._deprecated_aliases   	    %%r   c                    S r&   r   )r@   rF   s    r   _deprecated_alternativesz4ConfigType.__new__.<locals>._deprecated_alternatives   s	    **r   c                    S r&   r   )r@   deprecated_optionss    r   _deprecated_optionsz/ConfigType.__new__.<locals>._deprecated_options   rM   r   c                    S r&   r   )r@   experimental_optionss    r   _experimental_optionsz1ConfigType.__new__.<locals>._experimental_options   s	    ''r   r   rJ   rG   rL   rO   rR   rU   c                6    i | ]\  }}| d           v||S r&   r   ).0kvrG   s      r   
<dictcomp>z&ConfigType.__new__.<locals>.<dictcomp>   sB     C C C1"#+;+;D+A+A"A"A  !!"A"A"Ar   )typer   updaterL   rO   rR   rU   items
startswithcallable
isinstancestaticmethodclassmethodr-   r/   r1   r3   appendr5   r   r;   
setdefaultsuperr>   __new__)mcsnamebases
attributesbaserX   rY   r   rJ   rL   rO   rR   rU   rG   rE   rF   rQ   rT   rC   	__class__s                @@@@@@r   rf   zConfigType.__new__   s)   "$! 	J 	JDDzzS  $))++%"))$*B*B*D*DEEE'..t/L/L/N/NOOO"))$*B*B*D*DEEE$++D,F,F,H,HIII$$&& 	 	DAqS!!A;; a,!<==
 !_-- ()"1%!233 -.UAK-?'*MM!!-.. ()"1% !
1!/00 *+'$Q' !
1
	 	 	 	 		; 	; 	; 	; 	; 	;	 	 	 	 	 	
	& 	& 	& 	& 	&	+ 	+ 	+ 	+ 	+	& 	& 	& 	& 	&	( 	( 	( 	( 	( 	fk$&7&7888j)(33	5 	5 	50)*:;;	= 	= 	=3)*=>>	@ 	@ 	@8)*BCC	E 	E 	E3)*=>>	@ 	@ 	@5)*?@@	B 	B 	B Z%%--u C C C C
0@0@0B0B C C C
 
 	
r   )r   r   r   rf   __classcell__)rl   s   @r   r>   r>      sA        O
 O
 O
 O
 O
 O
 O
 O
 O
r   r>   c                  z    e Zd ZdZed             Zed             Zed             ZddZ	d Z
d Zd	 Zd
 Zd ZdS )Configz2 Base class for all configuration containers.
    c                $   g }|D ]Q}t          |t                    st          d|z            |                    |                    |                      R| r7t          dd                    |                                           z            |S )Nz%r is not a Config subclasszUnexpected config keys: %s, )
issubclassro   	TypeErrorrc   _consumer   joinr   )dataconfig_classesvaluesconfig_classs       r   consume_chainzConfig.consume_chain   s    * 	7 	7LlF33 N = LMMMMM,//556666 	\$%ADIIdiikkDZDZ%Z[[[r   c                6    |                      ||           \  }|S r&   )rz   )clsrv   configs      r   consumezConfig.consume   s    ##D#..r   c                    i }|rW|                                  |                                 z  D ]-}	 |                    |          }|||<   # t          $ r Y *w xY w | |          S r&   )r   rG   popKeyError)r|   rv   r}   r   r   s        r   rt   zConfig._consume  s     	(xxzzC$8$8$:$:: ( (( HHSMME #(F3KK     D s6{{s   A
AATc                n    t          t          |                     fdg }                                D ]N\  }}|G	  ||           # t          $ r,}|j        |fk    s |                    |           Y d }~Fd }~ww xY wO|r%t          dd                    |          z             d S )Nc                   |                                  v rr8|                                 v r"t          d                    |                      r8|                                 v r"t          d                    |                      t          | |           d S |                                 v r                    |           }|v r#t          d                    ||                     r#t          d                    | |                     | 
                                v r ||           d S                                 |          \  }} ||           d S t          |           )Nz"The '{}' config key is deprecated.zgThe '{}' config key is experimental. It might be changed or removed any time even without prior notice.z+Cannot specify both '{}' and '{}' in configz:The '{}' config key is deprecated, please use '{}' instead)r   rR   r   formatrU   r   setattrrG   rJ   r   rL   rO   AttributeError)	rX   rY   k0r@   r3   	data_dictr(   set_attrwarns	        r   r   z!Config.__update.<locals>.set_attr  s   DIIKK >A!9!9!;!;;;$ &3396!99> > > A!;!;!=!===%((.q		  
 a#####d++----]]1%%??,EA    $""(&B--   002222HROOOOO#'#@#@#B#B1#ELAyIdA&&&&&$Q'''r   zUnexpected config keys: rq   )dictr   r]   r   argsrc   r   ru   )	r(   rv   r   rejected_keysr   r   excr   r   s	   ` `    @@r   __updatezConfig.__update  s%   D))**		( 	( 	( 	( 	( 	( 	( 	(@ #//++ 	. 	.JC .HS%((((% . . .8v--!((--------. !  	A$%?'+yy'?'?&@ A A A	A 	As   A
B
"BB
c                    |D ]D}t          |t                    r|                     |d           /|                     |           E|                     |           d S )NF)r   )r`   ro   _Config__update)r(   r   kwargsargs       r   r*   zConfig.__init__?  si     	# 	#C#v&& #c....c""""fr   c           
         g }| D ]+}|                     d|dt          | |                     ,d| j        j        d                    |          dS )N =< >)rc   getattrrl   r   ru   )r(   attrsr   s      r   __repr__zConfig.__repr__G  si     	? 	?CLLLSSS'$*<*<*<=>>>>	?>22BGGENNNNCCr   c                D    t          |                                           S r&   )lenr   r(   s    r   __len__zConfig.__len__M  s    499;;r   c                "    t          | |          S r&   )r   )r(   r   s     r   __getitem__zConfig.__getitem__P  s    tS!!!r   c                D    t          |                                           S r&   )iterr   r   s    r   __iter__zConfig.__iter__S  s    DIIKK   r   N)T)r   r   r   r    ra   rz   rb   r~   rt   r   r*   r   r   r   r   r   r   r   ro   ro      s            \   [ 
 
 [
/A /A /A /Ab  D D D     " " "! ! ! ! !r   ro   )	metaclassc                    |t           k    rt                      | _        d S |t          k    rt	                      | _        d S d S r&   )r   r   trusted_certificatesr
   r"   )pool_configtrusts     r   _trust_to_trusted_certificatesr   W  sH    333+9+;+;(((	(	(	(+3::((( 
)	(r   c                  t    e Zd ZdZdZdZdZ ede          Z	dZ
dZ e            ZdZdZdZdZdZdZdZd	 ZdS )

PoolConfigz$ Connection pool configuration.
    i  d         >@r   NFTc                   | j         | j         S | j        sd S dd l}|                    |j                  }|j        j        |_        t          | j	        t                    rd|_        |j        |_        nyt          | j	        t                    r8d|_        |j        |_        | j	        j        D ]}|                    |           n'd|_        |j        |_        |                                 |S )Nr   FT)ssl_context	encryptedssl
SSLContextPROTOCOL_TLS_CLIENT
TLSVersionTLSv1_2minimum_versionr`   r   r"   check_hostname	CERT_NONEverify_moder$   CERT_REQUIREDr'   load_verify_locationsload_default_certs)r(   r   r   certs       r   get_ssl_contextzPoolConfig.get_ssl_context  s   '##~ 	4


 nnS%<== '*n&<#d/:: 	-).K&&)mK##1>BB 	-)-K&&)&7K#17 8 811$77778
 *.K&&)&7K# **,,,r   )r   r   r   r    max_connection_lifetimemax_connection_pool_sizeconnection_timeoutr1   r   r   resolverr   r   r   r   
user_agent
keep_aliveauthnotifications_min_severity!notifications_disabled_categoriestelemetry_disabledr   r   r   r   r   r   ^  s          #  #  "! > E H I *>++ K J J D "& )-% - - - - -r   r   c                  6    e Zd ZdZdZdZdZdZdZe	Z
dZdZdZdS )	WorkspaceConfigz WorkSpace configuration.
    g      N@r   g      ?g       @g?i  N)r   r   r   r    connection_acquisition_timeoutmax_transaction_retry_timeinitial_retry_delayretry_delay_multiplierretry_delay_jitter_factorr	   database
fetch_sizeimpersonated_userbookmark_managerr   r   r   r   r     s`          &*" "&  ! !$  H
 J  r   r   c                  &    e Zd ZdZdZeZdZdZdZ	dS )SessionConfigz Session configuration.
    N)
r   r   r   r    	bookmarksr   default_access_moder   r   r   r   r   r   r   r     s@          I ' D "& )-%%%r   r   c                      e Zd ZdZdZdZdS )TransactionConfigz Transaction configuration. This is internal for now.

    neo4j.session.begin_transaction
    neo4j.Query
    neo4j.unit_of_work

    are both using the same settings.
    N)r   r   r   r    metadatatimeoutr   r   r   r   r     s&          H GGGr   r   c                      e Zd ZdZdZdS )RoutingConfigz= Neo4jDriver routing settings. This is internal for now.
    r   N)r   r   r   r    routing_table_purge_delayr   r   r   r   r     s"          !%r   r   N)!
__future__r   abcr   collections.abcr   _metar   r   apir	   r
   r   r   
exceptionsr   r   r   r   r"   r$   r-   r1   r5   r;   r>   ro   r   r   r   r   r   r   r   r   r   <module>r      sm  " # " " " " "       # # # # # #                   + * * * * *  	 	 	 	 	 	 	 	
	 	 	 	 	Z 	 	 	$	 	 	 	 	z 	 	 	0" " " " "Z " " "6       # # # # # # # #              Q
 Q
 Q
 Q
 Q
 Q
 Q
 Q
hg! g! g! g! g!W
 g! g! g! g!T6 6 6n n n n n n n nb$ $ $ $ $f $ $ $P- - - - -O - - -(        % % % % %F % % % % %r   