
    nh:                        d Z ddlmZ ddlZddlZddlZddlmZmZm	Z	m
Z
 ddlmZ ddlmZ ddlmZ ddlmZmZ dd	Z G d
 d      Z G d dee         Zy)z2Helpers for the 'hello' and legacy hello commands.    )annotationsN)AnyGenericMappingOptional)ObjectId)common)SERVER_TYPE)ClusterTime_DocumentTypec                   | j                  d      st        j                  S | j                  d      rt        j                  S | j                  d      rt        j                  S | j                  d      r| j                  d      rt        j
                  S | j                  t        j                        rt        j                  S | j                  t        j                        rt        j                  S | j                  d      rt        j                  S | j                  d      rt        j                  S t        j
                  S | j                  d      d	k(  rt        j                  S t        j                  S )
z0Determine the server type from a hello response.ok	serviceIdisreplicasetsetNamehidden	secondaryarbiterOnlymsgisdbgrid)getr
   UnknownLoadBalancerRSGhostRSOtherHelloCompatPRIMARY	RSPrimaryLEGACY_PRIMARYRSSecondary	RSArbiterMongos
Standalone)docs    s/var/www/html/SchoolMeal/SchoolMeal/pds_admin_SchoolMeal/Backend/venv/lib/python3.12/site-packages/pymongo/hello.py_get_server_typer&      s   774="""
ww{'''		 """		778&&&WW[(()(((WW[//0(((WW[!***WW]#(((&&&	:	%!!!%%%    c                       e Zd ZdZdZdZdZdZy)r   helloismasterisWritablePrimaryz
not masterN)__name__
__module____qualname__CMD
LEGACY_CMDr   r   LEGACY_ERROR r'   r%   r   r   9   s    
CJ!GNLr'   r   c                     e Zd ZdZdZd d!dZed"d       Zed#d       Zed$d       Z	ed%d       Z
ed&d       Zed'd	       Zed#d
       Zed#d       Zed#d       Zed#d       Zed#d       Zed(d       Zed)d       Zed*d       Zed(d       Zed+d       Zed+d       Zed&d       Zed,d       Zed-d       Zed.d       Zed/d       Zed/d       Zed+d       Zed)d       Zed+d       Z ed(d       Z!y)0HellozHParse a hello response from the server.

    .. versionadded:: 3.12
    )_doc_server_type_is_writable_is_readable
_awaitablec                >   t        |      | _        || _        | j                  t        j                  t        j
                  t        j                  t        j                  fv | _        | j                  t        j                  k(  xs | j                  | _        || _        y N)r&   r6   r5   r
   r   r#   r"   r   r7   server_typer    r8   r9   )selfr$   	awaitables      r%   __init__zHello.__init__I   s    ,S1#&	 --!!""$$	2
 
 !,,0G0GG\4K\K\#r'   c                @    t        j                   | j                        S )zUThe complete hello command response document.

        .. versionadded:: 3.4
        )copyr5   r=   s    r%   documentzHello.documentV   s     yy##r'   c                    | j                   S r;   )r6   rB   s    r%   r<   zHello.server_type^          r'   c                   t        t        t        j                  t	        j
                  | j                  j                  dg       | j                  j                  dg       | j                  j                  dg                         S )z;List of hosts, passives, and arbiters known to this server.hostspassivesarbiters)setmapr	   
clean_node	itertoolschainr5   r   rB   s    r%   	all_hostszHello.all_hostsb   sd     !!IIMM'2.IIMM*b1IIMM*b1	
 		
r'   c                :    | j                   j                  di       S )z&Replica set member tags or empty dict.tagsr5   r   rB   s    r%   rQ   z
Hello.tagsp   s     yy}}VR((r'   c                ~    | j                   j                  d      r"t        j                  | j                   d         S y)z8This server's opinion about who the primary is, or None.primaryN)r5   r   r	   partition_noderB   s    r%   rT   zHello.primaryu   s1     99==#((9)=>>r'   c                8    | j                   j                  d      S )zReplica set name or None.r   rR   rB   s    r%   replica_set_namezHello.replica_set_name}   s     yy}}Y''r'   c                V    | j                   j                  dt        j                        S )NmaxBsonObjectSize)r5   r   r	   MAX_BSON_SIZErB   s    r%   max_bson_sizezHello.max_bson_size   s    yy}}0&2F2FGGr'   c                V    | j                   j                  dt        j                        S )NmaxMessageSizeBytes)r5   r   r	   MAX_MESSAGE_SIZErB   s    r%   max_message_sizezHello.max_message_size   s    yy}}2F4K4KLLr'   c                V    | j                   j                  dt        j                        S )NmaxWriteBatchSize)r5   r   r	   MAX_WRITE_BATCH_SIZErB   s    r%   max_write_batch_sizezHello.max_write_batch_size   s    yy}}0&2M2MNNr'   c                V    | j                   j                  dt        j                        S )NminWireVersion)r5   r   r	   MIN_WIRE_VERSIONrB   s    r%   min_wire_versionzHello.min_wire_version       yy}}-v/F/FGGr'   c                V    | j                   j                  dt        j                        S )NmaxWireVersion)r5   r   r	   MAX_WIRE_VERSIONrB   s    r%   max_wire_versionzHello.max_wire_version   rh   r'   c                8    | j                   j                  d      S )N
setVersionrR   rB   s    r%   set_versionzHello.set_version       yy}}\**r'   c                8    | j                   j                  d      S )N
electionIdrR   rB   s    r%   election_idzHello.election_id   rp   r'   c                8    | j                   j                  d      S )Nz$clusterTimerR   rB   s    r%   cluster_timezHello.cluster_time       yy}}^,,r'   c                8    | j                   j                  d      S )NlogicalSessionTimeoutMinutesrR   rB   s    r%   logical_session_timeout_minutesz%Hello.logical_session_timeout_minutes   s    yy}};<<r'   c                    | j                   S r;   )r7   rB   s    r%   is_writablezHello.is_writable   rE   r'   c                    | j                   S r;   )r8   rB   s    r%   is_readablezHello.is_readable   rE   r'   c                h    | j                   j                  d      }|rt        j                  |      S y )Nme)r5   r   r	   rL   )r=   r   s     r%   r   zHello.me   s+    YY]]4 $$R((r'   c                X    | j                   j                  di       j                  d      S )N	lastWritelastWriteDaterR   rB   s    r%   last_write_datezHello.last_write_date   s"    yy}}["-11/BBr'   c                8    | j                   j                  d      S )NcompressionrR   rB   s    r%   compressorszHello.compressors   s    yy}}]++r'   c                :    | j                   j                  dg       S )zSupported authentication mechanisms for the current user.

        For example::

            >>> hello.sasl_supported_mechs
            ["SCRAM-SHA-1", "SCRAM-SHA-256"]

        saslSupportedMechsrR   rB   s    r%   sasl_supported_mechszHello.sasl_supported_mechs   s     yy}}1266r'   c                8    | j                   j                  d      S )z"The speculativeAuthenticate field.speculativeAuthenticaterR   rB   s    r%   speculative_authenticatezHello.speculative_authenticate   s     yy}}677r'   c                8    | j                   j                  d      S )NtopologyVersionrR   rB   s    r%   topology_versionzHello.topology_version   s    yy}}.//r'   c                    | j                   S r;   )r9   rB   s    r%   r>   zHello.awaitable   s    r'   c                8    | j                   j                  d      S )Nr   rR   rB   s    r%   
