]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
mgr/smb: add a RawConfigEntry protocol type
authorJohn Mulligan <jmulligan@redhat.com>
Tue, 1 Jul 2025 21:15:10 +0000 (17:15 -0400)
committerJohn Mulligan <jmulligan@redhat.com>
Tue, 12 Aug 2025 14:48:03 +0000 (10:48 -0400)
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 <jmulligan@redhat.com>
src/pybind/mgr/smb/proto.py

index b04c3e90e0e4abcdf3c8d9b869f19c5d3d3c3786..3cb5a201485bf2ed951060becbd99660bc12e2e5 100644 (file)
@@ -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