
    h_                     \    d Z ddlZddlmZ ddlmZ ddlmZ ddlm	Z	 d Z
 G d d	e      Zy)
z2Helpers for the 'hello' and legacy hello commands.    N)imap)common)HelloCompat)SERVER_TYPEc                    | 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RSOtherr   PRIMARY	RSPrimaryLEGACY_PRIMARYRSSecondary	RSArbiterMongos
Standalone)docs    K/var/www/html/eduruby.in/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dZed        Zed        Zed        Z	ed        Z
ed        Zed	        Zed
        Zed        Zed        Zed        Zed        Zed        Zed        Zed        Zed        Zed        Zed        Zed        Zed        Zed        Zed        Zed        Zed        Zed        Zed        Zed        Z y) Helloz'Parse a hello response from the server.)_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   r$   r#   r   r   r   r   r   r%   server_typer   r&   r'   )selfr   	awaitables      r   __init__zHello.__init__:   s    ,S1	 --!!""$$	2
 
 !,,0G0GG\4K\K\#r    c                 6    | j                   j                         S )zUThe complete hello command response document.

        .. versionadded:: 3.4
        )r#   copyr+   s    r   documentzHello.documentG   s     yy~~r    c                     | j                   S r)   )r$   r0   s    r   r*   zHello.server_typeO          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)setr   r   
clean_node	itertoolschainr#   r   r0   s    r   	all_hostszHello.all_hostsS   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r#   r   r0   s    r   r>   z
Hello.tagsa   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)r#   r   r   partition_noder0   s    r   rA   zHello.primaryf   s1     99==#((9)=>>r    c                 8    | j                   j                  d      S )zReplica set name or None.r   r?   r0   s    r   replica_set_namezHello.replica_set_namen   s     yy}}Y''r    c                 V    | j                   j                  dt        j                        S )NmaxBsonObjectSize)r#   r   r   MAX_BSON_SIZEr0   s    r   max_bson_sizezHello.max_bson_sizes   s    yy}}0&2F2FGGr    c                 T    | j                   j                  dd| j                  z        S )NmaxMessageSizeBytes   )r#   r   rH   r0   s    r   max_message_sizezHello.max_message_sizew   s#    yy}}2A8J8J4JKKr    c                 V    | j                   j                  dt        j                        S )NmaxWriteBatchSize)r#   r   r   MAX_WRITE_BATCH_SIZEr0   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)r#   r   r   MIN_WIRE_VERSIONr0   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)r#   r   r   MAX_WIRE_VERSIONr0   s    r   max_wire_versionzHello.max_wire_version   rU   r    c                 8    | j                   j                  d      S )N
setVersionr?   r0   s    r   set_versionzHello.set_version       yy}}\**r    c                 8    | j                   j                  d      S )N
electionIdr?   r0   s    r   election_idzHello.election_id   r]   r    c                 8    | j                   j                  d      S )Nz$clusterTimer?   r0   s    r   cluster_timezHello.cluster_time   s    yy}}^,,r    c                 8    | j                   j                  d      S )NlogicalSessionTimeoutMinutesr?   r0   s    r   logical_session_timeout_minutesz%Hello.logical_session_timeout_minutes   s    yy}};<<r    c                     | j                   S r)   )r%   r0   s    r   is_writablezHello.is_writable   r3   r    c                     | j                   S r)   )r&   r0   s    r   is_readablezHello.is_readable   r3   r    c                 h    | j                   j                  d      }|rt        j                  |      S y )Nme)r#   r   r   r9   )r+   rk   s     r   rk   zHello.me   s-    YY]]4 $$R(( r    c                 X    | j                   j                  di       j                  d      S )N	lastWritelastWriteDater?   r0   s    r   last_write_datezHello.last_write_date   s"    yy}}["-11/BBr    c                 8    | j                   j                  d      S )Ncompressionr?   r0   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"]

        saslSupportedMechsr?   r0   s    r   sasl_supported_mechszHello.sasl_supported_mechs   s     yy}}1266r    c                 8    | j                   j                  d      S )z"The speculativeAuthenticate field.speculativeAuthenticater?   r0   s    r   speculative_authenticatezHello.speculative_authenticate   s     yy}}677r    c                 8    | j                   j                  d      S )NtopologyVersionr?   r0   s    r   topology_versionzHello.topology_version   s    yy}}.//r    c                     | j                   S r)   )r'   r0   s    r   r,   zHello.awaitable   s    r    c                 8    | j                   j                  d      S )Nr	   r?   r0   s    r   
service_idzHello.service_id   s    yy}}[))r    c                 :    | j                   j                  dd      S )NhelloOkFr?   r0   s    r   hello_okzHello.hello_ok   s    yy}}Y..r    N)F)!__name__
__module____qualname____doc__	__slots__r-   propertyr1   r*   r<   r>   rA   rD   rH   rL   rP   rT   rY   r\   r`   rb   re   rg   ri   rk   ro   rr   ru   rx   r{   r,   r~   r    r    r   r"   r"   5   s#   1VI$     ! ! 
 
 ) )   ( ( H H L L O O H H H H + + + + - - = = ! ! ! ! ) )
 C C , , 	7 	7 8 8 0 0   * * / /r    r"   )r   r:   bson.py3compatr   pymongor   pymongo.hello_compatr   pymongo.server_typer   r   objectr"   r   r    r   <module>r      s,    9    , +&8W/F W/r    