mirror of
https://github.com/adulau/hashlookup-server.git
synced 2024-11-23 02:27:11 +00:00
chg: [server] document API responses - valid swagger
This commit is contained in:
parent
672dc7a0dc
commit
a9372848d8
1 changed files with 32 additions and 0 deletions
|
@ -128,6 +128,10 @@ def calculate_trust(hobject=None):
|
||||||
@api.route('/lookup/md5/<string:md5>')
|
@api.route('/lookup/md5/<string:md5>')
|
||||||
@api.doc(description="Lookup MD5.")
|
@api.doc(description="Lookup MD5.")
|
||||||
class lookup(Resource):
|
class lookup(Resource):
|
||||||
|
@api.doc(id='get_lookup_md5')
|
||||||
|
@api.response(200, 'Success')
|
||||||
|
@api.response(400, 'MD5 value incorrect, expecting a MD5 value in hex format')
|
||||||
|
@api.response(404, 'Non existing MD5')
|
||||||
def get(self, md5):
|
def get(self, md5):
|
||||||
if check_md5(value=md5) is False:
|
if check_md5(value=md5) is False:
|
||||||
return {
|
return {
|
||||||
|
@ -206,6 +210,10 @@ class lookup(Resource):
|
||||||
@api.route('/lookup/sha1/<string:sha1>')
|
@api.route('/lookup/sha1/<string:sha1>')
|
||||||
@api.doc(description="Lookup SHA-1.")
|
@api.doc(description="Lookup SHA-1.")
|
||||||
class lookup(Resource):
|
class lookup(Resource):
|
||||||
|
@api.doc(id='get_lookup_sha1')
|
||||||
|
@api.response(200, 'Success')
|
||||||
|
@api.response(400, 'SHA1 value incorrect, expecting a SHA1 value in hex format')
|
||||||
|
@api.response(404, 'Non existing SHA1')
|
||||||
def get(self, sha1):
|
def get(self, sha1):
|
||||||
if check_sha1(value=sha1) is False:
|
if check_sha1(value=sha1) is False:
|
||||||
return {
|
return {
|
||||||
|
@ -281,6 +289,10 @@ class lookup(Resource):
|
||||||
@api.route('/lookup/sha256/<string:sha256>')
|
@api.route('/lookup/sha256/<string:sha256>')
|
||||||
@api.doc(description="Lookup SHA-256.")
|
@api.doc(description="Lookup SHA-256.")
|
||||||
class lookup(Resource):
|
class lookup(Resource):
|
||||||
|
@api.doc(id='get_lookup_sha256')
|
||||||
|
@api.response(200, 'Success')
|
||||||
|
@api.response(400, 'SHA-256 value incorrect, expecting a SHA-256 value in hex format')
|
||||||
|
@api.response(404, 'Non existing SHA-256')
|
||||||
def get(self, sha256):
|
def get(self, sha256):
|
||||||
if check_sha256(value=sha256) is False:
|
if check_sha256(value=sha256) is False:
|
||||||
return {
|
return {
|
||||||
|
@ -362,6 +374,9 @@ class lookup(Resource):
|
||||||
description="Return parents from a given SHA1. A number of element to return and an offset must be given. If not set it will be the 100 first elements. A cursor must be given to paginate over. The starting cursor is 0."
|
description="Return parents from a given SHA1. A number of element to return and an offset must be given. If not set it will be the 100 first elements. A cursor must be given to paginate over. The starting cursor is 0."
|
||||||
)
|
)
|
||||||
class parents(Resource):
|
class parents(Resource):
|
||||||
|
@api.response(200, 'Success')
|
||||||
|
@api.response(400, 'SHA1 value incorrect, expecting a SHA1 value in hex format')
|
||||||
|
@api.response(404, 'The SHA1 value has no known parent.')
|
||||||
def get(self, sha1, count, cursor):
|
def get(self, sha1, count, cursor):
|
||||||
if check_sha1(value=sha1) is False:
|
if check_sha1(value=sha1) is False:
|
||||||
return {
|
return {
|
||||||
|
@ -388,6 +403,9 @@ class parents(Resource):
|
||||||
description="Return children from a given SHA1. A number of element to return and an offset must be given. If not set it will be the 100 first elements. A cursor must be given to paginate over. The starting cursor is 0."
|
description="Return children from a given SHA1. A number of element to return and an offset must be given. If not set it will be the 100 first elements. A cursor must be given to paginate over. The starting cursor is 0."
|
||||||
)
|
)
|
||||||
class children(Resource):
|
class children(Resource):
|
||||||
|
@api.response(200, 'Success')
|
||||||
|
@api.response(400, 'SHA1 value incorrect, expecting a SHA1 value in hex format')
|
||||||
|
@api.response(404, 'The SHA1 value has no known child.')
|
||||||
def get(self, sha1, count, cursor):
|
def get(self, sha1, count, cursor):
|
||||||
if check_sha1(value=sha1) is False:
|
if check_sha1(value=sha1) is False:
|
||||||
return {
|
return {
|
||||||
|
@ -430,6 +448,8 @@ class info(Resource):
|
||||||
description="Bulk search of MD5 hashes in a JSON array with the key \'hashes\'."
|
description="Bulk search of MD5 hashes in a JSON array with the key \'hashes\'."
|
||||||
)
|
)
|
||||||
class bulkmd5(Resource):
|
class bulkmd5(Resource):
|
||||||
|
@api.response(200, 'Success')
|
||||||
|
@api.response(404, 'JSON format incorrect. An array of hashes in the key \'hashes\' is expected.')
|
||||||
def post(self):
|
def post(self):
|
||||||
json_data = request.get_json(force=True)
|
json_data = request.get_json(force=True)
|
||||||
if not 'hashes' in json_data:
|
if not 'hashes' in json_data:
|
||||||
|
@ -457,6 +477,8 @@ class bulkmd5(Resource):
|
||||||
@api.route('/bulk/sha1')
|
@api.route('/bulk/sha1')
|
||||||
@api.doc(description="Bulk search of SHA1 hashes in a JSON array with the \'hashes\'.")
|
@api.doc(description="Bulk search of SHA1 hashes in a JSON array with the \'hashes\'.")
|
||||||
class bulksha1(Resource):
|
class bulksha1(Resource):
|
||||||
|
@api.response(200, 'Success')
|
||||||
|
@api.response(404, 'JSON format incorrect. An array of hashes in the key \'hashes\' is expected.')
|
||||||
def post(self):
|
def post(self):
|
||||||
json_data = request.get_json(force=True)
|
json_data = request.get_json(force=True)
|
||||||
if not 'hashes' in json_data:
|
if not 'hashes' in json_data:
|
||||||
|
@ -486,6 +508,10 @@ class bulksha1(Resource):
|
||||||
description="Create a session key to keep search context. The session is attached to a name. After the session is created, the header `hashlookup_session` can be set to the session name."
|
description="Create a session key to keep search context. The session is attached to a name. After the session is created, the header `hashlookup_session` can be set to the session name."
|
||||||
)
|
)
|
||||||
class sessioncreate(Resource):
|
class sessioncreate(Resource):
|
||||||
|
@api.doc(id='get_session_create')
|
||||||
|
@api.response(200, 'Success')
|
||||||
|
@api.response(400, 'Expecting a name for the session')
|
||||||
|
@api.response(500, 'Session feature is not enabled')
|
||||||
def get(self, name):
|
def get(self, name):
|
||||||
if name is None or len(name) > 120:
|
if name is None or len(name) > 120:
|
||||||
return {'message': 'Expecting a name for the session'}, 400
|
return {'message': 'Expecting a name for the session'}, 400
|
||||||
|
@ -503,6 +529,10 @@ class sessioncreate(Resource):
|
||||||
@api.route('/session/get/<string:name>')
|
@api.route('/session/get/<string:name>')
|
||||||
@api.doc(description="Return set of matching and non-matching hashes from a session.")
|
@api.doc(description="Return set of matching and non-matching hashes from a session.")
|
||||||
class sessioncreate(Resource):
|
class sessioncreate(Resource):
|
||||||
|
@api.doc(id='get_session_matches')
|
||||||
|
@api.response(200, 'Success')
|
||||||
|
@api.response(400, 'Expecting a name for the session')
|
||||||
|
@api.response(500, 'Session feature is not enabled')
|
||||||
def get(self, name):
|
def get(self, name):
|
||||||
if name is None or len(name) > 120:
|
if name is None or len(name) > 120:
|
||||||
return {'message': 'Expecting a name for the session'}, 400
|
return {'message': 'Expecting a name for the session'}, 400
|
||||||
|
@ -522,6 +552,8 @@ class sessioncreate(Resource):
|
||||||
@api.route('/stats/top')
|
@api.route('/stats/top')
|
||||||
@api.doc(description="Return the top 100 of most queried values.")
|
@api.doc(description="Return the top 100 of most queried values.")
|
||||||
class stattop(Resource):
|
class stattop(Resource):
|
||||||
|
@api.response(200, 'Success')
|
||||||
|
@api.response(400, 'Public statistics not enabled')
|
||||||
def get(self):
|
def get(self):
|
||||||
if stats_public is False:
|
if stats_public is False:
|
||||||
return {'message': 'Public statistics not enabled'}, 400
|
return {'message': 'Public statistics not enabled'}, 400
|
||||||
|
|
Loading…
Reference in a new issue