Skip to content

Commit fdfcafa

Browse files
committed
zulip/__init__.py: Adds delete_topic method
Adds a method delete_topic which calls the url '/streams/stream_id/delete_topic ' with topic_name passed as data Closes #534
1 parent 396ef1d commit fdfcafa

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

zulip/zulip/__init__.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -800,6 +800,16 @@ def mark_topic_as_read(self, stream_id: int, topic_name: str) -> Dict[str, Any]:
800800
},
801801
)
802802

803+
def delete_topic(self, stream_id: int, topic_name: str) -> Dict[str, Any]:
804+
'''
805+
See examples/update-flags for example usage.
806+
'''
807+
return self.call_endpoint(
808+
url='/streams/{}/delete_topic'.format(stream_id),
809+
method='POST',
810+
request={'topic_name': topic_name}
811+
)
812+
803813
def get_message_history(self, message_id: int) -> Dict[str, Any]:
804814
'''
805815
See examples/message-history for example usage.

zulip/zulip/examples/delete-topic

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/usr/bin/env python3
2+
3+
import argparse
4+
import zulip
5+
6+
7+
usage = """delete-topic <stream_id/stream_name, topic_name>
8+
9+
Example: delete-topic 1 "Denmark1" or "Denmark" "Denmark1"
10+
"""
11+
12+
parser = zulip.add_default_arguments(argparse.ArgumentParser(usage=usage))
13+
parser.add_argument('stream_id')
14+
parser.add_argument('topic_name', type=str)
15+
options = parser.parse_args()
16+
17+
client = zulip.init_from_options(options)
18+
if (type(options.stream_id) == str):
19+
options.stream_id = client.get_stream_id(options.stream_id)
20+
21+
print(client.delete_topic(options.stream_id.get("stream_id"), options.topic_name))

0 commit comments

Comments
 (0)