diff options
author | John Estabrook <jestabro@vyos.io> | 2023-02-06 12:48:59 -0600 |
---|---|---|
committer | John Estabrook <jestabro@vyos.io> | 2023-02-06 12:48:59 -0600 |
commit | 1f71a4f9d733e5f24b1f1648f68787dc2c5cef09 (patch) | |
tree | 62d984ce09b96423726ff328654f3fbbb47b7887 /src/services/api/graphql/session/session.py | |
parent | 2622902ac76bc1c3356bb722f63e931119f3eb04 (diff) | |
download | vyos-1x-1f71a4f9d733e5f24b1f1648f68787dc2c5cef09.tar.gz vyos-1x-1f71a4f9d733e5f24b1f1648f68787dc2c5cef09.zip |
graphql: T4979: add query show_user_info
Diffstat (limited to 'src/services/api/graphql/session/session.py')
-rw-r--r-- | src/services/api/graphql/session/session.py | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/services/api/graphql/session/session.py b/src/services/api/graphql/session/session.py index 0b77b1433..b2aef9bd9 100644 --- a/src/services/api/graphql/session/session.py +++ b/src/services/api/graphql/session/session.py @@ -46,6 +46,17 @@ class Session: except Exception: self._op_mode_list = None + @staticmethod + def _get_config_dict(path=[], effective=False, key_mangling=None, + get_first_key=False, no_multi_convert=False, + no_tag_node_value_mangle=False): + config = Config() + return config.get_config_dict(path=path, effective=effective, + key_mangling=key_mangling, + get_first_key=get_first_key, + no_multi_convert=no_multi_convert, + no_tag_node_value_mangle=no_tag_node_value_mangle) + def show_config(self): session = self._session data = self._data @@ -116,6 +127,22 @@ class Session: return res + def show_user_info(self): + session = self._session + data = self._data + + user_info = {} + user = data['user'] + try: + info = self._get_config_dict(['system', 'login', 'user', user, + 'full-name']) + user_info['user'] = user + user_info['full_name'] = info.get('full-name', '') + except Exception as error: + raise error + + return user_info + def system_status(self): import api.graphql.session.composite.system_status as system_status |