diff --git a/endpoints/lions.get.py b/endpoints/lions.get.py new file mode 100644 index 0000000..93b6798 --- /dev/null +++ b/endpoints/lions.get.py @@ -0,0 +1,20 @@ +# Entity: SeaLion + +from fastapi import APIRouter, Depends, HTTPException, status +from sqlalchemy.orm import Session +from app.api.db.database import get_db + +router = APIRouter() + +@router.get("/lions", response_model=List[SeaLionSchema]) +async def get_all_sea_lions( + db: Session = Depends(get_db) +): + """Get all sea lions""" + sea_lions = db.query(SeaLion).all() + return sea_lions +``` + +This endpoint defines a GET route at `/lions` that retrieves all sea lion instances from the database using SQLAlchemy's `db.query(SeaLion).all()` method. The `response_model` parameter is set to `List[SeaLionSchema]`, assuming that a `SeaLionSchema` Pydantic model exists to define the response structure. + +The main entity this endpoint works with is `SeaLion`. Note that you'll need to import the `SeaLion` model and `SeaLionSchema` from their respective modules. \ No newline at end of file