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