Commit Graph

82 Commits

Author SHA1 Message Date
Tim Abbott ffc24e9f66 api: Add bindings for new get_presence endpoint. 2017-02-10 23:52:56 -08:00
Tim Abbott 4e171ce787 lint: Clean up E126 PEP-8 rule. 2017-01-23 22:06:13 -08:00
Tim Abbott d6e38e2a5c lint: Clean up E123 PEP-8 rule. 2017-01-23 21:34:26 -08:00
Tim Abbott 9cc83f87fc lint: Clean up E241 PEP-8 rule. 2017-01-23 21:21:14 -08:00
JefftheBest1 f0afa3e8df Fixed typos with receive 2017-01-12 04:52:44 -08:00
Yago González 25dbe35747 api: Support file uploads to the API.
Now, the `Client.do_api_query()` method supports sending files to the
API.

This has allowed the implementation of a new method,
`Client.upload_file(file)`.  It simply uploads the file set in the
parameter, and returns the API's response (that includes the URI).

Despite the fact that `do_api_query()` supports multiple files as
parameters, `upload_file()` doesn't, because right now the API isn't
capable of managing more than a file in the same request.
2017-01-10 17:46:00 -08:00
Steve Howell efc2d1a675 Simplify, document, and fix the API code.
We used to create endpoints with Client._register.

Now we now have explicit methods for the endpoints.

This allows us to add docstrings and stricter mypy annotations.

This fix also introduces a call_endpoint() method that avoids
the need for manually building urls with API_VERSTRING when you
know the URL pattern of the endpoint you want to hit (and when
the API doesn't have a convenient wrapper).

I fixed a bug with create_users where it now uses PUT instead
of POST.

I also removed client.export(), which was just broken.

I had to change recent-messages and zulip-export, which were
using client.do_api_query and Client._register.

Now it's easier to just call client.call_endpoint() for
situations where our API doesn't have convenient wrappers,
so that's what I did with those scripts.
2016-12-21 11:22:42 -08:00
Tim Abbott e1ed8e61d8 api: remove use of zulip.com domain in API bindings. 2016-12-15 09:35:37 -08:00
Steve Howell 0c49cebe86 Remove deprecated get_messages() API.
This also eliminates a very short script that basically
does nothing but call the long-dead API, so there's not
much to salvage there.
2016-12-13 20:33:20 -08:00
Tim Abbott 400e3b7dba Annotate API scripts. 2016-10-15 22:36:10 -07:00
Eklavya Sharma 149938d468 Change shebangs from python2.7 to python. 2016-05-29 05:03:08 -07:00
Ashish 2050f5c7fa Add API example for fetching historical messages.
Fixes: #269.
2016-03-29 19:04:43 -07:00
Eklavya Sharma c59185e119 Apply Python 3 futurize transform libfuturize.fixes.fix_print_with_import
Refer #256
2016-03-10 22:02:17 -08:00
Steven Oud d5435fad1d Consistently use /usr/bin/env python2.7 in shebangs and commands. 2015-10-21 22:58:21 +00:00
Tim Abbott b3dfacae19 Change API example usernames to use example.com domain.
(imported from commit 41b7be58735df0ea3d3a3daf23bc0f78606abc0d)
2015-09-19 18:12:02 -07:00
Tim Abbott eca3c3bfaa Add api/examples/print-events.
(imported from commit 8c0e3f7809f06e4aff3bd8c0640479819853c418)
2015-09-19 18:05:21 -07:00
Jessica McKellar da757b7195 Update copyright to 2014.
(imported from commit 733baed61e26be0c07a7e7a605618087df6b0866)
2014-02-04 15:51:53 -05:00
Tim Abbott 6721c465c9 Add admin API endpoint for creating users.
(imported from commit a8b919c7d21b28dfd75b6b95736a375874ead15f)
2013-12-10 13:21:33 -05:00
Tim Abbott 02304ca4a0 Remove api/examples/curl-examples.
It's out of date and we've never distributed it anyway.

(imported from commit 884e302ea4f55f9b3f986694a786cc5c17128e71)
2013-12-04 15:10:54 -05:00
Tim Abbott 901a5c342c Use os.path directly rather than sometimes importing it separately.
(imported from commit 48486c4ea64d02a15faeebb0f490d31e9b113d62)
2013-10-28 15:44:13 -04:00
acrefoot c5f8ffc767 Make call_on_each_{message,event} examples more clear
Before these examples weren't obviously blocking calls (they seemed
more like a callback registration, which may make more sense in the future)

