def get_entity(repository_id, entity_type, entity_id):
"""
Get an entity from a repository
:param repository_id: the repository that contains the entity
:param entity_type: a valid entity type (asset, offer or agreement)
:param entity_id: the entity's ID
:returns: the entity data from the repository service
:raises: tornado.httpclient.HTTPError
"""
endpoint = yield entity_endpoint(repository_id, entity_type)
if not endpoint:
raise Return(None)
try:
result = yield endpoint[entity_id].get()
except httpclient.HTTPError as err:
if err.code == 404:
raise Return(None)
else:
raise
raise Return(result['data'])
评论列表
文章目录