PYTHON-3818 Create unique key vault index in auto QE example (#1300)

This commit is contained in:
Shane Harvey 2023-07-10 15:10:35 -04:00 committed by GitHub
parent 2d2126bd7d
commit fd760c2b66
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -659,6 +659,12 @@ as demonstrated by the following example:
)
key_vault = key_vault_client["keyvault"]["datakeys"]
key_vault.drop()
# Ensure that two data keys cannot share the same keyAltName.
key_vault.create_index(
"keyAltNames",
unique=True,
partialFilterExpression={"keyAltNames": {"$exists": True}},
)
key1_id = client_encryption.create_data_key("local", key_alt_names=["firstName"])
key2_id = client_encryption.create_data_key("local", key_alt_names=["lastName"])