Commit graph

89 commits

Author SHA1 Message Date
Eeshan Garg 8fbb3700d2 zulip-send: Use argparse-based zulip.add_default_arguments. 2017-07-29 00:17:43 -02:30
Eeshan Garg 4a76284af1 zulip/examples: Use argparse-based zulip.add_default_arguments. 2017-07-29 00:17:34 -02:30
Eeshan Garg 38df8ef87b api: Recommend migrating to argparse-based add_default_arguments(). 2017-07-29 00:04:25 -02:30
Eeshan Garg 3d0f7955b6 api: Move the API package to a dedicated subdirectory.
In order to keep all three packages (zulip, zulip_bots,
zulip_botserver) in the same repo, all package files must now
be nested one level deeper.

For instance, python-zulip-api/zulip_bots/zulip_bots/bots/, instead
of python-zulip-api/zulip_bots/bots/.
2017-07-18 02:20:32 -02:30
Eeshan Garg 928d5ca16d flask_server: Move the server to its own package. 2017-07-18 01:31:54 -02:30
Rohitt Vashishtha 9d1253ff0d lint: Make zulip/__init__.py complaint with E261. 2017-07-06 19:58:50 -04:00
vaibhav 303daf074a zulip-bot-server: Rename and move source file to api/zulip directory and
add support for running the server from any place.
2017-06-22 10:37:05 -04:00
Aditya Bansal dd4a488ee5 pep8: Add compliance with rule E261 send.py. 2017-06-04 15:05:34 +05:30
Eeshan Garg 4e0424e9ff api/setup.py: Upgrade the version to 0.3.1.
Apparently, PyPI is very strict about package file names. Once you
upload files for 0.3.0, and only wish to make minor changes and
re-release it as the same version, it doesn't let you and complains
about identical file names.
2017-05-30 22:25:14 -07:00
Eeshan Garg 2063e5b3c4 api: Increase the version from 0.2.5 to 0.3.0. 2017-05-29 20:09:59 -07:00
Eeshan Garg 7f81f6b7e5 api: If there is no $HOME, assume .zuliprc doesn't exist. 2017-05-29 20:09:57 -07:00
Eeshan Garg 2d785ea3d1 api: Use the console_scripts entry point to point to zulip-send.
Instead of using the `scripts` keyword, we now use the
`console_scripts` entry point to point to the zulip-send script
to be installed. This is what the Python Packaging User Guide
recommends for better cross-platform compatibility.
2017-05-22 18:08:18 -07:00
Jordan Gedney f124531a88 mypy: Add type: ignores for optparse.OptionGroup.
Typeshed has already fixed this upstream (Description is optional)
2017-05-22 14:40:48 -07:00
Aditya Bansal 5605dfb6b1 pep8: Add compliance with rule E261 to api/zulip/__init__.py. 2017-05-07 23:21:50 -07:00
Raghav Jajodia 58f5e729b6 mypy: Added Dict, List and Set imports.
Fixed mypy errors associated with the upgrade.
2017-03-04 14:33:44 -08:00
Tim Abbott ca5fa6c9de mypy: Remove now-unused type: ignores. 2017-02-18 17:01:01 -08:00
Tim Abbott a87ae4b1c4 api: Add bindings for new get_presence endpoint. 2017-02-10 23:52:56 -08:00
Rohitt Vashishtha 863df67150 api: Add support for Environment Variables.
This adds support for controlling the basic configuration (user, API
key, etc.) of the Zulip API bindings via environment variables.

Fixes #3364.

Tweaked by tabbott to update variable names and document in README.md.
2017-02-06 22:56:59 -08:00
Steve Howell 39becef8c0 Fix update_message() in our API.
This was regressed in b3df1ddeb1bbf67695a673278ae3c4a3e7c9ae99.
2017-01-25 16:33:19 -08:00
Tim Abbott 722fc56534 lint: Clean up E126 PEP-8 rule. 2017-01-23 22:06:13 -08:00
Tim Abbott 55e8d5f58d lint: Clean up E123 PEP-8 rule. 2017-01-23 21:34:26 -08:00
Tim Abbott 2f0bc3dc69 lint: Clean up E306 PEP-8 rule. 2017-01-23 21:05:08 -08:00
Tim Abbott 07cdd69e42 lint: Clean up W503 PEP-8 warning. 2017-01-23 20:50:04 -08:00
Sampriti Panda 16b1be15c0 urls: Move /messages/render to POST endpoint 2017-01-13 16:11:51 -08:00
Rafid Aslam 229471c70f Change error handling in get_subscribers() in Zulip API client.
Fixes #3281.
2017-01-13 07:14:50 -08:00
Rafid Aslam 6972ce61c8 Move endpoints to use stream_id instead of stream_name in their URLs
- Change `stream_name` into `stream_id` on some API endpoints that use
`stream_name` in their URLs to prevent confusion of `views` selection.

