2019-12-30 01:51:55 +00:00
|
|
|
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 *
|
2019-12-30 01:51:55 +00:00
|
|
|
|
|
|
|
|
2020-02-09 18:12:34 +00:00
|
|
|
class ApiWikiGetStar(ApiStar):
|
|
|
|
path = "/api/wiki/get/v1"
|
2019-12-30 01:51:55 +00:00
|
|
|
|
2020-02-09 18:12:34 +00:00
|
|
|
async def api(self, data: ApiData) -> dict:
|
|
|
|
wikipage_id_str = data["id"]
|
2019-12-30 01:51:55 +00:00
|
|
|
try:
|
2020-02-09 18:12:34 +00:00
|
|
|
wikipage_id = uuid.UUID(wikipage_id_str)
|
2019-12-30 01:51:55 +00:00
|
|
|
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()
|