Show More
@@ -36,6 +36,8 b' import urlparse' | |||||
36 | import time |
|
36 | import time | |
37 | import string |
|
37 | import string | |
38 | import hashlib |
|
38 | import hashlib | |
|
39 | from collections import OrderedDict | |||
|
40 | ||||
39 | import pygments |
|
41 | import pygments | |
40 | import itertools |
|
42 | import itertools | |
41 | import fnmatch |
|
43 | import fnmatch | |
@@ -2003,3 +2005,23 b' def resource_path(*args, **kwds):' | |||||
2003 | """ |
|
2005 | """ | |
2004 | req = get_current_request() |
|
2006 | req = get_current_request() | |
2005 | return req.resource_path(*args, **kwds) |
|
2007 | return req.resource_path(*args, **kwds) | |
|
2008 | ||||
|
2009 | ||||
|
2010 | def api_call_example(method, args): | |||
|
2011 | """ | |||
|
2012 | Generates an API call example via CURL | |||
|
2013 | """ | |||
|
2014 | args_json = json.dumps(OrderedDict([ | |||
|
2015 | ('id', 1), | |||
|
2016 | ('auth_token', 'SECRET'), | |||
|
2017 | ('method', method), | |||
|
2018 | ('args', args) | |||
|
2019 | ])) | |||
|
2020 | return literal( | |||
|
2021 | "curl {api_url} -X POST -H 'content-type:text/plain' --data-binary '{data}'" | |||
|
2022 | "<br/><br/>SECRET can be found in <a href=\"{token_url}\">auth-tokens</a> page, " | |||
|
2023 | "and needs to be of `api calls` role." | |||
|
2024 | .format( | |||
|
2025 | api_url=route_url('apiv2'), | |||
|
2026 | token_url=route_url('my_account_auth_tokens'), | |||
|
2027 | data=args_json)) |
General Comments 0
You need to be logged in to leave comments.
Login now