2222
2323from .auth import UserInDB , get_current_active_user
2424
25- read_router = APIRouter ()
26- write_router = APIRouter ()
25+ read_router = APIRouter (prefix = '/nodes' )
26+ write_router = APIRouter (prefix = '/nodes' )
2727
2828repository = NodeRepository [orm .Node , orm .Node .Model ](orm .Node )
2929
3737 NodeModelUnion = model_registry .ModelUnion
3838
3939
40- @read_router .get ('/nodes/schema' )
40+ @read_router .get (
41+ '/schema' ,
42+ response_model = dict ,
43+ )
4144async def get_nodes_schema (
4245 node_type : str | None = Query (
4346 None ,
@@ -69,7 +72,10 @@ async def get_nodes_schema(
6972 raise HTTPException (status_code = 500 , detail = str (exception )) from exception
7073
7174
72- @read_router .get ('/nodes/projectable_properties' )
75+ @read_router .get (
76+ '/projectable_properties' ,
77+ response_model = list [str ],
78+ )
7379@with_dbenv ()
7480async def get_node_projectable_properties (
7581 node_type : str | None = Query (
@@ -120,7 +126,10 @@ class NodeStatistics(pdt.BaseModel):
120126 )
121127
122128
123- @read_router .get ('/nodes/statistics' , response_model = NodeStatistics )
129+ @read_router .get (
130+ '/statistics' ,
131+ response_model = NodeStatistics ,
132+ )
124133@with_dbenv ()
125134async def get_nodes_statistics (user : int | None = None ) -> dict [str , t .Any ]:
126135 """Get node statistics.
@@ -149,7 +158,7 @@ async def get_nodes_statistics(user: int | None = None) -> dict[str, t.Any]:
149158 return backend .query ().get_creation_statistics (user_pk = user )
150159
151160
152- @read_router .get ('/nodes/ download_formats' )
161+ @read_router .get ('/download_formats' )
153162async def get_nodes_download_formats () -> dict [str , t .Any ]:
154163 """Get download formats for AiiDA nodes.
155164
@@ -166,7 +175,7 @@ async def get_nodes_download_formats() -> dict[str, t.Any]:
166175
167176
168177@read_router .get (
169- '/nodes ' ,
178+ '' ,
170179 response_model = PaginatedResults [orm .Node .Model ],
171180 response_model_exclude_none = True ,
172181 response_model_exclude_unset = True ,
@@ -193,7 +202,10 @@ class NodeType(pdt.BaseModel):
193202 node_schema : str = pdt .Field (description = 'The URL to access the schema of this node type.' )
194203
195204
196- @read_router .get ('/nodes/types' , response_model = list [NodeType ])
205+ @read_router .get (
206+ '/types' ,
207+ response_model = list [NodeType ],
208+ )
197209async def get_node_types () -> list :
198210 """Get all node types in machine-actionable format.
199211
@@ -203,9 +215,9 @@ async def get_node_types() -> list:
203215 >>> {
204216 >>> "label": "Int",
205217 >>> "node_type": "data.core.int.Int.",
206- >>> "nodes": "/nodes?filters={\" node_type\" :{\" data.core.int.Int.\" }}",
207- >>> "projections": "/nodes/projectable_properties?type=data.core.int.Int.",
208- >>> "node_schema": "/nodes/schema?type=data.core.int.Int.",
218+ >>> "nodes": "... /nodes?filters={\" node_type\" :{\" data.core.int.Int.\" }}",
219+ >>> "projections": "... /nodes/projectable_properties?type=data.core.int.Int.",
220+ >>> "node_schema": "... /nodes/schema?type=data.core.int.Int.",
209221 >>> },
210222 >>> ...
211223 >>> ]
@@ -226,7 +238,7 @@ async def get_node_types() -> list:
226238
227239
228240@read_router .get (
229- '/nodes/ {uuid}' ,
241+ '/{uuid}' ,
230242 response_model = orm .Node .Model ,
231243 response_model_exclude_none = True ,
232244 response_model_exclude_unset = True ,
@@ -249,7 +261,7 @@ async def get_node(uuid: str) -> orm.Node.Model:
249261
250262
251263@read_router .get (
252- '/nodes/ {uuid}/attributes' ,
264+ '/{uuid}/attributes' ,
253265 response_model = dict [str , t .Any ],
254266)
255267@with_dbenv ()
@@ -270,7 +282,7 @@ async def get_node_attributes(uuid: str) -> dict[str, t.Any]:
270282
271283
272284@read_router .get (
273- '/nodes/ {uuid}/extras' ,
285+ '/{uuid}/extras' ,
274286 response_model = dict [str , t .Any ],
275287)
276288@with_dbenv ()
@@ -291,7 +303,7 @@ async def get_node_extras(uuid: str) -> dict[str, t.Any]:
291303
292304
293305@read_router .get (
294- '/nodes/ {uuid}/links' ,
306+ '/{uuid}/links' ,
295307 response_model = PaginatedResults [NodeLinks ],
296308 response_model_exclude_none = True ,
297309 response_model_exclude_unset = True ,
@@ -321,7 +333,10 @@ async def get_node_links(
321333 raise HTTPException (status_code = 500 , detail = str (exception )) from exception
322334
323335
324- @read_router .get ('/nodes/{uuid}/download' )
336+ @read_router .get (
337+ '/{uuid}/download' ,
338+ response_class = StreamingResponse ,
339+ )
325340@with_dbenv ()
326341async def download_node (
327342 uuid : str ,
@@ -411,7 +426,7 @@ class RepoDirMetadata(pdt.BaseModel):
411426
412427
413428@read_router .get (
414- '/nodes/ {uuid}/repo/metadata' ,
429+ '/{uuid}/repo/metadata' ,
415430 response_model = dict [str , MetadataType ],
416431)
417432@with_dbenv ()
@@ -431,7 +446,10 @@ async def get_node_repo_file_metadata(uuid: str) -> dict[str, dict]:
431446 raise HTTPException (status_code = 500 , detail = str (exception )) from exception
432447
433448
434- @read_router .get ('/nodes/{uuid}/repo/contents' )
449+ @read_router .get (
450+ '/{uuid}/repo/contents' ,
451+ response_class = StreamingResponse ,
452+ )
435453@with_dbenv ()
436454async def get_node_repo_file_contents (
437455 uuid : str ,
@@ -488,7 +506,7 @@ def zip_stream() -> t.Generator[bytes, None, None]:
488506
489507
490508@write_router .post (
491- '/nodes ' ,
509+ '' ,
492510 response_model = orm .Node .Model ,
493511 response_model_exclude_none = True ,
494512 response_model_exclude_unset = True ,
@@ -515,7 +533,7 @@ async def create_node(
515533
516534
517535@write_router .post (
518- '/nodes/ file-upload' ,
536+ '/file-upload' ,
519537 response_model = orm .Node .Model ,
520538 response_model_exclude_none = True ,
521539 response_model_exclude_unset = True ,
0 commit comments