Beispiel #1
0
class GetTypeEntities(Resource):
    @staticmethod
    @swag_from("../swagger/type_entities.yml", endpoint="api_03.type_entities")
    def get(id_: int) -> Union[tuple[Resource, int], Response, dict[str, Any]]:
        if id_ not in g.types:
            raise InvalidSubunitError
        if not (entities := g.types[id_].get_linked_entities(
            ['P2', 'P89'], inverse=True, types=True)):
            entities = get_entities_linked_to_special_type(id_)
        return resolve_entities(entities, entity_.parse_args(), id_)
Beispiel #2
0
class GetTypeEntitiesAll(Resource):
    @staticmethod
    @swag_from("../swagger/type_entities_all.yml",
               endpoint="api_03.type_entities_all")
    def get(id_: int) -> Union[tuple[Resource, int], Response, dict[str, Any]]:
        if id_ not in g.types:
            raise InvalidSubunitError
        if not (entities := get_entities_linked_to_type_recursive(id_, [])):
            entities = get_entities_by_ids(
                get_entities_linked_to_special_type_recursive(id_, []))
        return resolve_entities(entities, entity_.parse_args(), id_)
Beispiel #3
0
 def get(id_: int) -> Union[tuple[Resource, int], Response, dict[str, Any]]:
     return resolve_entities(get_linked_entities_api(id_),
                             entity_.parse_args(), 'linkedEntities')
Beispiel #4
0
 def get(latest: int) \
         -> Union[tuple[Resource, int], Response, dict[str, Any]]:
     if not 0 < latest < 101:
         raise InvalidLimitError
     return resolve_entities(Entity.get_latest(latest),
                             entity_.parse_args(), latest)
Beispiel #5
0
 def get(view_class: str) \
         -> Union[tuple[Resource, int], Response, dict[str, Any]]:
     return resolve_entities(get_entities_by_view_classes([view_class]),
                             entity_.parse_args(), view_class)
Beispiel #6
0
 def get(id_: int) -> Union[tuple[Resource, int], Response, dict[str, Any]]:
     return resolve_entity(get_entity_by_id(id_), entity_.parse_args())
Beispiel #7
0
 def get() -> Union[tuple[Resource, int], Response]:
     type_tree = {'typeTree': GetTypeTree.get_type_tree()}
     if entity_.parse_args()['download']:
         return download(type_tree, type_tree_template(), 'type_tree')
     return marshal(type_tree, type_tree_template()), 200
Beispiel #8
0
 def get(id_: int) -> Union[tuple[Resource, int], Response, dict[str, Any]]:
     parser = entity_.parse_args()
     subunits = get_subunits_from_id(get_entity_by_id(id_), parser)
     return resolve_subunits(subunits, parser, str(id_))
Beispiel #9
0
 def get(id_: int) -> Union[tuple[Resource, int], Response, dict[str, Any]]:
     return resolve_subunits(
         GetSubunits.iterate(get_entity_by_id(id_), entity_.parse_args()),
         entity_.parse_args(),
         str(id_))