From 39eeff8d422ac88bc7a10416bfe1a9bdae6fdbd7 Mon Sep 17 00:00:00 2001 From: Emily McLean Date: Mon, 18 Nov 2024 14:20:01 +1100 Subject: [PATCH 1/2] Update generator to accept new format --- pythonlemmy/lemmyhttp.py | 274 ++++++++-- pythonlemmy/objects.py | 495 +++++++++++++++--- pythonlemmy/responses.py | 134 ++++- pythonlemmy/views.py | 59 +-- type-generator/main.py | 41 +- .../src/generator/http_generator.py | 7 +- type-generator/src/visitor/__init__.py | 1 + type-generator/src/visitor/enum_visitor.py | 6 + type-generator/src/visitor/model_visitor.py | 28 +- .../src/visitor/type_alias_visitor.py | 31 ++ 10 files changed, 901 insertions(+), 175 deletions(-) create mode 100644 type-generator/src/visitor/type_alias_visitor.py diff --git a/pythonlemmy/lemmyhttp.py b/pythonlemmy/lemmyhttp.py index ce21b03..cf04dc0 100644 --- a/pythonlemmy/lemmyhttp.py +++ b/pythonlemmy/lemmyhttp.py @@ -57,7 +57,6 @@ def create_site( description: str = None, icon: str = None, banner: str = None, - enable_downvotes: bool = None, enable_nsfw: bool = None, community_creation_admin_only: bool = None, require_email_verification: bool = None, @@ -65,7 +64,9 @@ def create_site( private_instance: bool = None, default_theme: str = None, default_post_listing_type: str = None, - default_sort_type: str = None, + default_post_listing_mode: str = None, + default_post_sort_type: str = None, + default_comment_sort_type: str = None, legal_information: str = None, application_email_admins: bool = None, hide_modlog_mod_names: bool = None, @@ -90,10 +91,13 @@ def create_site( captcha_difficulty: str = None, allowed_instances: list[str] = None, blocked_instances: list[str] = None, - taglines: list[str] = None, registration_mode: str = None, + oauth_registration: bool = None, content_warning: str = None, - default_post_listing_mode: str = None + post_upvotes: str = None, + post_downvotes: str = None, + comment_upvotes: str = None, + comment_downvotes: str = None ): """ Create your site. Args: @@ -102,7 +106,6 @@ def create_site( description: CreateSite.description icon: CreateSite.icon banner: CreateSite.banner - enable_downvotes: CreateSite.enable_downvotes enable_nsfw: CreateSite.enable_nsfw community_creation_admin_only: CreateSite.community_creation_admin_only require_email_verification: CreateSite.require_email_verification @@ -110,7 +113,9 @@ def create_site( private_instance: CreateSite.private_instance default_theme: CreateSite.default_theme default_post_listing_type: Possible values [All, Local, Subscribed, ModeratorView] - default_sort_type: Possible values [Active, Hot, New, Old, TopDay, TopWeek, TopMonth, TopYear, TopAll, MostComments, NewComments, TopHour, TopSixHour, TopTwelveHour, TopThreeMonths, TopSixMonths, TopNineMonths, Controversial, Scaled] + default_post_listing_mode: Possible values [List, Card, SmallCard] + default_post_sort_type + default_comment_sort_type legal_information: CreateSite.legal_information application_email_admins: CreateSite.application_email_admins hide_modlog_mod_names: CreateSite.hide_modlog_mod_names @@ -135,10 +140,13 @@ def create_site( captcha_difficulty: CreateSite.captcha_difficulty allowed_instances: CreateSite.allowed_instances blocked_instances: CreateSite.blocked_instances - taglines: CreateSite.taglines registration_mode: Possible values [Closed, RequireApplication, Open] + oauth_registration content_warning: CreateSite.content_warning - default_post_listing_mode: Possible values [List, Card, SmallCard] + post_upvotes + post_downvotes + comment_upvotes + comment_downvotes Returns: requests.Response: result of API call (wrap in SiteResponse if successful) @@ -155,7 +163,6 @@ def edit_site( description: str = None, icon: str = None, banner: str = None, - enable_downvotes: bool = None, enable_nsfw: bool = None, community_creation_admin_only: bool = None, require_email_verification: bool = None, @@ -163,7 +170,9 @@ def edit_site( private_instance: bool = None, default_theme: str = None, default_post_listing_type: str = None, - default_sort_type: str = None, + default_post_listing_mode: str = None, + default_post_sort_type: str = None, + default_comment_sort_type: str = None, legal_information: str = None, application_email_admins: bool = None, hide_modlog_mod_names: bool = None, @@ -189,11 +198,14 @@ def edit_site( allowed_instances: list[str] = None, blocked_instances: list[str] = None, blocked_urls: list[str] = None, - taglines: list[str] = None, registration_mode: str = None, reports_email_admins: bool = None, content_warning: str = None, - default_post_listing_mode: str = None + oauth_registration: bool = None, + post_upvotes: str = None, + post_downvotes: str = None, + comment_upvotes: str = None, + comment_downvotes: str = None ): """ Edit your site. Args: @@ -202,7 +214,6 @@ def edit_site( description: EditSite.description icon: EditSite.icon banner: EditSite.banner - enable_downvotes: EditSite.enable_downvotes enable_nsfw: EditSite.enable_nsfw community_creation_admin_only: EditSite.community_creation_admin_only require_email_verification: EditSite.require_email_verification @@ -210,7 +221,9 @@ def edit_site( private_instance: EditSite.private_instance default_theme: EditSite.default_theme default_post_listing_type: Possible values [All, Local, Subscribed, ModeratorView] - default_sort_type: Possible values [Active, Hot, New, Old, TopDay, TopWeek, TopMonth, TopYear, TopAll, MostComments, NewComments, TopHour, TopSixHour, TopTwelveHour, TopThreeMonths, TopSixMonths, TopNineMonths, Controversial, Scaled] + default_post_listing_mode: Possible values [List, Card, SmallCard] + default_post_sort_type + default_comment_sort_type legal_information: EditSite.legal_information application_email_admins: EditSite.application_email_admins hide_modlog_mod_names: EditSite.hide_modlog_mod_names @@ -236,11 +249,14 @@ def edit_site( allowed_instances: EditSite.allowed_instances blocked_instances: EditSite.blocked_instances blocked_urls: EditSite.blocked_urls - taglines: EditSite.taglines registration_mode: Possible values [Closed, RequireApplication, Open] reports_email_admins: EditSite.reports_email_admins content_warning: EditSite.content_warning - default_post_listing_mode: Possible values [List, Card, SmallCard] + oauth_registration + post_upvotes + post_downvotes + comment_upvotes + comment_downvotes Returns: requests.Response: result of API call (wrap in SiteResponse if successful) @@ -428,7 +444,12 @@ def search( sort: str = None, listing_type: str = None, page: int = None, - limit: int = None + limit: int = None, + title_only: bool = None, + post_url_only: bool = None, + saved_only: bool = None, + liked_only: bool = None, + disliked_only: bool = None ): """ Search lemmy. Args: @@ -441,6 +462,11 @@ def search( listing_type: Possible values [All, Local, Subscribed, ModeratorView] page: Search.page limit: Search.limit + title_only + post_url_only + saved_only + liked_only + disliked_only Returns: requests.Response: result of API call (wrap in SearchResponse if successful) @@ -470,6 +496,7 @@ def create_community( self, name: str, title: str, + sidebar: str = None, description: str = None, icon: str = None, banner: str = None, @@ -482,6 +509,7 @@ def create_community( Args: name: CreateCommunity.name title: CreateCommunity.title + sidebar description: CreateCommunity.description icon: CreateCommunity.icon banner: CreateCommunity.banner @@ -520,6 +548,7 @@ def edit_community( self, community_id: int, title: str = None, + sidebar: str = None, description: str = None, icon: str = None, banner: str = None, @@ -532,6 +561,7 @@ def edit_community( Args: community_id: CommunityId title: EditCommunity.title + sidebar description: EditCommunity.description icon: EditCommunity.icon banner: EditCommunity.banner @@ -590,6 +620,41 @@ def follow_community( return result + def get_community_pending_follows_count( + self, + community_id: int + ): + + form = create_form(locals()) + result = self._request_controller.get_handler(f"{self._api_url}/community/pending_follows/count", json=None, params=form) + + return result + + def list_community_pending_follows( + self, + pending_only: bool = None, + all_communities: bool = None, + page: int = None, + limit: int = None + ): + + form = create_form(locals()) + result = self._request_controller.get_handler(f"{self._api_url}/community/pending_follows/list", json=None, params=form) + + return result + + def approve_community_pending_follow( + self, + community_id: int, + follower_id: int, + approve: bool + ): + + form = create_form(locals()) + result = self._request_controller.post_handler(f"{self._api_url}/community/pending_follows/approve", json=form, params=None) + + return result + def block_community( self, community_id: int, @@ -689,7 +754,7 @@ def ban_from_community( community_id: int, person_id: int, ban: bool, - remove_data: bool = None, + remove_or_restore_data: bool = None, reason: str = None, expires: int = None ): @@ -698,7 +763,7 @@ def ban_from_community( community_id: CommunityId person_id: PersonId ban: BanFromCommunity.ban - remove_data: BanFromCommunity.remove_data + remove_or_restore_data reason: BanFromCommunity.reason expires: BanFromCommunity.expires @@ -730,6 +795,16 @@ def add_mod_to_community( return result + def get_random_community( + self, + type_: str = None + ): + + form = create_form(locals()) + result = self._request_controller.get_handler(f"{self._api_url}/community/random", json=None, params=form) + + return result + def create_post( self, name: str, @@ -740,7 +815,8 @@ def create_post( honeypot: str = None, nsfw: bool = None, language_id: int = None, - custom_thumbnail: str = None + custom_thumbnail: str = None, + scheduled_publish_time: int = None ): """ Create a post. Args: @@ -753,6 +829,7 @@ def create_post( nsfw: CreatePost.nsfw language_id: LanguageId custom_thumbnail: CreatePost.custom_thumbnail + scheduled_publish_time Returns: requests.Response: result of API call (wrap in PostResponse if successful) @@ -789,7 +866,8 @@ def edit_post( alt_text: str = None, nsfw: bool = None, language_id: int = None, - custom_thumbnail: str = None + custom_thumbnail: str = None, + scheduled_publish_time: int = None ): """ Edit a post. Args: @@ -801,6 +879,7 @@ def edit_post( nsfw: EditPost.nsfw language_id: LanguageId custom_thumbnail: EditPost.custom_thumbnail + scheduled_publish_time Returns: requests.Response: result of API call (wrap in PostResponse if successful) @@ -936,6 +1015,7 @@ def get_posts( show_hidden: bool = None, show_read: bool = None, show_nsfw: bool = None, + no_comments_only: bool = None, page_cursor: str = None ): """ Get / fetch posts, with various filters. @@ -950,8 +1030,9 @@ def get_posts( liked_only: GetPosts.liked_only disliked_only: GetPosts.disliked_only show_hidden: GetPosts.show_hidden - show_read - show_nsfw + show_read: GetPosts.show_read + show_nsfw: GetPosts.show_nsfw + no_comments_only page_cursor: PaginationCursor Returns: @@ -1588,7 +1669,7 @@ def login( def logout( self ): - """ [MANUAL] Logout your user, which clears the cookie and invalidates the auth token + """ Invalidate the currently used auth token. Returns: @@ -1694,7 +1775,7 @@ def ban_person( self, person_id: int, ban: bool, - remove_data: bool = None, + remove_or_restore_data: bool = None, reason: str = None, expires: int = None ): @@ -1702,7 +1783,7 @@ def ban_person( Args: person_id: PersonId ban: BanPerson.ban - remove_data: BanPerson.remove_data + remove_or_restore_data reason: BanPerson.reason expires: BanPerson.expires @@ -1832,10 +1913,11 @@ def save_user_settings( self, show_nsfw: bool = None, blur_nsfw: bool = None, - auto_expand: bool = None, theme: str = None, - default_sort_type: str = None, default_listing_type: str = None, + post_listing_mode: str = None, + default_post_sort_type: str = None, + default_comment_sort_type: str = None, interface_language: str = None, avatar: str = None, banner: str = None, @@ -1851,7 +1933,6 @@ def save_user_settings( discussion_languages: list[int] = None, open_links_in_new_tab: bool = None, infinite_scroll_enabled: bool = None, - post_listing_mode: str = None, enable_keyboard_navigation: bool = None, enable_animated_images: bool = None, collapse_bot_comments: bool = None, @@ -1864,10 +1945,11 @@ def save_user_settings( Args: show_nsfw: SaveUserSettings.show_nsfw blur_nsfw: SaveUserSettings.blur_nsfw - auto_expand: SaveUserSettings.auto_expand theme: SaveUserSettings.theme - default_sort_type: Possible values [Active, Hot, New, Old, TopDay, TopWeek, TopMonth, TopYear, TopAll, MostComments, NewComments, TopHour, TopSixHour, TopTwelveHour, TopThreeMonths, TopSixMonths, TopNineMonths, Controversial, Scaled] default_listing_type: Possible values [All, Local, Subscribed, ModeratorView] + post_listing_mode: Possible values [List, Card, SmallCard] + default_post_sort_type + default_comment_sort_type interface_language: SaveUserSettings.interface_language avatar: SaveUserSettings.avatar banner: SaveUserSettings.banner @@ -1883,7 +1965,6 @@ def save_user_settings( discussion_languages: SaveUserSettings.discussion_languages open_links_in_new_tab: SaveUserSettings.open_links_in_new_tab infinite_scroll_enabled: SaveUserSettings.infinite_scroll_enabled - post_listing_mode: Possible values [List, Card, SmallCard] enable_keyboard_navigation: SaveUserSettings.enable_keyboard_navigation enable_animated_images: SaveUserSettings.enable_animated_images collapse_bot_comments: SaveUserSettings.collapse_bot_comments @@ -2026,7 +2107,7 @@ def approve_registration_application( ): """ Approve a registration application Args: - id: ApproveRegistrationApplication.id + id: RegistrationApplicationId approve: ApproveRegistrationApplication.approve deny_reason: ApproveRegistrationApplication.deny_reason @@ -2042,7 +2123,13 @@ def get_registration_application( self, person_id: int ): + """ Get the application a user submitted when they first registered their account + Args: + person_id: PersonId + Returns: + requests.Response: result of API call (wrap in RegistrationApplicationResponse if successful) + """ form = create_form(locals()) result = self._request_controller.get_handler(f"{self._api_url}/admin/registration_application", json=None, params=form) @@ -2184,6 +2271,127 @@ def delete_custom_emoji( return result + def list_custom_emojis( + self, + page: int = None, + limit: int = None, + category: str = None, + ignore_page_limits: bool = None + ): + + form = create_form(locals()) + result = self._request_controller.get_handler(f"{self._api_url}/custom_emoji/list", json=None, params=form) + + return result + + def create_tagline( + self, + content: str + ): + + form = create_form(locals()) + result = self._request_controller.post_handler(f"{self._api_url}/admin/tagline", json=form, params=None) + + return result + + def edit_tagline( + self, + id: int, + content: str + ): + + form = create_form(locals()) + result = self._request_controller.put_handler(f"{self._api_url}/admin/tagline", json=form, params=None) + + return result + + def delete_tagline( + self, + id: int + ): + + form = create_form(locals()) + result = self._request_controller.post_handler(f"{self._api_url}/admin/tagline/delete", json=form, params=None) + + return result + + def list_taglines( + self, + page: int = None, + limit: int = None + ): + + form = create_form(locals()) + result = self._request_controller.get_handler(f"{self._api_url}/admin/tagline/list", json=None, params=form) + + return result + + def create_o_auth_provider( + self, + display_name: str, + issuer: str, + authorization_endpoint: str, + token_endpoint: str, + userinfo_endpoint: str, + id_claim: str, + client_id: str, + client_secret: str, + scopes: str, + auto_verify_email: bool = None, + account_linking_enabled: bool = None, + enabled: bool = None + ): + + form = create_form(locals()) + result = self._request_controller.post_handler(f"{self._api_url}/oauth_provider", json=form, params=None) + + return result + + def edit_o_auth_provider( + self, + id: int, + display_name: str = None, + authorization_endpoint: str = None, + token_endpoint: str = None, + userinfo_endpoint: str = None, + id_claim: str = None, + client_secret: str = None, + scopes: str = None, + auto_verify_email: bool = None, + account_linking_enabled: bool = None, + enabled: bool = None + ): + + form = create_form(locals()) + result = self._request_controller.put_handler(f"{self._api_url}/oauth_provider", json=form, params=None) + + return result + + def delete_o_auth_provider( + self, + id: int + ): + + form = create_form(locals()) + result = self._request_controller.post_handler(f"{self._api_url}/oauth_provider/delete", json=form, params=None) + + return result + + def authenticate_with_o_auth( + self, + code: str, + oauth_provider_id: int, + redirect_uri: str, + show_nsfw: bool = None, + username: str = None, + answer: str = None + ): + + form = create_form(locals()) + result = self._request_controller.post_handler(f"{self._api_url}/oauth/authenticate", json=form, params=None) + + return result + def get_federated_instances( self ): diff --git a/pythonlemmy/objects.py b/pythonlemmy/objects.py index dd395c2..9622a25 100644 --- a/pythonlemmy/objects.py +++ b/pythonlemmy/objects.py @@ -75,7 +75,6 @@ class CreateSite: description: Optional[str] = None icon: Optional[str] = None banner: Optional[str] = None - enable_downvotes: Optional[bool] = None enable_nsfw: Optional[bool] = None community_creation_admin_only: Optional[bool] = None require_email_verification: Optional[bool] = None @@ -83,7 +82,9 @@ class CreateSite: private_instance: Optional[bool] = None default_theme: Optional[str] = None default_post_listing_type: Optional[str] = None - default_sort_type: Optional[str] = None + default_post_listing_mode: Optional[str] = None + default_post_sort_type: Optional[str] = None + default_comment_sort_type: Optional[str] = None legal_information: Optional[str] = None application_email_admins: Optional[bool] = None hide_modlog_mod_names: Optional[bool] = None @@ -108,10 +109,13 @@ class CreateSite: captcha_difficulty: Optional[str] = None allowed_instances: Optional[list[str]] = None blocked_instances: Optional[list[str]] = None - taglines: Optional[list[str]] = None registration_mode: Optional[str] = None + oauth_registration: Optional[bool] = None content_warning: Optional[str] = None - default_post_listing_mode: Optional[str] = None + post_upvotes: Optional[str] = None + post_downvotes: Optional[str] = None + comment_upvotes: Optional[str] = None + comment_downvotes: Optional[str] = None @classmethod def parse(cls, data: dict[str, Any]): @@ -121,7 +125,6 @@ def parse(cls, data: dict[str, Any]): description=data["description"] if "description" in data else None, icon=data["icon"] if "icon" in data else None, banner=data["banner"] if "banner" in data else None, - enable_downvotes=data["enable_downvotes"] if "enable_downvotes" in data else None, enable_nsfw=data["enable_nsfw"] if "enable_nsfw" in data else None, community_creation_admin_only=data["community_creation_admin_only"] if "community_creation_admin_only" in data else None, require_email_verification=data["require_email_verification"] if "require_email_verification" in data else None, @@ -129,7 +132,9 @@ def parse(cls, data: dict[str, Any]): private_instance=data["private_instance"] if "private_instance" in data else None, default_theme=data["default_theme"] if "default_theme" in data else None, default_post_listing_type=data["default_post_listing_type"] if "default_post_listing_type" in data else None, - default_sort_type=data["default_sort_type"] if "default_sort_type" in data else None, + default_post_listing_mode=data["default_post_listing_mode"] if "default_post_listing_mode" in data else None, + default_post_sort_type=data["default_post_sort_type"] if "default_post_sort_type" in data else None, + default_comment_sort_type=data["default_comment_sort_type"] if "default_comment_sort_type" in data else None, legal_information=data["legal_information"] if "legal_information" in data else None, application_email_admins=data["application_email_admins"] if "application_email_admins" in data else None, hide_modlog_mod_names=data["hide_modlog_mod_names"] if "hide_modlog_mod_names" in data else None, @@ -154,10 +159,13 @@ def parse(cls, data: dict[str, Any]): captcha_difficulty=data["captcha_difficulty"] if "captcha_difficulty" in data else None, allowed_instances=[e0 for e0 in data["allowed_instances"]] if "allowed_instances" in data else None, blocked_instances=[e0 for e0 in data["blocked_instances"]] if "blocked_instances" in data else None, - taglines=[e0 for e0 in data["taglines"]] if "taglines" in data else None, registration_mode=data["registration_mode"] if "registration_mode" in data else None, + oauth_registration=data["oauth_registration"] if "oauth_registration" in data else None, content_warning=data["content_warning"] if "content_warning" in data else None, - default_post_listing_mode=data["default_post_listing_mode"] if "default_post_listing_mode" in data else None + post_upvotes=data["post_upvotes"] if "post_upvotes" in data else None, + post_downvotes=data["post_downvotes"] if "post_downvotes" in data else None, + comment_upvotes=data["comment_upvotes"] if "comment_upvotes" in data else None, + comment_downvotes=data["comment_downvotes"] if "comment_downvotes" in data else None ) @@ -182,6 +190,7 @@ class CreateCommunity: name: str = None title: str = None + sidebar: Optional[str] = None description: Optional[str] = None icon: Optional[str] = None banner: Optional[str] = None @@ -195,6 +204,7 @@ def parse(cls, data: dict[str, Any]): return cls( name=data["name"], title=data["title"], + sidebar=data["sidebar"] if "sidebar" in data else None, description=data["description"] if "description" in data else None, icon=data["icon"] if "icon" in data else None, banner=data["banner"] if "banner" in data else None, @@ -247,6 +257,23 @@ def parse(cls, data: dict[str, Any]): ) +@dataclass +class ApproveCommunityPendingFollower: + """https://join-lemmy.org/api/interfaces/ApproveCommunityPendingFollower.html""" + + community_id: int = None + follower_id: int = None + approve: bool = None + + @classmethod + def parse(cls, data: dict[str, Any]): + return cls( + community_id=data["community_id"], + follower_id=data["follower_id"], + approve=data["approve"] + ) + + @dataclass class LocalSiteUrlBlocklist: """https://join-lemmy.org/api/interfaces/LocalSiteUrlBlocklist.html""" @@ -388,6 +415,38 @@ def parse(cls, data: dict[str, Any]): ) +@dataclass +class GetCommunityPendingFollowsCount: + """https://join-lemmy.org/api/interfaces/GetCommunityPendingFollowsCount.html""" + + community_id: int = None + + @classmethod + def parse(cls, data: dict[str, Any]): + return cls( + community_id=data["community_id"] + ) + + +@dataclass +class ListCommunityPendingFollows: + """https://join-lemmy.org/api/interfaces/ListCommunityPendingFollows.html""" + + pending_only: Optional[bool] = None + all_communities: Optional[bool] = None + page: Optional[int] = None + limit: Optional[int] = None + + @classmethod + def parse(cls, data: dict[str, Any]): + return cls( + pending_only=data["pending_only"] if "pending_only" in data else None, + all_communities=data["all_communities"] if "all_communities" in data else None, + page=data["page"] if "page" in data else None, + limit=data["limit"] if "limit" in data else None + ) + + @dataclass class DeleteCommunity: """https://join-lemmy.org/api/interfaces/DeleteCommunity.html""" @@ -568,26 +627,41 @@ def parse(cls, data: dict[str, Any]): ) +@dataclass +class UpdateTagline: + """https://join-lemmy.org/api/interfaces/UpdateTagline.html""" + + id: int = None + content: str = None + + @classmethod + def parse(cls, data: dict[str, Any]): + return cls( + id=data["id"], + content=data["content"] + ) + + @dataclass class ReadableFederationState: """https://join-lemmy.org/api/interfaces/ReadableFederationState.html""" + next_retry: Optional[str] = None instance_id: int = None last_successful_id: Optional[int] = None last_successful_published_time: Optional[str] = None fail_count: int = None last_retry: Optional[str] = None - next_retry: Optional[str] = None @classmethod def parse(cls, data: dict[str, Any]): return cls( + next_retry=data["next_retry"] if "next_retry" in data else None, instance_id=data["instance_id"], last_successful_id=data["last_successful_id"] if "last_successful_id" in data else None, last_successful_published_time=data["last_successful_published_time"] if "last_successful_published_time" in data else None, fail_count=data["fail_count"], - last_retry=data["last_retry"] if "last_retry" in data else None, - next_retry=data["next_retry"] if "next_retry" in data else None + last_retry=data["last_retry"] if "last_retry" in data else None ) @@ -668,19 +742,17 @@ class LocalUser: email: Optional[str] = None show_nsfw: bool = None theme: str = None - default_sort_type: str = None + default_post_sort_type: str = None default_listing_type: str = None interface_language: str = None show_avatars: bool = None send_notifications_to_email: bool = None - show_scores: bool = None show_bot_accounts: bool = None show_read_posts: bool = None email_verified: bool = None accepted_application: bool = None open_links_in_new_tab: bool = None blur_nsfw: bool = None - auto_expand: bool = None infinite_scroll_enabled: bool = None admin: bool = None post_listing_mode: str = None @@ -688,6 +760,7 @@ class LocalUser: enable_keyboard_navigation: bool = None enable_animated_images: bool = None collapse_bot_comments: bool = None + default_comment_sort_type: str = None @classmethod def parse(cls, data: dict[str, Any]): @@ -697,26 +770,25 @@ def parse(cls, data: dict[str, Any]): email=data["email"] if "email" in data else None, show_nsfw=data["show_nsfw"], theme=data["theme"], - default_sort_type=data["default_sort_type"], + default_post_sort_type=data["default_post_sort_type"], default_listing_type=data["default_listing_type"], interface_language=data["interface_language"], show_avatars=data["show_avatars"], send_notifications_to_email=data["send_notifications_to_email"], - show_scores=data["show_scores"], show_bot_accounts=data["show_bot_accounts"], show_read_posts=data["show_read_posts"], email_verified=data["email_verified"], accepted_application=data["accepted_application"], open_links_in_new_tab=data["open_links_in_new_tab"], blur_nsfw=data["blur_nsfw"], - auto_expand=data["auto_expand"], infinite_scroll_enabled=data["infinite_scroll_enabled"], admin=data["admin"], post_listing_mode=data["post_listing_mode"], totp_2fa_enabled=data["totp_2fa_enabled"], enable_keyboard_navigation=data["enable_keyboard_navigation"], enable_animated_images=data["enable_animated_images"], - collapse_bot_comments=data["collapse_bot_comments"] + collapse_bot_comments=data["collapse_bot_comments"], + default_comment_sort_type=data["default_comment_sort_type"] ) @@ -737,6 +809,19 @@ def parse(cls, data: dict[str, Any]): ) +@dataclass +class CreateTagline: + """https://join-lemmy.org/api/interfaces/CreateTagline.html""" + + content: str = None + + @classmethod + def parse(cls, data: dict[str, Any]): + return cls( + content=data["content"] + ) + + @dataclass class MarkCommentReplyAsRead: """https://join-lemmy.org/api/interfaces/MarkCommentReplyAsRead.html""" @@ -765,6 +850,11 @@ class Search: listing_type: Optional[str] = None page: Optional[int] = None limit: Optional[int] = None + title_only: Optional[bool] = None + post_url_only: Optional[bool] = None + saved_only: Optional[bool] = None + liked_only: Optional[bool] = None + disliked_only: Optional[bool] = None @classmethod def parse(cls, data: dict[str, Any]): @@ -777,7 +867,12 @@ def parse(cls, data: dict[str, Any]): sort=data["sort"] if "sort" in data else None, listing_type=data["listing_type"] if "listing_type" in data else None, page=data["page"] if "page" in data else None, - limit=data["limit"] if "limit" in data else None + limit=data["limit"] if "limit" in data else None, + title_only=data["title_only"] if "title_only" in data else None, + post_url_only=data["post_url_only"] if "post_url_only" in data else None, + saved_only=data["saved_only"] if "saved_only" in data else None, + liked_only=data["liked_only"] if "liked_only" in data else None, + disliked_only=data["disliked_only"] if "disliked_only" in data else None ) @@ -785,7 +880,6 @@ def parse(cls, data: dict[str, Any]): class LocalUserVoteDisplayMode: """https://join-lemmy.org/api/interfaces/LocalUserVoteDisplayMode.html""" - local_user_id: int = None score: bool = None upvotes: bool = None downvotes: bool = None @@ -794,7 +888,6 @@ class LocalUserVoteDisplayMode: @classmethod def parse(cls, data: dict[str, Any]): return cls( - local_user_id=data["local_user_id"], score=data["score"], upvotes=data["upvotes"], downvotes=data["downvotes"], @@ -964,7 +1057,6 @@ class CustomEmoji: """https://join-lemmy.org/api/interfaces/CustomEmoji.html""" id: int = None - local_site_id: int = None shortcode: str = None image_url: str = None alt_text: str = None @@ -976,7 +1068,6 @@ class CustomEmoji: def parse(cls, data: dict[str, Any]): return cls( id=data["id"], - local_site_id=data["local_site_id"], shortcode=data["shortcode"], image_url=data["image_url"], alt_text=data["alt_text"], @@ -1056,6 +1147,29 @@ def parse(cls, data: dict[str, Any]): ) +@dataclass +class AuthenticateWithOauth: + """https://join-lemmy.org/api/interfaces/AuthenticateWithOauth.html""" + + code: str = None + oauth_provider_id: int = None + redirect_uri: str = None + show_nsfw: Optional[bool] = None + username: Optional[str] = None + answer: Optional[str] = None + + @classmethod + def parse(cls, data: dict[str, Any]): + return cls( + code=data["code"], + oauth_provider_id=data["oauth_provider_id"], + redirect_uri=data["redirect_uri"], + show_nsfw=data["show_nsfw"] if "show_nsfw" in data else None, + username=data["username"] if "username" in data else None, + answer=data["answer"] if "answer" in data else None + ) + + @dataclass class DeletePrivateMessage: """https://join-lemmy.org/api/interfaces/DeletePrivateMessage.html""" @@ -1078,7 +1192,7 @@ class Community: id: int = None name: str = None title: str = None - description: Optional[str] = None + sidebar: Optional[str] = None removed: bool = None published: str = None updated: Optional[str] = None @@ -1092,6 +1206,7 @@ class Community: posting_restricted_to_mods: bool = None instance_id: int = None visibility: str = None + description: Optional[str] = None @classmethod def parse(cls, data: dict[str, Any]): @@ -1099,7 +1214,7 @@ def parse(cls, data: dict[str, Any]): id=data["id"], name=data["name"], title=data["title"], - description=data["description"] if "description" in data else None, + sidebar=data["sidebar"] if "sidebar" in data else None, removed=data["removed"], published=data["published"], updated=data["updated"] if "updated" in data else None, @@ -1112,7 +1227,8 @@ def parse(cls, data: dict[str, Any]): hidden=data["hidden"], posting_restricted_to_mods=data["posting_restricted_to_mods"], instance_id=data["instance_id"], - visibility=data["visibility"] + visibility=data["visibility"], + description=data["description"] if "description" in data else None ) @@ -1270,6 +1386,7 @@ class EditPost: nsfw: Optional[bool] = None language_id: Optional[int] = None custom_thumbnail: Optional[str] = None + scheduled_publish_time: Optional[int] = None @classmethod def parse(cls, data: dict[str, Any]): @@ -1281,7 +1398,8 @@ def parse(cls, data: dict[str, Any]): alt_text=data["alt_text"] if "alt_text" in data else None, nsfw=data["nsfw"] if "nsfw" in data else None, language_id=data["language_id"] if "language_id" in data else None, - custom_thumbnail=data["custom_thumbnail"] if "custom_thumbnail" in data else None + custom_thumbnail=data["custom_thumbnail"] if "custom_thumbnail" in data else None, + scheduled_publish_time=data["scheduled_publish_time"] if "scheduled_publish_time" in data else None ) @@ -1334,6 +1452,21 @@ def parse(cls, data: dict[str, Any]): ) +@dataclass +class ListTaglines: + """https://join-lemmy.org/api/interfaces/ListTaglines.html""" + + page: Optional[int] = None + limit: Optional[int] = None + + @classmethod + def parse(cls, data: dict[str, Any]): + return cls( + page=data["page"] if "page" in data else None, + limit=data["limit"] if "limit" in data else None + ) + + @dataclass class ModBan: """https://join-lemmy.org/api/interfaces/ModBan.html""" @@ -1364,7 +1497,6 @@ class Tagline: """https://join-lemmy.org/api/interfaces/Tagline.html""" id: int = None - local_site_id: int = None content: str = None published: str = None updated: Optional[str] = None @@ -1373,7 +1505,6 @@ class Tagline: def parse(cls, data: dict[str, Any]): return cls( id=data["id"], - local_site_id=data["local_site_id"], content=data["content"], published=data["published"], updated=data["updated"] if "updated" in data else None @@ -1412,6 +1543,19 @@ def parse(cls, data: dict[str, Any]): ) +@dataclass +class PublicOAuthProvider: + """https://join-lemmy.org/api/interfaces/PublicOAuthProvider.html""" + + + + @classmethod + def parse(cls, data: dict[str, Any]): + return cls( + + ) + + @dataclass class MarkPostAsRead: """https://join-lemmy.org/api/interfaces/MarkPostAsRead.html""" @@ -1427,6 +1571,25 @@ def parse(cls, data: dict[str, Any]): ) +@dataclass +class PendingFollow: + """https://join-lemmy.org/api/interfaces/PendingFollow.html""" + + person: Person = None + community: Community = None + is_new_instance: bool = None + subscribed: str = None + + @classmethod + def parse(cls, data: dict[str, Any]): + return cls( + person=Person.parse(data["person"]), + community=Community.parse(data["community"]), + is_new_instance=data["is_new_instance"], + subscribed=data["subscribed"] + ) + + @dataclass class ResolvePrivateMessageReport: """https://join-lemmy.org/api/interfaces/ResolvePrivateMessageReport.html""" @@ -1446,20 +1609,20 @@ def parse(cls, data: dict[str, Any]): class LinkMetadata: """https://join-lemmy.org/api/interfaces/LinkMetadata.html""" + content_type: Optional[str] = None title: Optional[str] = None description: Optional[str] = None image: Optional[str] = None embed_video_url: Optional[str] = None - content_type: Optional[str] = None @classmethod def parse(cls, data: dict[str, Any]): return cls( + content_type=data["content_type"] if "content_type" in data else None, title=data["title"] if "title" in data else None, description=data["description"] if "description" in data else None, image=data["image"] if "image" in data else None, - embed_video_url=data["embed_video_url"] if "embed_video_url" in data else None, - content_type=data["content_type"] if "content_type" in data else None + embed_video_url=data["embed_video_url"] if "embed_video_url" in data else None ) @@ -1509,6 +1672,27 @@ def parse(cls, data: dict[str, Any]): ) +@dataclass +class OAuthAccount: + """https://join-lemmy.org/api/interfaces/OAuthAccount.html""" + + local_user_id: int = None + oauth_provider_id: int = None + oauth_user_id: str = None + published: str = None + updated: Optional[str] = None + + @classmethod + def parse(cls, data: dict[str, Any]): + return cls( + local_user_id=data["local_user_id"], + oauth_provider_id=data["oauth_provider_id"], + oauth_user_id=data["oauth_user_id"], + published=data["published"], + updated=data["updated"] if "updated" in data else None + ) + + @dataclass class PurgeComment: """https://join-lemmy.org/api/interfaces/PurgeComment.html""" @@ -1537,6 +1721,7 @@ class CreatePost: nsfw: Optional[bool] = None language_id: Optional[int] = None custom_thumbnail: Optional[str] = None + scheduled_publish_time: Optional[int] = None @classmethod def parse(cls, data: dict[str, Any]): @@ -1549,7 +1734,8 @@ def parse(cls, data: dict[str, Any]): honeypot=data["honeypot"] if "honeypot" in data else None, nsfw=data["nsfw"] if "nsfw" in data else None, language_id=data["language_id"] if "language_id" in data else None, - custom_thumbnail=data["custom_thumbnail"] if "custom_thumbnail" in data else None + custom_thumbnail=data["custom_thumbnail"] if "custom_thumbnail" in data else None, + scheduled_publish_time=data["scheduled_publish_time"] if "scheduled_publish_time" in data else None ) @@ -1578,24 +1764,24 @@ def parse(cls, data: dict[str, Any]): class InstanceWithFederationState: """https://join-lemmy.org/api/interfaces/InstanceWithFederationState.html""" + federation_state: Optional[ReadableFederationState] = None id: int = None domain: str = None published: str = None updated: Optional[str] = None software: Optional[str] = None version: Optional[str] = None - federation_state: Optional[ReadableFederationState] = None @classmethod def parse(cls, data: dict[str, Any]): return cls( + federation_state=ReadableFederationState.parse(data["federation_state"]) if "federation_state" in data else None, id=data["id"], domain=data["domain"], published=data["published"], updated=data["updated"] if "updated" in data else None, software=data["software"] if "software" in data else None, - version=data["version"] if "version" in data else None, - federation_state=ReadableFederationState.parse(data["federation_state"]) if "federation_state" in data else None + version=data["version"] if "version" in data else None ) @@ -1655,6 +1841,7 @@ class EditCommunity: community_id: int = None title: Optional[str] = None + sidebar: Optional[str] = None description: Optional[str] = None icon: Optional[str] = None banner: Optional[str] = None @@ -1668,6 +1855,7 @@ def parse(cls, data: dict[str, Any]): return cls( community_id=data["community_id"], title=data["title"] if "title" in data else None, + sidebar=data["sidebar"] if "sidebar" in data else None, description=data["description"] if "description" in data else None, icon=data["icon"] if "icon" in data else None, banner=data["banner"] if "banner" in data else None, @@ -1739,6 +1927,45 @@ def parse(cls, data: dict[str, Any]): ) +@dataclass +class OAuthProvider: + """https://join-lemmy.org/api/interfaces/OAuthProvider.html""" + + id: int = None + display_name: str = None + issuer: str = None + authorization_endpoint: str = None + token_endpoint: str = None + userinfo_endpoint: str = None + id_claim: str = None + client_id: str = None + scopes: str = None + auto_verify_email: bool = None + account_linking_enabled: bool = None + enabled: bool = None + published: str = None + updated: Optional[str] = None + + @classmethod + def parse(cls, data: dict[str, Any]): + return cls( + id=data["id"], + display_name=data["display_name"], + issuer=data["issuer"], + authorization_endpoint=data["authorization_endpoint"], + token_endpoint=data["token_endpoint"], + userinfo_endpoint=data["userinfo_endpoint"], + id_claim=data["id_claim"], + client_id=data["client_id"], + scopes=data["scopes"], + auto_verify_email=data["auto_verify_email"], + account_linking_enabled=data["account_linking_enabled"], + enabled=data["enabled"], + published=data["published"], + updated=data["updated"] if "updated" in data else None + ) + + @dataclass class BanFromCommunity: """https://join-lemmy.org/api/interfaces/BanFromCommunity.html""" @@ -1746,7 +1973,7 @@ class BanFromCommunity: community_id: int = None person_id: int = None ban: bool = None - remove_data: Optional[bool] = None + remove_or_restore_data: Optional[bool] = None reason: Optional[str] = None expires: Optional[int] = None @@ -1756,7 +1983,7 @@ def parse(cls, data: dict[str, Any]): community_id=data["community_id"], person_id=data["person_id"], ban=data["ban"], - remove_data=data["remove_data"] if "remove_data" in data else None, + remove_or_restore_data=data["remove_or_restore_data"] if "remove_or_restore_data" in data else None, reason=data["reason"] if "reason" in data else None, expires=data["expires"] if "expires" in data else None ) @@ -1861,10 +2088,11 @@ class SaveUserSettings: show_nsfw: Optional[bool] = None blur_nsfw: Optional[bool] = None - auto_expand: Optional[bool] = None theme: Optional[str] = None - default_sort_type: Optional[str] = None default_listing_type: Optional[str] = None + post_listing_mode: Optional[str] = None + default_post_sort_type: Optional[str] = None + default_comment_sort_type: Optional[str] = None interface_language: Optional[str] = None avatar: Optional[str] = None banner: Optional[str] = None @@ -1880,7 +2108,6 @@ class SaveUserSettings: discussion_languages: Optional[list[int]] = None open_links_in_new_tab: Optional[bool] = None infinite_scroll_enabled: Optional[bool] = None - post_listing_mode: Optional[str] = None enable_keyboard_navigation: Optional[bool] = None enable_animated_images: Optional[bool] = None collapse_bot_comments: Optional[bool] = None @@ -1894,10 +2121,11 @@ def parse(cls, data: dict[str, Any]): return cls( show_nsfw=data["show_nsfw"] if "show_nsfw" in data else None, blur_nsfw=data["blur_nsfw"] if "blur_nsfw" in data else None, - auto_expand=data["auto_expand"] if "auto_expand" in data else None, theme=data["theme"] if "theme" in data else None, - default_sort_type=data["default_sort_type"] if "default_sort_type" in data else None, default_listing_type=data["default_listing_type"] if "default_listing_type" in data else None, + post_listing_mode=data["post_listing_mode"] if "post_listing_mode" in data else None, + default_post_sort_type=data["default_post_sort_type"] if "default_post_sort_type" in data else None, + default_comment_sort_type=data["default_comment_sort_type"] if "default_comment_sort_type" in data else None, interface_language=data["interface_language"] if "interface_language" in data else None, avatar=data["avatar"] if "avatar" in data else None, banner=data["banner"] if "banner" in data else None, @@ -1913,7 +2141,6 @@ def parse(cls, data: dict[str, Any]): discussion_languages=[e0 for e0 in data["discussion_languages"]] if "discussion_languages" in data else None, open_links_in_new_tab=data["open_links_in_new_tab"] if "open_links_in_new_tab" in data else None, infinite_scroll_enabled=data["infinite_scroll_enabled"] if "infinite_scroll_enabled" in data else None, - post_listing_mode=data["post_listing_mode"] if "post_listing_mode" in data else None, enable_keyboard_navigation=data["enable_keyboard_navigation"] if "enable_keyboard_navigation" in data else None, enable_animated_images=data["enable_animated_images"] if "enable_animated_images" in data else None, collapse_bot_comments=data["collapse_bot_comments"] if "collapse_bot_comments" in data else None, @@ -1924,6 +2151,32 @@ def parse(cls, data: dict[str, Any]): ) +@dataclass +class GetRandomCommunity: + """https://join-lemmy.org/api/interfaces/GetRandomCommunity.html""" + + type_: Optional[str] = None + + @classmethod + def parse(cls, data: dict[str, Any]): + return cls( + type_=data["type_"] if "type_" in data else None + ) + + +@dataclass +class DeleteTagline: + """https://join-lemmy.org/api/interfaces/DeleteTagline.html""" + + id: int = None + + @classmethod + def parse(cls, data: dict[str, Any]): + return cls( + id=data["id"] + ) + + @dataclass class CreatePrivateMessage: """https://join-lemmy.org/api/interfaces/CreatePrivateMessage.html""" @@ -2001,6 +2254,41 @@ def parse(cls, data: dict[str, Any]): ) +@dataclass +class CreateOAuthProvider: + """https://join-lemmy.org/api/interfaces/CreateOAuthProvider.html""" + + display_name: str = None + issuer: str = None + authorization_endpoint: str = None + token_endpoint: str = None + userinfo_endpoint: str = None + id_claim: str = None + client_id: str = None + client_secret: str = None + scopes: str = None + auto_verify_email: Optional[bool] = None + account_linking_enabled: Optional[bool] = None + enabled: Optional[bool] = None + + @classmethod + def parse(cls, data: dict[str, Any]): + return cls( + display_name=data["display_name"], + issuer=data["issuer"], + authorization_endpoint=data["authorization_endpoint"], + token_endpoint=data["token_endpoint"], + userinfo_endpoint=data["userinfo_endpoint"], + id_claim=data["id_claim"], + client_id=data["client_id"], + client_secret=data["client_secret"], + scopes=data["scopes"], + auto_verify_email=data["auto_verify_email"] if "auto_verify_email" in data else None, + account_linking_enabled=data["account_linking_enabled"] if "account_linking_enabled" in data else None, + enabled=data["enabled"] if "enabled" in data else None + ) + + @dataclass class SaveComment: """https://join-lemmy.org/api/interfaces/SaveComment.html""" @@ -2031,6 +2319,19 @@ def parse(cls, data: dict[str, Any]): ) +@dataclass +class DeleteOAuthProvider: + """https://join-lemmy.org/api/interfaces/DeleteOAuthProvider.html""" + + id: int = None + + @classmethod + def parse(cls, data: dict[str, Any]): + return cls( + id=data["id"] + ) + + @dataclass class LocalSite: """https://join-lemmy.org/api/interfaces/LocalSite.html""" @@ -2038,8 +2339,6 @@ class LocalSite: id: int = None site_id: int = None site_setup: bool = None - enable_downvotes: bool = None - enable_nsfw: bool = None community_creation_admin_only: bool = None require_email_verification: bool = None application_question: Optional[str] = None @@ -2060,7 +2359,13 @@ class LocalSite: reports_email_admins: bool = None federation_signed_fetch: bool = None default_post_listing_mode: str = None - default_sort_type: str = None + default_post_sort_type: str = None + default_comment_sort_type: str = None + oauth_registration: bool = None + post_upvotes: str = None + post_downvotes: str = None + comment_upvotes: str = None + comment_downvotes: str = None @classmethod def parse(cls, data: dict[str, Any]): @@ -2068,8 +2373,6 @@ def parse(cls, data: dict[str, Any]): id=data["id"], site_id=data["site_id"], site_setup=data["site_setup"], - enable_downvotes=data["enable_downvotes"], - enable_nsfw=data["enable_nsfw"], community_creation_admin_only=data["community_creation_admin_only"], require_email_verification=data["require_email_verification"], application_question=data["application_question"] if "application_question" in data else None, @@ -2090,7 +2393,13 @@ def parse(cls, data: dict[str, Any]): reports_email_admins=data["reports_email_admins"], federation_signed_fetch=data["federation_signed_fetch"], default_post_listing_mode=data["default_post_listing_mode"], - default_sort_type=data["default_sort_type"] + default_post_sort_type=data["default_post_sort_type"], + default_comment_sort_type=data["default_comment_sort_type"], + oauth_registration=data["oauth_registration"], + post_upvotes=data["post_upvotes"], + post_downvotes=data["post_downvotes"], + comment_upvotes=data["comment_upvotes"], + comment_downvotes=data["comment_downvotes"] ) @@ -2194,6 +2503,39 @@ def parse(cls, data: dict[str, Any]): ) +@dataclass +class EditOAuthProvider: + """https://join-lemmy.org/api/interfaces/EditOAuthProvider.html""" + + id: int = None + display_name: Optional[str] = None + authorization_endpoint: Optional[str] = None + token_endpoint: Optional[str] = None + userinfo_endpoint: Optional[str] = None + id_claim: Optional[str] = None + client_secret: Optional[str] = None + scopes: Optional[str] = None + auto_verify_email: Optional[bool] = None + account_linking_enabled: Optional[bool] = None + enabled: Optional[bool] = None + + @classmethod + def parse(cls, data: dict[str, Any]): + return cls( + id=data["id"], + display_name=data["display_name"] if "display_name" in data else None, + authorization_endpoint=data["authorization_endpoint"] if "authorization_endpoint" in data else None, + token_endpoint=data["token_endpoint"] if "token_endpoint" in data else None, + userinfo_endpoint=data["userinfo_endpoint"] if "userinfo_endpoint" in data else None, + id_claim=data["id_claim"] if "id_claim" in data else None, + client_secret=data["client_secret"] if "client_secret" in data else None, + scopes=data["scopes"] if "scopes" in data else None, + auto_verify_email=data["auto_verify_email"] if "auto_verify_email" in data else None, + account_linking_enabled=data["account_linking_enabled"] if "account_linking_enabled" in data else None, + enabled=data["enabled"] if "enabled" in data else None + ) + + @dataclass class ModBanFromCommunity: """https://join-lemmy.org/api/interfaces/ModBanFromCommunity.html""" @@ -2742,7 +3084,7 @@ class BanPerson: person_id: int = None ban: bool = None - remove_data: Optional[bool] = None + remove_or_restore_data: Optional[bool] = None reason: Optional[str] = None expires: Optional[int] = None @@ -2751,7 +3093,7 @@ def parse(cls, data: dict[str, Any]): return cls( person_id=data["person_id"], ban=data["ban"], - remove_data=data["remove_data"] if "remove_data" in data else None, + remove_or_restore_data=data["remove_or_restore_data"] if "remove_or_restore_data" in data else None, reason=data["reason"] if "reason" in data else None, expires=data["expires"] if "expires" in data else None ) @@ -2799,6 +3141,25 @@ def parse(cls, data: dict[str, Any]): ) +@dataclass +class ListCustomEmojis: + """https://join-lemmy.org/api/interfaces/ListCustomEmojis.html""" + + page: Optional[int] = None + limit: Optional[int] = None + category: Optional[str] = None + ignore_page_limits: Optional[bool] = None + + @classmethod + def parse(cls, data: dict[str, Any]): + return cls( + page=data["page"] if "page" in data else None, + limit=data["limit"] if "limit" in data else None, + category=data["category"] if "category" in data else None, + ignore_page_limits=data["ignore_page_limits"] if "ignore_page_limits" in data else None + ) + + @dataclass class EditSite: """https://join-lemmy.org/api/interfaces/EditSite.html""" @@ -2808,7 +3169,6 @@ class EditSite: description: Optional[str] = None icon: Optional[str] = None banner: Optional[str] = None - enable_downvotes: Optional[bool] = None enable_nsfw: Optional[bool] = None community_creation_admin_only: Optional[bool] = None require_email_verification: Optional[bool] = None @@ -2816,7 +3176,9 @@ class EditSite: private_instance: Optional[bool] = None default_theme: Optional[str] = None default_post_listing_type: Optional[str] = None - default_sort_type: Optional[str] = None + default_post_listing_mode: Optional[str] = None + default_post_sort_type: Optional[str] = None + default_comment_sort_type: Optional[str] = None legal_information: Optional[str] = None application_email_admins: Optional[bool] = None hide_modlog_mod_names: Optional[bool] = None @@ -2842,11 +3204,14 @@ class EditSite: allowed_instances: Optional[list[str]] = None blocked_instances: Optional[list[str]] = None blocked_urls: Optional[list[str]] = None - taglines: Optional[list[str]] = None registration_mode: Optional[str] = None reports_email_admins: Optional[bool] = None content_warning: Optional[str] = None - default_post_listing_mode: Optional[str] = None + oauth_registration: Optional[bool] = None + post_upvotes: Optional[str] = None + post_downvotes: Optional[str] = None + comment_upvotes: Optional[str] = None + comment_downvotes: Optional[str] = None @classmethod def parse(cls, data: dict[str, Any]): @@ -2856,7 +3221,6 @@ def parse(cls, data: dict[str, Any]): description=data["description"] if "description" in data else None, icon=data["icon"] if "icon" in data else None, banner=data["banner"] if "banner" in data else None, - enable_downvotes=data["enable_downvotes"] if "enable_downvotes" in data else None, enable_nsfw=data["enable_nsfw"] if "enable_nsfw" in data else None, community_creation_admin_only=data["community_creation_admin_only"] if "community_creation_admin_only" in data else None, require_email_verification=data["require_email_verification"] if "require_email_verification" in data else None, @@ -2864,7 +3228,9 @@ def parse(cls, data: dict[str, Any]): private_instance=data["private_instance"] if "private_instance" in data else None, default_theme=data["default_theme"] if "default_theme" in data else None, default_post_listing_type=data["default_post_listing_type"] if "default_post_listing_type" in data else None, - default_sort_type=data["default_sort_type"] if "default_sort_type" in data else None, + default_post_listing_mode=data["default_post_listing_mode"] if "default_post_listing_mode" in data else None, + default_post_sort_type=data["default_post_sort_type"] if "default_post_sort_type" in data else None, + default_comment_sort_type=data["default_comment_sort_type"] if "default_comment_sort_type" in data else None, legal_information=data["legal_information"] if "legal_information" in data else None, application_email_admins=data["application_email_admins"] if "application_email_admins" in data else None, hide_modlog_mod_names=data["hide_modlog_mod_names"] if "hide_modlog_mod_names" in data else None, @@ -2890,11 +3256,14 @@ def parse(cls, data: dict[str, Any]): allowed_instances=[e0 for e0 in data["allowed_instances"]] if "allowed_instances" in data else None, blocked_instances=[e0 for e0 in data["blocked_instances"]] if "blocked_instances" in data else None, blocked_urls=[e0 for e0 in data["blocked_urls"]] if "blocked_urls" in data else None, - taglines=[e0 for e0 in data["taglines"]] if "taglines" in data else None, registration_mode=data["registration_mode"] if "registration_mode" in data else None, reports_email_admins=data["reports_email_admins"] if "reports_email_admins" in data else None, content_warning=data["content_warning"] if "content_warning" in data else None, - default_post_listing_mode=data["default_post_listing_mode"] if "default_post_listing_mode" in data else None + oauth_registration=data["oauth_registration"] if "oauth_registration" in data else None, + post_upvotes=data["post_upvotes"] if "post_upvotes" in data else None, + post_downvotes=data["post_downvotes"] if "post_downvotes" in data else None, + comment_upvotes=data["comment_upvotes"] if "comment_upvotes" in data else None, + comment_downvotes=data["comment_downvotes"] if "comment_downvotes" in data else None ) @@ -2948,6 +3317,7 @@ class Post: featured_local: bool = None url_content_type: Optional[str] = None alt_text: Optional[str] = None + scheduled_publish_time: Optional[str] = None @classmethod def parse(cls, data: dict[str, Any]): @@ -2974,7 +3344,8 @@ def parse(cls, data: dict[str, Any]): featured_community=data["featured_community"], featured_local=data["featured_local"], url_content_type=data["url_content_type"] if "url_content_type" in data else None, - alt_text=data["alt_text"] if "alt_text" in data else None + alt_text=data["alt_text"] if "alt_text" in data else None, + scheduled_publish_time=data["scheduled_publish_time"] if "scheduled_publish_time" in data else None ) @@ -2994,6 +3365,7 @@ class GetPosts: show_hidden: Optional[bool] = None show_read: Optional[bool] = None show_nsfw: Optional[bool] = None + no_comments_only: Optional[bool] = None page_cursor: Optional[str] = None @classmethod @@ -3011,6 +3383,7 @@ def parse(cls, data: dict[str, Any]): show_hidden=data["show_hidden"] if "show_hidden" in data else None, show_read=data["show_read"] if "show_read" in data else None, show_nsfw=data["show_nsfw"] if "show_nsfw" in data else None, + no_comments_only=data["no_comments_only"] if "no_comments_only" in data else None, page_cursor=data["page_cursor"] if "page_cursor" in data else None ) diff --git a/pythonlemmy/responses.py b/pythonlemmy/responses.py index c036b93..3c9e658 100644 --- a/pythonlemmy/responses.py +++ b/pythonlemmy/responses.py @@ -231,6 +231,24 @@ def data( return obj +class GetCommunityPendingFollowsCountResponse(ResponseWrapper): + """https://join-lemmy.org/api/interfaces/GetCommunityPendingFollowsCountResponse.html""" + + count: int = None + + def parse(self, data: dict[str, Any]): + self.count = data["count"] + + @classmethod + def data( + cls, + count: int = None + ): + obj = cls.__new__(cls) + obj.count = count + return obj + + class PrivateMessageResponse(ResponseWrapper): """https://join-lemmy.org/api/interfaces/PrivateMessageResponse.html""" @@ -297,6 +315,24 @@ def data( return obj +class ListTaglinesResponse(ResponseWrapper): + """https://join-lemmy.org/api/interfaces/ListTaglinesResponse.html""" + + taglines: list[Tagline] = None + + def parse(self, data: dict[str, Any]): + self.taglines = [Tagline.parse(e0) for e0 in data["taglines"]] + + @classmethod + def data( + cls, + taglines: list[Tagline] = None + ): + obj = cls.__new__(cls) + obj.taglines = taglines + return obj + + class PostReportResponse(ResponseWrapper): """https://join-lemmy.org/api/interfaces/PostReportResponse.html""" @@ -342,8 +378,9 @@ class GetSiteResponse(ResponseWrapper): my_user: Optional[MyUserInfo] = None all_languages: list[Language] = None discussion_languages: list[int] = None - taglines: list[Tagline] = None - custom_emojis: list[CustomEmojiView] = None + tagline: Optional[Tagline] = None + oauth_providers: Optional[list[PublicOAuthProvider]] = None + admin_oauth_providers: Optional[list[OAuthProvider]] = None blocked_urls: list[LocalSiteUrlBlocklist] = None def parse(self, data: dict[str, Any]): @@ -353,8 +390,9 @@ def parse(self, data: dict[str, Any]): self.my_user = MyUserInfo.parse(data["my_user"]) if "my_user" in data else None self.all_languages = [Language.parse(e0) for e0 in data["all_languages"]] self.discussion_languages = [e0 for e0 in data["discussion_languages"]] - self.taglines = [Tagline.parse(e0) for e0 in data["taglines"]] - self.custom_emojis = [CustomEmojiView.parse(e0) for e0 in data["custom_emojis"]] + self.tagline = Tagline.parse(data["tagline"]) if "tagline" in data else None + self.oauth_providers = [PublicOAuthProvider.parse(e0) for e0 in data["oauth_providers"]] if "oauth_providers" in data else None + self.admin_oauth_providers = [OAuthProvider.parse(e0) for e0 in data["admin_oauth_providers"]] if "admin_oauth_providers" in data else None self.blocked_urls = [LocalSiteUrlBlocklist.parse(e0) for e0 in data["blocked_urls"]] @classmethod @@ -366,8 +404,9 @@ def data( my_user: Optional[MyUserInfo] = None, all_languages: list[Language] = None, discussion_languages: list[int] = None, - taglines: list[Tagline] = None, - custom_emojis: list[CustomEmojiView] = None, + tagline: Optional[Tagline] = None, + oauth_providers: Optional[list[PublicOAuthProvider]] = None, + admin_oauth_providers: Optional[list[OAuthProvider]] = None, blocked_urls: list[LocalSiteUrlBlocklist] = None ): obj = cls.__new__(cls) @@ -377,8 +416,9 @@ def data( obj.my_user = my_user obj.all_languages = all_languages obj.discussion_languages = discussion_languages - obj.taglines = taglines - obj.custom_emojis = custom_emojis + obj.tagline = tagline + obj.oauth_providers = oauth_providers + obj.admin_oauth_providers = admin_oauth_providers obj.blocked_urls = blocked_urls return obj @@ -419,6 +459,24 @@ def data( return obj +class ListLoginsResponse(ResponseWrapper): + """https://join-lemmy.org/api/interfaces/ListLoginsResponse.html""" + + logins: list[LoginToken] = None + + def parse(self, data: dict[str, Any]): + self.logins = [LoginToken.parse(e0) for e0 in data["logins"]] + + @classmethod + def data( + cls, + logins: list[LoginToken] = None + ): + obj = cls.__new__(cls) + obj.logins = logins + return obj + + class GetModlogResponse(ResponseWrapper): """https://join-lemmy.org/api/interfaces/GetModlogResponse.html""" @@ -599,21 +657,17 @@ class SiteResponse(ResponseWrapper): """https://join-lemmy.org/api/interfaces/SiteResponse.html""" site_view: SiteView = None - taglines: list[Tagline] = None def parse(self, data: dict[str, Any]): self.site_view = SiteView.parse(data["site_view"]) - self.taglines = [Tagline.parse(e0) for e0 in data["taglines"]] @classmethod def data( cls, - site_view: SiteView = None, - taglines: list[Tagline] = None + site_view: SiteView = None ): obj = cls.__new__(cls) obj.site_view = site_view - obj.taglines = taglines return obj @@ -675,6 +729,24 @@ def data( return obj +class ListCommunityPendingFollowsResponse(ResponseWrapper): + """https://join-lemmy.org/api/interfaces/ListCommunityPendingFollowsResponse.html""" + + items: list[PendingFollow] = None + + def parse(self, data: dict[str, Any]): + self.items = [PendingFollow.parse(e0) for e0 in data["items"]] + + @classmethod + def data( + cls, + items: list[PendingFollow] = None + ): + obj = cls.__new__(cls) + obj.items = items + return obj + + class LoginResponse(ResponseWrapper): """https://join-lemmy.org/api/interfaces/LoginResponse.html""" @@ -821,6 +893,24 @@ def data( return obj +class TaglineResponse(ResponseWrapper): + """https://join-lemmy.org/api/interfaces/TaglineResponse.html""" + + tagline: Tagline = None + + def parse(self, data: dict[str, Any]): + self.tagline = Tagline.parse(data["tagline"]) + + @classmethod + def data( + cls, + tagline: Tagline = None + ): + obj = cls.__new__(cls) + obj.tagline = tagline + return obj + + class BanPersonResponse(ResponseWrapper): """https://join-lemmy.org/api/interfaces/BanPersonResponse.html""" @@ -1131,6 +1221,24 @@ def data( return obj +class ListCustomEmojisResponse(ResponseWrapper): + """https://join-lemmy.org/api/interfaces/ListCustomEmojisResponse.html""" + + custom_emojis: list[CustomEmojiView] = None + + def parse(self, data: dict[str, Any]): + self.custom_emojis = [CustomEmojiView.parse(e0) for e0 in data["custom_emojis"]] + + @classmethod + def data( + cls, + custom_emojis: list[CustomEmojiView] = None + ): + obj = cls.__new__(cls) + obj.custom_emojis = custom_emojis + return obj + + class ListCommentLikesResponse(ResponseWrapper): """https://join-lemmy.org/api/interfaces/ListCommentLikesResponse.html""" diff --git a/pythonlemmy/views.py b/pythonlemmy/views.py index 7f66e3b..7da6afc 100644 --- a/pythonlemmy/views.py +++ b/pythonlemmy/views.py @@ -187,21 +187,6 @@ def parse(cls, data: dict[str, Any]): ) -@dataclass -class CommunityBlockView: - """https://join-lemmy.org/api/interfaces/CommunityBlockView.html""" - - person: Person = None - community: Community = None - - @classmethod - def parse(cls, data: dict[str, Any]): - return cls( - person=Person.parse(data["person"]), - community=Community.parse(data["community"]) - ) - - @dataclass class ModBanFromCommunityView: """https://join-lemmy.org/api/interfaces/ModBanFromCommunityView.html""" @@ -264,23 +249,6 @@ def parse(cls, data: dict[str, Any]): ) -@dataclass -class InstanceBlockView: - """https://join-lemmy.org/api/interfaces/InstanceBlockView.html""" - - person: Person = None - instance: Instance = None - site: Optional[Site] = None - - @classmethod - def parse(cls, data: dict[str, Any]): - return cls( - person=Person.parse(data["person"]), - instance=Instance.parse(data["instance"]), - site=Site.parse(data["site"]) if "site" in data else None - ) - - @dataclass class ModRemoveCommunityView: """https://join-lemmy.org/api/interfaces/ModRemoveCommunityView.html""" @@ -374,21 +342,6 @@ def parse(cls, data: dict[str, Any]): ) -@dataclass -class PersonBlockView: - """https://join-lemmy.org/api/interfaces/PersonBlockView.html""" - - person: Person = None - target: Person = None - - @classmethod - def parse(cls, data: dict[str, Any]): - return cls( - person=Person.parse(data["person"]), - target=Person.parse(data["target"]) - ) - - @dataclass class CommunityModeratorView: """https://join-lemmy.org/api/interfaces/CommunityModeratorView.html""" @@ -485,9 +438,9 @@ class MyUserInfo: local_user_view: LocalUserView = None follows: list[CommunityFollowerView] = None moderates: list[CommunityModeratorView] = None - community_blocks: list[CommunityBlockView] = None - instance_blocks: list[InstanceBlockView] = None - person_blocks: list[PersonBlockView] = None + community_blocks: list[Community] = None + instance_blocks: list[Instance] = None + person_blocks: list[Person] = None discussion_languages: list[int] = None @classmethod @@ -496,9 +449,9 @@ def parse(cls, data: dict[str, Any]): local_user_view=LocalUserView.parse(data["local_user_view"]), follows=[CommunityFollowerView.parse(e0) for e0 in data["follows"]], moderates=[CommunityModeratorView.parse(e0) for e0 in data["moderates"]], - community_blocks=[CommunityBlockView.parse(e0) for e0 in data["community_blocks"]], - instance_blocks=[InstanceBlockView.parse(e0) for e0 in data["instance_blocks"]], - person_blocks=[PersonBlockView.parse(e0) for e0 in data["person_blocks"]], + community_blocks=[Community.parse(e0) for e0 in data["community_blocks"]], + instance_blocks=[Instance.parse(e0) for e0 in data["instance_blocks"]], + person_blocks=[Person.parse(e0) for e0 in data["person_blocks"]], discussion_languages=[e0 for e0 in data["discussion_languages"]] ) diff --git a/type-generator/main.py b/type-generator/main.py index 8bf439a..8f2bc7d 100644 --- a/type-generator/main.py +++ b/type-generator/main.py @@ -7,7 +7,8 @@ from openapi_parser.parser import OpenApiParser from tree_sitter import Parser, Language import tree_sitter_typescript as ts_typescript -from src import ModelVisitor, EnumVisitor, HttpVisitor, ClassType, ModelGenerator, HttpGenerator, Property +from src import ModelVisitor, EnumVisitor, HttpVisitor, ClassType, ModelGenerator, HttpGenerator, Property, \ + TypeAliasVisitor parser = Parser() parser.set_language(Language(ts_typescript.language_typescript(), "TypeScript")) @@ -15,6 +16,7 @@ # model_dir = "./test_output" enum_names = [] +type_aliases = {} objects = [] responses = [] @@ -28,10 +30,10 @@ def list_enums(): files = os.listdir(types_dir) for file in files: - if file.endswith("Id.ts"): - continue with open(f"{types_dir}{file}", "r") as f: - parse_enum(f.read()) + content = f.read() + parse_enum(content) + parse_type_alias(content) def generate_types(): @@ -42,11 +44,15 @@ def generate_types(): os.makedirs(model_dir) for file in files: - if file.endswith("Id.ts"): + file_without_extension = file[:-len(".ts")] + if file_without_extension in enum_names or file_without_extension in type_aliases.keys(): continue with open(f"{types_dir}{file}", "r") as f: + print(f"File = {types_dir}{file}") parse_model(f.read()) + print(f"Object count = {len(objects)}, Response count = {len(responses)}, View count = {len(views)}") + with open(f"./headers/object_header.py", "r") as f: object_header = f.read() with open(f"./headers/response_header.py", "r") as f: @@ -77,15 +83,34 @@ def parse_enum(model_contents: str): visitor = EnumVisitor(tree) visitor.walk() + if not visitor.is_enum: + return + enum_names.append(visitor.enum_name) +def parse_type_alias(model_contents: str): + tree = parser.parse(bytes(model_contents, "utf-8")) + + if "export type" not in model_contents: + return + + visitor = TypeAliasVisitor(tree) + visitor.walk() + + if not visitor.is_type_alias: + return + + type_aliases[visitor.type_alias_name] = visitor.mapped_type + + def parse_model(model_contents: str): tree = parser.parse(bytes(model_contents, "utf-8")) - if "export interface" not in model_contents: + if "export type" not in model_contents: return - visitor = ModelVisitor(tree, enum_names) + + visitor = ModelVisitor(tree, enum_names, type_aliases) visitor.walk() result = ModelGenerator(visitor.class_name, visitor.properties, visitor.class_type).build() if visitor.class_type == ClassType.VIEW: @@ -117,7 +142,7 @@ def parse_http() -> str: tree = parser.parse(bytes(f.read(), "utf-8")) visitor = HttpVisitor(tree) visitor.walk() - result = HttpGenerator(visitor.methods, types_dir, enum_names, docs).build() + result = HttpGenerator(visitor.methods, types_dir, enum_names, type_aliases, docs).build() return result diff --git a/type-generator/src/generator/http_generator.py b/type-generator/src/generator/http_generator.py index 143b2ec..3dc7192 100644 --- a/type-generator/src/generator/http_generator.py +++ b/type-generator/src/generator/http_generator.py @@ -1,5 +1,5 @@ import textwrap -from typing import List, Optional +from typing import List, Optional, Dict from openapi_parser.model import ModelEndpoint, ModelSchema, ModelEnumData from openapi_parser.parser import OpenApiParser, ModelEnumDataImpl @@ -32,10 +32,11 @@ class HttpGenerator: _methods: List[ApiMethod] = [] - def __init__(self, methods: List[ApiMethod], types_dir: str, enums: List[str], + def __init__(self, methods: List[ApiMethod], types_dir: str, enums: List[str], type_aliases: Dict[str, str], openapi: Optional[OpenApiParser] = None): self._methods = methods self._types_dir = types_dir + self._type_aliases = type_aliases self._enums = enums self._openapi = openapi @@ -147,6 +148,6 @@ def _get_properties(self, method: ApiMethod) -> List[Property]: with open(f"{self._types_dir}/{method.input}.ts", "r") as f: tree = parser.parse(bytes(f.read(), "utf-8")) - visitor = ModelVisitor(tree, self._enums) + visitor = ModelVisitor(tree, self._enums, self._type_aliases) visitor.walk() return visitor.properties diff --git a/type-generator/src/visitor/__init__.py b/type-generator/src/visitor/__init__.py index 3d65af6..1a3a7dd 100644 --- a/type-generator/src/visitor/__init__.py +++ b/type-generator/src/visitor/__init__.py @@ -1,3 +1,4 @@ from .model_visitor import ModelVisitor from .enum_visitor import EnumVisitor from .http_visitor import HttpVisitor +from .type_alias_visitor import TypeAliasVisitor diff --git a/type-generator/src/visitor/enum_visitor.py b/type-generator/src/visitor/enum_visitor.py index 6fe74de..d2902e9 100644 --- a/type-generator/src/visitor/enum_visitor.py +++ b/type-generator/src/visitor/enum_visitor.py @@ -11,14 +11,20 @@ class EnumVisitor(Visitor): _encoding = "utf-8" _number_type = "long" + is_enum: bool enum_name = "" types: List[EnumProperty] = [] def __init__(self, tree: Tree): self.tree = tree + self.is_enum = False self.enum_name = "" self.types = [] + def visit_union_type(self, node: Node): + self.is_enum = True + self._accept_list(node.children) + def visit_type_alias_declaration(self, node: Node): self.enum_name = node.child_by_field_name("name").text.decode(self._encoding) self._accept_list(node.children) diff --git a/type-generator/src/visitor/model_visitor.py b/type-generator/src/visitor/model_visitor.py index dd6c857..c8b016f 100644 --- a/type-generator/src/visitor/model_visitor.py +++ b/type-generator/src/visitor/model_visitor.py @@ -1,5 +1,5 @@ import textwrap -from typing import List +from typing import List, Dict from tree_sitter import Node, Tree @@ -15,15 +15,18 @@ class ModelVisitor(Visitor): class_name = "" class_type = ClassType.OBJECT properties: List[Property] = [] + dependencies: List[str] = [] - def __init__(self, tree: Tree, enums: List[str]): + def __init__(self, tree: Tree, enums: List[str], type_aliases: Dict[str, str]): self.tree = tree self._enums = enums self.class_name = "" self.class_type = ClassType.OBJECT self.properties = [] + self._type_aliases = type_aliases + self.dependencies = [] - def visit_interface_declaration(self, node: Node): + def visit_type_alias_declaration(self, node: Node): self.class_name = node.child_by_field_name("name").text.decode(self._encoding) if self.class_name.endswith("Response"): @@ -50,19 +53,27 @@ def visit_type_annotation(self, node: Node): type_identifier = node.child(1).text.decode(self._encoding) if "<" in type_identifier: return self._accept(node.child(1)) + if type_identifier == "null": + return self._handle_null() if type_identifier in self._enums: type_identifier = "str" + elif type_identifier in self._type_aliases.keys(): + type_identifier = self._type_aliases[type_identifier] last_idx = len(self.properties) - 1 - self.properties[last_idx].type = normalize_type(type_identifier) + type_identifier = normalize_type(type_identifier) + self.properties[last_idx].type = type_identifier + self._update_dependency_tree(type_identifier) def visit_generic_type(self, node: Node): last_idx = len(self.properties) - 1 type_identifier = node.child(0).text.decode(self._encoding) type_parameter = normalize_type(node.child(1).child(1).text.decode(self._encoding)) + if type_parameter == "null": + return self._handle_null() if type_parameter in self._enums: type_parameter = "str" @@ -72,3 +83,12 @@ def visit_generic_type(self, node: Node): raise f"Unhandled Type {type_identifier}!" self.properties[last_idx].type = out_type + self._update_dependency_tree(type_parameter) + + def _handle_null(self): + self.properties.pop() + + def _update_dependency_tree(self, type_name: str): + if type_name in ["str", "int", "bool"]: + return + self.dependencies.append(type_name) diff --git a/type-generator/src/visitor/type_alias_visitor.py b/type-generator/src/visitor/type_alias_visitor.py new file mode 100644 index 0000000..e5e3599 --- /dev/null +++ b/type-generator/src/visitor/type_alias_visitor.py @@ -0,0 +1,31 @@ +import textwrap +from typing import List + +from tree_sitter import Node, Tree +from .visitor import Visitor +from ..models import EnumProperty +from ..util import to_enum_case + + +class TypeAliasVisitor(Visitor): + _encoding = "utf-8" + _number_type = "long" + + is_type_alias: bool + type_alias_name = "" + mapped_type = "" + + def __init__(self, tree: Tree): + self.tree = tree + self.is_type_alias = False + self.type_alias_name = "" + self.mapped_type = "" + + def visit_type_alias_declaration(self, node: Node): + self.type_alias_name = node.child_by_field_name("name").text.decode(self._encoding) + if node.child_by_field_name("value").type == "predefined_type": + self.is_type_alias = True + self._accept_list(node.children) + + def visit_predefined_type(self, node: Node): + self.mapped_type = node.text.decode(self._encoding) From a22c0ae3aaf7ba9ae660925b29e172721479f89a Mon Sep 17 00:00:00 2001 From: Emily McLean Date: Mon, 18 Nov 2024 14:43:12 +1100 Subject: [PATCH 2/2] Add dependency tree solving for models so they won't be declared before their dependencies --- pythonlemmy/lemmyhttp.py | 2 +- pythonlemmy/objects.py | 3671 +++++++++++---------- pythonlemmy/responses.py | 1142 +++---- pythonlemmy/views.py | 674 ++-- type-generator/headers/object_header.py | 3 +- type-generator/headers/response_header.py | 4 +- type-generator/headers/view_header.py | 4 +- type-generator/lemmy-js-client | 2 +- type-generator/main.py | 74 +- 9 files changed, 2799 insertions(+), 2777 deletions(-) diff --git a/pythonlemmy/lemmyhttp.py b/pythonlemmy/lemmyhttp.py index cf04dc0..65d1197 100644 --- a/pythonlemmy/lemmyhttp.py +++ b/pythonlemmy/lemmyhttp.py @@ -35,7 +35,7 @@ def __init__(self, base_url: str, headers: dict = None, def set_jwt(self, jwt: str): self._request_controller.create_session(jwt) - + def get_site( self ): diff --git a/pythonlemmy/objects.py b/pythonlemmy/objects.py index 9622a25..9d31774 100644 --- a/pythonlemmy/objects.py +++ b/pythonlemmy/objects.py @@ -1,248 +1,109 @@ from dataclasses import dataclass from typing import Optional, Any -@dataclass -class ListCommunities: - """https://join-lemmy.org/api/interfaces/ListCommunities.html""" - - type_: Optional[str] = None - sort: Optional[str] = None - show_nsfw: Optional[bool] = None - page: Optional[int] = None - limit: Optional[int] = None - - @classmethod - def parse(cls, data: dict[str, Any]): - return cls( - type_=data["type_"] if "type_" in data else None, - sort=data["sort"] if "sort" in data else None, - show_nsfw=data["show_nsfw"] if "show_nsfw" in data else None, - page=data["page"] if "page" in data else None, - limit=data["limit"] if "limit" in data else None - ) - - -@dataclass -class RegistrationApplication: - """https://join-lemmy.org/api/interfaces/RegistrationApplication.html""" - - id: int = None - local_user_id: int = None - answer: str = None - admin_id: Optional[int] = None - deny_reason: Optional[str] = None - published: str = None - - @classmethod - def parse(cls, data: dict[str, Any]): - return cls( - id=data["id"], - local_user_id=data["local_user_id"], - answer=data["answer"], - admin_id=data["admin_id"] if "admin_id" in data else None, - deny_reason=data["deny_reason"] if "deny_reason" in data else None, - published=data["published"] - ) - @dataclass -class AdminPurgeComment: - """https://join-lemmy.org/api/interfaces/AdminPurgeComment.html""" +class ModRemoveCommunity: + """https://join-lemmy.org/api/interfaces/ModRemoveCommunity.html""" id: int = None - admin_person_id: int = None - post_id: int = None + mod_person_id: int = None + community_id: int = None reason: Optional[str] = None + removed: bool = None when_: str = None @classmethod def parse(cls, data: dict[str, Any]): return cls( id=data["id"], - admin_person_id=data["admin_person_id"], - post_id=data["post_id"], + mod_person_id=data["mod_person_id"], + community_id=data["community_id"], reason=data["reason"] if "reason" in data else None, + removed=data["removed"], when_=data["when_"] ) @dataclass -class CreateSite: - """https://join-lemmy.org/api/interfaces/CreateSite.html""" +class CreateCommentReport: + """https://join-lemmy.org/api/interfaces/CreateCommentReport.html""" - name: str = None - sidebar: Optional[str] = None - description: Optional[str] = None - icon: Optional[str] = None - banner: Optional[str] = None - enable_nsfw: Optional[bool] = None - community_creation_admin_only: Optional[bool] = None - require_email_verification: Optional[bool] = None - application_question: Optional[str] = None - private_instance: Optional[bool] = None - default_theme: Optional[str] = None - default_post_listing_type: Optional[str] = None - default_post_listing_mode: Optional[str] = None - default_post_sort_type: Optional[str] = None - default_comment_sort_type: Optional[str] = None - legal_information: Optional[str] = None - application_email_admins: Optional[bool] = None - hide_modlog_mod_names: Optional[bool] = None - discussion_languages: Optional[list[int]] = None - slur_filter_regex: Optional[str] = None - actor_name_max_length: Optional[int] = None - rate_limit_message: Optional[int] = None - rate_limit_message_per_second: Optional[int] = None - rate_limit_post: Optional[int] = None - rate_limit_post_per_second: Optional[int] = None - rate_limit_register: Optional[int] = None - rate_limit_register_per_second: Optional[int] = None - rate_limit_image: Optional[int] = None - rate_limit_image_per_second: Optional[int] = None - rate_limit_comment: Optional[int] = None - rate_limit_comment_per_second: Optional[int] = None - rate_limit_search: Optional[int] = None - rate_limit_search_per_second: Optional[int] = None - federation_enabled: Optional[bool] = None - federation_debug: Optional[bool] = None - captcha_enabled: Optional[bool] = None - captcha_difficulty: Optional[str] = None - allowed_instances: Optional[list[str]] = None - blocked_instances: Optional[list[str]] = None - registration_mode: Optional[str] = None - oauth_registration: Optional[bool] = None - content_warning: Optional[str] = None - post_upvotes: Optional[str] = None - post_downvotes: Optional[str] = None - comment_upvotes: Optional[str] = None - comment_downvotes: Optional[str] = None + comment_id: int = None + reason: str = None @classmethod def parse(cls, data: dict[str, Any]): return cls( - name=data["name"], - sidebar=data["sidebar"] if "sidebar" in data else None, - description=data["description"] if "description" in data else None, - icon=data["icon"] if "icon" in data else None, - banner=data["banner"] if "banner" in data else None, - enable_nsfw=data["enable_nsfw"] if "enable_nsfw" in data else None, - community_creation_admin_only=data["community_creation_admin_only"] if "community_creation_admin_only" in data else None, - require_email_verification=data["require_email_verification"] if "require_email_verification" in data else None, - application_question=data["application_question"] if "application_question" in data else None, - private_instance=data["private_instance"] if "private_instance" in data else None, - default_theme=data["default_theme"] if "default_theme" in data else None, - default_post_listing_type=data["default_post_listing_type"] if "default_post_listing_type" in data else None, - default_post_listing_mode=data["default_post_listing_mode"] if "default_post_listing_mode" in data else None, - default_post_sort_type=data["default_post_sort_type"] if "default_post_sort_type" in data else None, - default_comment_sort_type=data["default_comment_sort_type"] if "default_comment_sort_type" in data else None, - legal_information=data["legal_information"] if "legal_information" in data else None, - application_email_admins=data["application_email_admins"] if "application_email_admins" in data else None, - hide_modlog_mod_names=data["hide_modlog_mod_names"] if "hide_modlog_mod_names" in data else None, - discussion_languages=[e0 for e0 in data["discussion_languages"]] if "discussion_languages" in data else None, - slur_filter_regex=data["slur_filter_regex"] if "slur_filter_regex" in data else None, - actor_name_max_length=data["actor_name_max_length"] if "actor_name_max_length" in data else None, - rate_limit_message=data["rate_limit_message"] if "rate_limit_message" in data else None, - rate_limit_message_per_second=data["rate_limit_message_per_second"] if "rate_limit_message_per_second" in data else None, - rate_limit_post=data["rate_limit_post"] if "rate_limit_post" in data else None, - rate_limit_post_per_second=data["rate_limit_post_per_second"] if "rate_limit_post_per_second" in data else None, - rate_limit_register=data["rate_limit_register"] if "rate_limit_register" in data else None, - rate_limit_register_per_second=data["rate_limit_register_per_second"] if "rate_limit_register_per_second" in data else None, - rate_limit_image=data["rate_limit_image"] if "rate_limit_image" in data else None, - rate_limit_image_per_second=data["rate_limit_image_per_second"] if "rate_limit_image_per_second" in data else None, - rate_limit_comment=data["rate_limit_comment"] if "rate_limit_comment" in data else None, - rate_limit_comment_per_second=data["rate_limit_comment_per_second"] if "rate_limit_comment_per_second" in data else None, - rate_limit_search=data["rate_limit_search"] if "rate_limit_search" in data else None, - rate_limit_search_per_second=data["rate_limit_search_per_second"] if "rate_limit_search_per_second" in data else None, - federation_enabled=data["federation_enabled"] if "federation_enabled" in data else None, - federation_debug=data["federation_debug"] if "federation_debug" in data else None, - captcha_enabled=data["captcha_enabled"] if "captcha_enabled" in data else None, - captcha_difficulty=data["captcha_difficulty"] if "captcha_difficulty" in data else None, - allowed_instances=[e0 for e0 in data["allowed_instances"]] if "allowed_instances" in data else None, - blocked_instances=[e0 for e0 in data["blocked_instances"]] if "blocked_instances" in data else None, - registration_mode=data["registration_mode"] if "registration_mode" in data else None, - oauth_registration=data["oauth_registration"] if "oauth_registration" in data else None, - content_warning=data["content_warning"] if "content_warning" in data else None, - post_upvotes=data["post_upvotes"] if "post_upvotes" in data else None, - post_downvotes=data["post_downvotes"] if "post_downvotes" in data else None, - comment_upvotes=data["comment_upvotes"] if "comment_upvotes" in data else None, - comment_downvotes=data["comment_downvotes"] if "comment_downvotes" in data else None + comment_id=data["comment_id"], + reason=data["reason"] ) @dataclass -class DeleteComment: - """https://join-lemmy.org/api/interfaces/DeleteComment.html""" +class VerifyEmail: + """https://join-lemmy.org/api/interfaces/VerifyEmail.html""" - comment_id: int = None - deleted: bool = None + token: str = None @classmethod def parse(cls, data: dict[str, Any]): return cls( - comment_id=data["comment_id"], - deleted=data["deleted"] + token=data["token"] ) @dataclass -class CreateCommunity: - """https://join-lemmy.org/api/interfaces/CreateCommunity.html""" +class PostAggregates: + """https://join-lemmy.org/api/interfaces/PostAggregates.html""" - name: str = None - title: str = None - sidebar: Optional[str] = None - description: Optional[str] = None - icon: Optional[str] = None - banner: Optional[str] = None - nsfw: Optional[bool] = None - posting_restricted_to_mods: Optional[bool] = None - discussion_languages: Optional[list[int]] = None - visibility: Optional[str] = None + post_id: int = None + comments: int = None + score: int = None + upvotes: int = None + downvotes: int = None + published: str = None + newest_comment_time: str = None @classmethod def parse(cls, data: dict[str, Any]): return cls( - name=data["name"], - title=data["title"], - sidebar=data["sidebar"] if "sidebar" in data else None, - description=data["description"] if "description" in data else None, - icon=data["icon"] if "icon" in data else None, - banner=data["banner"] if "banner" in data else None, - nsfw=data["nsfw"] if "nsfw" in data else None, - posting_restricted_to_mods=data["posting_restricted_to_mods"] if "posting_restricted_to_mods" in data else None, - discussion_languages=[e0 for e0 in data["discussion_languages"]] if "discussion_languages" in data else None, - visibility=data["visibility"] if "visibility" in data else None + post_id=data["post_id"], + comments=data["comments"], + score=data["score"], + upvotes=data["upvotes"], + downvotes=data["downvotes"], + published=data["published"], + newest_comment_time=data["newest_comment_time"] ) @dataclass -class AdminPurgeCommunity: - """https://join-lemmy.org/api/interfaces/AdminPurgeCommunity.html""" +class FollowCommunity: + """https://join-lemmy.org/api/interfaces/FollowCommunity.html""" - id: int = None - admin_person_id: int = None - reason: Optional[str] = None - when_: str = None + community_id: int = None + follow: bool = None @classmethod def parse(cls, data: dict[str, Any]): return cls( - id=data["id"], - admin_person_id=data["admin_person_id"], - reason=data["reason"] if "reason" in data else None, - when_=data["when_"] + community_id=data["community_id"], + follow=data["follow"] ) @dataclass -class ModRemoveCommunity: - """https://join-lemmy.org/api/interfaces/ModRemoveCommunity.html""" +class ModBanFromCommunity: + """https://join-lemmy.org/api/interfaces/ModBanFromCommunity.html""" id: int = None mod_person_id: int = None + other_person_id: int = None community_id: int = None reason: Optional[str] = None - removed: bool = None + banned: bool = None + expires: Optional[str] = None when_: str = None @classmethod @@ -250,706 +111,792 @@ def parse(cls, data: dict[str, Any]): return cls( id=data["id"], mod_person_id=data["mod_person_id"], + other_person_id=data["other_person_id"], community_id=data["community_id"], reason=data["reason"] if "reason" in data else None, - removed=data["removed"], + banned=data["banned"], + expires=data["expires"] if "expires" in data else None, when_=data["when_"] ) @dataclass -class ApproveCommunityPendingFollower: - """https://join-lemmy.org/api/interfaces/ApproveCommunityPendingFollower.html""" +class DeleteOAuthProvider: + """https://join-lemmy.org/api/interfaces/DeleteOAuthProvider.html""" - community_id: int = None - follower_id: int = None - approve: bool = None + id: int = None @classmethod def parse(cls, data: dict[str, Any]): return cls( - community_id=data["community_id"], - follower_id=data["follower_id"], - approve=data["approve"] + id=data["id"] ) @dataclass -class LocalSiteUrlBlocklist: - """https://join-lemmy.org/api/interfaces/LocalSiteUrlBlocklist.html""" +class AddModToCommunity: + """https://join-lemmy.org/api/interfaces/AddModToCommunity.html""" - id: int = None - url: str = None - published: str = None - updated: Optional[str] = None + community_id: int = None + person_id: int = None + added: bool = None @classmethod def parse(cls, data: dict[str, Any]): return cls( - id=data["id"], - url=data["url"], - published=data["published"], - updated=data["updated"] if "updated" in data else None + community_id=data["community_id"], + person_id=data["person_id"], + added=data["added"] ) @dataclass -class PostReport: - """https://join-lemmy.org/api/interfaces/PostReport.html""" +class ResolveObject: + """https://join-lemmy.org/api/interfaces/ResolveObject.html""" - id: int = None - creator_id: int = None - post_id: int = None - original_post_name: str = None - original_post_url: Optional[str] = None - original_post_body: Optional[str] = None - reason: str = None - resolved: bool = None - resolver_id: Optional[int] = None - published: str = None - updated: Optional[str] = None + q: str = None @classmethod def parse(cls, data: dict[str, Any]): return cls( - id=data["id"], - creator_id=data["creator_id"], - post_id=data["post_id"], - original_post_name=data["original_post_name"], - original_post_url=data["original_post_url"] if "original_post_url" in data else None, - original_post_body=data["original_post_body"] if "original_post_body" in data else None, - reason=data["reason"], - resolved=data["resolved"], - resolver_id=data["resolver_id"] if "resolver_id" in data else None, - published=data["published"], - updated=data["updated"] if "updated" in data else None + q=data["q"] ) @dataclass -class CommentAggregates: - """https://join-lemmy.org/api/interfaces/CommentAggregates.html""" +class ModRemoveComment: + """https://join-lemmy.org/api/interfaces/ModRemoveComment.html""" + id: int = None + mod_person_id: int = None comment_id: int = None - score: int = None - upvotes: int = None - downvotes: int = None - published: str = None - child_count: int = None + reason: Optional[str] = None + removed: bool = None + when_: str = None @classmethod def parse(cls, data: dict[str, Any]): return cls( + id=data["id"], + mod_person_id=data["mod_person_id"], comment_id=data["comment_id"], - score=data["score"], - upvotes=data["upvotes"], - downvotes=data["downvotes"], - published=data["published"], - child_count=data["child_count"] + reason=data["reason"] if "reason" in data else None, + removed=data["removed"], + when_=data["when_"] ) @dataclass -class FeaturePost: - """https://join-lemmy.org/api/interfaces/FeaturePost.html""" +class GetReplies: + """https://join-lemmy.org/api/interfaces/GetReplies.html""" - post_id: int = None - featured: bool = None - feature_type: str = None + sort: Optional[str] = None + page: Optional[int] = None + limit: Optional[int] = None + unread_only: Optional[bool] = None @classmethod def parse(cls, data: dict[str, Any]): return cls( - post_id=data["post_id"], - featured=data["featured"], - feature_type=data["feature_type"] + sort=data["sort"] if "sort" in data else None, + page=data["page"] if "page" in data else None, + limit=data["limit"] if "limit" in data else None, + unread_only=data["unread_only"] if "unread_only" in data else None ) @dataclass -class GetSiteMetadata: - """https://join-lemmy.org/api/interfaces/GetSiteMetadata.html""" +class ListCommentReports: + """https://join-lemmy.org/api/interfaces/ListCommentReports.html""" - url: str = None + comment_id: Optional[int] = None + page: Optional[int] = None + limit: Optional[int] = None + unresolved_only: Optional[bool] = None + community_id: Optional[int] = None @classmethod def parse(cls, data: dict[str, Any]): return cls( - url=data["url"] + comment_id=data["comment_id"] if "comment_id" in data else None, + page=data["page"] if "page" in data else None, + limit=data["limit"] if "limit" in data else None, + unresolved_only=data["unresolved_only"] if "unresolved_only" in data else None, + community_id=data["community_id"] if "community_id" in data else None ) @dataclass -class ModLockPost: - """https://join-lemmy.org/api/interfaces/ModLockPost.html""" +class HideCommunity: + """https://join-lemmy.org/api/interfaces/HideCommunity.html""" - id: int = None - mod_person_id: int = None - post_id: int = None - locked: bool = None - when_: str = None + community_id: int = None + hidden: bool = None + reason: Optional[str] = None @classmethod def parse(cls, data: dict[str, Any]): return cls( - id=data["id"], - mod_person_id=data["mod_person_id"], - post_id=data["post_id"], - locked=data["locked"], - when_=data["when_"] + community_id=data["community_id"], + hidden=data["hidden"], + reason=data["reason"] if "reason" in data else None ) @dataclass -class ResolveCommentReport: - """https://join-lemmy.org/api/interfaces/ResolveCommentReport.html""" +class GetComments: + """https://join-lemmy.org/api/interfaces/GetComments.html""" - report_id: int = None - resolved: bool = None + type_: Optional[str] = None + sort: Optional[str] = None + max_depth: Optional[int] = None + page: Optional[int] = None + limit: Optional[int] = None + community_id: Optional[int] = None + community_name: Optional[str] = None + post_id: Optional[int] = None + parent_id: Optional[int] = None + saved_only: Optional[bool] = None + liked_only: Optional[bool] = None + disliked_only: Optional[bool] = None @classmethod def parse(cls, data: dict[str, Any]): return cls( - report_id=data["report_id"], - resolved=data["resolved"] + type_=data["type_"] if "type_" in data else None, + sort=data["sort"] if "sort" in data else None, + max_depth=data["max_depth"] if "max_depth" in data else None, + page=data["page"] if "page" in data else None, + limit=data["limit"] if "limit" in data else None, + community_id=data["community_id"] if "community_id" in data else None, + community_name=data["community_name"] if "community_name" in data else None, + post_id=data["post_id"] if "post_id" in data else None, + parent_id=data["parent_id"] if "parent_id" in data else None, + saved_only=data["saved_only"] if "saved_only" in data else None, + liked_only=data["liked_only"] if "liked_only" in data else None, + disliked_only=data["disliked_only"] if "disliked_only" in data else None ) @dataclass -class GetCommunityPendingFollowsCount: - """https://join-lemmy.org/api/interfaces/GetCommunityPendingFollowsCount.html""" +class Register: + """https://join-lemmy.org/api/interfaces/Register.html""" - community_id: int = None + username: str = None + password: str = None + password_verify: str = None + show_nsfw: Optional[bool] = None + email: Optional[str] = None + captcha_uuid: Optional[str] = None + captcha_answer: Optional[str] = None + honeypot: Optional[str] = None + answer: Optional[str] = None @classmethod def parse(cls, data: dict[str, Any]): return cls( - community_id=data["community_id"] + username=data["username"], + password=data["password"], + password_verify=data["password_verify"], + show_nsfw=data["show_nsfw"] if "show_nsfw" in data else None, + email=data["email"] if "email" in data else None, + captcha_uuid=data["captcha_uuid"] if "captcha_uuid" in data else None, + captcha_answer=data["captcha_answer"] if "captcha_answer" in data else None, + honeypot=data["honeypot"] if "honeypot" in data else None, + answer=data["answer"] if "answer" in data else None ) @dataclass -class ListCommunityPendingFollows: - """https://join-lemmy.org/api/interfaces/ListCommunityPendingFollows.html""" +class GetPrivateMessages: + """https://join-lemmy.org/api/interfaces/GetPrivateMessages.html""" - pending_only: Optional[bool] = None - all_communities: Optional[bool] = None + unread_only: Optional[bool] = None page: Optional[int] = None limit: Optional[int] = None + creator_id: Optional[int] = None @classmethod def parse(cls, data: dict[str, Any]): return cls( - pending_only=data["pending_only"] if "pending_only" in data else None, - all_communities=data["all_communities"] if "all_communities" in data else None, + unread_only=data["unread_only"] if "unread_only" in data else None, page=data["page"] if "page" in data else None, - limit=data["limit"] if "limit" in data else None + limit=data["limit"] if "limit" in data else None, + creator_id=data["creator_id"] if "creator_id" in data else None ) @dataclass -class DeleteCommunity: - """https://join-lemmy.org/api/interfaces/DeleteCommunity.html""" +class CustomEmojiKeyword: + """https://join-lemmy.org/api/interfaces/CustomEmojiKeyword.html""" - community_id: int = None - deleted: bool = None + custom_emoji_id: int = None + keyword: str = None @classmethod def parse(cls, data: dict[str, Any]): return cls( - community_id=data["community_id"], - deleted=data["deleted"] + custom_emoji_id=data["custom_emoji_id"], + keyword=data["keyword"] ) @dataclass -class GetPersonMentions: - """https://join-lemmy.org/api/interfaces/GetPersonMentions.html""" +class RemovePost: + """https://join-lemmy.org/api/interfaces/RemovePost.html""" - sort: Optional[str] = None - page: Optional[int] = None - limit: Optional[int] = None - unread_only: Optional[bool] = None + post_id: int = None + removed: bool = None + reason: Optional[str] = None @classmethod def parse(cls, data: dict[str, Any]): return cls( - sort=data["sort"] if "sort" in data else None, - page=data["page"] if "page" in data else None, - limit=data["limit"] if "limit" in data else None, - unread_only=data["unread_only"] if "unread_only" in data else None + post_id=data["post_id"], + removed=data["removed"], + reason=data["reason"] if "reason" in data else None ) @dataclass -class ModHideCommunity: - """https://join-lemmy.org/api/interfaces/ModHideCommunity.html""" +class PrivateMessageReport: + """https://join-lemmy.org/api/interfaces/PrivateMessageReport.html""" id: int = None - community_id: int = None - mod_person_id: int = None - when_: str = None - reason: Optional[str] = None - hidden: bool = None + creator_id: int = None + private_message_id: int = None + original_pm_text: str = None + reason: str = None + resolved: bool = None + resolver_id: Optional[int] = None + published: str = None + updated: Optional[str] = None @classmethod def parse(cls, data: dict[str, Any]): return cls( id=data["id"], - community_id=data["community_id"], - mod_person_id=data["mod_person_id"], - when_=data["when_"], - reason=data["reason"] if "reason" in data else None, - hidden=data["hidden"] + creator_id=data["creator_id"], + private_message_id=data["private_message_id"], + original_pm_text=data["original_pm_text"], + reason=data["reason"], + resolved=data["resolved"], + resolver_id=data["resolver_id"] if "resolver_id" in data else None, + published=data["published"], + updated=data["updated"] if "updated" in data else None ) @dataclass -class HideCommunity: - """https://join-lemmy.org/api/interfaces/HideCommunity.html""" +class GetRegistrationApplication: + """https://join-lemmy.org/api/interfaces/GetRegistrationApplication.html""" - community_id: int = None - hidden: bool = None - reason: Optional[str] = None + person_id: int = None @classmethod def parse(cls, data: dict[str, Any]): return cls( - community_id=data["community_id"], - hidden=data["hidden"], - reason=data["reason"] if "reason" in data else None + person_id=data["person_id"] ) @dataclass -class RemoveCommunity: - """https://join-lemmy.org/api/interfaces/RemoveCommunity.html""" +class LocalUserVoteDisplayMode: + """https://join-lemmy.org/api/interfaces/LocalUserVoteDisplayMode.html""" + + score: bool = None + upvotes: bool = None + downvotes: bool = None + upvote_percentage: bool = None + + @classmethod + def parse(cls, data: dict[str, Any]): + return cls( + score=data["score"], + upvotes=data["upvotes"], + downvotes=data["downvotes"], + upvote_percentage=data["upvote_percentage"] + ) + + +@dataclass +class BanFromCommunity: + """https://join-lemmy.org/api/interfaces/BanFromCommunity.html""" community_id: int = None - removed: bool = None + person_id: int = None + ban: bool = None + remove_or_restore_data: Optional[bool] = None reason: Optional[str] = None + expires: Optional[int] = None @classmethod def parse(cls, data: dict[str, Any]): return cls( community_id=data["community_id"], - removed=data["removed"], - reason=data["reason"] if "reason" in data else None + person_id=data["person_id"], + ban=data["ban"], + remove_or_restore_data=data["remove_or_restore_data"] if "remove_or_restore_data" in data else None, + reason=data["reason"] if "reason" in data else None, + expires=data["expires"] if "expires" in data else None ) @dataclass -class EditComment: - """https://join-lemmy.org/api/interfaces/EditComment.html""" +class ListCommentLikes: + """https://join-lemmy.org/api/interfaces/ListCommentLikes.html""" comment_id: int = None - content: Optional[str] = None - language_id: Optional[int] = None + page: Optional[int] = None + limit: Optional[int] = None @classmethod def parse(cls, data: dict[str, Any]): return cls( comment_id=data["comment_id"], - content=data["content"] if "content" in data else None, - language_id=data["language_id"] if "language_id" in data else None + page=data["page"] if "page" in data else None, + limit=data["limit"] if "limit" in data else None ) @dataclass -class EditCustomEmoji: - """https://join-lemmy.org/api/interfaces/EditCustomEmoji.html""" +class ApproveRegistrationApplication: + """https://join-lemmy.org/api/interfaces/ApproveRegistrationApplication.html""" id: int = None - category: str = None - image_url: str = None - alt_text: str = None - keywords: list[str] = None + approve: bool = None + deny_reason: Optional[str] = None @classmethod def parse(cls, data: dict[str, Any]): return cls( id=data["id"], - category=data["category"], - image_url=data["image_url"], - alt_text=data["alt_text"], - keywords=[e0 for e0 in data["keywords"]] + approve=data["approve"], + deny_reason=data["deny_reason"] if "deny_reason" in data else None ) @dataclass -class PersonMention: - """https://join-lemmy.org/api/interfaces/PersonMention.html""" +class ListCommunityPendingFollows: + """https://join-lemmy.org/api/interfaces/ListCommunityPendingFollows.html""" - id: int = None - recipient_id: int = None - comment_id: int = None - read: bool = None - published: str = None + pending_only: Optional[bool] = None + all_communities: Optional[bool] = None + page: Optional[int] = None + limit: Optional[int] = None @classmethod def parse(cls, data: dict[str, Any]): return cls( - id=data["id"], - recipient_id=data["recipient_id"], - comment_id=data["comment_id"], - read=data["read"], - published=data["published"] + pending_only=data["pending_only"] if "pending_only" in data else None, + all_communities=data["all_communities"] if "all_communities" in data else None, + page=data["page"] if "page" in data else None, + limit=data["limit"] if "limit" in data else None ) @dataclass -class HidePost: - """https://join-lemmy.org/api/interfaces/HidePost.html""" +class ListRegistrationApplications: + """https://join-lemmy.org/api/interfaces/ListRegistrationApplications.html""" - post_ids: list[int] = None - hide: bool = None + unread_only: Optional[bool] = None + page: Optional[int] = None + limit: Optional[int] = None @classmethod def parse(cls, data: dict[str, Any]): return cls( - post_ids=[e0 for e0 in data["post_ids"]], - hide=data["hide"] + unread_only=data["unread_only"] if "unread_only" in data else None, + page=data["page"] if "page" in data else None, + limit=data["limit"] if "limit" in data else None ) @dataclass -class CreatePrivateMessageReport: - """https://join-lemmy.org/api/interfaces/CreatePrivateMessageReport.html""" +class LockPost: + """https://join-lemmy.org/api/interfaces/LockPost.html""" - private_message_id: int = None - reason: str = None + post_id: int = None + locked: bool = None @classmethod def parse(cls, data: dict[str, Any]): return cls( - private_message_id=data["private_message_id"], - reason=data["reason"] + post_id=data["post_id"], + locked=data["locked"] ) @dataclass -class UpdateTagline: - """https://join-lemmy.org/api/interfaces/UpdateTagline.html""" +class Instance: + """https://join-lemmy.org/api/interfaces/Instance.html""" id: int = None - content: str = None + domain: str = None + published: str = None + updated: Optional[str] = None + software: Optional[str] = None + version: Optional[str] = None @classmethod def parse(cls, data: dict[str, Any]): return cls( id=data["id"], - content=data["content"] + domain=data["domain"], + published=data["published"], + updated=data["updated"] if "updated" in data else None, + software=data["software"] if "software" in data else None, + version=data["version"] if "version" in data else None ) @dataclass -class ReadableFederationState: - """https://join-lemmy.org/api/interfaces/ReadableFederationState.html""" +class ListCustomEmojis: + """https://join-lemmy.org/api/interfaces/ListCustomEmojis.html""" - next_retry: Optional[str] = None - instance_id: int = None - last_successful_id: Optional[int] = None - last_successful_published_time: Optional[str] = None - fail_count: int = None - last_retry: Optional[str] = None + page: Optional[int] = None + limit: Optional[int] = None + category: Optional[str] = None + ignore_page_limits: Optional[bool] = None @classmethod def parse(cls, data: dict[str, Any]): return cls( - next_retry=data["next_retry"] if "next_retry" in data else None, - instance_id=data["instance_id"], - last_successful_id=data["last_successful_id"] if "last_successful_id" in data else None, - last_successful_published_time=data["last_successful_published_time"] if "last_successful_published_time" in data else None, - fail_count=data["fail_count"], - last_retry=data["last_retry"] if "last_retry" in data else None + page=data["page"] if "page" in data else None, + limit=data["limit"] if "limit" in data else None, + category=data["category"] if "category" in data else None, + ignore_page_limits=data["ignore_page_limits"] if "ignore_page_limits" in data else None ) @dataclass -class Login: - """https://join-lemmy.org/api/interfaces/Login.html""" +class LocalImage: + """https://join-lemmy.org/api/interfaces/LocalImage.html""" - username_or_email: str = None - password: str = None - totp_2fa_token: Optional[str] = None + local_user_id: Optional[int] = None + pictrs_alias: str = None + pictrs_delete_token: str = None + published: str = None @classmethod def parse(cls, data: dict[str, Any]): return cls( - username_or_email=data["username_or_email"], - password=data["password"], - totp_2fa_token=data["totp_2fa_token"] if "totp_2fa_token" in data else None + local_user_id=data["local_user_id"] if "local_user_id" in data else None, + pictrs_alias=data["pictrs_alias"], + pictrs_delete_token=data["pictrs_delete_token"], + published=data["published"] ) @dataclass -class BlockInstance: - """https://join-lemmy.org/api/interfaces/BlockInstance.html""" +class EditCustomEmoji: + """https://join-lemmy.org/api/interfaces/EditCustomEmoji.html""" - instance_id: int = None - block: bool = None + id: int = None + category: str = None + image_url: str = None + alt_text: str = None + keywords: list[str] = None @classmethod def parse(cls, data: dict[str, Any]): return cls( - instance_id=data["instance_id"], - block=data["block"] + id=data["id"], + category=data["category"], + image_url=data["image_url"], + alt_text=data["alt_text"], + keywords=[e0 for e0 in data["keywords"]] ) @dataclass -class LoginToken: - """https://join-lemmy.org/api/interfaces/LoginToken.html""" +class ListMedia: + """https://join-lemmy.org/api/interfaces/ListMedia.html""" - user_id: int = None - published: str = None - ip: Optional[str] = None - user_agent: Optional[str] = None + page: Optional[int] = None + limit: Optional[int] = None @classmethod def parse(cls, data: dict[str, Any]): return cls( - user_id=data["user_id"], - published=data["published"], - ip=data["ip"] if "ip" in data else None, - user_agent=data["user_agent"] if "user_agent" in data else None + page=data["page"] if "page" in data else None, + limit=data["limit"] if "limit" in data else None ) @dataclass -class PasswordChangeAfterReset: - """https://join-lemmy.org/api/interfaces/PasswordChangeAfterReset.html""" +class ResolveCommentReport: + """https://join-lemmy.org/api/interfaces/ResolveCommentReport.html""" - token: str = None - password: str = None - password_verify: str = None + report_id: int = None + resolved: bool = None @classmethod def parse(cls, data: dict[str, Any]): return cls( - token=data["token"], - password=data["password"], - password_verify=data["password_verify"] + report_id=data["report_id"], + resolved=data["resolved"] ) @dataclass -class LocalUser: - """https://join-lemmy.org/api/interfaces/LocalUser.html""" +class EditComment: + """https://join-lemmy.org/api/interfaces/EditComment.html""" - id: int = None - person_id: int = None - email: Optional[str] = None - show_nsfw: bool = None - theme: str = None - default_post_sort_type: str = None - default_listing_type: str = None - interface_language: str = None - show_avatars: bool = None - send_notifications_to_email: bool = None - show_bot_accounts: bool = None - show_read_posts: bool = None - email_verified: bool = None - accepted_application: bool = None - open_links_in_new_tab: bool = None - blur_nsfw: bool = None - infinite_scroll_enabled: bool = None - admin: bool = None - post_listing_mode: str = None - totp_2fa_enabled: bool = None - enable_keyboard_navigation: bool = None - enable_animated_images: bool = None - collapse_bot_comments: bool = None - default_comment_sort_type: str = None + comment_id: int = None + content: Optional[str] = None + language_id: Optional[int] = None @classmethod def parse(cls, data: dict[str, Any]): return cls( - id=data["id"], - person_id=data["person_id"], - email=data["email"] if "email" in data else None, - show_nsfw=data["show_nsfw"], - theme=data["theme"], - default_post_sort_type=data["default_post_sort_type"], - default_listing_type=data["default_listing_type"], - interface_language=data["interface_language"], - show_avatars=data["show_avatars"], - send_notifications_to_email=data["send_notifications_to_email"], - show_bot_accounts=data["show_bot_accounts"], - show_read_posts=data["show_read_posts"], - email_verified=data["email_verified"], - accepted_application=data["accepted_application"], - open_links_in_new_tab=data["open_links_in_new_tab"], - blur_nsfw=data["blur_nsfw"], - infinite_scroll_enabled=data["infinite_scroll_enabled"], - admin=data["admin"], - post_listing_mode=data["post_listing_mode"], - totp_2fa_enabled=data["totp_2fa_enabled"], - enable_keyboard_navigation=data["enable_keyboard_navigation"], - enable_animated_images=data["enable_animated_images"], - collapse_bot_comments=data["collapse_bot_comments"], - default_comment_sort_type=data["default_comment_sort_type"] + comment_id=data["comment_id"], + content=data["content"] if "content" in data else None, + language_id=data["language_id"] if "language_id" in data else None ) @dataclass -class PersonAggregates: - """https://join-lemmy.org/api/interfaces/PersonAggregates.html""" +class AdminPurgePost: + """https://join-lemmy.org/api/interfaces/AdminPurgePost.html""" - person_id: int = None - post_count: int = None - comment_count: int = None + id: int = None + admin_person_id: int = None + community_id: int = None + reason: Optional[str] = None + when_: str = None @classmethod def parse(cls, data: dict[str, Any]): return cls( - person_id=data["person_id"], - post_count=data["post_count"], - comment_count=data["comment_count"] + id=data["id"], + admin_person_id=data["admin_person_id"], + community_id=data["community_id"], + reason=data["reason"] if "reason" in data else None, + when_=data["when_"] ) @dataclass -class CreateTagline: - """https://join-lemmy.org/api/interfaces/CreateTagline.html""" +class CustomEmoji: + """https://join-lemmy.org/api/interfaces/CustomEmoji.html""" - content: str = None + id: int = None + shortcode: str = None + image_url: str = None + alt_text: str = None + category: str = None + published: str = None + updated: Optional[str] = None @classmethod def parse(cls, data: dict[str, Any]): return cls( - content=data["content"] + id=data["id"], + shortcode=data["shortcode"], + image_url=data["image_url"], + alt_text=data["alt_text"], + category=data["category"], + published=data["published"], + updated=data["updated"] if "updated" in data else None ) @dataclass -class MarkCommentReplyAsRead: - """https://join-lemmy.org/api/interfaces/MarkCommentReplyAsRead.html""" +class CreatePrivateMessageReport: + """https://join-lemmy.org/api/interfaces/CreatePrivateMessageReport.html""" - comment_reply_id: int = None - read: bool = None + private_message_id: int = None + reason: str = None @classmethod def parse(cls, data: dict[str, Any]): return cls( - comment_reply_id=data["comment_reply_id"], - read=data["read"] + private_message_id=data["private_message_id"], + reason=data["reason"] ) @dataclass -class Search: - """https://join-lemmy.org/api/interfaces/Search.html""" +class CommunityAggregates: + """https://join-lemmy.org/api/interfaces/CommunityAggregates.html""" + + community_id: int = None + subscribers: int = None + posts: int = None + comments: int = None + published: str = None + users_active_day: int = None + users_active_week: int = None + users_active_month: int = None + users_active_half_year: int = None + subscribers_local: int = None + + @classmethod + def parse(cls, data: dict[str, Any]): + return cls( + community_id=data["community_id"], + subscribers=data["subscribers"], + posts=data["posts"], + comments=data["comments"], + published=data["published"], + users_active_day=data["users_active_day"], + users_active_week=data["users_active_week"], + users_active_month=data["users_active_month"], + users_active_half_year=data["users_active_half_year"], + subscribers_local=data["subscribers_local"] + ) + + +@dataclass +class ListPrivateMessageReports: + """https://join-lemmy.org/api/interfaces/ListPrivateMessageReports.html""" - q: str = None - community_id: Optional[int] = None - community_name: Optional[str] = None - creator_id: Optional[int] = None - type_: Optional[str] = None - sort: Optional[str] = None - listing_type: Optional[str] = None page: Optional[int] = None limit: Optional[int] = None - title_only: Optional[bool] = None - post_url_only: Optional[bool] = None - saved_only: Optional[bool] = None - liked_only: Optional[bool] = None - disliked_only: Optional[bool] = None + unresolved_only: Optional[bool] = None @classmethod def parse(cls, data: dict[str, Any]): return cls( - q=data["q"], - community_id=data["community_id"] if "community_id" in data else None, - community_name=data["community_name"] if "community_name" in data else None, - creator_id=data["creator_id"] if "creator_id" in data else None, - type_=data["type_"] if "type_" in data else None, - sort=data["sort"] if "sort" in data else None, - listing_type=data["listing_type"] if "listing_type" in data else None, page=data["page"] if "page" in data else None, limit=data["limit"] if "limit" in data else None, - title_only=data["title_only"] if "title_only" in data else None, - post_url_only=data["post_url_only"] if "post_url_only" in data else None, - saved_only=data["saved_only"] if "saved_only" in data else None, - liked_only=data["liked_only"] if "liked_only" in data else None, - disliked_only=data["disliked_only"] if "disliked_only" in data else None + unresolved_only=data["unresolved_only"] if "unresolved_only" in data else None ) @dataclass -class LocalUserVoteDisplayMode: - """https://join-lemmy.org/api/interfaces/LocalUserVoteDisplayMode.html""" +class ApproveCommunityPendingFollower: + """https://join-lemmy.org/api/interfaces/ApproveCommunityPendingFollower.html""" - score: bool = None - upvotes: bool = None - downvotes: bool = None - upvote_percentage: bool = None + community_id: int = None + follower_id: int = None + approve: bool = None @classmethod def parse(cls, data: dict[str, Any]): return cls( - score=data["score"], - upvotes=data["upvotes"], - downvotes=data["downvotes"], - upvote_percentage=data["upvote_percentage"] + community_id=data["community_id"], + follower_id=data["follower_id"], + approve=data["approve"] ) @dataclass -class LockPost: - """https://join-lemmy.org/api/interfaces/LockPost.html""" +class GetReportCount: + """https://join-lemmy.org/api/interfaces/GetReportCount.html""" - post_id: int = None - locked: bool = None + community_id: Optional[int] = None @classmethod def parse(cls, data: dict[str, Any]): return cls( - post_id=data["post_id"], - locked=data["locked"] + community_id=data["community_id"] if "community_id" in data else None ) @dataclass -class ChangePassword: - """https://join-lemmy.org/api/interfaces/ChangePassword.html""" +class CreatePrivateMessage: + """https://join-lemmy.org/api/interfaces/CreatePrivateMessage.html""" - new_password: str = None - new_password_verify: str = None - old_password: str = None + content: str = None + recipient_id: int = None @classmethod def parse(cls, data: dict[str, Any]): return cls( - new_password=data["new_password"], - new_password_verify=data["new_password_verify"], - old_password=data["old_password"] + content=data["content"], + recipient_id=data["recipient_id"] ) @dataclass -class ResolveObject: - """https://join-lemmy.org/api/interfaces/ResolveObject.html""" +class Login: + """https://join-lemmy.org/api/interfaces/Login.html""" - q: str = None + username_or_email: str = None + password: str = None + totp_2fa_token: Optional[str] = None @classmethod def parse(cls, data: dict[str, Any]): return cls( - q=data["q"] + username_or_email=data["username_or_email"], + password=data["password"], + totp_2fa_token=data["totp_2fa_token"] if "totp_2fa_token" in data else None ) @dataclass -class VerifyEmail: - """https://join-lemmy.org/api/interfaces/VerifyEmail.html""" +class Site: + """https://join-lemmy.org/api/interfaces/Site.html""" - token: str = None + id: int = None + name: str = None + sidebar: Optional[str] = None + published: str = None + updated: Optional[str] = None + icon: Optional[str] = None + banner: Optional[str] = None + description: Optional[str] = None + actor_id: str = None + last_refreshed_at: str = None + inbox_url: str = None + public_key: str = None + instance_id: int = None + content_warning: Optional[str] = None @classmethod def parse(cls, data: dict[str, Any]): return cls( - token=data["token"] + id=data["id"], + name=data["name"], + sidebar=data["sidebar"] if "sidebar" in data else None, + published=data["published"], + updated=data["updated"] if "updated" in data else None, + icon=data["icon"] if "icon" in data else None, + banner=data["banner"] if "banner" in data else None, + description=data["description"] if "description" in data else None, + actor_id=data["actor_id"], + last_refreshed_at=data["last_refreshed_at"], + inbox_url=data["inbox_url"], + public_key=data["public_key"], + instance_id=data["instance_id"], + content_warning=data["content_warning"] if "content_warning" in data else None + ) + + +@dataclass +class OpenGraphData: + """https://join-lemmy.org/api/interfaces/OpenGraphData.html""" + + title: Optional[str] = None + description: Optional[str] = None + image: Optional[str] = None + embed_video_url: Optional[str] = None + + @classmethod + def parse(cls, data: dict[str, Any]): + return cls( + title=data["title"] if "title" in data else None, + description=data["description"] if "description" in data else None, + image=data["image"] if "image" in data else None, + embed_video_url=data["embed_video_url"] if "embed_video_url" in data else None + ) + + +@dataclass +class DistinguishComment: + """https://join-lemmy.org/api/interfaces/DistinguishComment.html""" + + comment_id: int = None + distinguished: bool = None + + @classmethod + def parse(cls, data: dict[str, Any]): + return cls( + comment_id=data["comment_id"], + distinguished=data["distinguished"] ) @@ -977,478 +924,531 @@ def parse(cls, data: dict[str, Any]): @dataclass -class BlockPerson: - """https://join-lemmy.org/api/interfaces/BlockPerson.html""" - - person_id: int = None - block: bool = None +class EditPost: + """https://join-lemmy.org/api/interfaces/EditPost.html""" + + post_id: int = None + name: Optional[str] = None + url: Optional[str] = None + body: Optional[str] = None + alt_text: Optional[str] = None + nsfw: Optional[bool] = None + language_id: Optional[int] = None + custom_thumbnail: Optional[str] = None + scheduled_publish_time: Optional[int] = None @classmethod def parse(cls, data: dict[str, Any]): return cls( - person_id=data["person_id"], - block=data["block"] + post_id=data["post_id"], + name=data["name"] if "name" in data else None, + url=data["url"] if "url" in data else None, + body=data["body"] if "body" in data else None, + alt_text=data["alt_text"] if "alt_text" in data else None, + nsfw=data["nsfw"] if "nsfw" in data else None, + language_id=data["language_id"] if "language_id" in data else None, + custom_thumbnail=data["custom_thumbnail"] if "custom_thumbnail" in data else None, + scheduled_publish_time=data["scheduled_publish_time"] if "scheduled_publish_time" in data else None ) @dataclass -class ListPrivateMessageReports: - """https://join-lemmy.org/api/interfaces/ListPrivateMessageReports.html""" +class AdminPurgePerson: + """https://join-lemmy.org/api/interfaces/AdminPurgePerson.html""" - page: Optional[int] = None - limit: Optional[int] = None - unresolved_only: Optional[bool] = None + id: int = None + admin_person_id: int = None + reason: Optional[str] = None + when_: str = None @classmethod def parse(cls, data: dict[str, Any]): return cls( - page=data["page"] if "page" in data else None, - limit=data["limit"] if "limit" in data else None, - unresolved_only=data["unresolved_only"] if "unresolved_only" in data else None + id=data["id"], + admin_person_id=data["admin_person_id"], + reason=data["reason"] if "reason" in data else None, + when_=data["when_"] ) @dataclass -class SiteAggregates: - """https://join-lemmy.org/api/interfaces/SiteAggregates.html""" +class GetSiteMetadata: + """https://join-lemmy.org/api/interfaces/GetSiteMetadata.html""" - site_id: int = None - users: int = None - posts: int = None - comments: int = None - communities: int = None - users_active_day: int = None - users_active_week: int = None - users_active_month: int = None - users_active_half_year: int = None + url: str = None @classmethod def parse(cls, data: dict[str, Any]): return cls( - site_id=data["site_id"], - users=data["users"], - posts=data["posts"], - comments=data["comments"], - communities=data["communities"], - users_active_day=data["users_active_day"], - users_active_week=data["users_active_week"], - users_active_month=data["users_active_month"], - users_active_half_year=data["users_active_half_year"] + url=data["url"] ) @dataclass -class CreatePostReport: - """https://join-lemmy.org/api/interfaces/CreatePostReport.html""" +class ModHideCommunity: + """https://join-lemmy.org/api/interfaces/ModHideCommunity.html""" - post_id: int = None - reason: str = None + id: int = None + community_id: int = None + mod_person_id: int = None + when_: str = None + reason: Optional[str] = None + hidden: bool = None @classmethod def parse(cls, data: dict[str, Any]): return cls( - post_id=data["post_id"], - reason=data["reason"] + id=data["id"], + community_id=data["community_id"], + mod_person_id=data["mod_person_id"], + when_=data["when_"], + reason=data["reason"] if "reason" in data else None, + hidden=data["hidden"] ) @dataclass -class CustomEmoji: - """https://join-lemmy.org/api/interfaces/CustomEmoji.html""" +class ModTransferCommunity: + """https://join-lemmy.org/api/interfaces/ModTransferCommunity.html""" id: int = None - shortcode: str = None - image_url: str = None - alt_text: str = None - category: str = None - published: str = None - updated: Optional[str] = None + mod_person_id: int = None + other_person_id: int = None + community_id: int = None + when_: str = None @classmethod def parse(cls, data: dict[str, Any]): return cls( id=data["id"], - shortcode=data["shortcode"], - image_url=data["image_url"], - alt_text=data["alt_text"], - category=data["category"], - published=data["published"], - updated=data["updated"] if "updated" in data else None + mod_person_id=data["mod_person_id"], + other_person_id=data["other_person_id"], + community_id=data["community_id"], + when_=data["when_"] ) @dataclass -class PurgePost: - """https://join-lemmy.org/api/interfaces/PurgePost.html""" +class CreatePostReport: + """https://join-lemmy.org/api/interfaces/CreatePostReport.html""" post_id: int = None - reason: Optional[str] = None + reason: str = None @classmethod def parse(cls, data: dict[str, Any]): return cls( post_id=data["post_id"], - reason=data["reason"] if "reason" in data else None + reason=data["reason"] ) @dataclass -class PostAggregates: - """https://join-lemmy.org/api/interfaces/PostAggregates.html""" +class CreateCommunity: + """https://join-lemmy.org/api/interfaces/CreateCommunity.html""" - post_id: int = None - comments: int = None - score: int = None - upvotes: int = None - downvotes: int = None - published: str = None - newest_comment_time: str = None + name: str = None + title: str = None + sidebar: Optional[str] = None + description: Optional[str] = None + icon: Optional[str] = None + banner: Optional[str] = None + nsfw: Optional[bool] = None + posting_restricted_to_mods: Optional[bool] = None + discussion_languages: Optional[list[int]] = None + visibility: Optional[str] = None @classmethod def parse(cls, data: dict[str, Any]): return cls( - post_id=data["post_id"], - comments=data["comments"], - score=data["score"], - upvotes=data["upvotes"], - downvotes=data["downvotes"], - published=data["published"], - newest_comment_time=data["newest_comment_time"] + name=data["name"], + title=data["title"], + sidebar=data["sidebar"] if "sidebar" in data else None, + description=data["description"] if "description" in data else None, + icon=data["icon"] if "icon" in data else None, + banner=data["banner"] if "banner" in data else None, + nsfw=data["nsfw"] if "nsfw" in data else None, + posting_restricted_to_mods=data["posting_restricted_to_mods"] if "posting_restricted_to_mods" in data else None, + discussion_languages=[e0 for e0 in data["discussion_languages"]] if "discussion_languages" in data else None, + visibility=data["visibility"] if "visibility" in data else None ) @dataclass -class Language: - """https://join-lemmy.org/api/interfaces/Language.html""" +class ImageDetails: + """https://join-lemmy.org/api/interfaces/ImageDetails.html""" - id: int = None - code: str = None - name: str = None + link: str = None + width: int = None + height: int = None + content_type: str = None @classmethod def parse(cls, data: dict[str, Any]): return cls( - id=data["id"], - code=data["code"], - name=data["name"] + link=data["link"], + width=data["width"], + height=data["height"], + content_type=data["content_type"] ) @dataclass -class GetReportCount: - """https://join-lemmy.org/api/interfaces/GetReportCount.html""" +class RemoveComment: + """https://join-lemmy.org/api/interfaces/RemoveComment.html""" - community_id: Optional[int] = None + comment_id: int = None + removed: bool = None + reason: Optional[str] = None @classmethod def parse(cls, data: dict[str, Any]): return cls( - community_id=data["community_id"] if "community_id" in data else None + comment_id=data["comment_id"], + removed=data["removed"], + reason=data["reason"] if "reason" in data else None ) @dataclass -class AuthenticateWithOauth: - """https://join-lemmy.org/api/interfaces/AuthenticateWithOauth.html""" +class TransferCommunity: + """https://join-lemmy.org/api/interfaces/TransferCommunity.html""" - code: str = None - oauth_provider_id: int = None - redirect_uri: str = None - show_nsfw: Optional[bool] = None - username: Optional[str] = None - answer: Optional[str] = None + community_id: int = None + person_id: int = None @classmethod def parse(cls, data: dict[str, Any]): return cls( - code=data["code"], - oauth_provider_id=data["oauth_provider_id"], - redirect_uri=data["redirect_uri"], - show_nsfw=data["show_nsfw"] if "show_nsfw" in data else None, - username=data["username"] if "username" in data else None, - answer=data["answer"] if "answer" in data else None + community_id=data["community_id"], + person_id=data["person_id"] ) @dataclass -class DeletePrivateMessage: - """https://join-lemmy.org/api/interfaces/DeletePrivateMessage.html""" +class CommentAggregates: + """https://join-lemmy.org/api/interfaces/CommentAggregates.html""" - private_message_id: int = None - deleted: bool = None + comment_id: int = None + score: int = None + upvotes: int = None + downvotes: int = None + published: str = None + child_count: int = None @classmethod def parse(cls, data: dict[str, Any]): return cls( - private_message_id=data["private_message_id"], - deleted=data["deleted"] + comment_id=data["comment_id"], + score=data["score"], + upvotes=data["upvotes"], + downvotes=data["downvotes"], + published=data["published"], + child_count=data["child_count"] ) @dataclass -class Community: - """https://join-lemmy.org/api/interfaces/Community.html""" +class ListCommunities: + """https://join-lemmy.org/api/interfaces/ListCommunities.html""" - id: int = None - name: str = None - title: str = None - sidebar: Optional[str] = None - removed: bool = None - published: str = None - updated: Optional[str] = None - deleted: bool = None - nsfw: bool = None - actor_id: str = None - local: bool = None - icon: Optional[str] = None - banner: Optional[str] = None - hidden: bool = None - posting_restricted_to_mods: bool = None - instance_id: int = None - visibility: str = None - description: Optional[str] = None + type_: Optional[str] = None + sort: Optional[str] = None + show_nsfw: Optional[bool] = None + page: Optional[int] = None + limit: Optional[int] = None @classmethod def parse(cls, data: dict[str, Any]): return cls( - id=data["id"], - name=data["name"], - title=data["title"], - sidebar=data["sidebar"] if "sidebar" in data else None, - removed=data["removed"], - published=data["published"], - updated=data["updated"] if "updated" in data else None, - deleted=data["deleted"], - nsfw=data["nsfw"], - actor_id=data["actor_id"], - local=data["local"], - icon=data["icon"] if "icon" in data else None, - banner=data["banner"] if "banner" in data else None, - hidden=data["hidden"], - posting_restricted_to_mods=data["posting_restricted_to_mods"], - instance_id=data["instance_id"], - visibility=data["visibility"], - description=data["description"] if "description" in data else None + type_=data["type_"] if "type_" in data else None, + sort=data["sort"] if "sort" in data else None, + show_nsfw=data["show_nsfw"] if "show_nsfw" in data else None, + page=data["page"] if "page" in data else None, + limit=data["limit"] if "limit" in data else None ) @dataclass -class ListPostReports: - """https://join-lemmy.org/api/interfaces/ListPostReports.html""" +class PurgeComment: + """https://join-lemmy.org/api/interfaces/PurgeComment.html""" - page: Optional[int] = None - limit: Optional[int] = None - unresolved_only: Optional[bool] = None - community_id: Optional[int] = None - post_id: Optional[int] = None + comment_id: int = None + reason: Optional[str] = None @classmethod def parse(cls, data: dict[str, Any]): return cls( - page=data["page"] if "page" in data else None, - limit=data["limit"] if "limit" in data else None, - unresolved_only=data["unresolved_only"] if "unresolved_only" in data else None, - community_id=data["community_id"] if "community_id" in data else None, - post_id=data["post_id"] if "post_id" in data else None + comment_id=data["comment_id"], + reason=data["reason"] if "reason" in data else None ) @dataclass -class ModFeaturePost: - """https://join-lemmy.org/api/interfaces/ModFeaturePost.html""" +class ReadableFederationState: + """https://join-lemmy.org/api/interfaces/ReadableFederationState.html""" + + next_retry: Optional[str] = None + instance_id: int = None + last_successful_id: Optional[int] = None + last_successful_published_time: Optional[str] = None + fail_count: int = None + last_retry: Optional[str] = None + + @classmethod + def parse(cls, data: dict[str, Any]): + return cls( + next_retry=data["next_retry"] if "next_retry" in data else None, + instance_id=data["instance_id"], + last_successful_id=data["last_successful_id"] if "last_successful_id" in data else None, + last_successful_published_time=data["last_successful_published_time"] if "last_successful_published_time" in data else None, + fail_count=data["fail_count"], + last_retry=data["last_retry"] if "last_retry" in data else None + ) + + +@dataclass +class Comment: + """https://join-lemmy.org/api/interfaces/Comment.html""" id: int = None - mod_person_id: int = None + creator_id: int = None post_id: int = None - featured: bool = None - when_: str = None - is_featured_community: bool = None + content: str = None + removed: bool = None + published: str = None + updated: Optional[str] = None + deleted: bool = None + ap_id: str = None + local: bool = None + path: str = None + distinguished: bool = None + language_id: int = None @classmethod def parse(cls, data: dict[str, Any]): return cls( id=data["id"], - mod_person_id=data["mod_person_id"], + creator_id=data["creator_id"], post_id=data["post_id"], - featured=data["featured"], - when_=data["when_"], - is_featured_community=data["is_featured_community"] + content=data["content"], + removed=data["removed"], + published=data["published"], + updated=data["updated"] if "updated" in data else None, + deleted=data["deleted"], + ap_id=data["ap_id"], + local=data["local"], + path=data["path"], + distinguished=data["distinguished"], + language_id=data["language_id"] ) @dataclass -class GetPersonDetails: - """https://join-lemmy.org/api/interfaces/GetPersonDetails.html""" +class LocalSiteRateLimit: + """https://join-lemmy.org/api/interfaces/LocalSiteRateLimit.html""" - person_id: Optional[int] = None - username: Optional[str] = None - sort: Optional[str] = None - page: Optional[int] = None - limit: Optional[int] = None - community_id: Optional[int] = None - saved_only: Optional[bool] = None + local_site_id: int = None + message: int = None + message_per_second: int = None + post: int = None + post_per_second: int = None + register: int = None + register_per_second: int = None + image: int = None + image_per_second: int = None + comment: int = None + comment_per_second: int = None + search: int = None + search_per_second: int = None + published: str = None + updated: Optional[str] = None + import_user_settings: int = None + import_user_settings_per_second: int = None @classmethod def parse(cls, data: dict[str, Any]): return cls( - person_id=data["person_id"] if "person_id" in data else None, - username=data["username"] if "username" in data else None, - sort=data["sort"] if "sort" in data else None, - page=data["page"] if "page" in data else None, - limit=data["limit"] if "limit" in data else None, - community_id=data["community_id"] if "community_id" in data else None, - saved_only=data["saved_only"] if "saved_only" in data else None + local_site_id=data["local_site_id"], + message=data["message"], + message_per_second=data["message_per_second"], + post=data["post"], + post_per_second=data["post_per_second"], + register=data["register"], + register_per_second=data["register_per_second"], + image=data["image"], + image_per_second=data["image_per_second"], + comment=data["comment"], + comment_per_second=data["comment_per_second"], + search=data["search"], + search_per_second=data["search_per_second"], + published=data["published"], + updated=data["updated"] if "updated" in data else None, + import_user_settings=data["import_user_settings"], + import_user_settings_per_second=data["import_user_settings_per_second"] ) @dataclass -class AddModToCommunity: - """https://join-lemmy.org/api/interfaces/AddModToCommunity.html""" +class PersonAggregates: + """https://join-lemmy.org/api/interfaces/PersonAggregates.html""" - community_id: int = None person_id: int = None - added: bool = None + post_count: int = None + comment_count: int = None @classmethod def parse(cls, data: dict[str, Any]): return cls( - community_id=data["community_id"], person_id=data["person_id"], - added=data["added"] + post_count=data["post_count"], + comment_count=data["comment_count"] ) @dataclass -class Site: - """https://join-lemmy.org/api/interfaces/Site.html""" +class ModAdd: + """https://join-lemmy.org/api/interfaces/ModAdd.html""" id: int = None - name: str = None - sidebar: Optional[str] = None - published: str = None - updated: Optional[str] = None - icon: Optional[str] = None - banner: Optional[str] = None - description: Optional[str] = None - actor_id: str = None - last_refreshed_at: str = None - inbox_url: str = None - public_key: str = None - instance_id: int = None - content_warning: Optional[str] = None + mod_person_id: int = None + other_person_id: int = None + removed: bool = None + when_: str = None @classmethod def parse(cls, data: dict[str, Any]): return cls( id=data["id"], - name=data["name"], - sidebar=data["sidebar"] if "sidebar" in data else None, - published=data["published"], - updated=data["updated"] if "updated" in data else None, - icon=data["icon"] if "icon" in data else None, - banner=data["banner"] if "banner" in data else None, - description=data["description"] if "description" in data else None, - actor_id=data["actor_id"], - last_refreshed_at=data["last_refreshed_at"], - inbox_url=data["inbox_url"], - public_key=data["public_key"], - instance_id=data["instance_id"], - content_warning=data["content_warning"] if "content_warning" in data else None + mod_person_id=data["mod_person_id"], + other_person_id=data["other_person_id"], + removed=data["removed"], + when_=data["when_"] ) @dataclass -class ApproveRegistrationApplication: - """https://join-lemmy.org/api/interfaces/ApproveRegistrationApplication.html""" +class Tagline: + """https://join-lemmy.org/api/interfaces/Tagline.html""" id: int = None - approve: bool = None - deny_reason: Optional[str] = None + content: str = None + published: str = None + updated: Optional[str] = None @classmethod def parse(cls, data: dict[str, Any]): return cls( id=data["id"], - approve=data["approve"], - deny_reason=data["deny_reason"] if "deny_reason" in data else None + content=data["content"], + published=data["published"], + updated=data["updated"] if "updated" in data else None ) @dataclass -class EditPost: - """https://join-lemmy.org/api/interfaces/EditPost.html""" +class CreateComment: + """https://join-lemmy.org/api/interfaces/CreateComment.html""" + content: str = None post_id: int = None - name: Optional[str] = None - url: Optional[str] = None - body: Optional[str] = None - alt_text: Optional[str] = None - nsfw: Optional[bool] = None + parent_id: Optional[int] = None language_id: Optional[int] = None - custom_thumbnail: Optional[str] = None - scheduled_publish_time: Optional[int] = None @classmethod def parse(cls, data: dict[str, Any]): return cls( + content=data["content"], post_id=data["post_id"], - name=data["name"] if "name" in data else None, - url=data["url"] if "url" in data else None, - body=data["body"] if "body" in data else None, - alt_text=data["alt_text"] if "alt_text" in data else None, - nsfw=data["nsfw"] if "nsfw" in data else None, - language_id=data["language_id"] if "language_id" in data else None, - custom_thumbnail=data["custom_thumbnail"] if "custom_thumbnail" in data else None, - scheduled_publish_time=data["scheduled_publish_time"] if "scheduled_publish_time" in data else None + parent_id=data["parent_id"] if "parent_id" in data else None, + language_id=data["language_id"] if "language_id" in data else None ) @dataclass -class GetPost: - """https://join-lemmy.org/api/interfaces/GetPost.html""" +class MarkPrivateMessageAsRead: + """https://join-lemmy.org/api/interfaces/MarkPrivateMessageAsRead.html""" - id: Optional[int] = None - comment_id: Optional[int] = None + private_message_id: int = None + read: bool = None @classmethod def parse(cls, data: dict[str, Any]): return cls( - id=data["id"] if "id" in data else None, - comment_id=data["comment_id"] if "comment_id" in data else None + private_message_id=data["private_message_id"], + read=data["read"] ) @dataclass -class FollowCommunity: - """https://join-lemmy.org/api/interfaces/FollowCommunity.html""" +class DeleteTagline: + """https://join-lemmy.org/api/interfaces/DeleteTagline.html""" - community_id: int = None - follow: bool = None + id: int = None @classmethod def parse(cls, data: dict[str, Any]): return cls( - community_id=data["community_id"], - follow=data["follow"] + id=data["id"] ) @dataclass -class GetPrivateMessages: - """https://join-lemmy.org/api/interfaces/GetPrivateMessages.html""" +class Post: + """https://join-lemmy.org/api/interfaces/Post.html""" - unread_only: Optional[bool] = None - page: Optional[int] = None - limit: Optional[int] = None - creator_id: Optional[int] = None + id: int = None + name: str = None + url: Optional[str] = None + body: Optional[str] = None + creator_id: int = None + community_id: int = None + removed: bool = None + locked: bool = None + published: str = None + updated: Optional[str] = None + deleted: bool = None + nsfw: bool = None + embed_title: Optional[str] = None + embed_description: Optional[str] = None + thumbnail_url: Optional[str] = None + ap_id: str = None + local: bool = None + embed_video_url: Optional[str] = None + language_id: int = None + featured_community: bool = None + featured_local: bool = None + url_content_type: Optional[str] = None + alt_text: Optional[str] = None + scheduled_publish_time: Optional[str] = None @classmethod def parse(cls, data: dict[str, Any]): return cls( - unread_only=data["unread_only"] if "unread_only" in data else None, - page=data["page"] if "page" in data else None, - limit=data["limit"] if "limit" in data else None, - creator_id=data["creator_id"] if "creator_id" in data else None + id=data["id"], + name=data["name"], + url=data["url"] if "url" in data else None, + body=data["body"] if "body" in data else None, + creator_id=data["creator_id"], + community_id=data["community_id"], + removed=data["removed"], + locked=data["locked"], + published=data["published"], + updated=data["updated"] if "updated" in data else None, + deleted=data["deleted"], + nsfw=data["nsfw"], + embed_title=data["embed_title"] if "embed_title" in data else None, + embed_description=data["embed_description"] if "embed_description" in data else None, + thumbnail_url=data["thumbnail_url"] if "thumbnail_url" in data else None, + ap_id=data["ap_id"], + local=data["local"], + embed_video_url=data["embed_video_url"] if "embed_video_url" in data else None, + language_id=data["language_id"], + featured_community=data["featured_community"], + featured_local=data["featured_local"], + url_content_type=data["url_content_type"] if "url_content_type" in data else None, + alt_text=data["alt_text"] if "alt_text" in data else None, + scheduled_publish_time=data["scheduled_publish_time"] if "scheduled_publish_time" in data else None ) @@ -1468,15 +1468,14 @@ def parse(cls, data: dict[str, Any]): @dataclass -class ModBan: - """https://join-lemmy.org/api/interfaces/ModBan.html""" +class ModRemovePost: + """https://join-lemmy.org/api/interfaces/ModRemovePost.html""" id: int = None mod_person_id: int = None - other_person_id: int = None + post_id: int = None reason: Optional[str] = None - banned: bool = None - expires: Optional[str] = None + removed: bool = None when_: str = None @classmethod @@ -1484,62 +1483,129 @@ def parse(cls, data: dict[str, Any]): return cls( id=data["id"], mod_person_id=data["mod_person_id"], - other_person_id=data["other_person_id"], + post_id=data["post_id"], reason=data["reason"] if "reason" in data else None, - banned=data["banned"], - expires=data["expires"] if "expires" in data else None, + removed=data["removed"], when_=data["when_"] ) @dataclass -class Tagline: - """https://join-lemmy.org/api/interfaces/Tagline.html""" +class LinkMetadata: + """https://join-lemmy.org/api/interfaces/LinkMetadata.html""" - id: int = None - content: str = None - published: str = None - updated: Optional[str] = None + content_type: Optional[str] = None + title: Optional[str] = None + description: Optional[str] = None + image: Optional[str] = None + embed_video_url: Optional[str] = None @classmethod def parse(cls, data: dict[str, Any]): return cls( - id=data["id"], - content=data["content"], - published=data["published"], - updated=data["updated"] if "updated" in data else None + content_type=data["content_type"] if "content_type" in data else None, + title=data["title"] if "title" in data else None, + description=data["description"] if "description" in data else None, + image=data["image"] if "image" in data else None, + embed_video_url=data["embed_video_url"] if "embed_video_url" in data else None ) @dataclass -class RemoveComment: - """https://join-lemmy.org/api/interfaces/RemoveComment.html""" +class Search: + """https://join-lemmy.org/api/interfaces/Search.html""" - comment_id: int = None - removed: bool = None - reason: Optional[str] = None + q: str = None + community_id: Optional[int] = None + community_name: Optional[str] = None + creator_id: Optional[int] = None + type_: Optional[str] = None + sort: Optional[str] = None + listing_type: Optional[str] = None + page: Optional[int] = None + limit: Optional[int] = None + title_only: Optional[bool] = None + post_url_only: Optional[bool] = None + saved_only: Optional[bool] = None + liked_only: Optional[bool] = None + disliked_only: Optional[bool] = None @classmethod def parse(cls, data: dict[str, Any]): return cls( - comment_id=data["comment_id"], - removed=data["removed"], - reason=data["reason"] if "reason" in data else None + q=data["q"], + community_id=data["community_id"] if "community_id" in data else None, + community_name=data["community_name"] if "community_name" in data else None, + creator_id=data["creator_id"] if "creator_id" in data else None, + type_=data["type_"] if "type_" in data else None, + sort=data["sort"] if "sort" in data else None, + listing_type=data["listing_type"] if "listing_type" in data else None, + page=data["page"] if "page" in data else None, + limit=data["limit"] if "limit" in data else None, + title_only=data["title_only"] if "title_only" in data else None, + post_url_only=data["post_url_only"] if "post_url_only" in data else None, + saved_only=data["saved_only"] if "saved_only" in data else None, + liked_only=data["liked_only"] if "liked_only" in data else None, + disliked_only=data["disliked_only"] if "disliked_only" in data else None ) @dataclass -class UpdateTotp: - """https://join-lemmy.org/api/interfaces/UpdateTotp.html""" +class LocalUser: + """https://join-lemmy.org/api/interfaces/LocalUser.html""" - totp_token: str = None - enabled: bool = None + id: int = None + person_id: int = None + email: Optional[str] = None + show_nsfw: bool = None + theme: str = None + default_post_sort_type: str = None + default_listing_type: str = None + interface_language: str = None + show_avatars: bool = None + send_notifications_to_email: bool = None + show_bot_accounts: bool = None + show_read_posts: bool = None + email_verified: bool = None + accepted_application: bool = None + open_links_in_new_tab: bool = None + blur_nsfw: bool = None + infinite_scroll_enabled: bool = None + admin: bool = None + post_listing_mode: str = None + totp_2fa_enabled: bool = None + enable_keyboard_navigation: bool = None + enable_animated_images: bool = None + collapse_bot_comments: bool = None + default_comment_sort_type: str = None @classmethod def parse(cls, data: dict[str, Any]): return cls( - totp_token=data["totp_token"], - enabled=data["enabled"] + id=data["id"], + person_id=data["person_id"], + email=data["email"] if "email" in data else None, + show_nsfw=data["show_nsfw"], + theme=data["theme"], + default_post_sort_type=data["default_post_sort_type"], + default_listing_type=data["default_listing_type"], + interface_language=data["interface_language"], + show_avatars=data["show_avatars"], + send_notifications_to_email=data["send_notifications_to_email"], + show_bot_accounts=data["show_bot_accounts"], + show_read_posts=data["show_read_posts"], + email_verified=data["email_verified"], + accepted_application=data["accepted_application"], + open_links_in_new_tab=data["open_links_in_new_tab"], + blur_nsfw=data["blur_nsfw"], + infinite_scroll_enabled=data["infinite_scroll_enabled"], + admin=data["admin"], + post_listing_mode=data["post_listing_mode"], + totp_2fa_enabled=data["totp_2fa_enabled"], + enable_keyboard_navigation=data["enable_keyboard_navigation"], + enable_animated_images=data["enable_animated_images"], + collapse_bot_comments=data["collapse_bot_comments"], + default_comment_sort_type=data["default_comment_sort_type"] ) @@ -1557,381 +1623,451 @@ def parse(cls, data: dict[str, Any]): @dataclass -class MarkPostAsRead: - """https://join-lemmy.org/api/interfaces/MarkPostAsRead.html""" +class PurgeCommunity: + """https://join-lemmy.org/api/interfaces/PurgeCommunity.html""" - post_ids: list[int] = None - read: bool = None + community_id: int = None + reason: Optional[str] = None @classmethod def parse(cls, data: dict[str, Any]): return cls( - post_ids=[e0 for e0 in data["post_ids"]], - read=data["read"] + community_id=data["community_id"], + reason=data["reason"] if "reason" in data else None ) @dataclass -class PendingFollow: - """https://join-lemmy.org/api/interfaces/PendingFollow.html""" +class GetPersonMentions: + """https://join-lemmy.org/api/interfaces/GetPersonMentions.html""" - person: Person = None - community: Community = None - is_new_instance: bool = None - subscribed: str = None + sort: Optional[str] = None + page: Optional[int] = None + limit: Optional[int] = None + unread_only: Optional[bool] = None @classmethod def parse(cls, data: dict[str, Any]): return cls( - person=Person.parse(data["person"]), - community=Community.parse(data["community"]), - is_new_instance=data["is_new_instance"], - subscribed=data["subscribed"] + sort=data["sort"] if "sort" in data else None, + page=data["page"] if "page" in data else None, + limit=data["limit"] if "limit" in data else None, + unread_only=data["unread_only"] if "unread_only" in data else None ) @dataclass -class ResolvePrivateMessageReport: - """https://join-lemmy.org/api/interfaces/ResolvePrivateMessageReport.html""" +class EditCommunity: + """https://join-lemmy.org/api/interfaces/EditCommunity.html""" - report_id: int = None - resolved: bool = None + community_id: int = None + title: Optional[str] = None + sidebar: Optional[str] = None + description: Optional[str] = None + icon: Optional[str] = None + banner: Optional[str] = None + nsfw: Optional[bool] = None + posting_restricted_to_mods: Optional[bool] = None + discussion_languages: Optional[list[int]] = None + visibility: Optional[str] = None @classmethod def parse(cls, data: dict[str, Any]): return cls( - report_id=data["report_id"], - resolved=data["resolved"] + community_id=data["community_id"], + title=data["title"] if "title" in data else None, + sidebar=data["sidebar"] if "sidebar" in data else None, + description=data["description"] if "description" in data else None, + icon=data["icon"] if "icon" in data else None, + banner=data["banner"] if "banner" in data else None, + nsfw=data["nsfw"] if "nsfw" in data else None, + posting_restricted_to_mods=data["posting_restricted_to_mods"] if "posting_restricted_to_mods" in data else None, + discussion_languages=[e0 for e0 in data["discussion_languages"]] if "discussion_languages" in data else None, + visibility=data["visibility"] if "visibility" in data else None ) @dataclass -class LinkMetadata: - """https://join-lemmy.org/api/interfaces/LinkMetadata.html""" +class DeleteComment: + """https://join-lemmy.org/api/interfaces/DeleteComment.html""" - content_type: Optional[str] = None - title: Optional[str] = None - description: Optional[str] = None - image: Optional[str] = None - embed_video_url: Optional[str] = None + comment_id: int = None + deleted: bool = None @classmethod def parse(cls, data: dict[str, Any]): return cls( - content_type=data["content_type"] if "content_type" in data else None, - title=data["title"] if "title" in data else None, - description=data["description"] if "description" in data else None, - image=data["image"] if "image" in data else None, - embed_video_url=data["embed_video_url"] if "embed_video_url" in data else None + comment_id=data["comment_id"], + deleted=data["deleted"] ) @dataclass -class PrivateMessage: - """https://join-lemmy.org/api/interfaces/PrivateMessage.html""" +class GetRandomCommunity: + """https://join-lemmy.org/api/interfaces/GetRandomCommunity.html""" - id: int = None - creator_id: int = None - recipient_id: int = None - content: str = None - deleted: bool = None - read: bool = None - published: str = None - updated: Optional[str] = None - ap_id: str = None - local: bool = None + type_: Optional[str] = None @classmethod def parse(cls, data: dict[str, Any]): return cls( - id=data["id"], - creator_id=data["creator_id"], - recipient_id=data["recipient_id"], - content=data["content"], - deleted=data["deleted"], - read=data["read"], - published=data["published"], - updated=data["updated"] if "updated" in data else None, - ap_id=data["ap_id"], - local=data["local"] + type_=data["type_"] if "type_" in data else None ) @dataclass -class DeletePost: - """https://join-lemmy.org/api/interfaces/DeletePost.html""" +class ModLockPost: + """https://join-lemmy.org/api/interfaces/ModLockPost.html""" + id: int = None + mod_person_id: int = None post_id: int = None - deleted: bool = None + locked: bool = None + when_: str = None @classmethod def parse(cls, data: dict[str, Any]): return cls( + id=data["id"], + mod_person_id=data["mod_person_id"], post_id=data["post_id"], - deleted=data["deleted"] + locked=data["locked"], + when_=data["when_"] ) @dataclass -class OAuthAccount: - """https://join-lemmy.org/api/interfaces/OAuthAccount.html""" +class EditPrivateMessage: + """https://join-lemmy.org/api/interfaces/EditPrivateMessage.html""" - local_user_id: int = None - oauth_provider_id: int = None - oauth_user_id: str = None + private_message_id: int = None + content: str = None + + @classmethod + def parse(cls, data: dict[str, Any]): + return cls( + private_message_id=data["private_message_id"], + content=data["content"] + ) + + +@dataclass +class CommentReport: + """https://join-lemmy.org/api/interfaces/CommentReport.html""" + + id: int = None + creator_id: int = None + comment_id: int = None + original_comment_text: str = None + reason: str = None + resolved: bool = None + resolver_id: Optional[int] = None published: str = None updated: Optional[str] = None @classmethod def parse(cls, data: dict[str, Any]): return cls( - local_user_id=data["local_user_id"], - oauth_provider_id=data["oauth_provider_id"], - oauth_user_id=data["oauth_user_id"], + id=data["id"], + creator_id=data["creator_id"], + comment_id=data["comment_id"], + original_comment_text=data["original_comment_text"], + reason=data["reason"], + resolved=data["resolved"], + resolver_id=data["resolver_id"] if "resolver_id" in data else None, published=data["published"], updated=data["updated"] if "updated" in data else None ) @dataclass -class PurgeComment: - """https://join-lemmy.org/api/interfaces/PurgeComment.html""" +class CommentReply: + """https://join-lemmy.org/api/interfaces/CommentReply.html""" + id: int = None + recipient_id: int = None comment_id: int = None - reason: Optional[str] = None + read: bool = None + published: str = None @classmethod def parse(cls, data: dict[str, Any]): return cls( + id=data["id"], + recipient_id=data["recipient_id"], comment_id=data["comment_id"], - reason=data["reason"] if "reason" in data else None + read=data["read"], + published=data["published"] ) @dataclass -class CreatePost: - """https://join-lemmy.org/api/interfaces/CreatePost.html""" +class MarkCommentReplyAsRead: + """https://join-lemmy.org/api/interfaces/MarkCommentReplyAsRead.html""" - name: str = None - community_id: int = None - url: Optional[str] = None - body: Optional[str] = None - alt_text: Optional[str] = None - honeypot: Optional[str] = None - nsfw: Optional[bool] = None - language_id: Optional[int] = None - custom_thumbnail: Optional[str] = None - scheduled_publish_time: Optional[int] = None + comment_reply_id: int = None + read: bool = None @classmethod def parse(cls, data: dict[str, Any]): return cls( - name=data["name"], - community_id=data["community_id"], - url=data["url"] if "url" in data else None, - body=data["body"] if "body" in data else None, - alt_text=data["alt_text"] if "alt_text" in data else None, - honeypot=data["honeypot"] if "honeypot" in data else None, - nsfw=data["nsfw"] if "nsfw" in data else None, - language_id=data["language_id"] if "language_id" in data else None, - custom_thumbnail=data["custom_thumbnail"] if "custom_thumbnail" in data else None, - scheduled_publish_time=data["scheduled_publish_time"] if "scheduled_publish_time" in data else None + comment_reply_id=data["comment_reply_id"], + read=data["read"] ) @dataclass -class CreateCustomEmoji: - """https://join-lemmy.org/api/interfaces/CreateCustomEmoji.html""" +class DeleteAccount: + """https://join-lemmy.org/api/interfaces/DeleteAccount.html""" - category: str = None - shortcode: str = None - image_url: str = None - alt_text: str = None - keywords: list[str] = None + password: str = None + delete_content: bool = None @classmethod def parse(cls, data: dict[str, Any]): return cls( - category=data["category"], - shortcode=data["shortcode"], - image_url=data["image_url"], - alt_text=data["alt_text"], - keywords=[e0 for e0 in data["keywords"]] + password=data["password"], + delete_content=data["delete_content"] ) @dataclass -class InstanceWithFederationState: - """https://join-lemmy.org/api/interfaces/InstanceWithFederationState.html""" +class HidePost: + """https://join-lemmy.org/api/interfaces/HidePost.html""" + + post_ids: list[int] = None + hide: bool = None + + @classmethod + def parse(cls, data: dict[str, Any]): + return cls( + post_ids=[e0 for e0 in data["post_ids"]], + hide=data["hide"] + ) + + +@dataclass +class Person: + """https://join-lemmy.org/api/interfaces/Person.html""" - federation_state: Optional[ReadableFederationState] = None id: int = None - domain: str = None + name: str = None + display_name: Optional[str] = None + avatar: Optional[str] = None + banned: bool = None published: str = None updated: Optional[str] = None - software: Optional[str] = None - version: Optional[str] = None + actor_id: str = None + bio: Optional[str] = None + local: bool = None + banner: Optional[str] = None + deleted: bool = None + matrix_user_id: Optional[str] = None + bot_account: bool = None + ban_expires: Optional[str] = None + instance_id: int = None @classmethod def parse(cls, data: dict[str, Any]): return cls( - federation_state=ReadableFederationState.parse(data["federation_state"]) if "federation_state" in data else None, id=data["id"], - domain=data["domain"], + name=data["name"], + display_name=data["display_name"] if "display_name" in data else None, + avatar=data["avatar"] if "avatar" in data else None, + banned=data["banned"], published=data["published"], updated=data["updated"] if "updated" in data else None, - software=data["software"] if "software" in data else None, - version=data["version"] if "version" in data else None + actor_id=data["actor_id"], + bio=data["bio"] if "bio" in data else None, + local=data["local"], + banner=data["banner"] if "banner" in data else None, + deleted=data["deleted"], + matrix_user_id=data["matrix_user_id"] if "matrix_user_id" in data else None, + bot_account=data["bot_account"], + ban_expires=data["ban_expires"] if "ban_expires" in data else None, + instance_id=data["instance_id"] ) @dataclass -class CommunityAggregates: - """https://join-lemmy.org/api/interfaces/CommunityAggregates.html""" +class RegistrationApplication: + """https://join-lemmy.org/api/interfaces/RegistrationApplication.html""" - community_id: int = None - subscribers: int = None - posts: int = None - comments: int = None + id: int = None + local_user_id: int = None + answer: str = None + admin_id: Optional[int] = None + deny_reason: Optional[str] = None published: str = None - users_active_day: int = None - users_active_week: int = None - users_active_month: int = None - users_active_half_year: int = None - subscribers_local: int = None @classmethod def parse(cls, data: dict[str, Any]): return cls( - community_id=data["community_id"], - subscribers=data["subscribers"], - posts=data["posts"], - comments=data["comments"], - published=data["published"], - users_active_day=data["users_active_day"], - users_active_week=data["users_active_week"], - users_active_month=data["users_active_month"], - users_active_half_year=data["users_active_half_year"], - subscribers_local=data["subscribers_local"] + id=data["id"], + local_user_id=data["local_user_id"], + answer=data["answer"], + admin_id=data["admin_id"] if "admin_id" in data else None, + deny_reason=data["deny_reason"] if "deny_reason" in data else None, + published=data["published"] ) @dataclass -class LocalImage: - """https://join-lemmy.org/api/interfaces/LocalImage.html""" +class SavePost: + """https://join-lemmy.org/api/interfaces/SavePost.html""" - local_user_id: Optional[int] = None - pictrs_alias: str = None - pictrs_delete_token: str = None - published: str = None + post_id: int = None + save: bool = None @classmethod def parse(cls, data: dict[str, Any]): return cls( - local_user_id=data["local_user_id"] if "local_user_id" in data else None, - pictrs_alias=data["pictrs_alias"], - pictrs_delete_token=data["pictrs_delete_token"], - published=data["published"] + post_id=data["post_id"], + save=data["save"] ) @dataclass -class EditCommunity: - """https://join-lemmy.org/api/interfaces/EditCommunity.html""" - - community_id: int = None - title: Optional[str] = None - sidebar: Optional[str] = None - description: Optional[str] = None - icon: Optional[str] = None - banner: Optional[str] = None - nsfw: Optional[bool] = None - posting_restricted_to_mods: Optional[bool] = None - discussion_languages: Optional[list[int]] = None - visibility: Optional[str] = None - - @classmethod - def parse(cls, data: dict[str, Any]): - return cls( - community_id=data["community_id"], - title=data["title"] if "title" in data else None, - sidebar=data["sidebar"] if "sidebar" in data else None, - description=data["description"] if "description" in data else None, - icon=data["icon"] if "icon" in data else None, - banner=data["banner"] if "banner" in data else None, - nsfw=data["nsfw"] if "nsfw" in data else None, - posting_restricted_to_mods=data["posting_restricted_to_mods"] if "posting_restricted_to_mods" in data else None, - discussion_languages=[e0 for e0 in data["discussion_languages"]] if "discussion_languages" in data else None, - visibility=data["visibility"] if "visibility" in data else None - ) - - -@dataclass -class ListPostLikes: - """https://join-lemmy.org/api/interfaces/ListPostLikes.html""" +class DeletePrivateMessage: + """https://join-lemmy.org/api/interfaces/DeletePrivateMessage.html""" - post_id: int = None - page: Optional[int] = None - limit: Optional[int] = None + private_message_id: int = None + deleted: bool = None @classmethod def parse(cls, data: dict[str, Any]): return cls( - post_id=data["post_id"], - page=data["page"] if "page" in data else None, - limit=data["limit"] if "limit" in data else None + private_message_id=data["private_message_id"], + deleted=data["deleted"] ) @dataclass -class CommentReply: - """https://join-lemmy.org/api/interfaces/CommentReply.html""" +class AdminPurgeCommunity: + """https://join-lemmy.org/api/interfaces/AdminPurgeCommunity.html""" id: int = None - recipient_id: int = None - comment_id: int = None - read: bool = None - published: str = None + admin_person_id: int = None + reason: Optional[str] = None + when_: str = None @classmethod def parse(cls, data: dict[str, Any]): return cls( id=data["id"], - recipient_id=data["recipient_id"], - comment_id=data["comment_id"], - read=data["read"], - published=data["published"] + admin_person_id=data["admin_person_id"], + reason=data["reason"] if "reason" in data else None, + when_=data["when_"] ) @dataclass -class ModRemovePost: - """https://join-lemmy.org/api/interfaces/ModRemovePost.html""" +class CreateSite: + """https://join-lemmy.org/api/interfaces/CreateSite.html""" - id: int = None - mod_person_id: int = None - post_id: int = None - reason: Optional[str] = None - removed: bool = None - when_: str = None + name: str = None + sidebar: Optional[str] = None + description: Optional[str] = None + icon: Optional[str] = None + banner: Optional[str] = None + enable_nsfw: Optional[bool] = None + community_creation_admin_only: Optional[bool] = None + require_email_verification: Optional[bool] = None + application_question: Optional[str] = None + private_instance: Optional[bool] = None + default_theme: Optional[str] = None + default_post_listing_type: Optional[str] = None + default_post_listing_mode: Optional[str] = None + default_post_sort_type: Optional[str] = None + default_comment_sort_type: Optional[str] = None + legal_information: Optional[str] = None + application_email_admins: Optional[bool] = None + hide_modlog_mod_names: Optional[bool] = None + discussion_languages: Optional[list[int]] = None + slur_filter_regex: Optional[str] = None + actor_name_max_length: Optional[int] = None + rate_limit_message: Optional[int] = None + rate_limit_message_per_second: Optional[int] = None + rate_limit_post: Optional[int] = None + rate_limit_post_per_second: Optional[int] = None + rate_limit_register: Optional[int] = None + rate_limit_register_per_second: Optional[int] = None + rate_limit_image: Optional[int] = None + rate_limit_image_per_second: Optional[int] = None + rate_limit_comment: Optional[int] = None + rate_limit_comment_per_second: Optional[int] = None + rate_limit_search: Optional[int] = None + rate_limit_search_per_second: Optional[int] = None + federation_enabled: Optional[bool] = None + federation_debug: Optional[bool] = None + captcha_enabled: Optional[bool] = None + captcha_difficulty: Optional[str] = None + allowed_instances: Optional[list[str]] = None + blocked_instances: Optional[list[str]] = None + registration_mode: Optional[str] = None + oauth_registration: Optional[bool] = None + content_warning: Optional[str] = None + post_upvotes: Optional[str] = None + post_downvotes: Optional[str] = None + comment_upvotes: Optional[str] = None + comment_downvotes: Optional[str] = None @classmethod def parse(cls, data: dict[str, Any]): return cls( - id=data["id"], - mod_person_id=data["mod_person_id"], - post_id=data["post_id"], - reason=data["reason"] if "reason" in data else None, - removed=data["removed"], - when_=data["when_"] + name=data["name"], + sidebar=data["sidebar"] if "sidebar" in data else None, + description=data["description"] if "description" in data else None, + icon=data["icon"] if "icon" in data else None, + banner=data["banner"] if "banner" in data else None, + enable_nsfw=data["enable_nsfw"] if "enable_nsfw" in data else None, + community_creation_admin_only=data["community_creation_admin_only"] if "community_creation_admin_only" in data else None, + require_email_verification=data["require_email_verification"] if "require_email_verification" in data else None, + application_question=data["application_question"] if "application_question" in data else None, + private_instance=data["private_instance"] if "private_instance" in data else None, + default_theme=data["default_theme"] if "default_theme" in data else None, + default_post_listing_type=data["default_post_listing_type"] if "default_post_listing_type" in data else None, + default_post_listing_mode=data["default_post_listing_mode"] if "default_post_listing_mode" in data else None, + default_post_sort_type=data["default_post_sort_type"] if "default_post_sort_type" in data else None, + default_comment_sort_type=data["default_comment_sort_type"] if "default_comment_sort_type" in data else None, + legal_information=data["legal_information"] if "legal_information" in data else None, + application_email_admins=data["application_email_admins"] if "application_email_admins" in data else None, + hide_modlog_mod_names=data["hide_modlog_mod_names"] if "hide_modlog_mod_names" in data else None, + discussion_languages=[e0 for e0 in data["discussion_languages"]] if "discussion_languages" in data else None, + slur_filter_regex=data["slur_filter_regex"] if "slur_filter_regex" in data else None, + actor_name_max_length=data["actor_name_max_length"] if "actor_name_max_length" in data else None, + rate_limit_message=data["rate_limit_message"] if "rate_limit_message" in data else None, + rate_limit_message_per_second=data["rate_limit_message_per_second"] if "rate_limit_message_per_second" in data else None, + rate_limit_post=data["rate_limit_post"] if "rate_limit_post" in data else None, + rate_limit_post_per_second=data["rate_limit_post_per_second"] if "rate_limit_post_per_second" in data else None, + rate_limit_register=data["rate_limit_register"] if "rate_limit_register" in data else None, + rate_limit_register_per_second=data["rate_limit_register_per_second"] if "rate_limit_register_per_second" in data else None, + rate_limit_image=data["rate_limit_image"] if "rate_limit_image" in data else None, + rate_limit_image_per_second=data["rate_limit_image_per_second"] if "rate_limit_image_per_second" in data else None, + rate_limit_comment=data["rate_limit_comment"] if "rate_limit_comment" in data else None, + rate_limit_comment_per_second=data["rate_limit_comment_per_second"] if "rate_limit_comment_per_second" in data else None, + rate_limit_search=data["rate_limit_search"] if "rate_limit_search" in data else None, + rate_limit_search_per_second=data["rate_limit_search_per_second"] if "rate_limit_search_per_second" in data else None, + federation_enabled=data["federation_enabled"] if "federation_enabled" in data else None, + federation_debug=data["federation_debug"] if "federation_debug" in data else None, + captcha_enabled=data["captcha_enabled"] if "captcha_enabled" in data else None, + captcha_difficulty=data["captcha_difficulty"] if "captcha_difficulty" in data else None, + allowed_instances=[e0 for e0 in data["allowed_instances"]] if "allowed_instances" in data else None, + blocked_instances=[e0 for e0 in data["blocked_instances"]] if "blocked_instances" in data else None, + registration_mode=data["registration_mode"] if "registration_mode" in data else None, + oauth_registration=data["oauth_registration"] if "oauth_registration" in data else None, + content_warning=data["content_warning"] if "content_warning" in data else None, + post_upvotes=data["post_upvotes"] if "post_upvotes" in data else None, + post_downvotes=data["post_downvotes"] if "post_downvotes" in data else None, + comment_upvotes=data["comment_upvotes"] if "comment_upvotes" in data else None, + comment_downvotes=data["comment_downvotes"] if "comment_downvotes" in data else None ) @dataclass -class OAuthProvider: - """https://join-lemmy.org/api/interfaces/OAuthProvider.html""" +class CreateOAuthProvider: + """https://join-lemmy.org/api/interfaces/CreateOAuthProvider.html""" - id: int = None display_name: str = None issuer: str = None authorization_endpoint: str = None @@ -1939,17 +2075,15 @@ class OAuthProvider: userinfo_endpoint: str = None id_claim: str = None client_id: str = None + client_secret: str = None scopes: str = None - auto_verify_email: bool = None - account_linking_enabled: bool = None - enabled: bool = None - published: str = None - updated: Optional[str] = None + auto_verify_email: Optional[bool] = None + account_linking_enabled: Optional[bool] = None + enabled: Optional[bool] = None @classmethod def parse(cls, data: dict[str, Any]): return cls( - id=data["id"], display_name=data["display_name"], issuer=data["issuer"], authorization_endpoint=data["authorization_endpoint"], @@ -1957,378 +2091,302 @@ def parse(cls, data: dict[str, Any]): userinfo_endpoint=data["userinfo_endpoint"], id_claim=data["id_claim"], client_id=data["client_id"], + client_secret=data["client_secret"], scopes=data["scopes"], - auto_verify_email=data["auto_verify_email"], - account_linking_enabled=data["account_linking_enabled"], - enabled=data["enabled"], - published=data["published"], - updated=data["updated"] if "updated" in data else None - ) - - -@dataclass -class BanFromCommunity: - """https://join-lemmy.org/api/interfaces/BanFromCommunity.html""" - - community_id: int = None - person_id: int = None - ban: bool = None - remove_or_restore_data: Optional[bool] = None - reason: Optional[str] = None - expires: Optional[int] = None - - @classmethod - def parse(cls, data: dict[str, Any]): - return cls( - community_id=data["community_id"], - person_id=data["person_id"], - ban=data["ban"], - remove_or_restore_data=data["remove_or_restore_data"] if "remove_or_restore_data" in data else None, - reason=data["reason"] if "reason" in data else None, - expires=data["expires"] if "expires" in data else None + auto_verify_email=data["auto_verify_email"] if "auto_verify_email" in data else None, + account_linking_enabled=data["account_linking_enabled"] if "account_linking_enabled" in data else None, + enabled=data["enabled"] if "enabled" in data else None ) @dataclass -class CreatePostLike: - """https://join-lemmy.org/api/interfaces/CreatePostLike.html""" +class AdminPurgeComment: + """https://join-lemmy.org/api/interfaces/AdminPurgeComment.html""" + id: int = None + admin_person_id: int = None post_id: int = None - score: int = None + reason: Optional[str] = None + when_: str = None @classmethod def parse(cls, data: dict[str, Any]): return cls( + id=data["id"], + admin_person_id=data["admin_person_id"], post_id=data["post_id"], - score=data["score"] + reason=data["reason"] if "reason" in data else None, + when_=data["when_"] ) @dataclass -class RemovePost: - """https://join-lemmy.org/api/interfaces/RemovePost.html""" +class Language: + """https://join-lemmy.org/api/interfaces/Language.html""" - post_id: int = None - removed: bool = None - reason: Optional[str] = None + id: int = None + code: str = None + name: str = None @classmethod def parse(cls, data: dict[str, Any]): return cls( - post_id=data["post_id"], - removed=data["removed"], - reason=data["reason"] if "reason" in data else None + id=data["id"], + code=data["code"], + name=data["name"] ) @dataclass -class EditPrivateMessage: - """https://join-lemmy.org/api/interfaces/EditPrivateMessage.html""" +class ResolvePostReport: + """https://join-lemmy.org/api/interfaces/ResolvePostReport.html""" - private_message_id: int = None - content: str = None + report_id: int = None + resolved: bool = None @classmethod def parse(cls, data: dict[str, Any]): return cls( - private_message_id=data["private_message_id"], - content=data["content"] + report_id=data["report_id"], + resolved=data["resolved"] ) @dataclass -class ImageDetails: - """https://join-lemmy.org/api/interfaces/ImageDetails.html""" +class GetPersonDetails: + """https://join-lemmy.org/api/interfaces/GetPersonDetails.html""" - link: str = None - width: int = None - height: int = None - content_type: str = None + person_id: Optional[int] = None + username: Optional[str] = None + sort: Optional[str] = None + page: Optional[int] = None + limit: Optional[int] = None + community_id: Optional[int] = None + saved_only: Optional[bool] = None @classmethod def parse(cls, data: dict[str, Any]): return cls( - link=data["link"], - width=data["width"], - height=data["height"], - content_type=data["content_type"] + person_id=data["person_id"] if "person_id" in data else None, + username=data["username"] if "username" in data else None, + sort=data["sort"] if "sort" in data else None, + page=data["page"] if "page" in data else None, + limit=data["limit"] if "limit" in data else None, + community_id=data["community_id"] if "community_id" in data else None, + saved_only=data["saved_only"] if "saved_only" in data else None ) @dataclass -class GetModlog: - """https://join-lemmy.org/api/interfaces/GetModlog.html""" +class PurgePost: + """https://join-lemmy.org/api/interfaces/PurgePost.html""" - mod_person_id: Optional[int] = None - community_id: Optional[int] = None - page: Optional[int] = None - limit: Optional[int] = None - type_: Optional[str] = None - other_person_id: Optional[int] = None - post_id: Optional[int] = None - comment_id: Optional[int] = None + post_id: int = None + reason: Optional[str] = None @classmethod def parse(cls, data: dict[str, Any]): return cls( - mod_person_id=data["mod_person_id"] if "mod_person_id" in data else None, - community_id=data["community_id"] if "community_id" in data else None, - page=data["page"] if "page" in data else None, - limit=data["limit"] if "limit" in data else None, - type_=data["type_"] if "type_" in data else None, - other_person_id=data["other_person_id"] if "other_person_id" in data else None, - post_id=data["post_id"] if "post_id" in data else None, - comment_id=data["comment_id"] if "comment_id" in data else None + post_id=data["post_id"], + reason=data["reason"] if "reason" in data else None ) -@dataclass -class SaveUserSettings: - """https://join-lemmy.org/api/interfaces/SaveUserSettings.html""" - - show_nsfw: Optional[bool] = None - blur_nsfw: Optional[bool] = None - theme: Optional[str] = None - default_listing_type: Optional[str] = None - post_listing_mode: Optional[str] = None - default_post_sort_type: Optional[str] = None - default_comment_sort_type: Optional[str] = None - interface_language: Optional[str] = None - avatar: Optional[str] = None - banner: Optional[str] = None - display_name: Optional[str] = None - email: Optional[str] = None - bio: Optional[str] = None - matrix_user_id: Optional[str] = None - show_avatars: Optional[bool] = None - send_notifications_to_email: Optional[bool] = None - bot_account: Optional[bool] = None - show_bot_accounts: Optional[bool] = None - show_read_posts: Optional[bool] = None - discussion_languages: Optional[list[int]] = None - open_links_in_new_tab: Optional[bool] = None - infinite_scroll_enabled: Optional[bool] = None - enable_keyboard_navigation: Optional[bool] = None - enable_animated_images: Optional[bool] = None - collapse_bot_comments: Optional[bool] = None - show_scores: Optional[bool] = None - show_upvotes: Optional[bool] = None - show_downvotes: Optional[bool] = None - show_upvote_percentage: Optional[bool] = None +@dataclass +class LoginToken: + """https://join-lemmy.org/api/interfaces/LoginToken.html""" + + user_id: int = None + published: str = None + ip: Optional[str] = None + user_agent: Optional[str] = None @classmethod def parse(cls, data: dict[str, Any]): return cls( - show_nsfw=data["show_nsfw"] if "show_nsfw" in data else None, - blur_nsfw=data["blur_nsfw"] if "blur_nsfw" in data else None, - theme=data["theme"] if "theme" in data else None, - default_listing_type=data["default_listing_type"] if "default_listing_type" in data else None, - post_listing_mode=data["post_listing_mode"] if "post_listing_mode" in data else None, - default_post_sort_type=data["default_post_sort_type"] if "default_post_sort_type" in data else None, - default_comment_sort_type=data["default_comment_sort_type"] if "default_comment_sort_type" in data else None, - interface_language=data["interface_language"] if "interface_language" in data else None, - avatar=data["avatar"] if "avatar" in data else None, - banner=data["banner"] if "banner" in data else None, - display_name=data["display_name"] if "display_name" in data else None, - email=data["email"] if "email" in data else None, - bio=data["bio"] if "bio" in data else None, - matrix_user_id=data["matrix_user_id"] if "matrix_user_id" in data else None, - show_avatars=data["show_avatars"] if "show_avatars" in data else None, - send_notifications_to_email=data["send_notifications_to_email"] if "send_notifications_to_email" in data else None, - bot_account=data["bot_account"] if "bot_account" in data else None, - show_bot_accounts=data["show_bot_accounts"] if "show_bot_accounts" in data else None, - show_read_posts=data["show_read_posts"] if "show_read_posts" in data else None, - discussion_languages=[e0 for e0 in data["discussion_languages"]] if "discussion_languages" in data else None, - open_links_in_new_tab=data["open_links_in_new_tab"] if "open_links_in_new_tab" in data else None, - infinite_scroll_enabled=data["infinite_scroll_enabled"] if "infinite_scroll_enabled" in data else None, - enable_keyboard_navigation=data["enable_keyboard_navigation"] if "enable_keyboard_navigation" in data else None, - enable_animated_images=data["enable_animated_images"] if "enable_animated_images" in data else None, - collapse_bot_comments=data["collapse_bot_comments"] if "collapse_bot_comments" in data else None, - show_scores=data["show_scores"] if "show_scores" in data else None, - show_upvotes=data["show_upvotes"] if "show_upvotes" in data else None, - show_downvotes=data["show_downvotes"] if "show_downvotes" in data else None, - show_upvote_percentage=data["show_upvote_percentage"] if "show_upvote_percentage" in data else None + user_id=data["user_id"], + published=data["published"], + ip=data["ip"] if "ip" in data else None, + user_agent=data["user_agent"] if "user_agent" in data else None ) @dataclass -class GetRandomCommunity: - """https://join-lemmy.org/api/interfaces/GetRandomCommunity.html""" +class RemoveCommunity: + """https://join-lemmy.org/api/interfaces/RemoveCommunity.html""" - type_: Optional[str] = None + community_id: int = None + removed: bool = None + reason: Optional[str] = None @classmethod def parse(cls, data: dict[str, Any]): return cls( - type_=data["type_"] if "type_" in data else None + community_id=data["community_id"], + removed=data["removed"], + reason=data["reason"] if "reason" in data else None ) @dataclass -class DeleteTagline: - """https://join-lemmy.org/api/interfaces/DeleteTagline.html""" +class SaveComment: + """https://join-lemmy.org/api/interfaces/SaveComment.html""" - id: int = None + comment_id: int = None + save: bool = None @classmethod def parse(cls, data: dict[str, Any]): return cls( - id=data["id"] + comment_id=data["comment_id"], + save=data["save"] ) @dataclass -class CreatePrivateMessage: - """https://join-lemmy.org/api/interfaces/CreatePrivateMessage.html""" +class BlockCommunity: + """https://join-lemmy.org/api/interfaces/BlockCommunity.html""" - content: str = None - recipient_id: int = None + community_id: int = None + block: bool = None @classmethod def parse(cls, data: dict[str, Any]): return cls( - content=data["content"], - recipient_id=data["recipient_id"] + community_id=data["community_id"], + block=data["block"] ) @dataclass -class LocalSiteRateLimit: - """https://join-lemmy.org/api/interfaces/LocalSiteRateLimit.html""" +class GetPost: + """https://join-lemmy.org/api/interfaces/GetPost.html""" - local_site_id: int = None - message: int = None - message_per_second: int = None - post: int = None - post_per_second: int = None - register: int = None - register_per_second: int = None - image: int = None - image_per_second: int = None - comment: int = None - comment_per_second: int = None - search: int = None - search_per_second: int = None - published: str = None - updated: Optional[str] = None - import_user_settings: int = None - import_user_settings_per_second: int = None + id: Optional[int] = None + comment_id: Optional[int] = None @classmethod def parse(cls, data: dict[str, Any]): return cls( - local_site_id=data["local_site_id"], - message=data["message"], - message_per_second=data["message_per_second"], - post=data["post"], - post_per_second=data["post_per_second"], - register=data["register"], - register_per_second=data["register_per_second"], - image=data["image"], - image_per_second=data["image_per_second"], - comment=data["comment"], - comment_per_second=data["comment_per_second"], - search=data["search"], - search_per_second=data["search_per_second"], - published=data["published"], - updated=data["updated"] if "updated" in data else None, - import_user_settings=data["import_user_settings"], - import_user_settings_per_second=data["import_user_settings_per_second"] + id=data["id"] if "id" in data else None, + comment_id=data["comment_id"] if "comment_id" in data else None ) @dataclass -class ListCommentLikes: - """https://join-lemmy.org/api/interfaces/ListCommentLikes.html""" +class CreateCustomEmoji: + """https://join-lemmy.org/api/interfaces/CreateCustomEmoji.html""" - comment_id: int = None - page: Optional[int] = None - limit: Optional[int] = None + category: str = None + shortcode: str = None + image_url: str = None + alt_text: str = None + keywords: list[str] = None @classmethod def parse(cls, data: dict[str, Any]): return cls( - comment_id=data["comment_id"], - page=data["page"] if "page" in data else None, - limit=data["limit"] if "limit" in data else None + category=data["category"], + shortcode=data["shortcode"], + image_url=data["image_url"], + alt_text=data["alt_text"], + keywords=[e0 for e0 in data["keywords"]] ) @dataclass -class CreateOAuthProvider: - """https://join-lemmy.org/api/interfaces/CreateOAuthProvider.html""" +class ModlogListParams: + """https://join-lemmy.org/api/interfaces/ModlogListParams.html""" - display_name: str = None - issuer: str = None - authorization_endpoint: str = None - token_endpoint: str = None - userinfo_endpoint: str = None - id_claim: str = None - client_id: str = None - client_secret: str = None - scopes: str = None - auto_verify_email: Optional[bool] = None - account_linking_enabled: Optional[bool] = None - enabled: Optional[bool] = None + community_id: Optional[int] = None + mod_person_id: Optional[int] = None + other_person_id: Optional[int] = None + post_id: Optional[int] = None + comment_id: Optional[int] = None + page: Optional[int] = None + limit: Optional[int] = None + hide_modlog_names: bool = None @classmethod def parse(cls, data: dict[str, Any]): return cls( - display_name=data["display_name"], - issuer=data["issuer"], - authorization_endpoint=data["authorization_endpoint"], - token_endpoint=data["token_endpoint"], - userinfo_endpoint=data["userinfo_endpoint"], - id_claim=data["id_claim"], - client_id=data["client_id"], - client_secret=data["client_secret"], - scopes=data["scopes"], - auto_verify_email=data["auto_verify_email"] if "auto_verify_email" in data else None, - account_linking_enabled=data["account_linking_enabled"] if "account_linking_enabled" in data else None, - enabled=data["enabled"] if "enabled" in data else None + community_id=data["community_id"] if "community_id" in data else None, + mod_person_id=data["mod_person_id"] if "mod_person_id" in data else None, + other_person_id=data["other_person_id"] if "other_person_id" in data else None, + post_id=data["post_id"] if "post_id" in data else None, + comment_id=data["comment_id"] if "comment_id" in data else None, + page=data["page"] if "page" in data else None, + limit=data["limit"] if "limit" in data else None, + hide_modlog_names=data["hide_modlog_names"] ) @dataclass -class SaveComment: - """https://join-lemmy.org/api/interfaces/SaveComment.html""" +class OAuthAccount: + """https://join-lemmy.org/api/interfaces/OAuthAccount.html""" - comment_id: int = None - save: bool = None + local_user_id: int = None + oauth_provider_id: int = None + oauth_user_id: str = None + published: str = None + updated: Optional[str] = None @classmethod def parse(cls, data: dict[str, Any]): return cls( - comment_id=data["comment_id"], - save=data["save"] + local_user_id=data["local_user_id"], + oauth_provider_id=data["oauth_provider_id"], + oauth_user_id=data["oauth_user_id"], + published=data["published"], + updated=data["updated"] if "updated" in data else None ) @dataclass -class ListMedia: - """https://join-lemmy.org/api/interfaces/ListMedia.html""" +class PostReport: + """https://join-lemmy.org/api/interfaces/PostReport.html""" - page: Optional[int] = None - limit: Optional[int] = None + id: int = None + creator_id: int = None + post_id: int = None + original_post_name: str = None + original_post_url: Optional[str] = None + original_post_body: Optional[str] = None + reason: str = None + resolved: bool = None + resolver_id: Optional[int] = None + published: str = None + updated: Optional[str] = None @classmethod def parse(cls, data: dict[str, Any]): return cls( - page=data["page"] if "page" in data else None, - limit=data["limit"] if "limit" in data else None + id=data["id"], + creator_id=data["creator_id"], + post_id=data["post_id"], + original_post_name=data["original_post_name"], + original_post_url=data["original_post_url"] if "original_post_url" in data else None, + original_post_body=data["original_post_body"] if "original_post_body" in data else None, + reason=data["reason"], + resolved=data["resolved"], + resolver_id=data["resolver_id"] if "resolver_id" in data else None, + published=data["published"], + updated=data["updated"] if "updated" in data else None ) @dataclass -class DeleteOAuthProvider: - """https://join-lemmy.org/api/interfaces/DeleteOAuthProvider.html""" +class UpdateTagline: + """https://join-lemmy.org/api/interfaces/UpdateTagline.html""" id: int = None + content: str = None @classmethod def parse(cls, data: dict[str, Any]): return cls( - id=data["id"] + id=data["id"], + content=data["content"] ) @@ -2396,154 +2454,78 @@ def parse(cls, data: dict[str, Any]): default_post_sort_type=data["default_post_sort_type"], default_comment_sort_type=data["default_comment_sort_type"], oauth_registration=data["oauth_registration"], - post_upvotes=data["post_upvotes"], - post_downvotes=data["post_downvotes"], - comment_upvotes=data["comment_upvotes"], - comment_downvotes=data["comment_downvotes"] - ) - - -@dataclass -class CustomEmojiKeyword: - """https://join-lemmy.org/api/interfaces/CustomEmojiKeyword.html""" - - custom_emoji_id: int = None - keyword: str = None - - @classmethod - def parse(cls, data: dict[str, Any]): - return cls( - custom_emoji_id=data["custom_emoji_id"], - keyword=data["keyword"] + post_upvotes=data["post_upvotes"], + post_downvotes=data["post_downvotes"], + comment_upvotes=data["comment_upvotes"], + comment_downvotes=data["comment_downvotes"] ) @dataclass -class ModlogListParams: - """https://join-lemmy.org/api/interfaces/ModlogListParams.html""" +class PasswordReset: + """https://join-lemmy.org/api/interfaces/PasswordReset.html""" - community_id: Optional[int] = None - mod_person_id: Optional[int] = None - other_person_id: Optional[int] = None - post_id: Optional[int] = None - comment_id: Optional[int] = None - page: Optional[int] = None - limit: Optional[int] = None - hide_modlog_names: bool = None + email: str = None @classmethod def parse(cls, data: dict[str, Any]): return cls( - community_id=data["community_id"] if "community_id" in data else None, - mod_person_id=data["mod_person_id"] if "mod_person_id" in data else None, - other_person_id=data["other_person_id"] if "other_person_id" in data else None, - post_id=data["post_id"] if "post_id" in data else None, - comment_id=data["comment_id"] if "comment_id" in data else None, - page=data["page"] if "page" in data else None, - limit=data["limit"] if "limit" in data else None, - hide_modlog_names=data["hide_modlog_names"] + email=data["email"] ) @dataclass -class ModRemoveComment: - """https://join-lemmy.org/api/interfaces/ModRemoveComment.html""" +class ChangePassword: + """https://join-lemmy.org/api/interfaces/ChangePassword.html""" - id: int = None - mod_person_id: int = None - comment_id: int = None - reason: Optional[str] = None - removed: bool = None - when_: str = None + new_password: str = None + new_password_verify: str = None + old_password: str = None @classmethod def parse(cls, data: dict[str, Any]): return cls( - id=data["id"], - mod_person_id=data["mod_person_id"], - comment_id=data["comment_id"], - reason=data["reason"] if "reason" in data else None, - removed=data["removed"], - when_=data["when_"] + new_password=data["new_password"], + new_password_verify=data["new_password_verify"], + old_password=data["old_password"] ) @dataclass -class GetComments: - """https://join-lemmy.org/api/interfaces/GetComments.html""" +class CreateCommentLike: + """https://join-lemmy.org/api/interfaces/CreateCommentLike.html""" - type_: Optional[str] = None - sort: Optional[str] = None - max_depth: Optional[int] = None - page: Optional[int] = None - limit: Optional[int] = None - community_id: Optional[int] = None - community_name: Optional[str] = None - post_id: Optional[int] = None - parent_id: Optional[int] = None - saved_only: Optional[bool] = None - liked_only: Optional[bool] = None - disliked_only: Optional[bool] = None + comment_id: int = None + score: int = None @classmethod def parse(cls, data: dict[str, Any]): return cls( - type_=data["type_"] if "type_" in data else None, - sort=data["sort"] if "sort" in data else None, - max_depth=data["max_depth"] if "max_depth" in data else None, - page=data["page"] if "page" in data else None, - limit=data["limit"] if "limit" in data else None, - community_id=data["community_id"] if "community_id" in data else None, - community_name=data["community_name"] if "community_name" in data else None, - post_id=data["post_id"] if "post_id" in data else None, - parent_id=data["parent_id"] if "parent_id" in data else None, - saved_only=data["saved_only"] if "saved_only" in data else None, - liked_only=data["liked_only"] if "liked_only" in data else None, - disliked_only=data["disliked_only"] if "disliked_only" in data else None + comment_id=data["comment_id"], + score=data["score"] ) @dataclass -class EditOAuthProvider: - """https://join-lemmy.org/api/interfaces/EditOAuthProvider.html""" +class GetComment: + """https://join-lemmy.org/api/interfaces/GetComment.html""" id: int = None - display_name: Optional[str] = None - authorization_endpoint: Optional[str] = None - token_endpoint: Optional[str] = None - userinfo_endpoint: Optional[str] = None - id_claim: Optional[str] = None - client_secret: Optional[str] = None - scopes: Optional[str] = None - auto_verify_email: Optional[bool] = None - account_linking_enabled: Optional[bool] = None - enabled: Optional[bool] = None @classmethod def parse(cls, data: dict[str, Any]): return cls( - id=data["id"], - display_name=data["display_name"] if "display_name" in data else None, - authorization_endpoint=data["authorization_endpoint"] if "authorization_endpoint" in data else None, - token_endpoint=data["token_endpoint"] if "token_endpoint" in data else None, - userinfo_endpoint=data["userinfo_endpoint"] if "userinfo_endpoint" in data else None, - id_claim=data["id_claim"] if "id_claim" in data else None, - client_secret=data["client_secret"] if "client_secret" in data else None, - scopes=data["scopes"] if "scopes" in data else None, - auto_verify_email=data["auto_verify_email"] if "auto_verify_email" in data else None, - account_linking_enabled=data["account_linking_enabled"] if "account_linking_enabled" in data else None, - enabled=data["enabled"] if "enabled" in data else None + id=data["id"] ) @dataclass -class ModBanFromCommunity: - """https://join-lemmy.org/api/interfaces/ModBanFromCommunity.html""" +class ModBan: + """https://join-lemmy.org/api/interfaces/ModBan.html""" id: int = None mod_person_id: int = None other_person_id: int = None - community_id: int = None reason: Optional[str] = None banned: bool = None expires: Optional[str] = None @@ -2555,7 +2537,6 @@ def parse(cls, data: dict[str, Any]): id=data["id"], mod_person_id=data["mod_person_id"], other_person_id=data["other_person_id"], - community_id=data["community_id"], reason=data["reason"] if "reason" in data else None, banned=data["banned"], expires=data["expires"] if "expires" in data else None, @@ -2579,186 +2560,160 @@ def parse(cls, data: dict[str, Any]): @dataclass -class GetCommunity: - """https://join-lemmy.org/api/interfaces/GetCommunity.html""" - - id: Optional[int] = None - name: Optional[str] = None - - @classmethod - def parse(cls, data: dict[str, Any]): - return cls( - id=data["id"] if "id" in data else None, - name=data["name"] if "name" in data else None - ) - - -@dataclass -class PrivateMessageReport: - """https://join-lemmy.org/api/interfaces/PrivateMessageReport.html""" +class CreateTagline: + """https://join-lemmy.org/api/interfaces/CreateTagline.html""" - id: int = None - creator_id: int = None - private_message_id: int = None - original_pm_text: str = None - reason: str = None - resolved: bool = None - resolver_id: Optional[int] = None - published: str = None - updated: Optional[str] = None + content: str = None @classmethod def parse(cls, data: dict[str, Any]): return cls( - id=data["id"], - creator_id=data["creator_id"], - private_message_id=data["private_message_id"], - original_pm_text=data["original_pm_text"], - reason=data["reason"], - resolved=data["resolved"], - resolver_id=data["resolver_id"] if "resolver_id" in data else None, - published=data["published"], - updated=data["updated"] if "updated" in data else None + content=data["content"] ) @dataclass -class SavePost: - """https://join-lemmy.org/api/interfaces/SavePost.html""" +class DeletePost: + """https://join-lemmy.org/api/interfaces/DeletePost.html""" post_id: int = None - save: bool = None + deleted: bool = None @classmethod def parse(cls, data: dict[str, Any]): return cls( post_id=data["post_id"], - save=data["save"] - ) - - -@dataclass -class PasswordReset: - """https://join-lemmy.org/api/interfaces/PasswordReset.html""" - - email: str = None - - @classmethod - def parse(cls, data: dict[str, Any]): - return cls( - email=data["email"] - ) - - -@dataclass -class CreateCommentReport: - """https://join-lemmy.org/api/interfaces/CreateCommentReport.html""" - - comment_id: int = None - reason: str = None - - @classmethod - def parse(cls, data: dict[str, Any]): - return cls( - comment_id=data["comment_id"], - reason=data["reason"] - ) - - -@dataclass -class CreateCommentLike: - """https://join-lemmy.org/api/interfaces/CreateCommentLike.html""" - - comment_id: int = None - score: int = None - - @classmethod - def parse(cls, data: dict[str, Any]): - return cls( - comment_id=data["comment_id"], - score=data["score"] + deleted=data["deleted"] ) @dataclass -class Register: - """https://join-lemmy.org/api/interfaces/Register.html""" +class EditOAuthProvider: + """https://join-lemmy.org/api/interfaces/EditOAuthProvider.html""" - username: str = None - password: str = None - password_verify: str = None - show_nsfw: Optional[bool] = None - email: Optional[str] = None - captcha_uuid: Optional[str] = None - captcha_answer: Optional[str] = None - honeypot: Optional[str] = None - answer: Optional[str] = None + id: int = None + display_name: Optional[str] = None + authorization_endpoint: Optional[str] = None + token_endpoint: Optional[str] = None + userinfo_endpoint: Optional[str] = None + id_claim: Optional[str] = None + client_secret: Optional[str] = None + scopes: Optional[str] = None + auto_verify_email: Optional[bool] = None + account_linking_enabled: Optional[bool] = None + enabled: Optional[bool] = None @classmethod def parse(cls, data: dict[str, Any]): return cls( - username=data["username"], - password=data["password"], - password_verify=data["password_verify"], - show_nsfw=data["show_nsfw"] if "show_nsfw" in data else None, - email=data["email"] if "email" in data else None, - captcha_uuid=data["captcha_uuid"] if "captcha_uuid" in data else None, - captcha_answer=data["captcha_answer"] if "captcha_answer" in data else None, - honeypot=data["honeypot"] if "honeypot" in data else None, - answer=data["answer"] if "answer" in data else None + id=data["id"], + display_name=data["display_name"] if "display_name" in data else None, + authorization_endpoint=data["authorization_endpoint"] if "authorization_endpoint" in data else None, + token_endpoint=data["token_endpoint"] if "token_endpoint" in data else None, + userinfo_endpoint=data["userinfo_endpoint"] if "userinfo_endpoint" in data else None, + id_claim=data["id_claim"] if "id_claim" in data else None, + client_secret=data["client_secret"] if "client_secret" in data else None, + scopes=data["scopes"] if "scopes" in data else None, + auto_verify_email=data["auto_verify_email"] if "auto_verify_email" in data else None, + account_linking_enabled=data["account_linking_enabled"] if "account_linking_enabled" in data else None, + enabled=data["enabled"] if "enabled" in data else None ) @dataclass -class FederatedInstances: - """https://join-lemmy.org/api/interfaces/FederatedInstances.html""" +class GetPosts: + """https://join-lemmy.org/api/interfaces/GetPosts.html""" - linked: list[InstanceWithFederationState] = None - allowed: list[InstanceWithFederationState] = None - blocked: list[InstanceWithFederationState] = None + type_: Optional[str] = None + sort: Optional[str] = None + page: Optional[int] = None + limit: Optional[int] = None + community_id: Optional[int] = None + community_name: Optional[str] = None + saved_only: Optional[bool] = None + liked_only: Optional[bool] = None + disliked_only: Optional[bool] = None + show_hidden: Optional[bool] = None + show_read: Optional[bool] = None + show_nsfw: Optional[bool] = None + no_comments_only: Optional[bool] = None + page_cursor: Optional[str] = None @classmethod def parse(cls, data: dict[str, Any]): return cls( - linked=[InstanceWithFederationState.parse(e0) for e0 in data["linked"]], - allowed=[InstanceWithFederationState.parse(e0) for e0 in data["allowed"]], - blocked=[InstanceWithFederationState.parse(e0) for e0 in data["blocked"]] + type_=data["type_"] if "type_" in data else None, + sort=data["sort"] if "sort" in data else None, + page=data["page"] if "page" in data else None, + limit=data["limit"] if "limit" in data else None, + community_id=data["community_id"] if "community_id" in data else None, + community_name=data["community_name"] if "community_name" in data else None, + saved_only=data["saved_only"] if "saved_only" in data else None, + liked_only=data["liked_only"] if "liked_only" in data else None, + disliked_only=data["disliked_only"] if "disliked_only" in data else None, + show_hidden=data["show_hidden"] if "show_hidden" in data else None, + show_read=data["show_read"] if "show_read" in data else None, + show_nsfw=data["show_nsfw"] if "show_nsfw" in data else None, + no_comments_only=data["no_comments_only"] if "no_comments_only" in data else None, + page_cursor=data["page_cursor"] if "page_cursor" in data else None ) @dataclass -class DeleteAccount: - """https://join-lemmy.org/api/interfaces/DeleteAccount.html""" +class BanPerson: + """https://join-lemmy.org/api/interfaces/BanPerson.html""" - password: str = None - delete_content: bool = None + person_id: int = None + ban: bool = None + remove_or_restore_data: Optional[bool] = None + reason: Optional[str] = None + expires: Optional[int] = None @classmethod def parse(cls, data: dict[str, Any]): return cls( - password=data["password"], - delete_content=data["delete_content"] + person_id=data["person_id"], + ban=data["ban"], + remove_or_restore_data=data["remove_or_restore_data"] if "remove_or_restore_data" in data else None, + reason=data["reason"] if "reason" in data else None, + expires=data["expires"] if "expires" in data else None ) @dataclass -class MarkPrivateMessageAsRead: - """https://join-lemmy.org/api/interfaces/MarkPrivateMessageAsRead.html""" +class CreatePost: + """https://join-lemmy.org/api/interfaces/CreatePost.html""" - private_message_id: int = None - read: bool = None + name: str = None + community_id: int = None + url: Optional[str] = None + body: Optional[str] = None + alt_text: Optional[str] = None + honeypot: Optional[str] = None + nsfw: Optional[bool] = None + language_id: Optional[int] = None + custom_thumbnail: Optional[str] = None + scheduled_publish_time: Optional[int] = None @classmethod def parse(cls, data: dict[str, Any]): return cls( - private_message_id=data["private_message_id"], - read=data["read"] + name=data["name"], + community_id=data["community_id"], + url=data["url"] if "url" in data else None, + body=data["body"] if "body" in data else None, + alt_text=data["alt_text"] if "alt_text" in data else None, + honeypot=data["honeypot"] if "honeypot" in data else None, + nsfw=data["nsfw"] if "nsfw" in data else None, + language_id=data["language_id"] if "language_id" in data else None, + custom_thumbnail=data["custom_thumbnail"] if "custom_thumbnail" in data else None, + scheduled_publish_time=data["scheduled_publish_time"] if "scheduled_publish_time" in data else None ) @dataclass -class GetComment: - """https://join-lemmy.org/api/interfaces/GetComment.html""" +class DeleteCustomEmoji: + """https://join-lemmy.org/api/interfaces/DeleteCustomEmoji.html""" id: int = None @@ -2770,17 +2725,33 @@ def parse(cls, data: dict[str, Any]): @dataclass -class PurgeCommunity: - """https://join-lemmy.org/api/interfaces/PurgeCommunity.html""" +class PrivateMessage: + """https://join-lemmy.org/api/interfaces/PrivateMessage.html""" - community_id: int = None - reason: Optional[str] = None + id: int = None + creator_id: int = None + recipient_id: int = None + content: str = None + deleted: bool = None + read: bool = None + published: str = None + updated: Optional[str] = None + ap_id: str = None + local: bool = None @classmethod def parse(cls, data: dict[str, Any]): return cls( - community_id=data["community_id"], - reason=data["reason"] if "reason" in data else None + id=data["id"], + creator_id=data["creator_id"], + recipient_id=data["recipient_id"], + content=data["content"], + deleted=data["deleted"], + read=data["read"], + published=data["published"], + updated=data["updated"] if "updated" in data else None, + ap_id=data["ap_id"], + local=data["local"] ) @@ -2800,122 +2771,61 @@ def parse(cls, data: dict[str, Any]): @dataclass -class ModTransferCommunity: - """https://join-lemmy.org/api/interfaces/ModTransferCommunity.html""" +class ListPostLikes: + """https://join-lemmy.org/api/interfaces/ListPostLikes.html""" - id: int = None - mod_person_id: int = None - other_person_id: int = None - community_id: int = None - when_: str = None + post_id: int = None + page: Optional[int] = None + limit: Optional[int] = None @classmethod def parse(cls, data: dict[str, Any]): return cls( - id=data["id"], - mod_person_id=data["mod_person_id"], - other_person_id=data["other_person_id"], - community_id=data["community_id"], - when_=data["when_"] + post_id=data["post_id"], + page=data["page"] if "page" in data else None, + limit=data["limit"] if "limit" in data else None ) @dataclass -class Person: - """https://join-lemmy.org/api/interfaces/Person.html""" +class AuthenticateWithOauth: + """https://join-lemmy.org/api/interfaces/AuthenticateWithOauth.html""" - id: int = None - name: str = None - display_name: Optional[str] = None - avatar: Optional[str] = None - banned: bool = None - published: str = None - updated: Optional[str] = None - actor_id: str = None - bio: Optional[str] = None - local: bool = None - banner: Optional[str] = None - deleted: bool = None - matrix_user_id: Optional[str] = None - bot_account: bool = None - ban_expires: Optional[str] = None - instance_id: int = None + code: str = None + oauth_provider_id: int = None + redirect_uri: str = None + show_nsfw: Optional[bool] = None + username: Optional[str] = None + answer: Optional[str] = None @classmethod def parse(cls, data: dict[str, Any]): return cls( - id=data["id"], - name=data["name"], - display_name=data["display_name"] if "display_name" in data else None, - avatar=data["avatar"] if "avatar" in data else None, - banned=data["banned"], - published=data["published"], - updated=data["updated"] if "updated" in data else None, - actor_id=data["actor_id"], - bio=data["bio"] if "bio" in data else None, - local=data["local"], - banner=data["banner"] if "banner" in data else None, - deleted=data["deleted"], - matrix_user_id=data["matrix_user_id"] if "matrix_user_id" in data else None, - bot_account=data["bot_account"], - ban_expires=data["ban_expires"] if "ban_expires" in data else None, - instance_id=data["instance_id"] + code=data["code"], + oauth_provider_id=data["oauth_provider_id"], + redirect_uri=data["redirect_uri"], + show_nsfw=data["show_nsfw"] if "show_nsfw" in data else None, + username=data["username"] if "username" in data else None, + answer=data["answer"] if "answer" in data else None ) @dataclass -class Comment: - """https://join-lemmy.org/api/interfaces/Comment.html""" +class LocalSiteUrlBlocklist: + """https://join-lemmy.org/api/interfaces/LocalSiteUrlBlocklist.html""" id: int = None - creator_id: int = None - post_id: int = None - content: str = None - removed: bool = None + url: str = None published: str = None updated: Optional[str] = None - deleted: bool = None - ap_id: str = None - local: bool = None - path: str = None - distinguished: bool = None - language_id: int = None @classmethod def parse(cls, data: dict[str, Any]): return cls( id=data["id"], - creator_id=data["creator_id"], - post_id=data["post_id"], - content=data["content"], - removed=data["removed"], + url=data["url"], published=data["published"], - updated=data["updated"] if "updated" in data else None, - deleted=data["deleted"], - ap_id=data["ap_id"], - local=data["local"], - path=data["path"], - distinguished=data["distinguished"], - language_id=data["language_id"] - ) - - -@dataclass -class OpenGraphData: - """https://join-lemmy.org/api/interfaces/OpenGraphData.html""" - - title: Optional[str] = None - description: Optional[str] = None - image: Optional[str] = None - embed_video_url: Optional[str] = None - - @classmethod - def parse(cls, data: dict[str, Any]): - return cls( - title=data["title"] if "title" in data else None, - description=data["description"] if "description" in data else None, - image=data["image"] if "image" in data else None, - embed_video_url=data["embed_video_url"] if "embed_video_url" in data else None + updated=data["updated"] if "updated" in data else None ) @@ -2935,228 +2845,303 @@ def parse(cls, data: dict[str, Any]): @dataclass -class BlockCommunity: - """https://join-lemmy.org/api/interfaces/BlockCommunity.html""" - - community_id: int = None - block: bool = None - - @classmethod - def parse(cls, data: dict[str, Any]): - return cls( - community_id=data["community_id"], - block=data["block"] - ) - - -@dataclass -class AdminPurgePost: - """https://join-lemmy.org/api/interfaces/AdminPurgePost.html""" +class ModFeaturePost: + """https://join-lemmy.org/api/interfaces/ModFeaturePost.html""" id: int = None - admin_person_id: int = None - community_id: int = None - reason: Optional[str] = None + mod_person_id: int = None + post_id: int = None + featured: bool = None when_: str = None + is_featured_community: bool = None @classmethod def parse(cls, data: dict[str, Any]): return cls( id=data["id"], - admin_person_id=data["admin_person_id"], - community_id=data["community_id"], - reason=data["reason"] if "reason" in data else None, - when_=data["when_"] + mod_person_id=data["mod_person_id"], + post_id=data["post_id"], + featured=data["featured"], + when_=data["when_"], + is_featured_community=data["is_featured_community"] ) @dataclass -class ResolvePostReport: - """https://join-lemmy.org/api/interfaces/ResolvePostReport.html""" +class Community: + """https://join-lemmy.org/api/interfaces/Community.html""" - report_id: int = None - resolved: bool = None + id: int = None + name: str = None + title: str = None + sidebar: Optional[str] = None + removed: bool = None + published: str = None + updated: Optional[str] = None + deleted: bool = None + nsfw: bool = None + actor_id: str = None + local: bool = None + icon: Optional[str] = None + banner: Optional[str] = None + hidden: bool = None + posting_restricted_to_mods: bool = None + instance_id: int = None + visibility: str = None + description: Optional[str] = None @classmethod def parse(cls, data: dict[str, Any]): return cls( - report_id=data["report_id"], - resolved=data["resolved"] + id=data["id"], + name=data["name"], + title=data["title"], + sidebar=data["sidebar"] if "sidebar" in data else None, + removed=data["removed"], + published=data["published"], + updated=data["updated"] if "updated" in data else None, + deleted=data["deleted"], + nsfw=data["nsfw"], + actor_id=data["actor_id"], + local=data["local"], + icon=data["icon"] if "icon" in data else None, + banner=data["banner"] if "banner" in data else None, + hidden=data["hidden"], + posting_restricted_to_mods=data["posting_restricted_to_mods"], + instance_id=data["instance_id"], + visibility=data["visibility"], + description=data["description"] if "description" in data else None ) @dataclass -class CreateComment: - """https://join-lemmy.org/api/interfaces/CreateComment.html""" +class CreatePostLike: + """https://join-lemmy.org/api/interfaces/CreatePostLike.html""" - content: str = None post_id: int = None - parent_id: Optional[int] = None - language_id: Optional[int] = None + score: int = None @classmethod def parse(cls, data: dict[str, Any]): return cls( - content=data["content"], post_id=data["post_id"], - parent_id=data["parent_id"] if "parent_id" in data else None, - language_id=data["language_id"] if "language_id" in data else None + score=data["score"] ) @dataclass -class ListRegistrationApplications: - """https://join-lemmy.org/api/interfaces/ListRegistrationApplications.html""" +class GetCommunityPendingFollowsCount: + """https://join-lemmy.org/api/interfaces/GetCommunityPendingFollowsCount.html""" - unread_only: Optional[bool] = None - page: Optional[int] = None - limit: Optional[int] = None + community_id: int = None @classmethod def parse(cls, data: dict[str, Any]): return cls( - unread_only=data["unread_only"] if "unread_only" in data else None, - page=data["page"] if "page" in data else None, - limit=data["limit"] if "limit" in data else None + community_id=data["community_id"] ) @dataclass -class DistinguishComment: - """https://join-lemmy.org/api/interfaces/DistinguishComment.html""" +class SaveUserSettings: + """https://join-lemmy.org/api/interfaces/SaveUserSettings.html""" - comment_id: int = None - distinguished: bool = None + show_nsfw: Optional[bool] = None + blur_nsfw: Optional[bool] = None + theme: Optional[str] = None + default_listing_type: Optional[str] = None + post_listing_mode: Optional[str] = None + default_post_sort_type: Optional[str] = None + default_comment_sort_type: Optional[str] = None + interface_language: Optional[str] = None + avatar: Optional[str] = None + banner: Optional[str] = None + display_name: Optional[str] = None + email: Optional[str] = None + bio: Optional[str] = None + matrix_user_id: Optional[str] = None + show_avatars: Optional[bool] = None + send_notifications_to_email: Optional[bool] = None + bot_account: Optional[bool] = None + show_bot_accounts: Optional[bool] = None + show_read_posts: Optional[bool] = None + discussion_languages: Optional[list[int]] = None + open_links_in_new_tab: Optional[bool] = None + infinite_scroll_enabled: Optional[bool] = None + enable_keyboard_navigation: Optional[bool] = None + enable_animated_images: Optional[bool] = None + collapse_bot_comments: Optional[bool] = None + show_scores: Optional[bool] = None + show_upvotes: Optional[bool] = None + show_downvotes: Optional[bool] = None + show_upvote_percentage: Optional[bool] = None @classmethod def parse(cls, data: dict[str, Any]): return cls( - comment_id=data["comment_id"], - distinguished=data["distinguished"] + show_nsfw=data["show_nsfw"] if "show_nsfw" in data else None, + blur_nsfw=data["blur_nsfw"] if "blur_nsfw" in data else None, + theme=data["theme"] if "theme" in data else None, + default_listing_type=data["default_listing_type"] if "default_listing_type" in data else None, + post_listing_mode=data["post_listing_mode"] if "post_listing_mode" in data else None, + default_post_sort_type=data["default_post_sort_type"] if "default_post_sort_type" in data else None, + default_comment_sort_type=data["default_comment_sort_type"] if "default_comment_sort_type" in data else None, + interface_language=data["interface_language"] if "interface_language" in data else None, + avatar=data["avatar"] if "avatar" in data else None, + banner=data["banner"] if "banner" in data else None, + display_name=data["display_name"] if "display_name" in data else None, + email=data["email"] if "email" in data else None, + bio=data["bio"] if "bio" in data else None, + matrix_user_id=data["matrix_user_id"] if "matrix_user_id" in data else None, + show_avatars=data["show_avatars"] if "show_avatars" in data else None, + send_notifications_to_email=data["send_notifications_to_email"] if "send_notifications_to_email" in data else None, + bot_account=data["bot_account"] if "bot_account" in data else None, + show_bot_accounts=data["show_bot_accounts"] if "show_bot_accounts" in data else None, + show_read_posts=data["show_read_posts"] if "show_read_posts" in data else None, + discussion_languages=[e0 for e0 in data["discussion_languages"]] if "discussion_languages" in data else None, + open_links_in_new_tab=data["open_links_in_new_tab"] if "open_links_in_new_tab" in data else None, + infinite_scroll_enabled=data["infinite_scroll_enabled"] if "infinite_scroll_enabled" in data else None, + enable_keyboard_navigation=data["enable_keyboard_navigation"] if "enable_keyboard_navigation" in data else None, + enable_animated_images=data["enable_animated_images"] if "enable_animated_images" in data else None, + collapse_bot_comments=data["collapse_bot_comments"] if "collapse_bot_comments" in data else None, + show_scores=data["show_scores"] if "show_scores" in data else None, + show_upvotes=data["show_upvotes"] if "show_upvotes" in data else None, + show_downvotes=data["show_downvotes"] if "show_downvotes" in data else None, + show_upvote_percentage=data["show_upvote_percentage"] if "show_upvote_percentage" in data else None ) @dataclass -class CommentReport: - """https://join-lemmy.org/api/interfaces/CommentReport.html""" +class PersonMention: + """https://join-lemmy.org/api/interfaces/PersonMention.html""" id: int = None - creator_id: int = None + recipient_id: int = None comment_id: int = None - original_comment_text: str = None - reason: str = None - resolved: bool = None - resolver_id: Optional[int] = None + read: bool = None published: str = None - updated: Optional[str] = None @classmethod def parse(cls, data: dict[str, Any]): return cls( id=data["id"], - creator_id=data["creator_id"], + recipient_id=data["recipient_id"], comment_id=data["comment_id"], - original_comment_text=data["original_comment_text"], - reason=data["reason"], - resolved=data["resolved"], - resolver_id=data["resolver_id"] if "resolver_id" in data else None, - published=data["published"], - updated=data["updated"] if "updated" in data else None + read=data["read"], + published=data["published"] ) @dataclass -class DeleteCustomEmoji: - """https://join-lemmy.org/api/interfaces/DeleteCustomEmoji.html""" +class OAuthProvider: + """https://join-lemmy.org/api/interfaces/OAuthProvider.html""" id: int = None + display_name: str = None + issuer: str = None + authorization_endpoint: str = None + token_endpoint: str = None + userinfo_endpoint: str = None + id_claim: str = None + client_id: str = None + scopes: str = None + auto_verify_email: bool = None + account_linking_enabled: bool = None + enabled: bool = None + published: str = None + updated: Optional[str] = None @classmethod def parse(cls, data: dict[str, Any]): return cls( - id=data["id"] + id=data["id"], + display_name=data["display_name"], + issuer=data["issuer"], + authorization_endpoint=data["authorization_endpoint"], + token_endpoint=data["token_endpoint"], + userinfo_endpoint=data["userinfo_endpoint"], + id_claim=data["id_claim"], + client_id=data["client_id"], + scopes=data["scopes"], + auto_verify_email=data["auto_verify_email"], + account_linking_enabled=data["account_linking_enabled"], + enabled=data["enabled"], + published=data["published"], + updated=data["updated"] if "updated" in data else None ) @dataclass -class BanPerson: - """https://join-lemmy.org/api/interfaces/BanPerson.html""" +class DeleteCommunity: + """https://join-lemmy.org/api/interfaces/DeleteCommunity.html""" - person_id: int = None - ban: bool = None - remove_or_restore_data: Optional[bool] = None - reason: Optional[str] = None - expires: Optional[int] = None + community_id: int = None + deleted: bool = None @classmethod def parse(cls, data: dict[str, Any]): return cls( - person_id=data["person_id"], - ban=data["ban"], - remove_or_restore_data=data["remove_or_restore_data"] if "remove_or_restore_data" in data else None, - reason=data["reason"] if "reason" in data else None, - expires=data["expires"] if "expires" in data else None + community_id=data["community_id"], + deleted=data["deleted"] ) @dataclass -class ListCommentReports: - """https://join-lemmy.org/api/interfaces/ListCommentReports.html""" +class SiteAggregates: + """https://join-lemmy.org/api/interfaces/SiteAggregates.html""" - comment_id: Optional[int] = None - page: Optional[int] = None - limit: Optional[int] = None - unresolved_only: Optional[bool] = None - community_id: Optional[int] = None + site_id: int = None + users: int = None + posts: int = None + comments: int = None + communities: int = None + users_active_day: int = None + users_active_week: int = None + users_active_month: int = None + users_active_half_year: int = None @classmethod def parse(cls, data: dict[str, Any]): return cls( - comment_id=data["comment_id"] if "comment_id" in data else None, - page=data["page"] if "page" in data else None, - limit=data["limit"] if "limit" in data else None, - unresolved_only=data["unresolved_only"] if "unresolved_only" in data else None, - community_id=data["community_id"] if "community_id" in data else None + site_id=data["site_id"], + users=data["users"], + posts=data["posts"], + comments=data["comments"], + communities=data["communities"], + users_active_day=data["users_active_day"], + users_active_week=data["users_active_week"], + users_active_month=data["users_active_month"], + users_active_half_year=data["users_active_half_year"] ) @dataclass -class ModAdd: - """https://join-lemmy.org/api/interfaces/ModAdd.html""" +class BlockPerson: + """https://join-lemmy.org/api/interfaces/BlockPerson.html""" - id: int = None - mod_person_id: int = None - other_person_id: int = None - removed: bool = None - when_: str = None + person_id: int = None + block: bool = None @classmethod def parse(cls, data: dict[str, Any]): return cls( - id=data["id"], - mod_person_id=data["mod_person_id"], - other_person_id=data["other_person_id"], - removed=data["removed"], - when_=data["when_"] + person_id=data["person_id"], + block=data["block"] ) @dataclass -class ListCustomEmojis: - """https://join-lemmy.org/api/interfaces/ListCustomEmojis.html""" +class BlockInstance: + """https://join-lemmy.org/api/interfaces/BlockInstance.html""" - page: Optional[int] = None - limit: Optional[int] = None - category: Optional[str] = None - ignore_page_limits: Optional[bool] = None + instance_id: int = None + block: bool = None @classmethod def parse(cls, data: dict[str, Any]): return cls( - page=data["page"] if "page" in data else None, - limit=data["limit"] if "limit" in data else None, - category=data["category"] if "category" in data else None, - ignore_page_limits=data["ignore_page_limits"] if "ignore_page_limits" in data else None + instance_id=data["instance_id"], + block=data["block"] ) @@ -3268,187 +3253,203 @@ def parse(cls, data: dict[str, Any]): @dataclass -class Instance: - """https://join-lemmy.org/api/interfaces/Instance.html""" +class MarkPostAsRead: + """https://join-lemmy.org/api/interfaces/MarkPostAsRead.html""" - id: int = None - domain: str = None - published: str = None - updated: Optional[str] = None - software: Optional[str] = None - version: Optional[str] = None + post_ids: list[int] = None + read: bool = None @classmethod def parse(cls, data: dict[str, Any]): return cls( - id=data["id"], - domain=data["domain"], - published=data["published"], - updated=data["updated"] if "updated" in data else None, - software=data["software"] if "software" in data else None, - version=data["version"] if "version" in data else None + post_ids=[e0 for e0 in data["post_ids"]], + read=data["read"] ) @dataclass -class Post: - """https://join-lemmy.org/api/interfaces/Post.html""" +class UpdateTotp: + """https://join-lemmy.org/api/interfaces/UpdateTotp.html""" - id: int = None - name: str = None - url: Optional[str] = None - body: Optional[str] = None - creator_id: int = None - community_id: int = None - removed: bool = None - locked: bool = None - published: str = None - updated: Optional[str] = None - deleted: bool = None - nsfw: bool = None - embed_title: Optional[str] = None - embed_description: Optional[str] = None - thumbnail_url: Optional[str] = None - ap_id: str = None - local: bool = None - embed_video_url: Optional[str] = None - language_id: int = None - featured_community: bool = None - featured_local: bool = None - url_content_type: Optional[str] = None - alt_text: Optional[str] = None - scheduled_publish_time: Optional[str] = None + totp_token: str = None + enabled: bool = None @classmethod def parse(cls, data: dict[str, Any]): return cls( - id=data["id"], - name=data["name"], - url=data["url"] if "url" in data else None, - body=data["body"] if "body" in data else None, - creator_id=data["creator_id"], - community_id=data["community_id"], - removed=data["removed"], - locked=data["locked"], - published=data["published"], - updated=data["updated"] if "updated" in data else None, - deleted=data["deleted"], - nsfw=data["nsfw"], - embed_title=data["embed_title"] if "embed_title" in data else None, - embed_description=data["embed_description"] if "embed_description" in data else None, - thumbnail_url=data["thumbnail_url"] if "thumbnail_url" in data else None, - ap_id=data["ap_id"], - local=data["local"], - embed_video_url=data["embed_video_url"] if "embed_video_url" in data else None, - language_id=data["language_id"], - featured_community=data["featured_community"], - featured_local=data["featured_local"], - url_content_type=data["url_content_type"] if "url_content_type" in data else None, - alt_text=data["alt_text"] if "alt_text" in data else None, - scheduled_publish_time=data["scheduled_publish_time"] if "scheduled_publish_time" in data else None + totp_token=data["totp_token"], + enabled=data["enabled"] ) @dataclass -class GetPosts: - """https://join-lemmy.org/api/interfaces/GetPosts.html""" +class GetCommunity: + """https://join-lemmy.org/api/interfaces/GetCommunity.html""" + + id: Optional[int] = None + name: Optional[str] = None + + @classmethod + def parse(cls, data: dict[str, Any]): + return cls( + id=data["id"] if "id" in data else None, + name=data["name"] if "name" in data else None + ) + + +@dataclass +class ListPostReports: + """https://join-lemmy.org/api/interfaces/ListPostReports.html""" - type_: Optional[str] = None - sort: Optional[str] = None page: Optional[int] = None limit: Optional[int] = None + unresolved_only: Optional[bool] = None community_id: Optional[int] = None - community_name: Optional[str] = None - saved_only: Optional[bool] = None - liked_only: Optional[bool] = None - disliked_only: Optional[bool] = None - show_hidden: Optional[bool] = None - show_read: Optional[bool] = None - show_nsfw: Optional[bool] = None - no_comments_only: Optional[bool] = None - page_cursor: Optional[str] = None + post_id: Optional[int] = None @classmethod def parse(cls, data: dict[str, Any]): return cls( - type_=data["type_"] if "type_" in data else None, - sort=data["sort"] if "sort" in data else None, page=data["page"] if "page" in data else None, limit=data["limit"] if "limit" in data else None, + unresolved_only=data["unresolved_only"] if "unresolved_only" in data else None, community_id=data["community_id"] if "community_id" in data else None, - community_name=data["community_name"] if "community_name" in data else None, - saved_only=data["saved_only"] if "saved_only" in data else None, - liked_only=data["liked_only"] if "liked_only" in data else None, - disliked_only=data["disliked_only"] if "disliked_only" in data else None, - show_hidden=data["show_hidden"] if "show_hidden" in data else None, - show_read=data["show_read"] if "show_read" in data else None, - show_nsfw=data["show_nsfw"] if "show_nsfw" in data else None, - no_comments_only=data["no_comments_only"] if "no_comments_only" in data else None, - page_cursor=data["page_cursor"] if "page_cursor" in data else None + post_id=data["post_id"] if "post_id" in data else None ) @dataclass -class GetRegistrationApplication: - """https://join-lemmy.org/api/interfaces/GetRegistrationApplication.html""" +class PasswordChangeAfterReset: + """https://join-lemmy.org/api/interfaces/PasswordChangeAfterReset.html""" - person_id: int = None + token: str = None + password: str = None + password_verify: str = None @classmethod def parse(cls, data: dict[str, Any]): return cls( - person_id=data["person_id"] + token=data["token"], + password=data["password"], + password_verify=data["password_verify"] ) @dataclass -class GetReplies: - """https://join-lemmy.org/api/interfaces/GetReplies.html""" +class GetModlog: + """https://join-lemmy.org/api/interfaces/GetModlog.html""" - sort: Optional[str] = None + mod_person_id: Optional[int] = None + community_id: Optional[int] = None page: Optional[int] = None limit: Optional[int] = None - unread_only: Optional[bool] = None + type_: Optional[str] = None + other_person_id: Optional[int] = None + post_id: Optional[int] = None + comment_id: Optional[int] = None @classmethod def parse(cls, data: dict[str, Any]): return cls( - sort=data["sort"] if "sort" in data else None, + mod_person_id=data["mod_person_id"] if "mod_person_id" in data else None, + community_id=data["community_id"] if "community_id" in data else None, page=data["page"] if "page" in data else None, limit=data["limit"] if "limit" in data else None, - unread_only=data["unread_only"] if "unread_only" in data else None + type_=data["type_"] if "type_" in data else None, + other_person_id=data["other_person_id"] if "other_person_id" in data else None, + post_id=data["post_id"] if "post_id" in data else None, + comment_id=data["comment_id"] if "comment_id" in data else None ) @dataclass -class AdminPurgePerson: - """https://join-lemmy.org/api/interfaces/AdminPurgePerson.html""" +class FeaturePost: + """https://join-lemmy.org/api/interfaces/FeaturePost.html""" + + post_id: int = None + featured: bool = None + feature_type: str = None + + @classmethod + def parse(cls, data: dict[str, Any]): + return cls( + post_id=data["post_id"], + featured=data["featured"], + feature_type=data["feature_type"] + ) + + +@dataclass +class ResolvePrivateMessageReport: + """https://join-lemmy.org/api/interfaces/ResolvePrivateMessageReport.html""" + + report_id: int = None + resolved: bool = None + + @classmethod + def parse(cls, data: dict[str, Any]): + return cls( + report_id=data["report_id"], + resolved=data["resolved"] + ) + + +@dataclass +class PendingFollow: + """https://join-lemmy.org/api/interfaces/PendingFollow.html""" + + person: Person = None + community: Community = None + is_new_instance: bool = None + subscribed: str = None + + @classmethod + def parse(cls, data: dict[str, Any]): + return cls( + person=Person.parse(data["person"]), + community=Community.parse(data["community"]), + is_new_instance=data["is_new_instance"], + subscribed=data["subscribed"] + ) + + +@dataclass +class InstanceWithFederationState: + """https://join-lemmy.org/api/interfaces/InstanceWithFederationState.html""" + federation_state: Optional[ReadableFederationState] = None id: int = None - admin_person_id: int = None - reason: Optional[str] = None - when_: str = None + domain: str = None + published: str = None + updated: Optional[str] = None + software: Optional[str] = None + version: Optional[str] = None @classmethod def parse(cls, data: dict[str, Any]): return cls( + federation_state=ReadableFederationState.parse(data["federation_state"]) if "federation_state" in data else None, id=data["id"], - admin_person_id=data["admin_person_id"], - reason=data["reason"] if "reason" in data else None, - when_=data["when_"] + domain=data["domain"], + published=data["published"], + updated=data["updated"] if "updated" in data else None, + software=data["software"] if "software" in data else None, + version=data["version"] if "version" in data else None ) @dataclass -class TransferCommunity: - """https://join-lemmy.org/api/interfaces/TransferCommunity.html""" +class FederatedInstances: + """https://join-lemmy.org/api/interfaces/FederatedInstances.html""" - community_id: int = None - person_id: int = None + linked: list[InstanceWithFederationState] = None + allowed: list[InstanceWithFederationState] = None + blocked: list[InstanceWithFederationState] = None @classmethod def parse(cls, data: dict[str, Any]): return cls( - community_id=data["community_id"], - person_id=data["person_id"] + linked=[InstanceWithFederationState.parse(e0) for e0 in data["linked"]], + allowed=[InstanceWithFederationState.parse(e0) for e0 in data["allowed"]], + blocked=[InstanceWithFederationState.parse(e0) for e0 in data["blocked"]] ) diff --git a/pythonlemmy/responses.py b/pythonlemmy/responses.py index 3c9e658..b2bd6f7 100644 --- a/pythonlemmy/responses.py +++ b/pythonlemmy/responses.py @@ -7,311 +7,313 @@ from .types import ResponseWrapper -class CaptchaResponse(ResponseWrapper): - """https://join-lemmy.org/api/interfaces/CaptchaResponse.html""" +class UpdateTotpResponse(ResponseWrapper): + """https://join-lemmy.org/api/interfaces/UpdateTotpResponse.html""" - png: str = None - wav: str = None - uuid: str = None + enabled: bool = None def parse(self, data: dict[str, Any]): - self.png = data["png"] - self.wav = data["wav"] - self.uuid = data["uuid"] + self.enabled = data["enabled"] @classmethod def data( cls, - png: str = None, - wav: str = None, - uuid: str = None + enabled: bool = None ): obj = cls.__new__(cls) - obj.png = png - obj.wav = wav - obj.uuid = uuid + obj.enabled = enabled return obj -class BannedPersonsResponse(ResponseWrapper): - """https://join-lemmy.org/api/interfaces/BannedPersonsResponse.html""" +class BlockInstanceResponse(ResponseWrapper): + """https://join-lemmy.org/api/interfaces/BlockInstanceResponse.html""" - banned: list[PersonView] = None + blocked: bool = None def parse(self, data: dict[str, Any]): - self.banned = [PersonView.parse(e0) for e0 in data["banned"]] + self.blocked = data["blocked"] @classmethod def data( cls, - banned: list[PersonView] = None + blocked: bool = None ): obj = cls.__new__(cls) - obj.banned = banned + obj.blocked = blocked return obj -class ListMediaResponse(ResponseWrapper): - """https://join-lemmy.org/api/interfaces/ListMediaResponse.html""" +class GetReportCountResponse(ResponseWrapper): + """https://join-lemmy.org/api/interfaces/GetReportCountResponse.html""" - images: list[LocalImageView] = None + community_id: Optional[int] = None + comment_reports: int = None + post_reports: int = None + private_message_reports: Optional[int] = None def parse(self, data: dict[str, Any]): - self.images = [LocalImageView.parse(e0) for e0 in data["images"]] + self.community_id = data["community_id"] if "community_id" in data else None + self.comment_reports = data["comment_reports"] + self.post_reports = data["post_reports"] + self.private_message_reports = data["private_message_reports"] if "private_message_reports" in data else None @classmethod def data( cls, - images: list[LocalImageView] = None + community_id: Optional[int] = None, + comment_reports: int = None, + post_reports: int = None, + private_message_reports: Optional[int] = None ): obj = cls.__new__(cls) - obj.images = images + obj.community_id = community_id + obj.comment_reports = comment_reports + obj.post_reports = post_reports + obj.private_message_reports = private_message_reports return obj -class UpdateTotpResponse(ResponseWrapper): - """https://join-lemmy.org/api/interfaces/UpdateTotpResponse.html""" +class GetUnreadCountResponse(ResponseWrapper): + """https://join-lemmy.org/api/interfaces/GetUnreadCountResponse.html""" - enabled: bool = None + replies: int = None + mentions: int = None + private_messages: int = None def parse(self, data: dict[str, Any]): - self.enabled = data["enabled"] + self.replies = data["replies"] + self.mentions = data["mentions"] + self.private_messages = data["private_messages"] @classmethod def data( cls, - enabled: bool = None + replies: int = None, + mentions: int = None, + private_messages: int = None ): obj = cls.__new__(cls) - obj.enabled = enabled + obj.replies = replies + obj.mentions = mentions + obj.private_messages = private_messages return obj -class CommentReportResponse(ResponseWrapper): - """https://join-lemmy.org/api/interfaces/CommentReportResponse.html""" +class GetCommunityPendingFollowsCountResponse(ResponseWrapper): + """https://join-lemmy.org/api/interfaces/GetCommunityPendingFollowsCountResponse.html""" - comment_report_view: CommentReportView = None + count: int = None def parse(self, data: dict[str, Any]): - self.comment_report_view = CommentReportView.parse(data["comment_report_view"]) + self.count = data["count"] @classmethod def data( cls, - comment_report_view: CommentReportView = None + count: int = None ): obj = cls.__new__(cls) - obj.comment_report_view = comment_report_view + obj.count = count return obj -class GetCommunityResponse(ResponseWrapper): - """https://join-lemmy.org/api/interfaces/GetCommunityResponse.html""" +class SuccessResponse(ResponseWrapper): + """https://join-lemmy.org/api/interfaces/SuccessResponse.html""" - community_view: CommunityView = None - site: Optional[Site] = None - moderators: list[CommunityModeratorView] = None - discussion_languages: list[int] = None + success: bool = None def parse(self, data: dict[str, Any]): - self.community_view = CommunityView.parse(data["community_view"]) - self.site = Site.parse(data["site"]) if "site" in data else None - self.moderators = [CommunityModeratorView.parse(e0) for e0 in data["moderators"]] - self.discussion_languages = [e0 for e0 in data["discussion_languages"]] + self.success = data["success"] @classmethod def data( cls, - community_view: CommunityView = None, - site: Optional[Site] = None, - moderators: list[CommunityModeratorView] = None, - discussion_languages: list[int] = None + success: bool = None ): obj = cls.__new__(cls) - obj.community_view = community_view - obj.site = site - obj.moderators = moderators - obj.discussion_languages = discussion_languages + obj.success = success return obj -class GetPostsResponse(ResponseWrapper): - """https://join-lemmy.org/api/interfaces/GetPostsResponse.html""" +class CaptchaResponse(ResponseWrapper): + """https://join-lemmy.org/api/interfaces/CaptchaResponse.html""" - posts: list[PostView] = None - next_page: Optional[str] = None + png: str = None + wav: str = None + uuid: str = None def parse(self, data: dict[str, Any]): - self.posts = [PostView.parse(e0) for e0 in data["posts"]] - self.next_page = data["next_page"] if "next_page" in data else None + self.png = data["png"] + self.wav = data["wav"] + self.uuid = data["uuid"] @classmethod def data( cls, - posts: list[PostView] = None, - next_page: Optional[str] = None + png: str = None, + wav: str = None, + uuid: str = None ): obj = cls.__new__(cls) - obj.posts = posts - obj.next_page = next_page + obj.png = png + obj.wav = wav + obj.uuid = uuid return obj -class CommunityResponse(ResponseWrapper): - """https://join-lemmy.org/api/interfaces/CommunityResponse.html""" +class LoginResponse(ResponseWrapper): + """https://join-lemmy.org/api/interfaces/LoginResponse.html""" - community_view: CommunityView = None - discussion_languages: list[int] = None + jwt: Optional[str] = None + registration_created: bool = None + verify_email_sent: bool = None def parse(self, data: dict[str, Any]): - self.community_view = CommunityView.parse(data["community_view"]) - self.discussion_languages = [e0 for e0 in data["discussion_languages"]] + self.jwt = data["jwt"] if "jwt" in data else None + self.registration_created = data["registration_created"] + self.verify_email_sent = data["verify_email_sent"] @classmethod def data( cls, - community_view: CommunityView = None, - discussion_languages: list[int] = None + jwt: Optional[str] = None, + registration_created: bool = None, + verify_email_sent: bool = None ): obj = cls.__new__(cls) - obj.community_view = community_view - obj.discussion_languages = discussion_languages + obj.jwt = jwt + obj.registration_created = registration_created + obj.verify_email_sent = verify_email_sent return obj -class GetCommentsResponse(ResponseWrapper): - """https://join-lemmy.org/api/interfaces/GetCommentsResponse.html""" +class GenerateTotpSecretResponse(ResponseWrapper): + """https://join-lemmy.org/api/interfaces/GenerateTotpSecretResponse.html""" - comments: list[CommentView] = None + totp_secret_url: str = None def parse(self, data: dict[str, Any]): - self.comments = [CommentView.parse(e0) for e0 in data["comments"]] + self.totp_secret_url = data["totp_secret_url"] @classmethod def data( cls, - comments: list[CommentView] = None + totp_secret_url: str = None ): obj = cls.__new__(cls) - obj.comments = comments + obj.totp_secret_url = totp_secret_url return obj -class SearchResponse(ResponseWrapper): - """https://join-lemmy.org/api/interfaces/SearchResponse.html""" +class GetUnreadRegistrationApplicationCountResponse(ResponseWrapper): + """https://join-lemmy.org/api/interfaces/GetUnreadRegistrationApplicationCountResponse.html""" - type_: str = None - comments: list[CommentView] = None - posts: list[PostView] = None - communities: list[CommunityView] = None - users: list[PersonView] = None + registration_applications: int = None def parse(self, data: dict[str, Any]): - self.type_ = data["type_"] - self.comments = [CommentView.parse(e0) for e0 in data["comments"]] - self.posts = [PostView.parse(e0) for e0 in data["posts"]] - self.communities = [CommunityView.parse(e0) for e0 in data["communities"]] - self.users = [PersonView.parse(e0) for e0 in data["users"]] + self.registration_applications = data["registration_applications"] @classmethod def data( cls, - type_: str = None, - comments: list[CommentView] = None, - posts: list[PostView] = None, - communities: list[CommunityView] = None, - users: list[PersonView] = None + registration_applications: int = None ): obj = cls.__new__(cls) - obj.type_ = type_ - obj.comments = comments - obj.posts = posts - obj.communities = communities - obj.users = users + obj.registration_applications = registration_applications return obj -class GetCommunityPendingFollowsCountResponse(ResponseWrapper): - """https://join-lemmy.org/api/interfaces/GetCommunityPendingFollowsCountResponse.html""" +class ListCommunityPendingFollowsResponse(ResponseWrapper): + """https://join-lemmy.org/api/interfaces/ListCommunityPendingFollowsResponse.html""" - count: int = None + items: list[PendingFollow] = None def parse(self, data: dict[str, Any]): - self.count = data["count"] + self.items = [PendingFollow.parse(e0) for e0 in data["items"]] @classmethod def data( cls, - count: int = None + items: list[PendingFollow] = None ): obj = cls.__new__(cls) - obj.count = count + obj.items = items return obj -class PrivateMessageResponse(ResponseWrapper): - """https://join-lemmy.org/api/interfaces/PrivateMessageResponse.html""" +class BanPersonResponse(ResponseWrapper): + """https://join-lemmy.org/api/interfaces/BanPersonResponse.html""" - private_message_view: PrivateMessageView = None + person_view: PersonView = None + banned: bool = None def parse(self, data: dict[str, Any]): - self.private_message_view = PrivateMessageView.parse(data["private_message_view"]) + self.person_view = PersonView.parse(data["person_view"]) + self.banned = data["banned"] @classmethod def data( cls, - private_message_view: PrivateMessageView = None + person_view: PersonView = None, + banned: bool = None ): obj = cls.__new__(cls) - obj.private_message_view = private_message_view + obj.person_view = person_view + obj.banned = banned return obj -class AddModToCommunityResponse(ResponseWrapper): - """https://join-lemmy.org/api/interfaces/AddModToCommunityResponse.html""" +class ListCommentLikesResponse(ResponseWrapper): + """https://join-lemmy.org/api/interfaces/ListCommentLikesResponse.html""" - moderators: list[CommunityModeratorView] = None + comment_likes: list[VoteView] = None def parse(self, data: dict[str, Any]): - self.moderators = [CommunityModeratorView.parse(e0) for e0 in data["moderators"]] + self.comment_likes = [VoteView.parse(e0) for e0 in data["comment_likes"]] @classmethod def data( cls, - moderators: list[CommunityModeratorView] = None + comment_likes: list[VoteView] = None ): obj = cls.__new__(cls) - obj.moderators = moderators + obj.comment_likes = comment_likes return obj -class GetReportCountResponse(ResponseWrapper): - """https://join-lemmy.org/api/interfaces/GetReportCountResponse.html""" +class BannedPersonsResponse(ResponseWrapper): + """https://join-lemmy.org/api/interfaces/BannedPersonsResponse.html""" - community_id: Optional[int] = None - comment_reports: int = None - post_reports: int = None - private_message_reports: Optional[int] = None + banned: list[PersonView] = None def parse(self, data: dict[str, Any]): - self.community_id = data["community_id"] if "community_id" in data else None - self.comment_reports = data["comment_reports"] - self.post_reports = data["post_reports"] - self.private_message_reports = data["private_message_reports"] if "private_message_reports" in data else None + self.banned = [PersonView.parse(e0) for e0 in data["banned"]] @classmethod def data( cls, - community_id: Optional[int] = None, - comment_reports: int = None, - post_reports: int = None, - private_message_reports: Optional[int] = None + banned: list[PersonView] = None ): obj = cls.__new__(cls) - obj.community_id = community_id - obj.comment_reports = comment_reports - obj.post_reports = post_reports - obj.private_message_reports = private_message_reports + obj.banned = banned + return obj + + +class CommentReportResponse(ResponseWrapper): + """https://join-lemmy.org/api/interfaces/CommentReportResponse.html""" + + comment_report_view: CommentReportView = None + + def parse(self, data: dict[str, Any]): + self.comment_report_view = CommentReportView.parse(data["comment_report_view"]) + + @classmethod + def data( + cls, + comment_report_view: CommentReportView = None + ): + obj = cls.__new__(cls) + obj.comment_report_view = comment_report_view return obj @@ -333,93 +335,75 @@ def data( return obj -class PostReportResponse(ResponseWrapper): - """https://join-lemmy.org/api/interfaces/PostReportResponse.html""" +class PersonMentionResponse(ResponseWrapper): + """https://join-lemmy.org/api/interfaces/PersonMentionResponse.html""" - post_report_view: PostReportView = None + person_mention_view: PersonMentionView = None def parse(self, data: dict[str, Any]): - self.post_report_view = PostReportView.parse(data["post_report_view"]) + self.person_mention_view = PersonMentionView.parse(data["person_mention_view"]) @classmethod def data( cls, - post_report_view: PostReportView = None + person_mention_view: PersonMentionView = None ): obj = cls.__new__(cls) - obj.post_report_view = post_report_view + obj.person_mention_view = person_mention_view return obj -class RegistrationApplicationResponse(ResponseWrapper): - """https://join-lemmy.org/api/interfaces/RegistrationApplicationResponse.html""" +class ListPostLikesResponse(ResponseWrapper): + """https://join-lemmy.org/api/interfaces/ListPostLikesResponse.html""" - registration_application: RegistrationApplicationView = None + post_likes: list[VoteView] = None def parse(self, data: dict[str, Any]): - self.registration_application = RegistrationApplicationView.parse(data["registration_application"]) + self.post_likes = [VoteView.parse(e0) for e0 in data["post_likes"]] @classmethod def data( cls, - registration_application: RegistrationApplicationView = None + post_likes: list[VoteView] = None ): obj = cls.__new__(cls) - obj.registration_application = registration_application + obj.post_likes = post_likes return obj -class GetSiteResponse(ResponseWrapper): - """https://join-lemmy.org/api/interfaces/GetSiteResponse.html""" +class GetRepliesResponse(ResponseWrapper): + """https://join-lemmy.org/api/interfaces/GetRepliesResponse.html""" - site_view: SiteView = None - admins: list[PersonView] = None - version: str = None - my_user: Optional[MyUserInfo] = None - all_languages: list[Language] = None - discussion_languages: list[int] = None - tagline: Optional[Tagline] = None - oauth_providers: Optional[list[PublicOAuthProvider]] = None - admin_oauth_providers: Optional[list[OAuthProvider]] = None - blocked_urls: list[LocalSiteUrlBlocklist] = None + replies: list[CommentReplyView] = None def parse(self, data: dict[str, Any]): - self.site_view = SiteView.parse(data["site_view"]) - self.admins = [PersonView.parse(e0) for e0 in data["admins"]] - self.version = data["version"] - self.my_user = MyUserInfo.parse(data["my_user"]) if "my_user" in data else None - self.all_languages = [Language.parse(e0) for e0 in data["all_languages"]] - self.discussion_languages = [e0 for e0 in data["discussion_languages"]] - self.tagline = Tagline.parse(data["tagline"]) if "tagline" in data else None - self.oauth_providers = [PublicOAuthProvider.parse(e0) for e0 in data["oauth_providers"]] if "oauth_providers" in data else None - self.admin_oauth_providers = [OAuthProvider.parse(e0) for e0 in data["admin_oauth_providers"]] if "admin_oauth_providers" in data else None - self.blocked_urls = [LocalSiteUrlBlocklist.parse(e0) for e0 in data["blocked_urls"]] + self.replies = [CommentReplyView.parse(e0) for e0 in data["replies"]] @classmethod def data( cls, - site_view: SiteView = None, - admins: list[PersonView] = None, - version: str = None, - my_user: Optional[MyUserInfo] = None, - all_languages: list[Language] = None, - discussion_languages: list[int] = None, - tagline: Optional[Tagline] = None, - oauth_providers: Optional[list[PublicOAuthProvider]] = None, - admin_oauth_providers: Optional[list[OAuthProvider]] = None, - blocked_urls: list[LocalSiteUrlBlocklist] = None + replies: list[CommentReplyView] = None ): obj = cls.__new__(cls) - obj.site_view = site_view - obj.admins = admins - obj.version = version - obj.my_user = my_user - obj.all_languages = all_languages - obj.discussion_languages = discussion_languages - obj.tagline = tagline - obj.oauth_providers = oauth_providers - obj.admin_oauth_providers = admin_oauth_providers - obj.blocked_urls = blocked_urls + obj.replies = replies + return obj + + +class ListPrivateMessageReportsResponse(ResponseWrapper): + """https://join-lemmy.org/api/interfaces/ListPrivateMessageReportsResponse.html""" + + private_message_reports: list[PrivateMessageReportView] = None + + def parse(self, data: dict[str, Any]): + self.private_message_reports = [PrivateMessageReportView.parse(e0) for e0 in data["private_message_reports"]] + + @classmethod + def data( + cls, + private_message_reports: list[PrivateMessageReportView] = None + ): + obj = cls.__new__(cls) + obj.private_message_reports = private_message_reports return obj @@ -441,817 +425,833 @@ def data( return obj -class PersonMentionResponse(ResponseWrapper): - """https://join-lemmy.org/api/interfaces/PersonMentionResponse.html""" +class RegistrationApplicationResponse(ResponseWrapper): + """https://join-lemmy.org/api/interfaces/RegistrationApplicationResponse.html""" - person_mention_view: PersonMentionView = None + registration_application: RegistrationApplicationView = None def parse(self, data: dict[str, Any]): - self.person_mention_view = PersonMentionView.parse(data["person_mention_view"]) + self.registration_application = RegistrationApplicationView.parse(data["registration_application"]) @classmethod def data( cls, - person_mention_view: PersonMentionView = None + registration_application: RegistrationApplicationView = None ): obj = cls.__new__(cls) - obj.person_mention_view = person_mention_view + obj.registration_application = registration_application return obj -class ListLoginsResponse(ResponseWrapper): - """https://join-lemmy.org/api/interfaces/ListLoginsResponse.html""" +class GetSiteMetadataResponse(ResponseWrapper): + """https://join-lemmy.org/api/interfaces/GetSiteMetadataResponse.html""" - logins: list[LoginToken] = None + metadata: LinkMetadata = None def parse(self, data: dict[str, Any]): - self.logins = [LoginToken.parse(e0) for e0 in data["logins"]] + self.metadata = LinkMetadata.parse(data["metadata"]) @classmethod def data( cls, - logins: list[LoginToken] = None + metadata: LinkMetadata = None ): obj = cls.__new__(cls) - obj.logins = logins + obj.metadata = metadata return obj -class GetModlogResponse(ResponseWrapper): - """https://join-lemmy.org/api/interfaces/GetModlogResponse.html""" +class GetPostResponse(ResponseWrapper): + """https://join-lemmy.org/api/interfaces/GetPostResponse.html""" - removed_posts: list[ModRemovePostView] = None - locked_posts: list[ModLockPostView] = None - featured_posts: list[ModFeaturePostView] = None - removed_comments: list[ModRemoveCommentView] = None - removed_communities: list[ModRemoveCommunityView] = None - banned_from_community: list[ModBanFromCommunityView] = None - banned: list[ModBanView] = None - added_to_community: list[ModAddCommunityView] = None - transferred_to_community: list[ModTransferCommunityView] = None - added: list[ModAddView] = None - admin_purged_persons: list[AdminPurgePersonView] = None - admin_purged_communities: list[AdminPurgeCommunityView] = None - admin_purged_posts: list[AdminPurgePostView] = None - admin_purged_comments: list[AdminPurgeCommentView] = None - hidden_communities: list[ModHideCommunityView] = None + post_view: PostView = None + community_view: CommunityView = None + moderators: list[CommunityModeratorView] = None + cross_posts: list[PostView] = None def parse(self, data: dict[str, Any]): - self.removed_posts = [ModRemovePostView.parse(e0) for e0 in data["removed_posts"]] - self.locked_posts = [ModLockPostView.parse(e0) for e0 in data["locked_posts"]] - self.featured_posts = [ModFeaturePostView.parse(e0) for e0 in data["featured_posts"]] - self.removed_comments = [ModRemoveCommentView.parse(e0) for e0 in data["removed_comments"]] - self.removed_communities = [ModRemoveCommunityView.parse(e0) for e0 in data["removed_communities"]] - self.banned_from_community = [ModBanFromCommunityView.parse(e0) for e0 in data["banned_from_community"]] - self.banned = [ModBanView.parse(e0) for e0 in data["banned"]] - self.added_to_community = [ModAddCommunityView.parse(e0) for e0 in data["added_to_community"]] - self.transferred_to_community = [ModTransferCommunityView.parse(e0) for e0 in data["transferred_to_community"]] - self.added = [ModAddView.parse(e0) for e0 in data["added"]] - self.admin_purged_persons = [AdminPurgePersonView.parse(e0) for e0 in data["admin_purged_persons"]] - self.admin_purged_communities = [AdminPurgeCommunityView.parse(e0) for e0 in data["admin_purged_communities"]] - self.admin_purged_posts = [AdminPurgePostView.parse(e0) for e0 in data["admin_purged_posts"]] - self.admin_purged_comments = [AdminPurgeCommentView.parse(e0) for e0 in data["admin_purged_comments"]] - self.hidden_communities = [ModHideCommunityView.parse(e0) for e0 in data["hidden_communities"]] + self.post_view = PostView.parse(data["post_view"]) + self.community_view = CommunityView.parse(data["community_view"]) + self.moderators = [CommunityModeratorView.parse(e0) for e0 in data["moderators"]] + self.cross_posts = [PostView.parse(e0) for e0 in data["cross_posts"]] @classmethod def data( cls, - removed_posts: list[ModRemovePostView] = None, - locked_posts: list[ModLockPostView] = None, - featured_posts: list[ModFeaturePostView] = None, - removed_comments: list[ModRemoveCommentView] = None, - removed_communities: list[ModRemoveCommunityView] = None, - banned_from_community: list[ModBanFromCommunityView] = None, - banned: list[ModBanView] = None, - added_to_community: list[ModAddCommunityView] = None, - transferred_to_community: list[ModTransferCommunityView] = None, - added: list[ModAddView] = None, - admin_purged_persons: list[AdminPurgePersonView] = None, - admin_purged_communities: list[AdminPurgeCommunityView] = None, - admin_purged_posts: list[AdminPurgePostView] = None, - admin_purged_comments: list[AdminPurgeCommentView] = None, - hidden_communities: list[ModHideCommunityView] = None + post_view: PostView = None, + community_view: CommunityView = None, + moderators: list[CommunityModeratorView] = None, + cross_posts: list[PostView] = None ): obj = cls.__new__(cls) - obj.removed_posts = removed_posts - obj.locked_posts = locked_posts - obj.featured_posts = featured_posts - obj.removed_comments = removed_comments - obj.removed_communities = removed_communities - obj.banned_from_community = banned_from_community - obj.banned = banned - obj.added_to_community = added_to_community - obj.transferred_to_community = transferred_to_community - obj.added = added - obj.admin_purged_persons = admin_purged_persons - obj.admin_purged_communities = admin_purged_communities - obj.admin_purged_posts = admin_purged_posts - obj.admin_purged_comments = admin_purged_comments - obj.hidden_communities = hidden_communities + obj.post_view = post_view + obj.community_view = community_view + obj.moderators = moderators + obj.cross_posts = cross_posts return obj -class SuccessResponse(ResponseWrapper): - """https://join-lemmy.org/api/interfaces/SuccessResponse.html""" +class TaglineResponse(ResponseWrapper): + """https://join-lemmy.org/api/interfaces/TaglineResponse.html""" - success: bool = None + tagline: Tagline = None def parse(self, data: dict[str, Any]): - self.success = data["success"] + self.tagline = Tagline.parse(data["tagline"]) @classmethod def data( cls, - success: bool = None + tagline: Tagline = None ): obj = cls.__new__(cls) - obj.success = success + obj.tagline = tagline return obj -class ListRegistrationApplicationsResponse(ResponseWrapper): - """https://join-lemmy.org/api/interfaces/ListRegistrationApplicationsResponse.html""" +class PostReportResponse(ResponseWrapper): + """https://join-lemmy.org/api/interfaces/PostReportResponse.html""" - registration_applications: list[RegistrationApplicationView] = None + post_report_view: PostReportView = None def parse(self, data: dict[str, Any]): - self.registration_applications = [RegistrationApplicationView.parse(e0) for e0 in data["registration_applications"]] + self.post_report_view = PostReportView.parse(data["post_report_view"]) @classmethod def data( cls, - registration_applications: list[RegistrationApplicationView] = None + post_report_view: PostReportView = None ): obj = cls.__new__(cls) - obj.registration_applications = registration_applications + obj.post_report_view = post_report_view return obj -class BlockInstanceResponse(ResponseWrapper): - """https://join-lemmy.org/api/interfaces/BlockInstanceResponse.html""" +class GetFederatedInstancesResponse(ResponseWrapper): + """https://join-lemmy.org/api/interfaces/GetFederatedInstancesResponse.html""" - blocked: bool = None + federated_instances: Optional[FederatedInstances] = None def parse(self, data: dict[str, Any]): - self.blocked = data["blocked"] + self.federated_instances = FederatedInstances.parse(data["federated_instances"]) if "federated_instances" in data else None @classmethod def data( cls, - blocked: bool = None + federated_instances: Optional[FederatedInstances] = None ): obj = cls.__new__(cls) - obj.blocked = blocked + obj.federated_instances = federated_instances return obj -class ResolveObjectResponse(ResponseWrapper): - """https://join-lemmy.org/api/interfaces/ResolveObjectResponse.html""" - - comment: Optional[CommentView] = None - post: Optional[PostView] = None - community: Optional[CommunityView] = None - person: Optional[PersonView] = None - - def parse(self, data: dict[str, Any]): - self.comment = CommentView.parse(data["comment"]) if "comment" in data else None - self.post = PostView.parse(data["post"]) if "post" in data else None - self.community = CommunityView.parse(data["community"]) if "community" in data else None - self.person = PersonView.parse(data["person"]) if "person" in data else None - - @classmethod - def data( - cls, - comment: Optional[CommentView] = None, - post: Optional[PostView] = None, - community: Optional[CommunityView] = None, - person: Optional[PersonView] = None - ): - obj = cls.__new__(cls) - obj.comment = comment - obj.post = post - obj.community = community - obj.person = person - return obj - - -class PrivateMessageReportResponse(ResponseWrapper): - """https://join-lemmy.org/api/interfaces/PrivateMessageReportResponse.html""" +class ListCommunitiesResponse(ResponseWrapper): + """https://join-lemmy.org/api/interfaces/ListCommunitiesResponse.html""" - private_message_report_view: PrivateMessageReportView = None + communities: list[CommunityView] = None def parse(self, data: dict[str, Any]): - self.private_message_report_view = PrivateMessageReportView.parse(data["private_message_report_view"]) + self.communities = [CommunityView.parse(e0) for e0 in data["communities"]] @classmethod def data( cls, - private_message_report_view: PrivateMessageReportView = None + communities: list[CommunityView] = None ): obj = cls.__new__(cls) - obj.private_message_report_view = private_message_report_view + obj.communities = communities return obj -class SiteResponse(ResponseWrapper): - """https://join-lemmy.org/api/interfaces/SiteResponse.html""" +class GetSiteResponse(ResponseWrapper): + """https://join-lemmy.org/api/interfaces/GetSiteResponse.html""" site_view: SiteView = None + admins: list[PersonView] = None + version: str = None + my_user: Optional[MyUserInfo] = None + all_languages: list[Language] = None + discussion_languages: list[int] = None + tagline: Optional[Tagline] = None + oauth_providers: Optional[list[PublicOAuthProvider]] = None + admin_oauth_providers: Optional[list[OAuthProvider]] = None + blocked_urls: list[LocalSiteUrlBlocklist] = None def parse(self, data: dict[str, Any]): self.site_view = SiteView.parse(data["site_view"]) + self.admins = [PersonView.parse(e0) for e0 in data["admins"]] + self.version = data["version"] + self.my_user = MyUserInfo.parse(data["my_user"]) if "my_user" in data else None + self.all_languages = [Language.parse(e0) for e0 in data["all_languages"]] + self.discussion_languages = [e0 for e0 in data["discussion_languages"]] + self.tagline = Tagline.parse(data["tagline"]) if "tagline" in data else None + self.oauth_providers = [PublicOAuthProvider.parse(e0) for e0 in data["oauth_providers"]] if "oauth_providers" in data else None + self.admin_oauth_providers = [OAuthProvider.parse(e0) for e0 in data["admin_oauth_providers"]] if "admin_oauth_providers" in data else None + self.blocked_urls = [LocalSiteUrlBlocklist.parse(e0) for e0 in data["blocked_urls"]] @classmethod def data( cls, - site_view: SiteView = None + site_view: SiteView = None, + admins: list[PersonView] = None, + version: str = None, + my_user: Optional[MyUserInfo] = None, + all_languages: list[Language] = None, + discussion_languages: list[int] = None, + tagline: Optional[Tagline] = None, + oauth_providers: Optional[list[PublicOAuthProvider]] = None, + admin_oauth_providers: Optional[list[OAuthProvider]] = None, + blocked_urls: list[LocalSiteUrlBlocklist] = None ): obj = cls.__new__(cls) obj.site_view = site_view + obj.admins = admins + obj.version = version + obj.my_user = my_user + obj.all_languages = all_languages + obj.discussion_languages = discussion_languages + obj.tagline = tagline + obj.oauth_providers = oauth_providers + obj.admin_oauth_providers = admin_oauth_providers + obj.blocked_urls = blocked_urls return obj -class ListPostReportsResponse(ResponseWrapper): - """https://join-lemmy.org/api/interfaces/ListPostReportsResponse.html""" - - post_reports: list[PostReportView] = None - - def parse(self, data: dict[str, Any]): - self.post_reports = [PostReportView.parse(e0) for e0 in data["post_reports"]] - - @classmethod - def data( - cls, - post_reports: list[PostReportView] = None - ): - obj = cls.__new__(cls) - obj.post_reports = post_reports - return obj - - -class BlockCommunityResponse(ResponseWrapper): - """https://join-lemmy.org/api/interfaces/BlockCommunityResponse.html""" +class GetModlogResponse(ResponseWrapper): + """https://join-lemmy.org/api/interfaces/GetModlogResponse.html""" - community_view: CommunityView = None - blocked: bool = None + removed_posts: list[ModRemovePostView] = None + locked_posts: list[ModLockPostView] = None + featured_posts: list[ModFeaturePostView] = None + removed_comments: list[ModRemoveCommentView] = None + removed_communities: list[ModRemoveCommunityView] = None + banned_from_community: list[ModBanFromCommunityView] = None + banned: list[ModBanView] = None + added_to_community: list[ModAddCommunityView] = None + transferred_to_community: list[ModTransferCommunityView] = None + added: list[ModAddView] = None + admin_purged_persons: list[AdminPurgePersonView] = None + admin_purged_communities: list[AdminPurgeCommunityView] = None + admin_purged_posts: list[AdminPurgePostView] = None + admin_purged_comments: list[AdminPurgeCommentView] = None + hidden_communities: list[ModHideCommunityView] = None def parse(self, data: dict[str, Any]): - self.community_view = CommunityView.parse(data["community_view"]) - self.blocked = data["blocked"] + self.removed_posts = [ModRemovePostView.parse(e0) for e0 in data["removed_posts"]] + self.locked_posts = [ModLockPostView.parse(e0) for e0 in data["locked_posts"]] + self.featured_posts = [ModFeaturePostView.parse(e0) for e0 in data["featured_posts"]] + self.removed_comments = [ModRemoveCommentView.parse(e0) for e0 in data["removed_comments"]] + self.removed_communities = [ModRemoveCommunityView.parse(e0) for e0 in data["removed_communities"]] + self.banned_from_community = [ModBanFromCommunityView.parse(e0) for e0 in data["banned_from_community"]] + self.banned = [ModBanView.parse(e0) for e0 in data["banned"]] + self.added_to_community = [ModAddCommunityView.parse(e0) for e0 in data["added_to_community"]] + self.transferred_to_community = [ModTransferCommunityView.parse(e0) for e0 in data["transferred_to_community"]] + self.added = [ModAddView.parse(e0) for e0 in data["added"]] + self.admin_purged_persons = [AdminPurgePersonView.parse(e0) for e0 in data["admin_purged_persons"]] + self.admin_purged_communities = [AdminPurgeCommunityView.parse(e0) for e0 in data["admin_purged_communities"]] + self.admin_purged_posts = [AdminPurgePostView.parse(e0) for e0 in data["admin_purged_posts"]] + self.admin_purged_comments = [AdminPurgeCommentView.parse(e0) for e0 in data["admin_purged_comments"]] + self.hidden_communities = [ModHideCommunityView.parse(e0) for e0 in data["hidden_communities"]] @classmethod def data( cls, - community_view: CommunityView = None, - blocked: bool = None + removed_posts: list[ModRemovePostView] = None, + locked_posts: list[ModLockPostView] = None, + featured_posts: list[ModFeaturePostView] = None, + removed_comments: list[ModRemoveCommentView] = None, + removed_communities: list[ModRemoveCommunityView] = None, + banned_from_community: list[ModBanFromCommunityView] = None, + banned: list[ModBanView] = None, + added_to_community: list[ModAddCommunityView] = None, + transferred_to_community: list[ModTransferCommunityView] = None, + added: list[ModAddView] = None, + admin_purged_persons: list[AdminPurgePersonView] = None, + admin_purged_communities: list[AdminPurgeCommunityView] = None, + admin_purged_posts: list[AdminPurgePostView] = None, + admin_purged_comments: list[AdminPurgeCommentView] = None, + hidden_communities: list[ModHideCommunityView] = None ): obj = cls.__new__(cls) - obj.community_view = community_view - obj.blocked = blocked + obj.removed_posts = removed_posts + obj.locked_posts = locked_posts + obj.featured_posts = featured_posts + obj.removed_comments = removed_comments + obj.removed_communities = removed_communities + obj.banned_from_community = banned_from_community + obj.banned = banned + obj.added_to_community = added_to_community + obj.transferred_to_community = transferred_to_community + obj.added = added + obj.admin_purged_persons = admin_purged_persons + obj.admin_purged_communities = admin_purged_communities + obj.admin_purged_posts = admin_purged_posts + obj.admin_purged_comments = admin_purged_comments + obj.hidden_communities = hidden_communities return obj -class PrivateMessagesResponse(ResponseWrapper): - """https://join-lemmy.org/api/interfaces/PrivateMessagesResponse.html""" +class SearchResponse(ResponseWrapper): + """https://join-lemmy.org/api/interfaces/SearchResponse.html""" - private_messages: list[PrivateMessageView] = None + type_: str = None + comments: list[CommentView] = None + posts: list[PostView] = None + communities: list[CommunityView] = None + users: list[PersonView] = None def parse(self, data: dict[str, Any]): - self.private_messages = [PrivateMessageView.parse(e0) for e0 in data["private_messages"]] + self.type_ = data["type_"] + self.comments = [CommentView.parse(e0) for e0 in data["comments"]] + self.posts = [PostView.parse(e0) for e0 in data["posts"]] + self.communities = [CommunityView.parse(e0) for e0 in data["communities"]] + self.users = [PersonView.parse(e0) for e0 in data["users"]] @classmethod def data( cls, - private_messages: list[PrivateMessageView] = None + type_: str = None, + comments: list[CommentView] = None, + posts: list[PostView] = None, + communities: list[CommunityView] = None, + users: list[PersonView] = None ): obj = cls.__new__(cls) - obj.private_messages = private_messages + obj.type_ = type_ + obj.comments = comments + obj.posts = posts + obj.communities = communities + obj.users = users return obj -class ListCommunityPendingFollowsResponse(ResponseWrapper): - """https://join-lemmy.org/api/interfaces/ListCommunityPendingFollowsResponse.html""" +class ListMediaResponse(ResponseWrapper): + """https://join-lemmy.org/api/interfaces/ListMediaResponse.html""" - items: list[PendingFollow] = None + images: list[LocalImageView] = None def parse(self, data: dict[str, Any]): - self.items = [PendingFollow.parse(e0) for e0 in data["items"]] + self.images = [LocalImageView.parse(e0) for e0 in data["images"]] @classmethod def data( cls, - items: list[PendingFollow] = None + images: list[LocalImageView] = None ): obj = cls.__new__(cls) - obj.items = items + obj.images = images return obj -class LoginResponse(ResponseWrapper): - """https://join-lemmy.org/api/interfaces/LoginResponse.html""" +class CustomEmojiResponse(ResponseWrapper): + """https://join-lemmy.org/api/interfaces/CustomEmojiResponse.html""" - jwt: Optional[str] = None - registration_created: bool = None - verify_email_sent: bool = None + custom_emoji: CustomEmojiView = None def parse(self, data: dict[str, Any]): - self.jwt = data["jwt"] if "jwt" in data else None - self.registration_created = data["registration_created"] - self.verify_email_sent = data["verify_email_sent"] + self.custom_emoji = CustomEmojiView.parse(data["custom_emoji"]) @classmethod def data( cls, - jwt: Optional[str] = None, - registration_created: bool = None, - verify_email_sent: bool = None + custom_emoji: CustomEmojiView = None ): obj = cls.__new__(cls) - obj.jwt = jwt - obj.registration_created = registration_created - obj.verify_email_sent = verify_email_sent + obj.custom_emoji = custom_emoji return obj -class GetUnreadCountResponse(ResponseWrapper): - """https://join-lemmy.org/api/interfaces/GetUnreadCountResponse.html""" +class GetPersonDetailsResponse(ResponseWrapper): + """https://join-lemmy.org/api/interfaces/GetPersonDetailsResponse.html""" - replies: int = None - mentions: int = None - private_messages: int = None + person_view: PersonView = None + site: Optional[Site] = None + comments: list[CommentView] = None + posts: list[PostView] = None + moderates: list[CommunityModeratorView] = None def parse(self, data: dict[str, Any]): - self.replies = data["replies"] - self.mentions = data["mentions"] - self.private_messages = data["private_messages"] + self.person_view = PersonView.parse(data["person_view"]) + self.site = Site.parse(data["site"]) if "site" in data else None + self.comments = [CommentView.parse(e0) for e0 in data["comments"]] + self.posts = [PostView.parse(e0) for e0 in data["posts"]] + self.moderates = [CommunityModeratorView.parse(e0) for e0 in data["moderates"]] @classmethod def data( cls, - replies: int = None, - mentions: int = None, - private_messages: int = None + person_view: PersonView = None, + site: Optional[Site] = None, + comments: list[CommentView] = None, + posts: list[PostView] = None, + moderates: list[CommunityModeratorView] = None ): obj = cls.__new__(cls) - obj.replies = replies - obj.mentions = mentions - obj.private_messages = private_messages + obj.person_view = person_view + obj.site = site + obj.comments = comments + obj.posts = posts + obj.moderates = moderates return obj -class BanFromCommunityResponse(ResponseWrapper): - """https://join-lemmy.org/api/interfaces/BanFromCommunityResponse.html""" +class GetCommentsResponse(ResponseWrapper): + """https://join-lemmy.org/api/interfaces/GetCommentsResponse.html""" - person_view: PersonView = None - banned: bool = None + comments: list[CommentView] = None def parse(self, data: dict[str, Any]): - self.person_view = PersonView.parse(data["person_view"]) - self.banned = data["banned"] + self.comments = [CommentView.parse(e0) for e0 in data["comments"]] @classmethod def data( cls, - person_view: PersonView = None, - banned: bool = None + comments: list[CommentView] = None ): obj = cls.__new__(cls) - obj.person_view = person_view - obj.banned = banned + obj.comments = comments return obj -class CommentReplyResponse(ResponseWrapper): - """https://join-lemmy.org/api/interfaces/CommentReplyResponse.html""" +class GetPersonMentionsResponse(ResponseWrapper): + """https://join-lemmy.org/api/interfaces/GetPersonMentionsResponse.html""" - comment_reply_view: CommentReplyView = None + mentions: list[PersonMentionView] = None def parse(self, data: dict[str, Any]): - self.comment_reply_view = CommentReplyView.parse(data["comment_reply_view"]) + self.mentions = [PersonMentionView.parse(e0) for e0 in data["mentions"]] @classmethod def data( cls, - comment_reply_view: CommentReplyView = None + mentions: list[PersonMentionView] = None ): obj = cls.__new__(cls) - obj.comment_reply_view = comment_reply_view + obj.mentions = mentions return obj -class ListPostLikesResponse(ResponseWrapper): - """https://join-lemmy.org/api/interfaces/ListPostLikesResponse.html""" +class AddAdminResponse(ResponseWrapper): + """https://join-lemmy.org/api/interfaces/AddAdminResponse.html""" - post_likes: list[VoteView] = None + admins: list[PersonView] = None def parse(self, data: dict[str, Any]): - self.post_likes = [VoteView.parse(e0) for e0 in data["post_likes"]] + self.admins = [PersonView.parse(e0) for e0 in data["admins"]] @classmethod def data( cls, - post_likes: list[VoteView] = None + admins: list[PersonView] = None ): obj = cls.__new__(cls) - obj.post_likes = post_likes + obj.admins = admins return obj -class ListCommentReportsResponse(ResponseWrapper): - """https://join-lemmy.org/api/interfaces/ListCommentReportsResponse.html""" +class ListRegistrationApplicationsResponse(ResponseWrapper): + """https://join-lemmy.org/api/interfaces/ListRegistrationApplicationsResponse.html""" - comment_reports: list[CommentReportView] = None + registration_applications: list[RegistrationApplicationView] = None def parse(self, data: dict[str, Any]): - self.comment_reports = [CommentReportView.parse(e0) for e0 in data["comment_reports"]] + self.registration_applications = [RegistrationApplicationView.parse(e0) for e0 in data["registration_applications"]] @classmethod def data( cls, - comment_reports: list[CommentReportView] = None + registration_applications: list[RegistrationApplicationView] = None ): obj = cls.__new__(cls) - obj.comment_reports = comment_reports + obj.registration_applications = registration_applications return obj -class GetSiteMetadataResponse(ResponseWrapper): - """https://join-lemmy.org/api/interfaces/GetSiteMetadataResponse.html""" +class CommunityResponse(ResponseWrapper): + """https://join-lemmy.org/api/interfaces/CommunityResponse.html""" - metadata: LinkMetadata = None + community_view: CommunityView = None + discussion_languages: list[int] = None def parse(self, data: dict[str, Any]): - self.metadata = LinkMetadata.parse(data["metadata"]) + self.community_view = CommunityView.parse(data["community_view"]) + self.discussion_languages = [e0 for e0 in data["discussion_languages"]] @classmethod def data( cls, - metadata: LinkMetadata = None + community_view: CommunityView = None, + discussion_languages: list[int] = None ): obj = cls.__new__(cls) - obj.metadata = metadata + obj.community_view = community_view + obj.discussion_languages = discussion_languages return obj -class TaglineResponse(ResponseWrapper): - """https://join-lemmy.org/api/interfaces/TaglineResponse.html""" +class SiteResponse(ResponseWrapper): + """https://join-lemmy.org/api/interfaces/SiteResponse.html""" - tagline: Tagline = None + site_view: SiteView = None def parse(self, data: dict[str, Any]): - self.tagline = Tagline.parse(data["tagline"]) + self.site_view = SiteView.parse(data["site_view"]) @classmethod def data( cls, - tagline: Tagline = None + site_view: SiteView = None ): obj = cls.__new__(cls) - obj.tagline = tagline + obj.site_view = site_view return obj -class BanPersonResponse(ResponseWrapper): - """https://join-lemmy.org/api/interfaces/BanPersonResponse.html""" +class CommentReplyResponse(ResponseWrapper): + """https://join-lemmy.org/api/interfaces/CommentReplyResponse.html""" - person_view: PersonView = None - banned: bool = None + comment_reply_view: CommentReplyView = None def parse(self, data: dict[str, Any]): - self.person_view = PersonView.parse(data["person_view"]) - self.banned = data["banned"] + self.comment_reply_view = CommentReplyView.parse(data["comment_reply_view"]) @classmethod def data( cls, - person_view: PersonView = None, - banned: bool = None + comment_reply_view: CommentReplyView = None ): obj = cls.__new__(cls) - obj.person_view = person_view - obj.banned = banned + obj.comment_reply_view = comment_reply_view return obj -class CommentResponse(ResponseWrapper): - """https://join-lemmy.org/api/interfaces/CommentResponse.html""" +class GetCommunityResponse(ResponseWrapper): + """https://join-lemmy.org/api/interfaces/GetCommunityResponse.html""" - comment_view: CommentView = None - recipient_ids: list[int] = None + community_view: CommunityView = None + site: Optional[Site] = None + moderators: list[CommunityModeratorView] = None + discussion_languages: list[int] = None def parse(self, data: dict[str, Any]): - self.comment_view = CommentView.parse(data["comment_view"]) - self.recipient_ids = [e0 for e0 in data["recipient_ids"]] + self.community_view = CommunityView.parse(data["community_view"]) + self.site = Site.parse(data["site"]) if "site" in data else None + self.moderators = [CommunityModeratorView.parse(e0) for e0 in data["moderators"]] + self.discussion_languages = [e0 for e0 in data["discussion_languages"]] @classmethod def data( cls, - comment_view: CommentView = None, - recipient_ids: list[int] = None + community_view: CommunityView = None, + site: Optional[Site] = None, + moderators: list[CommunityModeratorView] = None, + discussion_languages: list[int] = None ): obj = cls.__new__(cls) - obj.comment_view = comment_view - obj.recipient_ids = recipient_ids + obj.community_view = community_view + obj.site = site + obj.moderators = moderators + obj.discussion_languages = discussion_languages return obj -class GetRepliesResponse(ResponseWrapper): - """https://join-lemmy.org/api/interfaces/GetRepliesResponse.html""" +class PostResponse(ResponseWrapper): + """https://join-lemmy.org/api/interfaces/PostResponse.html""" - replies: list[CommentReplyView] = None + post_view: PostView = None def parse(self, data: dict[str, Any]): - self.replies = [CommentReplyView.parse(e0) for e0 in data["replies"]] + self.post_view = PostView.parse(data["post_view"]) @classmethod def data( cls, - replies: list[CommentReplyView] = None + post_view: PostView = None ): obj = cls.__new__(cls) - obj.replies = replies + obj.post_view = post_view return obj -class GetUnreadRegistrationApplicationCountResponse(ResponseWrapper): - """https://join-lemmy.org/api/interfaces/GetUnreadRegistrationApplicationCountResponse.html""" +class ListLoginsResponse(ResponseWrapper): + """https://join-lemmy.org/api/interfaces/ListLoginsResponse.html""" - registration_applications: int = None + logins: list[LoginToken] = None def parse(self, data: dict[str, Any]): - self.registration_applications = data["registration_applications"] + self.logins = [LoginToken.parse(e0) for e0 in data["logins"]] @classmethod def data( cls, - registration_applications: int = None + logins: list[LoginToken] = None ): obj = cls.__new__(cls) - obj.registration_applications = registration_applications + obj.logins = logins return obj -class CustomEmojiResponse(ResponseWrapper): - """https://join-lemmy.org/api/interfaces/CustomEmojiResponse.html""" +class PrivateMessagesResponse(ResponseWrapper): + """https://join-lemmy.org/api/interfaces/PrivateMessagesResponse.html""" - custom_emoji: CustomEmojiView = None + private_messages: list[PrivateMessageView] = None def parse(self, data: dict[str, Any]): - self.custom_emoji = CustomEmojiView.parse(data["custom_emoji"]) + self.private_messages = [PrivateMessageView.parse(e0) for e0 in data["private_messages"]] @classmethod def data( cls, - custom_emoji: CustomEmojiView = None + private_messages: list[PrivateMessageView] = None ): obj = cls.__new__(cls) - obj.custom_emoji = custom_emoji + obj.private_messages = private_messages return obj -class GetPersonDetailsResponse(ResponseWrapper): - """https://join-lemmy.org/api/interfaces/GetPersonDetailsResponse.html""" +class AddModToCommunityResponse(ResponseWrapper): + """https://join-lemmy.org/api/interfaces/AddModToCommunityResponse.html""" - person_view: PersonView = None - site: Optional[Site] = None - comments: list[CommentView] = None - posts: list[PostView] = None - moderates: list[CommunityModeratorView] = None + moderators: list[CommunityModeratorView] = None def parse(self, data: dict[str, Any]): - self.person_view = PersonView.parse(data["person_view"]) - self.site = Site.parse(data["site"]) if "site" in data else None - self.comments = [CommentView.parse(e0) for e0 in data["comments"]] - self.posts = [PostView.parse(e0) for e0 in data["posts"]] - self.moderates = [CommunityModeratorView.parse(e0) for e0 in data["moderates"]] + self.moderators = [CommunityModeratorView.parse(e0) for e0 in data["moderators"]] @classmethod def data( cls, - person_view: PersonView = None, - site: Optional[Site] = None, - comments: list[CommentView] = None, - posts: list[PostView] = None, - moderates: list[CommunityModeratorView] = None + moderators: list[CommunityModeratorView] = None ): obj = cls.__new__(cls) - obj.person_view = person_view - obj.site = site - obj.comments = comments - obj.posts = posts - obj.moderates = moderates + obj.moderators = moderators return obj -class ListCommunitiesResponse(ResponseWrapper): - """https://join-lemmy.org/api/interfaces/ListCommunitiesResponse.html""" +class ListPostReportsResponse(ResponseWrapper): + """https://join-lemmy.org/api/interfaces/ListPostReportsResponse.html""" - communities: list[CommunityView] = None + post_reports: list[PostReportView] = None def parse(self, data: dict[str, Any]): - self.communities = [CommunityView.parse(e0) for e0 in data["communities"]] + self.post_reports = [PostReportView.parse(e0) for e0 in data["post_reports"]] @classmethod def data( cls, - communities: list[CommunityView] = None + post_reports: list[PostReportView] = None ): obj = cls.__new__(cls) - obj.communities = communities + obj.post_reports = post_reports return obj -class GetPersonMentionsResponse(ResponseWrapper): - """https://join-lemmy.org/api/interfaces/GetPersonMentionsResponse.html""" +class ListCommentReportsResponse(ResponseWrapper): + """https://join-lemmy.org/api/interfaces/ListCommentReportsResponse.html""" - mentions: list[PersonMentionView] = None + comment_reports: list[CommentReportView] = None def parse(self, data: dict[str, Any]): - self.mentions = [PersonMentionView.parse(e0) for e0 in data["mentions"]] + self.comment_reports = [CommentReportView.parse(e0) for e0 in data["comment_reports"]] @classmethod def data( cls, - mentions: list[PersonMentionView] = None + comment_reports: list[CommentReportView] = None ): obj = cls.__new__(cls) - obj.mentions = mentions + obj.comment_reports = comment_reports return obj -class AddAdminResponse(ResponseWrapper): - """https://join-lemmy.org/api/interfaces/AddAdminResponse.html""" +class ResolveObjectResponse(ResponseWrapper): + """https://join-lemmy.org/api/interfaces/ResolveObjectResponse.html""" - admins: list[PersonView] = None + comment: Optional[CommentView] = None + post: Optional[PostView] = None + community: Optional[CommunityView] = None + person: Optional[PersonView] = None def parse(self, data: dict[str, Any]): - self.admins = [PersonView.parse(e0) for e0 in data["admins"]] + self.comment = CommentView.parse(data["comment"]) if "comment" in data else None + self.post = PostView.parse(data["post"]) if "post" in data else None + self.community = CommunityView.parse(data["community"]) if "community" in data else None + self.person = PersonView.parse(data["person"]) if "person" in data else None @classmethod def data( cls, - admins: list[PersonView] = None + comment: Optional[CommentView] = None, + post: Optional[PostView] = None, + community: Optional[CommunityView] = None, + person: Optional[PersonView] = None ): obj = cls.__new__(cls) - obj.admins = admins + obj.comment = comment + obj.post = post + obj.community = community + obj.person = person return obj -class GetFederatedInstancesResponse(ResponseWrapper): - """https://join-lemmy.org/api/interfaces/GetFederatedInstancesResponse.html""" +class ListCustomEmojisResponse(ResponseWrapper): + """https://join-lemmy.org/api/interfaces/ListCustomEmojisResponse.html""" - federated_instances: Optional[FederatedInstances] = None + custom_emojis: list[CustomEmojiView] = None def parse(self, data: dict[str, Any]): - self.federated_instances = FederatedInstances.parse(data["federated_instances"]) if "federated_instances" in data else None + self.custom_emojis = [CustomEmojiView.parse(e0) for e0 in data["custom_emojis"]] @classmethod def data( cls, - federated_instances: Optional[FederatedInstances] = None + custom_emojis: list[CustomEmojiView] = None ): obj = cls.__new__(cls) - obj.federated_instances = federated_instances + obj.custom_emojis = custom_emojis return obj -class PostResponse(ResponseWrapper): - """https://join-lemmy.org/api/interfaces/PostResponse.html""" +class CommentResponse(ResponseWrapper): + """https://join-lemmy.org/api/interfaces/CommentResponse.html""" - post_view: PostView = None + comment_view: CommentView = None + recipient_ids: list[int] = None def parse(self, data: dict[str, Any]): - self.post_view = PostView.parse(data["post_view"]) + self.comment_view = CommentView.parse(data["comment_view"]) + self.recipient_ids = [e0 for e0 in data["recipient_ids"]] @classmethod def data( cls, - post_view: PostView = None + comment_view: CommentView = None, + recipient_ids: list[int] = None ): obj = cls.__new__(cls) - obj.post_view = post_view + obj.comment_view = comment_view + obj.recipient_ids = recipient_ids return obj -class GenerateTotpSecretResponse(ResponseWrapper): - """https://join-lemmy.org/api/interfaces/GenerateTotpSecretResponse.html""" +class GetPostsResponse(ResponseWrapper): + """https://join-lemmy.org/api/interfaces/GetPostsResponse.html""" - totp_secret_url: str = None + posts: list[PostView] = None + next_page: Optional[str] = None def parse(self, data: dict[str, Any]): - self.totp_secret_url = data["totp_secret_url"] + self.posts = [PostView.parse(e0) for e0 in data["posts"]] + self.next_page = data["next_page"] if "next_page" in data else None @classmethod def data( cls, - totp_secret_url: str = None + posts: list[PostView] = None, + next_page: Optional[str] = None ): obj = cls.__new__(cls) - obj.totp_secret_url = totp_secret_url + obj.posts = posts + obj.next_page = next_page return obj -class ListPrivateMessageReportsResponse(ResponseWrapper): - """https://join-lemmy.org/api/interfaces/ListPrivateMessageReportsResponse.html""" +class BanFromCommunityResponse(ResponseWrapper): + """https://join-lemmy.org/api/interfaces/BanFromCommunityResponse.html""" - private_message_reports: list[PrivateMessageReportView] = None + person_view: PersonView = None + banned: bool = None def parse(self, data: dict[str, Any]): - self.private_message_reports = [PrivateMessageReportView.parse(e0) for e0 in data["private_message_reports"]] + self.person_view = PersonView.parse(data["person_view"]) + self.banned = data["banned"] @classmethod def data( cls, - private_message_reports: list[PrivateMessageReportView] = None + person_view: PersonView = None, + banned: bool = None ): obj = cls.__new__(cls) - obj.private_message_reports = private_message_reports + obj.person_view = person_view + obj.banned = banned return obj -class BlockPersonResponse(ResponseWrapper): - """https://join-lemmy.org/api/interfaces/BlockPersonResponse.html""" +class BlockCommunityResponse(ResponseWrapper): + """https://join-lemmy.org/api/interfaces/BlockCommunityResponse.html""" - person_view: PersonView = None + community_view: CommunityView = None blocked: bool = None def parse(self, data: dict[str, Any]): - self.person_view = PersonView.parse(data["person_view"]) + self.community_view = CommunityView.parse(data["community_view"]) self.blocked = data["blocked"] @classmethod def data( cls, - person_view: PersonView = None, + community_view: CommunityView = None, blocked: bool = None ): obj = cls.__new__(cls) - obj.person_view = person_view + obj.community_view = community_view obj.blocked = blocked return obj -class GetPostResponse(ResponseWrapper): - """https://join-lemmy.org/api/interfaces/GetPostResponse.html""" +class PrivateMessageReportResponse(ResponseWrapper): + """https://join-lemmy.org/api/interfaces/PrivateMessageReportResponse.html""" - post_view: PostView = None - community_view: CommunityView = None - moderators: list[CommunityModeratorView] = None - cross_posts: list[PostView] = None + private_message_report_view: PrivateMessageReportView = None def parse(self, data: dict[str, Any]): - self.post_view = PostView.parse(data["post_view"]) - self.community_view = CommunityView.parse(data["community_view"]) - self.moderators = [CommunityModeratorView.parse(e0) for e0 in data["moderators"]] - self.cross_posts = [PostView.parse(e0) for e0 in data["cross_posts"]] + self.private_message_report_view = PrivateMessageReportView.parse(data["private_message_report_view"]) @classmethod def data( cls, - post_view: PostView = None, - community_view: CommunityView = None, - moderators: list[CommunityModeratorView] = None, - cross_posts: list[PostView] = None + private_message_report_view: PrivateMessageReportView = None ): obj = cls.__new__(cls) - obj.post_view = post_view - obj.community_view = community_view - obj.moderators = moderators - obj.cross_posts = cross_posts + obj.private_message_report_view = private_message_report_view return obj -class ListCustomEmojisResponse(ResponseWrapper): - """https://join-lemmy.org/api/interfaces/ListCustomEmojisResponse.html""" +class BlockPersonResponse(ResponseWrapper): + """https://join-lemmy.org/api/interfaces/BlockPersonResponse.html""" - custom_emojis: list[CustomEmojiView] = None + person_view: PersonView = None + blocked: bool = None def parse(self, data: dict[str, Any]): - self.custom_emojis = [CustomEmojiView.parse(e0) for e0 in data["custom_emojis"]] + self.person_view = PersonView.parse(data["person_view"]) + self.blocked = data["blocked"] @classmethod def data( cls, - custom_emojis: list[CustomEmojiView] = None + person_view: PersonView = None, + blocked: bool = None ): obj = cls.__new__(cls) - obj.custom_emojis = custom_emojis + obj.person_view = person_view + obj.blocked = blocked return obj -class ListCommentLikesResponse(ResponseWrapper): - """https://join-lemmy.org/api/interfaces/ListCommentLikesResponse.html""" +class PrivateMessageResponse(ResponseWrapper): + """https://join-lemmy.org/api/interfaces/PrivateMessageResponse.html""" - comment_likes: list[VoteView] = None + private_message_view: PrivateMessageView = None def parse(self, data: dict[str, Any]): - self.comment_likes = [VoteView.parse(e0) for e0 in data["comment_likes"]] + self.private_message_view = PrivateMessageView.parse(data["private_message_view"]) @classmethod def data( cls, - comment_likes: list[VoteView] = None + private_message_view: PrivateMessageView = None ): obj = cls.__new__(cls) - obj.comment_likes = comment_likes + obj.private_message_view = private_message_view return obj diff --git a/pythonlemmy/views.py b/pythonlemmy/views.py index 7da6afc..01f052c 100644 --- a/pythonlemmy/views.py +++ b/pythonlemmy/views.py @@ -4,6 +4,40 @@ from .objects import * +@dataclass +class PrivateMessageView: + """https://join-lemmy.org/api/interfaces/PrivateMessageView.html""" + + private_message: PrivateMessage = None + creator: Person = None + recipient: Person = None + + @classmethod + def parse(cls, data: dict[str, Any]): + return cls( + private_message=PrivateMessage.parse(data["private_message"]), + creator=Person.parse(data["creator"]), + recipient=Person.parse(data["recipient"]) + ) + + +@dataclass +class AdminPurgeCommentView: + """https://join-lemmy.org/api/interfaces/AdminPurgeCommentView.html""" + + admin_purge_comment: AdminPurgeComment = None + admin: Optional[Person] = None + post: Post = None + + @classmethod + def parse(cls, data: dict[str, Any]): + return cls( + admin_purge_comment=AdminPurgeComment.parse(data["admin_purge_comment"]), + admin=Person.parse(data["admin"]) if "admin" in data else None, + post=Post.parse(data["post"]) + ) + + @dataclass class LocalUserView: """https://join-lemmy.org/api/interfaces/LocalUserView.html""" @@ -24,185 +58,163 @@ def parse(cls, data: dict[str, Any]): @dataclass -class CommentReplyView: - """https://join-lemmy.org/api/interfaces/CommentReplyView.html""" +class PostReportView: + """https://join-lemmy.org/api/interfaces/PostReportView.html""" - comment_reply: CommentReply = None - comment: Comment = None - creator: Person = None + post_report: PostReport = None post: Post = None community: Community = None - recipient: Person = None - counts: CommentAggregates = None + creator: Person = None + post_creator: Person = None creator_banned_from_community: bool = None - banned_from_community: bool = None creator_is_moderator: bool = None creator_is_admin: bool = None subscribed: str = None saved: bool = None + read: bool = None + hidden: bool = None creator_blocked: bool = None my_vote: Optional[int] = None + unread_comments: int = None + counts: PostAggregates = None + resolver: Optional[Person] = None @classmethod def parse(cls, data: dict[str, Any]): return cls( - comment_reply=CommentReply.parse(data["comment_reply"]), - comment=Comment.parse(data["comment"]), - creator=Person.parse(data["creator"]), + post_report=PostReport.parse(data["post_report"]), post=Post.parse(data["post"]), community=Community.parse(data["community"]), - recipient=Person.parse(data["recipient"]), - counts=CommentAggregates.parse(data["counts"]), + creator=Person.parse(data["creator"]), + post_creator=Person.parse(data["post_creator"]), creator_banned_from_community=data["creator_banned_from_community"], - banned_from_community=data["banned_from_community"], creator_is_moderator=data["creator_is_moderator"], creator_is_admin=data["creator_is_admin"], subscribed=data["subscribed"], saved=data["saved"], + read=data["read"], + hidden=data["hidden"], creator_blocked=data["creator_blocked"], - my_vote=data["my_vote"] if "my_vote" in data else None + my_vote=data["my_vote"] if "my_vote" in data else None, + unread_comments=data["unread_comments"], + counts=PostAggregates.parse(data["counts"]), + resolver=Person.parse(data["resolver"]) if "resolver" in data else None ) @dataclass -class CommunityFollowerView: - """https://join-lemmy.org/api/interfaces/CommunityFollowerView.html""" +class ModFeaturePostView: + """https://join-lemmy.org/api/interfaces/ModFeaturePostView.html""" + mod_feature_post: ModFeaturePost = None + moderator: Optional[Person] = None + post: Post = None community: Community = None - follower: Person = None - - @classmethod - def parse(cls, data: dict[str, Any]): - return cls( - community=Community.parse(data["community"]), - follower=Person.parse(data["follower"]) - ) - - -@dataclass -class VoteView: - """https://join-lemmy.org/api/interfaces/VoteView.html""" - - creator: Person = None - creator_banned_from_community: bool = None - score: int = None @classmethod def parse(cls, data: dict[str, Any]): return cls( - creator=Person.parse(data["creator"]), - creator_banned_from_community=data["creator_banned_from_community"], - score=data["score"] + mod_feature_post=ModFeaturePost.parse(data["mod_feature_post"]), + moderator=Person.parse(data["moderator"]) if "moderator" in data else None, + post=Post.parse(data["post"]), + community=Community.parse(data["community"]) ) @dataclass -class PrivateMessageReportView: - """https://join-lemmy.org/api/interfaces/PrivateMessageReportView.html""" +class ModHideCommunityView: + """https://join-lemmy.org/api/interfaces/ModHideCommunityView.html""" - private_message_report: PrivateMessageReport = None - private_message: PrivateMessage = None - private_message_creator: Person = None - creator: Person = None - resolver: Optional[Person] = None + mod_hide_community: ModHideCommunity = None + admin: Optional[Person] = None + community: Community = None @classmethod def parse(cls, data: dict[str, Any]): return cls( - private_message_report=PrivateMessageReport.parse(data["private_message_report"]), - private_message=PrivateMessage.parse(data["private_message"]), - private_message_creator=Person.parse(data["private_message_creator"]), - creator=Person.parse(data["creator"]), - resolver=Person.parse(data["resolver"]) if "resolver" in data else None + mod_hide_community=ModHideCommunity.parse(data["mod_hide_community"]), + admin=Person.parse(data["admin"]) if "admin" in data else None, + community=Community.parse(data["community"]) ) @dataclass -class ModAddView: - """https://join-lemmy.org/api/interfaces/ModAddView.html""" +class ModRemoveCommentView: + """https://join-lemmy.org/api/interfaces/ModRemoveCommentView.html""" - mod_add: ModAdd = None + mod_remove_comment: ModRemoveComment = None moderator: Optional[Person] = None - modded_person: Person = None + comment: Comment = None + commenter: Person = None + post: Post = None + community: Community = None @classmethod def parse(cls, data: dict[str, Any]): return cls( - mod_add=ModAdd.parse(data["mod_add"]), + mod_remove_comment=ModRemoveComment.parse(data["mod_remove_comment"]), moderator=Person.parse(data["moderator"]) if "moderator" in data else None, - modded_person=Person.parse(data["modded_person"]) - ) - - -@dataclass -class PersonView: - """https://join-lemmy.org/api/interfaces/PersonView.html""" - - person: Person = None - counts: PersonAggregates = None - is_admin: bool = None - - @classmethod - def parse(cls, data: dict[str, Any]): - return cls( - person=Person.parse(data["person"]), - counts=PersonAggregates.parse(data["counts"]), - is_admin=data["is_admin"] + comment=Comment.parse(data["comment"]), + commenter=Person.parse(data["commenter"]), + post=Post.parse(data["post"]), + community=Community.parse(data["community"]) ) @dataclass -class ModBanView: - """https://join-lemmy.org/api/interfaces/ModBanView.html""" +class ModLockPostView: + """https://join-lemmy.org/api/interfaces/ModLockPostView.html""" - mod_ban: ModBan = None + mod_lock_post: ModLockPost = None moderator: Optional[Person] = None - banned_person: Person = None + post: Post = None + community: Community = None @classmethod def parse(cls, data: dict[str, Any]): return cls( - mod_ban=ModBan.parse(data["mod_ban"]), + mod_lock_post=ModLockPost.parse(data["mod_lock_post"]), moderator=Person.parse(data["moderator"]) if "moderator" in data else None, - banned_person=Person.parse(data["banned_person"]) + post=Post.parse(data["post"]), + community=Community.parse(data["community"]) ) @dataclass -class RegistrationApplicationView: - """https://join-lemmy.org/api/interfaces/RegistrationApplicationView.html""" +class ModTransferCommunityView: + """https://join-lemmy.org/api/interfaces/ModTransferCommunityView.html""" - registration_application: RegistrationApplication = None - creator_local_user: LocalUser = None - creator: Person = None - admin: Optional[Person] = None + mod_transfer_community: ModTransferCommunity = None + moderator: Optional[Person] = None + community: Community = None + modded_person: Person = None @classmethod def parse(cls, data: dict[str, Any]): return cls( - registration_application=RegistrationApplication.parse(data["registration_application"]), - creator_local_user=LocalUser.parse(data["creator_local_user"]), - creator=Person.parse(data["creator"]), - admin=Person.parse(data["admin"]) if "admin" in data else None + mod_transfer_community=ModTransferCommunity.parse(data["mod_transfer_community"]), + moderator=Person.parse(data["moderator"]) if "moderator" in data else None, + community=Community.parse(data["community"]), + modded_person=Person.parse(data["modded_person"]) ) @dataclass -class ModBanFromCommunityView: - """https://join-lemmy.org/api/interfaces/ModBanFromCommunityView.html""" +class ModRemovePostView: + """https://join-lemmy.org/api/interfaces/ModRemovePostView.html""" - mod_ban_from_community: ModBanFromCommunity = None + mod_remove_post: ModRemovePost = None moderator: Optional[Person] = None + post: Post = None community: Community = None - banned_person: Person = None @classmethod def parse(cls, data: dict[str, Any]): return cls( - mod_ban_from_community=ModBanFromCommunity.parse(data["mod_ban_from_community"]), + mod_remove_post=ModRemovePost.parse(data["mod_remove_post"]), moderator=Person.parse(data["moderator"]) if "moderator" in data else None, - community=Community.parse(data["community"]), - banned_person=Person.parse(data["banned_person"]) + post=Post.parse(data["post"]), + community=Community.parse(data["community"]) ) @@ -250,146 +262,70 @@ def parse(cls, data: dict[str, Any]): @dataclass -class ModRemoveCommunityView: - """https://join-lemmy.org/api/interfaces/ModRemoveCommunityView.html""" +class PersonView: + """https://join-lemmy.org/api/interfaces/PersonView.html""" - mod_remove_community: ModRemoveCommunity = None - moderator: Optional[Person] = None - community: Community = None + person: Person = None + counts: PersonAggregates = None + is_admin: bool = None @classmethod def parse(cls, data: dict[str, Any]): return cls( - mod_remove_community=ModRemoveCommunity.parse(data["mod_remove_community"]), - moderator=Person.parse(data["moderator"]) if "moderator" in data else None, - community=Community.parse(data["community"]) + person=Person.parse(data["person"]), + counts=PersonAggregates.parse(data["counts"]), + is_admin=data["is_admin"] ) @dataclass -class ModHideCommunityView: - """https://join-lemmy.org/api/interfaces/ModHideCommunityView.html""" +class RegistrationApplicationView: + """https://join-lemmy.org/api/interfaces/RegistrationApplicationView.html""" - mod_hide_community: ModHideCommunity = None + registration_application: RegistrationApplication = None + creator_local_user: LocalUser = None + creator: Person = None admin: Optional[Person] = None - community: Community = None @classmethod def parse(cls, data: dict[str, Any]): return cls( - mod_hide_community=ModHideCommunity.parse(data["mod_hide_community"]), - admin=Person.parse(data["admin"]) if "admin" in data else None, - community=Community.parse(data["community"]) + registration_application=RegistrationApplication.parse(data["registration_application"]), + creator_local_user=LocalUser.parse(data["creator_local_user"]), + creator=Person.parse(data["creator"]), + admin=Person.parse(data["admin"]) if "admin" in data else None ) @dataclass -class ModRemoveCommentView: - """https://join-lemmy.org/api/interfaces/ModRemoveCommentView.html""" +class CommunityFollowerView: + """https://join-lemmy.org/api/interfaces/CommunityFollowerView.html""" - mod_remove_comment: ModRemoveComment = None - moderator: Optional[Person] = None - comment: Comment = None - commenter: Person = None - post: Post = None community: Community = None + follower: Person = None @classmethod def parse(cls, data: dict[str, Any]): return cls( - mod_remove_comment=ModRemoveComment.parse(data["mod_remove_comment"]), - moderator=Person.parse(data["moderator"]) if "moderator" in data else None, - comment=Comment.parse(data["comment"]), - commenter=Person.parse(data["commenter"]), - post=Post.parse(data["post"]), - community=Community.parse(data["community"]) + community=Community.parse(data["community"]), + follower=Person.parse(data["follower"]) ) @dataclass -class AdminPurgeCommentView: - """https://join-lemmy.org/api/interfaces/AdminPurgeCommentView.html""" +class ModBanView: + """https://join-lemmy.org/api/interfaces/ModBanView.html""" - admin_purge_comment: AdminPurgeComment = None - admin: Optional[Person] = None - post: Post = None - - @classmethod - def parse(cls, data: dict[str, Any]): - return cls( - admin_purge_comment=AdminPurgeComment.parse(data["admin_purge_comment"]), - admin=Person.parse(data["admin"]) if "admin" in data else None, - post=Post.parse(data["post"]) - ) - - -@dataclass -class ModAddCommunityView: - """https://join-lemmy.org/api/interfaces/ModAddCommunityView.html""" - - mod_add_community: ModAddCommunity = None - moderator: Optional[Person] = None - community: Community = None - modded_person: Person = None - - @classmethod - def parse(cls, data: dict[str, Any]): - return cls( - mod_add_community=ModAddCommunity.parse(data["mod_add_community"]), - moderator=Person.parse(data["moderator"]) if "moderator" in data else None, - community=Community.parse(data["community"]), - modded_person=Person.parse(data["modded_person"]) - ) - - -@dataclass -class CommunityModeratorView: - """https://join-lemmy.org/api/interfaces/CommunityModeratorView.html""" - - community: Community = None - moderator: Person = None - - @classmethod - def parse(cls, data: dict[str, Any]): - return cls( - community=Community.parse(data["community"]), - moderator=Person.parse(data["moderator"]) - ) - - -@dataclass -class ModFeaturePostView: - """https://join-lemmy.org/api/interfaces/ModFeaturePostView.html""" - - mod_feature_post: ModFeaturePost = None + mod_ban: ModBan = None moderator: Optional[Person] = None - post: Post = None - community: Community = None + banned_person: Person = None @classmethod def parse(cls, data: dict[str, Any]): return cls( - mod_feature_post=ModFeaturePost.parse(data["mod_feature_post"]), + mod_ban=ModBan.parse(data["mod_ban"]), moderator=Person.parse(data["moderator"]) if "moderator" in data else None, - post=Post.parse(data["post"]), - community=Community.parse(data["community"]) - ) - - -@dataclass -class PrivateMessageView: - """https://join-lemmy.org/api/interfaces/PrivateMessageView.html""" - - private_message: PrivateMessage = None - creator: Person = None - recipient: Person = None - - @classmethod - def parse(cls, data: dict[str, Any]): - return cls( - private_message=PrivateMessage.parse(data["private_message"]), - creator=Person.parse(data["creator"]), - recipient=Person.parse(data["recipient"]) + banned_person=Person.parse(data["banned_person"]) ) @@ -412,65 +348,6 @@ def parse(cls, data: dict[str, Any]): ) -@dataclass -class ModLockPostView: - """https://join-lemmy.org/api/interfaces/ModLockPostView.html""" - - mod_lock_post: ModLockPost = None - moderator: Optional[Person] = None - post: Post = None - community: Community = None - - @classmethod - def parse(cls, data: dict[str, Any]): - return cls( - mod_lock_post=ModLockPost.parse(data["mod_lock_post"]), - moderator=Person.parse(data["moderator"]) if "moderator" in data else None, - post=Post.parse(data["post"]), - community=Community.parse(data["community"]) - ) - - -@dataclass -class MyUserInfo: - """https://join-lemmy.org/api/interfaces/MyUserInfo.html""" - - local_user_view: LocalUserView = None - follows: list[CommunityFollowerView] = None - moderates: list[CommunityModeratorView] = None - community_blocks: list[Community] = None - instance_blocks: list[Instance] = None - person_blocks: list[Person] = None - discussion_languages: list[int] = None - - @classmethod - def parse(cls, data: dict[str, Any]): - return cls( - local_user_view=LocalUserView.parse(data["local_user_view"]), - follows=[CommunityFollowerView.parse(e0) for e0 in data["follows"]], - moderates=[CommunityModeratorView.parse(e0) for e0 in data["moderates"]], - community_blocks=[Community.parse(e0) for e0 in data["community_blocks"]], - instance_blocks=[Instance.parse(e0) for e0 in data["instance_blocks"]], - person_blocks=[Person.parse(e0) for e0 in data["person_blocks"]], - discussion_languages=[e0 for e0 in data["discussion_languages"]] - ) - - -@dataclass -class AdminPurgePersonView: - """https://join-lemmy.org/api/interfaces/AdminPurgePersonView.html""" - - admin_purge_person: AdminPurgePerson = None - admin: Optional[Person] = None - - @classmethod - def parse(cls, data: dict[str, Any]): - return cls( - admin_purge_person=AdminPurgePerson.parse(data["admin_purge_person"]), - admin=Person.parse(data["admin"]) if "admin" in data else None - ) - - @dataclass class CommentReportView: """https://join-lemmy.org/api/interfaces/CommentReportView.html""" @@ -513,21 +390,19 @@ def parse(cls, data: dict[str, Any]): @dataclass -class ModRemovePostView: - """https://join-lemmy.org/api/interfaces/ModRemovePostView.html""" +class ModAddView: + """https://join-lemmy.org/api/interfaces/ModAddView.html""" - mod_remove_post: ModRemovePost = None + mod_add: ModAdd = None moderator: Optional[Person] = None - post: Post = None - community: Community = None + modded_person: Person = None @classmethod def parse(cls, data: dict[str, Any]): return cls( - mod_remove_post=ModRemovePost.parse(data["mod_remove_post"]), + mod_add=ModAdd.parse(data["mod_add"]), moderator=Person.parse(data["moderator"]) if "moderator" in data else None, - post=Post.parse(data["post"]), - community=Community.parse(data["community"]) + modded_person=Person.parse(data["modded_person"]) ) @@ -553,68 +428,111 @@ def parse(cls, data: dict[str, Any]): @dataclass -class AdminPurgeCommunityView: - """https://join-lemmy.org/api/interfaces/AdminPurgeCommunityView.html""" +class ModAddCommunityView: + """https://join-lemmy.org/api/interfaces/ModAddCommunityView.html""" - admin_purge_community: AdminPurgeCommunity = None - admin: Optional[Person] = None + mod_add_community: ModAddCommunity = None + moderator: Optional[Person] = None + community: Community = None + modded_person: Person = None @classmethod def parse(cls, data: dict[str, Any]): return cls( - admin_purge_community=AdminPurgeCommunity.parse(data["admin_purge_community"]), - admin=Person.parse(data["admin"]) if "admin" in data else None + mod_add_community=ModAddCommunity.parse(data["mod_add_community"]), + moderator=Person.parse(data["moderator"]) if "moderator" in data else None, + community=Community.parse(data["community"]), + modded_person=Person.parse(data["modded_person"]) ) @dataclass -class AdminPurgePostView: - """https://join-lemmy.org/api/interfaces/AdminPurgePostView.html""" +class CommentView: + """https://join-lemmy.org/api/interfaces/CommentView.html""" - admin_purge_post: AdminPurgePost = None - admin: Optional[Person] = None + comment: Comment = None + creator: Person = None + post: Post = None community: Community = None + counts: CommentAggregates = None + creator_banned_from_community: bool = None + banned_from_community: bool = None + creator_is_moderator: bool = None + creator_is_admin: bool = None + subscribed: str = None + saved: bool = None + creator_blocked: bool = None + my_vote: Optional[int] = None @classmethod def parse(cls, data: dict[str, Any]): return cls( - admin_purge_post=AdminPurgePost.parse(data["admin_purge_post"]), - admin=Person.parse(data["admin"]) if "admin" in data else None, - community=Community.parse(data["community"]) + comment=Comment.parse(data["comment"]), + creator=Person.parse(data["creator"]), + post=Post.parse(data["post"]), + community=Community.parse(data["community"]), + counts=CommentAggregates.parse(data["counts"]), + creator_banned_from_community=data["creator_banned_from_community"], + banned_from_community=data["banned_from_community"], + creator_is_moderator=data["creator_is_moderator"], + creator_is_admin=data["creator_is_admin"], + subscribed=data["subscribed"], + saved=data["saved"], + creator_blocked=data["creator_blocked"], + my_vote=data["my_vote"] if "my_vote" in data else None ) @dataclass -class ModTransferCommunityView: - """https://join-lemmy.org/api/interfaces/ModTransferCommunityView.html""" +class PrivateMessageReportView: + """https://join-lemmy.org/api/interfaces/PrivateMessageReportView.html""" - mod_transfer_community: ModTransferCommunity = None - moderator: Optional[Person] = None - community: Community = None - modded_person: Person = None + private_message_report: PrivateMessageReport = None + private_message: PrivateMessage = None + private_message_creator: Person = None + creator: Person = None + resolver: Optional[Person] = None @classmethod def parse(cls, data: dict[str, Any]): return cls( - mod_transfer_community=ModTransferCommunity.parse(data["mod_transfer_community"]), - moderator=Person.parse(data["moderator"]) if "moderator" in data else None, - community=Community.parse(data["community"]), - modded_person=Person.parse(data["modded_person"]) + private_message_report=PrivateMessageReport.parse(data["private_message_report"]), + private_message=PrivateMessage.parse(data["private_message"]), + private_message_creator=Person.parse(data["private_message_creator"]), + creator=Person.parse(data["creator"]), + resolver=Person.parse(data["resolver"]) if "resolver" in data else None ) @dataclass -class LocalImageView: - """https://join-lemmy.org/api/interfaces/LocalImageView.html""" +class VoteView: + """https://join-lemmy.org/api/interfaces/VoteView.html""" - local_image: LocalImage = None - person: Person = None + creator: Person = None + creator_banned_from_community: bool = None + score: int = None @classmethod def parse(cls, data: dict[str, Any]): return cls( - local_image=LocalImage.parse(data["local_image"]), - person=Person.parse(data["person"]) + creator=Person.parse(data["creator"]), + creator_banned_from_community=data["creator_banned_from_community"], + score=data["score"] + ) + + +@dataclass +class AdminPurgePersonView: + """https://join-lemmy.org/api/interfaces/AdminPurgePersonView.html""" + + admin_purge_person: AdminPurgePerson = None + admin: Optional[Person] = None + + @classmethod + def parse(cls, data: dict[str, Any]): + return cls( + admin_purge_person=AdminPurgePerson.parse(data["admin_purge_person"]), + admin=Person.parse(data["admin"]) if "admin" in data else None ) @@ -660,28 +578,32 @@ def parse(cls, data: dict[str, Any]): @dataclass -class CustomEmojiView: - """https://join-lemmy.org/api/interfaces/CustomEmojiView.html""" +class ModRemoveCommunityView: + """https://join-lemmy.org/api/interfaces/ModRemoveCommunityView.html""" - custom_emoji: CustomEmoji = None - keywords: list[CustomEmojiKeyword] = None + mod_remove_community: ModRemoveCommunity = None + moderator: Optional[Person] = None + community: Community = None @classmethod def parse(cls, data: dict[str, Any]): return cls( - custom_emoji=CustomEmoji.parse(data["custom_emoji"]), - keywords=[CustomEmojiKeyword.parse(e0) for e0 in data["keywords"]] + mod_remove_community=ModRemoveCommunity.parse(data["mod_remove_community"]), + moderator=Person.parse(data["moderator"]) if "moderator" in data else None, + community=Community.parse(data["community"]) ) @dataclass -class CommentView: - """https://join-lemmy.org/api/interfaces/CommentView.html""" +class CommentReplyView: + """https://join-lemmy.org/api/interfaces/CommentReplyView.html""" + comment_reply: CommentReply = None comment: Comment = None creator: Person = None post: Post = None community: Community = None + recipient: Person = None counts: CommentAggregates = None creator_banned_from_community: bool = None banned_from_community: bool = None @@ -695,10 +617,12 @@ class CommentView: @classmethod def parse(cls, data: dict[str, Any]): return cls( + comment_reply=CommentReply.parse(data["comment_reply"]), comment=Comment.parse(data["comment"]), creator=Person.parse(data["creator"]), post=Post.parse(data["post"]), community=Community.parse(data["community"]), + recipient=Person.parse(data["recipient"]), counts=CommentAggregates.parse(data["counts"]), creator_banned_from_community=data["creator_banned_from_community"], banned_from_community=data["banned_from_community"], @@ -712,45 +636,121 @@ def parse(cls, data: dict[str, Any]): @dataclass -class PostReportView: - """https://join-lemmy.org/api/interfaces/PostReportView.html""" +class AdminPurgeCommunityView: + """https://join-lemmy.org/api/interfaces/AdminPurgeCommunityView.html""" - post_report: PostReport = None - post: Post = None + admin_purge_community: AdminPurgeCommunity = None + admin: Optional[Person] = None + + @classmethod + def parse(cls, data: dict[str, Any]): + return cls( + admin_purge_community=AdminPurgeCommunity.parse(data["admin_purge_community"]), + admin=Person.parse(data["admin"]) if "admin" in data else None + ) + + +@dataclass +class AdminPurgePostView: + """https://join-lemmy.org/api/interfaces/AdminPurgePostView.html""" + + admin_purge_post: AdminPurgePost = None + admin: Optional[Person] = None community: Community = None - creator: Person = None - post_creator: Person = None - creator_banned_from_community: bool = None - creator_is_moderator: bool = None - creator_is_admin: bool = None - subscribed: str = None - saved: bool = None - read: bool = None - hidden: bool = None - creator_blocked: bool = None - my_vote: Optional[int] = None - unread_comments: int = None - counts: PostAggregates = None - resolver: Optional[Person] = None @classmethod def parse(cls, data: dict[str, Any]): return cls( - post_report=PostReport.parse(data["post_report"]), - post=Post.parse(data["post"]), + admin_purge_post=AdminPurgePost.parse(data["admin_purge_post"]), + admin=Person.parse(data["admin"]) if "admin" in data else None, + community=Community.parse(data["community"]) + ) + + +@dataclass +class CustomEmojiView: + """https://join-lemmy.org/api/interfaces/CustomEmojiView.html""" + + custom_emoji: CustomEmoji = None + keywords: list[CustomEmojiKeyword] = None + + @classmethod + def parse(cls, data: dict[str, Any]): + return cls( + custom_emoji=CustomEmoji.parse(data["custom_emoji"]), + keywords=[CustomEmojiKeyword.parse(e0) for e0 in data["keywords"]] + ) + + +@dataclass +class LocalImageView: + """https://join-lemmy.org/api/interfaces/LocalImageView.html""" + + local_image: LocalImage = None + person: Person = None + + @classmethod + def parse(cls, data: dict[str, Any]): + return cls( + local_image=LocalImage.parse(data["local_image"]), + person=Person.parse(data["person"]) + ) + + +@dataclass +class ModBanFromCommunityView: + """https://join-lemmy.org/api/interfaces/ModBanFromCommunityView.html""" + + mod_ban_from_community: ModBanFromCommunity = None + moderator: Optional[Person] = None + community: Community = None + banned_person: Person = None + + @classmethod + def parse(cls, data: dict[str, Any]): + return cls( + mod_ban_from_community=ModBanFromCommunity.parse(data["mod_ban_from_community"]), + moderator=Person.parse(data["moderator"]) if "moderator" in data else None, community=Community.parse(data["community"]), - creator=Person.parse(data["creator"]), - post_creator=Person.parse(data["post_creator"]), - creator_banned_from_community=data["creator_banned_from_community"], - creator_is_moderator=data["creator_is_moderator"], - creator_is_admin=data["creator_is_admin"], - subscribed=data["subscribed"], - saved=data["saved"], - read=data["read"], - hidden=data["hidden"], - creator_blocked=data["creator_blocked"], - my_vote=data["my_vote"] if "my_vote" in data else None, - unread_comments=data["unread_comments"], - counts=PostAggregates.parse(data["counts"]), - resolver=Person.parse(data["resolver"]) if "resolver" in data else None + banned_person=Person.parse(data["banned_person"]) + ) + + +@dataclass +class CommunityModeratorView: + """https://join-lemmy.org/api/interfaces/CommunityModeratorView.html""" + + community: Community = None + moderator: Person = None + + @classmethod + def parse(cls, data: dict[str, Any]): + return cls( + community=Community.parse(data["community"]), + moderator=Person.parse(data["moderator"]) + ) + + +@dataclass +class MyUserInfo: + """https://join-lemmy.org/api/interfaces/MyUserInfo.html""" + + local_user_view: LocalUserView = None + follows: list[CommunityFollowerView] = None + moderates: list[CommunityModeratorView] = None + community_blocks: list[Community] = None + instance_blocks: list[Instance] = None + person_blocks: list[Person] = None + discussion_languages: list[int] = None + + @classmethod + def parse(cls, data: dict[str, Any]): + return cls( + local_user_view=LocalUserView.parse(data["local_user_view"]), + follows=[CommunityFollowerView.parse(e0) for e0 in data["follows"]], + moderates=[CommunityModeratorView.parse(e0) for e0 in data["moderates"]], + community_blocks=[Community.parse(e0) for e0 in data["community_blocks"]], + instance_blocks=[Instance.parse(e0) for e0 in data["instance_blocks"]], + person_blocks=[Person.parse(e0) for e0 in data["person_blocks"]], + discussion_languages=[e0 for e0 in data["discussion_languages"]] ) diff --git a/type-generator/headers/object_header.py b/type-generator/headers/object_header.py index dac6bbd..c58b922 100644 --- a/type-generator/headers/object_header.py +++ b/type-generator/headers/object_header.py @@ -1,3 +1,2 @@ from dataclasses import dataclass -from typing import Optional, Any - +from typing import Optional, Any \ No newline at end of file diff --git a/type-generator/headers/response_header.py b/type-generator/headers/response_header.py index eb7f651..00a0962 100644 --- a/type-generator/headers/response_header.py +++ b/type-generator/headers/response_header.py @@ -4,6 +4,4 @@ from .views import * from .objects import * -from .types import ResponseWrapper - - +from .types import ResponseWrapper \ No newline at end of file diff --git a/type-generator/headers/view_header.py b/type-generator/headers/view_header.py index f2adf3b..7a9549c 100644 --- a/type-generator/headers/view_header.py +++ b/type-generator/headers/view_header.py @@ -1,6 +1,4 @@ from dataclasses import dataclass from typing import Optional, Any -from .objects import * - - +from .objects import * \ No newline at end of file diff --git a/type-generator/lemmy-js-client b/type-generator/lemmy-js-client index 0b2674e..72693cd 160000 --- a/type-generator/lemmy-js-client +++ b/type-generator/lemmy-js-client @@ -1 +1 @@ -Subproject commit 0b2674e9b6c338037438fb22d6442149c2122563 +Subproject commit 72693cd09c92891d007619bd0cda949955cf7eaf diff --git a/type-generator/main.py b/type-generator/main.py index 8f2bc7d..963e6de 100644 --- a/type-generator/main.py +++ b/type-generator/main.py @@ -18,13 +18,38 @@ enum_names = [] type_aliases = {} -objects = [] -responses = [] -views = [] +objects = {} +object_dependencies = {} +responses = {} +response_dependencies = {} +views = {} +view_dependencies = {} openapi_docs = "https://raw.githubusercontent.com/MV-GH/lemmy_openapi_spec/master/lemmy_spec.yaml" +# From https://code.activestate.com/recipes/576570-dependency-resolver/ +def dep(arg): + ''' + Dependency resolver + + "arg" is a dependency dictionary in which + the values are the dependencies of their respective keys. + ''' + d=dict((k, set(arg[k])) for k in arg) + r=[] + while d: + # values not in keys (items without dep) + t=set(i for v in d.values() for i in v)-set(d.keys()) + # and keys without value (items without dep) + t.update(k for k, v in d.items() if not v) + # can be done right away + r.append(t) + # and cleaned up + d=dict(((k, v-t) for k, v in d.items() if v)) + return r + + def list_enums(): types_dir = f"{current_dir()}lemmy-js-client/src/types/" files = os.listdir(types_dir) @@ -48,29 +73,27 @@ def generate_types(): if file_without_extension in enum_names or file_without_extension in type_aliases.keys(): continue with open(f"{types_dir}{file}", "r") as f: - print(f"File = {types_dir}{file}") parse_model(f.read()) print(f"Object count = {len(objects)}, Response count = {len(responses)}, View count = {len(views)}") + generate_file(f"./headers/object_header.py", "objects.py", objects, object_dependencies) + generate_file(f"./headers/response_header.py", "responses.py", responses, response_dependencies) + generate_file(f"./headers/view_header.py", "views.py", views, view_dependencies) - with open(f"./headers/object_header.py", "r") as f: - object_header = f.read() - with open(f"./headers/response_header.py", "r") as f: - response_header = f.read() - with open(f"./headers/view_header.py", "r") as f: - view_header = f.read() - with open(f"{model_dir}/views.py", "w") as f: - f.write(view_header) - f.write("\n\n\n".join(views)) - f.write("\n") - with open(f"{model_dir}/objects.py", "w") as f: - f.write(object_header) - f.write("\n\n\n".join(objects)) - f.write("\n") - with open(f"{model_dir}/responses.py", "w") as f: - f.write(response_header) - f.write("\n\n\n".join(responses)) +def generate_file(header_file_path: str, output_file_path: str, types: dict[str, str], dependencies: dict[str, str]): + with open(header_file_path, "r") as f: + header = f.read() + + dep_tree = dep(dependencies) + + with open(f"{model_dir}/{output_file_path}", "w") as f: + f.write(header) + for d in dep_tree: + for r in d: + if r not in types: + continue + f.write(f"\n\n\n{types[r]}") f.write("\n") @@ -114,11 +137,14 @@ def parse_model(model_contents: str): visitor.walk() result = ModelGenerator(visitor.class_name, visitor.properties, visitor.class_type).build() if visitor.class_type == ClassType.VIEW: - views.append(result) + views[visitor.class_name] = result + view_dependencies[visitor.class_name] = visitor.dependencies elif visitor.class_type == ClassType.RESPONSE: - responses.append(result) + responses[visitor.class_name] = result + response_dependencies[visitor.class_name] = visitor.dependencies elif visitor.class_type == ClassType.OBJECT: - objects.append(result) + objects[visitor.class_name] = result + object_dependencies[visitor.class_name] = visitor.dependencies def generate_http():