Skip to content

Commit

Permalink
WIP: add statique create / bulk endpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
jmaupetit committed Apr 9, 2024
1 parent 6a8d604 commit 2713899
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion src/api/qualicharge/api/v1/routers/statique.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
import logging
from typing import List

from fastapi import APIRouter
from fastapi import APIRouter, status
from fastapi.responses import JSONResponse

from qualicharge.factories.static import StatiqueFactory
from qualicharge.models.static import Statique
Expand All @@ -29,3 +30,26 @@ async def list() -> List[Statique]:
id_station_itinerance=id_station_itinerance,
id_pdc_itinerance=id_pdc_itinerance,
)


@router.post("/")
async def create(statique: Statique) -> None:
"""Create a statique entry."""
return JSONResponse(
status_code=status.HTTP_201_CREATED,
content={"message": f"statique entry {statique.id_pdc_itinerance} created"},
)


@router.post("/bulk")
async def bulk(statiques: List[Statique]) -> None:
"""Create a set of statique entries."""
entries = [statique.id_pdc_itinerance for statique in statiques]
return JSONResponse(
status_code=status.HTTP_201_CREATED,
content={
"message": "statique entries created",
"entries": entries,
"size": len(entries),
},
)

0 comments on commit 2713899

Please sign in to comment.