Skip to content

Entities

The models/entities subpackage contains SQLAlchemy ORM base entity classes that all domain entities in an ArchiPy application should inherit from.

Base Entities

Base SQLAlchemy entity providing common columns (id, created_at, updated_at) and ORM configuration shared by all domain entities.

archipy.models.entities.sqlalchemy.base_entities.PK_COLUMN_NAME module-attribute

PK_COLUMN_NAME = 'pk_uuid'

archipy.models.entities.sqlalchemy.base_entities.BaseEntity

Bases: DeclarativeBase

Base class for all SQLAlchemy models with automatic timestamps.

This class serves as the base for all entities in the application. It provides common functionality such as automatic timestamping for created_at and validation for the primary key column.

Attributes:

Name Type Description
created_at Mapped[datetime]

Timestamp indicating when the entity was created.

Source code in archipy/models/entities/sqlalchemy/base_entities.py
class BaseEntity(DeclarativeBase):
    """Base class for all SQLAlchemy models with automatic timestamps.

    This class serves as the base for all entities in the application. It provides
    common functionality such as automatic timestamping for `created_at` and
    validation for the primary key column.

    Attributes:
        created_at: Timestamp indicating when the entity was created.
    """

    __abstract__ = True
    created_at: Mapped[datetime] = mapped_column(DateTime(), server_default=func.now(), nullable=False)

    @classmethod
    def _is_abstract(cls) -> bool:
        """Check if the class is abstract.

        Returns:
            bool: True if the class is abstract, False otherwise.
        """
        return (not hasattr(cls, "__tablename__")) and cls.__abstract__

    def __init_subclass__(cls, **kw: object) -> None:
        """Validate the subclass during initialization.

        Args:
            **kw: Additional keyword arguments passed to the subclass.

        Raises:
            AttributeError: If the subclass does not have the required primary key column.
        """
        if cls._is_abstract():
            return
        cls._validate_pk_column()
        super().__init_subclass__(**kw)

    @classmethod
    def _validate_pk_column(cls) -> None:
        """Validate that the subclass has the required primary key column.

        Raises:
            AttributeError: If the primary key column is missing or invalid.
        """
        if not hasattr(cls, PK_COLUMN_NAME):
            error_message = f"Child class {cls.__name__} must have {PK_COLUMN_NAME}"
            raise AttributeError(error_message)
        pk_column = getattr(cls, PK_COLUMN_NAME)
        if not isinstance(pk_column, Synonym):
            error_message = f"{PK_COLUMN_NAME} must be a sqlalchemy.orm.Synonym type"
            raise TypeError(error_message)

archipy.models.entities.sqlalchemy.base_entities.BaseEntity.created_at class-attribute instance-attribute

created_at: Mapped[datetime] = mapped_column(
    DateTime(), server_default=now(), nullable=False
)

archipy.models.entities.sqlalchemy.base_entities.EntityAttributeChecker

Utility class for validating model attributes.

This class provides functionality to ensure that at least one of the specified attributes is present in a model.

Attributes:

Name Type Description
required_any list[list[str]]

A list of lists, where each inner list contains attribute names. At least one attribute from each inner list must be present.

Source code in archipy/models/entities/sqlalchemy/base_entities.py
class EntityAttributeChecker:
    """Utility class for validating model attributes.

    This class provides functionality to ensure that at least one of the specified
    attributes is present in a model.

    Attributes:
        required_any: A list of lists, where each inner list contains
            attribute names. At least one attribute from each inner list must be present.
    """

    required_any: ClassVar[list[list[str]]] = []

    @classmethod
    def validate(cls, base_class: type) -> None:
        """Validate that at least one of the required attributes is present.

        Args:
            base_class: The class to validate.

        Raises:
            AttributeError: If none of the required attributes are present.
        """
        for attrs in cls.required_any:
            if not any(hasattr(base_class, attr) for attr in attrs):
                error_message = f"One of {attrs} must be defined in {base_class.__name__}"
                raise AttributeError(error_message)

archipy.models.entities.sqlalchemy.base_entities.EntityAttributeChecker.required_any class-attribute

required_any: list[list[str]] = []

archipy.models.entities.sqlalchemy.base_entities.EntityAttributeChecker.validate classmethod

validate(base_class: type) -> None

Validate that at least one of the required attributes is present.

Parameters:

Name Type Description Default
base_class type

The class to validate.

required

Raises:

Type Description
AttributeError

If none of the required attributes are present.

Source code in archipy/models/entities/sqlalchemy/base_entities.py
@classmethod
def validate(cls, base_class: type) -> None:
    """Validate that at least one of the required attributes is present.

    Args:
        base_class: The class to validate.

    Raises:
        AttributeError: If none of the required attributes are present.
    """
    for attrs in cls.required_any:
        if not any(hasattr(base_class, attr) for attr in attrs):
            error_message = f"One of {attrs} must be defined in {base_class.__name__}"
            raise AttributeError(error_message)

archipy.models.entities.sqlalchemy.base_entities.DeletableMixin

Mixin to add a deletable flag to models.

This mixin adds an is_deleted column to indicate whether the entity has been soft-deleted, allowing for logical deletion without physically removing records.

Attributes:

Name Type Description
is_deleted

Flag indicating if the entity is deleted.

Source code in archipy/models/entities/sqlalchemy/base_entities.py
class DeletableMixin:
    """Mixin to add a deletable flag to models.

    This mixin adds an `is_deleted` column to indicate whether the entity has been
    soft-deleted, allowing for logical deletion without physically removing records.

    Attributes:
        is_deleted: Flag indicating if the entity is deleted.
    """

    __abstract__ = True
    is_deleted = Column(Boolean, default=False, nullable=False)

archipy.models.entities.sqlalchemy.base_entities.DeletableMixin.is_deleted class-attribute instance-attribute

is_deleted = Column(Boolean, default=False, nullable=False)

archipy.models.entities.sqlalchemy.base_entities.UpdatableMixin

Mixin to add updatable timestamp functionality.

This mixin adds an updated_at column to track the last update time of the entity, automatically maintaining a timestamp of the most recent modification.

Attributes:

Name Type Description
updated_at

Timestamp indicating when the entity was last updated.

Source code in archipy/models/entities/sqlalchemy/base_entities.py
class UpdatableMixin:
    """Mixin to add updatable timestamp functionality.

    This mixin adds an `updated_at` column to track the last update time of the entity,
    automatically maintaining a timestamp of the most recent modification.

    Attributes:
        updated_at: Timestamp indicating when the entity was last updated.
    """

    __abstract__ = True

    updated_at = Column(
        DateTime(),
        server_default=func.now(),
        nullable=False,
        onupdate=func.now(),
    )

archipy.models.entities.sqlalchemy.base_entities.UpdatableMixin.updated_at class-attribute instance-attribute

updated_at = Column(
    DateTime(),
    server_default=now(),
    nullable=False,
    onupdate=now(),
)

archipy.models.entities.sqlalchemy.base_entities.ArchivableMixin

Mixin to add Archivable functionality.

This mixin adds an is_archived column to indicate whether the entity has been archived, and an origin_uuid column to reference the original entity.

Attributes:

Name Type Description
is_archived

Flag indicating if the entity is archived.

origin_uuid

Reference to the original entity.

Source code in archipy/models/entities/sqlalchemy/base_entities.py
class ArchivableMixin:
    """Mixin to add Archivable functionality.

    This mixin adds an `is_archived` column to indicate whether the entity has been
    archived, and an `origin_uuid` column to reference the original entity.

    Attributes:
        is_archived: Flag indicating if the entity is archived.
        origin_uuid: Reference to the original entity.
    """

    __abstract__ = True
    is_archived = Column(Boolean, default=False, nullable=False)
    # Using Column without Mapped is acceptable since Column works with BaseEntity.__table__
    origin_uuid = Column(ForeignKey("self.pk_uuid"), nullable=True)

archipy.models.entities.sqlalchemy.base_entities.ArchivableMixin.is_archived class-attribute instance-attribute

is_archived = Column(Boolean, default=False, nullable=False)

archipy.models.entities.sqlalchemy.base_entities.ArchivableMixin.origin_uuid class-attribute instance-attribute

origin_uuid = Column(
    ForeignKey("self.pk_uuid"), nullable=True
)

archipy.models.entities.sqlalchemy.base_entities.AdminMixin

Bases: EntityAttributeChecker

Mixin for models with admin-related attributes.

This mixin ensures that at least one of the admin-related attributes is present, providing tracking of which administrator created the entity.

Attributes:

Name Type Description
required_any list[list[str]]

Specifies the required admin-related attributes.

