From 8190541891e054d160645a208e92e919d0a23b32 Mon Sep 17 00:00:00 2001 From: Yves Noirjean <yves.noirjean@id.ethz.ch> Date: Fri, 6 Jul 2018 13:28:47 +0200 Subject: [PATCH] SSDM-6845: added get_server_information() call to pybis.Openbis --- pybis/src/python/pybis/pybis.py | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/pybis/src/python/pybis/pybis.py b/pybis/src/python/pybis/pybis.py index f06637c2279..142fc83c923 100644 --- a/pybis/src/python/pybis/pybis.py +++ b/pybis/src/python/pybis/pybis.py @@ -523,6 +523,7 @@ class Openbis: return [ 'url', 'port', 'hostname', 'login()', 'logout()', 'is_session_active()', 'token', 'is_token_valid("")', + "get_server_information()", "get_dataset('permId')", "get_datasets()", "get_dataset_type('raw_data')", @@ -725,6 +726,31 @@ class Openbis: os.environ['OPENBIS_TOKEN'] = self.token return self.token + + def get_server_information(self): + """ Returns a dict containing the following server information: + api-version, archiving-configured, authentication-service, enabled-technologies, project-samples-enabled + """ + request = { + "method": "getServerInformation", + "params": [self.token], + } + resp = self._post_request(self.as_v3, request) + if resp is not None: + # result is a dict of strings - use more useful types + keys_boolean = ['archiving-configured', 'project-samples-enabled'] + keys_csv = ['enabled-technologies'] + for key in keys_boolean: + if key in resp: + resp[key] = resp[key] == 'true' + for key in keys_csv: + if key in resp: + resp[key] = list(map(lambda item: item.strip(), resp[key].split(','))) + return resp + else: + raise ValueError("Could not get the server information") + + def create_permId(self): """Have the server generate a new permId""" # Request just 1 permId -- GitLab