service_idzHello.service_id   s    yy}}[))r'   c                :    | j                   j                  dd      S )NhelloOkFrR   rB   s    r%   hello_okzHello.hello_ok   s    yy}}Y..r'   c                8    | j                   j                  d      S )NconnectionIdrR   rB   s    r%   connection_idzHello.connection_id   rv   r'   N)F)r$   r   r>   boolreturnNone)r   r   )r   int)r   zset[tuple[str, int]])r   Mapping[str, Any])r   zOptional[tuple[str, int]])r   zOptional[str])r   zOptional[int])r   zOptional[ObjectId])r   zOptional[ClusterTime])r   r   )r   zOptional[datetime.datetime])r   zOptional[list[str]])r   z	list[str])r   zOptional[Mapping[str, Any]])"r,   r-   r.   __doc__	__slots__r?   propertyrC   r<   rO   rQ   rT   rW   r[   r_   rc   rg   rl   ro   rs   ru   ry   r{   r}   r   r   r   r   r   r   r>   r   r   r   r2   r'   r%   r4   r4   A   s<   
 WI$ $ $ ! ! 
 
 ) )   ( ( H H M M O O H H H H + + + + - - = = ! ! ! !   C C , , 	7 	7 8 8 0 0   * * / / - -r'   r4   )r$   r   r   r   )r   
__future__r   rA   datetimerM   typingr   r   r   r   bson.objectidr   pymongor	   pymongo.server_typer
   pymongo.typingsr   r   r&   r   r4   r2   r'   r%   <module>r      sJ    9 "    2 2 "  + 6&8   _-GM" _-r'   