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 *
|
2019-11-28 01:30:40 +00:00
|
|
|
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()
|