
    nh2                    x   d Z ddlmZ ddlmZmZ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 ddlmZmZ dd	lmZ dd
lmZ ddlmZmZmZ ddlmZ ddlm Z  ddl!m"Z"m#Z# erddl
m$Z$ ddl%m&Z& ddl'm(Z( ddl)m*Z* ddl+m,Z, 	 	 	 	 	 	 	 	 	 	 ddZ-ddZ.ddZ/d dZ0d!dZ1	 	 	 	 	 	 	 	 	 	 	 	 d"dZ2 G d d      Z3y)#zTools to parse mongo client options.

.. seealso:: This module is compatible with both the synchronous and asynchronous PyMongo APIs.
    )annotations)TYPE_CHECKINGAnyMappingOptionalSequencecast)_parse_codec_options)common)CompressionSettings)ConfigurationError)_EventListener_EventListeners)PoolOptions)ReadConcern)_ServerModemake_read_preferenceread_pref_mode_from_name)any_server_selector)get_ssl_context)WriteConcernvalidate_boolean)CodecOptions)MongoCredential)AutoEncryptionOpts)
SSLContext)_ServerSelectorc                    |j                  d| rdnd      }|j                  d      }| s|rddlm}  |||| |||      S y)z!Parse authentication credentials.authmechanismDEFAULTN
authsourcer   )_build_credentials_tuple)getpymongo.auth_sharedr"   )usernamepassworddatabaseoptions	mechanismsourcer"   s          |/var/www/html/SchoolMeal/SchoolMeal/pds_admin_SchoolMeal/Backend/venv/lib/python3.12/site-packages/pymongo/client_options.py_parse_credentialsr,   /   sG     O(YMI[[&F9@'	68XwX`aa    c                    d| v r| d   S | j                  dd      }t        |      }| j                  d      }| j                  dd      }t        |||      S )zParse read preference options.read_preferencereadpreferenceprimaryreadpreferencetagsmaxstalenessseconds)r#   r   r   )r(   namemodetagsmax_stalenesss        r+   _parse_read_preferencer9   <   s`    G#());;'3D#D)D;;+,DKK 5r:MdM::r-   c                    | j                  d      }| j                  d      }| j                  d      }| j                  d      }t        ||||      S )zParse write concern options.w
wtimeoutmsjournalfsync)r#   r   )r(   concernwtimeoutjr>   s        r+   _parse_write_concernrB   H   sK    kk#G{{<(HIAKK E1e44r-   c                :    | j                  d      }t        |      S )zParse read concern options.readconcernlevel)r#   r   )r(   r?   s     r+   _parse_read_concernrE   Q   s    kk,-Gwr-   c           	     F   | j                  d      }|t        d|       | j                  d      }| j                  d      }| j                  d      }| j                  d      }| j                  dd      }| j                  d	d      }| j                  d
d      }g }	dD ]  }
|
| v s| |
   s|	j                  |
         dD ]  }
|
| v s| |
   r|	j                  |
         |	r$|d}n|st        ddj	                  |	      z        |rt        |||||||      }||fS d|fS )zParse ssl options.tlsNtlscertificatekeyfiletlscertificatekeyfilepassword	tlscafile
tlscrlfiletlsallowinvalidcertificatesFtlsallowinvalidhostnamestlsdisableocspendpointcheck)rH   rI   rJ   rK   )rL   rM   rN   TzmTLS has not been enabled but the following tls parameters have been set: %s. Please set `tls=True` or remove.z, )r#   r   appendr   joinr   )r(   use_tlscertfile
passphraseca_certscrlfileallow_invalid_certificatesallow_invalid_hostnamesdisable_ocsp_endpoint_checkenabled_tls_optsoptctxs               r+   _parse_ssl_optionsr\   W   sg   kk% G({{23H<=J{{;'Hkk,'G!(-JE!R%kk*DeL")++.KU"S ) '>gcl##C() ) '>'#,##C() ?G$79=CS9TU  &#'
 +++(((r-   c                   t        | |||      }|j                  dt        j                        }|j                  dt        j                        }|j                  dt        j
                        }|||kD  rt        d      |j                  dt        j                        }	|j                  d      }
|j                  dt        j                        }t        t        t        t              |j                  d            }|j                  d	      }|j                  d
      }|j                  d      }t        |j                  dg       |j                  dd            }t        |      \  }}|j                  d      }|j                  dt        j                        }t!        ||||	|
