60 lines
1.3 KiB
Python
60 lines
1.3 KiB
Python
"""Schemas for Forgejo issue operations."""
|
|
|
|
from __future__ import annotations
|
|
|
|
from datetime import datetime
|
|
from typing import Any
|
|
from uuid import UUID
|
|
|
|
from sqlmodel import SQLModel
|
|
|
|
|
|
class ForgejoIssueBase(SQLModel):
|
|
"""Shared issue fields used across create/read payloads."""
|
|
|
|
forgejo_issue_number: int
|
|
title: str
|
|
body_preview: str | None = None
|
|
state: str
|
|
is_pull_request: bool
|
|
labels: list[dict[str, Any]] = []
|
|
assignees: list[dict[str, Any]] = []
|
|
author: str
|
|
html_url: str
|
|
forgejo_created_at: datetime
|
|
forgejo_updated_at: datetime
|
|
forgejo_closed_at: datetime | None = None
|
|
|
|
|
|
class ForgejoIssueCreate(ForgejoIssueBase):
|
|
"""Payload for creating a Forgejo issue record."""
|
|
|
|
|
|
class ForgejoIssueRead(ForgejoIssueBase):
|
|
"""Issue payload returned from read endpoints."""
|
|
|
|
id: UUID
|
|
organization_id: UUID
|
|
repository_id: UUID
|
|
created_at: datetime
|
|
updated_at: datetime
|
|
|
|
|
|
class ForgejoIssueListResponse(SQLModel):
|
|
"""Paginated list response for issues."""
|
|
|
|
items: list[ForgejoIssueRead]
|
|
total: int
|
|
page: int
|
|
limit: int
|
|
|
|
|
|
class ForgejoIssueUpsertResponse(SQLModel):
|
|
"""Response for issue sync operations."""
|
|
|
|
created: int = 0
|
|
updated: int = 0
|
|
open: int = 0
|
|
closed: int = 0
|
|
total: int = 0
|