Michal Koutný ccf7f1
# This work is licensed under the GNU GPLv2 or later.
Michal Koutný ccf7f1
# See the COPYING file in the top-level directory.
Michal Koutný ccf7f1
Michal Koutný ccf7f1
from logging import getLogger
Michal Koutný ccf7f1
Michal Koutný ccf7f1
import requests
Michal Koutný ccf7f1
Michal Koutný ccf7f1
log = getLogger(__name__)
Michal Koutný ccf7f1
Michal Koutný ccf7f1
Michal Koutný ccf7f1
class _BackendBase(object):
Michal Koutný ccf7f1
    """
Michal Koutný ccf7f1
    Backends are thin wrappers around the different bugzilla API paradigms
Michal Koutný ccf7f1
    (XMLRPC, REST). This base class defines the public API for the rest of
Michal Koutný ccf7f1
    the code, but this is all internal to the library.
Michal Koutný ccf7f1
    """
Michal Koutný ccf7f1
    def __init__(self, url, bugzillasession):
Michal Koutný ccf7f1
        self._url = url
Michal Koutný ccf7f1
        self._bugzillasession = bugzillasession
Michal Koutný ccf7f1
Michal Koutný ccf7f1
Michal Koutný ccf7f1
    @staticmethod
Michal Koutný ccf7f1
    def probe(url):
Michal Koutný ccf7f1
        try:
Michal Koutný ccf7f1
            requests.head(url).raise_for_status()
Michal Koutný ccf7f1
            return True  # pragma: no cover
Michal Koutný ccf7f1
        except Exception as e:
Michal Koutný ccf7f1
            log.debug("Failed to probe url=%s : %s", url, str(e))
Michal Koutný ccf7f1
        return False
Michal Koutný ccf7f1
Michal Koutný ccf7f1
Michal Koutný ccf7f1
    #################
Michal Koutný ccf7f1
    # Internal APIs #
Michal Koutný ccf7f1
    #################
Michal Koutný ccf7f1
Michal Koutný ccf7f1
    def get_xmlrpc_proxy(self):
Michal Koutný ccf7f1
        """
Michal Koutný ccf7f1
        Provides the raw XMLRPC proxy to API users of Bugzilla._proxy
Michal Koutný ccf7f1
        """
Michal Koutný ccf7f1
        raise NotImplementedError()
Michal Koutný ccf7f1
Michal Koutný ccf7f1
    def is_rest(self):
Michal Koutný ccf7f1
        """
Michal Koutný ccf7f1
        :returns: True if this is the REST backend
Michal Koutný ccf7f1
        """
Michal Koutný ccf7f1
        return False
Michal Koutný ccf7f1
Michal Koutný ccf7f1
    def is_xmlrpc(self):
Michal Koutný ccf7f1
        """
Michal Koutný ccf7f1
        :returns: True if this is the XMLRPC backend
Michal Koutný ccf7f1
        """
Michal Koutný ccf7f1
        return False
Michal Koutný ccf7f1
Michal Koutný ccf7f1
Michal Koutný ccf7f1
    ######################
Michal Koutný ccf7f1
    # Bugzilla info APIs #
Michal Koutný ccf7f1
    ######################
Michal Koutný ccf7f1
Michal Koutný ccf7f1
    def bugzilla_version(self):
Michal Koutný ccf7f1
        """
Michal Koutný ccf7f1
        Fetch bugzilla version string
Michal Koutný ccf7f1
        http://bugzilla.readthedocs.io/en/latest/api/core/v1/bugzilla.html#version
Michal Koutný ccf7f1
        """
Michal Koutný ccf7f1
        raise NotImplementedError()
Michal Koutný ccf7f1
Michal Koutný ccf7f1
Michal Koutný ccf7f1
    #######################
Michal Koutný ccf7f1
    # Bug attachment APIs #
Michal Koutný ccf7f1
    #######################
Michal Koutný ccf7f1
Michal Koutný ccf7f1
    def bug_attachment_get(self, attachment_ids, paramdict):
Michal Koutný ccf7f1
        """
Michal Koutný ccf7f1
        Fetch bug attachments IDs. One part of:
Michal Koutný ccf7f1
        http://bugzilla.readthedocs.io/en/latest/api/core/v1/attachment.html#get-attachment
Michal Koutný ccf7f1
        """
Michal Koutný ccf7f1
        raise NotImplementedError()
