Skip to content

PYTHON-4698 Rename the async ClientEncryption to AsyncClientEncryption #1816

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions pymongo/asynchronous/encryption.py
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ async def close(self) -> None:


class RewrapManyDataKeyResult:
"""Result object returned by a :meth:`~ClientEncryption.rewrap_many_data_key` operation.
"""Result object returned by a :meth:`~AsyncClientEncryption.rewrap_many_data_key` operation.

.. versionadded:: 4.2
"""
Expand All @@ -316,7 +316,7 @@ def __init__(self, bulk_write_result: Optional[BulkWriteResult] = None) -> None:
def bulk_write_result(self) -> Optional[BulkWriteResult]:
"""The result of the bulk write operation used to update the key vault
collection with one or more rewrapped data keys. If
:meth:`~ClientEncryption.rewrap_many_data_key` does not find any matching keys to rewrap,
:meth:`~AsyncClientEncryption.rewrap_many_data_key` does not find any matching keys to rewrap,
no bulk write operation will be executed and this field will be
``None``.
"""
Expand Down Expand Up @@ -506,7 +506,7 @@ def _create_mongocrypt_options(**kwargs: Any) -> MongoCryptOptions:
return opts


class ClientEncryption(Generic[_DocumentType]):
class AsyncClientEncryption(Generic[_DocumentType]):
"""Explicit client-side field level encryption."""

def __init__(
Expand All @@ -519,7 +519,7 @@ def __init__(
) -> None:
"""Explicit client-side field level encryption.

The ClientEncryption class encapsulates explicit operations on a key
The AsyncClientEncryption class encapsulates explicit operations on a key
vault collection that cannot be done directly on an AsyncMongoClient. Similar
to configuring auto encryption on an AsyncMongoClient, it is constructed with
an AsyncMongoClient (to a MongoDB cluster containing the key vault
Expand Down Expand Up @@ -1126,23 +1126,23 @@ async def rewrap_many_data_key(
result = await self._key_vault_coll.bulk_write(replacements)
return RewrapManyDataKeyResult(result)

async def __aenter__(self) -> ClientEncryption[_DocumentType]:
async def __aenter__(self) -> AsyncClientEncryption[_DocumentType]:
return self

async def __aexit__(self, exc_type: Any, exc_val: Any, exc_tb: Any) -> None:
await self.close()

def _check_closed(self) -> None:
if self._encryption is None:
raise InvalidOperation("Cannot use closed ClientEncryption")
raise InvalidOperation("Cannot use closed AsyncClientEncryption")

async def close(self) -> None:
"""Release resources.

Note that using this class in a with-statement will automatically call
:meth:`close`::

with ClientEncryption(...) as client_encryption:
with AsyncClientEncryption(...) as client_encryption:
encrypted = client_encryption.encrypt(value, ...)
decrypted = client_encryption.decrypt(encrypted)

Expand Down
2 changes: 1 addition & 1 deletion pymongo/encryption_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def __init__(
users. To configure automatic *decryption* without automatic
*encryption* set ``bypass_auto_encryption=True``. Explicit
encryption and explicit decryption is also supported for all users
with the :class:`~pymongo.encryption.ClientEncryption` class.
with the :class:`~pymongo.asynchronous.encryption.AsyncClientEncryption` and :class:`~pymongo.encryption.ClientEncryption` classes.

See :ref:`automatic-client-side-encryption` for an example.

Expand Down
1 change: 1 addition & 0 deletions tools/synchro.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
"_AsyncGridOutChunkIterator": "GridOutChunkIterator",
"_a_grid_in_property": "_grid_in_property",
"_a_grid_out_property": "_grid_out_property",
"AsyncClientEncryption": "ClientEncryption",
"AsyncMongoCryptCallback": "MongoCryptCallback",
"AsyncExplicitEncrypter": "ExplicitEncrypter",
"AsyncAutoEncrypter": "AutoEncrypter",
Expand Down
Loading