
    i)iL2                    T   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/d0d#Z0d1d'Z1d2d)Z2 G d* d+          Z3d,S )3zTools 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)_ServerSelectorusernamestrpassworddatabaseOptional[str]optionsMapping[str, Any]returnOptional[MongoCredential]c                    |                     d| rdnd          }|                     d          }| s|rddlm}  |||| |||          S dS )z!Parse authentication credentials.authmechanismDEFAULTN
authsourcer   )_build_credentials_tuple)getpymongo.auth_sharedr+   )r   r    r!   r#   	mechanismsourcer+   s          h/Users/user/workspace/sujinbaek/cqa-test-app/venv/lib/python3.11/site-packages/pymongo/client_options.py_parse_credentialsr1   /   su     O(-LYYMMI[[&&F b9 b@@@@@@''	68XwX`aaa4    r   c                    d| v r| d         S |                      dd          }t          |          }|                      d          }|                      dd          }t          |||          S )zParse read preference options.read_preferencereadpreferenceprimaryreadpreferencetagsmaxstalenessseconds)r,   r   r   )r#   namemodetagsmax_stalenesss        r0   _parse_read_preferencer>   <   sr    G##());;'33D#D))D;;+,,DKK 5r::MdM:::r2   r   c                    |                      d          }|                      d          }|                      d          }|                      d          }t          ||||          S )zParse write concern options.w
wtimeoutmsjournalfsync)r,   r   )r#   concernwtimeoutjrC   s        r0   _parse_write_concernrG   H   sZ    kk#G{{<((HIAKK  E1e444r2   r   c                J    |                      d          }t          |          S )zParse read concern options.readconcernlevel)r,   r   )r#   rD   s     r0   _parse_read_concernrJ   Q   s"    kk,--Gwr2   is_syncbool!tuple[Optional[SSLContext], bool]c           
        |                      d          }|t          d|           |                      d          }|                      d          }|                      d          }|                      d          }|                      dd          }|                      d	d          }|                      d
d          }	g }
dD ]#}|| v r| |         r|
                    |           $dD ]#}|| v r| |         s|
                    |           $|
r,|d}n'|s%t          dd                    |
          z            |rt          |||||||	|          }||fS d|fS )zParse ssl options.tlsNtlscertificatekeyfiletlscertificatekeyfilepassword	tlscafile
tlscrlfiletlsallowinvalidcertificatesFtlsallowinvalidhostnamestlsdisableocspendpointcheck)rP   rQ   rR   rS   )rT   rU   rV   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#   rK   use_tlscertfile
passphraseca_certscrlfileallow_invalid_certificatesallow_invalid_hostnamesdisable_ocsp_endpoint_checkenabled_tls_optsoptctxs                r0   _parse_ssl_optionsrd   W   s    kk%  G((({{233H<==J{{;''Hkk,''G!(-JE!R!R%kk*DeLL")++.KU"S"S ) ) '>>gcl>##C((( ) ) '>>'#,>##C((( 
?GG 	$79=CS9T9TU    ,&#'	
 	
 +++(((r2   r   c                   t          | |||          }|                    dt          j                  }|                    dt          j                  }|                    dt          j                  }|||k    rt          d          |                    dt          j                  }	|                    d          }
|                    dt          j                  }t          t          t          t                            |                    d	                    }|                    d
          }|                    d          }|                    d          }t          |                    dg           |                    dd                    }t          ||          \  }}|                    d          }|                    dt          j                  }t!          ||||	|
