Skip to content

Commit cd059e1

Browse files
committed
Add _Backend API and _BackendXMLRPC implementation
_Backend is a class that provides thin wrappers around raw bugzilla API calls. Implement it for XMLRPC, and convert all the internal code to use it. In the future we will add a REST implementation. Signed-off-by: Cole Robinson <[email protected]>
1 parent 1c193ba commit cd059e1

4 files changed

Lines changed: 383 additions & 95 deletions

File tree

bugzilla/_backendbase.py

Lines changed: 234 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,234 @@
1+
# This work is licensed under the GNU GPLv2 or later.
2+
# See the COPYING file in the top-level directory.
3+
4+
5+
class _BackendBase(object):
6+
"""
7+
Backends are thin wrappers around the different bugzilla API paradigms
8+
(XMLRPC, REST). This base class defines the public API for the rest of
9+
the code, but this is all internal to the library.
10+
"""
11+
def __init__(self, bugzillasession):
12+
self._bugzillasession = bugzillasession
13+
14+
#################
15+
# Internal APIs #
16+
#################
17+
18+
def get_xmlrpc_proxy(self):
19+
"""
20+
Provides the raw XMLRPC proxy to API users of Bugzilla._proxy
21+
"""
22+
raise NotImplementedError()
23+
24+
25+
######################
26+
# Bugzilla info APIs #
27+
######################
28+
29+
def bugzilla_version(self):
30+
"""
31+
Fetch bugzilla version string
32+
http://bugzilla.readthedocs.io/en/latest/api/core/v1/bugzilla.html#version
33+
"""
34+
raise NotImplementedError()
35+
36+
def bugzilla_extensions(self):
37+
"""
38+
Return info about Bugzilla extensions
39+
http://bugzilla.readthedocs.io/en/latest/api/core/v1/bugzilla.html#extensions
40+
"""
41+
raise NotImplementedError()
42+
43+
44+
#######################
45+
# Bug attachment APIs #
46+
#######################
47+
48+
def bug_attachment_get(self, attachment_ids, paramdict):
49+
"""
50+
Fetch bug attachments IDs. One part of:
51+
http://bugzilla.readthedocs.io/en/latest/api/core/v1/attachment.html#get-attachment
52+
"""
53+
raise NotImplementedError()
54+
55+
def bug_attachment_get_all(self, bug_ids, paramdict):
56+
"""
57+
Fetch all bug attachments IDs. One part of
58+
http://bugzilla.readthedocs.io/en/latest/api/core/v1/attachment.html#get-attachment
59+
"""
60+
raise NotImplementedError()
61+
62+
def bug_attachment_create(self, paramdict):
63+
"""
64+
Create a bug attachment
65+
http://bugzilla.readthedocs.io/en/latest/api/core/v1/attachment.html#create-attachment
66+
"""
67+
raise NotImplementedError()
68+
69+
def bug_attachment_update(self, paramdict):
70+
"""
71+
Update a bug attachment
72+
http://bugzilla.readthedocs.io/en/latest/api/core/v1/attachment.html#update-attachment
73+
"""
74+
raise NotImplementedError()
75+
76+
77+
############
78+
# bug APIs #
79+
############
80+
81+
def bug_comments(self, paramdict):
82+
"""
83+
Fetch bug comments
84+
http://bugzilla.readthedocs.io/en/latest/api/core/v1/comment.html#get-comments
85+
"""
86+
raise NotImplementedError()
87+
88+
def bug_create(self, paramdict):
89+
"""
90+
Create a new bug
91+
http://bugzilla.readthedocs.io/en/latest/api/core/v1/bug.html#create-bug
92+
"""
93+
raise NotImplementedError()
94+
95+
def bug_fields(self, paramdict):
96+
"""
97+
Query available bug field values
98+
http://bugzilla.readthedocs.io/en/latest/api/core/v1/field.html#fields
99+
"""
100+
raise NotImplementedError()
101+
102+
def bug_get(self, paramdict):
103+
"""
104+
Lookup bug data by ID
105+
http://bugzilla.readthedocs.io/en/latest/api/core/v1/bug.html#get-bug
106+
"""
107+
raise NotImplementedError()
108+
109+
def bug_history(self, paramdict):
110+
"""
111+
Lookup bug history
112+
http://bugzilla.readthedocs.io/en/latest/api/core/v1/bug.html#bug-history
113+
"""
114+
raise NotImplementedError()
115+
116+
def bug_legal_values(self, paramdict):
117+
"""
118+
Old style fields querying
119+
http://bugzilla.readthedocs.io/en/latest/api/core/v1/field.html#legal-values
120+
"""
121+
raise NotImplementedError()
122+
123+
def bug_search(self, paramdict):
124+
"""
125+
Search/query bugs
126+
http://bugzilla.readthedocs.io/en/latest/api/core/v1/bug.html#search-bugs
127+
"""
128+
raise NotImplementedError()
129+
130+
def bug_update(self, paramdict):
131+
"""
132+
Update bugs
133+
http://bugzilla.readthedocs.io/en/latest/api/core/v1/bug.html#update-bug
134+
"""
135+
raise NotImplementedError()
136+
137+
def bug_update_tags(self, paramdict):
138+
"""
139+
Update bug tags
140+
https://www.bugzilla.org/docs/4.4/en/html/api/Bugzilla/WebService/Bug.html#update_tags
141+
"""
142+
raise NotImplementedError()
143+
144+
145+
##################
146+
# Component APIs #
147+
##################
148+
149+
def component_create(self, paramdict):
150+
"""
151+
Create component
152+
https://bugzilla.readthedocs.io/en/latest/api/core/v1/component.html#create-component
153+
"""
154+
raise NotImplementedError()
155+
156+
def component_update(self, paramdict):
157+
"""
158+
Update component
159+
https://bugzilla.readthedocs.io/en/latest/api/core/v1/component.html#update-component
160+
"""
161+
raise NotImplementedError()
162+
163+
164+
################
165+
# Product APIs #
166+
################
167+
168+
def product_get(self, paramdict):
169+
"""
170+
Fetch product details
171+
http://bugzilla.readthedocs.io/en/latest/api/core/v1/product.html#get-product
172+
"""
173+
raise NotImplementedError()
174+
175+
def product_get_accessible(self):
176+
"""
177+
List accessible products
178+
http://bugzilla.readthedocs.io/en/latest/api/core/v1/product.html#list-products
179+
"""
180+
raise NotImplementedError()
181+
182+
def product_get_enterable(self):
183+
"""
184+
List enterable products
185+
http://bugzilla.readthedocs.io/en/latest/api/core/v1/product.html#list-products
186+
"""
187+
raise NotImplementedError()
188+
189+
def product_get_selectable(self):
190+
"""
191+
List selectable products
192+
http://bugzilla.readthedocs.io/en/latest/api/core/v1/product.html#list-products
193+
"""
194+
raise NotImplementedError()
195+
196+
197+
#############
198+
# User APIs #
199+
#############
200+
201+
def user_create(self, paramdict):
202+
"""
203+
Create user
204+
http://bugzilla.readthedocs.io/en/latest/api/core/v1/user.html#create-user
205+
"""
206+
raise NotImplementedError()
207+
208+
def user_get(self, paramdict):
209+
"""
210+
Get user info
211+
http://bugzilla.readthedocs.io/en/latest/api/core/v1/user.html#get-user
212+
"""
213+
raise NotImplementedError()
214+
215+
def user_login(self, paramdict):
216+
"""
217+
Log in to bugzilla
218+
http://bugzilla.readthedocs.io/en/latest/api/core/v1/user.html#login
219+
"""
220+
raise NotImplementedError()
221+
222+
def user_logout(self):
223+
"""
224+
Log out of bugzilla
225+
http://bugzilla.readthedocs.io/en/latest/api/core/v1/user.html#logout
226+
"""
227+
raise NotImplementedError()
228+
229+
def user_update(self, paramdict):
230+
"""
231+
Update user
232+
http://bugzilla.readthedocs.io/en/latest/api/core/v1/user.html#update-user
233+
"""
234+
raise NotImplementedError()

