cloud-api/src/service/schemas.py

42 lines
994 B
Python
Raw Normal View History

"""
2026-05-28 14:41:11 +01:00
Pydantic models for service module
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
"""
from pydantic import ConfigDict, Field
2026-05-26 10:16:59 +01:00
from src.schemas import CustomBaseModel
2026-05-27 13:43:06 +01:00
class ServiceIDMixin(CustomBaseModel):
service_id: int = Field(gt=0)
2026-05-27 13:43:06 +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-26 10:16:59 +01:00
id: int
name: str
2026-05-28 14:27:14 +01:00
class ServiceWithKeySchema(ServiceSchema):
2026-05-26 10:16:59 +01:00
api_key: str
class ServiceGetServiceResponse(CustomBaseModel):
2026-05-28 14:27:14 +01:00
services: list[ServiceSchema]
2026-05-26 10:16:59 +01:00
class ServicePostServiceRequest(CustomBaseModel):
name: str
class ServicePostServiceResponse(CustomBaseModel):
2026-05-28 14:27:14 +01:00
service: ServiceWithKeySchema
2026-05-26 10:16:59 +01:00
2026-05-27 13:43:06 +01:00
class ServicePatchKeyRequest(ServiceIDMixin):
pass
2026-05-26 10:16:59 +01:00
class ServicePatchKeyResponse(CustomBaseModel):
2026-05-28 14:27:14 +01:00
service: ServiceWithKeySchema
2026-05-27 13:43:06 +01:00
class ServiceDeleteServiceRequest(ServiceIDMixin):
pass