"""Resources MVP API endpoints. Job ID: MTAD-IMPL-2025-11-18-CL""" from fastapi import APIRouter, Depends, HTTPException, status from sqlalchemy.orm import Session from app.database import get_db from app.models import Resource router = APIRouter() @router.get("/") async def list_resources(access_tier: str = "public", skip: int = 0, limit: int = 20, db: Session = Depends(get_db)): """List resources by access tier.""" resources = db.query(Resource).filter(Resource.access_tier == access_tier).offset(skip).limit(limit).all() return {"items": resources} @router.get("/{resource_id}") async def get_resource(resource_id: str, db: Session = Depends(get_db)): """Get a specific resource.""" resource = db.query(Resource).filter(Resource.id == resource_id).first() if not resource: raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail="Resource not found") return resource @router.get("/slug/{slug}") async def get_resource_by_slug(slug: str, db: Session = Depends(get_db)): """Get resource by slug.""" resource = db.query(Resource).filter(Resource.slug == slug).first() if not resource: raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail="Resource not found") return resource @router.post("/") async def create_resource(title: str, slug: str, content: str, db: Session = Depends(get_db)): """Create resource (admin or authorized user).""" return {"message": "Resource creation not yet implemented"}