2021-08-22 17:57:36 -04:00
|
|
|
from typing import List
|
|
|
|
|
2021-07-19 01:47:39 -04:00
|
|
|
from zope.interface import Interface, Attribute
|
|
|
|
|
|
|
|
|
|
|
|
class IGroup(Interface):
|
|
|
|
"""Represents a Unix group."""
|
|
|
|
|
|
|
|
cn = Attribute('common name')
|
|
|
|
gid_number = Attribute('gid number')
|
2021-08-18 19:48:17 -04:00
|
|
|
description = Attribute('optional description')
|
2021-08-04 02:33:50 -04:00
|
|
|
members = Attribute('usernames of group members')
|
2021-08-15 01:04:49 -04:00
|
|
|
|
|
|
|
ldap3_entry = Attribute('cached ldap3.Entry instance for this group')
|
2021-08-18 19:48:17 -04:00
|
|
|
user_cn = Attribute('cached CN of the user associated with this group')
|
2021-07-19 01:47:39 -04:00
|
|
|
|
|
|
|
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."""
|
|
|
|
|
2021-08-22 17:57:36 -04:00
|
|
|
def set_members(usernames: List[str]):
|
|
|
|
"""Set all of the members of this group in LDAP."""
|
|
|
|
|
2021-08-04 02:33:50 -04:00
|
|
|
def to_dict():
|
|
|
|
"""Serialize this group as JSON."""
|