From 32ec1722c6fe5b5074070718705ba31ce79b0422 Mon Sep 17 00:00:00 2001 From: Tom Cocozzello Date: Wed, 9 Dec 2015 10:38:14 -0600 Subject: [PATCH] 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 --- .../tests/unit/v3/test_role_assignments.py | 12 ++++++++++++ keystoneclient/v3/role_assignments.py | 6 +++++- .../list_role_assignment_names-7e1b7eb8c2d22d7c.yaml | 6 ++++++ 3 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 releasenotes/notes/list_role_assignment_names-7e1b7eb8c2d22d7c.yaml diff --git a/keystoneclient/tests/unit/v3/test_role_assignments.py b/keystoneclient/tests/unit/v3/test_role_assignments.py index b955dfad6..b24799cbc 100644 --- a/keystoneclient/tests/unit/v3/test_role_assignments.py +++ b/keystoneclient/tests/unit/v3/test_role_assignments.py @@ -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', diff --git a/keystoneclient/v3/role_assignments.py b/keystoneclient/v3/role_assignments.py index fb9b5c71f..1e85e838f 100644 --- a/keystoneclient/v3/role_assignments.py +++ b/keystoneclient/v3/role_assignments.py @@ -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) diff --git a/releasenotes/notes/list_role_assignment_names-7e1b7eb8c2d22d7c.yaml b/releasenotes/notes/list_role_assignment_names-7e1b7eb8c2d22d7c.yaml new file mode 100644 index 000000000..499306a4a --- /dev/null +++ b/releasenotes/notes/list_role_assignment_names-7e1b7eb8c2d22d7c.yaml @@ -0,0 +1,6 @@ +--- +features: + - > + [`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)