Skip to content

Commit b16563c

Browse files
committed
zulip: Standardize the names of bindings with OperationIDs.
Some bindings had names that differed from the names that were used in the OperationID. This commit deprecates the older names, and changes the names of the bindings to match operationIDs.
1 parent 285a946 commit b16563c

File tree

1 file changed

+99
-2
lines changed

1 file changed

+99
-2
lines changed

zulip/zulip/__init__.py

+99-2
Original file line numberDiff line numberDiff line change
@@ -951,6 +951,10 @@ def remove_reaction(self, reaction_data: Dict[str, Any]) -> Dict[str, Any]:
951951
)
952952

953953
def get_realm_emoji(self) -> Dict[str, Any]:
954+
logger.warning("get_realm_emoji() is deprecated." " Please use get_custom_emoji() instead.")
955+
return self.get_custom_emoji()
956+
957+
def get_custom_emoji(self) -> Dict[str, Any]:
954958
"""
955959
See examples/realm-emoji for example usage.
956960
"""
@@ -978,6 +982,12 @@ def delete_custom_emoji(self, emoji_name: str) -> Dict[str, Any]:
978982
)
979983

980984
def get_realm_linkifiers(self) -> Dict[str, Any]:
985+
logger.warning(
986+
"get_realm_linkifiers() is deprecated." " Please use get_linkifiers() instead."
987+
)
988+
return self.get_linkifiers()
989+
990+
def get_linkifiers(self) -> Dict[str, Any]:
981991
"""
982992
Example usage:
983993
@@ -1000,6 +1010,10 @@ def get_realm_linkifiers(self) -> Dict[str, Any]:
10001010
)
10011011

10021012
def add_realm_filter(self, pattern: str, url_format_string: str) -> Dict[str, Any]:
1013+
logger.warning("get_members() is deprecated." " Please use get_users() instead.")
1014+
return self.add_linkifier(pattern, url_format_string)
1015+
1016+
def add_linkifier(self, pattern: str, url_format_string: str) -> Dict[str, Any]:
10031017
"""
10041018
Example usage:
10051019
@@ -1016,6 +1030,12 @@ def add_realm_filter(self, pattern: str, url_format_string: str) -> Dict[str, An
10161030
)
10171031

10181032
def remove_realm_filter(self, filter_id: int) -> Dict[str, Any]:
1033+
logger.warning(
1034+
"remove_realm_filter() is deprecated." " Please use remove_linkifier() instead."
1035+
)
1036+
return self.remove_linkifier(filter_id)
1037+
1038+
def remove_linkifier(self, filter_id: int) -> Dict[str, Any]:
10191039
"""
10201040
Example usage:
10211041
@@ -1028,6 +1048,13 @@ def remove_realm_filter(self, filter_id: int) -> Dict[str, Any]:
10281048
)
10291049

10301050
def get_realm_profile_fields(self) -> Dict[str, Any]:
1051+
logger.warning(
1052+
"get_realm_profile_fields() is deprecated."
1053+
" Please use get_custom_profile_fields() instead."
1054+
)
1055+
return self.get_custom_profile_fields()
1056+
1057+
def get_custom_profile_fields(self) -> Dict[str, Any]:
10311058
"""
10321059
Example usage:
10331060
@@ -1040,6 +1067,13 @@ def get_realm_profile_fields(self) -> Dict[str, Any]:
10401067
)
10411068

