From d87e684700aecaaa16c7aa7119f4d202b231653a Mon Sep 17 00:00:00 2001 From: Tomas Kopecek Date: Thu, 22 Apr 2021 09:33:26 +0200 Subject: [PATCH] web: additional info on API page Related: https://pagure.io/koji/issue/2825 --- www/kojiweb/api.chtml | 20 ++++++++++++++++++++ www/kojiweb/index.py | 1 + 2 files changed, 21 insertions(+) diff --git a/www/kojiweb/api.chtml b/www/kojiweb/api.chtml index 1a23dbf5..ea2fb3c8 100644 --- a/www/kojiweb/api.chtml +++ b/www/kojiweb/api.chtml @@ -3,6 +3,26 @@

API reference (hub version: $koji_version, web version: $koji.__version__)

+Various constants used in API calls can be found in first part of koji module. +Exceptions which can be raised in python client are just after constants section. + +Basic anonymous client in python would look like this: + +
+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")
+
+ +

List of API calls