From e2f379675b61f0ddf6ff3ff3c2bc901747c41431 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yago=20Gonz=C3=A1lez?= Date: Tue, 26 Jun 2018 16:13:26 +0200 Subject: [PATCH] api: Implement DELETE /messages/. --- zulip/zulip/__init__.py | 10 ++++++++++ zulip/zulip/examples/delete-message | 22 ++++++++++++++++++++++ 2 files changed, 32 insertions(+) create mode 100755 zulip/zulip/examples/delete-message diff --git a/zulip/zulip/__init__.py b/zulip/zulip/__init__.py index ba8d243..995e623 100644 --- a/zulip/zulip/__init__.py +++ b/zulip/zulip/__init__.py @@ -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] ''' diff --git a/zulip/zulip/examples/delete-message b/zulip/zulip/examples/delete-message new file mode 100755 index 0000000..3429bd0 --- /dev/null +++ b/zulip/zulip/examples/delete-message @@ -0,0 +1,22 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +import argparse + +import zulip + +usage = """delete-message [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))