From 899889e782ccab98f09b31ba0eaa5bba54702d2e Mon Sep 17 00:00:00 2001 From: Suyash Vardhan Mathur Date: Mon, 16 Aug 2021 12:07:11 +0530 Subject: [PATCH] zulip: Deprecate methods whose names don't match with OperationIDs and add newer methods. --- zulip/zulip/__init__.py | 43 +++++++++++++++++++++++++++++++++++++++-- 1 file changed, 41 insertions(+), 2 deletions(-) diff --git a/zulip/zulip/__init__.py b/zulip/zulip/__init__.py index 725896e34..6f3546916 100644 --- a/zulip/zulip/__init__.py +++ b/zulip/zulip/__init__.py @@ -951,6 +951,12 @@ def remove_reaction(self, reaction_data: Dict[str, Any]) -> Dict[str, Any]: ) def get_realm_emoji(self) -> Dict[str, Any]: + logger.warning( + "get_realm_emoji() is deprecated." " Please use get_custom_emoji() instead." + ) + return self.get_custom_emoji() + + def get_custom_emoji(self) -> Dict[str, Any]: """ See examples/realm-emoji for example usage. """ @@ -1000,6 +1006,12 @@ def get_realm_linkifiers(self) -> Dict[str, Any]: ) def add_realm_filter(self, pattern: str, url_format_string: str) -> Dict[str, Any]: + logger.warning( + "get_members() is deprecated." " Please use get_users() instead." + ) + self.add_linkifier(pattern, url_format_string) + + def add_linkifier(self, pattern: str, url_format_string: str) -> Dict[str, Any]: """ Example usage: @@ -1078,6 +1090,12 @@ def reorder_realm_profile_fields(self, **request: Any) -> Dict[str, Any]: ) def update_realm_profile_field(self, field_id: int, **request: Any) -> Dict[str, Any]: + logger.warning( + "update_realm_profile_field() is deprecated." " Please use update_linkifier() instead." + ) + return self.update_linkifier(field_id) + + def update_linkifier(self, field_id: int, **request: Any) -> Dict[str, Any]: """ Example usage: @@ -1157,6 +1175,12 @@ def deregister(self, queue_id: str, timeout: Optional[float] = None) -> Dict[str ) def get_profile(self, request: Optional[Dict[str, Any]] = None) -> Dict[str, Any]: + logger.warning( + "get_profile() is deprecated." " Please use get_own_user() instead." + ) + self.get_own_user(request) + + def get_own_user(self, request: Optional[Dict[str, Any]] = None) -> Dict[str, Any]: """ Example usage: @@ -1321,8 +1345,9 @@ def get_users(self, request: Optional[Dict[str, Any]] = None) -> Dict[str, Any]: def get_members(self, request: Optional[Dict[str, Any]] = None) -> Dict[str, Any]: # This exists for backwards-compatibility; we renamed this # function get_users for consistency with the rest of the API. - # Later, we may want to add a warning for clients using this - # legacy name. + logger.warning( + "get_members() is deprecated." " Please use get_users() instead." + ) return self.get_users(request=request) def get_alert_words(self) -> Dict[str, Any]: @@ -1364,6 +1389,12 @@ def list_subscriptions(self, request: Optional[Dict[str, Any]] = None) -> Dict[s return self.get_subscriptions(request) def add_subscriptions(self, streams: Iterable[Dict[str, Any]], **kwargs: Any) -> Dict[str, Any]: + logger.warning( + "add_subscriptions() is deprecated." " Please use subscribe() instead." + ) + return self.subscribe(streams) + + def subscribe(self, streams: Iterable[Dict[str, Any]], **kwargs: Any) -> Dict[str, Any]: """ See examples/subscribe for example usage. """ @@ -1376,6 +1407,14 @@ def add_subscriptions(self, streams: Iterable[Dict[str, Any]], **kwargs: Any) -> def remove_subscriptions( self, streams: Iterable[str], principals: Union[Sequence[str], Sequence[int]] = [] + ) -> Dict[str, Any]: + logger.warning( + "remove_subscriptions() is deprecated." " Please use unsubscribe() instead." + ) + return self.unsubscribe(streams, principals) + + def unsubscribe( + self, streams: Iterable[str], principals: Union[Sequence[str], Sequence[int]] = [] ) -> Dict[str, Any]: """ See examples/unsubscribe for example usage.