Add ID-based pagination to logs using new decorators and an encrypted token
Fixes #599
This commit is contained in:
parent
af77b92bcf
commit
bd0a098282
8 changed files with 110 additions and 36 deletions
|
@ -12,7 +12,8 @@ import features
|
|||
from app import app, avatar, superusers, authentication, config_provider
|
||||
from endpoints.api import (ApiResource, nickname, resource, validate_json_request,
|
||||
internal_only, require_scope, show_if, parse_args,
|
||||
query_param, abort, require_fresh_login, path_param, verify_not_prod)
|
||||
query_param, abort, require_fresh_login, path_param, verify_not_prod,
|
||||
page_support)
|
||||
from endpoints.api.logs import get_logs, get_aggregate_logs
|
||||
from data import model
|
||||
from auth.permissions import SuperUserPermission
|
||||
|
@ -116,14 +117,15 @@ class SuperUserLogs(ApiResource):
|
|||
@query_param('starttime', 'Earliest time from which to get logs (%m/%d/%Y %Z)', type=str)
|
||||
@query_param('endtime', 'Latest time to which to get logs (%m/%d/%Y %Z)', type=str)
|
||||
@query_param('page', 'The page number for the logs', type=int, default=1)
|
||||
@page_support
|
||||
@require_scope(scopes.SUPERUSER)
|
||||
def get(self, args):
|
||||
def get(self, args, page_token):
|
||||
""" List the usage logs for the current system. """
|
||||
if SuperUserPermission().can():
|
||||
start_time = args['starttime']
|
||||
end_time = args['endtime']
|
||||
|
||||
return get_logs(start_time, end_time, page=args['page'])
|
||||
return get_logs(start_time, end_time, page_token=page_token)
|
||||
|
||||
abort(403)
|
||||
|
||||
|
|
Reference in a new issue