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.
| 195 | |
| 196 | |
| 197 | class ClientOptions: |
| 198 | """Read only configuration options for an AsyncMongoClient/MongoClient. |
| 199 | |
| 200 | Should not be instantiated directly by application developers. Access |
| 201 | a client's options via :attr:`pymongo.mongo_client.AsyncMongoClient.options` or :attr:`pymongo.mongo_client.MongoClient.options` |
| 202 | instead. |
| 203 | """ |
| 204 | |
| 205 | def __init__( |
| 206 | self, |
| 207 | username: str, |
| 208 | password: str, |
| 209 | database: Optional[str], |
| 210 | options: Mapping[str, Any], |
| 211 | is_sync: bool = True, |
| 212 | ): |
| 213 | self.__options = options |
| 214 | self.__codec_options = _parse_codec_options(options) |
| 215 | self.__direct_connection = options.get("directconnection") |
| 216 | self.__local_threshold_ms = options.get("localthresholdms", common.LOCAL_THRESHOLD_MS) |
| 217 | # self.__server_selection_timeout is in seconds. Must use full name for |
| 218 | # common.SERVER_SELECTION_TIMEOUT because it is set directly by tests. |
| 219 | self.__server_selection_timeout = options.get( |
| 220 | "serverselectiontimeoutms", common.SERVER_SELECTION_TIMEOUT |
| 221 | ) |
| 222 | self.__pool_options = _parse_pool_options(username, password, database, options, is_sync) |
| 223 | self.__read_preference = _parse_read_preference(options) |
| 224 | self.__replica_set_name = options.get("replicaset") |
| 225 | self.__write_concern = _parse_write_concern(options) |
| 226 | self.__read_concern = _parse_read_concern(options) |
| 227 | self.__connect = options.get("connect") |
| 228 | self.__heartbeat_frequency = options.get("heartbeatfrequencyms", common.HEARTBEAT_FREQUENCY) |
| 229 | self.__retry_writes = options.get("retrywrites", common.RETRY_WRITES) |
| 230 | self.__retry_reads = options.get("retryreads", common.RETRY_READS) |
| 231 | self.__server_selector = options.get("server_selector", any_server_selector) |
| 232 | self.__auto_encryption_opts = options.get("auto_encryption_opts") |
| 233 | self.__load_balanced = options.get("loadbalanced") |
| 234 | self.__timeout = options.get("timeoutms") |
| 235 | self.__server_monitoring_mode = options.get( |
| 236 | "servermonitoringmode", common.SERVER_MONITORING_MODE |
| 237 | ) |
| 238 | self.__max_adaptive_retries = ( |
| 239 | options.get("max_adaptive_retries", common.MAX_ADAPTIVE_RETRIES) |
| 240 | if "max_adaptive_retries" in options |
| 241 | else options.get("maxadaptiveretries", common.MAX_ADAPTIVE_RETRIES) |
| 242 | ) |
| 243 | self.__enable_overload_retargeting = ( |
| 244 | options.get("enable_overload_retargeting", common.ENABLE_OVERLOAD_RETARGETING) |
| 245 | if "enable_overload_retargeting" in options |
| 246 | else options.get("enableoverloadretargeting", common.ENABLE_OVERLOAD_RETARGETING) |
| 247 | ) |
| 248 | |
| 249 | @property |
| 250 | def _options(self) -> Mapping[str, Any]: |
| 251 | """The original options used to create this ClientOptions.""" |
| 252 | return self.__options |
| 253 | |
| 254 | @property |
no outgoing calls
no test coverage detected