10421069
def create_realm_profile_field(self, **request: Any) -> Dict[str, Any]:
1070+
logger.warning(
1071+
"create_realm_profile_field() is deprecated."
1072+
" Please use create_custom_profile_field() instead."
1073+
)
1074+
return self.create_custom_profile_field(**request)
1075+
1076+
def create_custom_profile_field(self, **request: Any) -> Dict[str, Any]:
10431077
"""
10441078
Example usage:
10451079
@@ -1065,6 +1099,13 @@ def remove_realm_profile_field(self, field_id: int) -> Dict[str, Any]:
10651099
)
10661100

10671101
def reorder_realm_profile_fields(self, **request: Any) -> Dict[str, Any]:
1102+
logger.warning(
1103+
"reorder_realm_profile_fields() is deprecated."
1104+
" Please use reorder_custom_profile_fields() instead."
1105+
)
1106+
return self.reorder_custom_profile_fields(**request)
1107+
1108+
def reorder_custom_profile_fields(self, **request: Any) -> Dict[str, Any]:
10681109
"""
10691110
Example usage:
10701111
@@ -1078,6 +1119,12 @@ def reorder_realm_profile_fields(self, **request: Any) -> Dict[str, Any]:
10781119
)
10791120

10801121
def update_realm_profile_field(self, field_id: int, **request: Any) -> Dict[str, Any]:
1122+
logger.warning(
1123+
"update_realm_profile_field() is deprecated." " Please use update_linkifier() instead."
1124+
)
1125+
return self.update_linkifier(field_id, **request)
1126+
1127+
def update_linkifier(self, field_id: int, **request: Any) -> Dict[str, Any]:
10811128
"""
10821129
Example usage:
10831130
@@ -1118,6 +1165,15 @@ def register(
11181165
event_types: Optional[Iterable[str]] = None,
11191166
narrow: Optional[List[List[str]]] = None,
11201167
**kwargs: object,
1168+
) -> Dict[str, Any]:
1169+
logger.warning("register() is deprecated." " Please use register_queue() instead.")
1170+
return self.register_queue(event_types, narrow, **kwargs)
1171+
1172+
def register_queue(
1173+
self,
1174+
event_types: Optional[Iterable[str]] = None,
1175+
narrow: Optional[List[List[str]]] = None,
1176+
**kwargs: object,
11211177
) -> Dict[str, Any]:
11221178
"""
11231179
Example usage:
@@ -1139,6 +1195,10 @@ def register(
11391195
)
11401196

11411197
def deregister(self, queue_id: str, timeout: Optional[float] = None) -> Dict[str, Any]:
1198+
logger.warning("deregister() is deprecated." " Please use delete_queue() instead.")
1199+
return self.delete_queue(queue_id, timeout)
1200+
1201+
def delete_queue(self, queue_id: str, timeout: Optional[float] = None) -> Dict[str, Any]:
11421202
"""
11431203
Example usage:
11441204
@@ -1157,6 +1217,10 @@ def deregister(self, queue_id: str, timeout: Optional[float] = None) -> Dict[str
11571217
)
11581218

11591219
def get_profile(self, request: Optional[Dict[str, Any]] = None) -> Dict[str, Any]:
1220+
logger.warning("get_profile() is deprecated." " Please use get_own_user() instead.")
1221+
return self.get_own_user(request)
1222+
1223+
def get_own_user(self, request: Optional[Dict[str, Any]] = None) -> Dict[str, Any]:
11601224
"""
11611225
Example usage:
11621226
@@ -1232,6 +1296,10 @@ def update_stream(self, stream_data: Dict[str, Any]) -> Dict[str, Any]:
12321296
)
12331297

12341298
def delete_stream(self, stream_id: int) -> Dict[str, Any]:
1299+
logger.warning("delete_stream() is deprecated." " Please use archive_stream() instead.")
1300+
return self.archive_stream(stream_id)
1301+
1302+
def archive_stream(self, stream_id: int) -> Dict[str, Any]:
12351303
"""
12361304
See examples/delete-stream for example usage.
12371305
"""
@@ -1255,6 +1323,10 @@ def add_default_stream(self, stream_id: int) -> Dict[str, Any]:
12551323
)
12561324

12571325
def get_user_by_id(self, user_id: int, **request: Any) -> Dict[str, Any]:
1326+
logger.warning("get_user_by_id() is deprecated." " Please use get_user() instead.")
1327+
return self.get_user(user_id, **request)
1328+
1329+
def get_user(self, user_id: int, **request: Any) -> Dict[str, Any]:
12581330

