Skip to content

Conversation

@git-thomasdolan
Copy link

@git-thomasdolan git-thomasdolan commented Dec 7, 2021


closed Azure/azure-cli#20265

This checklist is used to make sure that common guidelines for a pull request are followed.

General Guidelines

  • Have you run azdev style <YOUR_EXT> locally? (pip install azdev required)
  • Have you run python scripts/ci/test_index.py -q locally?

For new extensions:

About Extension Publish

There is a pipeline to automatically build, upload and publish extension wheels.
Once your PR is merged into master branch, a new PR will be created to update src/index.json automatically.
The precondition is to put your code inside this repo and upgrade the version in the PR but do not modify src/index.json.

@ghost ghost added the customer-reported Issues that are reported by GitHub users external to the Azure organization. label Dec 7, 2021
@ghost
Copy link

ghost commented Dec 7, 2021

Thank you for your contribution git-thomasdolan! We will review the pull request and get back to you soon.

@ghost
Copy link

ghost commented Dec 7, 2021

CLA assistant check
All CLA requirements met.

@git-thomasdolan git-thomasdolan changed the title Thomasdolan/managementgroup_extension Adding the az managementgroup extension for Management Groups Dec 10, 2021
@git-thomasdolan git-thomasdolan marked this pull request as ready for review December 10, 2021 23:44
@yonzhan
Copy link
Collaborator

yonzhan commented Dec 21, 2021

managementgroup

@yonzhan yonzhan added this to the Jan 2022 (2022-02-01) milestone Dec 21, 2021

/src/init/ @zhoxing-ms @HuangYT2000

/src/managementgroup/ @kairu-ms
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@git-thomasdolan Just out of curiosity, is this extension the owned by your team or Azure CLI team?
If your team is responsible for it's development and maintenance, the owner should be a member from your team

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since I generated the commands, I can put myself as an owner

Comment on lines +17 to +37
##### Show #####
```
az managementgroup management-group show --group-id "20000000-0001-0000-0000-000000000000"
```
##### Show #####
```
az managementgroup management-group show --expand "ancestors" --group-id "20000000-0001-0000-0000-00000000000"
```
##### Show #####
```
az managementgroup management-group show --expand "children" --group-id "20000000-0001-0000-0000-000000000000"
```
##### Show #####
```
az managementgroup management-group show --expand "path" --group-id "20000000-0001-0000-0000-000000000000"
```
##### Show #####
```
az managementgroup management-group show --expand "children" --recurse true \
--group-id "20000000-0001-0000-0000-000000000000"
```
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Show

Could we have a more detailed description of this title, or could we put similar contents together under one title

'subscriptions from results (i.e. \'$filter=children.childType ne Subscription\')')

with self.argument_context('managementgroup management-group-subscription create') as c:
c.argument('group_id', type=str, help='Management Group ID.')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

type=str is the default setting, it does not need to be explicitly declared

Comment on lines +95 to +98
c.argument('skiptoken', type=str, help='Page continuation token is only used if a previous operation returned '
'a partial result. If a previous response contains a nextLink element, the value of the nextLink '
'element will include a token parameter that specifies a starting point to use for subsequent '
'calls.')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above

Comment on lines +132 to +135
c.argument('skiptoken', type=str, help='Page continuation token is only used if a previous operation returned '
'a partial result. If a previous response contains a nextLink element, the value of the nextLink '
'element will include a token parameter that specifies a starting point to use for subsequent '
'calls.')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above

Comment on lines +140 to +161
c.argument('select', type=str, help='This parameter specifies the fields to include in the response. Can '
'include any combination of Name,DisplayName,Type,ParentDisplayNameChain,ParentChain, e.g. '
'\'$select=Name,DisplayName,Type,ParentDisplayNameChain,ParentNameChain\'. When specified the '
'$select parameter can override select in $skipToken.')
c.argument('search', arg_type=get_enum_type(['AllowedParents', 'AllowedChildren',
'ParentAndFirstLevelChildren', 'ParentOnly', 'ChildrenOnly']),
help='The $search parameter is used in conjunction with the $filter parameter to return three '
'different outputs depending on the parameter passed in. With $search=AllowedParents the API will '
'return the entity info of all groups that the requested entity will be able to reparent to as '
'determined by the user\'s permissions. With $search=AllowedChildren the API will return the entity '
'info of all entities that can be added as children of the requested entity. With '
'$search=ParentAndFirstLevelChildren the API will return the parent and first level of children '
'that the user has either direct access to or indirect access via one of their descendants. With '
'$search=ParentOnly the API will return only the group if the user has access to at least one of '
'the descendants of the group. With $search=ChildrenOnly the API will return only the first level '
'of children of the group entity info specified in $filter. The user must have direct access to '
'the children entities or one of it\'s descendants for it to show up in the results.')
c.argument('filter_', options_list=['--filter'], type=str, help='The filter parameter allows you to filter on '
'the the name or display name fields. You can check for equality on the name field (e.g. name eq '
'\'{entityName}\') and you can check for substrings on either the name or display name fields(e.g. '
'contains(name, \'{substringToSearch}\'), contains(displayName, \'{substringToSearch\')). Note that '
'the \'{entityName}\' and \'{substringToSearch}\' fields are checked case insensitively.')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please refine the help message, because It seems to illustrate the feature of this parameter from the perspective of REST API rather than from the perspective of command parameters.
Please explain the parameters from the perspective of command parameters, otherwise users will be confused.

