
    Rǻi2                       U d Z ddlmZ ddlZddlmZ ddl	m
Z ej                  rddlmZ neZg dZd	Zd
ed<   dZd
ed<   dZd
ed<   dZd
ed<   dZd
ed<   dZd
ed<   dZd
ed<   dZd
ed<   dZd
ed<   dZd
ed<   dZded<    G d  d!      ZeZee e f   ez  dz  Z!d"ed#<   d1d2d$Z"d3d%Z#d4d&Z$	 	 	 	 	 	 	 	 	 	 	 	 d5d'Z% G d( d)      Z& G d* d+      Z' G d, d-eejP                  .      Z) G d/ d0eejP                  .      Z*y)6zBase classes and helpers.    )annotationsN   )_typing)Address)Protocol)DEFAULT_DATABASEREAD_ACCESSSYSTEM_DATABASEURI_SCHEME_BOLTURI_SCHEME_BOLT_ROUTINGURI_SCHEME_BOLT_SECURE'URI_SCHEME_BOLT_SELF_SIGNED_CERTIFICATEURI_SCHEME_NEO4JURI_SCHEME_NEO4J_SECURE(URI_SCHEME_NEO4J_SELF_SIGNED_CERTIFICATEWRITE_ACCESSAsyncBookmarkManagerAuth	AuthTokenBookmarkManager	Bookmarks
ServerInfo
basic_authbearer_authcustom_authkerberos_authREADz_t.Final[str]r	   WRITEr   boltr   zbolt+sscr   zbolt+sr   neo4jr   z	neo4j+sscr   zneo4j+sr   zbolt+routingr   systemr
   z_t.Final[None]r   c                  :    e Zd ZdZ	 d	 	 	 	 	 	 	 	 	 	 	 ddZddZy)r   aG  
    Container for auth details.

    :param scheme: specifies the type of authentication, examples: "basic",
                   "kerberos"
    :type scheme: str | None
    :param principal: specifies who is being authenticated
    :type principal: str | None
    :param credentials: authenticates the principal
    :type credentials: str | None
    :param realm: specifies the authentication provider
    :type realm: str | None
    :param parameters: extra key word parameters passed along to the
                       authentication provider
    :type parameters: typing.Any
    Nc                \    || _         ||| _        |r|| _        |r|| _        |r|| _        y y N)scheme	principalcredentialsrealm
parameters)selfr%   r&   r'   r(   r)   s         G/opt/lhia/marcimex/agent/venv/lib/python3.12/site-packages/neo4j/api.py__init__zAuth.__init__`   s>       &DN*DDJ(DO     c                \    t        |t              st        S t        |       t        |      k(  S r$   )
isinstancer   NotImplementedvars)r*   others     r+   __eq__zAuth.__eq__t   s%    %&!!DzT%[((r-   r$   )r%   
str | Noner&   r4   r'   r4   r(   r4   r)   _t.AnyreturnNone)r2   objectr6   bool)__name__
__module____qualname____doc__r,   r3    r-   r+   r   r   N   sP    , !)) )  	)
 ) ) 
)()r-   r   z_t.TypeAlias_TAuthc                    t        d| ||      S )a  
    Generate a basic auth token for a given user and password.

    This will set the scheme to "basic" for the auth token.

    :param user: user name, this will set the principal
    :param password: current password, this will set the credentials
    :param realm: specifies the authentication provider

    :returns: auth token for use with :meth:`GraphDatabase.driver` or
        :meth:`AsyncGraphDatabase.driver`
    basicr   )userpasswordr(   s      r+   r   r      s     x//r-   c                    t        dd|       S )ac  
    Generate a kerberos auth token with the base64 encoded ticket.

    This will set the scheme to "kerberos" for the auth token.

    :param base64_encoded_ticket: a base64 encoded service ticket, this will
        set the credentials

    :returns: auth token for use with :meth:`GraphDatabase.driver` or
        :meth:`AsyncGraphDatabase.driver`
    kerberos rB   )base64_encoded_tickets    r+   r   r      s     
