diff --git a/backend/bin/server.py b/backend/bin/server.py index daa93af..4365914 100644 --- a/backend/bin/server.py +++ b/backend/bin/server.py @@ -6,13 +6,13 @@ import uuid app = Flask(__name__) app.url_map.strict_slashes = False -api = Api(app, version=version, title='CyCAT.org API', description='CyCAT - The Cybersecurity Resource Catalogue public API services.', doc='/doc/') +api = Api(app, version=version, title='CyCAT.org API', description='CyCAT - The Cybersecurity Resource Catalogue public API services.', doc='/', ordered=True) import uuid import inspect import redis -r = redis.Redis(host='127.0.0.1', port='3033') +r = redis.Redis(host='127.0.0.1', port='3033', decode_responses=True) # genericc lib - TODO: move to cycat Python library @@ -49,7 +49,11 @@ class favicon(Resource): class lookup(Resource): def get(self, uuid): if _validate_uuid(value=uuid): - return ("{}".format(uuid)) + if not r.exists("u:{}".format(uuid)): + return{'message': 'Non existing UUID'}, 404 + t = r.get("u:{}".format(uuid)) + h = r.hgetall("{}:{}".format(t, uuid)) + return (h) else: return {'message': 'UUID is incorrect'}, 400 diff --git a/backend/data-structure.md b/backend/data-structure.md index dd2f208..cb0e2d0 100644 --- a/backend/data-structure.md +++ b/backend/data-structure.md @@ -13,9 +13,21 @@ Each UUID inserted in CyCAT has at least an entry in the backend with the follow |value|type| |-----|-----------------------------------------| -|`1 | Publisher | +| 1 | Publisher | | 2 | Project | +# UUID hash table + +Each UUID inserted might have a corresponding hash table + +- `:` -> keys associated with the hash table type + +# type sorted set + +Each type got a sorted set (with a score of one) to easily paginate over the various types + +- `t:` -> `` + # Statistics ## Automatic API statistics