bugzilla/_backendxmlrpc.py

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
# This work is licensed under the GNU GPLv2 or later.
2+
# See the COPYING file in the top-level directory.
3+
4+
from ._backendbase import _BackendBase
5+
from .transport import _BugzillaXMLRPCProxy
6+
from ._util import listify
7+
8+
9+
class _BackendXMLRPC(_BackendBase):
10+
"""
11+
Internal interface for direct calls to bugzilla's XMLRPC API
12+
"""
13+
def __init__(self, url, bugzillasession):
14+
_BackendBase.__init__(self, bugzillasession)
15+
self._xmlrpc_proxy = _BugzillaXMLRPCProxy(url, self._bugzillasession)
16+
17+
def get_xmlrpc_proxy(self):
18+
return self._xmlrpc_proxy
19+
20+
def bugzilla_version(self):
21+
return self._xmlrpc_proxy.Bugzilla.version()["version"]
22+
def bugzilla_extensions(self):
23+
return self._xmlrpc_proxy.Bugzilla.extensions()
24+
25+
def bug_attachment_get(self, attachment_ids, paramdict):
26+
data = paramdict.copy()
27+
data["attachment_ids"] = listify(attachment_ids)
28+
return self._xmlrpc_proxy.Bug.attachments(data)
29+
def bug_attachment_get_all(self, bug_ids, paramdict):
30+
data = paramdict.copy()
31+
data["ids"] = listify(bug_ids)
32+
return self._xmlrpc_proxy.Bug.attachments(data)
33+
def bug_attachment_create(self, paramdict):
34+
return self._xmlrpc_proxy.Bug.add_attachment(paramdict)
35+
def bug_attachment_update(self, paramdict):
36+
return self._xmlrpc_proxy.Bug.update_attachment(paramdict)
37+
38+
def bug_comments(self, paramdict):
39+
return self._xmlrpc_proxy.Bug.comments(paramdict)
40+
def bug_create(self, paramdict):
41+
return self._xmlrpc_proxy.Bug.create(paramdict)
42+
def bug_fields(self, paramdict):
43+
return self._xmlrpc_proxy.Bug.fields(paramdict)
44+
def bug_get(self, paramdict):
45+
return self._xmlrpc_proxy.Bug.get(paramdict)
46+
def bug_history(self, paramdict):
47+
return self._xmlrpc_proxy.Bug.history(paramdict)
48+
def bug_legal_values(self, paramdict):
49+
return self._xmlrpc_proxy.Bug.legal_values(paramdict)
50+
def bug_search(self, paramdict):
51+
return self._xmlrpc_proxy.Bug.search(paramdict)
52+
def bug_update(self, paramdict):
53+
return self._xmlrpc_proxy.Bug.update(paramdict)
54+
def bug_update_tags(self, paramdict):
55+
return self._xmlrpc_proxy.Bug.update_tags(paramdict)
56+
57+
def component_create(self, paramdict):
58+
return self._xmlrpc_proxy.Component.create(paramdict)
59+
def component_update(self, paramdict):
60+
return self._xmlrpc_proxy.Component.update(paramdict)
61+
62+
def product_get(self, paramdict):
63+
return self._xmlrpc_proxy.Product.get(paramdict)
64+
def product_get_accessible(self):
65+
return self._xmlrpc_proxy.Product.get_accessible_products()
66+
def product_get_enterable(self):
67+
return self._xmlrpc_proxy.Product.get_enterable_products()
68+
def product_get_selectable(self):
69+
return self._xmlrpc_proxy.Product.get_selectable_products()
70+
71+
def user_create(self, paramdict):
72+
return self._xmlrpc_proxy.User.create(paramdict)
73+
def user_get(self, paramdict):
74+
return self._xmlrpc_proxy.User.get(paramdict)
75+
def user_login(self, paramdict):
76+
return self._xmlrpc_proxy.User.login(paramdict)
77+
def user_logout(self):
78+
return self._xmlrpc_proxy.User.logout()
79+
def user_update(self, paramdict):
80+
return self._xmlrpc_proxy.User.update(paramdict)

0 commit comments

Comments
 (0)