[manual] Uniformize the subscriptions API method names.

This requires a zephyr_mirror deployment when it is pushed to prod.

(imported from commit 6543441fb264b518f8705d7989d068a1d50ce5d6)
This commit is contained in:
Tim Abbott 2012-11-16 13:40:03 -05:00
parent b251d064f9
commit afc62a8e16
7 changed files with 18 additions and 18 deletions

View File

@ -495,7 +495,7 @@ def add_humbug_subscriptions(verbose):
zephyr_subscriptions.add(cls) zephyr_subscriptions.add(cls)
if len(zephyr_subscriptions) != 0: if len(zephyr_subscriptions) != 0:
res = humbug_client.subscribe(list(zephyr_subscriptions)) res = humbug_client.add_subscriptions(list(zephyr_subscriptions))
if res.get("result") != "success": if res.get("result") != "success":
print "Error subscribing to streams:" print "Error subscribing to streams:"
print res["msg"] print res["msg"]

View File

@ -103,12 +103,12 @@ class HumbugAPI():
def get_public_streams(self, request = {}): def get_public_streams(self, request = {}):
return self.do_api_query(request, "/api/v1/get_public_streams") return self.do_api_query(request, "/api/v1/get_public_streams")
def get_subscriptions(self, request = {}): def list_subscriptions(self, request = {}):
return self.do_api_query(request, "/api/v1/get_subscriptions") return self.do_api_query(request, "/api/v1/subscriptions/list")
def subscribe(self, streams): def add_subscriptions(self, streams):
request = {'streams': streams} request = {'streams': streams}
return self.do_api_query(request, "/api/v1/subscribe") return self.do_api_query(request, "/api/v1/subscriptions/add")
def call_on_each_message(self, callback, options = {}): def call_on_each_message(self, callback, options = {}):
max_message_id = None max_message_id = None

View File

@ -3,11 +3,11 @@ import sys
import os import os
import optparse import optparse
usage = """get-subscriptions --user=<email address> [options] usage = """list-subscriptions --user=<email address> [options]
Prints out a list of the user's subscriptions. Prints out a list of the user's subscriptions.
Example: get-subscriptions --user=tabbott@humbughq.com --site=http://127.0.0.1:8000 Example: list-subscriptions --user=tabbott@humbughq.com --site=http://127.0.0.1:8000
""" """
parser = optparse.OptionParser(usage=usage) parser = optparse.OptionParser(usage=usage)
parser.add_option('--site', parser.add_option('--site',
@ -30,4 +30,4 @@ client = api.common.HumbugAPI(email=options.user,
verbose=True, verbose=True,
site=options.site) site=options.site)
print client.get_subscriptions() print client.list_subscriptions()

View File

@ -38,4 +38,4 @@ if options.streams == "":
print >>sys.stderr, "Usage:", parser.usage print >>sys.stderr, "Usage:", parser.usage
sys.exit(1) sys.exit(1)
print client.subscribe(options.streams.split()) print client.add_subscriptions(options.streams.split())

View File

@ -40,7 +40,7 @@ urlpatterns = patterns('',
url(r'^json/send_message$', 'zephyr.views.json_send_message'), url(r'^json/send_message$', 'zephyr.views.json_send_message'),
url(r'^json/settings/change$', 'zephyr.views.json_change_settings'), url(r'^json/settings/change$', 'zephyr.views.json_change_settings'),
url(r'^json/subscriptions/list$', 'zephyr.views.json_list_subscriptions'), url(r'^json/subscriptions/list$', 'zephyr.views.json_list_subscriptions'),
url(r'^json/subscriptions/remove$', 'zephyr.views.json_remove_subscription'), url(r'^json/subscriptions/remove$', 'zephyr.views.json_remove_subscriptions'),
url(r'^json/subscriptions/add$', 'zephyr.views.json_add_subscriptions'), url(r'^json/subscriptions/add$', 'zephyr.views.json_add_subscriptions'),
url(r'^json/subscriptions/exists$', 'zephyr.views.json_stream_exists'), url(r'^json/subscriptions/exists$', 'zephyr.views.json_stream_exists'),
url(r'^json/fetch_api_key$', 'zephyr.views.json_fetch_api_key'), url(r'^json/fetch_api_key$', 'zephyr.views.json_fetch_api_key'),
@ -50,8 +50,8 @@ urlpatterns = patterns('',
url(r'^api/v1/get_messages$', 'zephyr.views.api_get_messages'), url(r'^api/v1/get_messages$', 'zephyr.views.api_get_messages'),
url(r'^api/v1/get_old_messages$', 'zephyr.views.api_get_old_messages'), url(r'^api/v1/get_old_messages$', 'zephyr.views.api_get_old_messages'),
url(r'^api/v1/get_public_streams$', 'zephyr.views.api_get_public_streams'), url(r'^api/v1/get_public_streams$', 'zephyr.views.api_get_public_streams'),
url(r'^api/v1/get_subscriptions$', 'zephyr.views.api_get_subscriptions'), url(r'^api/v1/subscriptions/list$', 'zephyr.views.api_list_subscriptions'),
url(r'^api/v1/subscribe$', 'zephyr.views.api_subscribe'), url(r'^api/v1/subscriptions/add$', 'zephyr.views.api_add_subscriptions'),
url(r'^api/v1/send_message$', 'zephyr.views.api_send_message'), url(r'^api/v1/send_message$', 'zephyr.views.api_send_message'),
url(r'^api/v1/update_pointer$', 'zephyr.views.api_update_pointer'), url(r'^api/v1/update_pointer$', 'zephyr.views.api_update_pointer'),

View File

@ -121,8 +121,8 @@ class PublicURLTest(TestCase):
302: ["/", "/accounts/logout/"], 302: ["/", "/accounts/logout/"],
400: ["/accounts/register/", 400: ["/accounts/register/",
"/api/v1/get_public_streams", "/api/v1/get_public_streams",
"/api/v1/get_subscriptions", "/api/v1/subscriptions/list",
"/api/v1/subscribe", "/api/v1/subscriptions/add",
"/api/v1/send_message", "/api/v1/send_message",
"/api/v1/fetch_api_key", "/api/v1/fetch_api_key",
"/json/fetch_api_key", "/json/fetch_api_key",

View File

@ -701,7 +701,7 @@ def gather_subscriptions(user_profile):
if sub.recipient.type == Recipient.STREAM) if sub.recipient.type == Recipient.STREAM)
@authenticated_api_view @authenticated_api_view
def api_get_subscriptions(request, user_profile): def api_list_subscriptions(request, user_profile):
return json_success({"streams": gather_subscriptions(user_profile)}) return json_success({"streams": gather_subscriptions(user_profile)})
@authenticated_json_view @authenticated_json_view
@ -710,7 +710,7 @@ def json_list_subscriptions(request, user_profile):
@authenticated_json_view @authenticated_json_view
@has_request_variables @has_request_variables
def json_remove_subscription(request, user_profile, def json_remove_subscriptions(request, user_profile,
sub_name=POST("subscription")): sub_name=POST("subscription")):
stream = get_stream(sub_name, user_profile.realm) stream = get_stream(sub_name, user_profile.realm)
if not stream: if not stream:
@ -725,7 +725,7 @@ def valid_stream_name(name):
return name != "" return name != ""
@authenticated_api_view @authenticated_api_view
def api_subscribe(request, user_profile): def api_add_subscriptions(request, user_profile):
return add_subscriptions_backend(request, user_profile) return add_subscriptions_backend(request, user_profile)
@authenticated_json_view @authenticated_json_view