-
Notifications
You must be signed in to change notification settings - Fork 3.3k
[Role] Add az role definition show command
#30593
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
️✔️AzureCLI-FullTest
|
|
Hi @jiasli, |
|
| rule | cmd_name | rule_message | suggest_message |
|---|---|---|---|
| role definition show | cmd role definition show added |
|
Thank you for your contribution! We will review the pull request and get back to you soon. |
|
|
az role definition show command az role definition show command
c34504d to
2fd55cd
Compare
|
|
||
| with self.argument_context('role definition') as c: | ||
| c.argument('role_definition_id', options_list=['--name', '-n'], help='the role definition name') | ||
| c.argument('role_id', options_list=['--id'], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The --ids argument provided by Azure CLI core relies on azure.mgmt.core.tools.parse_resource_id
| parts = parse_resource_id(val) |
which parses the resource ID into parts:
- subscription: Subscription id
- resource_group: Name of resource group
- namespace: Namespace for the resource provider (i.e. Microsoft.Compute)
- type: Type of the root resource (i.e. virtualMachines)
- name: Name of the root resource
- child_namespace_{level}: Namespace for the child resource of that level
- child_type_{level}: Type of the child resource of that level
- child_name_{level}: Name of the child resource of that level
- last_child_num: Level of the last child
- resource_parent: Computed parent in the following pattern: providers/{namespace}\
/{parent}/{type}/{name}
- resource_namespace: Same as namespace. Note that this may be different than the \
target resource's namespace.
- resource_type: Type of the target resource (not the parent)
- resource_name: Name of the target resource (not the parent)
However, it can't parse scope, so we have to define our own --id.
7d172d3 to
149c614
Compare
149c614 to
1758442
Compare
| if not role_id and not (name and scope): | ||
| raise CLIError('Usage error: Provide both --scope and --name') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
--scope should be a required argument to align with az role assignment create and az ad sp create-for-rbac.
Also see
Related command
az role definition showDescription
For
az role definition list, #30587 started to useroleNamefilter when--nameis a non-GUID string, but if the provided--nameis a GUID, this command still uses a client-side filter which is inefficient.namecannot be used as afilterand the API fails with:We can internally switch to Role Definitions - Get API when
--nameis a GUID and convert the result to a list, but this introduces complexity withinaz role definition listcommands, as it will have 2 code paths and need to handle 404 error returned by the Role Definitions - Get API.Having a dedicated
az role definition showcommand is more consistent with other Azure CLI commands and the underlying REST API.Testing Guide