Download app/routers/schema.py from petermutwiri/analytics-engine: direct link, hf CLI and curl.
- Browser
- Download file 860 Bytes
-
https://huggingface.co/spaces/petermutwiri/analytics-engine/resolve/main/app/routers/schema.py
- Command line
-
hf download hf://spaces/petermutwiri/analytics-engine/app/routers/schema.py
-
curl -L -o schema.py https://huggingface.co/spaces/petermutwiri/analytics-engine/resolve/main/app/routers/schema.py
860 Bytes
| # app/routers/schema.py | |
| from fastapi import APIRouter, Depends, Query | |
| from app.deps import verify_api_key | |
| from typing import Dict | |
| from app.schemas.org_schema import OrgSchema | |
| router = APIRouter(prefix="/api/v1/schema", tags=["schema"]) | |
| async def discover_schema( | |
| org_id: str = Query(..., description="Organization ID"), | |
| api_key: str = Depends(verify_api_key), | |
| ): | |
| """Return column mappings for this org""" | |
| schema = OrgSchema(org_id) | |
| return schema.get_mapping() | |
| async def override_schema( | |
| mapping: Dict[str, str], | |
| org_id: str = Query(..., description="Organization ID"), | |
| api_key: str = Depends(verify_api_key), | |
| ): | |
| """Allow manual column mapping override""" | |
| schema = OrgSchema(org_id) | |
| schema.save_mapping(mapping) | |
| return {"status": "saved", "mapping": mapping} |