From a1e2d380ae948a42143d7331f308486e8319b6ba Mon Sep 17 00:00:00 2001 From: Tomas Kopecek Date: Apr 26 2021 13:38:29 +0000 Subject: web: additional info on API page Related: https://pagure.io/koji/issue/2825 --- diff --git a/www/kojiweb/api.chtml b/www/kojiweb/api.chtml index 1a23dbf..ea2fb3c 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