# Path: api/theatrics/handlers/helpers.py
# @with_params(ItemParams)
# async def get_item(request, type_, id_, relations={},
#                    fields=(), expand=()):
#     item = await fetch_item(type_, id_, fields)
#     if item is None:
#         raise web.HTTPNotFound()
#     expanding_relations = project(relations, expand)
#     return await expand_item(item, expanding_relations)
# 
# @with_params(ListParams)
# async def get_list(request, query, type_=None, relations={},
#                    page=1, page_size=20, fields=(), expand=()):
#     items, count, took = await search(query, type_, page, page_size, fields)
# 
#     expanding_relations = project(relations, expand)
#     items = await expand_multiple_items(items, expanding_relations)
# 
#     previous = get_previous_page_uri(request, page, page_size)
#     next_ = get_next_page_uri(request, page, page_size, count)
# 
#     return {
#         'count': count,
#         'items': items,
#         'took': took,
#         'previous': previous,
#         'next': next_,
#     }


from theatrics.scoring import get_default_score_functions
from theatrics.utils.handlers import json_response
from ..helpers import get_item, get_list



__all__ = ['agent', 'agent_list']


@json_response
async def agent(request):
    return await get_item(
        request,
        type_='agent',
        id_=request.match_info['id'],
    )


@json_response
async def agent_list(request):
    return await get_list(
        request,
        type_='agent',
        query=build_query_from_request(request),

# Path: api/theatrics/handlers/helpers.py
# @with_params(ItemParams)
# async def get_item(request, type_, id_, relations={},
#                    fields=(), expand=()):
#     item = await fetch_item(type_, id_, fields)
#     if item is None:
#         raise web.HTTPNotFound()
#     expanding_relations = project(relations, expand)
#     return await expand_item(item, expanding_relations)
# 
# @with_params(ListParams)
# async def get_list(request, query, type_=None, relations={},
#                    page=1, page_size=20, fields=(), expand=()):
#     items, count, took = await search(query, type_, page, page_size, fields)
# 
#     expanding_relations = project(relations, expand)
#     items = await expand_multiple_items(items, expanding_relations)
# 
#     previous = get_previous_page_uri(request, page, page_size)
#     next_ = get_next_page_uri(request, page, page_size, count)
# 
#     return {
#         'count': count,
#         'items': items,
#         'took': took,
#         'previous': previous,
#         'next': next_,
#     }


# Path: api/theatrics/handlers/v1/agents.py
from theatrics.scoring import get_default_score_functions
from theatrics.utils.handlers import json_response
from ..helpers import get_item, get_list




__all__ = ['agent', 'agent_list']


@json_response
async def agent(request):
    return await get_item(
        request,
        type_='agent',
        id_=request.match_info['id'],
    )


@json_response
async def agent_list(request):
    return await get_list(
        request,
        type_='agent',
        query=build_query_from_request(request),

    )