12591331
"""
12601332
Example usage:
@@ -1269,6 +1341,12 @@ def get_user_by_id(self, user_id: int, **request: Any) -> Dict[str, Any]:
12691341
)
12701342

12711343
def deactivate_user_by_id(self, user_id: int) -> Dict[str, Any]:
1344+
logger.warning(
1345+
"deactivate_user_by_id() is deprecated." " Please use deactivate_user() instead."
1346+
)
1347+
return self.deactivate_user(user_id)
1348+
1349+
def deactivate_user(self, user_id: int) -> Dict[str, Any]:
12721350

12731351
"""
12741352
Example usage:
@@ -1282,6 +1360,12 @@ def deactivate_user_by_id(self, user_id: int) -> Dict[str, Any]:
12821360
)
12831361

12841362
def reactivate_user_by_id(self, user_id: int) -> Dict[str, Any]:
1363+
logger.warning(
1364+
"reactivate_user_by_id() is deprecated." " Please use reactivate_user() instead."
1365+
)
1366+
return self.reactivate_user(user_id)
1367+
1368+
def reactivate_user(self, user_id: int) -> Dict[str, Any]:
12851369

12861370
"""
12871371
Example usage:
@@ -1295,6 +1379,10 @@ def reactivate_user_by_id(self, user_id: int) -> Dict[str, Any]:
12951379
)
12961380

12971381
def update_user_by_id(self, user_id: int, **request: Any) -> Dict[str, Any]:
1382+
logger.warning("update_user_by_id() is deprecated." " Please use update_user() instead.")
1383+
return self.update_user(user_id, **request)
1384+
1385+
def update_user(self, user_id: int, **request: Any) -> Dict[str, Any]:
12981386

12991387
"""
13001388
Example usage:
@@ -1321,8 +1409,7 @@ def get_users(self, request: Optional[Dict[str, Any]] = None) -> Dict[str, Any]:
13211409
def get_members(self, request: Optional[Dict[str, Any]] = None) -> Dict[str, Any]:
13221410
# This exists for backwards-compatibility; we renamed this
13231411
# function get_users for consistency with the rest of the API.
1324-
# Later, we may want to add a warning for clients using this
1325-
# legacy name.
1412+
logger.warning("get_members() is deprecated." " Please use get_users() instead.")
13261413
return self.get_users(request=request)
13271414

13281415
def get_alert_words(self) -> Dict[str, Any]:
@@ -1364,6 +1451,10 @@ def list_subscriptions(self, request: Optional[Dict[str, Any]] = None) -> Dict[s
13641451
return self.get_subscriptions(request)
13651452

13661453
def add_subscriptions(self, streams: Iterable[Dict[str, Any]], **kwargs: Any) -> Dict[str, Any]:
1454+
logger.warning("add_subscriptions() is deprecated." " Please use subscribe() instead.")
1455+
return self.subscribe(streams, **kwargs)
1456+
1457+
def subscribe(self, streams: Iterable[Dict[str, Any]], **kwargs: Any) -> Dict[str, Any]:
13671458
"""
13681459
See examples/subscribe for example usage.
13691460
"""
@@ -1376,6 +1467,12 @@ def add_subscriptions(self, streams: Iterable[Dict[str, Any]], **kwargs: Any) ->
13761467

13771468
def remove_subscriptions(
13781469
self, streams: Iterable[str], principals: Union[Sequence[str], Sequence[int]] = []
1470+
) -> Dict[str, Any]:
1471+
logger.warning("remove_subscriptions() is deprecated." " Please use unsubscribe() instead.")
1472+
return self.unsubscribe(streams, principals)
1473+
1474+
def unsubscribe(
1475+
self, streams: Iterable[str], principals: Union[Sequence[str], Sequence[int]] = []
13791476
) -> Dict[str, Any]:
13801477
"""
13811478
See examples/unsubscribe for example usage.

0 commit comments

Comments
 (0)