B 566r-   c                    t        dd|       S )ae  
    Generate an auth token for Single-Sign-On providers.

    This will set the scheme to "bearer" for the auth token.

    :param base64_encoded_token: a base64 encoded authentication token
        generated by a Single-Sign-On provider.

    :returns: auth token for use with :meth:`GraphDatabase.driver` or
        :meth:`AsyncGraphDatabase.driver`
    bearerNrB   )base64_encoded_tokens    r+   r   r      s     $ 455r-   c                     t        || ||fi |S )a  
    Generate a custom auth token.

    :param principal: specifies who is being authenticated
    :param credentials: authenticates the principal
    :param realm: specifies the authentication provider
    :param scheme: specifies the type of authentication
    :param parameters: extra key word parameters passed along to the
                       authentication provider

    :returns: auth token for use with :meth:`GraphDatabase.driver` or
        :meth:`AsyncGraphDatabase.driver`
    rB   )r&   r'   r(   r%   r)   s        r+   r   r      s    ( 	;DDDr-   c                  R    e Zd ZdZd Zd	dZd
dZddZedd       Z	e
dd       Zy)r   aG  
    Container for an immutable set of bookmark string values.

    Bookmarks are used to causally chain sessions.
    See :meth:`Session.last_bookmarks` or :meth:`AsyncSession.last_bookmarks`
    for more information.

    Use addition to combine multiple Bookmarks objects::

        bookmarks3 = bookmarks1 + bookmarks2
    c                "    t               | _        y r$   )	frozenset_raw_valuesr*   s    r+   r,   zBookmarks.__init__   s    $;r-   c           
         dj                  dj                  t        t        t	        | j
                                          S )zc
        Represent the container as str.

        :returns: repr string with sorted values
        z<Bookmarks values={{{}}}>z, )formatjoinmapreprsortedrP   rQ   s    r+   __repr__zBookmarks.__repr__   s5     +11IIc$t'7'7 89:
 	
r-   c                ,    t        | j                        S )z6Indicate whether there are bookmarks in the container.)r9   rP   rQ   s    r+   __bool__zBookmarks.__bool__   s    D$$%%r-   c                    t        |t              r4|s| S | j                         }| j                  |j                  z  |_        |S t        S )z!Add multiple containers together.)r/   r   	__class__rP   r0   )r*   r2   rets      r+   __add__zBookmarks.__add__   sC    eY'.."C"..1B1BBCOJr-   c                    | j                   S )z
        The raw bookmark values.

        You should not need to access them unless you want to serialize
        bookmarks.

        :returns: immutable list of bookmark string values
        :rtype: frozenset[str]
        )rP   rQ   s    r+   
raw_valueszBookmarks.raw_values   s     r-   c                B   t        |t              r|f} |        }g }|D ]L  }t        |t              st        dt        |             	 |j	                  d       |j                  |       N t        |      |_	        |S # t
        $ r}t        d| d      |d}~ww xY w)z
        Create a Bookmarks object from a list of raw bookmark string values.

        You should not need to use this method unless you want to deserialize
        bookmarks.

        :param values: ASCII string values (raw bookmarks)
        z'Raw bookmark values must be str. Found asciiz
The value z is not ASCIIN)
r/   str	TypeErrortypeencodeUnicodeEncodeError
ValueErrorappendrO   rP   )clsvaluesobj	bookmarksvaluees         r+   from_raw_valueszBookmarks.from_raw_values   s     fc" YFe	 		$EeS)=d5k]K KW% U#		$ $I.
	 & K :eWM!BCJKs   
