1
Fork 0
mirror of https://github.com/RYGhub/royalnet.git synced 2024-11-24 03:54:20 +00:00
royalnet/royalpack/stars/api_diario.py

25 lines
657 B
Python
Raw Normal View History

2020-06-26 14:13:11 +00:00
import royalnet.constellation.api as rca
import royalnet.utils as ru
from ..tables import *
2019-11-11 08:56:08 +00:00
2020-06-26 14:13:11 +00:00
class ApiDiarioGetStar(rca.ApiStar):
2020-06-22 17:27:11 +00:00
path = "/api/diario/v2"
2020-03-09 20:21:07 +00:00
parameters = {
2020-06-22 17:27:11 +00:00
"get": {
"id": "The id of the diario entry to get."
}
2020-03-09 20:21:07 +00:00
}
tags = ["diario"]
2020-06-26 14:13:11 +00:00
@rca.magic
async def get(self, data: rca.ApiData) -> ru.JSON:
2020-06-22 17:27:11 +00:00
"""Get a specific diario entry."""
diario_id = data.int("id")
2020-06-26 14:13:11 +00:00
entry: Diario = await ru.asyncify(data.session.query(self.alchemy.get(Diario)).get, diario_id)
2020-02-08 00:49:07 +00:00
if entry is None:
2020-06-26 14:13:11 +00:00
raise rca.NotFoundError("No such diario entry.")
2020-02-08 00:49:07 +00:00
return entry.json()