|||t#        |      ||||||||      S )zParse connection pool options.maxpoolsizeminpoolsizemaxidletimemsz3minPoolSize must be smaller or equal to maxPoolSizeconnecttimeoutmssockettimeoutmswaitqueuetimeoutmsevent_listenersappnamedriver
server_apicompressorszlibcompressionlevelr4   loadbalancedmaxconnecting)max_connectingrg   load_balancedcredentialsis_sync)r,   r#   r   MAX_POOL_SIZEMIN_POOL_SIZEMAX_IDLE_TIME_SEC
ValueErrorCONNECT_TIMEOUTWAIT_QUEUE_TIMEOUTr	   r   r   r   r   r\   MAX_CONNECTINGr   r   )r%   r&   r'   r(   ro   rn   max_pool_sizemin_pool_sizemax_idle_time_secondsconnect_timeoutsocket_timeoutwait_queue_timeoutrd   re   rf   rg   compression_settingsssl_contexttls_allow_invalid_hostnamesrm   rl   s                        r+   _parse_pool_optionsr      s    %Xx7KKKKv/C/CDMKKv/C/CDM#KK9Q9QR ]]%BNOOkk"4f6L6LMO[[!23N %96;T;TU8H^$<=w{{K\?]^Okk)$G[["F\*J.M2&4JB(O 0B'/J,K,KK/M[[&2G2GHN#(%## r-   c                     e 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y))ClientOptionsa&  Read only configuration options for an AsyncMongoClient/MongoClient.

    Should not be instantiated directly by application developers. Access
    a client's options via :attr:`pymongo.mongo_client.AsyncMongoClient.options` or :attr:`pymongo.mongo_client.MongoClient.options`
    instead.
    c                   || _         t        |      | _        |j                  d      | _        |j                  dt
        j                        | _        |j                  dt
        j                        | _	        t        |||||      | _        t        |      | _        |j                  d      | _        t        |      | _        t#        |      | _        |j                  d      | _        |j                  dt
        j(                        | _        |j                  dt
        j,                        | _        |j                  dt
        j0                        | _        |j                  d	t4              | _        |j                  d
      | _        |j                  d      | _        |j                  d      | _        |j                  dt
        j>                        | _         y )Ndirectconnectionlocalthresholdmsserverselectiontimeoutms
replicasetconnectheartbeatfrequencymsretrywrites
retryreadsserver_selectorauto_encryption_optsrj   	timeoutmsservermonitoringmode)!_ClientOptions__optionsr
   _ClientOptions__codec_optionsr#   !_ClientOptions__direct_connectionr   LOCAL_THRESHOLD_MS"_ClientOptions__local_threshold_msSERVER_SELECTION_TIMEOUT(_ClientOptions__server_selection_timeoutr   _ClientOptions__pool_optionsr9   _ClientOptions__read_preference _ClientOptions__replica_set_namerB   _ClientOptions__write_concernrE   _ClientOptions__read_concern_ClientOptions__connectHEARTBEAT_FREQUENCY#_ClientOptions__heartbeat_frequencyRETRY_WRITES_ClientOptions__retry_writesRETRY_READS_ClientOptions__retry_readsr   _ClientOptions__server_selector$_ClientOptions__auto_encryption_opts_ClientOptions__load_balanced_ClientOptions__timeoutSERVER_MONITORING_MODE&_ClientOptions__server_monitoring_mode)selfr%   r&   r'   r(   ro   s         r+   __init__zClientOptions.__init__   ss    !3G<#*;;/A#B $+KK0BFD]D]$^! +2++&(G(G+
' 2(HhPWY`a!7!@")++l";3G<1': Y/%,[[1GIcIc%d"%kk-9L9LM$[[v7I7IJ!(->@S!T&-kk2H&I#&{{>: [1(/"F$A$A)
%r-   c                    | j                   S )z7The original options used to create this ClientOptions.)r   r   s    r+   _optionszClientOptions._options        ~~r-   c                    | j                   S )z>Whether to begin discovering a MongoDB topology automatically.)r   r   s    r+   r   zClientOptions.connect   r   r-   c                    | j                   S )z5A :class:`~bson.codec_options.CodecOptions` instance.)r   r   s    r+   codec_optionszClientOptions.codec_options        ###r-   c                    | j                   S )z:Whether to connect to the deployment in 'Single' topology.)r   r   s    r+   direct_connectionzClientOptions.direct_connection   s     '''r-   c                    | j                   S )z&The local threshold for this instance.)r   r   s    r+   local_threshold_msz ClientOptions.local_threshold_ms   s     (((r-   c                    | j                   S )z:The server selection timeout for this instance in seconds.)r   r   s    r+   server_selection_timeoutz&ClientOptions.server_selection_timeout  s     ...r-   c                    | j                   S )N)r   r   s    r+   r   zClientOptions.server_selector
  s    %%%r-   c                    | j                   S )z$The monitoring frequency in seconds.)r   r   s    r+   heartbeat_frequencyz!ClientOptions.heartbeat_frequency  s     )))r-   c                    | j                   S )z.A :class:`~pymongo.pool.PoolOptions` instance.)r   r   s    r+   pool_optionszClientOptions.pool_options       """r-   c                    | j                   S )zA read preference instance.)r   r   s    r+   r/   zClientOptions.read_preference  s     %%%r-   c                    | j                   S )zReplica set name or None.)r   r   s    r+   replica_set_namezClientOptions.replica_set_name  s     &&&r-   c                    | j                   S )z8A :class:`~pymongo.write_concern.WriteConcern` instance.)r   r   s    r+   write_concernzClientOptions.write_concern"  r   r-   c                    | j                   S )z6A :class:`~pymongo.read_concern.ReadConcern` instance.)r   r   s    r+   read_concernzClientOptions.read_concern'  r   r-   c                    | j                   S )z_The configured timeoutMS converted to seconds, or None.

        .. versionadded:: 4.2
        )r   r   s    r+   timeoutzClientOptions.timeout,  s     ~~r-   c                    | j                   S )z9If this instance should retry supported write operations.)r   r   s    r+   retry_writeszClientOptions.retry_writes4  r   r-   c                    | j                   S )z8If this instance should retry supported read operations.)r   r   s    r+   retry_readszClientOptions.retry_reads9  s     !!!r-   c                    | j                   S )z:A :class:`~pymongo.encryption.AutoEncryptionOpts` or None.)r   r   s    r+   r   z"ClientOptions.auto_encryption_opts>  s     ***r-   c                    | j                   S )z@True if the client was configured to connect to a load balancer.)r   r   s    r+   rm   zClientOptions.load_balancedC  r   r-   c                z    | j                   j                  J | j                   j                  j                         S )zThe event listeners registered for this client.

        See :mod:`~pymongo.monitoring` for details.

        .. versionadded:: 4.0
        )r   _event_listenersrd   r   s    r+   rd   zClientOptions.event_listenersH  s7     ""33???""33CCEEr-   c                    | j                   S )zSThe configured serverMonitoringMode option.

        .. versionadded:: 4.5
        )r   r   s    r+   server_monitoring_modez$ClientOptions.server_monitoring_modeS  s     ,,,r-   N)T)
r%   strr&   r   r'   Optional[str]r(   Mapping[str, Any]ro   bool)returnr   )r   zOptional[bool])r   r   )r   int)r   r   )r   r   )r   r   )r   r   )r   r   )r   r   )r   zOptional[float])r   r   )r   zOptional[AutoEncryptionOpts])r   zlist[_EventListeners])r   r   )__name__
__module____qualname____doc__r   propertyr   r   r   r   r   r   r   r   r   r/   r   r   r   r   r   r   r   rm   rd   r    r-   r+   r   r      s     
 
  
  	 

 # 
  
D     $ $ ( ( ) ) / / & & * * # # & & ' ' $ $ # #   # # " " + + $ $ F F - -r-   r   N)
r%   r   r&   r   r'   r   r(   r   r   zOptional[MongoCredential])r(   r   r   r   )r(   r   r   r   )r(   r   r   r   )r(   r   r   z!tuple[Optional[SSLContext], bool])r%   r   r&   r   r'   r   r(   r   ro   r   r   r   )4r   
__future__r   typingr   r   r   r   r   r	   bson.codec_optionsr
   pymongor   pymongo.compression_supportr   pymongo.errorsr   pymongo.monitoringr   r   pymongo.pool_optionsr   pymongo.read_concernr   pymongo.read_preferencesr   r   r   pymongo.server_selectorsr   pymongo.ssl_supportr   pymongo.write_concernr   r   r   r$   r   pymongo.encryption_optionsr   pymongo.pyopenssl_contextr   pymongo.topology_descriptionr   r,   r9   rB   rE   r\   r   r   r   r-   r+   <module>r      s    # H H 3  ; - > , , 
 9 / @/3=4<

 
,9
DU

	;5 8)v--- - 	-
 - -`W- W-r-   