Skip to content

zulip/__init__.py: Adds delete_topic method #603

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions zulip/zulip/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -800,6 +800,16 @@ def mark_topic_as_read(self, stream_id: int, topic_name: str) -> Dict[str, Any]:
},
)

def delete_topic(self, stream_id: int, topic_name: str) -> Dict[str, Any]:
'''
See examples/delete-topic for example usage.
'''
return self.call_endpoint(
url='/streams/{}/delete_topic'.format(stream_id),
method='POST',
request={'topic_name': topic_name}
)

def get_message_history(self, message_id: int) -> Dict[str, Any]:
'''
See examples/message-history for example usage.
Expand Down
21 changes: 21 additions & 0 deletions zulip/zulip/examples/delete-topic
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/usr/bin/env python3

import argparse
import zulip


usage = """delete-topic <stream_id/stream_name, topic_name>

Example: delete-topic 1 "Denmark1" or "Denmark" "Denmark1"
"""

parser = zulip.add_default_arguments(argparse.ArgumentParser(usage=usage))
parser.add_argument('stream_id')
parser.add_argument('topic_name', type=str)
options = parser.parse_args()

client = zulip.init_from_options(options)
if (type(options.stream_id) == str):
Copy link
Contributor

@akashaviator akashaviator Jun 23, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Pradhvan Have you tried manually testing this ? I am getting an error while trying to pass a stream id (i.e. int) as argument. Seems like it treats it as a string.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@akashaviator let me try manually testing it. 😄

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Pradhvan have you tested this?

If you don't have time, can @akashaviator take over finishing this?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@timabbott sorry for the delay. I will test and update this. So that @akashaviator can review and merge this.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@akashaviator can you take this over? Sorry but I am bit stuck on things and won't be able to give this time.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since it's not merged, I can take this up again. @akashaviator

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Pradhvan are you working on this? Just asking since i did not see it claimed. Thanks!

options.stream_id = client.get_stream_id(options.stream_id)

print(client.delete_topic(options.stream_id.get("stream_id"), options.topic_name))