@@ -232,10 +232,10 @@ def _create_role_assignment(cli_ctx, role, assignee, resource_group_name=None, s
232232 condition = condition , condition_version = condition_version )
233233
234234
235- def list_role_assignments (cmd , assignee = None , role = None , resource_group_name = None ,
235+ def list_role_assignments (cmd , assignee = None , role = None , resource_group_name = None , # pylint: disable=too-many-locals
236236 scope = None , include_inherited = False ,
237237 show_all = False , include_groups = False , include_classic_administrators = False ,
238- fill_principal_name = True ):
238+ fill_role_definition_name = True , fill_principal_name = True ):
239239 '''
240240 :param include_groups: include extra assignments to the groups of which the user is a
241241 member(transitively).
@@ -267,23 +267,23 @@ def list_role_assignments(cmd, assignee=None, role=None, resource_group_name=Non
267267 if not results :
268268 return []
269269
270- # 1. fill in logic names to get things understandable.
271- # (it's possible that associated roles and principals were deleted, and we just do nothing.)
272- # 2. fill in role names
273- role_defs = list (definitions_client .list (
274- scope = scope or ('/subscriptions/' + definitions_client ._config .subscription_id )))
275- worker = MultiAPIAdaptor (cmd .cli_ctx )
276- role_dics = {i .id : worker .get_role_property (i , 'role_name' ) for i in role_defs }
277- for i in results :
278- if not i .get ('roleDefinitionName' ):
279- if role_dics .get (worker .get_role_property (i , 'roleDefinitionId' )):
280- worker .set_role_property (i , 'roleDefinitionName' ,
281- role_dics [worker .get_role_property (i , 'roleDefinitionId' )])
282- else :
283- i ['roleDefinitionName' ] = None # the role definition might have been deleted
270+ # Fill in role definition names
271+ if fill_role_definition_name :
272+ worker = MultiAPIAdaptor (cmd .cli_ctx )
273+ role_defs = list (definitions_client .list (
274+ scope = scope or ('/subscriptions/' + definitions_client ._config .subscription_id )))
275+ role_dics = {i .id : worker .get_role_property (i , 'role_name' ) for i in role_defs }
276+ for i in results :
277+ if not i .get ('roleDefinitionName' ):
278+ if role_dics .get (worker .get_role_property (i , 'roleDefinitionId' )):
279+ worker .set_role_property (i , 'roleDefinitionName' ,
280+ role_dics [worker .get_role_property (i , 'roleDefinitionId' )])
281+ else :
282+ i ['roleDefinitionName' ] = None # the role definition might have been deleted
284283
285- # fill in principal names
284+ # Fill in principal names
286285 if fill_principal_name :
286+ worker = MultiAPIAdaptor (cmd .cli_ctx )
287287 principal_ids = set (worker .get_role_property (i , 'principalId' )
288288 for i in results if worker .get_role_property (i , 'principalId' ))
289289
0 commit comments