Source code in archipy/models/entities/sqlalchemy/base_entities.py
class AdminMixin(EntityAttributeChecker):
    """Mixin for models with admin-related attributes.

    This mixin ensures that at least one of the admin-related attributes is present,
    providing tracking of which administrator created the entity.

    Attributes:
        required_any: Specifies the required admin-related attributes.
    """

    __abstract__ = True
    required_any: ClassVar[list[list[str]]] = [["created_by_admin", "created_by_admin_uuid"]]

    def __init_subclass__(cls, **kw: object) -> None:
        """Validate the subclass during initialization.

        Args:
            **kw: Additional keyword arguments passed to the subclass.
        """
        cls.validate(cls)
        super().__init_subclass__(**kw)

archipy.models.entities.sqlalchemy.base_entities.AdminMixin.required_any class-attribute

required_any: list[list[str]] = [
    ["created_by_admin", "created_by_admin_uuid"]
]

archipy.models.entities.sqlalchemy.base_entities.AdminMixin.validate classmethod

validate(base_class: type) -> None

Validate that at least one of the required attributes is present.

Parameters:

Name Type Description Default
base_class type

The class to validate.

required

Raises:

Type Description
AttributeError

If none of the required attributes are present.

Source code in archipy/models/entities/sqlalchemy/base_entities.py
@classmethod
def validate(cls, base_class: type) -> None:
    """Validate that at least one of the required attributes is present.

    Args:
        base_class: The class to validate.

    Raises:
        AttributeError: If none of the required attributes are present.
    """
    for attrs in cls.required_any:
        if not any(hasattr(base_class, attr) for attr in attrs):
            error_message = f"One of {attrs} must be defined in {base_class.__name__}"
            raise AttributeError(error_message)

archipy.models.entities.sqlalchemy.base_entities.ManagerMixin

Bases: EntityAttributeChecker

Mixin for models with manager-related attributes.

This mixin ensures that at least one of the manager-related attributes is present, providing tracking of which manager created the entity.

Attributes:

Name Type Description
required_any list[list[str]]

Specifies the required manager-related attributes.

Source code in archipy/models/entities/sqlalchemy/base_entities.py
class ManagerMixin(EntityAttributeChecker):
    """Mixin for models with manager-related attributes.

    This mixin ensures that at least one of the manager-related attributes is present,
    providing tracking of which manager created the entity.

    Attributes:
        required_any: Specifies the required manager-related attributes.
    """

    __abstract__ = True
    required_any: ClassVar[list[list[str]]] = [["created_by", "created_by_uuid"]]

    def __init_subclass__(cls, **kw: object) -> None:
        """Validate the subclass during initialization.

        Args:
            **kw: Additional keyword arguments passed to the subclass.
        """
        cls.validate(cls)
        super().__init_subclass__(**kw)

archipy.models.entities.sqlalchemy.base_entities.ManagerMixin.required_any class-attribute

required_any: list[list[str]] = [
    ["created_by", "created_by_uuid"]
]

archipy.models.entities.sqlalchemy.base_entities.ManagerMixin.validate classmethod

validate(base_class: type) -> None

Validate that at least one of the required attributes is present.

Parameters:

Name Type Description Default
base_class type

The class to validate.

required

Raises:

Type Description
AttributeError

If none of the required attributes are present.

Source code in archipy/models/entities/sqlalchemy/base_entities.py
@classmethod
def validate(cls, base_class: type) -> None:
    """Validate that at least one of the required attributes is present.

    Args:
        base_class: The class to validate.

    Raises:
        AttributeError: If none of the required attributes are present.
    """
    for attrs in cls.required_any:
        if not any(hasattr(base_class, attr) for attr in attrs):
            error_message = f"One of {attrs} must be defined in {base_class.__name__}"
            raise AttributeError(error_message)

archipy.models.entities.sqlalchemy.base_entities.UpdatableAdminMixin

Bases: EntityAttributeChecker

Mixin for models updatable by admin.

This mixin ensures that at least one of the admin-related update attributes is present, providing tracking of which administrator last updated the entity.

Attributes:

Name Type Description
required_any list[list[str]]

Specifies the required admin-related update attributes.

Source code in archipy/models/entities/sqlalchemy/base_entities.py
class UpdatableAdminMixin(EntityAttributeChecker):
    """Mixin for models updatable by admin.

    This mixin ensures that at least one of the admin-related update attributes is present,
    providing tracking of which administrator last updated the entity.

    Attributes:
        required_any: Specifies the required admin-related update attributes.
    """

    __abstract__ = True
    required_any: ClassVar[list[list[str]]] = [["updated_by_admin", "updated_by_admin_uuid"]]

    def __init_subclass__(cls, **kw: object) -> None:
        """Validate the subclass during initialization.

        Args:
            **kw: Additional keyword arguments passed to the subclass.
        """
        cls.validate(cls)
        super().__init_subclass__(**kw)

archipy.models.entities.sqlalchemy.base_entities.UpdatableAdminMixin.required_any class-attribute

required_any: list[list[str]] = [
    ["updated_by_admin", "updated_by_admin_uuid"]
]

archipy.models.entities.sqlalchemy.base_entities.UpdatableAdminMixin.validate classmethod

validate(base_class: type) -> None

Validate that at least one of the required attributes is present.

Parameters:

Name Type Description Default
base_class type

The class to validate.

required

Raises:

Type Description
AttributeError

If none of the required attributes are present.

Source code in archipy/models/entities/sqlalchemy/base_entities.py
@classmethod
def validate(cls, base_class: type) -> None:
    """Validate that at least one of the required attributes is present.

    Args:
        base_class: The class to validate.

    Raises:
        AttributeError: If none of the required attributes are present.
    """
    for attrs in cls.required_any:
        if not any(hasattr(base_class, attr) for attr in attrs):
            error_message = f"One of {attrs} must be defined in {base_class.__name__}"
            raise AttributeError(error_message)

archipy.models.entities.sqlalchemy.base_entities.UpdatableManagerMixin

Bases: EntityAttributeChecker

Mixin for models updatable by managers.

This mixin ensures that at least one of the manager-related update attributes is present, providing tracking of which manager last updated the entity.

Attributes:

Name Type Description
required_any list[list[str]]

Specifies the required manager-related update attributes.

Source code in archipy/models/entities/sqlalchemy/base_entities.py
class UpdatableManagerMixin(EntityAttributeChecker):
    """Mixin for models updatable by managers.

    This mixin ensures that at least one of the manager-related update attributes is present,
    providing tracking of which manager last updated the entity.

    Attributes:
        required_any: Specifies the required manager-related update attributes.
    """

    __abstract__ = True
    required_any: ClassVar[list[list[str]]] = [["updated_by", "updated_by_uuid"]]

    def __init_subclass__(cls, **kw: object) -> None:
        """Validate the subclass during initialization.

        Args:
            **kw: Additional keyword arguments passed to the subclass.
        """
        cls.validate(cls)
        super().__init_subclass__(**kw)

archipy.models.entities.sqlalchemy.base_entities.UpdatableManagerMixin.required_any class-attribute

required_any: list[list[str]] = [
    ["updated_by", "updated_by_uuid"]
]

archipy.models.entities.sqlalchemy.base_entities.UpdatableManagerMixin.validate classmethod

validate(base_class: type) -> None

Validate that at least one of the required attributes is present.

Parameters:

Name Type Description Default
base_class type

The class to validate.

required

Raises:

Type Description
AttributeError

If none of the required attributes are present.

Source code in archipy/models/entities/sqlalchemy/base_entities.py
@classmethod
def validate(cls, base_class: type) -> None:
    """Validate that at least one of the required attributes is present.

    Args:
        base_class: The class to validate.

    Raises:
        AttributeError: If none of the required attributes are present.
    """
    for attrs in cls.required_any:
        if not any(hasattr(base_class, attr) for attr in attrs):
            error_message = f"One of {attrs} must be defined in {base_class.__name__}"
            raise AttributeError(error_message)

archipy.models.entities.sqlalchemy.base_entities.UpdatableEntity

Bases: BaseEntity, UpdatableMixin

Base class for entities that support updating timestamps.

This class extends BaseEntity with update tracking functionality, allowing applications to track when records were last modified.

Attributes:

Name Type Description
created_at Mapped[datetime]

Timestamp indicating when the entity was created.

updated_at

Timestamp indicating when the entity was last updated.

Source code in archipy/models/entities/sqlalchemy/base_entities.py
class UpdatableEntity(BaseEntity, UpdatableMixin):
    """Base class for entities that support updating timestamps.

    This class extends BaseEntity with update tracking functionality, allowing
    applications to track when records were last modified.

    Attributes:
        created_at: Timestamp indicating when the entity was created.
        updated_at: Timestamp indicating when the entity was last updated.
    """

    __abstract__ = True

