Skip to content

Commit d6e7f61

Browse files
committed
Add examples/getbug_restapi.py
Just a little example for using force_rest=True Signed-off-by: Cole Robinson <[email protected]>
1 parent 8b34269 commit d6e7f61

1 file changed

Lines changed: 31 additions & 0 deletions

File tree

examples/getbug_restapi.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/usr/bin/env python
2+
#
3+
# This work is licensed under the GNU GPLv2 or later.
4+
# See the COPYING file in the top-level directory.
5+
6+
# getbug_restapi.py:
7+
# Simple demonstration of connecting to bugzilla over the REST
8+
# API and printing some bug details.
9+
10+
from __future__ import print_function
11+
12+
import bugzilla
13+
14+
# public test instance of bugzilla.redhat.com. It's okay to make changes
15+
URL = "partner-bugzilla.redhat.com"
16+
17+
# By default, if plain Bugzilla(URL) is invoked, the Bugzilla class will
18+
# attempt to determine if XMLRPC or REST API is available, with a preference
19+
# for XMLRPC for back compatability. But you can for use for the REST API
20+
# with force_rest=True
21+
bzapi = bugzilla.Bugzilla(URL, force_rest=True)
22+
23+
# After that, the bugzilla API can be used as normal. See getbug.py for
24+
# some more info here.
25+
bug = bzapi.getbug(427301)
26+
print("Fetched bug #%s:" % bug.id)
27+
print(" Product = %s" % bug.product)
28+
print(" Component = %s" % bug.component)
29+
print(" Status = %s" % bug.status)
30+
print(" Resolution= %s" % bug.resolution)
31+
print(" Summary = %s" % bug.summary)

0 commit comments

Comments
 (0)