diff options
author | Jamie Lennox <jamielennox@redhat.com> | 2015-01-16 16:03:25 +1000 |
---|---|---|
committer | Jamie Lennox <jamielennox@redhat.com> | 2015-03-27 16:17:04 +1100 |
commit | 2141b6a608fc7359a2a9ec59ade971dab511235d (patch) | |
tree | d75de7c326d29ad60e98e9bb9282760d1f0f4887 /saharaclient/api/base.py | |
parent | 3fa0e0e798db785463711de617052d8bfe5cbe14 (diff) | |
download | python-saharaclient-2141b6a608fc7359a2a9ec59ade971dab511235d.tar.gz |
Rework authentication
Saharaclient's authentication is relatively simple. It resolves the
sahara URL and the token prior to making any requests.
Provide the means to use the features of the adapter directly and adopt
those features.
Change-Id: I7d0f8435b836d187a0396657b485d9d080a59ba1
Diffstat (limited to 'saharaclient/api/base.py')
-rw-r--r-- | saharaclient/api/base.py | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/saharaclient/api/base.py b/saharaclient/api/base.py index 5b67167..6e82f9d 100644 --- a/saharaclient/api/base.py +++ b/saharaclient/api/base.py @@ -86,8 +86,11 @@ class ResourceManager(object): def _create(self, url, data, response_key=None, dump_json=True): if dump_json: - data = json.dumps(data) - resp = self.api.post(url, data, json=dump_json) + kwargs = {'json': data} + else: + kwargs = {'data': data} + + resp = self.api.post(url, **kwargs) if resp.status_code != 202: self._raise_api_exception(resp) @@ -100,8 +103,11 @@ class ResourceManager(object): def _update(self, url, data, response_key=None, dump_json=True): if dump_json: - data = json.dumps(data) - resp = self.api.put(url, data, json=dump_json) + kwargs = {'json': data} + else: + kwargs = {'data': data} + + resp = self.api.put(url, **kwargs) if resp.status_code != 202: self._raise_api_exception(resp) |