Skip to content

Commit ff72f3f

Browse files
authored
Merge pull request #163 from prkumar/master
Release v0.9.0
2 parents ac0f1b2 + 5332d99 commit ff72f3f

41 files changed

Lines changed: 1341 additions & 214 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.travis.yml

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,13 @@
11
language: python
22
python:
33
- '2.7'
4-
- '3.3'
54
- '3.4'
65
- '3.5'
76
- '3.6'
87
- '3.6-dev'
98
- '3.7-dev'
109
before_script:
11-
- |
12-
if [[ $TRAVIS_PYTHON_VERSION == 3.3 ]]; then
13-
# virtualenv 16.0.0 bundles wheel 0.31.1, which drops python 3.3.* support
14-
# tox 3.0.0 drops python 3.3.* support
15-
pip install virtualenv==15.2.0 tox==2.9.1
16-
else
17-
pip install tox
18-
fi
10+
- pip install tox
1911
- if [[ $TRAVIS_PYTHON_VERSION == 3.6 ]]; then pip install flake8 flake8-bugbear; fi
2012
script:
2113
- tox -e py

AUTHORS.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,4 @@ Contributors
1414
- Nils Philippsen (`@nphilipp <https://github.com/nphilipp>`_)
1515
- Alexander Duryagin (`@daa <https://github.com/daa>`_)
1616
- Sakorn Waungwiwatsin (`@SakornW <https://github.com/SakornW>`_)
17+
- Jacob Floyd (`@cognifloyd <https://github.com/cognifloyd>`_)

CHANGELOG.rst

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,31 @@ All notable changes to this project will be documented in this file.
66
The format is based on `Keep a Changelog`_, and this project adheres to the
77
`Semantic Versioning`_ scheme.
88

9+
0.9.0_ - 2019-06-05
10+
===================
11+
Added
12+
-----
13+
- Create consumer method templates to reduce boilerplate in request
14+
definitions. (`#151`_, `#159`_)
15+
- ``Context`` argument annotation to pass request-specific information to
16+
middleware. (`#143`_, `#155`_)
17+
- ``Session.context`` property to pass session-specific information to
18+
middleware. (`#143`_, `#155`_)
19+
- Built-in authentication support for API tokens in the querystring
20+
and header, Bearer tokens, and multi-auth. (`#137`_)
21+
22+
Fixed
23+
-----
24+
- Schema defined using ``@returns.*`` decorators should override the
25+
consumer method's return annotation. (`#144`_, `#154`_)
26+
- ``@returns.*`` decorators should propagate to all consumer method when used
27+
as a class decorator. (`#145`_, `#154`_)
28+
- Decorating a ``Consumer`` subclass no longer affects other subclasses. (`#152`_)
29+
30+
Changed
31+
-------
32+
- Renamed ``uplink.retry.stop.DISABLE`` to ``uplink.retry.stop.NEVER``
33+
934
0.8.0_ - 2019-02-16
1035
===================
1136
Added
@@ -269,6 +294,7 @@ Added
269294
.. _`Semantic Versioning`: https://packaging.python.org/tutorials/distributing-packages/#semantic-versioning-preferred
270295

271296
.. Releases
297+
.. _0.9.0: https://github.com/prkumar/uplink/compare/v0.8.0...v0.9.0
272298
.. _0.8.0: https://github.com/prkumar/uplink/compare/v0.7.0...v0.8.0
273299
.. _0.7.0: https://github.com/prkumar/uplink/compare/v0.6.1...v0.7.0
274300
.. _0.6.1: https://github.com/prkumar/uplink/compare/v0.6.0...v0.6.1
@@ -286,11 +312,20 @@ Added
286312
.. _0.2.0: https://github.com/prkumar/uplink/compare/v0.1.1...v0.2.0
287313
.. _0.1.1: https://github.com/prkumar/uplink/compare/v0.1.0...v0.1.1
288314