|||t#          |          ||||||||          S )zParse connection pool options.maxpoolsizeminpoolsizemaxidletimemsNz3minPoolSize must be smaller or equal to maxPoolSizeconnecttimeoutmssockettimeoutmswaitqueuetimeoutmsevent_listenersappnamedriver
server_apicompressorszlibcompressionlevelr9   loadbalancedmaxconnecting)max_connectingro   load_balancedcredentialsrK   )r1   r,   r   MAX_POOL_SIZEMIN_POOL_SIZEMAX_IDLE_TIME_SEC
ValueErrorCONNECT_TIMEOUTWAIT_QUEUE_TIMEOUTr	   r   r   r   r   rd   MAX_CONNECTINGr   r   )r   r    r!   r#   rK   rv   max_pool_sizemin_pool_sizemax_idle_time_secondsconnect_timeoutsocket_timeoutwait_queue_timeoutrl   rm   rn   ro   compression_settingsssl_contexttls_allow_invalid_hostnamesru   rt   s                        r0   _parse_pool_optionsr      s    %Xx7KKKKKv/CDDMKKv/CDDM#KK9QRR ]]%B%BNOOOkk"4f6LMMO[[!233N %96;TUU8H^$<=w{{K\?]?]^^Okk)$$G[[""F\**J.M2&&4JB(O(O  0B'7/S/S,K,KK//M[[&2GHHN#((%##   r2   c                     e Zd ZdZ	 d.d/dZed0d            Zed1d            Zed2d            Zed1d            Z	ed3d            Z
ed3d            Zed4d            Zed3d            Zed5d            Zed6d            Zed7d            Zed8d             Zed9d"            Zed:d$            Zed;d%            Zed;d&            Zed<d(            Zed1d)            Zed=d+            Zed>d,            Zd-S )?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.
    Tr   r   r    r!   r"   r#   r$   rK   rL   c                   || _         t          |          | _        |                    d          | _        |                    dt
          j                  | _        |                    dt
          j                  | _	        t          |||||          | _        t          |          | _        |                    d          | _        t          |          | _        t#          |          | _        |                    d          | _        |                    dt
          j                  | _        |                    dt
          j                  | _        |                    dt
          j                  | _        |                    d	t4                    | _        |                    d
          | _        |                    d          | _        |                    d          | _        |                    dt
          j                  | _         d S )Ndirectconnectionlocalthresholdmsserverselectiontimeoutms
replicasetconnectheartbeatfrequencymsretrywrites
retryreadsserver_selectorauto_encryption_optsrr   	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_optionsr>   _ClientOptions__read_preference _ClientOptions__replica_set_namerG   _ClientOptions__write_concernrJ   _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#   rK   s         r0   __init__zClientOptions.__init__   s    !3G<<#*;;/A#B#B $+KK0BFD]$^$^! +2++&(G+
 +
' 2(HhPWY`aa!7!@!@")++l";";3G<<1':: Y//%,[[1GIc%d%d"%kk-9LMM$[[v7IJJ!(->@S!T!T&-kk2H&I&I#&{{>:: [11(/"F$A)
 )
