File: _backendbase.py

package info (click to toggle)
python-bugzilla 3.0.2-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, sid
  • size: 1,072 kB
  • sloc: python: 5,760; makefile: 9
file content (288 lines) | stat: -rw-r--r-- 8,223 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
# This work is licensed under the GNU GPLv2 or later.
# See the COPYING file in the top-level directory.

from logging import getLogger

import requests

log = getLogger(__name__)


class _BackendBase(object):
    """
    Backends are thin wrappers around the different bugzilla API paradigms
    (XMLRPC, REST). This base class defines the public API for the rest of
    the code, but this is all internal to the library.
    """
    def __init__(self, url, bugzillasession):
        self._url = url
        self._bugzillasession = bugzillasession


    @staticmethod
    def probe(url):
        try:
            requests.head(url).raise_for_status()
            return True  # pragma: no cover
        except Exception as e:
            log.debug("Failed to probe url=%s : %s", url, str(e))
        return False


    #################
    # Internal APIs #
    #################

    def get_xmlrpc_proxy(self):
        """
        Provides the raw XMLRPC proxy to API users of Bugzilla._proxy
        """
        raise NotImplementedError()

    def is_rest(self):
        """
        :returns: True if this is the REST backend
        """
        return False

    def is_xmlrpc(self):
        """
        :returns: True if this is the XMLRPC backend
        """
        return False


    ######################
    # Bugzilla info APIs #
    ######################

    def bugzilla_version(self):
        """
        Fetch bugzilla version string
        http://bugzilla.readthedocs.io/en/latest/api/core/v1/bugzilla.html#version
        """
        raise NotImplementedError()


    #######################
    # Bug attachment APIs #
    #######################

    def bug_attachment_get(self, attachment_ids, paramdict):
        """
        Fetch bug attachments IDs. One part of:
        http://bugzilla.readthedocs.io/en/latest/api/core/v1/attachment.html#get-attachment
        """
        raise NotImplementedError()

    def bug_attachment_get_all(self, bug_ids, paramdict):
        """
        Fetch all bug attachments IDs. One part of
        http://bugzilla.readthedocs.io/en/latest/api/core/v1/attachment.html#get-attachment
        """
        raise NotImplementedError()

    def bug_attachment_create(self, bug_ids, data, paramdict):
        """
        Create a bug attachment
        http://bugzilla.readthedocs.io/en/latest/api/core/v1/attachment.html#create-attachment

        :param data: raw Bytes data of the attachment to attach. API will
            encode this correctly if you pass it in and 'data' is not in
            paramdict.
        """
        raise NotImplementedError()

    def bug_attachment_update(self, attachment_ids, paramdict):
        """
        Update a bug attachment
        http://bugzilla.readthedocs.io/en/latest/api/core/v1/attachment.html#update-attachment
        """
        raise NotImplementedError()


    ############
    # bug APIs #
    ############

    def bug_comments(self, bug_ids, paramdict):
        """
        Fetch bug comments
        http://bugzilla.readthedocs.io/en/latest/api/core/v1/comment.html#get-comments
        """
        raise NotImplementedError()

    def bug_create(self, paramdict):
        """
        Create a new bug
        http://bugzilla.readthedocs.io/en/latest/api/core/v1/bug.html#create-bug
        """
        raise NotImplementedError()

    def bug_fields(self, paramdict):
        """
        Query available bug field values
        http://bugzilla.readthedocs.io/en/latest/api/core/v1/field.html#fields
        """
        raise NotImplementedError()

    def bug_get(self, bug_ids, aliases, paramdict):
        """
        Lookup bug data by ID
        http://bugzilla.readthedocs.io/en/latest/api/core/v1/bug.html#get-bug
        """
        raise NotImplementedError()

    def bug_history(self, bug_ids, paramdict):
        """
        Lookup bug history
        http://bugzilla.readthedocs.io/en/latest/api/core/v1/bug.html#bug-history
        """
        raise NotImplementedError()

    def bug_search(self, paramdict):
        """
        Search/query bugs
        http://bugzilla.readthedocs.io/en/latest/api/core/v1/bug.html#search-bugs
        """
        raise NotImplementedError()

    def bug_update(self, bug_ids, paramdict):
        """
        Update bugs
        http://bugzilla.readthedocs.io/en/latest/api/core/v1/bug.html#update-bug
        """
        raise NotImplementedError()

    def bug_update_tags(self, bug_ids, paramdict):
        """
        Update bug tags
        https://www.bugzilla.org/docs/4.4/en/html/api/Bugzilla/WebService/Bug.html#update_tags
        """
        raise NotImplementedError()


    ##################
    # Component APIs #
    ##################

    def component_create(self, paramdict):
        """
        Create component
        https://bugzilla.readthedocs.io/en/latest/api/core/v1/component.html#create-component
        """
        raise NotImplementedError()

    def component_update(self, paramdict):
        """
        Update component
        https://bugzilla.readthedocs.io/en/latest/api/core/v1/component.html#update-component
        """
        raise NotImplementedError()


    ###############################
    # ExternalBugs extension APIs #
    ###############################

    def externalbugs_add(self, paramdict):
        """
        https://bugzilla.redhat.com/docs/en/html/integrating/api/Bugzilla/Extension/ExternalBugs/WebService.html#add-external-bug
        """
        raise NotImplementedError()

    def externalbugs_update(self, paramdict):
        """
        https://bugzilla.redhat.com/docs/en/html/integrating/api/Bugzilla/Extension/ExternalBugs/WebService.html#update-external-bug
        """
        raise NotImplementedError()

    def externalbugs_remove(self, paramdict):
        """
        https://bugzilla.redhat.com/docs/en/html/integrating/api/Bugzilla/Extension/ExternalBugs/WebService.html#remove-external-bug
        """
        raise NotImplementedError()


    ##############
    # Group APIs #
    ##############

    def group_get(self, paramdict):
        """
        https://bugzilla.readthedocs.io/en/latest/api/core/v1/group.html#get-group
        """
        raise NotImplementedError()


    ################
    # Product APIs #
    ################

    def product_get(self, paramdict):
        """
        Fetch product details
        http://bugzilla.readthedocs.io/en/latest/api/core/v1/product.html#get-product
        """
        raise NotImplementedError()

    def product_get_accessible(self):
        """
        List accessible products
        http://bugzilla.readthedocs.io/en/latest/api/core/v1/product.html#list-products
        """
        raise NotImplementedError()

    def product_get_enterable(self):
        """
        List enterable products
        http://bugzilla.readthedocs.io/en/latest/api/core/v1/product.html#list-products
        """
        raise NotImplementedError()

    def product_get_selectable(self):
        """
        List selectable products
        http://bugzilla.readthedocs.io/en/latest/api/core/v1/product.html#list-products
        """
        raise NotImplementedError()


    #############
    # User APIs #
    #############

    def user_create(self, paramdict):
        """
        Create user
        http://bugzilla.readthedocs.io/en/latest/api/core/v1/user.html#create-user
        """
        raise NotImplementedError()

    def user_get(self, paramdict):
        """
        Get user info
        http://bugzilla.readthedocs.io/en/latest/api/core/v1/user.html#get-user
        """
        raise NotImplementedError()

    def user_login(self, paramdict):
        """
        Log in to bugzilla
        http://bugzilla.readthedocs.io/en/latest/api/core/v1/user.html#login
        """
        raise NotImplementedError()

    def user_logout(self):
        """
        Log out of bugzilla
        http://bugzilla.readthedocs.io/en/latest/api/core/v1/user.html#logout
        """
        raise NotImplementedError()

    def user_update(self, paramdict):
        """
        Update user
        http://bugzilla.readthedocs.io/en/latest/api/core/v1/user.html#update-user
        """
        raise NotImplementedError()