289-
.. Pull Requests
315+
.. Issues & Pull Requests
290316
.. _#132: https://github.com/prkumar/uplink/pull/132
291317
.. _#133: https://github.com/prkumar/uplink/pull/133
292318
.. _#134: https://github.com/prkumar/uplink/pull/134
319+
.. _#137: https://github.com/prkumar/uplink/pull/137
293320
.. _#138: https://github.com/prkumar/uplink/pull/138
321+
.. _#143: https://github.com/prkumar/uplink/issues/143
322+
.. _#144: https://github.com/prkumar/uplink/issues/144
323+
.. _#145: https://github.com/prkumar/uplink/issues/145
324+
.. _#151: https://github.com/prkumar/uplink/issues/151
325+
.. _#152: https://github.com/prkumar/uplink/pull/152
326+
.. _#154: https://github.com/prkumar/uplink/pull/154
327+
.. _#155: https://github.com/prkumar/uplink/pull/155
328+
.. _#159: https://github.com/prkumar/uplink/pull/159
294329

295330
.. Contributors
296331
.. _@daa: https://github.com/daa

README.rst

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,15 @@ Uplink turns your HTTP API into a Python class.
1313

1414
.. code-block:: python
1515
16-
from uplink import Consumer, get, headers, Path, Query
16+
from uplink import Consumer, get, Path, Query
17+
1718
1819
class GitHub(Consumer):
19-
"""A Python Client for the GitHub API."""
20+
"""A Python Client for the GitHub API."""
2021
21-
@get("users/{user}/repos")
22-
def get_repos(self, user: Path, sort_by: Query("sort")):
23-
"""Retrieves the user's public repositories."""
22+
@get("users/{user}/repos")
23+
def get_repos(self, user: Path, sort_by: Query("sort")):
24+
"""Retrieves the user's public repositories."""
2425
2526
Build an instance to interact with the webservice.
2627

@@ -157,11 +158,24 @@ User Testimonials
157158

158159
Documentation
159160
=============
160-
For more details, check out the documentation at
161-
https://uplink.readthedocs.io/.
161+
162+
Check out the library's documentation at https://uplink.readthedocs.io/.
163+
164+
For new users, a good place to start is this `quick tutorial`_.
165+
166+
167+
Community
168+
=========
169+
170+
Join the conversation on `Gitter`_ to ask questions, provide feedback,
171+
and meet other users!
172+
173+
.. _Gitter: https://gitter.im/python-uplink/Lobby
174+
162175

163176
Contributing
164177
============
178+
165179
Want to report a bug, request a feature, or contribute code to Uplink?
166180
Checkout the `Contribution Guide`_ for where to start.
167181
Thank you for taking the time to improve an open source project :purple_heart:

docs/source/dev/auth.rst

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
.. _auth_methods:
2+
3+
Auth Methods
4+
************
5+
6+
7+
The ``auth`` parameter of the :py:class:`Consumer` constructor offers a way
8+
to define an auth method to use for all requests.
9+
10+
.. code-block:: python
11+
12+
auth_method = SomeAuthMethod(...)
13+
github = GitHub(BASE_URL, auth=auth_method)
14+
15+
16+
BasicAuth
17+
=========
18+
19+
.. autoclass:: uplink.auth.BasicAuth
20+
21+
ProxyAuth
22+
=========
23+
24+
.. autoclass:: uplink.auth.ProxyAuth
25+
26+
BearerToken
27+
===========
28+
29+
.. autoclass:: uplink.auth.BearerToken
30+
31+
MultiAuth
32+
=========
33+
34+
.. autoclass:: uplink.auth.MultiAuth
35+
36+
ApiTokenParam
37+
=============
38+
39+
.. autoclass:: uplink.auth.ApiTokenParam
40+
41+
ApiTokenHeader
42+
==============
43+
44+
.. autoclass:: uplink.auth.ApiTokenHeader

docs/source/dev/decorators.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,9 +188,13 @@ Use the ``|`` operator to logically combine strategies:
188188
.. automodule:: uplink.retry.stop
189189
:members:
190190

191+
.. autodata:: uplink.retry.stop.NEVER
192+
:annotation:
193+
191194
ratelimit
192195
=========
193196

194197
.. autoclass:: uplink.ratelimit
195198

199+
196200
.. autoclass:: uplink.ratelimit.RateLimitExceeded

docs/source/dev/index.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,5 @@ This guide details the classes and methods in Uplink's public API.
1010
decorators.rst
1111
types.rst
1212
clients.rst
13-
converters.rst
13+
converters.rst
14+
auth.rst

docs/source/dev/types.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,3 +67,8 @@ Timeout
6767
=======
6868

6969
.. autoclass:: uplink.Timeout
70+
71+
Context
72+
=======
73+
74+
.. autoclass:: uplink.Context

