1
Fork 0
mirror of https://github.com/RYGhub/royalnet.git synced 2024-12-05 01:04:21 +00:00
royalnet/royalpack/stars/api_wiki_get.py

31 lines
950 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-03-09 20:21:07 +00:00
summary = "Get information about a specific wiki page."
parameters = {
"id": "The id of the wiki page to get information for."
}
tags = ["wiki"]
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()