def create(body, headers): queue_collection = queues.CollectionResource() queue_item = queues.ItemResource() stats_endpoint = stats.Resource() msg_collection = messages.CollectionResource() msg_item = messages.ItemResource() claim_collection = claims.CollectionResource() claim_item = claims.ItemResource() middleware = [ RequestIDComponent(), CannedResponseComponent(body, headers), ] api = falcon.API(middleware=middleware) api.add_route('/v1/{tenant_id}/queues', queue_collection) api.add_route('/v1/{tenant_id}/queues/{queue_name}', queue_item) api.add_route('/v1/{tenant_id}/queues/{queue_name}' '/stats', stats_endpoint) api.add_route('/v1/{tenant_id}/queues/{queue_name}' '/messages', msg_collection) api.add_route( '/v1/{tenant_id}/queues/{queue_name}' '/messages/{message_id}', msg_item) api.add_route('/v1/{tenant_id}/queues/{queue_name}' '/claims', claim_collection) api.add_route('/v1/{tenant_id}/queues/{queue_name}' '/claims/{claim_id}', claim_item) return api
def create(body, headers): vary = ('X-Auth-Token', 'Accept-Encoding') def canned_response(req, resp): resp.status = falcon.HTTP_200 resp.body = body resp.set_headers(headers) resp.vary = vary resp.content_range = (0, len(body), len(body) + 100) queue_collection = queues.CollectionResource() queue_item = queues.ItemResource() stats_endpoint = stats.Resource() msg_collection = messages.CollectionResource() msg_item = messages.ItemResource() claim_collection = claims.CollectionResource() claim_item = claims.ItemResource() middleware = [NoopComponent(), RequestIDComponent()] api = falcon.API(after=canned_response, middleware=middleware) api.add_route('/v1/{tenant_id}/queues', queue_collection) api.add_route('/v1/{tenant_id}/queues/{queue_name}', queue_item) api.add_route('/v1/{tenant_id}/queues/{queue_name}' '/stats', stats_endpoint) api.add_route('/v1/{tenant_id}/queues/{queue_name}' '/messages', msg_collection) api.add_route( '/v1/{tenant_id}/queues/{queue_name}' '/messages/{message_id}', msg_item) api.add_route('/v1/{tenant_id}/queues/{queue_name}' '/claims', claim_collection) api.add_route('/v1/{tenant_id}/queues/{queue_name}' '/claims/{claim_id}', claim_item) return api