Skip to content

Commit

Permalink
feat: jans-cli tabulate scim user list (#1518)
Browse files Browse the repository at this point in the history
  • Loading branch information
devrimyatar authored Jun 7, 2022
1 parent 31dd609 commit d370978
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions jans-cli/cli/config_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,12 @@
'jca.get-user': ['inum', 'userId', 'mail','sn', 'givenName', 'jansStatus'],
'jca.get-attributes': ['inum', 'name', 'displayName', 'status', 'dataType', 'claimName'],
'jca.get-oauth-openid-clients': ['inum', 'displayName', 'clientName', 'applicationType'],
'jca.get-oauth-scopes': ['dn', 'id', 'scopeType']
'jca.get-oauth-scopes': ['dn', 'id', 'scopeType'],
'scim.get-users': ['id', 'userName', 'displayName', 'active']
}

tabular_dataset = {'scim.get-users': 'Resources'}

my_op_mode = 'scim' if 'scim' in os.path.basename(sys.argv[0]) else 'jca'
sys.path.append(os.path.join(cur_dir, my_op_mode))
swagger_client = importlib.import_module(my_op_mode + '.swagger_client')
Expand Down Expand Up @@ -1102,7 +1105,7 @@ def tabular_data(self, data, ome):
for i, entry in enumerate(data):
row_ = [i + 1]
for header in headers:
row_.append(entry.get(header, ''))
row_.append(str(entry.get(header, '')))
tab_data.append(row_)

print(tabulate(tab_data, headers, tablefmt="grid"))
Expand Down Expand Up @@ -1183,7 +1186,10 @@ def process_get(self, endpoint, return_value=False, parameters=None):
elif attrib['name'] in tabulate_endpoints[op_mode_endpoint]:
entry[attrib['name']] = attrib['values'][0]

self.tabular_data(api_response_unmapped_ext, op_mode_endpoint)
tab_data = api_response_unmapped_ext
if op_mode_endpoint in tabular_dataset:
tab_data = api_response_unmapped_ext[tabular_dataset[op_mode_endpoint]]
self.tabular_data(tab_data, op_mode_endpoint)
item_counters = [str(i + 1) for i in range(len(api_response_unmapped))]
tabulated = True
else:
Expand Down

0 comments on commit d370978

Please sign in to comment.