-
-
Notifications
You must be signed in to change notification settings - Fork 379
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
api: Encoded certain api endpoint parameters.
Rectified the parameters in certain api endpoints to , take up default parameters rather than a dictionary. Affected endpoints : GET get_profile POST update_presence GET get_users GET get_members GET list_subscriptions PATCH mute_topic POST render_message POST create_user PUT update_storage GET get_storage POST set_typing_status As discussed within zulip/zulip#16698
- Loading branch information
1 parent
f2d80c6
commit f1a8470
Showing
1 changed file
with
53 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1072,17 +1072,20 @@ def deregister(self, queue_id: str, timeout: Optional[float] = None) -> Dict[str | |
timeout=timeout, | ||
) | ||
|
||
def get_profile(self, request: Optional[Dict[str, Any]] = None) -> Dict[str, Any]: | ||
def get_profile(self, request: Optional[Dict[str, Any]] = None, **kwargs: Any) -> Dict[str, Any]: | ||
''' | ||
Example usage: | ||
>>> client.get_profile() | ||
{u'user_id': 5, u'full_name': u'Iago', u'short_name': u'iago', ...} | ||
''' | ||
if request is not None: | ||
logging.warning('Passing parameters as a dictionary will be deprecated in future versions.') | ||
|
||
return self.call_endpoint( | ||
url='users/me', | ||
method='GET', | ||
request=request, | ||
request=request or kwargs, | ||
) | ||
|
||
def get_user_presence(self, email: str) -> Dict[str, Any]: | ||
|
@@ -1109,21 +1112,24 @@ def get_realm_presence(self) -> Dict[str, Any]: | |
method='GET', | ||
) | ||
|
||
def update_presence(self, request: Dict[str, Any]) -> Dict[str, Any]: | ||
def update_presence(self, request: Dict[str, Any] = None, **kwargs: Any) -> Dict[str, Any]: | ||
''' | ||
Example usage: | ||
>>> client.update_presence({ | ||
status='active', | ||
:='active', | ||
ping_only=False, | ||
new_user_input=False, | ||
}) | ||
{'result': 'success', 'server_timestamp': 1333649180.7073195, 'presences': {'[email protected]': { ... }}, 'msg': ''} | ||
''' | ||
if request is not None: | ||
logging.warning('Passing parameters as a dictionary will be deprecated in future versions.') | ||
|
||
return self.call_endpoint( | ||
url='users/me/presence', | ||
method='POST', | ||
request=request, | ||
request=request or kwargs, | ||
) | ||
|
||
def get_streams(self, **request: Any) -> Dict[str, Any]: | ||
|
@@ -1228,22 +1234,25 @@ def update_user_by_id(self, user_id: int, **request: Any) -> Dict[str, Any]: | |
request=request | ||
) | ||
|
||
def get_users(self, request: Optional[Dict[str, Any]] = None) -> Dict[str, Any]: | ||
def get_users(self, request: Optional[Dict[str, Any]] = None, **kwargs: Any) -> Dict[str, Any]: | ||
''' | ||
See examples/list-users for example usage. | ||
''' | ||
if request is not None: | ||
logging.warning('Passing parameters as a dictionary will be deprecated in future versions.') | ||
|
||
return self.call_endpoint( | ||
url='users', | ||
method='GET', | ||
request=request, | ||
request=request or kwargs, | ||
) | ||
|
||
def get_members(self, request: Optional[Dict[str, Any]] = None) -> Dict[str, Any]: | ||
def get_members(self, request: Optional[Dict[str, Any]] = None, **kwargs: Any) -> 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. | ||
return self.get_users(request=request) | ||
return self.get_users(request=request, **kwargs) | ||
|
||
def get_alert_words(self) -> Dict[str, Any]: | ||
''' | ||
|
@@ -1278,14 +1287,17 @@ def remove_alert_words(self, alert_words: List[str]) -> Dict[str, Any]: | |
} | ||
) | ||
|
||
def list_subscriptions(self, request: Optional[Dict[str, Any]] = None) -> Dict[str, Any]: | ||
def list_subscriptions(self, request: Optional[Dict[str, Any]] = None, **kwargs: Any) -> Dict[str, Any]: | ||
''' | ||
See examples/list-subscriptions for example usage. | ||
''' | ||
if request is not None: | ||
logging.warning('Passing parameters as a dictionary will be deprecated in future versions.') | ||
|
||
return self.call_endpoint( | ||
url='users/me/subscriptions', | ||
method='GET', | ||
request=request, | ||
request=request or kwargs, | ||
) | ||
|
||
def add_subscriptions(self, streams: Iterable[Dict[str, Any]], **kwargs: Any) -> Dict[str, Any]: | ||
|
@@ -1329,14 +1341,17 @@ def get_subscription_status(self, user_id: int, stream_id: int) -> Dict[str, Any | |
method='GET', | ||
) | ||
|
||
def mute_topic(self, request: Dict[str, Any]) -> Dict[str, Any]: | ||
def mute_topic(self, request: Dict[str, Any] = None, **kwargs: Any) -> Dict[str, Any]: | ||
''' | ||
See examples/mute-topic for example usage. | ||
''' | ||
if request is not None: | ||
logging.warning('Passing parameters as a dictionary will be deprecated in future versions.') | ||
|
||
return self.call_endpoint( | ||
url='users/me/subscriptions/muted_topics', | ||
method='PATCH', | ||
request=request | ||
request=request or kwargs, | ||
) | ||
|
||
def update_subscription_settings(self, subscription_data: List[Dict[str, Any]]) -> Dict[str, Any]: | ||
|
@@ -1486,44 +1501,53 @@ def get_subscribers(self, **request: Any) -> Dict[str, Any]: | |
request=request, | ||
) | ||
|
||
def render_message(self, request: Optional[Dict[str, Any]] = None) -> Dict[str, Any]: | ||
def render_message(self, request: Optional[Dict[str, Any]] = None, **kwargs: Any) -> Dict[str, Any]: | ||
''' | ||
Example usage: | ||
>>> client.render_message(request=dict(content='foo **bar**')) | ||
{u'msg': u'', u'rendered': u'<p>foo <strong>bar</strong></p>', u'result': u'success'} | ||
''' | ||
if request is not None: | ||
logging.warning('Passing parameters as a dictionary will be deprecated in future versions.') | ||
|
||
return self.call_endpoint( | ||
url='messages/render', | ||
method='POST', | ||
request=request, | ||
request=request or kwargs, | ||
) | ||
|
||
def create_user(self, request: Optional[Dict[str, Any]] = None) -> Dict[str, Any]: | ||
def create_user(self, request: Optional[Dict[str, Any]] = None, **kwargs: Any) -> Dict[str, Any]: | ||
''' | ||
See examples/create-user for example usage. | ||
''' | ||
if request is not None: | ||
logging.warning('Passing parameters as a dictionary will be deprecated in future versions.') | ||
|
||
return self.call_endpoint( | ||
method='POST', | ||
url='users', | ||
request=request, | ||
request=request or kwargs, | ||
) | ||
|
||
def update_storage(self, request: Dict[str, Any]) -> Dict[str, Any]: | ||
def update_storage(self, request: Dict[str, Any] = None, **kwargs: Any) -> Dict[str, Any]: | ||
''' | ||
Example usage: | ||
>>> client.update_storage({'storage': {"entry 1": "value 1", "entry 2": "value 2", "entry 3": "value 3"}}) | ||
>>> client.get_storage({'keys': ["entry 1", "entry 3"]}) | ||
{'result': 'success', 'storage': {'entry 1': 'value 1', 'entry 3': 'value 3'}, 'msg': ''} | ||
''' | ||
if request is not None: | ||
logging.warning('Passing parameters as a dictionary will be deprecated in future versions.') | ||
|
||
return self.call_endpoint( | ||
url='bot_storage', | ||
method='PUT', | ||
request=request, | ||
request=request or kwargs, | ||
) | ||
|
||
def get_storage(self, request: Optional[Dict[str, Any]] = None) -> Dict[str, Any]: | ||
def get_storage(self, request: Optional[Dict[str, Any]] = None, **kwargs: Any) -> Dict[str, Any]: | ||
''' | ||
Example usage: | ||
|
@@ -1533,13 +1557,16 @@ def get_storage(self, request: Optional[Dict[str, Any]] = None) -> Dict[str, Any | |
>>> client.get_storage({'keys': ["entry 1", "entry 3"]}) | ||
{'result': 'success', 'storage': {'entry 1': 'value 1', 'entry 3': 'value 3'}, 'msg': ''} | ||
''' | ||
if request is not None: | ||
logging.warning('Passing parameters as a dictionary will be deprecated in future versions.') | ||
|
||
return self.call_endpoint( | ||
url='bot_storage', | ||
method='GET', | ||
request=request, | ||
request=request or kwargs, | ||
) | ||
|
||
def set_typing_status(self, request: Dict[str, Any]) -> Dict[str, Any]: | ||
def set_typing_status(self, request: Dict[str, Any] = None, **kwargs: Any) -> Dict[str, Any]: | ||
''' | ||
Example usage: | ||
>>> client.set_typing_status({ | ||
|
@@ -1548,10 +1575,13 @@ def set_typing_status(self, request: Dict[str, Any]) -> Dict[str, Any]: | |
}) | ||
{'result': 'success', 'msg': ''} | ||
''' | ||
if request is not None: | ||
logging.warning('Passing parameters as a dictionary will be deprecated in future versions.') | ||
|
||
return self.call_endpoint( | ||
url='typing', | ||
method='POST', | ||
request=request | ||
request=request or kwargs, | ||
) | ||
|
||
def move_topic( | ||
|