104 lines
1.7 KiB
Python
104 lines
1.7 KiB
Python
from typing import Optional
|
|
|
|
from schemas.attribute import ModuleAttributeSchema
|
|
from schemas.base import BaseSchema, BaseResponse
|
|
|
|
|
|
# region Entity
|
|
|
|
|
|
class ModuleTabSchema(BaseSchema):
|
|
id: int
|
|
key: str
|
|
label: str
|
|
icon_name: Optional[str]
|
|
device: str
|
|
|
|
|
|
class ModuleSchema(BaseSchema):
|
|
id: int
|
|
key: str
|
|
label: str
|
|
description: Optional[str]
|
|
is_built_in: bool
|
|
depends_on: list["ModuleSchema"]
|
|
tabs: list[ModuleTabSchema]
|
|
|
|
|
|
class ModuleWithAttributesSchema(ModuleSchema):
|
|
attributes: list[ModuleAttributeSchema]
|
|
|
|
|
|
class CreateModuleSchema(BaseSchema):
|
|
label: str
|
|
description: Optional[str]
|
|
|
|
|
|
class UpdateModuleCommonInfoSchema(BaseSchema):
|
|
label: str
|
|
description: Optional[str]
|
|
|
|
|
|
# endregion
|
|
|
|
|
|
# region Requests
|
|
|
|
|
|
class AddAttributeRequest(BaseSchema):
|
|
attribute_id: int
|
|
module_id: int
|
|
|
|
|
|
class DeleteAttributeRequest(BaseSchema):
|
|
attribute_id: int
|
|
module_id: int
|
|
|
|
|
|
class CreateModuleRequest(BaseSchema):
|
|
entity: CreateModuleSchema
|
|
|
|
|
|
class UpdateModuleCommonInfoRequest(BaseSchema):
|
|
entity: UpdateModuleCommonInfoSchema
|
|
|
|
|
|
# endregion
|
|
|
|
# region Response
|
|
|
|
|
|
class GetAllModulesResponse(BaseSchema):
|
|
items: list[ModuleSchema]
|
|
|
|
|
|
class GetAllWithAttributesResponse(BaseSchema):
|
|
items: list[ModuleWithAttributesSchema]
|
|
|
|
|
|
class GetByIdWithAttributesResponse(BaseSchema):
|
|
entity: ModuleWithAttributesSchema
|
|
|
|
|
|
class CreateModuleResponse(BaseResponse):
|
|
pass
|
|
|
|
|
|
class UpdateModuleCommonInfoResponse(BaseResponse):
|
|
pass
|
|
|
|
|
|
class DeleteModuleResponse(BaseResponse):
|
|
pass
|
|
|
|
|
|
class AddAttributeResponse(BaseResponse):
|
|
pass
|
|
|
|
|
|
class DeleteAttributeResponse(BaseResponse):
|
|
pass
|
|
|
|
|
|
# endregion
|