Skip to content
Snippets Groups Projects
Commit c30cc8bc authored by joe's avatar joe
Browse files

Added the methods to get the timestamp as well.

parent 59246837
Branches
No related tags found
No related merge requests found
......@@ -241,3 +241,21 @@ class AdmDbApi(object):
self.schema.acl_check_entity(ent, auth_context, 'r', None)
return self.db.get_audit(query, session)
@with_session
def get_timestamp(self, session, entity_name, auth_context):
"""Get the timestamp of the last update on an entity.
"""
ent = self.schema.get_entity(entity_name)
if not ent:
raise exceptions.NotFound(entity_name)
self.schema.acl_check_entity(ent, auth_context, 'r', None)
obj = self.db.get_by_name('__timestamp', entity_name, session)
if not obj:
raise exceptions.NotFound(entity_name)
return obj
......@@ -156,6 +156,14 @@ def find(class_name):
def delete(class_name, object_name):
return g.api.delete(class_name, object_name, g.auth_ctx)
@api_app.route('/timestamp/<class_name>')
@authenticate
def ts(class_name):
try:
res = g.api.get_timestamp(class_name, g.auth_ctx)
return str(res.ts)
except exceptions.NotFound:
return "0"
@api_app.route('/audit', methods=['POST'])
@authenticate
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment