diff --git a/adjutantclient/osc/v1/users.py b/adjutantclient/osc/v1/users.py index 5493778..96d8002 100644 --- a/adjutantclient/osc/v1/users.py +++ b/adjutantclient/osc/v1/users.py @@ -32,10 +32,18 @@ class UserList(command.Lister): project_users = client.users.list() headers = [ 'id', 'name', 'email', 'roles', 'cohort', 'status'] + optional_headers = ['has_mfa'] - rows = [[user.id, user.name, user.email, - user.roles, user.cohort, user.status] - for user in project_users] + rows = [] + for user in project_users: + # Check the first user for optional headers. + for opt in optional_headers: + if hasattr(user, opt): + headers.append(opt) + optional_headers = [] + rows.append([ + getattr(user, header) for header in headers + ]) return headers, rows diff --git a/releasenotes/notes/add-mfa-display-2eeb55fbd40d671c.yaml b/releasenotes/notes/add-mfa-display-2eeb55fbd40d671c.yaml new file mode 100644 index 0000000..4912d9b --- /dev/null +++ b/releasenotes/notes/add-mfa-display-2eeb55fbd40d671c.yaml @@ -0,0 +1,7 @@ +--- +features: + - | + Add support for optionally displaying column use_mfa in user list if + Adjutant API returns this in the query. This may be added to responses if + Adjutant MFA server plugin is installed and the user has the appropriate + roles in the project otherwise it is omitted.