From 93720bd0f4f4e9c208b9cb234729df800937dbc2 Mon Sep 17 00:00:00 2001 From: Jimmy Zelinskie Date: Wed, 30 Mar 2016 16:48:06 -0400 Subject: [PATCH] superuser: proper view for approvals/keys --- endpoints/api/superuser.py | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/endpoints/api/superuser.py b/endpoints/api/superuser.py index 065d17709..8dcccb79a 100644 --- a/endpoints/api/superuser.py +++ b/endpoints/api/superuser.py @@ -478,6 +478,28 @@ class SuperUserOrganizationManagement(ApiResource): abort(403) +def key_view(key): + return { + 'name': key.name, + 'kid': key.kid, + 'service': key.service, + 'jwk': key.jwk, + 'metadata': key.metadata, + 'created_date': key.created_date, + 'expiration_date': key.expiration_date, + 'approval': approval_view(key.approval) if key.approval is not None else None, + } + + +def approval_view(approval): + return { + 'approver': user_view(approval.approver), + 'approval_type': approval.approval_type, + 'approved_date': approval.approved_date, + 'notes': approval.notes, + } + + @resource('/v1/superuser/keys') @show_if(features.SUPER_USERS) class SuperUserServiceKeyManagement(ApiResource): @@ -514,7 +536,8 @@ class SuperUserServiceKeyManagement(ApiResource): @require_scope(scopes.SUPERUSER) def get(self): if SuperUserPermission().can(): - return jsonify(model.service_keys.list_keys()) + keys = model.service_keys.list_keys() + return jsonify({'keys': [key_view(key) for key in keys]}) abort(403) @verify_not_prod