Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release v0.9.0 #163

Merged
merged 40 commits into from
Jun 5, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
0179c2a
Bump minor version to v0.9.0
prkumar Feb 16, 2019
27803a2
Add and expose auth methods: MultiAuth ApiToken*
cognifloyd Jan 16, 2019
d84cf4a
Merge pull request #137 from cognifloyd/multi_auth
prkumar Feb 17, 2019
5cf85a4
Merge branch 'stable'
prkumar Feb 18, 2019
5bb0f33
Document Auth methods from #137
cognifloyd Feb 18, 2019
df75cb4
Merge pull request #142 from cognifloyd/multi_auth_docs
prkumar Feb 19, 2019
e90e9f4
Update README.rst
prkumar Mar 2, 2019
05fd5b3
Update index.rst
prkumar Mar 2, 2019
33bf076
Remove unused imports
prkumar Mar 2, 2019
104e652
Remove unused imports
prkumar Mar 2, 2019
8c7f603
Fix indentations
prkumar Mar 2, 2019
b429aa7
Stop sharing class decorators across siblings
prkumar Mar 12, 2019
9a41e1e
Merge branch 'stable'
prkumar Mar 13, 2019
6a6e247
Explain absolute URL resolution
prkumar Mar 16, 2019
7f51452
Explain support for optional parameters
prkumar Mar 16, 2019
c494696
Add community section to README
prkumar Mar 16, 2019
db502bc
Explain how @retry takes precedence over handlers
prkumar Mar 16, 2019
a85d23a
Fix unit tests
prkumar Mar 26, 2019
592757c
Merge pull request #152 from prkumar/v0.9.0/fix-class-decorators
prkumar Mar 26, 2019
09aa1db
Fix @return.* implementations
prkumar Mar 26, 2019
67974bf
Add unit tests for @returns.* fixes
prkumar Mar 27, 2019
472c28d
Merge pull request #154 from prkumar/v0.9.0/fix-returns
prkumar Mar 28, 2019
67c8925
Clarify note about how Uplink forms abs url
prkumar Apr 2, 2019
5d3492b
Fix B011 warning spotted by flake8
prkumar Apr 2, 2019
b91a561
Fix B011 warning spotted by flake8
prkumar Apr 2, 2019
6bd21b8
Clarify relative path resolution in docs
prkumar Apr 3, 2019
0d29483
Add `Context` argument annotation (#155)
prkumar Apr 4, 2019
da9d6b7
Allow extending consumer methods
prkumar Apr 21, 2019
3b1730f
Remove Python 3 function annotations
prkumar Apr 21, 2019
e518e41
Document consumer method extension
prkumar Apr 23, 2019
b8f4c65
Fix whitespace issues
prkumar Apr 23, 2019
527e8e4
Fix broken logic with @returns.*
prkumar Apr 23, 2019
8483dcc
Extend Consumer Methods to Reduce Boilerplate (#159)
prkumar Apr 23, 2019
015cca3
Update documentation for @retry
prkumar May 11, 2019
164b683
Update CHANGELOG for v0.9.0
prkumar May 11, 2019
2c9e174
Merge branch 'v0.9.0/prepare-for-release'
prkumar May 11, 2019
adbb8ee
Update documentation for v0.9.0
prkumar May 13, 2019
23a55f3
Specify the package name in setup.py
prkumar Jun 5, 2019
c5e0d48
Remove python 3.3 Travis build
prkumar Jun 5, 2019
5332d99
Update release date of v0.9.0
prkumar Jun 5, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 1 addition & 9 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,21 +1,13 @@
language: python
python:
- '2.7'
- '3.3'
- '3.4'
- '3.5'
- '3.6'
- '3.6-dev'
- '3.7-dev'
before_script:
- |
if [[ $TRAVIS_PYTHON_VERSION == 3.3 ]]; then
# virtualenv 16.0.0 bundles wheel 0.31.1, which drops python 3.3.* support
# tox 3.0.0 drops python 3.3.* support
pip install virtualenv==15.2.0 tox==2.9.1
else
pip install tox
fi
- pip install tox
- if [[ $TRAVIS_PYTHON_VERSION == 3.6 ]]; then pip install flake8 flake8-bugbear; fi
script:
- tox -e py
Expand Down
1 change: 1 addition & 0 deletions AUTHORS.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ Contributors
- Nils Philippsen (`@nphilipp <https://github.com/nphilipp>`_)
- Alexander Duryagin (`@daa <https://github.com/daa>`_)
- Sakorn Waungwiwatsin (`@SakornW <https://github.com/SakornW>`_)
- Jacob Floyd (`@cognifloyd <https://github.com/cognifloyd>`_)
37 changes: 36 additions & 1 deletion CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,31 @@ All notable changes to this project will be documented in this file.
The format is based on `Keep a Changelog`_, and this project adheres to the
`Semantic Versioning`_ scheme.

0.9.0_ - 2019-06-05
===================
Added
-----
- Create consumer method templates to reduce boilerplate in request
definitions. (`#151`_, `#159`_)
- ``Context`` argument annotation to pass request-specific information to
middleware. (`#143`_, `#155`_)
- ``Session.context`` property to pass session-specific information to
middleware. (`#143`_, `#155`_)
- Built-in authentication support for API tokens in the querystring
and header, Bearer tokens, and multi-auth. (`#137`_)

Fixed
-----
- Schema defined using ``@returns.*`` decorators should override the
consumer method's return annotation. (`#144`_, `#154`_)
- ``@returns.*`` decorators should propagate to all consumer method when used
as a class decorator. (`#145`_, `#154`_)
- Decorating a ``Consumer`` subclass no longer affects other subclasses. (`#152`_)

Changed
-------
- Renamed ``uplink.retry.stop.DISABLE`` to ``uplink.retry.stop.NEVER``

0.8.0_ - 2019-02-16
===================
Added
Expand Down Expand Up @@ -269,6 +294,7 @@ Added
.. _`Semantic Versioning`: https://packaging.python.org/tutorials/distributing-packages/#semantic-versioning-preferred

.. Releases
.. _0.9.0: https://github.com/prkumar/uplink/compare/v0.8.0...v0.9.0
.. _0.8.0: https://github.com/prkumar/uplink/compare/v0.7.0...v0.8.0
.. _0.7.0: https://github.com/prkumar/uplink/compare/v0.6.1...v0.7.0
.. _0.6.1: https://github.com/prkumar/uplink/compare/v0.6.0...v0.6.1
Expand All @@ -286,11 +312,20 @@ Added
.. _0.2.0: https://github.com/prkumar/uplink/compare/v0.1.1...v0.2.0
.. _0.1.1: https://github.com/prkumar/uplink/compare/v0.1.0...v0.1.1

.. Pull Requests
.. Issues & Pull Requests
.. _#132: https://github.com/prkumar/uplink/pull/132
.. _#133: https://github.com/prkumar/uplink/pull/133
.. _#134: https://github.com/prkumar/uplink/pull/134
.. _#137: https://github.com/prkumar/uplink/pull/137
.. _#138: https://github.com/prkumar/uplink/pull/138
.. _#143: https://github.com/prkumar/uplink/issues/143
.. _#144: https://github.com/prkumar/uplink/issues/144
.. _#145: https://github.com/prkumar/uplink/issues/145
.. _#151: https://github.com/prkumar/uplink/issues/151
.. _#152: https://github.com/prkumar/uplink/pull/152
.. _#154: https://github.com/prkumar/uplink/pull/154
.. _#155: https://github.com/prkumar/uplink/pull/155
.. _#159: https://github.com/prkumar/uplink/pull/159

.. Contributors
.. _@daa: https://github.com/daa
Expand Down
28 changes: 21 additions & 7 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,15 @@ Uplink turns your HTTP API into a Python class.

.. code-block:: python

from uplink import Consumer, get, headers, Path, Query
from uplink import Consumer, get, Path, Query


class GitHub(Consumer):
"""A Python Client for the GitHub API."""
"""A Python Client for the GitHub API."""

@get("users/{user}/repos")
def get_repos(self, user: Path, sort_by: Query("sort")):
"""Retrieves the user's public repositories."""
@get("users/{user}/repos")
def get_repos(self, user: Path, sort_by: Query("sort")):
"""Retrieves the user's public repositories."""

Build an instance to interact with the webservice.

Expand Down Expand Up @@ -157,11 +158,24 @@ User Testimonials

Documentation
=============
For more details, check out the documentation at
https://uplink.readthedocs.io/.

Check out the library's documentation at https://uplink.readthedocs.io/.

For new users, a good place to start is this `quick tutorial`_.


Community
=========

Join the conversation on `Gitter`_ to ask questions, provide feedback,
and meet other users!

.. _Gitter: https://gitter.im/python-uplink/Lobby


Contributing
============

Want to report a bug, request a feature, or contribute code to Uplink?
Checkout the `Contribution Guide`_ for where to start.
Thank you for taking the time to improve an open source project :purple_heart:
Expand Down
44 changes: 44 additions & 0 deletions docs/source/dev/auth.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
.. _auth_methods:

Auth Methods
************


The ``auth`` parameter of the :py:class:`Consumer` constructor offers a way
to define an auth method to use for all requests.

.. code-block:: python

auth_method = SomeAuthMethod(...)
github = GitHub(BASE_URL, auth=auth_method)


BasicAuth
=========

.. autoclass:: uplink.auth.BasicAuth

ProxyAuth
=========

.. autoclass:: uplink.auth.ProxyAuth

BearerToken
===========

.. autoclass:: uplink.auth.BearerToken

MultiAuth
=========

.. autoclass:: uplink.auth.MultiAuth

ApiTokenParam
=============

.. autoclass:: uplink.auth.ApiTokenParam

ApiTokenHeader
==============

.. autoclass:: uplink.auth.ApiTokenHeader
4 changes: 4 additions & 0 deletions docs/source/dev/decorators.rst
Original file line number Diff line number Diff line change
Expand Up @@ -188,9 +188,13 @@ Use the ``|`` operator to logically combine strategies:
.. automodule:: uplink.retry.stop
:members:

.. autodata:: uplink.retry.stop.NEVER
:annotation:

ratelimit
=========

.. autoclass:: uplink.ratelimit


.. autoclass:: uplink.ratelimit.RateLimitExceeded
3 changes: 2 additions & 1 deletion docs/source/dev/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ This guide details the classes and methods in Uplink's public API.
decorators.rst
types.rst
clients.rst
converters.rst
converters.rst
auth.rst
5 changes: 5 additions & 0 deletions docs/source/dev/types.rst
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,8 @@ Timeout
=======

.. autoclass:: uplink.Timeout

Context
=======

.. autoclass:: uplink.Context
11 changes: 6 additions & 5 deletions docs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,15 @@ Uplink turns your HTTP API into a Python class.

.. code-block:: python

from uplink import Consumer, get, headers, Path, Query
from uplink import Consumer, get, Path, Query


class GitHub(Consumer):
"""A Python Client for the GitHub API."""
"""A Python Client for the GitHub API."""

@get("users/{user}/repos")
def get_repos(self, user: Path, sort_by: Query("sort")):
"""Get user's public repositories."""
@get("users/{user}/repos")
def get_repos(self, user: Path, sort_by: Query("sort")):
"""Get user's public repositories."""

Build an instance to interact with the webservice.

Expand Down
60 changes: 55 additions & 5 deletions docs/source/user/auth.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,50 @@ Authentication

This section covers how to do authentication with Uplink.

In v0.4, we added the :py:attr:`auth` parameter to the
:py:class:`uplink.Consumer` constructor which allowed for
sending HTTP Basic Authentication with all requests.

In v0.9, we added more auth methods which can be used in the
:py:attr:`auth` parameter of the :py:class:`uplink.Consumer`
constructor. If you are using an uplink-based API library,
the library might extend these methods with additional
API-specific auth methods.

Some common auth methods are described below, but for a
complete list of auth methods provided with Uplink, see
the :ref:`auth_methods` reference.

.. _basic_authentication:

Basic Authentication
--------------------

In v0.4, we added the :py:attr:`auth` parameter to the
:py:class:`uplink.Consumer` constructor.

Now it's simple to construct a consumer that uses HTTP Basic
It's simple to construct a consumer that uses HTTP Basic
Authentication with all requests:

.. code-block:: python

github = GitHub(BASE_URL, auth=("user", "pass"))

Proxy Authentication
--------------------

If you need to supply credentials for an intermediate proxy
in addition to the API's HTTP Basic Authentication, use
:py:class:`uplink.auth.MultiAuth` with :py:class:`uplink.auth.ProxyAuth`
and :py:class:`uplink.auth.BasicAuth`.

.. code-block:: python

from uplink.auth import BasicAuth, MultiAuth, ProxyAuth

auth_methods = MultiAuth(
ProxyAuth("proxy_user", "proxy_pass"),
BasicAuth("user", "pass")
)
github = GitHub(BASE_URL, auth=auth_methods)

Other Authentication
--------------------

Expand All @@ -39,10 +68,31 @@ through the consumer's :obj:`session <uplink.Consumer.session>` property:

class GitHub(Consumer):

def __init__(self, access_token):
def __init__(self, base_url, access_token):
super(GitHub, self).__init__(base_url=base_url)
self.session.params["access_token"] = access_token
...

As of v0.9, you can also supply these tokens via the :py:attr:`auth`
parameter of the :py:class:`uplink.Consumer` constructor. This is
like adding the token to the session (above) so that the token is
sent as part of every request.

.. code-block:: python

from uplink.auth import ApiTokenParam, ApiTokenHeader, BearerToken

# Passing an auth token as a query parameter
token_auth = ApiTokenParam("access_token", access_token)
github = GitHub(BASE_URL, auth=token_auth)

# Passing the token as a header value
token_auth = ApiTokenHeader("Access-Token", access_token)
github = GitHub(BASE_URL, auth=token_auth)

# Passing a Bearer auth token
bearer_auth = BearerToken(access_token)
github = GitHub(BASE_URL, auth=bearer_auth)

Using Auth Support for Requests and aiohttp
-------------------------------------------
Expand Down
Loading