From 79c3f4e44f77eb580af9b9393864a4503d1e2597 Mon Sep 17 00:00:00 2001 From: Tomas Kopecek Date: Dec 09 2019 13:00:33 +0000 Subject: browsable api Fixes: https://pagure.io/koji/issue/1813 --- diff --git a/cli/koji_cli/commands.py b/cli/koji_cli/commands.py index 931d51b..6106357 100644 --- a/cli/koji_cli/commands.py +++ b/cli/koji_cli/commands.py @@ -2445,10 +2445,7 @@ def anon_handle_list_api(goptions, session, args): parser.error(_("This command takes no arguments")) assert False # pragma: no cover activate_session(session, goptions) - tmplist = [(x['name'], x) for x in session._listapi()] - tmplist.sort() - funcs = [x[1] for x in tmplist] - for x in funcs: + for x in sorted(session._listapi(), key=lambda x: x['name']): if 'argdesc' in x: args = x['argdesc'] elif x['args']: diff --git a/www/kojiweb/api.chtml b/www/kojiweb/api.chtml new file mode 100644 index 0000000..291d584 --- /dev/null +++ b/www/kojiweb/api.chtml @@ -0,0 +1,15 @@ +#include "includes/header.chtml" + +

API reference

+ + + +#include "includes/footer.chtml" diff --git a/www/kojiweb/includes/header.chtml b/www/kojiweb/includes/header.chtml index d008f4e..421b3f1 100644 --- a/www/kojiweb/includes/header.chtml +++ b/www/kojiweb/includes/header.chtml @@ -74,6 +74,7 @@ $localnav
  • Hosts
  • Reports
  • Search
  • +
  • API
  • diff --git a/www/kojiweb/index.py b/www/kojiweb/index.py index b5880b6..b5ecd78 100644 --- a/www/kojiweb/index.py +++ b/www/kojiweb/index.py @@ -2344,6 +2344,16 @@ def search(environ, start=None, order=None): else: return _genHTML(environ, 'search.chtml') + +def api(environ): + values = _initValues(environ, 'API', 'api') + server = _getServer(environ) + + values['methods'] = sorted(server._listapi(), key=lambda x: x['name']) + + return _genHTML(environ, 'api.chtml') + + def watchlogs(environ, taskID): values = _initValues(environ) if isinstance(taskID, list): diff --git a/www/static/koji.css b/www/static/koji.css index 2f31138..aa0b912 100644 --- a/www/static/koji.css +++ b/www/static/koji.css @@ -146,7 +146,8 @@ body#users #mainNav li#usersTab a, body#hosts #mainNav li#hostsTab a, body#buildtargets #mainNav li#buildtargetsTab a, body#reports #mainNav li#reportsTab a, -body#search #mainNav li#searchTab a { +body#search #mainNav li#searchTab a, +body#api #mainNav li#apiTab a { background-color: #eee; color: #000; }