From 817636cbc62e1eb0b25de4eb78af9c0b3ec724d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yago=20Gonz=C3=A1lez?= Date: Mon, 14 May 2018 19:45:41 +0200 Subject: [PATCH] api: Implement /users/me//topics. --- zulip/zulip/__init__.py | 10 ++++++++++ zulip/zulip/examples/get-stream-topics | 19 +++++++++++++++++++ 2 files changed, 29 insertions(+) create mode 100755 zulip/zulip/examples/get-stream-topics diff --git a/zulip/zulip/__init__.py b/zulip/zulip/__init__.py index f78858f..ddafda8 100644 --- a/zulip/zulip/__init__.py +++ b/zulip/zulip/__init__.py @@ -848,6 +848,16 @@ class Client(object): request=None, ) + def get_stream_topics(self, stream_id): + # type: (int) -> Dict[str, Any] + ''' + See examples/get-stream-topics for example usage. + ''' + return self.call_endpoint( + url='users/me/{}/topics'.format(stream_id), + method='GET' + ) + def get_subscribers(self, **request): # type: (**Any) -> Dict[str, Any] ''' diff --git a/zulip/zulip/examples/get-stream-topics b/zulip/zulip/examples/get-stream-topics new file mode 100755 index 0000000..8fc8616 --- /dev/null +++ b/zulip/zulip/examples/get-stream-topics @@ -0,0 +1,19 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +import argparse + +usage = """get-stream-topics --stream-id= [options] + +Get all the topics for a specific stream. +""" + +import zulip + +parser = zulip.add_default_arguments(argparse.ArgumentParser(usage=usage)) +parser.add_argument('--stream-id', required=True) +options = parser.parse_args() + +client = zulip.init_from_options(options) + +print(client.get_stream_topics(options.stream_id))