Comment on lines +165 to +166
c.argument('group_name', type=str, help='A filter which allows the get entities call to focus on a particular '
'group (i.e. "$filter=name eq \'groupName\'")')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please refine the help message, because It seems to illustrate the feature of this parameter from the perspective of REST API rather than from the perspective of command parameters.
Please explain the parameters from the perspective of command parameters, otherwise users will be confused.

Comment on lines +95 to +99
g.custom_command('show-subscription', 'managementgroup_management_group_subscription_show_subscription')
g.custom_command(
'show-subscription-under-management-group',
'managementgroup_management_group_subscription_show_subscription_under_management_group',
)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The command signature show-subscription-under-management-group seems to be too long and inconvenient for users to input
Could we distinguish these two scenarios by parameters rather than by command signature?

Comment on lines 61 to 82
step_entity_list(test, checks=[])
#step_hierarchy_setting_create(test, checks=[])
#step_hierarchy_setting_show(test, checks=[])
#step_hierarchy_setting_list(test, checks=[])
#step_hierarchy_setting_update(test, checks=[])
#step_hierarchy_setting_delete(test, checks=[])
step_start_tenant_backfill(test, checks=[])
step_tenant_backfill_status(test, checks=[])
step_management_group_create(test, checks=[])
step_management_group_show_descendant(test, checks=[])
step_management_group_show(test, checks=[])
step_management_group_show2(test, checks=[])
step_management_group_show3(test, checks=[])
step_management_group_show4(test, checks=[])
step_management_group_show5(test, checks=[])
step_management_group_list(test, checks=[])
step_management_group_update(test, checks=[])
step_management_group_delete(test, checks=[])
#step_management_group_subscription_create(test, checks=[])
#step_management_group_subscription(test, checks=[])
#step_management_group_subscription2(test, checks=[])
#step_management_group_subscription_delete(test, checks=[])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add checks for those tests

"Command": "az azurestackhci",
"AzureServiceName": "Azure Stack HCI",
"URL": "https://docs.microsoft.com/en-us/cli/azure/azurestackhci?view=azure-cli-latest"
"URL": "https://docs.microsoft.com/en-us/cli/azure/stack-hci?view=azure-cli-latest"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

May I ask why do you need to modify this URL?

@zhoxing-ms
Copy link
Contributor

zhoxing-ms commented Jan 6, 2022

I see that some commands with the same features have been included in the official CLI, could you confirm it? code link
If so, please delete these duplicate commands in this PR

@git-thomasdolan
Copy link
Author

I see that some commands with the same features have been included in the official CLI, could you confirm it? code link If so, please delete these duplicate commands in this PR

Yes, the commands have the same features in this new extension as they do in the link you sent. However, that has not been updated in a long time. I believe the 'az account managementgroup' is a 2018 API. There have been changes to those commands and new commands have been added to our API. So the 'az account managementgroup' also needs to be updated or it should be replaced by this new extension. What would you recommend?

@zhoxing-ms
Copy link
Contributor

zhoxing-ms commented Jan 7, 2022

@git-thomasdolan I suggest updating those commands in CLI main repo, including upgrading the api-version for ManagementGroupsAPI and Python SDK version for azure-mgmt-managementgroups, and then removing the new commands which with duplicate features in CLI extension.

Because the commands with same features in CLI should not have two different interactive interfaces, otherwise it will increase the user's additional learning cost and confuse users.
Since these commands have been included in the official CLI before, if they are replaced by the new commands in the CLI extension, it will lead to breaking changes.
Therefore, the above is the reason why I recommend it.

@git-thomasdolan
Copy link
Author

@zhoxing-ms I started looking into what you mentioned yesterday and it seems like the python sdk for management groups was updated to our latest version here. If that's the case, why would the current managementgroup cli main module look at an older version?

@zhoxing-ms
Copy link
Contributor

zhoxing-ms commented Jan 9, 2022

@git-thomasdolan This is because the Python SDK version used in CLI is still the older version. code link
So you need to bump the version of azure-mgmt-managementgroups in CLI from 0.2.0 to the latest version
For how to bump SDK version, You can refer to this PR Azure/azure-cli#20837

@git-thomasdolan
Copy link
Author

@zhoxing-ms I Created a draft PR here. Found that the latest version of the azure-mgt-managementgroup python sdk is 1.0.0. Do I need to update the tests for managementgroup? If so how do I test? I have only done tests for the cli extensions so I am unfamiliar with this process.

@zhoxing-ms
Copy link
Contributor

@git-thomasdolan Hi, I have commented here Azure/azure-cli#20942 (comment)

@zhoxing-ms
Copy link
Contributor

@git-thomasdolan I'd like ask whether the contents in this PR are included in #20942? If we don't need this PR any more, please close it

@git-thomasdolan
Copy link
Author

This PR is not needed anymore, it is fully covered in #20942

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

customer-reported Issues that are reported by GitHub users external to the Azure organization.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support with Updating Management Groups CLI

3 participants