-
Notifications
You must be signed in to change notification settings - Fork 3.4k
[Identity] az identity create/update: Add new --resource-restriction parameter to support identity assignment restrictions
#32214
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
base: dev
Are you sure you want to change the base?
Changes from 22 commits
2e8a000
26a521e
1492ad5
9688b75
4074506
6e74275
d820df7
d7582a0
27ac843
d9965d9
356c39e
32cb812
f05d221
ee5d8b7
f850a41
e4f64be
6315665
7434b19
e18c075
12b2094
a605481
be81d45
6f383fb
146ce49
ebda947
af19c22
59a4c0d
078b3ce
d8ed0aa
6dc00dc
ea87d1a
49f4888
3450a3d
49e2584
2b638db
26175fa
2a708ef
93ff125
247c676
9fb67e6
423f830
cb8b712
e3cf3dc
e8b2018
16205e9
77b9ddb
acb2298
57068f0
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 | ||||
|---|---|---|---|---|---|---|
|
|
@@ -20,3 +20,8 @@ def load_arguments(self, _): | |||||
| with self.argument_context('identity create') as c: | ||||||
| c.argument('location', get_location_type(self.cli_ctx), required=False) | ||||||
| c.argument('tags', tags_type) | ||||||
| c.argument('assignment_restriction', required=False, help='Identity assignment restriction, used to restrict the resources that can be assigned to the identity.') | ||||||
|
Contributor
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. Default configuration
Suggested change
|
||||||
|
|
||||||
| with self.argument_context('identity update') as c: | ||||||
| c.argument('tags', tags_type) | ||||||
| c.argument('assignment_restriction', required=False, help='Identity assignment restriction, used to restrict the resources that can be assigned to the identity.') | ||||||
|
||||||
| c.argument('assignment_restriction', required=False, help='Identity assignment restriction, used to restrict the resources that can be assigned to the identity.') | |
| c.argument('assignment_restriction', help='Identity assignment restriction, used to restrict the resources that can be assigned to the identity.') |
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -3,7 +3,6 @@ | |||||||||
| # Licensed under the MIT License. See License.txt in the project root for license information. | ||||||||||
| # -------------------------------------------------------------------------------------------- | ||||||||||
|
|
||||||||||
|
|
||||||||||
| def list_user_assigned_identities(cmd, resource_group_name=None): | ||||||||||
| from azure.cli.command_modules.identity._client_factory import _msi_client_factory | ||||||||||
| client = _msi_client_factory(cmd.cli_ctx) | ||||||||||
|
|
@@ -12,16 +11,27 @@ def list_user_assigned_identities(cmd, resource_group_name=None): | |||||||||
| return client.user_assigned_identities.list_by_subscription() | ||||||||||
|
|
||||||||||
|
|
||||||||||
| def create_identity(client, resource_group_name, resource_name, location, tags=None): | ||||||||||
| def create_identity(client, resource_group_name, resource_name, location, tags=None, assignment_restriction=None): | ||||||||||
| parameters = {} | ||||||||||
| parameters['location'] = location | ||||||||||
| if tags is not None: | ||||||||||
| parameters['tags'] = tags | ||||||||||
| if assignment_restriction is not None: | ||||||||||
| parameters['assignmentRestriction'] = assignment_restriction | ||||||||||
| return client.create_or_update(resource_group_name=resource_group_name, | ||||||||||
| resource_name=resource_name, | ||||||||||
| parameters=parameters) | ||||||||||
|
|
||||||||||
|
|
||||||||||
| def update_identity(instance, tags=None, assignment_restriction=None): | ||||||||||
| parameters = {} | ||||||||||
| if tags is not None: | ||||||||||
| parameters['tags'] = tags | ||||||||||
| if assignment_restriction is not None: | ||||||||||
| parameters['assignmentRestriction'] = assignment_restriction or instance.assignment_restriction | ||||||||||
|
||||||||||
| parameters['assignmentRestriction'] = assignment_restriction or instance.assignment_restriction | |
| parameters['assignmentRestriction'] = assignment_restriction | |
| elif hasattr(instance, 'assignment_restriction'): | |
| parameters['assignmentRestriction'] = instance.assignment_restriction |
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 help message should start with a verb in active voice. Change "Identity assignment restriction, used to restrict..." to "Restrict the resources that can be assigned to the identity."