# Path: freezer_api/common/exceptions.py
# class FreezerAPIException(falcon.HTTPError):
# class BadDataFormat(FreezerAPIException):
# class DocumentExists(FreezerAPIException):
# class StorageEngineError(FreezerAPIException):
# class DocumentNotFound(FreezerAPIException):
# class AccessForbidden(FreezerAPIException):
# class MethodNotImplemented(FreezerAPIException):
#     def __init__(self, message=''):
#     def handle(ex, req, resp, params):
#     def handle(ex, req, resp, params):
#     def handle(ex, req, resp, params):
#     def handle(ex, req, resp, params):
#     def handle(ex, req, resp, params):
#     def handle(ex, req, resp, params):
#     def handle(ex, req, resp, params):
# 
# Path: freezer_api/context.py
# LOG = log.getLogger(__name__)
# class FreezerContext(context.RequestContext):
#     def __init__(self, auth_token=None, user=None, tenant=None, domain=None,
#                  user_domain=None, project_domain=None, is_admin=False,
#                  read_only=False, show_deleted=False, request_id=None,
#                  resource_uuid=None, overwrite=True, roles=None):
#     def from_dict(cls, values):
#     def elevated(self, show_deleted=False):
#     def view_deleted(self):
# def get_admin_context(show_deleted="no"):
# def get_current():


import falcon
import webob.dec
import webob.exc
from oslo_log import log
from oslo_serialization import jsonutils as json
from freezer_api.common import exceptions as freezer_api_exc
from freezer_api import context
            # For python 3 compatibility need to use bytes type
            prefix = b'req-' if isinstance(request_id, bytes) else 'req-'

            if not request_id.startswith(prefix):
                request_id = prefix + request_id

            response.headers['x-openstack-request-id'] = request_id
        return response


class ContextMiddleware(BaseContextMiddleware):
    """
    Simple WSGI app to support HAProxy polling.
    If the requested url matches the configured path it replies
    with a 200 otherwise passes the request to the inner app
    """

    def get_context(self, req):
        token = req.headers.get('X-Auth-Token')
        userid = req.headers.get('X-User-Id')
        domainid = req.headers.get('X-Domain-Id')
        tenantid = req.headers.get('X-Tenant-Id')
        user_domain_id = req.headers.get('X-User-Domain-Id')
        projectid = req.headers.get('X-Project-Id')
        project_domain_id = req.headers.get('X-Project-Domain-Id')
        request_id = req.headers.get('X-Openstack-Request-ID')
        roles_header = req.headers.get('X-Roles', '')
        roles = [r.strip().lower() for r in roles_header.split(',')]
        is_admin = 'admin' in roles


# Path: freezer_api/common/exceptions.py
# class FreezerAPIException(falcon.HTTPError):
# class BadDataFormat(FreezerAPIException):
# class DocumentExists(FreezerAPIException):
# class StorageEngineError(FreezerAPIException):
# class DocumentNotFound(FreezerAPIException):
# class AccessForbidden(FreezerAPIException):
# class MethodNotImplemented(FreezerAPIException):
#     def __init__(self, message=''):
#     def handle(ex, req, resp, params):
#     def handle(ex, req, resp, params):
#     def handle(ex, req, resp, params):
#     def handle(ex, req, resp, params):
#     def handle(ex, req, resp, params):
#     def handle(ex, req, resp, params):
#     def handle(ex, req, resp, params):
# 
# Path: freezer_api/context.py
# LOG = log.getLogger(__name__)
# class FreezerContext(context.RequestContext):
#     def __init__(self, auth_token=None, user=None, tenant=None, domain=None,
#                  user_domain=None, project_domain=None, is_admin=False,
#                  read_only=False, show_deleted=False, request_id=None,
#                  resource_uuid=None, overwrite=True, roles=None):
#     def from_dict(cls, values):
#     def elevated(self, show_deleted=False):
#     def view_deleted(self):
# def get_admin_context(show_deleted="no"):
# def get_current():


# Path: freezer_api/api/common/middleware.py
import falcon
import webob.dec
import webob.exc
from oslo_log import log
from oslo_serialization import jsonutils as json
from freezer_api.common import exceptions as freezer_api_exc
from freezer_api import context

            # For python 3 compatibility need to use bytes type
            prefix = b'req-' if isinstance(request_id, bytes) else 'req-'

            if not request_id.startswith(prefix):
                request_id = prefix + request_id

            response.headers['x-openstack-request-id'] = request_id
        return response


class ContextMiddleware(BaseContextMiddleware):
    """
    Simple WSGI app to support HAProxy polling.
    If the requested url matches the configured path it replies
    with a 200 otherwise passes the request to the inner app
    """

    def get_context(self, req):
        token = req.headers.get('X-Auth-Token')
        userid = req.headers.get('X-User-Id')
        domainid = req.headers.get('X-Domain-Id')
        tenantid = req.headers.get('X-Tenant-Id')
        user_domain_id = req.headers.get('X-User-Domain-Id')
        projectid = req.headers.get('X-Project-Id')
        project_domain_id = req.headers.get('X-Project-Domain-Id')
        request_id = req.headers.get('X-Openstack-Request-ID')
        roles_header = req.headers.get('X-Roles', '')
        roles = [r.strip().lower() for r in roles_header.split(',')]
        is_admin = 'admin' in roles


        return context.FreezerContext(auth_token=token,