| 123456789101112131415161718 |
- from datetime import datetime
- from core_db import AuditMixin, Base, EntityMixin
- from sqlalchemy import DateTime, String, Text
- from sqlalchemy.orm import Mapped, mapped_column
- class AppApiKey(EntityMixin, AuditMixin, Base):
- __tablename__ = "app_api_key"
- app_id: Mapped[str] = mapped_column(String(36), index=True)
- name: Mapped[str] = mapped_column(String(128))
- key_prefix: Mapped[str] = mapped_column(String(16), index=True)
- key_hash: Mapped[str] = mapped_column(String(128), unique=True, index=True)
- status: Mapped[str] = mapped_column(String(32), default="active", index=True)
- scopes: Mapped[str | None] = mapped_column(Text, nullable=True)
- expires_time: Mapped[datetime | None] = mapped_column(DateTime, nullable=True)
- last_used_time: Mapped[datetime | None] = mapped_column(DateTime, nullable=True)
|