Skip to content

Commit

Permalink
seperate request for manifest
Browse files Browse the repository at this point in the history
  • Loading branch information
JLoveUOA committed Nov 25, 2024
1 parent 2b11810 commit 37dd942
Showing 1 changed file with 27 additions and 3 deletions.
30 changes: 27 additions & 3 deletions src/api/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,32 +143,56 @@ async def get_drive_info(
"""Retrieve information about the specified Research Drive."""

validate_permissions("GET", api_key)

code_query = select(ResearchDriveService).where(
ResearchDriveService.name == drive_id
)
drive_found = session.exec(code_query).first()

if drive_found is None:
raise HTTPException(
status_code=404,
detail=f"Research Drive ID {drive_id} not found in local database.",
)

projects = drive_found.projects
if len(projects) == 0:
raise HTTPException(
status_code=404,
detail=f"No Projects associated with {drive_id} in local database",
)

return {
"drive_id": drive_id,
"ro_crate": "TODO: Make RO-Crate from: " + str(projects),
}


@app.get(ENDPOINT_PREFIX + "/resdrivemanifest")
async def get_drive_manifest(
drive_id: ResearchDriveID,
session: SessionDep,
api_key: ApiKey = Security(validate_api_key),
) -> dict[str, str]:
"""Retrieve a manifest from a research drive that has been loaded into the backend"""
validate_permissions("GET", api_key)
code_query = select(ResearchDriveService).where(
ResearchDriveService.name == drive_id
)
drive_found = session.exec(code_query).first()

if drive_found is None:
raise HTTPException(
status_code=404,
detail=f"Research Drive ID {drive_id} not found in local database.",
)
manifest = drive_found.manifest.manifest

if manifest is None:
raise HTTPException(
status_code=404,
detail=f"Manifest not available for {drive_id}",
)

return {
"drive_id": drive_id,
"ro_crate": "TODO: Make RO-Crate from: " + str(projects),
"manifest": manifest,
}

0 comments on commit 37dd942

Please sign in to comment.