From ac34a26b023649b5844dcad448977314aa8bf2fd Mon Sep 17 00:00:00 2001 From: Yoshihiro OKUMURA Date: Wed, 4 Oct 2023 12:49:13 +0900 Subject: [PATCH] follow-up recent specification changes about foldeer access level. --- mdrsclient/models/folder.py | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/mdrsclient/models/folder.py b/mdrsclient/models/folder.py index 4d59c94..8fa5d88 100644 --- a/mdrsclient/models/folder.py +++ b/mdrsclient/models/folder.py @@ -8,28 +8,37 @@ from mdrsclient.models.utils import iso8601_to_user_friendly class FolderAccessLevelItem(NamedTuple): - id: int + mask: int key: str label: str class FolderAccessLevel: + # Bit Mask + # - bit 0: Storage or Repository + # - bit 1: Is Public + # - bit 2: With Password + # - bit 3-7: (Reserved) + # - bit 8-15: Restricted Open ACCESS_LEVELS: Final[list[FolderAccessLevelItem]] = [ - FolderAccessLevelItem(-1, "storage", "Storage"), - FolderAccessLevelItem(0, "private", "Private"), - FolderAccessLevelItem(1, "cbs_open", "CBS Open"), - FolderAccessLevelItem(2, "pw_open", "PW Open"), - FolderAccessLevelItem(3, "public", "Public"), + FolderAccessLevelItem(0x0204, "5kikan_or_pw_open", "5Kikan or PW Open"), + FolderAccessLevelItem(0x0104, "cbs_or_pw_open", "CBS or PW Open"), + FolderAccessLevelItem(0x0200, "5kikan_open", "5Kikan Open"), + FolderAccessLevelItem(0x0100, "cbs_open", "CBS Open"), + FolderAccessLevelItem(0x0004, "pw_open", "PW Open"), + FolderAccessLevelItem(0x0002, "public", "Public"), + FolderAccessLevelItem(0x0001, "private", "Private"), + FolderAccessLevelItem(0x0000, "storage", "Storage"), ] @staticmethod def key2id(key: str) -> int | None: acl = next((x for x in FolderAccessLevel.ACCESS_LEVELS if x.key == key), None) - return acl.id if acl is not None else None + return acl.mask if acl is not None else None @staticmethod def id2label(id: int) -> str | None: - acl = next((x for x in FolderAccessLevel.ACCESS_LEVELS if x.id == id), None) + acl = next((x for x in FolderAccessLevel.ACCESS_LEVELS if (x.mask & id) == x.mask), None) return acl.label if acl is not None else None