# Path: crabpy/gateway/exception.py
# class GatewayResourceNotFoundException(GatewayException):
#     """
#     An exception that signifies that no results where found.
#     """
#     def __init__(self):
#         GatewayException.__init__(self, 'This resource was not found.')
# 
# Path: crabpy/gateway/exception.py
# class GatewayRuntimeException(GatewayException):
#     """
#     An exception that signifies a soap request went wrong.
# 
#     """
# 
#     soapfault = None
#     """
#     The soapfault that was generated by the service.
#     """
# 
#     def __init__(self, message, soapfault):
#         GatewayException.__init__(self, message)
#         self.soapfault = soapfault


import json
import logging
import requests
        import re
        import re
        import re
        import re
        import re
from dogpile.cache import make_region
from crabpy.gateway.exception import GatewayResourceNotFoundException
from crabpy.gateway.exception import GatewayRuntimeException
.. versionadded:: 0.2.0
"""




log = logging.getLogger(__name__)


def capakey_rest_gateway_request(url, headers={}, params={}):
    """
    Utility function that helps making requests to the CAPAKEY REST service.

    :param string url: URL to request.
    :param dict headers: Headers to send with the URL.
    :param dict params: Parameters to send with the URL.
    :returns: Result of the call.
    """
    try:
        res = requests.get(url, headers=headers, params=params)
        res.raise_for_status()
        return res
    except requests.ConnectionError as ce:
        raise GatewayRuntimeException(
            'Could not execute request due to connection problems:\n%s' % repr(ce),
            ce
        )
    except requests.HTTPError as he:
        raise GatewayResourceNotFoundException()
    except requests.RequestException as re:

# Path: crabpy/gateway/exception.py
# class GatewayResourceNotFoundException(GatewayException):
#     """
#     An exception that signifies that no results where found.
#     """
#     def __init__(self):
#         GatewayException.__init__(self, 'This resource was not found.')
# 
# Path: crabpy/gateway/exception.py
# class GatewayRuntimeException(GatewayException):
#     """
#     An exception that signifies a soap request went wrong.
# 
#     """
# 
#     soapfault = None
#     """
#     The soapfault that was generated by the service.
#     """
# 
#     def __init__(self, message, soapfault):
#         GatewayException.__init__(self, message)
#         self.soapfault = soapfault


# Path: crabpy/gateway/capakey.py
import json
import logging
import requests
        import re
        import re
        import re
        import re
        import re
from dogpile.cache import make_region
from crabpy.gateway.exception import GatewayResourceNotFoundException
from crabpy.gateway.exception import GatewayRuntimeException

.. versionadded:: 0.2.0
"""




log = logging.getLogger(__name__)


def capakey_rest_gateway_request(url, headers={}, params={}):
    """
    Utility function that helps making requests to the CAPAKEY REST service.

    :param string url: URL to request.
    :param dict headers: Headers to send with the URL.
    :param dict params: Parameters to send with the URL.
    :returns: Result of the call.
    """
    try:
        res = requests.get(url, headers=headers, params=params)
        res.raise_for_status()
        return res
    except requests.ConnectionError as ce:
        raise GatewayRuntimeException(
            'Could not execute request due to connection problems:\n%s' % repr(ce),
            ce
        )
    except requests.HTTPError as he:
        raise GatewayResourceNotFoundException()
    except requests.RequestException as re:

        raise GatewayRuntimeException(