Coverage for packages/clopos/src/integrify/clopos/schemas/common/response.py: 100%
35 statements
« prev ^ index » next coverage.py v7.16.0, created at 2026-10-19 02:39 +0000
« prev ^ index » next coverage.py v7.16.0, created at 2026-10-19 02:39 +0000
1from typing import Generic, Literal, TypeVar
3from integrify.utils import UnsetField
4from pydantic import BaseModel
6_ObjectTypeT = TypeVar('_ObjectTypeT', bound=BaseModel)
9class BaseResponse(BaseModel):
10 success: Literal[True]
11 """Success status of the request"""
13 message: UnsetField[str]
14 """Success message"""
16 time: int
17 """Response time (ms)"""
19 timestamp: str
20 """ISO 8601 date"""
22 unix: int
23 """Unix timestamp of the response"""
26class PaginatedResponse(BaseResponse):
27 total: UnsetField[int]
28 """Number of items returned"""
30 sorts: UnsetField[list[str]]
31 """List of sortable fields"""
34class ObjectResponse(BaseResponse, Generic[_ObjectTypeT]):
35 data: _ObjectTypeT
36 """Object returned"""
39class ObjectListResponse(PaginatedResponse, Generic[_ObjectTypeT]):
40 data: list[_ObjectTypeT]
43class Errors(BaseModel):
44 message: str | None = None
45 type: str | None = None
46 exception: str | None = None
47 code: int | None = None
48 http_code: int | None = None
51class ErrorResponse(BaseModel):
52 success: Literal[False]
53 error: list[Errors] = []
54 message: str | None = None