|
| 1 | +from fastapi import APIRouter, Depends, HTTPException, Request |
| 2 | + |
| 3 | +from security import RoleChecker, AuthenticatedUser |
| 4 | +from linuxmusterTools.ldapconnector import LMNLdapReader as lr |
| 5 | + |
| 6 | + |
| 7 | +router = APIRouter( |
| 8 | + prefix="/schools", |
| 9 | + tags=["Schools"], |
| 10 | + responses={404: {"description": "Not found"}}, |
| 11 | +) |
| 12 | + |
| 13 | +@router.get("/", name="List all schools") |
| 14 | +def get_all_schools(who: AuthenticatedUser = Depends(RoleChecker("G"))): |
| 15 | + """ |
| 16 | + ## List all schools. |
| 17 | +
|
| 18 | + ### Access |
| 19 | + - global-administrators |
| 20 | +
|
| 21 | + \f |
| 22 | + :param who: User requesting the data, read from API Token |
| 23 | + :type who: AuthenticatedUser |
| 24 | + :return: List of all schools (dict) |
| 25 | + :rtype: list |
| 26 | + """ |
| 27 | + |
| 28 | + |
| 29 | + return lr.get('/schools') |
| 30 | + |
| 31 | +@router.get("/{school}", name="Retrieve informations from a specific school") |
| 32 | +def get_all_schools(school: str, who: AuthenticatedUser = Depends(RoleChecker("G"))): |
| 33 | + """ |
| 34 | + ## Retrieve informations (projects, teachers, students, groups, etc ...) |
| 35 | + from a specific school. TODO ! NOT WORKING YET. |
| 36 | +
|
| 37 | + ### Access |
| 38 | + - global-administrators |
| 39 | +
|
| 40 | + \f |
| 41 | + :param who: User requesting the data, read from API Token |
| 42 | + :type who: AuthenticatedUser |
| 43 | + :return: List of all schools (dict) |
| 44 | + :rtype: list |
| 45 | + """ |
| 46 | + |
| 47 | + |
| 48 | + return lr.get(f'/schools/{school}') |
0 commit comments