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
47 changes: 29 additions & 18 deletions dj_gui_api_server/DJGUIAPIServer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 <JWT-Token>
body: (html:POST:JSON): {"schemaName": <schema_name>, "tableName": <table_name>, "tuple", "tuple": <tuple_to_insert>} (NOTE: Table name must be in CamalCase)
body: (html:POST:JSON): {"schemaName": <schema_name>, "tableName": <table_name>} (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 <JWT-Token>
body: (html:POST:JSON): {"schemaName": <schema_name>, "tableName": <table_name>} (NOTE: Table name must be in CamalCase)

Returns:
dict(tuples=[tuples_as_dicts])
dict(primary_keys=[<primary_key_names>], secondary_attributes=[<secondary_key_names])
or
dict(error=<error_message>): 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 <JWT-Token>
body: (html:POST:JSON): {"schemaName": <schema_name>, "tableName": <table_name>, "tuple", "tuple": <tuple_to_insert>} (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

Expand Down