]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
mgr/smb: add enums for managing share login access control
authorJohn Mulligan <jmulligan@redhat.com>
Mon, 6 May 2024 20:35:06 +0000 (16:35 -0400)
committerJohn Mulligan <jmulligan@redhat.com>
Wed, 19 Jun 2024 13:29:42 +0000 (09:29 -0400)
Add enums that will be used to create a share login control attribute.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
src/pybind/mgr/smb/enums.py

index 92b8705ebbab7f1b26deb2aa7f572a6d41f5f7ee..175af98d49938202477703191e27f694c61d53ba 100644 (file)
@@ -54,3 +54,26 @@ class ConfigNS(_StrEnum):
     SHARES = 'shares'
     USERS_AND_GROUPS = 'users_and_groups'
     JOIN_AUTHS = 'join_auths'
+
+
+class LoginCategory(_StrEnum):
+    USER = 'user'
+    GROUP = 'group'
+
+
+class LoginAccess(_StrEnum):
+    ADMIN = 'admin'
+    NONE = 'none'
+    READ_ONLY = 'read'
+    READ_ONLY_SHORT = 'r'
+    READ_WRITE = 'read-write'
+    READ_WRITE_SHORT = 'rw'
+
+    def expand(self) -> 'LoginAccess':
+        """Exapend abbreviated enum values into their full forms."""
+        # the extra LoginAccess(...) calls are to appease mypy
+        if self == self.READ_ONLY_SHORT:
+            return LoginAccess(self.READ_ONLY)
+        if self == self.READ_WRITE_SHORT:
+            return LoginAccess(self.READ_WRITE)
+        return self