Encrypt a MongoDB command. :param database: The database for this command. :param cmd: A command document. :param codec_options: The CodecOptions to use while encoding `cmd`. :return: The encrypted command to execute.
(
self, database: str, cmd: Mapping[str, Any], codec_options: CodecOptions[_DocumentTypeArg]
)
| 459 | self._closed = False |
| 460 | |
| 461 | async def encrypt( |
| 462 | self, database: str, cmd: Mapping[str, Any], codec_options: CodecOptions[_DocumentTypeArg] |
| 463 | ) -> dict[str, Any]: |
| 464 | """Encrypt a MongoDB command. |
| 465 | |
| 466 | :param database: The database for this command. |
| 467 | :param cmd: A command document. |
| 468 | :param codec_options: The CodecOptions to use while encoding `cmd`. |
| 469 | |
| 470 | :return: The encrypted command to execute. |
| 471 | """ |
| 472 | self._check_closed() |
| 473 | encoded_cmd = _dict_to_bson(cmd, False, codec_options) |
| 474 | with _wrap_encryption_errors(): |
| 475 | encrypted_cmd = await self._auto_encrypter.encrypt(database, encoded_cmd) |
| 476 | # TODO: PYTHON-1922 avoid decoding the encrypted_cmd. |
| 477 | return _inflate_bson(encrypted_cmd, DEFAULT_RAW_BSON_OPTIONS) |
| 478 | |
| 479 | async def decrypt(self, response: bytes | memoryview) -> Optional[bytes]: |
| 480 | """Decrypt a MongoDB command response. |
no test coverage detected