Pass keywords to the request initialization

The `prepare_request` function accepts keywords corresponding to what
the Request class can take as arguments. This patch passes those kwargs
to the newly created `Request` instance, which is needed for the correct
work of the auth backend.

Partially-Implements blueprint python-marconiclient-v1

Change-Id: Ib333a7ad4d4628e2e5a66ddc91fafc378679f69c
This commit is contained in:
Flavio Percoco
2013-10-09 11:12:32 +02:00
parent fcccf5e1ba
commit 0dd1dff5c6

View File

@@ -21,9 +21,7 @@ from marconiclient import auth
from marconiclient import errors from marconiclient import errors
def prepare_request(conf, endpoint=None, def prepare_request(conf, data=None, **kwargs):
params=None, headers=None,
data=None):
"""Prepares a request """Prepares a request
This method takes care of authentication This method takes care of authentication
@@ -37,12 +35,13 @@ def prepare_request(conf, endpoint=None,
:param data: Optional data to send along with the :param data: Optional data to send along with the
request. If data is not None, it'll be serialized. request. If data is not None, it'll be serialized.
:type data: Any primitive type that is json-serializable. :type data: Any primitive type that is json-serializable.
:param kwargs: Anything accepted by `Request`
:returns: A `Request` instance ready to be sent. :returns: A `Request` instance ready to be sent.
:rtype: `Request` :rtype: `Request`
""" """
req = Request() req = Request(**kwargs)
auth_backend = auth.get_backend(conf) auth_backend = auth.get_backend(conf)
# TODO(flaper87): Do something smarter # TODO(flaper87): Do something smarter
# to get the api_version. # to get the api_version.