new: [api] basic lookup added
parent
542b41db42
commit
15092537b0
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
- `<type>:<UUID>` -> 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:<type>` -> `<UUID>`
|
||||
|
||||
# Statistics
|
||||
|
||||
## Automatic API statistics
|
||||
|
|
Loading…
Reference in New Issue