archipy.models.entities.sqlalchemy.base_entities.UpdatableEntity.updated_at class-attribute instance-attribute

updated_at = Column(
    DateTime(),
    server_default=now(),
    nullable=False,
    onupdate=now(),
)

archipy.models.entities.sqlalchemy.base_entities.UpdatableEntity.created_at class-attribute instance-attribute

created_at: Mapped[datetime] = mapped_column(
    DateTime(), server_default=now(), nullable=False
)

archipy.models.entities.sqlalchemy.base_entities.DeletableEntity

Bases: BaseEntity, DeletableMixin

Base class for entities that support soft deletion.

This class extends BaseEntity with soft deletion capability, allowing applications to mark records as deleted without physically removing them.

Attributes:

Name Type Description
created_at Mapped[datetime]

Timestamp indicating when the entity was created.

is_deleted

Flag indicating if the entity is deleted.

Source code in archipy/models/entities/sqlalchemy/base_entities.py
class DeletableEntity(BaseEntity, DeletableMixin):
    """Base class for entities that support soft deletion.

    This class extends BaseEntity with soft deletion capability, allowing
    applications to mark records as deleted without physically removing them.

    Attributes:
        created_at: Timestamp indicating when the entity was created.
        is_deleted: Flag indicating if the entity is deleted.
    """

    __abstract__ = True

archipy.models.entities.sqlalchemy.base_entities.DeletableEntity.is_deleted class-attribute instance-attribute

is_deleted = Column(Boolean, default=False, nullable=False)

archipy.models.entities.sqlalchemy.base_entities.DeletableEntity.created_at class-attribute instance-attribute

created_at: Mapped[datetime] = mapped_column(
    DateTime(), server_default=now(), nullable=False
)

archipy.models.entities.sqlalchemy.base_entities.AdminEntity

Bases: BaseEntity, AdminMixin

Base class for entities with admin-related attributes.

This class extends BaseEntity with tracking of which administrator created the entity, supporting audit and accountability requirements.

Attributes:

Name Type Description
created_at Mapped[datetime]

Timestamp indicating when the entity was created.

created_by_admin/created_by_admin_uuid Mapped[datetime]

Reference to the admin who created the entity.

Source code in archipy/models/entities/sqlalchemy/base_entities.py
class AdminEntity(BaseEntity, AdminMixin):
    """Base class for entities with admin-related attributes.

    This class extends BaseEntity with tracking of which administrator created
    the entity, supporting audit and accountability requirements.

    Attributes:
        created_at: Timestamp indicating when the entity was created.
        created_by_admin/created_by_admin_uuid: Reference to the admin who created the entity.
    """

    __abstract__ = True

archipy.models.entities.sqlalchemy.base_entities.AdminEntity.required_any class-attribute

required_any: list[list[str]] = [
    ["created_by_admin", "created_by_admin_uuid"]
]

archipy.models.entities.sqlalchemy.base_entities.AdminEntity.created_at class-attribute instance-attribute

created_at: Mapped[datetime] = mapped_column(
    DateTime(), server_default=now(), nullable=False
)

archipy.models.entities.sqlalchemy.base_entities.AdminEntity.validate classmethod

validate(base_class: type) -> None

Validate that at least one of the required attributes is present.

Parameters:

Name Type Description Default
base_class type

The class to validate.

required

Raises:

Type Description
AttributeError

If none of the required attributes are present.

Source code in archipy/models/entities/sqlalchemy/base_entities.py
@classmethod
def validate(cls, base_class: type) -> None:
    """Validate that at least one of the required attributes is present.

    Args:
        base_class: The class to validate.

    Raises:
        AttributeError: If none of the required attributes are present.
    """
    for attrs in cls.required_any:
        if not any(hasattr(base_class, attr) for attr in attrs):
            error_message = f"One of {attrs} must be defined in {base_class.__name__}"
            raise AttributeError(error_message)

archipy.models.entities.sqlalchemy.base_entities.ManagerEntity

Bases: BaseEntity, ManagerMixin

Base class for entities with manager-related attributes.

This class extends BaseEntity with tracking of which manager created the entity, supporting audit and accountability requirements.

Attributes:

Name Type Description
created_at Mapped[datetime]

Timestamp indicating when the entity was created.

created_by/created_by_uuid Mapped[datetime]

Reference to the manager who created the entity.

Source code in archipy/models/entities/sqlalchemy/base_entities.py
class ManagerEntity(BaseEntity, ManagerMixin):
    """Base class for entities with manager-related attributes.

    This class extends BaseEntity with tracking of which manager created
    the entity, supporting audit and accountability requirements.

    Attributes:
        created_at: Timestamp indicating when the entity was created.
        created_by/created_by_uuid: Reference to the manager who created the entity.
    """

    __abstract__ = True

archipy.models.entities.sqlalchemy.base_entities.ManagerEntity.required_any class-attribute

required_any: list[list[str]] = [
    ["created_by", "created_by_uuid"]
]

archipy.models.entities.sqlalchemy.base_entities.ManagerEntity.created_at class-attribute instance-attribute

created_at: Mapped[datetime] = mapped_column(
    DateTime(), server_default=now(), nullable=False
)

archipy.models.entities.sqlalchemy.base_entities.ManagerEntity.validate classmethod

validate(base_class: type) -> None

Validate that at least one of the required attributes is present.

Parameters:

Name Type Description Default
base_class type

The class to validate.

required

Raises:

Type Description
AttributeError

If none of the required attributes are present.

Source code in archipy/models/entities/sqlalchemy/base_entities.py
@classmethod
def validate(cls, base_class: type) -> None:
    """Validate that at least one of the required attributes is present.

    Args:
        base_class: The class to validate.

    Raises:
        AttributeError: If none of the required attributes are present.
    """
    for attrs in cls.required_any:
        if not any(hasattr(base_class, attr) for attr in attrs):
            error_message = f"One of {attrs} must be defined in {base_class.__name__}"
            raise AttributeError(error_message)

archipy.models.entities.sqlalchemy.base_entities.UpdatableDeletableEntity

Bases: BaseEntity, UpdatableMixin, DeletableMixin

Base class for entities that support updating timestamps and soft deletion.

This class combines update tracking and soft deletion capabilities, providing a complete history of when records were created, updated, and deleted.

Attributes:

Name Type Description
created_at Mapped[datetime]

Timestamp indicating when the entity was created.

updated_at

Timestamp indicating when the entity was last updated.

is_deleted

Flag indicating if the entity is deleted.

Source code in archipy/models/entities/sqlalchemy/base_entities.py
class UpdatableDeletableEntity(BaseEntity, UpdatableMixin, DeletableMixin):
    """Base class for entities that support updating timestamps and soft deletion.

    This class combines update tracking and soft deletion capabilities, providing
    a complete history of when records were created, updated, and deleted.

    Attributes:
        created_at: Timestamp indicating when the entity was created.
        updated_at: Timestamp indicating when the entity was last updated.
        is_deleted: Flag indicating if the entity is deleted.
    """

    __abstract__ = True

archipy.models.entities.sqlalchemy.base_entities.UpdatableDeletableEntity.is_deleted class-attribute instance-attribute

is_deleted = Column(Boolean, default=False, nullable=False)

archipy.models.entities.sqlalchemy.base_entities.UpdatableDeletableEntity.updated_at class-attribute instance-attribute

updated_at = Column(
    DateTime(),
    server_default=now(),
    nullable=False,
    onupdate=now(),
)

archipy.models.entities.sqlalchemy.base_entities.UpdatableDeletableEntity.created_at class-attribute instance-attribute

created_at: Mapped[datetime] = mapped_column(
    DateTime(), server_default=now(), nullable=False
)

archipy.models.entities.sqlalchemy.base_entities.ArchivableEntity

Bases: UpdatableEntity, ArchivableMixin

Base class for entities that support archiving.

This class extends UpdatableEntity with archiving capability, allowing applications to mark records as archived and track the original entity.

Attributes:

Name Type Description
created_at Mapped[datetime]

Timestamp indicating when the entity was created.

updated_at

Timestamp indicating when the entity was last updated.

is_archived

Flag indicating if the entity is archived.

origin_uuid

Reference to the original entity.

Source code in archipy/models/entities/sqlalchemy/base_entities.py
class ArchivableEntity(UpdatableEntity, ArchivableMixin):
    """Base class for entities that support archiving.

    This class extends UpdatableEntity with archiving capability, allowing
    applications to mark records as archived and track the original entity.

    Attributes:
        created_at: Timestamp indicating when the entity was created.
        updated_at: Timestamp indicating when the entity was last updated.
        is_archived: Flag indicating if the entity is archived.
        origin_uuid: Reference to the original entity.
    """

    __abstract__ = True

