1
Fork 0
mirror of https://github.com/RYGhub/royalnet.git synced 2024-11-30 15:04:18 +00:00
royalnet/royalpack/stars/api_diario_get.py

26 lines
726 B
Python
Raw Normal View History

2020-02-08 00:49:07 +00:00
from royalnet.constellation.api import *
2019-11-11 08:56:08 +00:00
from royalnet.utils import *
from ..tables import *
2019-11-11 08:56:08 +00:00
2020-02-08 00:49:07 +00:00
class ApiDiarioGetStar(ApiStar):
path = "/api/diario/get/v1"
2019-11-11 08:56:08 +00:00
2020-03-09 20:21:07 +00:00
summary = "Get the diario entry with a specific id."
parameters = {
"id": "The id of the diario entry to get."
}
tags = ["diario"]
2020-02-08 00:49:07 +00:00
async def api(self, data: ApiData) -> dict:
2019-11-11 08:56:08 +00:00
try:
2020-02-09 18:12:34 +00:00
diario_id = int(data["id"])
2020-02-08 00:49:07 +00:00
except ValueError:
2020-02-09 18:12:34 +00:00
raise InvalidParameterError("'id' is not a valid int.")
2020-02-08 00:49:07 +00:00
entry: Diario = await asyncify(data.session.query(self.alchemy.get(Diario)).get, diario_id)
if entry is None:
raise NotFoundError("No such diario entry.")
return entry.json()