67 lines
1.9 KiB
Python
67 lines
1.9 KiB
Python
|
|
import uuid
|
||
|
|
from datetime import date, datetime
|
||
|
|
|
||
|
|
from pydantic import BaseModel, ConfigDict
|
||
|
|
|
||
|
|
|
||
|
|
class InterfaceChangeCreate(BaseModel):
|
||
|
|
repo_slug: str
|
||
|
|
interface_type: str # rest_api | mcp_tool | cli | schema | capability
|
||
|
|
change_type: str # breaking | additive | deprecation | removal
|
||
|
|
title: str
|
||
|
|
description: str
|
||
|
|
affected_paths: list[str] = []
|
||
|
|
affected_repo_slugs: list[str] = []
|
||
|
|
planned_for: date | None = None
|
||
|
|
author: str = "custodian"
|
||
|
|
|
||
|
|
|
||
|
|
class InterfaceChangePatch(BaseModel):
|
||
|
|
title: str | None = None
|
||
|
|
description: str | None = None
|
||
|
|
affected_paths: list[str] | None = None
|
||
|
|
affected_repo_slugs: list[str] | None = None
|
||
|
|
planned_for: date | None = None
|
||
|
|
|
||
|
|
|
||
|
|
class InterfaceChangeRead(BaseModel):
|
||
|
|
model_config = ConfigDict(from_attributes=True)
|
||
|
|
|
||
|
|
id: uuid.UUID
|
||
|
|
repo_id: uuid.UUID
|
||
|
|
repo_slug: str
|
||
|
|
interface_type: str
|
||
|
|
change_type: str
|
||
|
|
title: str
|
||
|
|
description: str
|
||
|
|
affected_paths: list[str]
|
||
|
|
affected_repo_slugs: list[str]
|
||
|
|
status: str
|
||
|
|
planned_for: date | None
|
||
|
|
published_at: datetime | None
|
||
|
|
resolved_at: datetime | None
|
||
|
|
author: str
|
||
|
|
created_at: datetime
|
||
|
|
updated_at: datetime
|
||
|
|
|
||
|
|
@classmethod
|
||
|
|
def from_orm_with_slug(cls, obj) -> "InterfaceChangeRead":
|
||
|
|
return cls(
|
||
|
|
id=obj.id,
|
||
|
|
repo_id=obj.repo_id,
|
||
|
|
repo_slug=obj.repo.slug,
|
||
|
|
interface_type=obj.interface_type,
|
||
|
|
change_type=obj.change_type,
|
||
|
|
title=obj.title,
|
||
|
|
description=obj.description,
|
||
|
|
affected_paths=obj.affected_paths or [],
|
||
|
|
affected_repo_slugs=obj.affected_repo_slugs or [],
|
||
|
|
status=obj.status,
|
||
|
|
planned_for=obj.planned_for,
|
||
|
|
published_at=obj.published_at,
|
||
|
|
resolved_at=obj.resolved_at,
|
||
|
|
author=obj.author,
|
||
|
|
created_at=obj.created_at,
|
||
|
|
updated_at=obj.updated_at,
|
||
|
|
)
|