def GET(self, account):
""" get account information for given account name.
HTTP Success:
200 OK
HTTP Error:
401 Unauthorized
404 Not Found
500 InternalError
:param Rucio-Account: Account identifier.
:param Rucio-Auth-Token: as an 32 character hex string.
:returns: JSON dict containing informations about the requested user.
"""
header('Content-Type', 'application/json')
if account == 'whoami':
# Redirect to the account uri
frontend = ctx.env.get('HTTP_X_REQUESTED_HOST')
if frontend:
raise redirect(frontend + "/accounts/%s" % (ctx.env.get('issuer')))
raise seeother(ctx.env.get('issuer'))
acc = None
try:
acc = get_account_info(account)
except AccountNotFound, e:
raise generate_http_error(404, 'AccountNotFound', e.args[0][0])
except AccessDenied, e:
raise generate_http_error(401, 'AccessDenied', e.args[0][0])
except RucioException, e:
raise generate_http_error(500, e.__class__.__name__, e.args[0][0])
except Exception, e:
print format_exc()
raise InternalError(e)
dict = acc.to_dict()
for key, value in dict.items():
if isinstance(value, datetime):
dict[key] = value.strftime('%Y-%m-%dT%H:%M:%S')
del dict['_sa_instance_state']
return render_json(**dict)
评论列表
文章目录