pyceo/ceo_common/interfaces/IUser.py

78 lines
2.4 KiB
Python

from typing import List, Dict
from zope.interface import Interface, Attribute
class IUser(Interface):
"""Represents a Unix user."""
# LDAP attributes
uid = Attribute('user identifier')
cn = Attribute('common name')
login_shell = Attribute('login shell')
uid_number = Attribute('uid number')
gid_number = Attribute('gid number')
home_directory = Attribute('home directory')
program = Attribute('academic program')
position = Attribute('executive position')
terms = Attribute('list of terms for which this person was a member')
non_member_terms = Attribute('list of terms for which this person was '
'a club rep')
mail_local_addresses = Attribute('email aliases')
dn = Attribute('distinguished name')
# Non-LDAP attributes
forwarding_addresses = Attribute('list of email forwarding addresses')
def get_forwarding_addresses(self) -> List[str]:
"""Get the forwarding addresses for this user."""
def set_forwarding_addresses(self, addresses: List[str]):
"""Set the forwarding addresses for this user."""
def is_club() -> bool:
"""
Returns True if this is the Unix user for a club.
Returns False if this is the Unix user for a member.
"""
def add_to_ldap():
"""
Add a new record to LDAP for this user.
A new UID number and GID number will be created.
"""
def add_to_kerberos(password: str):
"""Add a new Kerberos principal for this user."""
def add_terms(terms: List[str]):
"""Add member terms for this user."""
def add_non_member_terms(terms: List[str]):
"""Add non-member terms for this user."""
def add_position(position: str):
"""Add a position to this user."""
def remove_position(position: str):
"""Remove a position from this user."""
def change_password(password: str):
"""Replace the user's password."""
def create_home_dir():
"""Create a new home directory for this user."""
def serialize_for_modlist() -> Dict[str, List[bytes]]:
"""
Serialize this user into a dict to be passed to
ldap.modlist.addModlist().
"""
# static method
def deserialize_from_dict(data: Dict[str, List[bytes]]):
"""Deserialize this user from a dict returned by ldap.search_s().
:returns: IUser
"""