Michal Koutný ccf7f1
Michal Koutný ccf7f1
    def bug_attachment_get_all(self, bug_ids, paramdict):
Michal Koutný ccf7f1
        """
Michal Koutný ccf7f1
        Fetch all bug attachments IDs. One part of
Michal Koutný ccf7f1
        http://bugzilla.readthedocs.io/en/latest/api/core/v1/attachment.html#get-attachment
Michal Koutný ccf7f1
        """
Michal Koutný ccf7f1
        raise NotImplementedError()
Michal Koutný ccf7f1
Michal Koutný ccf7f1
    def bug_attachment_create(self, bug_ids, data, paramdict):
Michal Koutný ccf7f1
        """
Michal Koutný ccf7f1
        Create a bug attachment
Michal Koutný ccf7f1
        http://bugzilla.readthedocs.io/en/latest/api/core/v1/attachment.html#create-attachment
Michal Koutný ccf7f1
Michal Koutný ccf7f1
        :param data: raw Bytes data of the attachment to attach. API will
Michal Koutný ccf7f1
            encode this correctly if you pass it in and 'data' is not in
Michal Koutný ccf7f1
            paramdict.
Michal Koutný ccf7f1
        """
Michal Koutný ccf7f1
        raise NotImplementedError()
Michal Koutný ccf7f1
Michal Koutný ccf7f1
    def bug_attachment_update(self, attachment_ids, paramdict):
Michal Koutný ccf7f1
        """
Michal Koutný ccf7f1
        Update a bug attachment
Michal Koutný ccf7f1
        http://bugzilla.readthedocs.io/en/latest/api/core/v1/attachment.html#update-attachment
Michal Koutný ccf7f1
        """
Michal Koutný ccf7f1
        raise NotImplementedError()
Michal Koutný ccf7f1
Michal Koutný ccf7f1
Michal Koutný ccf7f1
    ############
Michal Koutný ccf7f1
    # bug APIs #
Michal Koutný ccf7f1
    ############
Michal Koutný ccf7f1
Michal Koutný ccf7f1
    def bug_comments(self, bug_ids, paramdict):
Michal Koutný ccf7f1
        """
Michal Koutný ccf7f1
        Fetch bug comments
Michal Koutný ccf7f1
        http://bugzilla.readthedocs.io/en/latest/api/core/v1/comment.html#get-comments
Michal Koutný ccf7f1
        """
Michal Koutný ccf7f1
        raise NotImplementedError()
Michal Koutný ccf7f1
Michal Koutný ccf7f1
    def bug_create(self, paramdict):
Michal Koutný ccf7f1
        """
Michal Koutný ccf7f1
        Create a new bug
Michal Koutný ccf7f1
        http://bugzilla.readthedocs.io/en/latest/api/core/v1/bug.html#create-bug
Michal Koutný ccf7f1
        """
Michal Koutný ccf7f1
        raise NotImplementedError()
Michal Koutný ccf7f1
Michal Koutný ccf7f1
    def bug_fields(self, paramdict):
Michal Koutný ccf7f1
        """
Michal Koutný ccf7f1
        Query available bug field values
Michal Koutný ccf7f1
        http://bugzilla.readthedocs.io/en/latest/api/core/v1/field.html#fields
Michal Koutný ccf7f1
        """
Michal Koutný ccf7f1
        raise NotImplementedError()
Michal Koutný ccf7f1
Michal Koutný ccf7f1
    def bug_get(self, bug_ids, aliases, paramdict):
Michal Koutný ccf7f1
        """
Michal Koutný ccf7f1
        Lookup bug data by ID
Michal Koutný ccf7f1
        http://bugzilla.readthedocs.io/en/latest/api/core/v1/bug.html#get-bug
Michal Koutný ccf7f1
        """
Michal Koutný ccf7f1
        raise NotImplementedError()
Michal Koutný ccf7f1
Michal Koutný ccf7f1
    def bug_history(self, bug_ids, paramdict):
Michal Koutný ccf7f1
        """
Michal Koutný ccf7f1
        Lookup bug history
Michal Koutný ccf7f1
        http://bugzilla.readthedocs.io/en/latest/api/core/v1/bug.html#bug-history
Michal Koutný ccf7f1
        """
Michal Koutný ccf7f1
        raise NotImplementedError()
Michal Koutný ccf7f1
Michal Koutný ccf7f1
    def bug_search(self, paramdict):
