def category_terms_relationship_parent_category_terms(category_term_id: str):
    """
    Returns parent CategoryTerm resource linkages for a specific CategoryTerm resource, specified by its Neutral ID

    :type category_term_id: str
    :param category_term_id: neutral ID of a CategoryTerm resource
    """
    try:
        category_term = CategoryTerm.query.filter_by(neutral_id=category_term_id).one()
        payload = CategoryTermSchema(resource_linkage='parent-category').dump(category_term)
        return jsonify(payload)
    except NoResultFound:
        raise NotFound()
    except MultipleResultsFound:
        raise UnprocessableEntity()
def category_terms_categorisations(category_term_id: str):
    """
    Returns Categorisation resources associated with a specific CategoryTerm resource, specified by its Neutral ID

    :type category_term_id: str
    :param category_term_id: neutral ID of a CategoryTerm resource
    """
    try:
        category_term = CategoryTerm.query.filter_by(neutral_id=category_term_id).one()
        payload = CategoryTermSchema(related_resource='categorisations', many_related=True).dump(category_term)
        return jsonify(payload)
    except NoResultFound:
        raise NotFound()
    except MultipleResultsFound:
        raise UnprocessableEntity()
def category_terms_list():
    """
    Returns all CategoryTerm resources

    The response is paginated.
    """
    page = request.args.get('page', type=int)
    if page is None:
        page = 1

    _category_terms = CategoryTerm.query.paginate(page=page, per_page=app.config['APP_PAGE_SIZE'])
    payload = CategoryTermSchema(many=True, paginate=True, include_data=(
        'parent_category',
        'categorisations',
        'categorisations.project',
        'category_scheme'
    )).dump(_category_terms)

    return jsonify(payload)
def category_terms_detail(category_term_id: str):
    """
    Returns a specific CategoryTerm resource, specified by its Neutral ID

    :type category_term_id: str
    :param category_term_id: neutral ID of a CategoryTerm resource
    """
    try:
        category_term = CategoryTerm.query.filter_by(neutral_id=category_term_id).one()
        payload = CategoryTermSchema(include_data=(
            'parent_category',
            'categorisations',
            'categorisations.project',
            'category_scheme'
        )).dump(category_term)
        return jsonify(payload)
    except NoResultFound:
        raise NotFound()
    except MultipleResultsFound:
        raise UnprocessableEntity()