Skip to content

Commit 6d916d6

Browse files
authored
PYTHON-3315 Remove index_key_id option from ClientEncryption encrypt method (#989)
1 parent b37b146 commit 6d916d6

File tree

2 files changed

+3
-17
lines changed

2 files changed

+3
-17
lines changed

pymongo/encryption.py

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -636,7 +636,6 @@ def encrypt(
636636
algorithm: str,
637637
key_id: Optional[Binary] = None,
638638
key_alt_name: Optional[str] = None,
639-
index_key_id: Optional[Binary] = None,
640639
query_type: Optional[str] = None,
641640
contention_factor: Optional[int] = None,
642641
) -> Binary:
@@ -653,34 +652,29 @@ def encrypt(
653652
:class:`~bson.binary.Binary` with subtype 4 (
654653
:attr:`~bson.binary.UUID_SUBTYPE`).
655654
- `key_alt_name`: Identifies a key vault document by 'keyAltName'.
656-
- `index_key_id`: **(BETA)** The index key id to use for Queryable Encryption. Must be
657-
a :class:`~bson.binary.Binary` with subtype 4 (:attr:`~bson.binary.UUID_SUBTYPE`).
658655
- `query_type` (str): **(BETA)** The query type to execute. See
659656
:class:`QueryType` for valid options.
660657
- `contention_factor` (int): **(BETA)** The contention factor to use
661658
when the algorithm is :attr:`Algorithm.INDEXED`. An integer value
662659
*must* be given when the :attr:`Algorithm.INDEXED` algorithm is
663660
used.
664661
665-
.. note:: `index_key_id`, `query_type`, and `contention_factor` are part of the
662+
.. note:: `query_type` and `contention_factor` are part of the
666663
Queryable Encryption beta. Backwards-breaking changes may be made before the
667664
final release.
668665
669666
:Returns:
670667
The encrypted value, a :class:`~bson.binary.Binary` with subtype 6.
671668
672669
.. versionchanged:: 4.2
673-
Added the `index_key_id`, `query_type`, and `contention_factor` parameters.
670+
Added the `query_type` and `contention_factor` parameters.
671+
674672
"""
675673
self._check_closed()
676674
if key_id is not None and not (
677675
isinstance(key_id, Binary) and key_id.subtype == UUID_SUBTYPE
678676
):
679677
raise TypeError("key_id must be a bson.binary.Binary with subtype 4")
680-
if index_key_id is not None and not (
681-
isinstance(index_key_id, Binary) and index_key_id.subtype == UUID_SUBTYPE
682-
):
683-
raise TypeError("index_key_id must be a bson.binary.Binary with subtype 4")
684678

685679
doc = encode({"v": value}, codec_options=self._codec_options)
686680
with _wrap_encryption_errors():
@@ -689,7 +683,6 @@ def encrypt(
689683
algorithm,
690684
key_id=key_id,
691685
key_alt_name=key_alt_name,
692-
index_key_id=index_key_id,
693686
query_type=query_type,
694687
contention_factor=contention_factor,
695688
)

test/test_encryption.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -462,13 +462,6 @@ def test_validation(self):
462462
with self.assertRaisesRegex(TypeError, msg):
463463
client_encryption.encrypt("str", algo, key_id=Binary(b"123"))
464464

465-
msg = "index_key_id must be a bson.binary.Binary with subtype 4"
466-
algo = Algorithm.INDEXED
467-
with self.assertRaisesRegex(TypeError, msg):
468-
client_encryption.encrypt("str", algo, index_key_id=uid) # type: ignore[arg-type]
469-
with self.assertRaisesRegex(TypeError, msg):
470-
client_encryption.encrypt("str", algo, index_key_id=Binary(b"123"))
471-
472465
def test_bson_errors(self):
473466
client_encryption = ClientEncryption(
474467
KMS_PROVIDERS, "keyvault.datakeys", client_context.client, OPTS

0 commit comments

Comments
 (0)