docs/source/index.rst

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,15 @@ Uplink turns your HTTP API into a Python class.
2222

2323
.. code-block:: python
2424
25-
from uplink import Consumer, get, headers, Path, Query
25+
from uplink import Consumer, get, Path, Query
26+
2627
2728
class GitHub(Consumer):
28-
"""A Python Client for the GitHub API."""
29+
"""A Python Client for the GitHub API."""
2930
30-
@get("users/{user}/repos")
31-
def get_repos(self, user: Path, sort_by: Query("sort")):
32-
"""Get user's public repositories."""
31+
@get("users/{user}/repos")
32+
def get_repos(self, user: Path, sort_by: Query("sort")):
33+
"""Get user's public repositories."""
3334
3435
Build an instance to interact with the webservice.
3536

docs/source/user/auth.rst

Lines changed: 55 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,50 @@ Authentication
33

44
This section covers how to do authentication with Uplink.
55

6+
In v0.4, we added the :py:attr:`auth` parameter to the
7+
:py:class:`uplink.Consumer` constructor which allowed for
8+
sending HTTP Basic Authentication with all requests.
9+
10+
In v0.9, we added more auth methods which can be used in the
11+
:py:attr:`auth` parameter of the :py:class:`uplink.Consumer`
12+
constructor. If you are using an uplink-based API library,
13+
the library might extend these methods with additional
14+
API-specific auth methods.
15+
16+
Some common auth methods are described below, but for a
17+
complete list of auth methods provided with Uplink, see
18+
the :ref:`auth_methods` reference.
19+
620
.. _basic_authentication:
721

822
Basic Authentication
923
--------------------
1024

11-
In v0.4, we added the :py:attr:`auth` parameter to the
12-
:py:class:`uplink.Consumer` constructor.
13-
14-
Now it's simple to construct a consumer that uses HTTP Basic
25+
It's simple to construct a consumer that uses HTTP Basic
1526
Authentication with all requests:
1627

1728
.. code-block:: python
1829
1930
github = GitHub(BASE_URL, auth=("user", "pass"))
2031
32+
Proxy Authentication
33+
--------------------
34+
35+
If you need to supply credentials for an intermediate proxy
36+
in addition to the API's HTTP Basic Authentication, use
37+
:py:class:`uplink.auth.MultiAuth` with :py:class:`uplink.auth.ProxyAuth`
38+
and :py:class:`uplink.auth.BasicAuth`.
39+
40+
.. code-block:: python
41+
42+
from uplink.auth import BasicAuth, MultiAuth, ProxyAuth
43+
44+
auth_methods = MultiAuth(
45+
ProxyAuth("proxy_user", "proxy_pass"),
46+
BasicAuth("user", "pass")
47+
)
48+
github = GitHub(BASE_URL, auth=auth_methods)
49+
2150
Other Authentication
2251
--------------------
2352

@@ -39,10 +68,31 @@ through the consumer's :obj:`session <uplink.Consumer.session>` property:
3968
4069
class GitHub(Consumer):
4170
42-
def __init__(self, access_token):
71+
def __init__(self, base_url, access_token):
72+
super(GitHub, self).__init__(base_url=base_url)
4373
self.session.params["access_token"] = access_token
4474
...
4575
76+
As of v0.9, you can also supply these tokens via the :py:attr:`auth`
77+
parameter of the :py:class:`uplink.Consumer` constructor. This is
78+
like adding the token to the session (above) so that the token is
79+
sent as part of every request.
80+
81+
.. code-block:: python
82+
83+
from uplink.auth import ApiTokenParam, ApiTokenHeader, BearerToken
84+
85+
# Passing an auth token as a query parameter
86+
token_auth = ApiTokenParam("access_token", access_token)
87+
github = GitHub(BASE_URL, auth=token_auth)
88+
89+
# Passing the token as a header value
90+
token_auth = ApiTokenHeader("Access-Token", access_token)
91+
github = GitHub(BASE_URL, auth=token_auth)
92+
93+
# Passing a Bearer auth token
94+
bearer_auth = BearerToken(access_token)
95+
github = GitHub(BASE_URL, auth=bearer_auth)
4696
4797
Using Auth Support for Requests and aiohttp
4898
-------------------------------------------

0 commit comments

Comments
 (0)