mbutrovich commented on code in PR #3968: URL: https://github.com/apache/iceberg-python/pull/3968#discussion_r4085154970
########## pyiceberg/encryption/kms.py: ########## @@ -0,0 +1,114 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +"""Key management client interface for table encryption, and an in-memory implementation.""" + +from __future__ import annotations + +from abc import ABC, abstractmethod +from dataclasses import dataclass, field + +from pyiceberg.encryption.ciphers import AesGcmCipher, AesKeySize, SecureKey + + +@dataclass(frozen=True) +class GeneratedKey: + """A newly generated key, both in the clear and wrapped by the key management service.""" + + key: bytes = field(repr=False) + wrapped_key: bytes + + +class KeyManagementClient(ABC): + """A base class for key management service implementations. + + Wraps and unwraps table encryption keys using master keys that the service holds. + """ Review Comment: Thanks, `__init__(self, properties: Properties = EMPTY_DICT)` on the base class settles it. The docstring now says implementations "are loaded by name from the catalog properties", but nothing in PyIceberg loads them yet, so a reader will go looking for a loader that doesn't exist. Could it state the requirement instead? Something like "Subclasses must accept `properties` as their only required constructor argument, so that they can be loaded by name like `FileIO`." Could you also add a test that pins the contract, so a later change to either class can't drop it without a failure? For example, in `tests/encryption/test_kms.py`: ```python def test_client_keeps_its_properties() -> None: assert MemoryKeyManagementClient().properties == {} assert MemoryKeyManagementClient({"kms.key": "value"}).properties == {"kms.key": "value"} ``` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
