diff --git a/pythorhead/admin.py b/pythorhead/admin.py new file mode 100644 index 0000000..494f3fb --- /dev/null +++ b/pythorhead/admin.py @@ -0,0 +1,25 @@ +from typing import Any, List, Literal, Optional +from pythorhead.requestor import Request, Requestor + +class Admin: + def __init__(self, _requestor: Requestor): + self._requestor = _requestor + + def list_applications( + self, + limit: Optional[int] = None, + page: Optional[int] = None, + unread_only: Optional[str] = None, + ) -> Optional[dict]: + """ + Pull applications from site. Note user must be admin. + + Args: + limit (Optional[int], optional): Defaults to None. + page (Optional[int], optional): Defaults to None. + undread_only (Optional[str], optional): Must be "true" or "false". Defaults to false + Returns: + dict: list applications + """ + params: dict[str, Any] = {key: value for key, value in locals().items() if value is not None and key != "self"} + return self._requestor.api(Request.GET, "/admin/registration_application/list", params=params) \ No newline at end of file diff --git a/pythorhead/lemmy.py b/pythorhead/lemmy.py index a2da01e..48c56e7 100644 --- a/pythorhead/lemmy.py +++ b/pythorhead/lemmy.py @@ -11,6 +11,7 @@ from pythorhead.site import Site from pythorhead.types import FeatureType, ListingType, SortType from pythorhead.user import User +from pythorhead.admin import Admin class Lemmy: @@ -28,6 +29,7 @@ def __init__(self, api_base_url: str) -> None: self.private_message = PrivateMessage(self._requestor) self.image = Image(self._requestor) self.mention = Mention(self._requestor) + self.admin = Admin(self._requestor) @property def nodeinfo(self):