X-Git-Url: https://osm.etsi.org/gitweb/?p=osm%2FLW-UI.git;a=blobdiff_plain;f=lib%2Fosm%2Fosmclient%2Fclientv2.py;h=0914fb3fc010d2d5efe5ff50a9b59efc54fc3865;hp=f82bf4d29a43a7cdc3618f2f83ded6e938eeb6a6;hb=3fcf21a3589d2e9f94b2de318d3dc0404f4be94b;hpb=478c2a894ec892beafab0f59365b996287e58cb1 diff --git a/lib/osm/osmclient/clientv2.py b/lib/osm/osmclient/clientv2.py index f82bf4d..0914fb3 100644 --- a/lib/osm/osmclient/clientv2.py +++ b/lib/osm/osmclient/clientv2.py @@ -1210,6 +1210,23 @@ class Client(object): result['data'] = r.text return result + def wim_list(self, token): + result = {'error': True, 'data': ''} + headers = {"Content-Type": "application/yaml", "accept": "application/json", + 'Authorization': 'Bearer {}'.format(token['id'])} + _url = "{0}/admin/v1/wim_accounts".format(self._base_path) + try: + r = requests.get(_url, params=None, verify=False, stream=True, headers=headers) + except Exception as e: + log.exception(e) + result['data'] = str(e) + return result + if r.status_code == requests.codes.ok: + result['error'] = False + result['data'] = Util.json_loads_byteified(r.text) + + return result + def vim_list(self, token): result = {'error': True, 'data': ''} headers = {"Content-Type": "application/yaml", "accept": "application/json", @@ -1227,6 +1244,23 @@ class Client(object): return result + def wim_delete(self, token, id): + result = {'error': True, 'data': ''} + headers = {"accept": "application/json", + 'Authorization': 'Bearer {}'.format(token['id'])} + _url = "{0}/admin/v1/wim_accounts/{1}".format(self._base_path, id) + try: + r = requests.delete(_url, params=None, verify=False, headers=headers) + except Exception as e: + log.exception(e) + result['data'] = str(e) + return result + if r.status_code == requests.codes.accepted: + result['error'] = False + else: + result['data'] = r.text + return result + def vim_delete(self, token, id): result = {'error': True, 'data': ''} headers = {"accept": "application/json", @@ -1244,6 +1278,24 @@ class Client(object): result['data'] = r.text return result + def wim_get(self, token, id): + + result = {'error': True, 'data': ''} + headers = {"Content-Type": "application/json", "accept": "application/json", + 'Authorization': 'Bearer {}'.format(token['id'])} + _url = "{0}/admin/v1/wim_accounts/{1}".format(self._base_path, id) + + try: + r = requests.get(_url, params=None, verify=False, stream=True, headers=headers) + except Exception as e: + log.exception(e) + result['data'] = str(e) + return result + if r.status_code == requests.codes.ok: + result['error'] = False + result['data'] = Util.json_loads_byteified(r.text) + return result + def vim_get(self, token, id): result = {'error': True, 'data': ''} @@ -1262,6 +1314,24 @@ class Client(object): result['data'] = Util.json_loads_byteified(r.text) return result + def wim_create(self, token, wim_data): + result = {'error': True, 'data': ''} + headers = {"Content-Type": "application/json", "accept": "application/json", + 'Authorization': 'Bearer {}'.format(token['id'])} + + _url = "{0}/admin/v1/wim_accounts".format(self._base_path) + + try: + r = requests.post(_url, json=wim_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 vim_create(self, token, vim_data): result = {'error': True, 'data': ''}