%%%r2   r%   c                    | j         S )z7The original options used to create this ClientOptions.)r   r   s    r0   _optionszClientOptions._options        ~r2   Optional[bool]c                    | j         S )z>Whether to begin discovering a MongoDB topology automatically.)r   r   s    r0   r   zClientOptions.connect   r   r2   CodecOptions[Any]c                    | j         S )z5A :class:`~bson.codec_options.CodecOptions` instance.)r   r   s    r0   codec_optionszClientOptions.codec_options        ##r2   c                    | j         S )z:Whether to connect to the deployment in 'Single' topology.)r   r   s    r0   direct_connectionzClientOptions.direct_connection   s     ''r2   intc                    | j         S )z&The local threshold for this instance.)r   r   s    r0   local_threshold_msz ClientOptions.local_threshold_ms  s     ((r2   c                    | j         S )z:The server selection timeout for this instance in seconds.)r   r   s    r0   server_selection_timeoutz&ClientOptions.server_selection_timeout  s     ..r2   r   c                    | j         S )N)r   r   s    r0   r   zClientOptions.server_selector  s    %%r2   c                    | j         S )z$The monitoring frequency in seconds.)r   r   s    r0   heartbeat_frequencyz!ClientOptions.heartbeat_frequency  s     ))r2   r   c                    | j         S )z.A :class:`~pymongo.pool.PoolOptions` instance.)r   r   s    r0   pool_optionszClientOptions.pool_options       ""r2   r   c                    | j         S )zA read preference instance.)r   r   s    r0   r4   zClientOptions.read_preference  s     %%r2   c                    | j         S )zReplica set name or None.)r   r   s    r0   replica_set_namezClientOptions.replica_set_name   s     &&r2   r   c                    | j         S )z8A :class:`~pymongo.write_concern.WriteConcern` instance.)r   r   s    r0   write_concernzClientOptions.write_concern%  r   r2   r   c                    | j         S )z6A :class:`~pymongo.read_concern.ReadConcern` instance.)r   r   s    r0   read_concernzClientOptions.read_concern*  r   r2   Optional[float]c                    | j         S )z_The configured timeoutMS converted to seconds, or None.

        .. versionadded:: 4.2
        )r   r   s    r0   timeoutzClientOptions.timeout/  s     ~r2   c                    | j         S )z9If this instance should retry supported write operations.)r   r   s    r0   retry_writeszClientOptions.retry_writes7  r   r2   c                    | j         S )z8If this instance should retry supported read operations.)r   r   s    r0   retry_readszClientOptions.retry_reads<  s     !!r2   Optional[AutoEncryptionOpts]c                    | j         S )z:A :class:`~pymongo.encryption.AutoEncryptionOpts` or None.)r   r   s    r0   r   z"ClientOptions.auto_encryption_optsA  s     **r2   c                    | j         S )z@True if the client was configured to connect to a load balancer.)r   r   s    r0   ru   zClientOptions.load_balancedF  r   r2   list[_EventListeners]c                Z    | j         j        J | j         j                                        S )zThe event listeners registered for this client.

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

        .. versionadded:: 4.0
        )r   _event_listenersrl   r   s    r0   rl   zClientOptions.event_listenersK  s.     "3???"3CCEEEr2   c                    | j         S )zSThe configured serverMonitoringMode option.

        .. versionadded:: 4.5
        )r   r   s    r0   server_monitoring_modez$ClientOptions.server_monitoring_modeV  s     ,,r2   N)T)
r   r   r    r   r!   r"   r#   r$   rK   rL   )r%   r$   )r%   r   )r%   r   )r%   r   )r%   r   )r%   r   )r%   r   )r%   r"   )r%   r   )r%   r   )r%   r   )r%   rL   )r%   r   )r%   r   )r%   r   )__name__
__module____qualname____doc__r   propertyr   r   r   r   r   r   r   r   r   r4   r   r   r   r   r   r   r   ru   rl   r    r2   r0   r   r      s          
  
  
  
  
D    X    X $ $ $ X$ ( ( ( X( ) ) ) X) / / / X/ & & & X& * * * X* # # # X# & & & X& ' ' ' X' $ $ $ X$ # # # X#    X # # # X# " " " X" + + + X+ $ $ $ X$ F F F XF - - - X- - -r2   r   N)
r   r   r    r   r!   r"   r#   r$   r%   r&   )r#   r$   r%   r   )r#   r$   r%   r   )r#   r$   r%   r   )r#   r$   rK   rL   r%   rM   )r   r   r    r   r!   r"   r#   r$   rK   rL   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   r1   r>   rG   rJ   rd   r   r   r   r2   r0   <module>r      s_    # " " " " " H H H H H H H H H H H H H H H H 3 3 3 3 3 3       ; ; ; ; ; ; - - - - - - > > > > > > > > , , , , , , , , , , , ,         
 9 8 8 8 8 8 / / / / / / @ @ @ @ @ @ @ @ =//////333333======444444<<<<<<
 
 
 
	; 	; 	; 	;5 5 5 5       ;) ;) ;) ;)|- - - -`W- W- W- W- W- W- W- W- W- W-r2   