From 89b7486e36273859eb00a99b47c9c54028907a3b Mon Sep 17 00:00:00 2001 From: Backend IM Bot Date: Thu, 17 Apr 2025 16:23:47 +0000 Subject: [PATCH] feat: Add 4 endpoints via editor --- endpoints/names.post.py | 20 ++++++++++++++++++++ endpoints/names/{name_id}.delete.py | 15 +++++++++++++++ endpoints/names/{name_id}.get.py | 18 ++++++++++++++++++ endpoints/names/{name_id}.put.py | 22 ++++++++++++++++++++++ 4 files changed, 75 insertions(+) create mode 100644 endpoints/names.post.py create mode 100644 endpoints/names/{name_id}.delete.py create mode 100644 endpoints/names/{name_id}.get.py create mode 100644 endpoints/names/{name_id}.put.py diff --git a/endpoints/names.post.py b/endpoints/names.post.py new file mode 100644 index 0000000..94c7a33 --- /dev/null +++ b/endpoints/names.post.py @@ -0,0 +1,20 @@ + +from fastapi import APIRouter, Depends, status, HTTPException +# TODO: Import db session, schemas, models as needed +# from pydantic import BaseModel # Example + +router = APIRouter() + +# TODO: Define request body schema if needed +# class name_Create(BaseModel): +# name: str # Example field + +@router.post("/names", status_code=status.HTTP_201_CREATED) +async def create_name( + # item: name_Create, # Example request body + # db: Session = Depends(get_db) # Example dependency +): + """first rest: Create new item""" + # TODO: Implement logic to create a new name + print(f"Creating new name") # with data: {item.dict()}") + return {"message": "name created successfully"} # Placeholder diff --git a/endpoints/names/{name_id}.delete.py b/endpoints/names/{name_id}.delete.py new file mode 100644 index 0000000..f4e114f --- /dev/null +++ b/endpoints/names/{name_id}.delete.py @@ -0,0 +1,15 @@ + +from fastapi import APIRouter, Depends, HTTPException, status + +router = APIRouter() + +@router.delete("/names/{name_id}", status_code=status.HTTP_204_NO_CONTENT) +async def delete_name_item( + name_id: Any, # TODO: Adjust type hint + # db: Session = Depends(get_db) # Example dependency +): + """first rest: Delete item by ID""" + # TODO: Implement logic to delete name with id: {name_id} + print(f"Deleting name with id: {name_id}") + # Example: Check if found, perform deletion, raise 404 if not + return None # Return No Content on success diff --git a/endpoints/names/{name_id}.get.py b/endpoints/names/{name_id}.get.py new file mode 100644 index 0000000..dcad3d1 --- /dev/null +++ b/endpoints/names/{name_id}.get.py @@ -0,0 +1,18 @@ + +from fastapi import APIRouter, Depends, HTTPException, status +# TODO: Import db session, schemas, models as needed + +router = APIRouter() + +@router.get("/names/{name_id}") +async def get_name_item( + name_id: Any, # TODO: Adjust type hint (e.g., int, str, UUID) + # db: Session = Depends(get_db) # Example dependency +): + """first rest: Get item by ID""" + # TODO: Implement logic to fetch name with id: {name_id} + print(f"Fetching name with id: {name_id}") + # Example: Check if found, raise 404 if not + # if not found: + # raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail="name not found") + return {"name_id": name_id} # Placeholder diff --git a/endpoints/names/{name_id}.put.py b/endpoints/names/{name_id}.put.py new file mode 100644 index 0000000..76c3fdb --- /dev/null +++ b/endpoints/names/{name_id}.put.py @@ -0,0 +1,22 @@ + +from fastapi import APIRouter, Depends, HTTPException, status +# TODO: Import db session, schemas, models as needed +# from pydantic import BaseModel # Example + +router = APIRouter() + +# TODO: Define request body schema if needed +# class name_Update(BaseModel): +# name: str # Example field + +@router.put("/names/{name_id}") +async def update_name_item( + name_id: Any, # TODO: Adjust type hint + # item: name_Update, # Example request body + # db: Session = Depends(get_db) # Example dependency +): + """first rest: Update item by ID""" + # TODO: Implement logic to update name with id: {name_id} + print(f"Updating name with id: {name_id}") # with data: {item.dict()}") + # Example: Check if found, raise 404 if not + return {"message": "name updated successfully"} # Placeholder