Skip to content

Commit

Permalink
Refine documentation of changesheet-related endpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
eecavanna committed Dec 3, 2024
1 parent a123f51 commit afdfd4b
Showing 1 changed file with 16 additions and 11 deletions.
27 changes: 16 additions & 11 deletions nmdc_runtime/api/endpoints/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@


async def raw_changesheet_from_uploaded_file(uploaded_file: UploadFile):
r"""
TODO: Document this function.
"""
content_type = uploaded_file.content_type
name = uploaded_file.filename
if name.endswith(".csv"):
Expand All @@ -56,14 +59,12 @@ async def raw_changesheet_from_uploaded_file(uploaded_file: UploadFile):

@router.post("/metadata/changesheets:validate")
async def validate_changesheet(
uploaded_file: UploadFile = File(...),
uploaded_file: UploadFile = File(..., description="The changesheet you want the server to validate"),
mdb: MongoDatabase = Depends(get_mongo_db),
):
"""
Example changesheet
[here](https://github.com/microbiomedata/nmdc-runtime/blob/main/metadata-translation/notebooks/data/changesheet-without-separator3.tsv).
r"""
Validates a [changesheet](https://microbiomedata.github.io/nmdc-runtime/howto-guides/author-changesheets/)
that is in either CSV or TSV format.
"""
sheet_in = await raw_changesheet_from_uploaded_file(uploaded_file)
df_change = df_from_sheet_in(sheet_in, mdb)
Expand All @@ -72,16 +73,20 @@ async def validate_changesheet(

@router.post("/metadata/changesheets:submit", response_model=DrsObjectWithTypes)
async def submit_changesheet(
uploaded_file: UploadFile = File(...),
uploaded_file: UploadFile = File(..., description="The changesheet you want the server to apply"),
mdb: MongoDatabase = Depends(get_mongo_db),
user: User = Depends(get_current_active_user),
):
"""
Example changesheet
[here](https://github.com/microbiomedata/nmdc-runtime/blob/main/metadata-translation/notebooks/data/changesheet-without-separator3.tsv).
r"""
Applies a [changesheet](https://microbiomedata.github.io/nmdc-runtime/howto-guides/author-changesheets/)
that is in either CSV or TSV format.
**Note:** This endpoint is only accessible to users that have been granted access by a Runtime administrator.
"""
# TODO: Allow users to determine whether they have that access (i.e. whether they are allowed to perform the
# `/metadata/changesheets:submit` action), themselves, so that they don't have to contact an admin
# or submit an example changesheet in order to find that out.

if not permitted(user.username, "/metadata/changesheets:submit"):
raise HTTPException(
status_code=status.HTTP_403_FORBIDDEN,
Expand Down

0 comments on commit afdfd4b

Please sign in to comment.