diff --git a/dj_gui_api_server/DJGUIAPIServer.py b/dj_gui_api_server/DJGUIAPIServer.py index e09d116..37d54ec 100644 --- a/dj_gui_api_server/DJGUIAPIServer.py +++ b/dj_gui_api_server/DJGUIAPIServer.py @@ -128,55 +128,66 @@ def fetch_tuples(jwt_payload): return str(e), 500 """ -Route to insert tuple +Route to get table definition -Parameter: - Parameters: +Parameters: header: (html:GET:Authorization): Must include in format of: bearer - body: (html:POST:JSON): {"schemaName": , "tableName": , "tuple", "tuple": } (NOTE: Table name must be in CamalCase) + body: (html:POST:JSON): {"schemaName": , "tableName": } (NOTE: Table name must be in CamalCase) Returns: - string: "Insert Successful" if the tuple was insert sucessfully + dict(tuples=[tuples_as_dicts]) or string: With error message of why it failed, 500 error """ -@app.route('/api/insert_tuple', methods=['POST']) +@app.route('/api/get_table_definition', methods=['POST']) @protected_route -def insert_tuple(jwt_payload): +def get_table_definition(jwt_payload): try: - # Attempt to insert - DJConnector.insert_tuple(jwt_payload, request.json["schemaName"], request.json["tableName"], request.json["tuple"]) - return "Insert Successful" + table_definition = DJConnector.get_table_definition(jwt_payload, request.json["schemaName"], request.json["tableName"]) + return table_definition except Exception as e: return str(e), 500 """ -Route to get table definition +Route to get table attibutes Parameters: header: (html:GET:Authorization): Must include in format of: bearer body: (html:POST:JSON): {"schemaName": , "tableName": } (NOTE: Table name must be in CamalCase) Returns: - dict(tuples=[tuples_as_dicts]) + dict(primary_keys=[], secondary_attributes=[): With error message of why it failed + string: With error message of why it failed, 500 error """ @app.route('/api/get_table_attributes', methods=['POST']) @protected_route def get_table_attributes(jwt_payload): try: return DJConnector.get_table_attributes(jwt_payload, request.json["schemaName"], request.json["tableName"]) - string: The table definition + except Exception as e: + return str(e), 500 + +""" +Route to insert tuple + +Parameter: + Parameters: + header: (html:GET:Authorization): Must include in format of: bearer + body: (html:POST:JSON): {"schemaName": , "tableName": , "tuple", "tuple": } (NOTE: Table name must be in CamalCase) + +Returns: + string: "Insert Successful" if the tuple was insert sucessfully or string: With error message of why it failed, 500 error """ -@app.route('/api/get_table_definition', methods=['POST']) +@app.route('/api/insert_tuple', methods=['POST']) @protected_route -def get_table_definition(jwt_payload): +def insert_tuple(jwt_payload): try: - table_definition = DJConnector.get_table_definition(jwt_payload, request.json["schemaName"], request.json["tableName"]) - return table_definition + # Attempt to insert + DJConnector.insert_tuple(jwt_payload, request.json["schemaName"], request.json["tableName"], request.json["tuple"]) + return "Insert Successful" except Exception as e: return str(e), 500