[WIP] user editing
[osm/LW-UI.git] / lib / osm / osmclient / clientv2.py
index 482ff07..fa4117e 100644 (file)
@@ -107,6 +107,25 @@ class Client(object):
         result['data'] = Util.json_loads_byteified(r.text)
         return result
 
+    def user_update(self, token, id, user_data):
+        result = {'error': True, 'data': ''}
+        headers = {"Content-Type": "application/json", "accept": "application/json",
+                   'Authorization': 'Bearer {}'.format(token['id'])}
+
+        _url = "{0}/admin/v1/users/{1}".format(self._base_path, id)
+        print _url
+        print user_data
+        try:
+            r = requests.post(_url, json=user_data, verify=False, headers=headers)
+        except Exception as e:
+            log.exception(e)
+            result['data'] = str(e)
+            return result
+        if r.status_code == requests.codes.created:
+            result['error'] = False
+        result['data'] = Util.json_loads_byteified(r.text)
+        return result
+
     def user_delete(self, token, id):
         result = {'error': True, 'data': ''}
         headers = {"Content-Type": "application/yaml", "accept": "application/json",