Skip to content

Commit 0c6d2b6

Browse files
ShaneHarveyjuliusgeo
authored andcommitted
PYTHON-3293 Document Queryable Encryption API is in beta (mongodb#965)
1 parent 95153a8 commit 0c6d2b6

File tree

5 files changed

+51
-16
lines changed

5 files changed

+51
-16
lines changed

doc/changelog.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,10 @@ Changes in Version 4.2
99
PyMongo 4.2 brings a number of improvements including:
1010

1111
- Support for MongoDB 6.0.
12+
- Support for the Queryable Encryption beta with MongoDB 6.0. Note that backwards-breaking
13+
changes may be made before the final release.
1214
- Provisional (beta) support for :func:`pymongo.timeout` to apply a single timeout
1315
to an entire block of pymongo operations.
14-
- Beta support for Queryable Encryption with MongoDB 6.0.
1516

1617
Bug fixes
1718
.........

pymongo/collection.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,9 +159,14 @@ def __init__(
159159
- `session` (optional): a
160160
:class:`~pymongo.client_session.ClientSession` that is used with
161161
the create collection command
162+
- `encrypted_fields`: **(BETA)** Document that describes the encrypted fields for
163+
Queryable Encryption. If provided it will be passed to the create collection command.
162164
- `**kwargs` (optional): additional keyword arguments will
163165
be passed as options for the create collection command
164166
167+
.. versionchanged:: 4.2
168+
Added ``encrypted_fields`` parameter.
169+
165170
.. versionchanged:: 4.0
166171
Removed the reindex, map_reduce, inline_map_reduce,
167172
parallel_scan, initialize_unordered_bulk_op,
@@ -1156,6 +1161,7 @@ def drop(
11561161
self,
11571162
session: Optional["ClientSession"] = None,
11581163
comment: Optional[Any] = None,
1164+
encrypted_fields: Optional[Mapping[str, Any]] = None,
11591165
) -> None:
11601166
"""Alias for :meth:`~pymongo.database.Database.drop_collection`.
11611167
@@ -1164,12 +1170,17 @@ def drop(
11641170
:class:`~pymongo.client_session.ClientSession`.
11651171
- `comment` (optional): A user-provided comment to attach to this
11661172
command.
1173+
- `encrypted_fields`: **(BETA)** Document that describes the encrypted fields for
1174+
Queryable Encryption.
11671175
11681176
The following two calls are equivalent:
11691177
11701178
>>> db.foo.drop()
11711179
>>> db.drop_collection("foo")
11721180
1181+
.. versionchanged:: 4.2
1182+
Added ``encrypted_fields`` parameter.
1183+
11731184
.. versionchanged:: 4.1
11741185
Added ``comment`` parameter.
11751186
@@ -1186,7 +1197,9 @@ def drop(
11861197
self.write_concern,
11871198
self.read_concern,
11881199
)
1189-
dbo.drop_collection(self.__name, session=session, comment=comment)
1200+
dbo.drop_collection(
1201+
self.__name, session=session, comment=comment, encrypted_fields=encrypted_fields
1202+
)
11901203

11911204
def _delete(
11921205
self,

pymongo/database.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -336,9 +336,8 @@ def create_collection(
336336
:class:`~pymongo.collation.Collation`.
337337
- `session` (optional): a
338338
:class:`~pymongo.client_session.ClientSession`.
339-
- `encrypted_fields`: Document that describes the encrypted fields for Queryable
340-
Encryption.
341-
For example::
339+
- `encrypted_fields`: **(BETA)** Document that describes the encrypted fields for
340+
Queryable Encryption. For example::
342341
343342
{
344343
"escCollection": "enxcol_.encryptedCollection.esc",
@@ -391,6 +390,9 @@ def create_collection(
391390
- ``comment`` (str): a user-provided comment to attach to this command.
392391
This option is only supported on MongoDB >= 4.4.
393392
393+
.. versionchanged:: 4.2
394+
Added ``encrypted_fields`` parameter.
395+
394396
.. versionchanged:: 3.11
395397
This method is now supported inside multi-document transactions
396398
with MongoDB 4.4+.
@@ -955,9 +957,8 @@ def drop_collection(
955957
:class:`~pymongo.client_session.ClientSession`.
956958
- `comment` (optional): A user-provided comment to attach to this
957959
command.
958-
- `encrypted_fields`: Document that describes the encrypted fields for Queryable
959-
Encryption.
960-
For example::
960+
- `encrypted_fields`: **(BETA)** Document that describes the encrypted fields for
961+
Queryable Encryption. For example::
961962
962963
{
963964
"escCollection": "enxcol_.encryptedCollection.esc",
@@ -983,6 +984,9 @@ def drop_collection(
983984
.. note:: The :attr:`~pymongo.database.Database.write_concern` of
984985
this database is automatically applied to this operation.
985986
987+
.. versionchanged:: 4.2
988+
Added ``encrypted_fields`` parameter.
989+
986990
.. versionchanged:: 4.1
987991
Added ``comment`` parameter.
988992

pymongo/encryption.py

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -379,17 +379,26 @@ class Algorithm(str, enum.Enum):
379379
INDEXED = "Indexed"
380380
"""Indexed.
381381
382+
.. note:: Support for Queryable Encryption is in beta.
383+
Backwards-breaking changes may be made before the final release.
384+
382385
.. versionadded:: 4.2
383386
"""
384387
UNINDEXED = "Unindexed"
385388
"""Unindexed.
386389
390+
.. note:: Support for Queryable Encryption is in beta.
391+
Backwards-breaking changes may be made before the final release.
392+
387393
.. versionadded:: 4.2
388394
"""
389395

390396

391397
class QueryType(enum.IntEnum):
392-
"""An enum that defines the supported values for explicit encryption query_type.
398+
"""**(BETA)** An enum that defines the supported values for explicit encryption query_type.
399+
400+
.. note:: Support for Queryable Encryption is in beta.
401+
Backwards-breaking changes may be made before the final release.
393402
394403
.. versionadded:: 4.2
395404
"""
@@ -606,13 +615,17 @@ def encrypt(
606615
:class:`~bson.binary.Binary` with subtype 4 (
607616
:attr:`~bson.binary.UUID_SUBTYPE`).
608617
- `key_alt_name`: Identifies a key vault document by 'keyAltName'.
609-
- `index_key_id`: The index key id to use for Queryable Encryption. Must be
618+
- `index_key_id`: **(BETA)** The index key id to use for Queryable Encryption. Must be
610619
a :class:`~bson.binary.Binary` with subtype 4 (:attr:`~bson.binary.UUID_SUBTYPE`).
611-
- `query_type` (int): The query type to execute. See
620+
- `query_type` (int): **(BETA)** The query type to execute. See
612621
:class:`QueryType` for valid options.
613-
- `contention_factor` (int): The contention factor to use
622+
- `contention_factor` (int): **(BETA)** The contention factor to use
614623
when the algorithm is :attr:`Algorithm.INDEXED`.
615624
625+
.. note:: `index_key_id`, `query_type`, and `contention_factor` are part of the
626+
Queryable Encryption beta. Backwards-breaking changes may be made before the
627+
final release.
628+
616629
:Returns:
617630
The encrypted value, a :class:`~bson.binary.Binary` with subtype 6.
618631

pymongo/encryption_options.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -148,12 +148,12 @@ def __init__(
148148
- `crypt_shared_lib_path` (optional): Override the path to load the crypt_shared library.
149149
- `crypt_shared_lib_required` (optional): If True, raise an error if libmongocrypt is
150150
unable to load the crypt_shared library.
151-
- `bypass_query_analysis` (optional): If ``True``, disable automatic analysis of
152-
outgoing commands. Set `bypass_query_analysis` to use explicit
151+
- `bypass_query_analysis` (optional): **(BETA)** If ``True``, disable automatic analysis
152+
of outgoing commands. Set `bypass_query_analysis` to use explicit
153153
encryption on indexed fields without the MongoDB Enterprise Advanced
154154
licensed crypt_shared library.
155-
- `encrypted_fields_map`: Map of collection namespace ("db.coll") to documents that
156-
described the encrypted fields for Queryable Encryption. For example::
155+
- `encrypted_fields_map`: **(BETA)** Map of collection namespace ("db.coll") to documents
156+
that described the encrypted fields for Queryable Encryption. For example::
157157
158158
{
159159
"db.encryptedCollection": {
@@ -176,6 +176,10 @@ def __init__(
176176
}
177177
}
178178
179+
.. note:: `bypass_query_analysis` and `encrypted_fields_map` are part of the
180+
Queryable Encryption beta. Backwards-breaking changes may be made before the
181+
final release.
182+
179183
.. versionchanged:: 4.2
180184
Added `encrypted_fields_map` `crypt_shared_lib_path`, `crypt_shared_lib_required`,
181185
and `bypass_query_analysis` parameters.

0 commit comments

Comments
 (0)