Coverage for apps/kwai-api/src/kwai_api/v1/club/coaches/schemas.py: 100%
23 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 JSON:API schemas for the coaches endpoints."""
3from kwai_core.json_api import Meta, Relationship, ResourceMeta
4from pydantic import BaseModel, Field
6from kwai_api.v1.club.schemas.resources import (
7 CoachResourceIdentifier,
8 MemberResourceIdentifier,
9 UserResourceIdentifier,
10)
13class PublicCoachAttributes(BaseModel):
14 """Public attributes for the coach JSON:API resource."""
16 name: str
17 description: str
18 diploma: str
21class PublicCoachResource(CoachResourceIdentifier):
22 """A public JSON:API resource identifier for a coach."""
24 meta: ResourceMeta | None = None
25 attributes: PublicCoachAttributes
28class PublicCoachDocument(BaseModel):
29 """A public JSON:API document for a coach."""
31 data: PublicCoachResource
34class PublicCoachesDocument(BaseModel):
35 """A public JSON:API document for multiple coaches."""
37 meta: Meta
38 data: list[PublicCoachResource] = Field(default_factory=list)
41class CoachAttributes(PublicCoachAttributes):
42 """All attributes for the coach JSON:API resource."""
44 remark: str
45 active: bool
46 license: str | None = None
47 license_end_date: str | None = None
48 birthdate: str | None = None
51class CoachRelationships(BaseModel):
52 """Relationships for the coach JSON:API resource."""
54 user: Relationship[UserResourceIdentifier]
55 member: Relationship[MemberResourceIdentifier]
58class CoachResource(PublicCoachResource):
59 """A JSON:API resource for a coach."""
61 attributes: CoachAttributes
62 relationships: CoachRelationships | None = None
65class UserAttributes(BaseModel):
66 """Attributes for the user JSON:API resource."""
68 uuid: str
71class UserResource(UserResourceIdentifier):
72 """A JSON:API resource for a user."""
74 attributes: UserAttributes
77class CoachDocument(BaseModel):
78 """A JSON:API document for a coach."""
80 data: CoachResource
81 included: set[UserResource] = Field(default_factory=set)
84class CoachesDocument(BaseModel):
85 """A JSON:API document for multiple coaches."""
87 meta: Meta
88 data: list[CoachResource] = Field(default_factory=list)
89 included: set[UserResource] = Field(default_factory=set)