Mark a command for encryption. :param database: The database on which to run this command. :param cmd: The BSON command to run. :return: The marked command response from mongocryptd.
(self, database: str, cmd: bytes)
| 275 | _spawn_daemon(args) |
| 276 | |
| 277 | def mark_command(self, database: str, cmd: bytes) -> bytes | memoryview: |
| 278 | """Mark a command for encryption. |
| 279 | |
| 280 | :param database: The database on which to run this command. |
| 281 | :param cmd: The BSON command to run. |
| 282 | |
| 283 | :return: The marked command response from mongocryptd. |
| 284 | """ |
| 285 | if not self._spawned and not self.opts._mongocryptd_bypass_spawn: |
| 286 | self.spawn() |
| 287 | # Database.command only supports mutable mappings so we need to decode |
| 288 | # the raw BSON command first. |
| 289 | inflated_cmd = _inflate_bson(cmd, DEFAULT_RAW_BSON_OPTIONS) |
| 290 | assert self.mongocryptd_client is not None |
| 291 | try: |
| 292 | res = self.mongocryptd_client[database].command( |
| 293 | inflated_cmd, codec_options=DEFAULT_RAW_BSON_OPTIONS |
| 294 | ) |
| 295 | except ServerSelectionTimeoutError: |
| 296 | if self.opts._mongocryptd_bypass_spawn: |
| 297 | raise |
| 298 | self.spawn() |
| 299 | res = self.mongocryptd_client[database].command( |
| 300 | inflated_cmd, codec_options=DEFAULT_RAW_BSON_OPTIONS |
| 301 | ) |
| 302 | return res.raw |
| 303 | |
| 304 | def fetch_keys(self, filter: bytes) -> Generator[bytes | memoryview, None]: |
| 305 | """Yields one or more keys from the key vault. |
nothing calls this directly
no test coverage detected