exoscale / cs

A simple, yet powerful CloudStack API client for python and the command-line.
BSD 3-Clause "New" or "Revised" License
88 stars 36 forks source link

parameter key to lower case #52

Closed marcaurele closed 6 years ago

marcaurele commented 6 years ago

Fix #51

greut commented 6 years ago

with CaseInsensitiveDict, it seems that the tests can remains as is.

index 0853fbe..786fcd7 100644
--- a/cs/client.py
+++ b/cs/client.py
@@ -16,6 +16,7 @@ except ImportError:  # python 2
     from urllib import quote

 import requests
+from requests.structures import CaseInsensitiveDict

 PY2 = sys.version_info < (3, 0)

@@ -110,8 +111,9 @@ class CloudStack(object):

     def _prepare_request(self, command, json, opcode_name, fetch_list,
                          **kwargs):
+        kwargs = CaseInsensitiveDict(kwargs)
         kwargs.update({
             'apiKey': self.key,
             opcode_name: command,
         })
         if json:
@@ -120,7 +122,7 @@ class CloudStack(object):
             kwargs.setdefault('pagesize', 500)

         kwarg = 'params' if self.method == 'get' else 'data'
-        return kwarg, kwargs
+        return kwarg, dict(kwargs._store.values())
brutasse commented 6 years ago

Fixed in #53 :+1: