Skip to content

Commit c38962f

Browse files
authored
Merge pull request #243 from hubmapconsortium/Derek-Furst/validate-new-entity-revisions
Derek furst/validate new entity revisions
2 parents 1547762 + 40c7b20 commit c38962f

File tree

2 files changed

+62
-0
lines changed

2 files changed

+62
-0
lines changed

entity-api-spec.yaml

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1422,5 +1422,62 @@ paths:
14221422
description: The user is not authorized to query the revision number of the given dataset.
14231423
'404':
14241424
description: The target dataset could not be found
1425+
'500':
1426+
description: Internal error
1427+
'/datasets/{id}/revisions':
1428+
get:
1429+
summary: 'From a given ID of a versioned dataset, retrieve a list of every dataset in the chain ordered from most recent to oldest. The revision number, as well as the dataset uuid will be included. An optional parameter ?include_dataset=true will include the full dataset for each revision as well. Public/Consortium access rules apply, if is for a non-public dataset and no token or a token without membership in HuBMAP-Read group is sent with the request then a 403 response should be returned. If the given id is published, but later revisions are not and the user is not in HuBMAP-Read group, only published revisions will be returned. The field next_revision_uuid will not be returned if the next revision is unpublished'
1430+
parameters:
1431+
- name: id
1432+
in: path
1433+
description: The unique identifier of entity. This identifier can be either an HuBMAP ID (e.g. HBM123.ABCD.456) or UUID
1434+
required: true
1435+
schema:
1436+
type: string
1437+
- name: include_dataset
1438+
in: query
1439+
description: A case insensitive string. Any value besides true will have no effect. If the string is 'true', the full dataset for each revision will be included in the response
1440+
required: false
1441+
schema:
1442+
type: string
1443+
responses:
1444+
'200':
1445+
description: The revision number (integer) on successful operation
1446+
'400':
1447+
description: Invalid or misformatted entity identifier, or the given entity is not a Dataset
1448+
'401':
1449+
description: The user's token has expired or the user did not supply a valid token
1450+
'403':
1451+
description: The user is not authorized to query the revision number of the given dataset.
1452+
'404':
1453+
description: The target dataset could not be found
1454+
'500':
1455+
description: Internal error
1456+
'/datasets/{id}/retract':
1457+
put:
1458+
summary: 'Takes a json with a single required field {retraction_reason: string}. The dataset for the given id is modified to include this new retraction_reason field and sets the property sub_status to retracted. The complete modified dataset is returned. This will not work for anything besides published datasets. If the user has no token or has a token without membership in HuBMAP-Data-Admin group, then a 403 response should be returned.'
1459+
parameters:
1460+
- name: id
1461+
in: path
1462+
description: The unique identifier of entity. This identifier can be either a HubMAP ID (e.g. HBM123.ABCD.456) or UUID
1463+
required: true
1464+
schema:
1465+
type: string
1466+
requestBody:
1467+
content:
1468+
application/json:
1469+
schema:
1470+
retraction_reason: string
1471+
responses:
1472+
'200':
1473+
description: The complete dataset with modified sub_status and retraction_reason
1474+
'400':
1475+
description: Invalid or misformatted entity identifier, or the given entity is not a Dataset or is not published
1476+
'401':
1477+
description: The user's token has expired or the user did not supply a valid token
1478+
'403':
1479+
description: The user is not authorized to query the retract the given dataset.
1480+
'404':
1481+
description: The target dataset could not be found
14251482
'500':
14261483
description: Internal error

src/app.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -866,6 +866,11 @@ def create_entity(entity_type):
866866
if next_revisions_list:
867867
bad_request_error(f"The previous_revision_uuid specified for this dataset has already had a next revision")
868868

869+
# Only published datasets can have revisions made of them. Verify that that status of the Dataset specified
870+
# by previous_revision_uuid is published. Else, bad request error.
871+
if previous_version_dict['status'].lower() != DATASET_STATUS_PUBLISHED:
872+
bad_request_error(f"The previous_revision_uuid specified for this dataset must be 'Published' in order to create a new revision from it")
873+
869874
# Generate 'before_create_triiger' data and create the entity details in Neo4j
870875
merged_dict = create_entity_details(request, normalized_entity_type, user_token, json_data_dict)
871876
else:

0 commit comments

Comments
 (0)