##// END OF EJS Templates
helpers: added separate curl example, we'll need to it generate artifacts curl examples.
marcink -
r3990:aeba388b default
parent child Browse files
Show More
@@ -2018,24 +2018,31 b' def current_route_path(request, **kw):'
2018 2018 return request.current_route_path(_query=new_args)
2019 2019
2020 2020
2021 def api_call_example(method, args):
2022 """
2023 Generates an API call example via CURL
2024 """
2021 def curl_api_example(method, args):
2025 2022 args_json = json.dumps(OrderedDict([
2026 2023 ('id', 1),
2027 2024 ('auth_token', 'SECRET'),
2028 2025 ('method', method),
2029 2026 ('args', args)
2030 2027 ]))
2028
2029 return "curl {api_url} -X POST -H 'content-type:text/plain' --data-binary '{args_json}'".format(
2030 api_url=route_url('apiv2'),
2031 args_json=args_json
2032 )
2033
2034
2035 def api_call_example(method, args):
2036 """
2037 Generates an API call example via CURL
2038 """
2039 curl_call = curl_api_example(method, args)
2040
2031 2041 return literal(
2032 "curl {api_url} -X POST -H 'content-type:text/plain' --data-binary '{data}'"
2042 curl_call +
2033 2043 "<br/><br/>SECRET can be found in <a href=\"{token_url}\">auth-tokens</a> page, "
2034 2044 "and needs to be of `api calls` role."
2035 .format(
2036 api_url=route_url('apiv2'),
2037 token_url=route_url('my_account_auth_tokens'),
2038 data=args_json))
2045 .format(token_url=route_url('my_account_auth_tokens')))
2039 2046
2040 2047
2041 2048 def notification_description(notification, request):
General Comments 0
You need to be logged in to leave comments. Login now