o
    {g8                     @  s   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dZG dd dZG dd dee ZdS )z2Helpers for the 'hello' and legacy hello commands.    )annotationsN)AnyGenericMappingOptional)ObjectId)common)SERVER_TYPE)ClusterTime_DocumentTypedocMapping[str, Any]returnintc                 C  s   |  dstjS |  drtjS |  drtjS |  drJ|  dr%tjS |  tjr.tjS |  tj	r7tjS |  dr?tj
S |  drGtjS tjS |  dd	krTt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)r    r&   j/var/www/bot.gig.net.ua/public_html/telegram/P1/HellBot/venv/lib/python3.10/site-packages/pymongo/hello.py_get_server_type   s*   






r(   c                   @  s    e Zd ZdZdZdZdZdZdS )r   helloismasterisWritablePrimaryz
not masterN)__name__
__module____qualname__CMD
LEGACY_CMDr   r!   LEGACY_ERRORr&   r&   r&   r'   r   9   s    r   c                   @  s  e Zd ZdZdZdOdPd
dZedQddZedRddZedSddZ	edTddZ
edUddZedVddZedRddZedRdd ZedRd!d"ZedRd#d$ZedRd%d&ZedWd(d)ZedXd+d,ZedYd.d/ZedWd0d1ZedZd2d3ZedZd4d5ZedUd6d7Zed[d9d:Zed\d<d=Zed]d?d@Zed^dBdCZed^dDdEZedZdFdGZedXdHdIZedZdJdKZ edWdLdMZ!dNS )_HellozHParse a hello response from the server.

    .. versionadded:: 3.12
    )_doc_server_type_is_writable_is_readable
_awaitableFr   r   	awaitableboolr   Nonec                 C  sJ   t || _|| _| jtjtjtjtjfv | _| j	tj
kp| j| _|| _d S N)r(   r4   r3   r	   r    r%   r$   r   r5   server_typer"   r6   r7   )selfr   r8   r&   r&   r'   __init__I   s   

zHello.__init__c                 C  s   t  | jS )zUThe complete hello command response document.

        .. versionadded:: 3.4
        )copyr3   r=   r&   r&   r'   documentV   s   zHello.documentr   c                 C     | j S r;   )r4   r@   r&   r&   r'   r<   ^      zHello.server_typeset[tuple[str, int]]c                 C  s8   t ttjt| jdg | jdg | jdg S )z;List of hosts, passives, and arbiters known to this server.hostspassivesarbiters)setmapr   
clean_node	itertoolschainr3   r   r@   r&   r&   r'   	all_hostsb   s   zHello.all_hostsr   c                 C  s   | j di S )z&Replica set member tags or empty dict.tagsr3   r   r@   r&   r&   r'   rN   p   s   z
Hello.tagsOptional[tuple[str, int]]c                 C  s    | j drt| j d S dS )z8This server's opinion about who the primary is, or None.primaryN)r3   r   r   partition_noder@   r&   r&   r'   rQ   u   s   zHello.primaryOptional[str]c                 C     | j dS )zReplica set name or None.r   rO   r@   r&   r&   r'   replica_set_name}      zHello.replica_set_namec                 C     | j dtjS )NmaxBsonObjectSize)r3   r   r   MAX_BSON_SIZEr@   r&   r&   r'   max_bson_size      zHello.max_bson_sizec                 C  s   | j dd| j S )NmaxMessageSizeBytes   )r3   r   rZ   r@   r&   r&   r'   max_message_size      zHello.max_message_sizec                 C  rW   )NmaxWriteBatchSize)r3   r   r   MAX_WRITE_BATCH_SIZEr@   r&   r&   r'   max_write_batch_size   r[   zHello.max_write_batch_sizec                 C  rW   )NminWireVersion)r3   r   r   MIN_WIRE_VERSIONr@   r&   r&   r'   min_wire_version   r[   zHello.min_wire_versionc                 C  rW   )NmaxWireVersion)r3   r   r   MAX_WIRE_VERSIONr@   r&   r&   r'   max_wire_version   r[   zHello.max_wire_versionOptional[int]c                 C  rT   )N
setVersionrO   r@   r&   r&   r'   set_version      zHello.set_versionOptional[ObjectId]c                 C  rT   )N
electionIdrO   r@   r&   r&   r'   election_id   rl   zHello.election_idOptional[ClusterTime]c                 C  rT   )Nz$clusterTimerO   r@   r&   r&   r'   cluster_time   rl   zHello.cluster_timec                 C  rT   )NlogicalSessionTimeoutMinutesrO   r@   r&   r&   r'   logical_session_timeout_minutes   rl   z%Hello.logical_session_timeout_minutesc                 C  rB   r;   )r5   r@   r&   r&   r'   is_writable   rC   zHello.is_writablec                 C  rB   r;   )r6   r@   r&   r&   r'   is_readable   rC   zHello.is_readablec                 C  s   | j d}|rt|S d S )Nme)r3   r   r   rJ   )r=   rv   r&   r&   r'   rv      s   
zHello.meOptional[datetime.datetime]c                 C  s   | j di dS )N	lastWritelastWriteDaterO   r@   r&   r&   r'   last_write_date   r_   zHello.last_write_dateOptional[list[str]]c                 C  rT   )NcompressionrO   r@   r&   r&   r'   compressors   rl   zHello.compressors	list[str]c                 C  s   | j dg S )zSupported authentication mechanisms for the current user.

        For example::

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

        saslSupportedMechsrO   r@   r&   r&   r'   sasl_supported_mechs   s   
zHello.sasl_supported_mechsOptional[Mapping[str, Any]]c                 C  rT   )z"The speculativeAuthenticate field.speculativeAuthenticaterO   r@   r&   r&   r'   speculative_authenticate   rV   zHello.speculative_authenticatec                 C  rT   )NtopologyVersionrO   r@   r&   r&   r'   topology_version   rl   zHello.topology_versionc                 C  rB   r;   )r7   r@   r&   r&   r'   r8      rC   zHello.awaitablec                 C  rT   )Nr   rO   r@   r&   r&   r'   
service_id   rl   zHello.service_idc                 C  s   | j ddS )NhelloOkFrO   r@   r&   r&   r'   hello_ok   s   zHello.hello_okc                 C  rT   )NconnectionIdrO   r@   r&   r&   r'   connection_id   rl   zHello.connection_idN)F)r   r   r8   r9   r   r:   )r   r   )r   r   )r   rD   )r   r   )r   rP   )r   rS   )r   ri   )r   rm   )r   rp   )r   r9   )r   rw   )r   r{   )r   r~   )r   r   )"r,   r-   r.   __doc__	__slots__r>   propertyrA   r<   rM   rN   rQ   rU   rZ   r^   rb   re   rh   rk   ro   rq   rs   rt   ru   rv   rz   r}   r   r   r   r8   r   r   r   r&   r&   r&   r'   r2   A   st    r2   )r   r   r   r   )r   
__future__r   r?   datetimerK   typingr   r   r   r   bson.objectidr   pymongor   pymongo.server_typer	   pymongo.typingsr
   r   r(   r   r2   r&   r&   r&   r'   <module>   s   
