web: additional info on API page
Related: https://pagure.io/koji/issue/2825
This commit is contained in:
parent
d83c15247c
commit
d87e684700
2 changed files with 21 additions and 0 deletions
|
|
@ -3,6 +3,26 @@
|
||||||
|
|
||||||
<h4>API reference <small>(hub version: $koji_version, web version: $koji.__version__)</small></h4>
|
<h4>API reference <small>(hub version: $koji_version, web version: $koji.__version__)</small></h4>
|
||||||
|
|
||||||
|
Various constants used in API calls can be found in first part of <a
|
||||||
|
href="https://pagure.io/koji/blob/master/f/koji/__init__.py">koji module</a>.
|
||||||
|
Exceptions which can be raised in python client are just after constants section.
|
||||||
|
|
||||||
|
Basic anonymous client in python would look like this:
|
||||||
|
|
||||||
|
<pre>
|
||||||
|
import koji
|
||||||
|
|
||||||
|
mytag = "mytag"
|
||||||
|
session = koji.ClientSession("$koji_hub_url")
|
||||||
|
try:
|
||||||
|
repo_info = session.getRepo(mytag, koji.REPO_STATES["READY"], dist=True)
|
||||||
|
if not repo_info:
|
||||||
|
print(f"There is no active dist repo for {mytag}")
|
||||||
|
except koji.GenericError:
|
||||||
|
print(f"Tag {mytag} doesn't exist")
|
||||||
|
</pre>
|
||||||
|
|
||||||
|
<h4>List of API calls</h4>
|
||||||
<ul>
|
<ul>
|
||||||
#for method in $methods
|
#for method in $methods
|
||||||
<li>
|
<li>
|
||||||
|
|
|
||||||
|
|
@ -2517,6 +2517,7 @@ def api(environ):
|
||||||
values = _initValues(environ, 'API', 'api')
|
values = _initValues(environ, 'API', 'api')
|
||||||
server = _getServer(environ)
|
server = _getServer(environ)
|
||||||
|
|
||||||
|
values['koji_hub_url'] = environ['koji.options']['KojiHubURL']
|
||||||
values['methods'] = sorted(server._listapi(), key=lambda x: x['name'])
|
values['methods'] = sorted(server._listapi(), key=lambda x: x['name'])
|
||||||
try:
|
try:
|
||||||
values['koji_version'] = server.getKojiVersion()
|
values['koji_version'] = server.getKojiVersion()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue