-
Notifications
You must be signed in to change notification settings - Fork 0
/
webservice.py
72 lines (62 loc) · 2.89 KB
/
webservice.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
from flask import Flask, jsonify, request
def new(daemon):
"""
Returns a new Flask instance for a Daemon
Daemon must implements the info function
:param daemon:
:return: Flask
"""
app = Flask(__name__)
@app.route('/', methods=['GET'])
def info():
print("info")
return jsonify(daemon.info())
@app.route('/get_nested_collections', methods=['GET'])
def getNestedCollectiomns():
try:
identifier_value = request.args.get('identifier_value', type=str)
identifier_type = request.args.get('identifier_type', type=str)
if identifier_value is None or identifier_value == "" :
return "identifier_value is required"
elif identifier_type is None or identifier_type == "":
return "identifier_type is required"
else:
return daemon.get_nested_collections(identifier_value, identifier_type)
except Exception as e:
print(e)
return
@app.route('/get_collection_tree', methods=['GET'])
def getNestedCollectiomn_tree():
try:
identifier_value = request.args.get('identifier_value', type=str)
identifier_type = request.args.get('identifier_type', type=str)
if identifier_value is None or identifier_value == "" :
return "identifier_value is required"
elif identifier_type is None or identifier_type == "":
return "identifier_type is required"
else:
return daemon.get_nested_collections_subtree(identifier_value, identifier_type)
except Exception as e:
print(e)
return
@app.route('/get_implicit_relationship_between', methods=['GET'])
def getImplicitRelationships():
try:
from_identifier_value = request.args.get('from_identifier_value', type=str)
from_identifier_type = request.args.get('from_identifier_type', type=str)
to_identifier_value = request.args.get('to_identifier_value', type=str)
to_identifier_type = request.args.get('to_identifier_type', type=str)
if from_identifier_value is None or from_identifier_value == "" :
return "from_identifier_value is required"
elif from_identifier_type is None or from_identifier_type == "":
return "from_identifier_type is required"
elif to_identifier_value is None or to_identifier_value == "":
return "to_identifier_type is required"
elif to_identifier_type is None or to_identifier_type == "":
return "to_identifier_type is required"
else:
return daemon.getRelationshipsBetween_shortest(from_identifier_value, from_identifier_type, to_identifier_value, to_identifier_type)
except Exception as e:
print(e)
return
return app