2026-05-25 09:05:17 +01:00
|
|
|
"""
|
2026-05-28 14:41:11 +01:00
|
|
|
Pydantic models for service module
|
2026-05-25 09:05:17 +01:00
|
|
|
|
2026-05-28 14:41:11 +01:00
|
|
|
Models follow the nomenclature of:
|
|
|
|
|
- Sub-models: "<Resource><Opt:>Schema"
|
|
|
|
|
- Mixins: "<Attribute>Mixin"
|
|
|
|
|
- Models: "<Module><Method><Resource><Opt:Resource><Direction>" ie "ServiceGetServiceResponse"
|
2026-05-26 10:16:59 +01:00
|
|
|
"""
|
2026-06-08 15:31:37 +01:00
|
|
|
|
2026-06-02 15:36:05 +01:00
|
|
|
from pydantic import ConfigDict, Field
|
2026-05-26 10:16:59 +01:00
|
|
|
|
|
|
|
|
from src.schemas import CustomBaseModel
|
|
|
|
|
|
2026-06-08 15:31:37 +01:00
|
|
|
|
2026-05-27 13:43:06 +01:00
|
|
|
class ServiceIDMixin(CustomBaseModel):
|
2026-06-02 15:36:05 +01:00
|
|
|
service_id: int = Field(gt=0)
|
2026-05-27 13:43:06 +01:00
|
|
|
|
2026-06-08 15:31:37 +01:00
|
|
|
|
2026-05-28 14:27:14 +01:00
|
|
|
class ServiceSchema(CustomBaseModel):
|
2026-05-26 10:16:59 +01:00
|
|
|
model_config = ConfigDict(from_attributes=True, extra="ignore")
|
2026-05-27 12:21:03 +01:00
|
|
|
|
2026-05-26 10:16:59 +01:00
|
|
|
id: int
|
|
|
|
|
name: str
|
|
|
|
|
|
2026-06-08 15:31:37 +01:00
|
|
|
|
2026-05-28 14:27:14 +01:00
|
|
|
class ServiceWithKeySchema(ServiceSchema):
|
2026-05-26 10:16:59 +01:00
|
|
|
api_key: str
|
|
|
|
|
|
2026-06-08 15:31:37 +01:00
|
|
|
|
2026-05-26 10:16:59 +01:00
|
|
|
class ServiceGetServiceResponse(CustomBaseModel):
|
2026-05-28 14:27:14 +01:00
|
|
|
services: list[ServiceSchema]
|
2026-05-26 10:16:59 +01:00
|
|
|
|
2026-06-08 15:31:37 +01:00
|
|
|
|
2026-05-26 10:16:59 +01:00
|
|
|
class ServicePostServiceRequest(CustomBaseModel):
|
|
|
|
|
name: str
|
|
|
|
|
|
2026-06-08 15:31:37 +01:00
|
|
|
|
2026-05-26 10:16:59 +01:00
|
|
|
class ServicePostServiceResponse(CustomBaseModel):
|
2026-05-28 14:27:14 +01:00
|
|
|
service: ServiceWithKeySchema
|
2026-05-26 10:16:59 +01:00
|
|
|
|
2026-06-08 15:31:37 +01:00
|
|
|
|
2026-05-27 13:43:06 +01:00
|
|
|
class ServicePatchKeyRequest(ServiceIDMixin):
|
|
|
|
|
pass
|
|
|
|
|
|
2026-06-08 15:31:37 +01:00
|
|
|
|
2026-05-26 10:16:59 +01:00
|
|
|
class ServicePatchKeyResponse(CustomBaseModel):
|
2026-05-28 14:27:14 +01:00
|
|
|
service: ServiceWithKeySchema
|