(imported from commit 78fdf98d791b19843526437c710901d8dff62e8c)
2013-09-24 16:19:54 -04:00
Tim Abbott f5f95e5f43 [manual] Extend /api/v1/streams API endpoint.
Previously it only provided the list of all public streams; now it
allows one to specify any union of some of the following:
* all public streams
* all streams the user subscribed to

(the most relevant being the union of those two, which is what we want
for the "streams" page).

Or:
* all streams in realm (superuser only)

The manual task required is that when this is pushed to prod, we need
to also deploy the new sync-public-streams version to zmirror.

(imported from commit 27848b8bd136e2777f399b7d05b2fdcec35e4e21)
2013-08-22 12:29:04 -04:00
Tim Abbott 747a9c536f Rename the 'humbug' API module to 'zulip'.
(imported from commit b3a3d7c05459cbb0110cd0fbe2197d779f3a6264)
2013-08-08 10:22:31 -04:00
Tim Abbott 2ea1bb05a5 Rename ~/.humbugrc to ~/.zuliprc.
(imported from commit a0d53dd20097a56971874dc1d84c6f95267e84f2)
2013-08-08 10:22:31 -04:00
Tim Abbott 1f1af26048 Change Humbug => Zulip in text/comments.
(imported from commit 2f9d73431ae40e1b9e9e11bc2f4f62f566ae758a)
2013-08-07 10:00:07 -04:00
Tim Abbott 975f4aa59f api: Fix path in send_message example.
(imported from commit 6aab581bf00736986ffcd11042c757eff0c78653)
2013-07-25 17:27:46 -04:00
Tim Abbott 0d077e7f41 [manual] Use api.zulip.com to access the Humbug API.
This needs to be deployed after the nginx configuration is deployed.

(imported from commit 167a3d9d27595d40883bb400ebcc44c4ad9b6a2f)
2013-07-25 17:27:46 -04:00
Tim Abbott bcf86cae98 Switch Humbug users in API examples to zulip.com email addresses.
(imported from commit 83abeafee8d7d146d950c3049568acbf51bb3a12)
2013-07-25 17:19:18 -04:00
Tim Abbott ea8a80603a [manual] Change API URLs to be based on api.humbughq.com/api.
This must be deployed after we update our running nginx configuration
to serve api.humbughq.com.

(imported from commit b5c34ebdd595f55eecd6dca6a18a37f105107bd5)
2013-06-28 15:57:27 -04:00
Tim Abbott 1ec0ee0fd6 [manual] API add_subscriptions: Change arguments to support options.
Since in the future we might want requests to add subscriptions to
include things like colors, in_home_view, etc., we're changing the
data format for the add_subscriptions API call to pass each stream as
a dictionary, giving a convenient place to put any added options.

The manual step required here is updating the API version in AFS
available for use with the zephyr_mirror.py system.

(imported from commit 364960cca582a0658f0d334668822045c001b92c)
2013-06-25 16:34:45 -04:00
Tim Abbott 2a9498dfd3 API: Use humbug.init_from_options in send-message example.
(imported from commit d44cd5fafa565b2f4709714c2777ad9ce513d953)
2013-06-25 16:34:44 -04:00
Tim Abbott ce50812bca API get_members: Return a dictionary of users, not a list of tuples.
I believe this should require no special work on deploy, since some
grepping of logs suggests we are not currently using this API query.

(imported from commit 240086f900c6680cbc90bf6a2f334a9e1f172df6)
2013-06-25 16:34:43 -04:00
acrefoot b20eb5621f [api version bump] Update API documentation in the example scripts
Give better examples, and rewrite options parsing to be more consistent across examples.
Make it more obvious that you can use "--user" and "--api-key" with our python examples.

This bumps our python bindings to v0.1.9

(imported from commit 297468088f864b7d585e567dc45523ea681f1856)
2013-06-05 17:34:41 -04:00
Tim Abbott d467a93877 Add support for updating messages after they've been received.
Currently the interface for editing messages is limited to a
command-line API tool; it's great for testing with e.g.:

./api/examples/edit-message --message=348135 --content="test $(date +%s)" --site=http://localhost:9991 --subject="test"

The next commit will add a user interface for actually doing the editing.

(imported from commit bdd408cec2946f31c2292e44f724f96ed5938791)
2013-05-20 23:40:26 -04:00
Zev Benjamin d12a6b8506 Remove the use of "--site" from the example scripts' usage text
Now that we're distributing these examples, we shouldn't be promoting
the use of the "--site" option.