For example:
If the stream name is "foo/members", the URL would be trigger
"^streams/(?P<stream_name>.*)/members$" and it would be confusing because
we intend to use the endpoint with "^streams/(?P<stream_name>.*)$" regex.

All stream-related endpoints now use stream id instead of stream name,
except for a single endpoint that lets you convert stream names to stream ids.

See https://github.com/zulip/zulip/issues/2930#issuecomment-269576231

- Add `get_stream_id()` method to Zulip API client, and change
`get_subscribers()` method to comply with the new stream API
(replace `stream_name` with `stream_id`).

Fixes #2930.
2017-01-12 15:23:31 -08:00
Yago González cb6ae09bc8 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
Jackson 630ee0be92 Clean PUT /users to POST /users 2017-01-03 15:40:00 -08:00
Rishi Gupta eb983e0bbc mypy: Convert api/ and docs/ to use typing.Text. 2016-12-26 16:11:37 -08:00
Steve Howell 14ee40bf52 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
Steve Howell 0272d6abe7 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
reallyly 9d6e7cfea5 pep8: Fix E128 violations.
With some line-wrapping tweaks by tabbott.
2016-12-13 10:50:14 -08:00
bulat22101 47488217b1 pep8: Fix E129 violations 2016-12-03 10:56:36 -08:00
bulat22101 dc48a41efe pep8: Fix E502 violations 2016-12-03 10:56:36 -08:00
Juan Verhook 25a8315f71 Annotate api/zulip/__init__.py.
Note that we still can't run mypy against this file and other files,
because of how the interface is dynamically created via _register.  We
will need to change that or use a stub file to make it possible to
annotate this.

This was tweaked by tabbott to fix some bugs.
2016-12-02 18:26:47 -08:00
AZtheAsian 73bd3572cf pep8: Fix E111 violations 2016-12-01 14:18:11 -08:00
Rafid Aslam 1ae8ac85d8 pep8: Fix E301 pep8 violations.
Fix "E301: expected (1 or 2) blank line" pep8 violations.
2016-11-29 08:51:44 -08:00
Rafid Aslam d4410365ea pep8: Fix E225 pep8 violations. 2016-11-28 15:21:15 -08:00
umkay cac0d1c394 api: Add default protocol for localhost.
Add default "http://" to site argument locally if it is not specified
in an api call.

This fixes a problem where if you didn't manually specify `http://`
when connecting to a development server, the API bindings would hang
trying to connect using HTTPS.
2016-11-03 18:09:26 -07:00
reyha 4cdc59a3e4 API bindings: Raise error if site param not defined.
Stops defaulting the site parameter to the now-nonexistent
https://zulip.com, and ask the user to enter the site via --site or
~/.zuliprc if not provided.

Fixes #2039.
2016-10-25 18:08:46 -07:00
Alex Dehnert ad94b57e2f Add support for client certs to the Python API.
This adds support for passing a client cert (in the format expected by the
`requests` library) to the `Client` constructor, as well as for specifying
one on the command line or in .zuliprc (through new `client_cert` and
`client_cert_key` options).
2016-07-19 14:40:26 -07:00
Taranjeet 6034ae7b9a Wrap some lines with length greater than 120.
With some tweaks by tabbott.
2016-07-06 14:35:16 -07:00
Eklavya Sharma d198eedbcd api/zulip/__init__.py: Make compatible with newer mypy. 2016-06-27 21:00:09 +05:30
Nathan Florea b2c73d5346 Changed make_request lambda to more readable function. 2016-06-03 09:17:04 -07:00
Nathan Florea 25d7e844a2 api: Remove some mutable default arguments.
This could be more succinct with a conditional expression, but this is
easier to read.
2016-06-03 09:16:52 -07:00
Eklavya Sharma 03adee4c19 Make api/zulip/__init__.py pass mypy check. 2016-05-18 17:10:17 +05:30
Eklavya Sharma 5e3013d2c2 Partially apply Python 3 libmodernize.fixes.fix_dict_six.
Refer to #256
2016-03-19 15:52:58 -07:00
Tim Abbott a8c4facc67 Switch to using Python 3 style division everywhere.
Also add testing for this to our Python 3 compatibility test suite.
2016-01-26 21:09:43 -08:00
Tim Abbott 4dc5761ce2 Switch all urllib/urlparse usage to six.moves.urllib.
This provides Python 2+3 compatibility for our use of urllib.

Also add a test to avoid future regressions.
2016-01-26 21:09:43 -08:00
Tim Abbott 91d851c448 Apply modernize transform libmodernize.fixes.fix_file.
This replaces use of file() with open() which is python 3 compatible,
and also adds it to our python 3 support test suite.
2016-01-26 21:09:42 -08:00