X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;f=lib%2Fosm%2Fosmclient%2Fclientv2.py;fp=lib%2Fosm%2Fosmclient%2Fclientv2.py;h=6bb8c7105f88b5a78fdd6c7d4d55caa322217b13;hb=f705bc834c4073155310ef740475d3d8543b22f4;hp=30cc1f4d7153c1945178a4f96de2bcfe79b0163f;hpb=162ddd1d6b32a82e060eaca8f8d32683c49560ac;p=osm%2FLW-UI.git diff --git a/lib/osm/osmclient/clientv2.py b/lib/osm/osmclient/clientv2.py index 30cc1f4..6bb8c71 100644 --- a/lib/osm/osmclient/clientv2.py +++ b/lib/osm/osmclient/clientv2.py @@ -252,6 +252,27 @@ class Client(object): result['data'] = Util.json_loads_byteified(r.text) return result + def get_projects(self, token, uuids): + result = {'error': False, 'data': ''} + headers = {"Content-Type": "application/yaml", "accept": "application/json", + 'Authorization': 'Bearer {}'.format(token['id'])} + + projects = [] + try: + for uuid in uuids: + _url = "{0}/admin/v1/projects/{1}".format(self._base_path, uuid) + r = requests.get(_url, params=None, verify=False, stream=True, headers=headers) + if r.status_code not in (200, 201, 202, 204): + raise Exception() + projects.append(Util.json_loads_byteified(r.text)) + except Exception as e: + log.exception(e) + result['error'] = True + result['data'] = str(e) + return result + result['data'] = projects + return result + def project_list(self, token): result = {'error': True, 'data': ''} headers = {"Content-Type": "application/yaml", "accept": "application/json",