Coverage for apps/kwai-api/src/kwai_api/v1/trainings/coaches/schemas.py: 100%
19 statements
« prev ^ index » next coverage.py v7.11.0, created at 2024-01-01 00:00 +0000
« prev ^ index » next coverage.py v7.11.0, created at 2024-01-01 00:00 +0000
1"""Module that defines the JSON:API schemas for coaches."""
3from typing import Literal
5from kwai_core.json_api import Meta, Relationship, ResourceIdentifier
6from pydantic import BaseModel, Field
8from kwai_api.schemas.resources import CoachResourceIdentifier
11class CoachAttributes(BaseModel):
12 """Attributes for a coach JSON:API resource."""
14 name: str
15 head: bool
18class CoachResource(CoachResourceIdentifier):
19 """A JSON:API resource for a coach."""
21 attributes: CoachAttributes
24class CoachDocument(BaseModel):
25 """A JSON:API document for one coaches."""
27 data: CoachResource
30class CoachesDocument(BaseModel):
31 """A JSON:API document for multiple coaches."""
33 meta: Meta
34 data: list[CoachResource] = Field(default_factory=list)
37class TrainingCoachResourceIdentifier(ResourceIdentifier):
38 """A JSON:API resource identifier for a training coach."""
40 type: Literal["training_coaches"] = "training_coaches"
43class TrainingCoachAttributes(BaseModel):
44 """Base attributes for a training coach JSON:API resource."""
46 payed: bool
47 head: bool
48 present: bool
49 remark: str
52class TrainingCoachRelationships(BaseModel):
53 """Relationships of a training coach JSON:API resource."""
55 coach: Relationship[CoachResourceIdentifier]
58class TrainingCoachResource(TrainingCoachResourceIdentifier):
59 """Resource for a training coach JSON:API resource."""
61 attributes: TrainingCoachAttributes
62 relationships: TrainingCoachRelationships
65class TrainingCoachDocument(BaseModel):
66 """Document for a coach of a training."""
68 data: TrainingCoachResource
69 included: set[CoachResource] = Field(default_factory=set)
72class TrainingCoachesDocument(BaseModel):
73 """Document for multiple training coaches."""
75 meta: Meta
76 data: list[TrainingCoachResource] = Field(default_factory=list)
77 included: set[CoachResource] = Field(default_factory=set)