api: Implement DELETE /messages/<message_id>.

This commit is contained in:
Yago González 2018-06-26 16:13:26 +02:00 committed by Eeshan Garg
parent 005829192e
commit e2f379675b
2 changed files with 32 additions and 0 deletions

View file

@ -728,6 +728,16 @@ class Client(object):
request=message_data,
)
def delete_message(self, message_id):
# type: (Dict[str, Any]) -> Dict[str, Any]
'''
See examples/delete-message for example usage.
'''
return self.call_endpoint(
url='messages/{}'.format(message_id),
method='DELETE'
)
def get_events(self, **request):
# type: (**Any) -> Dict[str, Any]
'''

View file

@ -0,0 +1,22 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import argparse
import zulip
usage = """delete-message <message_id> [options]
Please note that an administrator user is required for this example.
Example: delete-message 42
"""
parser = zulip.add_default_arguments(argparse.ArgumentParser(usage=usage))
parser.add_argument('message_id', type=int)
options = parser.parse_args()
client = zulip.init_from_options(options)
print(client.delete_message(options.message_id))