archipy.models.entities.sqlalchemy.base_entities.ArchivableEntity.is_archived class-attribute instance-attribute

is_archived = Column(Boolean, default=False, nullable=False)

archipy.models.entities.sqlalchemy.base_entities.ArchivableEntity.origin_uuid class-attribute instance-attribute

origin_uuid = Column(
    ForeignKey("self.pk_uuid"), nullable=True
)

archipy.models.entities.sqlalchemy.base_entities.ArchivableEntity.updated_at class-attribute instance-attribute

updated_at = Column(
    DateTime(),
    server_default=now(),
    nullable=False,
    onupdate=now(),
)

archipy.models.entities.sqlalchemy.base_entities.ArchivableEntity.created_at class-attribute instance-attribute

created_at: Mapped[datetime] = mapped_column(
    DateTime(), server_default=now(), nullable=False
)

archipy.models.entities.sqlalchemy.base_entities.UpdatableAdminEntity

Bases: BaseEntity, UpdatableMixin, AdminMixin, UpdatableAdminMixin

Base class for entities updatable by admin with timestamps.

This class combines creation and update tracking for administrator actions, providing a comprehensive audit trail of administrative modifications.

Attributes:

Name Type Description
created_at Mapped[datetime]

Timestamp indicating when the entity was created.

updated_at

Timestamp indicating when the entity was last updated.

created_by_admin/created_by_admin_uuid

Reference to the admin who created the entity.

updated_by_admin/updated_by_admin_uuid

Reference to the admin who last updated the entity.

Source code in archipy/models/entities/sqlalchemy/base_entities.py
class UpdatableAdminEntity(BaseEntity, UpdatableMixin, AdminMixin, UpdatableAdminMixin):
    """Base class for entities updatable by admin with timestamps.

    This class combines creation and update tracking for administrator actions,
    providing a comprehensive audit trail of administrative modifications.

    Attributes:
        created_at: Timestamp indicating when the entity was created.
        updated_at: Timestamp indicating when the entity was last updated.
        created_by_admin/created_by_admin_uuid: Reference to the admin who created the entity.
        updated_by_admin/updated_by_admin_uuid: Reference to the admin who last updated the entity.
    """

    __abstract__ = True

archipy.models.entities.sqlalchemy.base_entities.UpdatableAdminEntity.required_any class-attribute

required_any: list[list[str]] = [
    ["created_by_admin", "created_by_admin_uuid"]
]

archipy.models.entities.sqlalchemy.base_entities.UpdatableAdminEntity.updated_at class-attribute instance-attribute

updated_at = Column(
    DateTime(),
    server_default=now(),
    nullable=False,
    onupdate=now(),
)

archipy.models.entities.sqlalchemy.base_entities.UpdatableAdminEntity.created_at class-attribute instance-attribute

created_at: Mapped[datetime] = mapped_column(
    DateTime(), server_default=now(), nullable=False
)

archipy.models.entities.sqlalchemy.base_entities.UpdatableAdminEntity.validate classmethod

validate(base_class: type) -> None

Validate that at least one of the required attributes is present.

Parameters:

Name Type Description Default
base_class type

The class to validate.

required

Raises:

Type Description
AttributeError

If none of the required attributes are present.

Source code in archipy/models/entities/sqlalchemy/base_entities.py
@classmethod
def validate(cls, base_class: type) -> None:
    """Validate that at least one of the required attributes is present.

    Args:
        base_class: The class to validate.

    Raises:
        AttributeError: If none of the required attributes are present.
    """
    for attrs in cls.required_any:
        if not any(hasattr(base_class, attr) for attr in attrs):
            error_message = f"One of {attrs} must be defined in {base_class.__name__}"
            raise AttributeError(error_message)

archipy.models.entities.sqlalchemy.base_entities.UpdatableManagerEntity

Bases: BaseEntity, UpdatableMixin, ManagerMixin, UpdatableManagerMixin

Base class for entities updatable by managers with timestamps.

This class combines creation and update tracking for manager actions, providing a comprehensive audit trail of management modifications.

Attributes:

Name Type Description
created_at Mapped[datetime]

Timestamp indicating when the entity was created.

updated_at

Timestamp indicating when the entity was last updated.

created_by/created_by_uuid

Reference to the manager who created the entity.

updated_by/updated_by_uuid

Reference to the manager who last updated the entity.

Source code in archipy/models/entities/sqlalchemy/base_entities.py
class UpdatableManagerEntity(BaseEntity, UpdatableMixin, ManagerMixin, UpdatableManagerMixin):
    """Base class for entities updatable by managers with timestamps.

    This class combines creation and update tracking for manager actions,
    providing a comprehensive audit trail of management modifications.

    Attributes:
        created_at: Timestamp indicating when the entity was created.
        updated_at: Timestamp indicating when the entity was last updated.
        created_by/created_by_uuid: Reference to the manager who created the entity.
        updated_by/updated_by_uuid: Reference to the manager who last updated the entity.
    """

    __abstract__ = True

archipy.models.entities.sqlalchemy.base_entities.UpdatableManagerEntity.required_any class-attribute

required_any: list[list[str]] = [
    ["created_by", "created_by_uuid"]
]

archipy.models.entities.sqlalchemy.base_entities.UpdatableManagerEntity.updated_at class-attribute instance-attribute

updated_at = Column(
    DateTime(),
    server_default=now(),
    nullable=False,
    onupdate=now(),
)

archipy.models.entities.sqlalchemy.base_entities.UpdatableManagerEntity.created_at class-attribute instance-attribute

created_at: Mapped[datetime] = mapped_column(
    DateTime(), server_default=now(), nullable=False
)

archipy.models.entities.sqlalchemy.base_entities.UpdatableManagerEntity.validate classmethod

validate(base_class: type) -> None

Validate that at least one of the required attributes is present.

Parameters:

Name Type Description Default
base_class type

The class to validate.

required

Raises:

Type Description
AttributeError

If none of the required attributes are present.

Source code in archipy/models/entities/sqlalchemy/base_entities.py
@classmethod
def validate(cls, base_class: type) -> None:
    """Validate that at least one of the required attributes is present.

    Args:
        base_class: The class to validate.

    Raises:
        AttributeError: If none of the required attributes are present.
    """
    for attrs in cls.required_any:
        if not any(hasattr(base_class, attr) for attr in attrs):
            error_message = f"One of {attrs} must be defined in {base_class.__name__}"
            raise AttributeError(error_message)

archipy.models.entities.sqlalchemy.base_entities.ArchivableDeletableEntity

Bases: UpdatableDeletableEntity, ArchivableMixin

Base class for entities that support both archiving and soft deletion.

This class combines archiving and soft deletion capabilities, providing a complete history of when records were created, updated, archived, and deleted.

Attributes:

Name Type Description
created_at Mapped[datetime]

Timestamp indicating when the entity was created.

updated_at

Timestamp indicating when the entity was last updated.

is_deleted

Flag indicating if the entity is deleted.

is_archived

Flag indicating if the entity is archived.

origin_uuid

Reference to the original entity.

Source code in archipy/models/entities/sqlalchemy/base_entities.py
class ArchivableDeletableEntity(UpdatableDeletableEntity, ArchivableMixin):
    """Base class for entities that support both archiving and soft deletion.

    This class combines archiving and soft deletion capabilities, providing
    a complete history of when records were created, updated, archived, and deleted.

    Attributes:
        created_at: Timestamp indicating when the entity was created.
        updated_at: Timestamp indicating when the entity was last updated.
        is_deleted: Flag indicating if the entity is deleted.
        is_archived: Flag indicating if the entity is archived.
        origin_uuid: Reference to the original entity.
    """

    __abstract__ = True

archipy.models.entities.sqlalchemy.base_entities.ArchivableDeletableEntity.is_archived class-attribute instance-attribute

is_archived = Column(Boolean, default=False, nullable=False)

archipy.models.entities.sqlalchemy.base_entities.ArchivableDeletableEntity.origin_uuid class-attribute instance-attribute

origin_uuid = Column(
    ForeignKey("self.pk_uuid"), nullable=True
)

archipy.models.entities.sqlalchemy.base_entities.ArchivableDeletableEntity.is_deleted class-attribute instance-attribute

is_deleted = Column(Boolean, default=False, nullable=False)

archipy.models.entities.sqlalchemy.base_entities.ArchivableDeletableEntity.updated_at class-attribute instance-attribute

updated_at = Column(
    DateTime(),
    server_default=now(),
    nullable=False,
    onupdate=now(),
)

archipy.models.entities.sqlalchemy.base_entities.ArchivableDeletableEntity.created_at class-attribute instance-attribute