(imported from commit 01ded4a851dc799fa6c7e902e937c4331ed92bf8)
2013-04-01 13:05:57 -04:00
Zev Benjamin a326eb2c48 Fix subscribe/unsubscribe example help text
(imported from commit 886066daa80b377b71b19f992d6733d87bc4d9d3)
2013-04-01 13:05:57 -04:00
Keegan McAllister 56d183ea06 Remove lurk mode from web client and API examples
See #796.

(imported from commit e238ce571c3f30d8312b630df7048ad1d9cad6d2)
2013-02-21 15:11:10 -05:00
Keegan McAllister 75704ad1e8 Consistently use #!/usr/bin/env python
At Ksplice we used /usr/bin/python because we shipped dependencies as Debian /
Red Hat packages, which would be installed against the system Python.  We were
also very careful to use only Python 2.3 features so that even old system
Python would still work.

None of that is true at Humbug.  We expect users to install dependencies
themselves, so it's more likely that the Python in $PATH is correct.  On OS X
in particular, it's common to have five broken Python installs and there's no
expectation that /usr/bin/python is the right one.

The files which aren't marked executable are not interesting to run as scripts,
so we just remove the line there.  (In general it's common to have libraries
that can also be executed, to run test cases or whatever, but that's not the
case here.)

(imported from commit 437d4aee2c6e66601ad3334eefd50749cce2eca6)
2013-02-20 16:02:30 -05:00
Jessica McKellar 73331f1e18 api: Add a list-members example script for the /get_members query.
(imported from commit 2fc213b746eb032b98d86f933ce69e7cbe9822d1)
2013-02-11 13:45:47 -05:00
Waseem Daher 2660db7e18 api: Move integrations into their own subdirectory.
(imported from commit e1a64fbbc64e64e7a2c2fdda4cc9bc77ff3bc852)
2013-02-07 14:15:44 -05:00
Waseem Daher 8f573fac4c Simplify the Trac integration plugin options slightly.
(imported from commit 4588d70f4e7664a9ba85be7003e17d4e8f55a333)
2013-02-06 17:37:44 -05:00
Zev Benjamin b0b304e58b Add a copy of our Trac integration (with example constants) to the API examples
(imported from commit 4e7bfaf92842ae0bb24c28ae1187d83ca5c44b0e)
2013-02-06 11:45:43 -05:00
Luke Faraone 61d8183a71 Be more explicit as to where .humbugrc goes
(imported from commit 3e229d61ebfef64e29ca45cc57eca04ec207ae86)
2013-02-05 16:35:45 -05:00
Luke Faraone 57e0d37249 Move files around in the API.
Bots are not part of what we distribute, so put them in the repo root.

We also updated some of the bots to use relative path names.

(imported from commit 0471d863450712fd0cdb651f39f32e9041df52ba)
2013-02-01 15:52:28 -05:00
Luke Faraone 4463f267b3 Move the API into a subdirectory for ease of imports.
Previously, if users of our code put the API folder in their pyshared
they would have to import it as "humbug.humbug". By moving Humbug's API
into a directory named "humbug" and moving the API into __init__, you
can just "import humbug".

(imported from commit 1d2654ae57f8ecbbfe76559de267ec4889708ee8)
2013-01-16 16:55:22 -05:00
Reid Barton 3c1f08c394 Add --stream option to print-messages, print-next-message API examples
(imported from commit aeaf8a111759de59ba87fc7014be86bd13810271)
2013-01-16 14:19:05 -05:00
Luke Faraone f76ea63b77 Document humbug-send and humbugrc in README for API users
(imported from commit 9ca282d4d768f2d2a474da1209621f03147954fe)
2012-12-12 16:48:00 -05:00
Luke Faraone 2da0a2275c Switch to the option group pattern for API examples.
(imported from commit 67d0164df822a56f06d5f959297cc2efa9706001)
2012-12-12 16:48:00 -05:00
Luke Faraone 0057c04e13 Update copyright notices for consistency, use the copyright symbol.
No textual changes were made besides reflowing text and subbing © for
(C).

(imported from commit e36108ad31be6ec65325e4ac48e9fb7d17e409ff)
2012-12-12 16:48:00 -05:00
Keegan McAllister 9125489c20 Rename class HumbugAPI to Client
(imported from commit 4270f31fc5febcd9c444d0d133a1dad3860618f0)
2012-12-03 15:54:54 -05:00