add apikey

This commit is contained in:
2025-03-27 01:14:18 -03:00
parent 7021833476
commit 8118dfd403
14 changed files with 114 additions and 69 deletions

View File

@@ -572,30 +572,30 @@ class DynamoDBCollection:
def __init__(
self,
persistence_layer: DynamoDBPersistenceLayer,
exception_cls: Type[ValueError] = MissingError,
exc_cls: Type[ValueError] = MissingError,
tz: str = TZ,
) -> None:
if not issubclass(exception_cls, ValueError):
if not issubclass(exc_cls, ValueError):
raise TypeError(
f'exception_cls must be a subclass of ValueError, got {exception_cls}'
f'exception_cls must be a subclass of ValueError, got {exc_cls}'
)
self.persistence_layer = persistence_layer
self.exception_cls = exception_cls
self.exc_cls = exc_cls
self.tz = tz
def get_item(
self,
key: KeyPair,
path_spec: str | None = None,
raise_if_missing: bool = True,
raise_on_error: bool = True,
default: Any = None,
delimiter: str = '#',
) -> Any:
exc_cls = self.exception_cls
exc_cls = self.exc_cls
data = self.persistence_layer.get_item(key)
if raise_if_missing and not data:
if raise_on_error and not data:
raise exc_cls(f'Item with {key} not found.')
if path_spec and data: