Skip to content

Commit

Permalink
Add GroupAccess enum
Browse files Browse the repository at this point in the history
  • Loading branch information
yannickhilber committed Mar 16, 2023
1 parent 0af7cc3 commit 0a98f16
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions bitwarden_access_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,9 @@ class MemberType(Enum):
MANAGER = 3
CUSTOM = 4

class GroupAccess(Enum):
READONLY = 0
WRITE = 1

class Member(NamedTuple):
id: str
Expand Down Expand Up @@ -188,17 +191,17 @@ def format_toml(self) -> str:

class GroupCollectionAccess(NamedTuple):
name: str
access: str
access: GroupAccess

@staticmethod
def from_toml_dict(data: Dict[str, Any]) -> GroupCollectionAccess:
return GroupCollectionAccess(
name=data["group_name"],
access=data["access"],
access=GroupAccess[data["access"].upper()],
)

def format_toml(self) -> str:
return "{ group_name = " + self.name + '", access = "' + self.access + '" }'
return "{ group_name = " + self.name + '", access = "' + str(self.access).lower() + '" }'


class Collection(NamedTuple):
Expand Down Expand Up @@ -332,9 +335,9 @@ def get_collection_members(
def get_collection_groups(self, groups: Any) -> Iterable[GroupCollectionAccess]:
for group in groups:
if group["readOnly"] == True:
access = "readonly"
access = GroupAccess["READONLY"]
else:
access = "write"
access = GroupAccess["WRITE"]

group_id = group["id"]
yield GroupCollectionAccess(
Expand Down

0 comments on commit 0a98f16

Please sign in to comment.