B  	B	BBNr6   rc   )r6   r9   )r2   r   r6   r   )r6   zfrozenset[str])rk   z_t.Iterable[str]r6   r   )r:   r;   r<   r=   r,   rX   rZ   r^   propertyr`   classmethodrp   r>   r-   r+   r   r      sC    
'
& 
  
   r-   r   c                  V    e Zd ZdZddZed	d       Zed
d       Zedd       ZddZ	y)r   z?Represents a package of information relating to a Neo4j server.c                .    || _         || _        i | _        y r$   )_address_protocol_version	_metadata)r*   addressprotocol_versions      r+   r,   zServerInfo.__init__  s    !1!r-   c                    | j                   S )z%Network address of the remote server.)rv   rQ   s    r+   ry   zServerInfo.address!  s     }}r-   c                    | j                   S )z
        Bolt protocol version with which the remote server communicates.

        This is returned as a 2-:class:`tuple` of ``(major, minor)``
        integers.
        )rw   rQ   s    r+   rz   zServerInfo.protocol_version&  s     %%%r-   c                J    t        | j                  j                  d            S )zAServer agent string by which the remote server identifies itself.server)rc   rx   getrQ   s    r+   agentzServerInfo.agent0  s     4>>%%h/00r-   c                :    | j                   j                  |       y)z
        Update server information with extra metadata.

        This is typically drawn from the metadata received after successful
        connection initialisation.
        N)rx   update)r*   metadatas     r+   r   zServerInfo.update5  s     	h'r-   N)ry   _Addressrz   tuple[int, int])r6   r   )r6   r   rq   )r   dictr6   r7   )
r:   r;   r<   r=   r,   rr   ry   rz   r   r   r>   r-   r+   r   r     sK    I"
   & & 1 1(r-   r   c                  h    e Zd ZdZej
                  	 	 	 	 	 	 dd       Zej
                  dd       Zy)r   a  
    Class to manage bookmarks throughout the driver's lifetime.

    Neo4j clusters are eventually consistent, meaning that there is no
    guarantee a query will be able to read changes made by a previous query.
    For cases where such a guarantee is necessary, the server provides
    bookmarks to the client. A bookmark is an abstract token that represents
    some state of the database. By passing one or multiple bookmarks along
    with a query, the server will make sure that the query will not get
    executed before the represented state(s) (or a later state) have been
    established.

    The bookmark manager is an interface used by the driver for keeping
    track of the bookmarks and this way keeping sessions automatically
    consistent. Configure the driver to use a specific bookmark manager with
    :ref:`bookmark-manager-ref`.

    This class is just an abstract base class that defines the required
    interface. Create a child class to implement a specific bookmark manager
    or make use of the default implementation provided by the driver through
    :meth:`.GraphDatabase.bookmark_manager`.

    .. note::
        All methods must be concurrency safe.

    .. versionadded:: 5.0

    .. versionchanged:: 5.3
        The bookmark manager no longer tracks bookmarks per database.
        This effectively changes the signature of almost all bookmark
        manager related methods:

        * :meth:`.update_bookmarks` has no longer a ``database`` argument.
        * :meth:`.get_bookmarks` has no longer a ``database`` argument.
        * The ``get_all_bookmarks`` method was removed.
        * The ``forget`` method was removed.

    .. versionchanged:: 5.8 Stabilized from experimental.
    c                     y)z
        Handle bookmark updates.

        :param previous_bookmarks:
            The bookmarks used at the start of a transaction
        :param new_bookmarks:
            The new bookmarks retrieved at the end of a transaction
        Nr>   r*   previous_bookmarksnew_bookmarkss      r+   update_bookmarksz BookmarkManager.update_bookmarksh  s     	r-   c                     y)z~
        Return the bookmarks stored in the bookmark manager.

        :returns: The bookmarks for the given database
        Nr>   rQ   s    r+   get_bookmarkszBookmarkManager.get_bookmarksx  s     	r-   Nr   _t.Collection[str]r   r   r6   r7   r6   r   )r:   r;   r<   r=   _abcabstractmethodr   r   r>   r-   r+   r   r   ?  sX    &P 
. * 
	  
 r-   r   )	metaclassc                      e Zd ZdZej
                  	 	 	 	 	 	 dd       Zej                  j                  e_        ej
                  dd       Zej                  j                  e_        y)r   a  
    Same as :class:`.BookmarkManager` but with async methods.

    The driver comes with a default implementation of the async bookmark
    manager accessible through :attr:`.AsyncGraphDatabase.bookmark_manager()`.

    .. versionadded:: 5.0

    .. versionchanged:: 5.3
        See :class:`.BookmarkManager` for changes.

    .. versionchanged:: 5.8 Stabilized from experimental.
    c                   K   y wr$   r>   r   s      r+   r   z%AsyncBookmarkManager.update_bookmarks  s     
    c                   K   y wr$   r>   rQ   s    r+   r   z"AsyncBookmarkManager.get_bookmarks  s	     9<r   Nr   r   )	r:   r;   r<   r=   r   r   r   r   r   r>   r-   r+   r   r     s|     
. * 
	   /??GG	< <+99AAMr-   r   r$   )rC   rc   rD   rc   r(   r4   r6   r   )rH   rc   r6   r   )rK   rc   r6   r   )r&   r4   r'   r4   r(   r4   r%   r4   r)   r5   r6   r   )+r=   
__future__r   _abcr   rG   r   _t_addressingr   r   TYPE_CHECKINGr   	_Protocolr8   __all__r	   __annotations__r   r   r   r   r   r   r   r   r
   r   r   r   tuplerc   r?   r   r   r   r   r   r   ABCMetar   r   r>   r-   r+   <module>r      sk  "   '   - .I2 $] #%m %!' '9C ' C(0  0") - ):E (- E)2  2)7  7!) )#' . ')) ))Z 	S#X-4 40 76EEE E 	E
 E 
E.Q Qh#( #(L@i4<< @FB9 Br-   