Adds an option to include names in role assignment lists

Allow the client to take advantage of the include_names with
list role assignments.

Change-Id: I4aa77c08660a0cbd021502155938a46121ca76ef
Depends-On: I0a1cc986b8a35aeafe567e5e7fee6eeb848ae113
Closes-Bug: #1479569
Implements: blueprint list-assignment-with-names
This commit is contained in:
Tom Cocozzello 2015-12-09 10:38:14 -06:00 committed by Steve Martinelli
parent 0a0419d2b8
commit 32ec1722c6
3 changed files with 23 additions and 1 deletions

View File

@ -189,6 +189,18 @@ class RoleAssignmentsTests(utils.ClientTestCase, utils.CrudTests):
kwargs = {'effective': 'True'}
self.assertQueryStringContains(**kwargs)
def test_include_names_assignments_list(self):
ref_list = self.TEST_ALL_RESPONSE_LIST
self.stub_entity('GET',
[self.collection_key,
'?include_names'],
entity=ref_list)
returned_list = self.manager.list(include_names=True)
self._assert_returned_list(ref_list, returned_list)
kwargs = {'include_names': 'True'}
self.assertQueryStringContains(**kwargs)
def test_role_assignments_list(self):
ref_list = self.TEST_ALL_RESPONSE_LIST
self.stub_entity('GET',

View File

@ -48,7 +48,7 @@ class RoleAssignmentManager(base.CrudManager):
def list(self, user=None, group=None, project=None, domain=None, role=None,
effective=False, os_inherit_extension_inherited_to=None,
include_subtree=False):
include_subtree=False, include_names=False):
"""Lists role assignments.
If no arguments are provided, all role assignments in the
@ -71,6 +71,8 @@ class RoleAssignmentManager(base.CrudManager):
return inherited role assignments for either 'projects' or
'domains'. (optional)
:param boolean include_subtree: Include subtree (optional)
:param boolean include_names: Display names instead
of IDs. (optional)
"""
self._check_not_user_and_group(user, group)
@ -89,6 +91,8 @@ class RoleAssignmentManager(base.CrudManager):
query_params['role.id'] = base.getid(role)
if effective:
query_params['effective'] = effective
if include_names:
query_params['include_names'] = include_names
if os_inherit_extension_inherited_to:
query_params['scope.OS-INHERIT:inherited_to'] = (
os_inherit_extension_inherited_to)

View File

@ -0,0 +1,6 @@
---
features:
- >
[`bug 1479569 <https://bugs.launchpad.net/python-keystoneclient/+bug/1479569>`_]
With the ``include_names`` parameter set to True the names of the role assignments
are returned with the entities IDs. (GET /role_assignments?include_names=True)