# Path: katprep/exceptions.py
# class UnauthenticatedError(RuntimeError):
#     """
#     Exception for showing that a client wasn't able to authenticate itself.
#     """


from abc import ABCMeta, abstractmethod
from requests import Session
from requests.auth import HTTPBasicAuth
from ..exceptions import UnauthenticatedError
        If username and password are given HTTP basic authentication
        will be used.

        :param url: The API URL
        :type url: str
        :param username: API username
        :type username: str
        :param password: corresponding password
        :type password: str
        :param verify_ssl: Control SSL verfication.
        :type verify_ssl: bool
        """
        self._url = url
        self._username = username
        self._password = password
        self._verify_ssl = verify_ssl
        self._session = None

        self._connect()

    def _connect(self):
        """
        This function establishes a connection to the Icinga2 API.
        """
        self._session = Session()

        if self._username:
            self._session.auth = HTTPBasicAuth(self._username, self._password)

        if not self.is_authenticated():

# Path: katprep/exceptions.py
# class UnauthenticatedError(RuntimeError):
#     """
#     Exception for showing that a client wasn't able to authenticate itself.
#     """


# Path: katprep/monitoring/base.py
from abc import ABCMeta, abstractmethod
from requests import Session
from requests.auth import HTTPBasicAuth
from ..exceptions import UnauthenticatedError

        If username and password are given HTTP basic authentication
        will be used.

        :param url: The API URL
        :type url: str
        :param username: API username
        :type username: str
        :param password: corresponding password
        :type password: str
        :param verify_ssl: Control SSL verfication.
        :type verify_ssl: bool
        """
        self._url = url
        self._username = username
        self._password = password
        self._verify_ssl = verify_ssl
        self._session = None

        self._connect()

    def _connect(self):
        """
        This function establishes a connection to the Icinga2 API.
        """
        self._session = Session()

        if self._username:
            self._session.auth = HTTPBasicAuth(self._username, self._password)

        if not self.is_authenticated():

            raise UnauthenticatedError("Unable to authenticate!")