Michal Koutný ccf7f1
        """
Michal Koutný ccf7f1
        Search/query bugs
Michal Koutný ccf7f1
        http://bugzilla.readthedocs.io/en/latest/api/core/v1/bug.html#search-bugs
Michal Koutný ccf7f1
        """
Michal Koutný ccf7f1
        raise NotImplementedError()
Michal Koutný ccf7f1
Michal Koutný ccf7f1
    def bug_update(self, bug_ids, paramdict):
Michal Koutný ccf7f1
        """
Michal Koutný ccf7f1
        Update bugs
Michal Koutný ccf7f1
        http://bugzilla.readthedocs.io/en/latest/api/core/v1/bug.html#update-bug
Michal Koutný ccf7f1
        """
Michal Koutný ccf7f1
        raise NotImplementedError()
Michal Koutný ccf7f1
Michal Koutný ccf7f1
    def bug_update_tags(self, bug_ids, paramdict):
Michal Koutný ccf7f1
        """
Michal Koutný ccf7f1
        Update bug tags
Michal Koutný ccf7f1
        https://www.bugzilla.org/docs/4.4/en/html/api/Bugzilla/WebService/Bug.html#update_tags
Michal Koutný ccf7f1
        """
Michal Koutný ccf7f1
        raise NotImplementedError()
Michal Koutný ccf7f1
Michal Koutný ccf7f1
Michal Koutný ccf7f1
    ##################
Michal Koutný ccf7f1
    # Component APIs #
Michal Koutný ccf7f1
    ##################
Michal Koutný ccf7f1
Michal Koutný ccf7f1
    def component_create(self, paramdict):
Michal Koutný ccf7f1
        """
Michal Koutný ccf7f1
        Create component
Michal Koutný ccf7f1
        https://bugzilla.readthedocs.io/en/latest/api/core/v1/component.html#create-component
Michal Koutný ccf7f1
        """
Michal Koutný ccf7f1
        raise NotImplementedError()
Michal Koutný ccf7f1
Michal Koutný ccf7f1
    def component_update(self, paramdict):
Michal Koutný ccf7f1
        """
Michal Koutný ccf7f1
        Update component
Michal Koutný ccf7f1
        https://bugzilla.readthedocs.io/en/latest/api/core/v1/component.html#update-component
Michal Koutný ccf7f1
        """
Michal Koutný ccf7f1
        raise NotImplementedError()
Michal Koutný ccf7f1
Michal Koutný ccf7f1
Michal Koutný ccf7f1
    ###############################
Michal Koutný ccf7f1
    # ExternalBugs extension APIs #
Michal Koutný ccf7f1
    ###############################
Michal Koutný ccf7f1
Michal Koutný ccf7f1
    def externalbugs_add(self, paramdict):
Michal Koutný ccf7f1
        """
Michal Koutný ccf7f1
        https://bugzilla.redhat.com/docs/en/html/integrating/api/Bugzilla/Extension/ExternalBugs/WebService.html#add-external-bug
Michal Koutný ccf7f1
        """
Michal Koutný ccf7f1
        raise NotImplementedError()
Michal Koutný ccf7f1
Michal Koutný ccf7f1
    def externalbugs_update(self, paramdict):
Michal Koutný ccf7f1
        """
Michal Koutný ccf7f1
        https://bugzilla.redhat.com/docs/en/html/integrating/api/Bugzilla/Extension/ExternalBugs/WebService.html#update-external-bug
Michal Koutný ccf7f1
        """
Michal Koutný ccf7f1
        raise NotImplementedError()
Michal Koutný ccf7f1
Michal Koutný ccf7f1
    def externalbugs_remove(self, paramdict):
Michal Koutný ccf7f1
        """
Michal Koutný ccf7f1
        https://bugzilla.redhat.com/docs/en/html/integrating/api/Bugzilla/Extension/ExternalBugs/WebService.html#remove-external-bug
Michal Koutný ccf7f1
        """
Michal Koutný ccf7f1
        raise NotImplementedError()
Michal Koutný ccf7f1
Michal Koutný ccf7f1
Michal Koutný ccf7f1
    ##############
Michal Koutný ccf7f1
    # Group APIs #
Michal Koutný ccf7f1
    ##############
Michal Koutný ccf7f1
Michal Koutný ccf7f1
    def group_get(self, paramdict):
Michal Koutný ccf7f1
        """
Michal Koutný ccf7f1
        https://bugzilla.readthedocs.io/en/latest/api/core/v1/group.html#get-group
Michal Koutný ccf7f1
        """
