From fb627721680b18efd2c06aede0600b2957f2ff16 Mon Sep 17 00:00:00 2001 From: John Mulligan Date: Tue, 1 Jul 2025 17:15:10 -0400 Subject: [PATCH] mgr/smb: add a RawConfigEntry protocol type Previously, the ConfigEntry type was created to be general interface for serializing structures to JSON and persist them in a store. However, there are times we want to retain data in a store that is not serialized JSON - but just raw data. Create a new protocol for that purpose. Signed-off-by: John Mulligan (cherry picked from commit 6d9e126eb25625dec5a2de61955ad625a6303d1a) --- src/pybind/mgr/smb/proto.py | 34 +++++++++++++++++++++++++--------- 1 file changed, 25 insertions(+), 9 deletions(-) diff --git a/src/pybind/mgr/smb/proto.py b/src/pybind/mgr/smb/proto.py index b04c3e90e0e4a..3cb5a201485bf 100644 --- a/src/pybind/mgr/smb/proto.py +++ b/src/pybind/mgr/smb/proto.py @@ -62,7 +62,27 @@ class ResourceKey(Protocol): ... # pragma: no cover -class ConfigEntry(Protocol): +class BaseEntry(Protocol): + """Base protocol class for Entry objects. Entry objects are stored + peristently and can by identified by an internal key or URI. + """ + + def remove(self) -> bool: + ... # pragma: no cover + + def exists(self) -> bool: + ... # pragma: no cover + + @property + def uri(self) -> str: + ... # pragma: no cover + + @property + def full_key(self) -> EntryKey: + ... # pragma: no cover + + +class ConfigEntry(BaseEntry, Protocol): """A protocol for describing a configuration object that can be kept within a configuration store. Has the ability to identify itself either by a relative key or by a global URI value. @@ -74,18 +94,14 @@ class ConfigEntry(Protocol): def set(self, obj: Simplified) -> None: ... # pragma: no cover - def remove(self) -> bool: - ... # pragma: no cover - def exists(self) -> bool: - ... # pragma: no cover +class RawConfigEntry(BaseEntry, Protocol): + """Like a ConfigEntry but for opaque data blobs.""" - @property - def uri(self) -> str: + def get_data(self) -> str: ... # pragma: no cover - @property - def full_key(self) -> EntryKey: + def set_data(self, obj: Simplified) -> None: ... # pragma: no cover -- 2.39.5