azure-sdk-for-python icon indicating copy to clipboard operation
azure-sdk-for-python copied to clipboard

Adding the principal_name to the RoleAssignment class

Open athiruma opened this issue 2 years ago • 4 comments

Is your feature request related to a problem? Please describe. A RoleAssignment class is missing the attribute principal_name. However, I can see the principal_name by using the Azure CLI: az role assignment list

Describe the solution you'd like Adding the principal_name attribute to the RoleAssignment.

athiruma avatar Mar 06 '24 09:03 athiruma

Thanks for the feedback.

Could you provide the information: which SDK library are you using? the version of the library? if possible, some code snippet?

Thank you.

xiangyan99 avatar Mar 06 '24 22:03 xiangyan99

Hi @athiruma. Thank you for opening this issue and giving us the opportunity to assist. To help our team better understand your issue and the details of your scenario please provide a response to the question asked above or the information requested above. This will help us more accurately address your issue.

github-actions[bot] avatar Mar 06 '24 22:03 github-actions[bot]

Package-details:- Name: azure-mgmt-authorization Version: 4.0.0

I am calling the role_assignment operations by following this doc. In which I used the list_for_scope method that returns the RoleAssignment object. In the role_assignment object, I do not see the principal_name.

My code snippet:

import json

from azure.mgmt.authorization import AuthorizationManagementClient

from cloud_governance.common.clouds.azure.common.common_operations import CommonOperations


class AuthorizationOperations(CommonOperations):

    def __init__(self):
        super().__init__()
        self.__auth_client = AuthorizationManagementClient(credential=self._default_creds,
                                                           subscription_id=self._subscription_id)

    def get_service_account_details(self):
        """
        This method returns the service account details
        :return:
        :rtype:
        """
        scope = f"/subscriptions/{self._subscription_id}"
        role_assignments = self.__auth_client.role_assignments.list_for_scope(scope)
        return self._item_paged_iterator(role_assignments, as_dict=True)

athiruma avatar Mar 07 '24 01:03 athiruma

I guess to use the principal_id retuned should be enough though, and since there're serval principal types, the principal_name may not be able to have a stable format. But if you insist to request this feature, please know that Python SDK is generated with swagger automatically, so please open issue in https://github.com/Azure/azure-rest-api-specs/issues and mark it with label feature request. Once swagger is fixed, python SDK will release new version to support it.

ChenxiJiang333 avatar Mar 08 '24 07:03 ChenxiJiang333

Hi @athiruma. Thank you for opening this issue and giving us the opportunity to assist. To help our team better understand your issue and the details of your scenario please provide a response to the question asked above or the information requested above. This will help us more accurately address your issue.

github-actions[bot] avatar Mar 14 '24 15:03 github-actions[bot]

In my use case, I needed the principal_name. Although I can find the principal_name using the principal_id with another SDK module, it would be beneficial if the principal_name could also be retrieved in the same place when listing roles. This request isn't beyond the scope, as the principal_name is displayed in the CLI command az ad list roles. I opened the feature_request, as you suggested.

athiruma avatar Mar 17 '24 06:03 athiruma

got it, hope there will be a quick response

ChenxiJiang333 avatar Mar 18 '24 02:03 ChenxiJiang333

Closing the issue.

Please use https://github.com/Azure/azure-rest-api-specs/issues/28219 to track.

xiangyan99 avatar Jun 20 '24 15:06 xiangyan99