1515
1616from .auth import UserInDB , get_current_active_user
1717
18- router = APIRouter ()
18+ read_router = APIRouter ()
19+ write_router = APIRouter ()
1920
2021repository = EntityRepository [orm .Computer , orm .Computer .Model ](orm .Computer )
2122
2223
23- @router .get ('/computers/schema' )
24+ @read_router .get ('/computers/schema' )
2425async def get_computers_schema (
2526 which : t .Literal ['get' , 'post' ] = Query (
2627 'get' ,
@@ -39,7 +40,7 @@ async def get_computers_schema(
3940 raise HTTPException (status_code = 422 , detail = str (err )) from err
4041
4142
42- @router .get ('/computers/projectable_properties' , response_model = list [str ])
43+ @read_router .get ('/computers/projectable_properties' , response_model = list [str ])
4344async def get_computer_projectable_properties () -> list [str ]:
4445 """Get projectable properties for AiiDA computers.
4546
@@ -48,7 +49,7 @@ async def get_computer_projectable_properties() -> list[str]:
4849 return repository .get_projectable_properties ()
4950
5051
51- @router .get (
52+ @read_router .get (
5253 '/computers' ,
5354 response_model = PaginatedResults [orm .Computer .Model ],
5455 response_model_exclude_none = True ,
@@ -66,7 +67,7 @@ async def get_computers(
6667 return repository .get_entities (queries )
6768
6869
69- @router .get (
70+ @read_router .get (
7071 '/computers/{computer_id}' ,
7172 response_model = orm .Computer .Model ,
7273 response_model_exclude_none = True ,
@@ -86,7 +87,7 @@ async def get_computer(computer_id: int) -> orm.Computer.Model:
8687 raise HTTPException (status_code = 404 , detail = f'Could not find a Computer with id { computer_id } ' )
8788
8889
89- @router .get ('/computers/{computer_id}/metadata' , response_model = dict [str , t .Any ])
90+ @read_router .get ('/computers/{computer_id}/metadata' , response_model = dict [str , t .Any ])
9091@with_dbenv ()
9192async def get_computer_metadata (computer_id : int ) -> dict [str , t .Any ]:
9293 """Get metadata of an AiiDA computer by id.
@@ -102,7 +103,7 @@ async def get_computer_metadata(computer_id: int) -> dict[str, t.Any]:
102103 raise HTTPException (status_code = 404 , detail = f'Could not find a Computer with id { computer_id } ' )
103104
104105
105- @router .post (
106+ @write_router .post (
106107 '/computers' ,
107108 response_model = orm .Computer .Model ,
108109 response_model_exclude_none = True ,
0 commit comments