Skip to content

Commit

Permalink
adds basic metadata and example barcode
Browse files Browse the repository at this point in the history
  • Loading branch information
niquerio committed Oct 7, 2024
1 parent 2dd7009 commit 42329c7
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 3 deletions.
7 changes: 6 additions & 1 deletion aim/digifeeds/database/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,12 @@
engine = create_engine(S.mysql_database)

SessionLocal = sessionmaker(autocommit=False, autoflush=False, bind=engine)
app = FastAPI()

description = """
The Digifeeds API enables tracking of images sent to HathiTrust and Google
through the digifeeds workflow
"""
app = FastAPI(title="Digifeeds", description=description)


# Dependency
Expand Down
24 changes: 22 additions & 2 deletions aim/digifeeds/database/schemas.py
Original file line number Diff line number Diff line change
@@ -1,30 +1,50 @@
from pydantic import BaseModel, Field, ConfigDict
from datetime import datetime


class ItemStatus(BaseModel):
name: str = Field(alias="status_name")
description: str = Field(alias="status_description")
created_at: datetime

model_config = ConfigDict(populate_by_name=True, from_attributes=True)


class ItemBase(BaseModel):
model_config = ConfigDict(populate_by_name=True, from_attributes=True)

barcode: str = Field(alias="item_barcode")


class Item(ItemBase):
created_at: datetime
statuses: list[ItemStatus] = []
model_config = ConfigDict(
json_schema_extra={
"examples": [
{
"barcode": "39015040218748",
"created_at": "2024-09-25T17:12:39",
"statuses": [
{
"name": "in_zephir",
"description": "Item is in zephir",
"created_at": "2024-09-25T17:13:28",
}
],
}
]
}
)


class ItemCreate(ItemBase):
pass


class StatusBase(BaseModel):
name: str


class Status(StatusBase):
description: str


0 comments on commit 42329c7

Please sign in to comment.