def GET(self, account, rse): """ Return the account usage of the account. HTTP Success: 200 OK HTTP Error: 401 Unauthorized 406 Not Acceptable 404 Not Found :param account: The account name. :param rse: The rse. """ header('Content-Type', 'application/x-json-stream') try: for usage in get_account_usage(account=account, rse=rse, issuer=ctx.env.get('issuer'), vo=ctx.env.get('vo')): yield dumps(usage, cls=APIEncoder) + '\n' except AccountNotFound as error: raise generate_http_error(404, 'AccountNotFound', error.args[0]) except RSENotFound as error: raise generate_http_error(404, 'RSENotFound', error.args[0]) except AccessDenied as error: raise generate_http_error(401, 'AccessDenied', error.args[0]) except Exception as error: print(format_exc()) raise InternalError(error)
def get(self, account, rse): """ Return the account usage of the account. .. :quickref: Usage2; Get account usage for RSE. :param account: The account name. :param rse: The rse. :resheader Content-Type: application/x-json-stream :status 200: OK. :status 401: Invalid auth token. :status 404: Account not found. :status 404: RSE not found. :status 500: Database exception. :returns: Line separated list of account usages. """ try: data = "" for usage in get_account_usage( account=account, rse=rse, issuer=request.environ.get('issuer')): data += dumps(usage, cls=APIEncoder) + '\n' return Response(data, content_type="application/x-json-stream") except AccountNotFound as error: return generate_http_error_flask(404, 'AccountNotFound', error.args[0]) except RSENotFound as error: return generate_http_error_flask(404, 'RSENotFound', error.args[0]) except AccessDenied as error: return generate_http_error_flask(401, 'AccessDenied', error.args[0]) except Exception as error: print(format_exc()) return error, 500
def GET(self, account): """ Return the account usage of the account. HTTP Success: 200 OK HTTP Error: 401 Unauthorized 404 Not Found :param account: The account name. """ header('Content-Type', 'application/x-json-stream') try: for usage in get_account_usage(account=account, rse=None, issuer=ctx.env.get('issuer')): yield dumps(usage, cls=APIEncoder) + '\n' except AccountNotFound, e: raise generate_http_error(404, 'AccountNotFound', e.args[0][0])