Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 75 additions & 0 deletions src/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -1114,6 +1114,24 @@ def get_entities_by_type(entity_type):
# Response with the final result
return jsonify(final_result)


"""
Retrieve the document info needed for a given entity's ancestors. Result filtering for this
endpoint is required and is given by the required parameter 'include'.
For example /ancestors-info?include=uuid,status,entity_type


Parameters
----------
include : str
A comma delimited string of all the properties to be retrieved by the endpoint

Returns
-------
json
A list of dicts where each dict contains the requested fields for the given ancestor.
"""

@app.route('/ancestors-info/<uuid>', methods=['GET'])
def get_ancestors_info(uuid):
validate_token_if_auth_header_exists(request)
Expand All @@ -1130,6 +1148,10 @@ def get_ancestors_info(uuid):
invalid = [f for f in include_fields if f not in valid_fields]
if invalid:
return bad_request_error(f"Invalid include fields: {invalid}")
else:
return bad_request_error(f"Missing required parameter: 'include'. Must include a list of properties to be returned.")
else:
return bad_request_error(f"Missing required parameter: 'include'. Must include a list of properties to be returned.")
result = app_neo4j_queries.get_ancestors_trimmed(neo4j_driver_instance, uuid, included_fields=include_fields)
if result is None:
return not_found_error(f"Entity {uuid} not found")
Expand All @@ -1139,6 +1161,22 @@ def get_ancestors_info(uuid):
return jsonify(ordered_response)


"""
Retrieve the document info needed for a given entity's descendant. Result filtering for this
endpoint is required and is given by the required parameter 'include'.
For example /descendants-info?include=uuid,status,entity_type


Parameters
----------
include : str
A comma delimited string of all the properties to be retrieved by the endpoint

Returns
-------
json
A list of dicts where each dict contains the requested fields for the given descendant.
"""
@app.route('/descendants-info/<uuid>', methods=['GET'])
def get_descendants_info(uuid):
validate_token_if_auth_header_exists(request)
Expand All @@ -1155,6 +1193,10 @@ def get_descendants_info(uuid):
invalid = [f for f in include_fields if f not in valid_fields]
if invalid:
return bad_request_error(f"Invalid include fields: {invalid}")
else:
return bad_request_error(f"Missing required parameter: 'include'. Must include a list of properties to be returned.")
else:
return bad_request_error(f"Missing required parameter: 'include'. Must include a list of properties to be returned.")
result = app_neo4j_queries.get_descendants_trimmed(neo4j_driver_instance, uuid, included_fields=include_fields)
if result is None:
return not_found_error(f"Entity {uuid} not found")
Expand All @@ -1163,6 +1205,23 @@ def get_descendants_info(uuid):
ordered_response = [alphabetize_dict_recursive(entity) for entity in complete]
return jsonify(ordered_response)


"""
Retrieve the document info needed for a given entity's parents (immediate ancestors). Result filtering for this
endpoint is allowed and is given by the required parameter 'include'.
For example /parents-info?include=uuid,status,entity_type


Parameters
----------
include : str
A comma delimited string of all the properties to be retrieved by the endpoint

Returns
-------
json
A list of dicts where each dict contains the requested fields for the given parent.
"""
@app.route('/parents-info/<uuid>', methods=['GET'])
def get_parents_info(uuid):
validate_token_if_auth_header_exists(request)
Expand All @@ -1188,6 +1247,22 @@ def get_parents_info(uuid):
return jsonify(ordered_response)


"""
Retrieve the document info needed for a given entity's children (immediate descendants). Result filtering for this
endpoint is allowed and is given by the required parameter 'include'.
For example /children-info?include=uuid,status,entity_type


Parameters
----------
include : str
A comma delimited string of all the properties to be retrieved by the endpoint

Returns
-------
json
A list of dicts where each dict contains the requested fields for the given child.
"""
@app.route('/children-info/<uuid>', methods=['GET'])
def get_children_info(uuid):
validate_token_if_auth_header_exists(request)
Expand Down
Loading