47 lines
950 B
Python
47 lines
950 B
Python
from datetime import datetime
|
|
|
|
from pydantic import BaseModel, Field, field_validator
|
|
|
|
|
|
class ParentBlobBase(BaseModel):
|
|
iv: str = Field(min_length=1)
|
|
ciphertext: str = Field(min_length=1)
|
|
|
|
|
|
class ParentCreateRequest(ParentBlobBase):
|
|
pass
|
|
|
|
|
|
class ParentUpdateRequest(ParentBlobBase):
|
|
pass
|
|
|
|
|
|
class ChildCreateRequest(ParentBlobBase):
|
|
parentId: str = Field(min_length=1)
|
|
|
|
@field_validator("parentId")
|
|
@classmethod
|
|
def strip_parent_id(cls, value: str) -> str:
|
|
normalized = value.strip()
|
|
if not normalized:
|
|
raise ValueError("parentId cannot be empty")
|
|
return normalized
|
|
|
|
|
|
class ChildUpdateRequest(ParentBlobBase):
|
|
pass
|
|
|
|
|
|
class ParentRecordResponse(ParentBlobBase):
|
|
id: str
|
|
ownerId: str
|
|
createdAt: datetime
|
|
updatedAt: datetime
|
|
|
|
|
|
class ChildRecordResponse(ParentBlobBase):
|
|
id: str
|
|
parentId: str
|
|
ownerId: str
|
|
createdAt: datetime
|
|
updatedAt: datetime
|