1
Fork 0
mirror of https://github.com/RYGhub/royalnet.git synced 2024-12-17 23:24:20 +00:00
royalnet/royalpack/stars/api_diario.py
2020-06-26 16:13:11 +02:00

24 lines
657 B
Python

import royalnet.constellation.api as rca
import royalnet.utils as ru
from ..tables import *
class ApiDiarioGetStar(rca.ApiStar):
path = "/api/diario/v2"
parameters = {
"get": {
"id": "The id of the diario entry to get."
}
}
tags = ["diario"]
@rca.magic
async def get(self, data: rca.ApiData) -> ru.JSON:
"""Get a specific diario entry."""
diario_id = data.int("id")
entry: Diario = await ru.asyncify(data.session.query(self.alchemy.get(Diario)).get, diario_id)
if entry is None:
raise rca.NotFoundError("No such diario entry.")
return entry.json()