created_at: Mapped[datetime] = mapped_column(
    DateTime(), server_default=now(), nullable=False
)

archipy.models.entities.sqlalchemy.base_entities.UpdatableDeletableAdminEntity

Bases: BaseEntity, UpdatableMixin, AdminMixin, UpdatableAdminMixin, DeletableMixin

Base class for entities updatable by admin with timestamps and soft deletion.

This class combines administrator creation and update tracking with soft deletion, providing a complete audit trail throughout the entity's lifecycle.

Attributes:

Name Type Description
created_at Mapped[datetime]

Timestamp indicating when the entity was created.

updated_at

Timestamp indicating when the entity was last updated.

is_deleted

Flag indicating if the entity is deleted.

created_by_admin/created_by_admin_uuid

Reference to the admin who created the entity.

updated_by_admin/updated_by_admin_uuid

Reference to the admin who last updated the entity.

Source code in archipy/models/entities/sqlalchemy/base_entities.py
class UpdatableDeletableAdminEntity(BaseEntity, UpdatableMixin, AdminMixin, UpdatableAdminMixin, DeletableMixin):
    """Base class for entities updatable by admin with timestamps and soft deletion.

    This class combines administrator creation and update tracking with soft deletion,
    providing a complete audit trail throughout the entity's lifecycle.

    Attributes:
        created_at: Timestamp indicating when the entity was created.
        updated_at: Timestamp indicating when the entity was last updated.
        is_deleted: Flag indicating if the entity is deleted.
        created_by_admin/created_by_admin_uuid: Reference to the admin who created the entity.
        updated_by_admin/updated_by_admin_uuid: Reference to the admin who last updated the entity.
    """

    __abstract__ = True

archipy.models.entities.sqlalchemy.base_entities.UpdatableDeletableAdminEntity.is_deleted class-attribute instance-attribute

is_deleted = Column(Boolean, default=False, nullable=False)

archipy.models.entities.sqlalchemy.base_entities.UpdatableDeletableAdminEntity.required_any class-attribute

required_any: list[list[str]] = [
    ["created_by_admin", "created_by_admin_uuid"]
]

archipy.models.entities.sqlalchemy.base_entities.UpdatableDeletableAdminEntity.updated_at class-attribute instance-attribute

updated_at = Column(
    DateTime(),
    server_default=now(),
    nullable=False,
    onupdate=now(),
)

archipy.models.entities.sqlalchemy.base_entities.UpdatableDeletableAdminEntity.created_at class-attribute instance-attribute

created_at: Mapped[datetime] = mapped_column(
    DateTime(), server_default=now(), nullable=False
)

archipy.models.entities.sqlalchemy.base_entities.UpdatableDeletableAdminEntity.validate classmethod

validate(base_class: type) -> None

Validate that at least one of the required attributes is present.

Parameters:

Name Type Description Default
base_class type

The class to validate.

required

Raises:

Type Description
AttributeError

If none of the required attributes are present.

Source code in archipy/models/entities/sqlalchemy/base_entities.py
@classmethod
def validate(cls, base_class: type) -> None:
    """Validate that at least one of the required attributes is present.

    Args:
        base_class: The class to validate.

    Raises:
        AttributeError: If none of the required attributes are present.
    """
    for attrs in cls.required_any:
        if not any(hasattr(base_class, attr) for attr in attrs):
            error_message = f"One of {attrs} must be defined in {base_class.__name__}"
            raise AttributeError(error_message)

archipy.models.entities.sqlalchemy.base_entities.UpdatableDeletableManagerEntity

Bases: BaseEntity, UpdatableMixin, ManagerMixin, UpdatableManagerMixin, DeletableMixin

Base class for entities updatable by managers with timestamps and soft deletion.

This class combines manager creation and update tracking with soft deletion, providing a complete audit trail throughout the entity's lifecycle.

Attributes:

Name Type Description
created_at Mapped[datetime]

Timestamp indicating when the entity was created.

updated_at

Timestamp indicating when the entity was last updated.

is_deleted

Flag indicating if the entity is deleted.

created_by/created_by_uuid

Reference to the manager who created the entity.

updated_by/updated_by_uuid

Reference to the manager who last updated the entity.

Source code in archipy/models/entities/sqlalchemy/base_entities.py
class UpdatableDeletableManagerEntity(BaseEntity, UpdatableMixin, ManagerMixin, UpdatableManagerMixin, DeletableMixin):
    """Base class for entities updatable by managers with timestamps and soft deletion.

    This class combines manager creation and update tracking with soft deletion,
    providing a complete audit trail throughout the entity's lifecycle.

    Attributes:
        created_at: Timestamp indicating when the entity was created.
        updated_at: Timestamp indicating when the entity was last updated.
        is_deleted: Flag indicating if the entity is deleted.
        created_by/created_by_uuid: Reference to the manager who created the entity.
        updated_by/updated_by_uuid: Reference to the manager who last updated the entity.
    """

    __abstract__ = True

archipy.models.entities.sqlalchemy.base_entities.UpdatableDeletableManagerEntity.is_deleted class-attribute instance-attribute

is_deleted = Column(Boolean, default=False, nullable=False)

archipy.models.entities.sqlalchemy.base_entities.UpdatableDeletableManagerEntity.required_any class-attribute

required_any: list[list[str]] = [
    ["created_by", "created_by_uuid"]
]

archipy.models.entities.sqlalchemy.base_entities.UpdatableDeletableManagerEntity.updated_at class-attribute instance-attribute

updated_at = Column(
    DateTime(),
    server_default=now(),
    nullable=False,
    onupdate=now(),
)

archipy.models.entities.sqlalchemy.base_entities.UpdatableDeletableManagerEntity.created_at class-attribute instance-attribute

created_at: Mapped[datetime] = mapped_column(
    DateTime(), server_default=now(), nullable=False
)

archipy.models.entities.sqlalchemy.base_entities.UpdatableDeletableManagerEntity.validate classmethod

validate(base_class: type) -> None

Validate that at least one of the required attributes is present.

Parameters:

Name Type Description Default
base_class type

The class to validate.

required

Raises:

Type Description
AttributeError

If none of the required attributes are present.

Source code in archipy/models/entities/sqlalchemy/base_entities.py
@classmethod
def validate(cls, base_class: type) -> None:
    """Validate that at least one of the required attributes is present.

    Args:
        base_class: The class to validate.

    Raises:
        AttributeError: If none of the required attributes are present.
    """
    for attrs in cls.required_any:
        if not any(hasattr(base_class, attr) for attr in attrs):
            error_message = f"One of {attrs} must be defined in {base_class.__name__}"
            raise AttributeError(error_message)

archipy.models.entities.sqlalchemy.base_entities.ArchivableAdminEntity

Bases: ArchivableEntity, AdminMixin

Base class for entities Archivable by admin.

This class extends ArchivableEntity with tracking of which administrator created the entity, supporting audit and accountability requirements.

Attributes:

Name Type Description
created_at Mapped[datetime]

Timestamp indicating when the entity was created.

updated_at

Timestamp indicating when the entity was last updated.

is_archived

Flag indicating if the entity is archived.

origin_uuid

Reference to the original entity.

created_by_admin/created_by_admin_uuid

Reference to the admin who created the entity.

Source code in archipy/models/entities/sqlalchemy/base_entities.py
class ArchivableAdminEntity(ArchivableEntity, AdminMixin):
    """Base class for entities Archivable by admin.

    This class extends ArchivableEntity with tracking of which administrator created
    the entity, supporting audit and accountability requirements.

    Attributes:
        created_at: Timestamp indicating when the entity was created.
        updated_at: Timestamp indicating when the entity was last updated.
        is_archived: Flag indicating if the entity is archived.
        origin_uuid: Reference to the original entity.
        created_by_admin/created_by_admin_uuid: Reference to the admin who created the entity.
    """

    __abstract__ = True

archipy.models.entities.sqlalchemy.base_entities.ArchivableAdminEntity.required_any class-attribute

required_any: list[list[str]] = [
    ["created_by_admin", "created_by_admin_uuid"]
]

archipy.models.entities.sqlalchemy.base_entities.ArchivableAdminEntity.is_archived class-attribute instance-attribute

is_archived = Column(Boolean, default=False, nullable=False)

archipy.models.entities.sqlalchemy.base_entities.ArchivableAdminEntity.origin_uuid class-attribute instance-attribute

origin_uuid = Column(
    ForeignKey("self.pk_uuid"), nullable=True
)

archipy.models.entities.sqlalchemy.base_entities.ArchivableAdminEntity.updated_at class-attribute instance-attribute

