# Path: marvin_python_toolbox/common/utils.py
# def to_json(data):
#     """Convert non default objects to json."""
#     return json.dumps(data, default=_to_json_default)
# 
# Path: marvin_python_toolbox/_compatibility.py

# 
# Path: marvin_python_toolbox/_logging.py
# def get_logger(name, namespace='marvin_python_toolbox',
#                log_level=DEFAULT_LOG_LEVEL, log_dir=DEFAULT_LOG_DIR):
#     """Build a logger that outputs to a file and to the console,"""
# 
#     log_level = (os.getenv('{}_LOG_LEVEL'.format(namespace.upper())) or
#                  os.getenv('LOG_LEVEL', log_level))
#     log_dir = (os.getenv('{}_LOG_DIR'.format(namespace.upper())) or
#                os.getenv('LOG_DIR', log_dir))
# 
#     logger = logging.getLogger('{}.{}'.format(namespace, name))
#     logger.setLevel(log_level)
# 
#     formatter = logging.Formatter(
#         '%(asctime)s - %(name)s - %(levelname)s - %(message)s')
# 
#     # Create a console stream handler
#     console_handler = logging.StreamHandler()
#     console_handler.setLevel(log_level)
#     console_handler.setFormatter(formatter)
#     logger.addHandler(console_handler)
# 
#     try:
#         log_path = os.path.abspath(log_dir)
#         log_filename = '{name}.{pid}.log'.format(
#             name=namespace, pid=os.getpid())
# 
#         file_path = str(os.path.join(log_path, log_filename))
# 
#         if not os.path.exists(log_path):  # pragma: no cover
#             os.makedirs(log_path, mode=774)
# 
#         # Create a file handler
#         file_handler = logging.FileHandler(file_path)
#         file_handler.setLevel(log_level)
#         file_handler.setFormatter(formatter)
#         logger.addHandler(file_handler)
#     except OSError as e:
#         logger.error('Could not create log file {file}: {error}'.format(
#             file=file_path, error=e.strerror))
# 
#     return logger
# 
# Path: marvin_python_toolbox/common/exceptions.py
# class HTTPException(HTTPExceptionBase):
#     """
#     HTTP exception
#     """


import requests
import math
from .utils import to_json
from .._compatibility import six
from .._logging import get_logger
from .exceptions import HTTPException
                errors = response.json()
            except ValueError:
                errors = response.content
            return HttpResponse(ok=response.ok, status=status, errors=errors, data=None)

    def request_header(self):
        """
        Build a headers dict with:
          - the content type as json

        :return: [dict] headers dict
        """
        return {
            'Content-Type': 'application/json',
            'Csrf-Token': 'nocheck',
        }

    def get_all(self, path, data=None, limit=100):
        """Encapsulates GET all requests"""
        return ListResultSet(path=path, data=data or {}, limit=limit)

    def get(self, path, data=None):
        """Encapsulates GET requests"""
        data = data or {}
        response = requests.get(self.url(path), params=data, headers=self.request_header())
        return self.parse_response(response)

    def post(self, path, data=None):
        """Encapsulates POST requests"""
        data = data or {}

# Path: marvin_python_toolbox/common/utils.py
# def to_json(data):
#     """Convert non default objects to json."""
#     return json.dumps(data, default=_to_json_default)
# 
# Path: marvin_python_toolbox/_compatibility.py

# 
# Path: marvin_python_toolbox/_logging.py
# def get_logger(name, namespace='marvin_python_toolbox',
#                log_level=DEFAULT_LOG_LEVEL, log_dir=DEFAULT_LOG_DIR):
#     """Build a logger that outputs to a file and to the console,"""
# 
#     log_level = (os.getenv('{}_LOG_LEVEL'.format(namespace.upper())) or
#                  os.getenv('LOG_LEVEL', log_level))
#     log_dir = (os.getenv('{}_LOG_DIR'.format(namespace.upper())) or
#                os.getenv('LOG_DIR', log_dir))
# 
#     logger = logging.getLogger('{}.{}'.format(namespace, name))
#     logger.setLevel(log_level)
# 
#     formatter = logging.Formatter(
#         '%(asctime)s - %(name)s - %(levelname)s - %(message)s')
# 
#     # Create a console stream handler
#     console_handler = logging.StreamHandler()
#     console_handler.setLevel(log_level)
#     console_handler.setFormatter(formatter)
#     logger.addHandler(console_handler)
# 
#     try:
#         log_path = os.path.abspath(log_dir)
#         log_filename = '{name}.{pid}.log'.format(
#             name=namespace, pid=os.getpid())
# 
#         file_path = str(os.path.join(log_path, log_filename))
# 
#         if not os.path.exists(log_path):  # pragma: no cover
#             os.makedirs(log_path, mode=774)
# 
#         # Create a file handler
#         file_handler = logging.FileHandler(file_path)
#         file_handler.setLevel(log_level)
#         file_handler.setFormatter(formatter)
#         logger.addHandler(file_handler)
#     except OSError as e:
#         logger.error('Could not create log file {file}: {error}'.format(
#             file=file_path, error=e.strerror))
# 
#     return logger
# 
# Path: marvin_python_toolbox/common/exceptions.py
# class HTTPException(HTTPExceptionBase):
#     """
#     HTTP exception
#     """


# Path: marvin_python_toolbox/common/http_client.py
import requests
import math
from .utils import to_json
from .._compatibility import six
from .._logging import get_logger
from .exceptions import HTTPException

                errors = response.json()
            except ValueError:
                errors = response.content
            return HttpResponse(ok=response.ok, status=status, errors=errors, data=None)

    def request_header(self):
        """
        Build a headers dict with:
          - the content type as json

        :return: [dict] headers dict
        """
        return {
            'Content-Type': 'application/json',
            'Csrf-Token': 'nocheck',
        }

    def get_all(self, path, data=None, limit=100):
        """Encapsulates GET all requests"""
        return ListResultSet(path=path, data=data or {}, limit=limit)

    def get(self, path, data=None):
        """Encapsulates GET requests"""
        data = data or {}
        response = requests.get(self.url(path), params=data, headers=self.request_header())
        return self.parse_response(response)

    def post(self, path, data=None):
        """Encapsulates POST requests"""
        data = data or {}

        response = requests.post(self.url(path), data=to_json(data), headers=self.request_header())