pyceo/ceo_common/interfaces/IGroup.py

38 lines
1007 B
Python

from typing import Dict, List
from zope.interface import Interface, Attribute
class IGroup(Interface):
"""Represents a Unix group."""
cn = Attribute('common name')
gid_number = Attribute('gid number')
members = Attribute('usernames of group members')
dn = Attribute('distinguished name')
def add_to_ldap():
"""Add a new record to LDAP for this group."""
def add_member(username: str):
"""Add the member to this group in LDAP."""
def remove_member(username: str):
"""Remove the member from this group in LDAP."""
def serialize_for_ldap() -> Dict[str, List[bytes]]:
"""
Serialize this group into a dict to be passed to
ldap.modlist.addModlist().
"""
# static method
def deserialize_from_ldap(data: Dict[str, List[bytes]]):
"""Deserialize this group from a dict returned by ldap.search_s().
:returns: IGroup
"""
def to_dict():
"""Serialize this group as JSON."""