diff options
author | Christopher Zee <christopher.xs.zee@gmail.com> | 2014-03-14 16:37:41 +0100 |
---|---|---|
committer | David Pursehouse <david.pursehouse@sonymobile.com> | 2014-03-17 09:41:18 +0900 |
commit | 281a49cd2a108d0c5402d718823e56f71339584a (patch) | |
tree | 3663eafa3d78ed09f0e96e2a528c679162ba773e | |
parent | f82202457273eec72e8e11651a7d66930ab3b11b (diff) | |
download | pygerrit-281a49cd2a108d0c5402d718823e56f71339584a.tar.gz |
Accept kwargs for request functions
kwargs now made passable to request functions so that lower-level
python-requests interface can be fully utilized.
Change-Id: I38eff49314a3966546e0b272af2e58ed276269d9
-rw-r--r-- | pygerrit/rest/__init__.py | 26 |
1 files changed, 8 insertions, 18 deletions
diff --git a/pygerrit/rest/__init__.py b/pygerrit/rest/__init__.py index 1cfcdc8..cccfa94 100644 --- a/pygerrit/rest/__init__.py +++ b/pygerrit/rest/__init__.py @@ -100,7 +100,7 @@ class GerritRestAPI(object): endpoint = endpoint.lstrip('/') return self.url + endpoint - def get(self, endpoint, params=None): + def get(self, endpoint, **kwargs): """ Send HTTP GET to `endpoint`. Return JSON decoded result. @@ -108,13 +108,11 @@ class GerritRestAPI(object): Raise requests.RequestException on timeout or connection error. """ - kwargs = self.kwargs.copy() - if params: - kwargs['params'] = params + kwargs.update(self.kwargs.copy()) response = self.session.get(self.make_url(endpoint), **kwargs) return _decode_response(response) - def put(self, endpoint, params=None, data=None): + def put(self, endpoint, **kwargs): """ Send HTTP PUT to `endpoint`. Return JSON decoded result. @@ -122,15 +120,11 @@ class GerritRestAPI(object): Raise requests.RequestException on timeout or connection error. """ - kwargs = self.kwargs.copy() - if params: - kwargs['params'] = params - if data: - kwargs['data'] = data + kwargs.update(self.kwargs.copy()) response = self.session.put(self.make_url(endpoint), **kwargs) return _decode_response(response) - def post(self, endpoint, params=None, data=None): + def post(self, endpoint, **kwargs): """ Send HTTP POST to `endpoint`. Return JSON decoded result. @@ -138,15 +132,11 @@ class GerritRestAPI(object): Raise requests.RequestException on timeout or connection error. """ - kwargs = self.kwargs.copy() - if params: - kwargs['params'] = params - if data: - kwargs['data'] = data + kwargs.update(self.kwargs.copy()) response = self.session.post(self.make_url(endpoint), **kwargs) return _decode_response(response) - def delete(self, endpoint): + def delete(self, endpoint, **kwargs): """ Send HTTP DELETE to `endpoint`. Return JSON decoded result. @@ -154,6 +144,6 @@ class GerritRestAPI(object): Raise requests.RequestException on timeout or connection error. """ - kwargs = self.kwargs.copy() + kwargs.update(self.kwargs.copy()) response = self.session.delete(self.make_url(endpoint), **kwargs) return _decode_response(response) |