# Path: libcloud_rest/api/urls.py

# 
# Path: libcloud_rest/api/validators.py
# class BaseValidator(object):
# class NumericValidator(BaseValidator):
# class IntegerValidator(NumericValidator):
# class FloatValidator(NumericValidator):
# class StringValidator(BaseValidator):
# class BooleanValidator(BaseValidator):
# class NoneValidator(BaseValidator):
# class ConstValidator(BaseValidator):
# class DictValidator(BaseValidator):
# class ChoicesValidator(BaseValidator):
# class TypeValidator(BaseValidator):
#     def __init__(self, *args, **kwargs):
#     def configure(self, args, kwargs):
#     def _get_name(self):
#     def _set_name(self, new_name):
#     def __call__(self, data):
#     def _validate(self):
#     def _check_data(self):
#     def configure(self, args, kwargs):
#     def _check_data(self):
#     def _check_data(self):
#     def _check_data(self):
#     def _check_data(self):
#     def configure(self, args, kwargs):
#     def _check_data(self):
#     def configure(self, args, kwargs):
#     def _check_data(self):
#     def configure(self, args, kwargs):
#     def _check_data(self):
#     def configure(self, args, kwargs):
#     def _check_data(self):
# 
# Path: libcloud_rest/log.py
# def get_logger(handler, level):
# 
# Path: libcloud_rest/constants.py
# MAX_BODY_LENGTH = 512
# 
# Path: libcloud_rest/utils.py
# class JsonResponse(Response):
# class DateTimeJsonEncoder(json.JSONEncoder):
# class OrderedDict(dict):
# class LastUpdatedOrderedDict(OrderedDict):
#     def default(self, obj):
#     def __init__(self, *args, **kwds):
#     def __setitem__(self, key, value, dict_setitem=dict.__setitem__):
#     def __delitem__(self, key, dict_delitem=dict.__delitem__):
#     def __iter__(self):
#     def __reversed__(self):
#     def clear(self):
#     def popitem(self, last=True):
#     def keys(self):
#     def values(self):
#     def items(self):
#     def iterkeys(self):
#     def itervalues(self):
#     def iteritems(self):
#     def update(*args, **kwds):
#     def pop(self, key, default=__marker):
#     def setdefault(self, key, default=None):
#     def __repr__(self, _repr_running={}):
#     def __reduce__(self):
#     def copy(self):
#     def fromkeys(cls, iterable, value=None):
#     def __eq__(self, other):
#     def __ne__(self, other):
#     def viewkeys(self):
#     def viewvalues(self):
#     def viewitems(self):
#     def __setitem__(self, key, value):


import sys
import re
from werkzeug.urls import url_decode
from libcloud_rest.api.urls import urls
from libcloud_rest.api import validators as valid
from libcloud_rest.log import logger
from .errors import LibcloudRestError, InternalError
from libcloud_rest.constants import MAX_BODY_LENGTH
from libcloud_rest.utils import json, Response, Request
            else:
                rv.status_code = status
        if headers is not None:
            rv.headers.extend(headers)

        return rv

    def handle_exception(self, e, request):
        #TODO: make this handler defined function
        exc_type, exc_value, tb = sys.exc_info()
        assert exc_value is e

        if issubclass(exc_type, LibcloudRestError):
            error = e
            logger.debug('Exception on %s [%s]' % (
                request.path,
                request.method),
                exc_info=(exc_type, exc_value, tb)
            )
        else:
            error = InternalError(detail=str(e))
            logger.error('Exception on %s [%s]' % (
                request.path,
                request.method),
                exc_info=(exc_type, exc_value, tb)
            )
        return self.make_response(error.to_json(), error.http_status_code)

    def __call__(self, environ, start_response):
        request = Request(environ)

# Path: libcloud_rest/api/urls.py

# 
# Path: libcloud_rest/api/validators.py
# class BaseValidator(object):
# class NumericValidator(BaseValidator):
# class IntegerValidator(NumericValidator):
# class FloatValidator(NumericValidator):
# class StringValidator(BaseValidator):
# class BooleanValidator(BaseValidator):
# class NoneValidator(BaseValidator):
# class ConstValidator(BaseValidator):
# class DictValidator(BaseValidator):
# class ChoicesValidator(BaseValidator):
# class TypeValidator(BaseValidator):
#     def __init__(self, *args, **kwargs):
#     def configure(self, args, kwargs):
#     def _get_name(self):
#     def _set_name(self, new_name):
#     def __call__(self, data):
#     def _validate(self):
#     def _check_data(self):
#     def configure(self, args, kwargs):
#     def _check_data(self):
#     def _check_data(self):
#     def _check_data(self):
#     def _check_data(self):
#     def configure(self, args, kwargs):
#     def _check_data(self):
#     def configure(self, args, kwargs):
#     def _check_data(self):
#     def configure(self, args, kwargs):
#     def _check_data(self):
#     def configure(self, args, kwargs):
#     def _check_data(self):
# 
# Path: libcloud_rest/log.py
# def get_logger(handler, level):
# 
# Path: libcloud_rest/constants.py
# MAX_BODY_LENGTH = 512
# 
# Path: libcloud_rest/utils.py
# class JsonResponse(Response):
# class DateTimeJsonEncoder(json.JSONEncoder):
# class OrderedDict(dict):
# class LastUpdatedOrderedDict(OrderedDict):
#     def default(self, obj):
#     def __init__(self, *args, **kwds):
#     def __setitem__(self, key, value, dict_setitem=dict.__setitem__):
#     def __delitem__(self, key, dict_delitem=dict.__delitem__):
#     def __iter__(self):
#     def __reversed__(self):
#     def clear(self):
#     def popitem(self, last=True):
#     def keys(self):
#     def values(self):
#     def items(self):
#     def iterkeys(self):
#     def itervalues(self):
#     def iteritems(self):
#     def update(*args, **kwds):
#     def pop(self, key, default=__marker):
#     def setdefault(self, key, default=None):
#     def __repr__(self, _repr_running={}):
#     def __reduce__(self):
#     def copy(self):
#     def fromkeys(cls, iterable, value=None):
#     def __eq__(self, other):
#     def __ne__(self, other):
#     def viewkeys(self):
#     def viewvalues(self):
#     def viewitems(self):
#     def __setitem__(self, key, value):


# Path: libcloud_rest/application.py
import sys
import re
from werkzeug.urls import url_decode
from libcloud_rest.api.urls import urls
from libcloud_rest.api import validators as valid
from libcloud_rest.log import logger
from .errors import LibcloudRestError, InternalError
from libcloud_rest.constants import MAX_BODY_LENGTH
from libcloud_rest.utils import json, Response, Request

            else:
                rv.status_code = status
        if headers is not None:
            rv.headers.extend(headers)

        return rv

    def handle_exception(self, e, request):
        #TODO: make this handler defined function
        exc_type, exc_value, tb = sys.exc_info()
        assert exc_value is e

        if issubclass(exc_type, LibcloudRestError):
            error = e
            logger.debug('Exception on %s [%s]' % (
                request.path,
                request.method),
                exc_info=(exc_type, exc_value, tb)
            )
        else:
            error = InternalError(detail=str(e))
            logger.error('Exception on %s [%s]' % (
                request.path,
                request.method),
                exc_info=(exc_type, exc_value, tb)
            )
        return self.make_response(error.to_json(), error.http_status_code)

    def __call__(self, environ, start_response):
        request = Request(environ)

        logger.debug('%s - %s %s' %