Coverage for apps/kwai-api/src/kwai_api/v1/pages/schemas.py: 100%
18 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 for defining the page JSON:API resource."""
3from kwai_core.json_api import (
4 Meta,
5 Relationship,
6 ResourceMeta,
7)
8from pydantic import BaseModel, Field
10from kwai_api.schemas.resources import (
11 ApplicationResourceIdentifier,
12 PageResourceIdentifier,
13)
16class PageApplicationAttributes(BaseModel):
17 """Attributes of a page application JSON:API resource."""
19 name: str
20 title: str
23class PageApplicationResource(ApplicationResourceIdentifier):
24 """A JSON:API resource for a page application."""
26 attributes: PageApplicationAttributes
29class PageApplicationDocument(BaseModel):
30 """A JSON:API document for a page application."""
32 data: PageApplicationResource
35class BasePageText(BaseModel):
36 """Basic schema for the text of a page."""
38 locale: str
39 title: str
40 summary: str
41 content: str | None
44class PageText(BasePageText):
45 """Schema for the text of a page."""
47 format: str
48 original_summary: str
49 original_content: str | None
52class BasePageAttributes(BaseModel):
53 """Basic attributes of a JSON:API page resource."""
55 priority: int
56 texts: list[PageText]
59class PageAttributes(BasePageAttributes):
60 """Attributes of a page JSON:API resource."""
62 enabled: bool
63 remark: str
66class PageRelationships(BaseModel):
67 """Relationships of a page JSON:API resource."""
69 application: Relationship[ApplicationResourceIdentifier]
72class PageResource(PageResourceIdentifier):
73 """A JSON:API resource for a page."""
75 meta: ResourceMeta | None = None
76 attributes: PageAttributes
77 relationships: PageRelationships
80class PageDocument(BaseModel):
81 """A JSON:API document for one page."""
83 data: PageResource
84 included: set[PageApplicationResource] = Field(default_factory=set)
87class PagesDocument(BaseModel):
88 """A JSON:API document for multiple pages."""
90 meta: Meta
91 data: list[PageResource] = Field(default_factory=list)
92 included: set[PageApplicationResource] = Field(default_factory=set)