updated_at = Column(
    DateTime(),
    server_default=now(),
    nullable=False,
    onupdate=now(),
)

archipy.models.entities.sqlalchemy.base_entities.ArchivableAdminEntity.created_at class-attribute instance-attribute

created_at: Mapped[datetime] = mapped_column(
    DateTime(), server_default=now(), nullable=False
)

archipy.models.entities.sqlalchemy.base_entities.ArchivableAdminEntity.validate classmethod

validate(base_class: type) -> None

Validate that at least one of the required attributes is present.

Parameters:

Name Type Description Default
base_class type

The class to validate.

required

Raises:

Type Description
AttributeError

If none of the required attributes are present.

Source code in archipy/models/entities/sqlalchemy/base_entities.py
@classmethod
def validate(cls, base_class: type) -> None:
    """Validate that at least one of the required attributes is present.

    Args:
        base_class: The class to validate.

    Raises:
        AttributeError: If none of the required attributes are present.
    """
    for attrs in cls.required_any:
        if not any(hasattr(base_class, attr) for attr in attrs):
            error_message = f"One of {attrs} must be defined in {base_class.__name__}"
            raise AttributeError(error_message)

archipy.models.entities.sqlalchemy.base_entities.ArchivableManagerEntity

Bases: ArchivableEntity, ManagerMixin

Base class for entities Archivable by managers.

This class extends ArchivableEntity with tracking of which manager created the entity, supporting audit and accountability requirements.

Attributes:

Name Type Description
created_at Mapped[datetime]

Timestamp indicating when the entity was created.

updated_at

Timestamp indicating when the entity was last updated.

is_archived

Flag indicating if the entity is archived.

origin_uuid

Reference to the original entity.

created_by/created_by_uuid

Reference to the manager who created the entity.

Source code in archipy/models/entities/sqlalchemy/base_entities.py
class ArchivableManagerEntity(ArchivableEntity, ManagerMixin):
    """Base class for entities Archivable by managers.

    This class extends ArchivableEntity with tracking of which manager created
    the entity, supporting audit and accountability requirements.

    Attributes:
        created_at: Timestamp indicating when the entity was created.
        updated_at: Timestamp indicating when the entity was last updated.
        is_archived: Flag indicating if the entity is archived.
        origin_uuid: Reference to the original entity.
        created_by/created_by_uuid: Reference to the manager who created the entity.
    """

    __abstract__ = True

archipy.models.entities.sqlalchemy.base_entities.ArchivableManagerEntity.required_any class-attribute

required_any: list[list[str]] = [
    ["created_by", "created_by_uuid"]
]

archipy.models.entities.sqlalchemy.base_entities.ArchivableManagerEntity.is_archived class-attribute instance-attribute

is_archived = Column(Boolean, default=False, nullable=False)

archipy.models.entities.sqlalchemy.base_entities.ArchivableManagerEntity.origin_uuid class-attribute instance-attribute

origin_uuid = Column(
    ForeignKey("self.pk_uuid"), nullable=True
)

archipy.models.entities.sqlalchemy.base_entities.ArchivableManagerEntity.updated_at class-attribute instance-attribute

updated_at = Column(
    DateTime(),
    server_default=now(),
    nullable=False,
    onupdate=now(),
)

archipy.models.entities.sqlalchemy.base_entities.ArchivableManagerEntity.created_at class-attribute instance-attribute

created_at: Mapped[datetime] = mapped_column(
    DateTime(), server_default=now(), nullable=False
)

archipy.models.entities.sqlalchemy.base_entities.ArchivableManagerEntity.validate classmethod

validate(base_class: type) -> None

Validate that at least one of the required attributes is present.

Parameters:

Name Type Description Default
base_class type

The class to validate.

required

Raises:

Type Description
AttributeError

If none of the required attributes are present.

Source code in archipy/models/entities/sqlalchemy/base_entities.py
@classmethod
def validate(cls, base_class: type) -> None:
    """Validate that at least one of the required attributes is present.

    Args:
        base_class: The class to validate.

    Raises:
        AttributeError: If none of the required attributes are present.
    """
    for attrs in cls.required_any:
        if not any(hasattr(base_class, attr) for attr in attrs):
            error_message = f"One of {attrs} must be defined in {base_class.__name__}"
            raise AttributeError(error_message)

archipy.models.entities.sqlalchemy.base_entities.UpdatableManagerAdminEntity

Bases: BaseEntity, UpdatableMixin, ManagerMixin, AdminMixin, UpdatableManagerMixin, UpdatableAdminMixin

Base class for entities updatable by both managers and admins with timestamps.

This class provides comprehensive tracking of entity creation and updates by both administrators and managers, supporting complex workflows where different user roles interact with the same data.

Attributes:

Name Type Description
created_at Mapped[datetime]

Timestamp indicating when the entity was created.

updated_at

Timestamp indicating when the entity was last updated.

created_by_admin/created_by_admin_uuid

Reference to the admin who created the entity.

created_by/created_by_uuid

Reference to the manager who created the entity.

updated_by_admin/updated_by_admin_uuid

Reference to the admin who last updated the entity.

updated_by/updated_by_uuid

Reference to the manager who last updated the entity.

Source code in archipy/models/entities/sqlalchemy/base_entities.py
class UpdatableManagerAdminEntity(
    BaseEntity,
    UpdatableMixin,
    ManagerMixin,
    AdminMixin,
    UpdatableManagerMixin,
    UpdatableAdminMixin,
):
    """Base class for entities updatable by both managers and admins with timestamps.

    This class provides comprehensive tracking of entity creation and updates
    by both administrators and managers, supporting complex workflows where
    different user roles interact with the same data.

    Attributes:
        created_at: Timestamp indicating when the entity was created.
        updated_at: Timestamp indicating when the entity was last updated.
        created_by_admin/created_by_admin_uuid: Reference to the admin who created the entity.
        created_by/created_by_uuid: Reference to the manager who created the entity.
        updated_by_admin/updated_by_admin_uuid: Reference to the admin who last updated the entity.
        updated_by/updated_by_uuid: Reference to the manager who last updated the entity.
    """

    __abstract__ = True

archipy.models.entities.sqlalchemy.base_entities.UpdatableManagerAdminEntity.required_any class-attribute

required_any: list[list[str]] = [
    ["created_by", "created_by_uuid"]
]

archipy.models.entities.sqlalchemy.base_entities.UpdatableManagerAdminEntity.updated_at class-attribute instance-attribute

updated_at = Column(
    DateTime(),
    server_default=now(),
    nullable=False,
    onupdate=now(),
)

archipy.models.entities.sqlalchemy.base_entities.UpdatableManagerAdminEntity.created_at class-attribute instance-attribute

created_at: Mapped[datetime] = mapped_column(
    DateTime(), server_default=now(), nullable=False
)

archipy.models.entities.sqlalchemy.base_entities.UpdatableManagerAdminEntity.validate classmethod

validate(base_class: type) -> None

Validate that at least one of the required attributes is present.

Parameters:

Name Type Description Default
base_class type

The class to validate.

required

Raises:

Type Description
AttributeError

If none of the required attributes are present.

Source code in archipy/models/entities/sqlalchemy/base_entities.py
@classmethod
def validate(cls, base_class: type) -> None:
    """Validate that at least one of the required attributes is present.

    Args:
        base_class: The class to validate.

    Raises:
        AttributeError: If none of the required attributes are present.
    """
    for attrs in cls.required_any:
        if not any(hasattr(base_class, attr) for attr in attrs):
            error_message = f"One of {attrs} must be defined in {base_class.__name__}"
            raise AttributeError(error_message)

archipy.models.entities.sqlalchemy.base_entities.ArchivableManagerAdminEntity

Bases: ArchivableEntity, ManagerMixin, AdminMixin

Base class for entities Archivable by both managers and admins.

This class provides comprehensive tracking of entity creation by both administrators and managers, supporting complex workflows where different user roles interact with the same data.

Attributes:

Name Type Description
created_at Mapped[datetime]

Timestamp indicating when the entity was created.

updated_at

Timestamp indicating when the entity was last updated.

is_archived

Flag indicating if the entity is archived.

origin_uuid

Reference to the original entity.

created_by_admin/created_by_admin_uuid

Reference to the admin who created the entity.

created_by/created_by_uuid

Reference to the manager who created the entity.

Source code in archipy/models/entities/sqlalchemy/base_entities.py
class ArchivableManagerAdminEntity(
    ArchivableEntity,
    ManagerMixin,
    AdminMixin,
):
    """Base class for entities Archivable by both managers and admins.

    This class provides comprehensive tracking of entity creation
    by both administrators and managers, supporting complex workflows where
    different user roles interact with the same data.

    Attributes:
        created_at: Timestamp indicating when the entity was created.
        updated_at: Timestamp indicating when the entity was last updated.
        is_archived: Flag indicating if the entity is archived.
        origin_uuid: Reference to the original entity.
        created_by_admin/created_by_admin_uuid: Reference to the admin who created the entity.
        created_by/created_by_uuid: Reference to the manager who created the entity.
    """

    __abstract__ = True

