# HG changeset patch # User Marcin Kuzminski # Date 2019-10-15 11:24:38 # Node ID aeba388b46f7e7c57d31ca13d2224966f5feb7b6 # Parent ec9a2a1dcbac70b62fe02e78e126d5be17af353d helpers: added separate curl example, we'll need to it generate artifacts curl examples. diff --git a/rhodecode/lib/helpers.py b/rhodecode/lib/helpers.py --- a/rhodecode/lib/helpers.py +++ b/rhodecode/lib/helpers.py @@ -2018,24 +2018,31 @@ def current_route_path(request, **kw): return request.current_route_path(_query=new_args) -def api_call_example(method, args): - """ - Generates an API call example via CURL - """ +def curl_api_example(method, args): args_json = json.dumps(OrderedDict([ ('id', 1), ('auth_token', 'SECRET'), ('method', method), ('args', args) ])) + + return "curl {api_url} -X POST -H 'content-type:text/plain' --data-binary '{args_json}'".format( + api_url=route_url('apiv2'), + args_json=args_json + ) + + +def api_call_example(method, args): + """ + Generates an API call example via CURL + """ + curl_call = curl_api_example(method, args) + return literal( - "curl {api_url} -X POST -H 'content-type:text/plain' --data-binary '{data}'" + curl_call + "

SECRET can be found in auth-tokens page, " "and needs to be of `api calls` role." - .format( - api_url=route_url('apiv2'), - token_url=route_url('my_account_auth_tokens'), - data=args_json)) + .format(token_url=route_url('my_account_auth_tokens'))) def notification_description(notification, request):