2019-11-11 08:56:08 +00:00
|
|
|
from starlette.requests import Request
|
|
|
|
from starlette.responses import *
|
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-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-08 00:49:07 +00:00
|
|
|
diario_id = int(data["diario_id"])
|
|
|
|
except ValueError:
|
|
|
|
raise InvalidParameterError("'diario_id' is not a valid int.")
|
|
|
|
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()
|