Check in backend in working state
This commit is contained in:
@ -7,17 +7,21 @@ This might require some changes to these schemas.
|
||||
|
||||
"""
|
||||
|
||||
import logging
|
||||
import uuid
|
||||
from datetime import datetime
|
||||
import sqlalchemy as sa
|
||||
from sqlmodel import Field, Relationship, SQLModel
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class Client(SQLModel, table=True):
|
||||
"""Client model."""
|
||||
|
||||
id: uuid.UUID = Field(default_factory=uuid.uuid4, primary_key=True)
|
||||
name: str = Field(unique=True)
|
||||
description: str | None = None
|
||||
public_key: str
|
||||
|
||||
created_at: datetime | None = Field(
|
||||
@ -61,11 +65,13 @@ class ClientAccessPolicy(SQLModel, table=True):
|
||||
sa_column_kwargs={"onupdate": sa.func.now(), "server_default": sa.func.now()},
|
||||
)
|
||||
|
||||
|
||||
class ClientSecret(SQLModel, table=True):
|
||||
"""A client secret."""
|
||||
|
||||
id: uuid.UUID = Field(default_factory=uuid.uuid4, primary_key=True)
|
||||
name: str
|
||||
description: str | None = None
|
||||
client_id: uuid.UUID | None = Field(foreign_key="client.id", ondelete="CASCADE")
|
||||
client: Client | None = Relationship(back_populates="secrets")
|
||||
secret: str
|
||||
@ -92,6 +98,7 @@ class AuditLog(SQLModel, table=True):
|
||||
"""
|
||||
|
||||
id: uuid.UUID = Field(default_factory=uuid.uuid4, primary_key=True)
|
||||
subsystem: str | None = None
|
||||
object: str | None = None
|
||||
object_id: str | None = None
|
||||
operation: str
|
||||
@ -107,6 +114,7 @@ class AuditLog(SQLModel, table=True):
|
||||
nullable=False,
|
||||
)
|
||||
|
||||
|
||||
class APIClient(SQLModel, table=True):
|
||||
"""Stores API Keys."""
|
||||
|
||||
@ -120,6 +128,8 @@ class APIClient(SQLModel, table=True):
|
||||
nullable=False,
|
||||
)
|
||||
|
||||
|
||||
def init_db(engine: sa.Engine) -> None:
|
||||
"""Create database."""
|
||||
LOG.info("Starting init_db")
|
||||
SQLModel.metadata.create_all(engine)
|
||||
|
||||
Reference in New Issue
Block a user