X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;f=lib%2Fosm%2Fosmclient%2Fclientv2.py;h=414019e6167bd9d0b724012724b6a2e3931ae8e9;hb=e65ab995302cb8ea6d91cb0916d72a31528df67a;hp=482ff07e4d334a3beb3c35cd49e15e49ac450cf5;hpb=78e7188849e9acdb565a4598dba733b69faa764f;p=osm%2FLW-UI.git diff --git a/lib/osm/osmclient/clientv2.py b/lib/osm/osmclient/clientv2.py index 482ff07..414019e 100644 --- a/lib/osm/osmclient/clientv2.py +++ b/lib/osm/osmclient/clientv2.py @@ -24,10 +24,13 @@ import StringIO from lib.util import Util import hashlib import os +from requests.packages.urllib3.exceptions import InsecureRequestWarning -logging.basicConfig(level=logging.DEBUG) -log = logging.getLogger('helper.py') +requests.packages.urllib3.disable_warnings(InsecureRequestWarning) +logging.basicConfig(level=logging.INFO) +log = logging.getLogger('helper.py') +logging.getLogger("urllib3").setLevel(logging.INFO) class Client(object): def __init__(self): @@ -107,6 +110,24 @@ 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) + try: + r = requests.patch(_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.no_content: + result['error'] = False + else: + 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",