Skip to content

Commit 94e5993

Browse files
committed
Retrieve school list.
1 parent 217ac95 commit 94e5993

File tree

2 files changed

+50
-0
lines changed

2 files changed

+50
-0
lines changed

usr/lib/python3/dist-packages/linuxmusterApi/main.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@
6969
roles,
7070
samba,
7171
schoolclasses,
72+
schools,
7273
sessions,
7374
teachers,
7475
users,
@@ -105,6 +106,7 @@ def home():
105106
"""
106107

107108
app.include_router(auth.router, prefix="/v1")
109+
app.include_router(schools.router, prefix="/v1")
108110
app.include_router(roles.router, prefix="/v1")
109111
app.include_router(users.router, prefix="/v1")
110112
app.include_router(teachers.router, prefix="/v1")
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
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

Comments
 (0)