archipy.models.entities.sqlalchemy.base_entities.ArchivableManagerAdminEntity.required_any class-attribute

required_any: list[list[str]] = [
    ["created_by", "created_by_uuid"]
]

archipy.models.entities.sqlalchemy.base_entities.ArchivableManagerAdminEntity.is_archived class-attribute instance-attribute

is_archived = Column(Boolean, default=False, nullable=False)

archipy.models.entities.sqlalchemy.base_entities.ArchivableManagerAdminEntity.origin_uuid class-attribute instance-attribute

origin_uuid = Column(
    ForeignKey("self.pk_uuid"), nullable=True
)

archipy.models.entities.sqlalchemy.base_entities.ArchivableManagerAdminEntity.updated_at class-attribute instance-attribute

updated_at = Column(
    DateTime(),
    server_default=now(),
    nullable=False,
    onupdate=now(),
)

archipy.models.entities.sqlalchemy.base_entities.ArchivableManagerAdminEntity.created_at class-attribute instance-attribute

created_at: Mapped[datetime] = mapped_column(
    DateTime(), server_default=now(), nullable=False
)

archipy.models.entities.sqlalchemy.base_entities.ArchivableManagerAdminEntity.validate classmethod

validate(base_class: type) -> None

Validate that at least one of the required attributes is present.

Parameters:

Name Type Description Default
base_class type

The class to validate.

required

Raises:

Type Description
AttributeError

If none of the required attributes are present.

Source code in archipy/models/entities/sqlalchemy/base_entities.py
@classmethod
def validate(cls, base_class: type) -> None:
    """Validate that at least one of the required attributes is present.

    Args:
        base_class: The class to validate.

    Raises:
        AttributeError: If none of the required attributes are present.
    """
    for attrs in cls.required_any:
        if not any(hasattr(base_class, attr) for attr in attrs):
            error_message = f"One of {attrs} must be defined in {base_class.__name__}"
            raise AttributeError(error_message)

archipy.models.entities.sqlalchemy.base_entities.ArchivableDeletableAdminEntity

Bases: ArchivableDeletableEntity, AdminMixin

Base class for entities Archivable and deletable by admin.

This class combines administrator creation tracking with soft deletion and archiving, providing a complete audit trail throughout the entity's lifecycle.

Attributes:

Name Type Description
created_at Mapped[datetime]

Timestamp indicating when the entity was created.

updated_at

Timestamp indicating when the entity was last updated.

is_deleted

Flag indicating if the entity is deleted.

is_archived

Flag indicating if the entity is archived.

origin_uuid

Reference to the original entity.

created_by_admin/created_by_admin_uuid

Reference to the admin who created the entity.

Source code in archipy/models/entities/sqlalchemy/base_entities.py
class ArchivableDeletableAdminEntity(ArchivableDeletableEntity, AdminMixin):
    """Base class for entities Archivable and deletable by admin.

    This class combines administrator creation tracking with soft deletion and archiving,
    providing a complete audit trail throughout the entity's lifecycle.

    Attributes:
        created_at: Timestamp indicating when the entity was created.
        updated_at: Timestamp indicating when the entity was last updated.
        is_deleted: Flag indicating if the entity is deleted.
        is_archived: Flag indicating if the entity is archived.
        origin_uuid: Reference to the original entity.
        created_by_admin/created_by_admin_uuid: Reference to the admin who created the entity.
    """

    __abstract__ = True

archipy.models.entities.sqlalchemy.base_entities.ArchivableDeletableAdminEntity.required_any class-attribute

required_any: list[list[str]] = [
    ["created_by_admin", "created_by_admin_uuid"]
]

archipy.models.entities.sqlalchemy.base_entities.ArchivableDeletableAdminEntity.is_archived class-attribute instance-attribute

is_archived = Column(Boolean, default=False, nullable=False)

archipy.models.entities.sqlalchemy.base_entities.ArchivableDeletableAdminEntity.origin_uuid class-attribute instance-attribute

origin_uuid = Column(
    ForeignKey("self.pk_uuid"), nullable=True
)

archipy.models.entities.sqlalchemy.base_entities.ArchivableDeletableAdminEntity.is_deleted class-attribute instance-attribute

is_deleted = Column(Boolean, default=False, nullable=False)

archipy.models.entities.sqlalchemy.base_entities.ArchivableDeletableAdminEntity.updated_at class-attribute instance-attribute

updated_at = Column(
    DateTime(),
    server_default=now(),
    nullable=False,
    onupdate=now(),
)

archipy.models.entities.sqlalchemy.base_entities.ArchivableDeletableAdminEntity.created_at class-attribute instance-attribute

created_at: Mapped[datetime] = mapped_column(
    DateTime(), server_default=now(), nullable=False
)

archipy.models.entities.sqlalchemy.base_entities.ArchivableDeletableAdminEntity.validate classmethod

validate(base_class: type) -> None

Validate that at least one of the required attributes is present.

Parameters:

Name Type Description Default
base_class type

The class to validate.

required

Raises:

Type Description
AttributeError

If none of the required attributes are present.

Source code in archipy/models/entities/sqlalchemy/base_entities.py
@classmethod
def validate(cls, base_class: type) -> None:
    """Validate that at least one of the required attributes is present.

    Args:
        base_class: The class to validate.

    Raises:
        AttributeError: If none of the required attributes are present.
    """
    for attrs in cls.required_any:
        if not any(hasattr(base_class, attr) for attr in attrs):
            error_message = f"One of {attrs} must be defined in {base_class.__name__}"
            raise AttributeError(error_message)

archipy.models.entities.sqlalchemy.base_entities.ArchivableDeletableManagerEntity

Bases: ArchivableDeletableEntity, ManagerMixin

Base class for entities Archivable and deletable by managers.

This class combines manager creation tracking with soft deletion and archiving, providing a complete audit trail throughout the entity's lifecycle.

Attributes:

Name Type Description
created_at Mapped[datetime]

Timestamp indicating when the entity was created.

updated_at

Timestamp indicating when the entity was last updated.

is_deleted

Flag indicating if the entity is deleted.

is_archived

Flag indicating if the entity is archived.

origin_uuid

Reference to the original entity.

created_by/created_by_uuid

Reference to the manager who created the entity.

Source code in archipy/models/entities/sqlalchemy/base_entities.py
class ArchivableDeletableManagerEntity(ArchivableDeletableEntity, ManagerMixin):
    """Base class for entities Archivable and deletable by managers.

    This class combines manager creation tracking with soft deletion and archiving,
    providing a complete audit trail throughout the entity's lifecycle.

    Attributes:
        created_at: Timestamp indicating when the entity was created.
        updated_at: Timestamp indicating when the entity was last updated.
        is_deleted: Flag indicating if the entity is deleted.
        is_archived: Flag indicating if the entity is archived.
        origin_uuid: Reference to the original entity.
        created_by/created_by_uuid: Reference to the manager who created the entity.
    """

    __abstract__ = True

archipy.models.entities.sqlalchemy.base_entities.ArchivableDeletableManagerEntity.required_any class-attribute

required_any: list[list[str]] = [
    ["created_by", "created_by_uuid"]
]

archipy.models.entities.sqlalchemy.base_entities.ArchivableDeletableManagerEntity.is_archived class-attribute instance-attribute

is_archived = Column(Boolean, default=False, nullable=False)

archipy.models.entities.sqlalchemy.base_entities.ArchivableDeletableManagerEntity.origin_uuid class-attribute instance-attribute

origin_uuid = Column(
    ForeignKey("self.pk_uuid"), nullable=True
)

archipy.models.entities.sqlalchemy.base_entities.ArchivableDeletableManagerEntity.is_deleted class-attribute instance-attribute

is_deleted = Column(Boolean, default=False, nullable=False)

archipy.models.entities.sqlalchemy.base_entities.ArchivableDeletableManagerEntity.updated_at class-attribute instance-attribute

updated_at = Column(
    DateTime(),
    server_default=now(),
    nullable=False,
    onupdate=now(),
)

archipy.models.entities.sqlalchemy.base_entities.ArchivableDeletableManagerEntity.created_at class-attribute instance-attribute

created_at: Mapped[datetime] = mapped_column(
    DateTime(), server_default=now(), nullable=False
)

archipy.models.entities.sqlalchemy.base_entities.ArchivableDeletableManagerEntity.validate classmethod

