2024-10-26 18:22:31 +00:00
|
|
|
from abc import ABC, abstractmethod
|
|
|
|
from typing import Optional
|
|
|
|
|
2024-11-02 23:15:51 +00:00
|
|
|
from selfprivacy_api.models.user import UserDataUser
|
2024-10-26 18:22:31 +00:00
|
|
|
|
|
|
|
|
|
|
|
class AbstractUserRepository(ABC):
|
2024-11-02 23:15:51 +00:00
|
|
|
@staticmethod
|
2024-10-26 18:22:31 +00:00
|
|
|
@abstractmethod
|
|
|
|
def get_users(
|
|
|
|
exclude_primary: bool = False,
|
|
|
|
exclude_root: bool = False,
|
|
|
|
) -> list[UserDataUser]:
|
|
|
|
"""Retrieves a list of users with options to exclude specific user groups"""
|
|
|
|
|
2024-11-02 23:15:51 +00:00
|
|
|
@staticmethod
|
2024-10-26 18:22:31 +00:00
|
|
|
@abstractmethod
|
2024-11-15 14:30:51 +00:00
|
|
|
def create_user(username: str, password: str) -> None:
|
2024-10-26 18:22:31 +00:00
|
|
|
"""Creates a new user"""
|
|
|
|
|
2024-11-02 23:15:51 +00:00
|
|
|
@staticmethod
|
2024-10-26 18:22:31 +00:00
|
|
|
@abstractmethod
|
|
|
|
def delete_user(username: str) -> None:
|
|
|
|
"""Deletes an existing user"""
|
|
|
|
|
2024-11-02 23:15:51 +00:00
|
|
|
@staticmethod
|
2024-10-26 18:22:31 +00:00
|
|
|
@abstractmethod
|
2024-11-15 14:30:51 +00:00
|
|
|
def update_user(username: str, password: str) -> None:
|
2024-10-26 18:22:31 +00:00
|
|
|
"""Updates the password of an existing user"""
|
|
|
|
|
2024-11-02 23:15:51 +00:00
|
|
|
@staticmethod
|
2024-10-26 18:22:31 +00:00
|
|
|
@abstractmethod
|
|
|
|
def get_user_by_username(username: str) -> Optional[UserDataUser]:
|
|
|
|
"""Retrieves user data (UserDataUser) by username"""
|