1
Fork 0
mirror of https://github.com/RYGhub/royalnet.git synced 2024-11-27 21:44:21 +00:00
royalnet/royalpack/stars/api_wiki_get.py

23 lines
778 B
Python
Raw Normal View History

from starlette.requests import Request
from starlette.responses import *
from royalnet.constellation import *
from royalnet.utils import *
from ..tables import *
import uuid
2020-02-09 18:12:34 +00:00
from royalnet.constellation.api import *
2020-02-09 18:12:34 +00:00
class ApiWikiGetStar(ApiStar):
path = "/api/wiki/get/v1"
2020-02-09 18:12:34 +00:00
async def api(self, data: ApiData) -> dict:
wikipage_id_str = data["id"]
try:
2020-02-09 18:12:34 +00:00
wikipage_id = uuid.UUID(wikipage_id_str)
except (ValueError, AttributeError, TypeError):
2020-02-09 18:12:34 +00:00
raise InvalidParameterError("'id' is not a valid UUID.")
wikipage: WikiPage = await asyncify(data.session.query(self.alchemy.get(WikiPage)).get, wikipage_id)
if wikipage is None:
raise NotFoundError("No such page.")
return wikipage.json_full()