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
17class CoachResource(CoachResourceIdentifier):
18 """A JSON:API resource for a coach."""
20 attributes: CoachAttributes
23class CoachDocument(BaseModel):
24 """A JSON:API document for one coaches."""
26 data: CoachResource
29class CoachesDocument(BaseModel):
30 """A JSON:API document for multiple coaches."""
32 meta: Meta
33 data: list[CoachResource] = Field(default_factory=list)
36class TrainingCoachResourceIdentifier(ResourceIdentifier):
37 """A JSON:API resource identifier for a training coach."""
39 type: Literal["training_coaches"] = "training_coaches"
42class TrainingCoachAttributes(BaseModel):
43 """Base attributes for a training coach JSON:API resource."""
45 payed: bool
46 head: bool
47 present: bool
48 remark: str
51class TrainingCoachRelationships(BaseModel):
52 """Relationships of a training coach JSON:API resource."""
54 coach: Relationship[CoachResourceIdentifier]
57class TrainingCoachResource(TrainingCoachResourceIdentifier):
58 """Resource for a training coach JSON:API resource."""
60 attributes: TrainingCoachAttributes
61 relationships: TrainingCoachRelationships
64class TrainingCoachDocument(BaseModel):
65 """Document for a coach of a training."""
67 data: TrainingCoachResource
68 included: set[CoachResource] = Field(default_factory=set)
71class TrainingCoachesDocument(BaseModel):
72 """Document for multiple training coaches."""
74 meta: Meta
75 data: list[TrainingCoachResource] = Field(default_factory=list)
76 included: set[CoachResource] = Field(default_factory=set)