-
Notifications
You must be signed in to change notification settings - Fork 3.3k
[Role] Migrate azure-mgmt-authorization SDK to Track 2 and bump API version to 2022-04-01
#25452
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
Changes from all commits
898f5a3
3639f9d
c25dcd5
ee43004
032e64d
ce4e4f5
4dda3fc
c43a62d
1a2d0ac
2ffad8b
ce22054
d185743
422fa12
8c8bbbf
fa84b6b
6fa073c
35a3147
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -179,9 +179,9 @@ def default_api_version(self): | |||||||||||
| ResourceType.MGMT_RESOURCE_PRIVATELINKS: '2020-05-01', | ||||||||||||
| ResourceType.MGMT_NETWORK_DNS: '2018-05-01', | ||||||||||||
| ResourceType.MGMT_KEYVAULT: '2022-07-01', | ||||||||||||
| ResourceType.MGMT_AUTHORIZATION: SDKProfile('2020-04-01-preview', { | ||||||||||||
| ResourceType.MGMT_AUTHORIZATION: SDKProfile('2022-04-01', { | ||||||||||||
| 'classic_administrators': '2015-06-01', | ||||||||||||
| 'role_definitions': '2018-01-01-preview', | ||||||||||||
| 'role_definitions': '2022-04-01', | ||||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
We can simply remove this line if
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
azure-cli/src/azure-cli/azure/cli/command_modules/role/_multi_api_adaptor.py Lines 62 to 65 in 5f40c5e
so it is merely a placeholder.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||||||||||||
| 'provider_operations_metadata': '2018-01-01-preview' | ||||||||||||
| }), | ||||||||||||
| ResourceType.MGMT_CONTAINERREGISTRY: SDKProfile('2022-02-01-preview', { | ||||||||||||
|
|
||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -28,6 +28,8 @@ | |
|
|
||
| logger = get_logger(__name__) | ||
|
|
||
| # pylint: disable=protected-access | ||
|
|
||
|
|
||
| def resolve_role_id(role, scope, definitions_client): | ||
| role_id = None | ||
|
|
@@ -68,10 +70,10 @@ def add_role_assignment_executor(cmd, role, assignee, resource_group_name=None, | |
| definitions_client = factory.role_definitions | ||
|
|
||
| # FIXME: is this necessary? | ||
| if assignments_client.config is None: | ||
| if assignments_client._config is None: | ||
| raise AzCLIError("Assignments client config is undefined.") | ||
|
|
||
| scope = build_role_scope(resource_group_name, scope, assignments_client.config.subscription_id) | ||
| scope = build_role_scope(resource_group_name, scope, assignments_client._config.subscription_id) | ||
|
|
||
| # XXX: if role is uuid, this function's output cannot be used as role assignment defintion id | ||
| # ref: https://github.com/Azure/azure-cli/issues/2458 | ||
|
|
@@ -92,8 +94,9 @@ def add_role_assignment_executor(cmd, role, assignee, resource_group_name=None, | |
| operation_group="role_assignments", | ||
| ) | ||
| if cmd.supported_api_version(min_api="2018-01-01-preview", resource_type=ResourceType.MGMT_AUTHORIZATION): | ||
| parameters = RoleAssignmentCreateParameters(role_definition_id=role_id, principal_id=object_id) | ||
| return assignments_client.create(scope, assignment_name, parameters, custom_headers=custom_headers) | ||
| parameters = RoleAssignmentCreateParameters(role_definition_id=role_id, principal_id=object_id, | ||
| principal_type=None) | ||
| return assignments_client.create(scope, assignment_name, parameters, headers=custom_headers) | ||
|
|
||
| # for backward compatibility | ||
| RoleAssignmentProperties = get_sdk( | ||
|
|
@@ -104,7 +107,7 @@ def add_role_assignment_executor(cmd, role, assignee, resource_group_name=None, | |
| operation_group="role_assignments", | ||
| ) | ||
| properties = RoleAssignmentProperties(role_definition_id=role_id, principal_id=object_id) | ||
| return assignments_client.create(scope, assignment_name, properties, custom_headers=custom_headers) | ||
| return assignments_client.create(scope, assignment_name, properties, headers=custom_headers) | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is to handle breaking change 1-2. |
||
|
|
||
|
|
||
| def add_role_assignment(cmd, role, service_principal_msi_id, is_service_principal=True, delay=2, scope=None): | ||
|
|
@@ -164,9 +167,9 @@ def search_role_assignments( | |
| f = "assignedTo('{}')".format(assignee_object_id) | ||
| else: | ||
| f = "principalId eq '{}'".format(assignee_object_id) | ||
| assignments = list(assignments_client.list(filter=f)) | ||
| assignments = list(assignments_client.list_for_subscription(filter=f)) | ||
| else: | ||
| assignments = list(assignments_client.list()) | ||
| assignments = list(assignments_client.list_for_subscription()) | ||
|
|
||
| if assignments: | ||
| assignments = [ | ||
|
|
@@ -245,7 +248,7 @@ def delete_role_assignments_executor( | |
| if not prompt_y_n(msg, default="n"): | ||
| return | ||
|
|
||
| scope = build_role_scope(resource_group_name, scope, assignments_client.config.subscription_id) | ||
| scope = build_role_scope(resource_group_name, scope, assignments_client._config.subscription_id) | ||
| assignments = search_role_assignments( | ||
| cli_ctx, | ||
| assignments_client, | ||
|
|
||
Large diffs are not rendered by default.
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.
This is to handle breaking change 1-3.