Michal Koutný ccf7f1
        raise NotImplementedError()
Michal Koutný ccf7f1
Michal Koutný ccf7f1
Michal Koutný ccf7f1
    ################
Michal Koutný ccf7f1
    # Product APIs #
Michal Koutný ccf7f1
    ################
Michal Koutný ccf7f1
Michal Koutný ccf7f1
    def product_get(self, paramdict):
Michal Koutný ccf7f1
        """
Michal Koutný ccf7f1
        Fetch product details
Michal Koutný ccf7f1
        http://bugzilla.readthedocs.io/en/latest/api/core/v1/product.html#get-product
Michal Koutný ccf7f1
        """
Michal Koutný ccf7f1
        raise NotImplementedError()
Michal Koutný ccf7f1
Michal Koutný ccf7f1
    def product_get_accessible(self):
Michal Koutný ccf7f1
        """
Michal Koutný ccf7f1
        List accessible products
Michal Koutný ccf7f1
        http://bugzilla.readthedocs.io/en/latest/api/core/v1/product.html#list-products
Michal Koutný ccf7f1
        """
Michal Koutný ccf7f1
        raise NotImplementedError()
Michal Koutný ccf7f1
Michal Koutný ccf7f1
    def product_get_enterable(self):
Michal Koutný ccf7f1
        """
Michal Koutný ccf7f1
        List enterable products
Michal Koutný ccf7f1
        http://bugzilla.readthedocs.io/en/latest/api/core/v1/product.html#list-products
Michal Koutný ccf7f1
        """
Michal Koutný ccf7f1
        raise NotImplementedError()
Michal Koutný ccf7f1
Michal Koutný ccf7f1
    def product_get_selectable(self):
Michal Koutný ccf7f1
        """
Michal Koutný ccf7f1
        List selectable products
Michal Koutný ccf7f1
        http://bugzilla.readthedocs.io/en/latest/api/core/v1/product.html#list-products
Michal Koutný ccf7f1
        """
Michal Koutný ccf7f1
        raise NotImplementedError()
Michal Koutný ccf7f1
Michal Koutný ccf7f1
Michal Koutný ccf7f1
    #############
Michal Koutný ccf7f1
    # User APIs #
Michal Koutný ccf7f1
    #############
Michal Koutný ccf7f1
Michal Koutný ccf7f1
    def user_create(self, paramdict):
Michal Koutný ccf7f1
        """
Michal Koutný ccf7f1
        Create user
Michal Koutný ccf7f1
        http://bugzilla.readthedocs.io/en/latest/api/core/v1/user.html#create-user
Michal Koutný ccf7f1
        """
Michal Koutný ccf7f1
        raise NotImplementedError()
Michal Koutný ccf7f1
Michal Koutný ccf7f1
    def user_get(self, paramdict):
Michal Koutný ccf7f1
        """
Michal Koutný ccf7f1
        Get user info
Michal Koutný ccf7f1
        http://bugzilla.readthedocs.io/en/latest/api/core/v1/user.html#get-user
Michal Koutný ccf7f1
        """
Michal Koutný ccf7f1
        raise NotImplementedError()
Michal Koutný ccf7f1
Michal Koutný ccf7f1
    def user_login(self, paramdict):
Michal Koutný ccf7f1
        """
Michal Koutný ccf7f1
        Log in to bugzilla
Michal Koutný ccf7f1
        http://bugzilla.readthedocs.io/en/latest/api/core/v1/user.html#login
Michal Koutný ccf7f1
        """
Michal Koutný ccf7f1
        raise NotImplementedError()
Michal Koutný ccf7f1
Michal Koutný ccf7f1
    def user_logout(self):
Michal Koutný ccf7f1
        """
Michal Koutný ccf7f1
        Log out of bugzilla
Michal Koutný ccf7f1
        http://bugzilla.readthedocs.io/en/latest/api/core/v1/user.html#logout
Michal Koutný ccf7f1
        """
Michal Koutný ccf7f1
        raise NotImplementedError()
Michal Koutný ccf7f1
Michal Koutný ccf7f1
    def user_update(self, paramdict):
Michal Koutný ccf7f1
        """
Michal Koutný ccf7f1
        Update user
Michal Koutný ccf7f1
        http://bugzilla.readthedocs.io/en/latest/api/core/v1/user.html#update-user
Michal Koutný ccf7f1
        """
Michal Koutný ccf7f1
        raise NotImplementedError()