MCPcopy Index your code
hub / github.com/mongodb/mongo-python-driver / mark_command

Method mark_command

pymongo/asynchronous/encryption.py:280–305  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 3

spawnMethod · 0.95
_inflate_bsonFunction · 0.90
commandMethod · 0.45

Tested by

no test coverage detected