Model/backend/app/plan/router.py
2023-07-17 10:06:35 +01:00

29 lines
915 B
Python

from fastapi import APIRouter, Depends
from app.dependencies import validate_token
from app.plan.schemas import PlanTriggerRequest
from app.utils import read_csv_from_s3
from app.config import get_settings
router = APIRouter(
prefix="/plan",
tags=["plan"],
dependencies=[Depends(validate_token)],
responses={404: {"description": "Not found"}}
)
@router.post("/trigger")
async def trigger_plan(body: PlanTriggerRequest):
print("Getting the inputs")
# Read in the trigger file from s3
bucket_name = get_settings().PLAN_TRIGGER_BUCKET
print("bucket_name: ", bucket_name)
print("body.trigger_file_path: ", body.trigger_file_path)
plan_input = read_csv_from_s3(bucket_name=bucket_name, filepath=body.trigger_file_path)
print("Got the inputs")
print(plan_input)
# TODO: Parse the file
# TODO: Put messages on the queue
return {"message": "Plan triggered"}