validate(base_class: type) -> None

Validate that at least one of the required attributes is present.

Parameters:

Name Type Description Default
base_class type

The class to validate.

required

Raises:

Type Description
AttributeError

If none of the required attributes are present.

Source code in archipy/models/entities/sqlalchemy/base_entities.py
@classmethod
def validate(cls, base_class: type) -> None:
    """Validate that at least one of the required attributes is present.

    Args:
        base_class: The class to validate.

    Raises:
        AttributeError: If none of the required attributes are present.
    """
    for attrs in cls.required_any:
        if not any(hasattr(base_class, attr) for attr in attrs):
            error_message = f"One of {attrs} must be defined in {base_class.__name__}"
            raise AttributeError(error_message)

archipy.models.entities.sqlalchemy.base_entities.UpdatableDeletableManagerAdminEntity

Bases: BaseEntity, UpdatableMixin, ManagerMixin, AdminMixin, UpdatableManagerMixin, UpdatableAdminMixin, DeletableMixin

Base class for entities updatable by both managers and admins with timestamps and soft deletion.

This is the most comprehensive entity class, supporting tracking of creation and updates by both administrators and managers, along with soft deletion capability. It provides complete accountability for all operations throughout the entity's lifecycle.

Attributes:

Name Type Description
created_at Mapped[datetime]

Timestamp indicating when the entity was created.

updated_at

Timestamp indicating when the entity was last updated.

is_deleted

Flag indicating if the entity is deleted.

created_by_admin/created_by_admin_uuid

Reference to the admin who created the entity.

created_by/created_by_uuid

Reference to the manager who created the entity.

updated_by_admin/updated_by_admin_uuid

Reference to the admin who last updated the entity.

updated_by/updated_by_uuid

Reference to the manager who last updated the entity.

Source code in archipy/models/entities/sqlalchemy/base_entities.py
class UpdatableDeletableManagerAdminEntity(
    BaseEntity,
    UpdatableMixin,
    ManagerMixin,
    AdminMixin,
    UpdatableManagerMixin,
    UpdatableAdminMixin,
    DeletableMixin,
):
    """Base class for entities updatable by both managers and admins with timestamps and soft deletion.

    This is the most comprehensive entity class, supporting tracking of creation and
    updates by both administrators and managers, along with soft deletion capability.
    It provides complete accountability for all operations throughout the entity's lifecycle.

    Attributes:
        created_at: Timestamp indicating when the entity was created.
        updated_at: Timestamp indicating when the entity was last updated.
        is_deleted: Flag indicating if the entity is deleted.
        created_by_admin/created_by_admin_uuid: Reference to the admin who created the entity.
        created_by/created_by_uuid: Reference to the manager who created the entity.
        updated_by_admin/updated_by_admin_uuid: Reference to the admin who last updated the entity.
        updated_by/updated_by_uuid: Reference to the manager who last updated the entity.
    """

    __abstract__ = True

archipy.models.entities.sqlalchemy.base_entities.UpdatableDeletableManagerAdminEntity.is_deleted class-attribute instance-attribute

is_deleted = Column(Boolean, default=False, nullable=False)

archipy.models.entities.sqlalchemy.base_entities.UpdatableDeletableManagerAdminEntity.required_any class-attribute

required_any: list[list[str]] = [
    ["created_by", "created_by_uuid"]
]

archipy.models.entities.sqlalchemy.base_entities.UpdatableDeletableManagerAdminEntity.updated_at class-attribute instance-attribute

updated_at = Column(
    DateTime(),
    server_default=now(),
    nullable=False,
    onupdate=now(),
)

archipy.models.entities.sqlalchemy.base_entities.UpdatableDeletableManagerAdminEntity.created_at class-attribute instance-attribute

created_at: Mapped[datetime] = mapped_column(
    DateTime(), server_default=now(), nullable=False
)

archipy.models.entities.sqlalchemy.base_entities.UpdatableDeletableManagerAdminEntity.validate classmethod

validate(base_class: type) -> None

Validate that at least one of the required attributes is present.

Parameters:

Name Type Description Default
base_class type

The class to validate.

required

Raises:

Type Description
AttributeError

If none of the required attributes are present.

Source code in archipy/models/entities/sqlalchemy/base_entities.py
@classmethod
def validate(cls, base_class: type) -> None:
    """Validate that at least one of the required attributes is present.

    Args:
        base_class: The class to validate.

    Raises:
        AttributeError: If none of the required attributes are present.
    """
    for attrs in cls.required_any:
        if not any(hasattr(base_class, attr) for attr in attrs):
            error_message = f"One of {attrs} must be defined in {base_class.__name__}"
            raise AttributeError(error_message)

archipy.models.entities.sqlalchemy.base_entities.ArchivableDeletableManagerAdminEntity

Bases: ArchivableDeletableEntity, ManagerMixin, AdminMixin

Base class for entities Archivable and deletable by both managers and admins.

This is a comprehensive entity class, supporting tracking of creation by both administrators and managers, along with soft deletion and archiving capability. It provides complete accountability for all operations throughout the entity's lifecycle.

Attributes:

Name Type Description
created_at Mapped[datetime]

Timestamp indicating when the entity was created.

updated_at

Timestamp indicating when the entity was last updated.

is_deleted

Flag indicating if the entity is deleted.

is_archived

Flag indicating if the entity is archived.

origin_uuid

Reference to the original entity.

created_by_admin/created_by_admin_uuid

Reference to the admin who created the entity.

created_by/created_by_uuid

Reference to the manager who created the entity.

Source code in archipy/models/entities/sqlalchemy/base_entities.py
class ArchivableDeletableManagerAdminEntity(
    ArchivableDeletableEntity,
    ManagerMixin,
    AdminMixin,
):
    """Base class for entities Archivable and deletable by both managers and admins.

    This is a comprehensive entity class, supporting tracking of creation
    by both administrators and managers, along with soft deletion and archiving capability.
    It provides complete accountability for all operations throughout the entity's lifecycle.

    Attributes:
        created_at: Timestamp indicating when the entity was created.
        updated_at: Timestamp indicating when the entity was last updated.
        is_deleted: Flag indicating if the entity is deleted.
        is_archived: Flag indicating if the entity is archived.
        origin_uuid: Reference to the original entity.
        created_by_admin/created_by_admin_uuid: Reference to the admin who created the entity.
        created_by/created_by_uuid: Reference to the manager who created the entity.
    """

    __abstract__ = True

archipy.models.entities.sqlalchemy.base_entities.ArchivableDeletableManagerAdminEntity.required_any class-attribute

required_any: list[list[str]] = [
    ["created_by", "created_by_uuid"]
]

archipy.models.entities.sqlalchemy.base_entities.ArchivableDeletableManagerAdminEntity.is_archived class-attribute instance-attribute

is_archived = Column(Boolean, default=False, nullable=False)

archipy.models.entities.sqlalchemy.base_entities.ArchivableDeletableManagerAdminEntity.origin_uuid class-attribute instance-attribute

origin_uuid = Column(
    ForeignKey("self.pk_uuid"), nullable=True
)

archipy.models.entities.sqlalchemy.base_entities.ArchivableDeletableManagerAdminEntity.is_deleted class-attribute instance-attribute

is_deleted = Column(Boolean, default=False, nullable=False)

archipy.models.entities.sqlalchemy.base_entities.ArchivableDeletableManagerAdminEntity.updated_at class-attribute instance-attribute

updated_at = Column(
    DateTime(),
    server_default=now(),
    nullable=False,
    onupdate=now(),
)

archipy.models.entities.sqlalchemy.base_entities.ArchivableDeletableManagerAdminEntity.created_at class-attribute instance-attribute

created_at: Mapped[datetime] = mapped_column(
    DateTime(), server_default=now(), nullable=False
)

archipy.models.entities.sqlalchemy.base_entities.ArchivableDeletableManagerAdminEntity.validate classmethod

validate(base_class: type) -> None

Validate that at least one of the required attributes is present.

Parameters:

Name Type Description Default
base_class type

The class to validate.

required

Raises:

Type Description
AttributeError

If none of the required attributes are present.

Source code in archipy/models/entities/sqlalchemy/base_entities.py
@classmethod
def validate(cls, base_class: type) -> None:
    """Validate that at least one of the required attributes is present.

    Args:
        base_class: The class to validate.

    Raises:
        AttributeError: If none of the required attributes are present.
    """
    for attrs in cls.required_any:
        if not any(hasattr(base_class, attr) for attr in attrs):
            error_message = f"One of {attrs} must be defined in {base_class.__name__}"
            raise AttributeError(error_message)

options: show_root_toc_entry: false heading_level: 3