diff --git a/src/app.py b/src/app.py index 54aa57f2..66cef3dd 100644 --- a/src/app.py +++ b/src/app.py @@ -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/', methods=['GET']) def get_ancestors_info(uuid): validate_token_if_auth_header_exists(request) @@ -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") @@ -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/', methods=['GET']) def get_descendants_info(uuid): validate_token_if_auth_header_exists(request) @@ -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") @@ -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/', methods=['GET']) def get_parents_info(uuid): validate_token_if_auth_header_exists(request) @@ -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/', methods=['GET']) def get_children_info(uuid): validate_token_if_auth_header_exists(request)