# HG changeset patch # User Marcin Kuzminski # Date 2017-03-16 11:18:47 # Node ID 9c7eeec8b8a9fd5471f017b127591cd108d6b162 # Parent d8292ad9c7167ce3b88a5b7f73441820afc04c7e repo-settings: expose pull api endpoint into remote pull view for easier automation. diff --git a/docs/api/api.rst b/docs/api/api.rst --- a/docs/api/api.rst +++ b/docs/api/api.rst @@ -75,7 +75,7 @@ Example call for auto pulling from remot .. code-block:: bash curl https://server.com/_admin/api -X POST -H 'content-type:text/plain' --data-binary '{"id":1, - "auth_token":"xe7cdb2v278e4evbdf5vs04v832v0efvcbcve4a3","method":"pull", "args":{"repo":"CPython"}}' + "auth_token":"xe7cdb2v278e4evbdf5vs04v832v0efvcbcve4a3","method":"pull", "args":{"repoid":"CPython"}}' Provide those parameters: - **id** A value of any type, which is used to match the response with the diff --git a/rhodecode/lib/helpers.py b/rhodecode/lib/helpers.py --- a/rhodecode/lib/helpers.py +++ b/rhodecode/lib/helpers.py @@ -1992,6 +1992,16 @@ def get_last_path_part(file_node): return u'../' + path +def route_url(*args, **kwds): + """ + Wrapper around pyramids `route_url` function. It is used to generate + URLs from within pylons views or templates. This will be removed when + pyramid migration if finished. + """ + req = get_current_request() + return req.route_url(*args, **kwds) + + def route_path(*args, **kwds): """ Wrapper around pyramids `route_path` function. It is used to generate diff --git a/rhodecode/templates/admin/repos/repo_edit_remote.mako b/rhodecode/templates/admin/repos/repo_edit_remote.mako --- a/rhodecode/templates/admin/repos/repo_edit_remote.mako +++ b/rhodecode/templates/admin/repos/repo_edit_remote.mako @@ -6,7 +6,15 @@ %if c.repo_info.clone_uri: -
${_('Remote mirror url')}: ${c.repo_info.clone_uri_hidden}
+
${_('Remote mirror url')}: + ${c.repo_info.clone_uri_hidden} +

+ ${_('Pull can be automated by such api call called periodically (in crontab etc)')} +

+ + curl ${h.route_url('apiv2')} -X POST -H 'content-type:text/plain' --data-binary '{"id":1, "auth_token":"SECRET","method":"pull", "args":{"repoid":"${c.repo_info.repo_name}"}}' + +
${h.secure_form(url('edit_repo_remote', repo_name=c.repo_name), method='put')}
@@ -18,7 +26,7 @@ %else:
${_('This repository does not have any remote mirror url set.')}
- %endif