Skip to content

Commit

Permalink
[ARM] Bump version of azure-mgmt-managementgroups from 0.2.0 to `…
Browse files Browse the repository at this point in the history
…1.0.0` (Track 2 SDK) and add new sub commands for management-group (#20942)

* Updated version number for azure-mgmt-managementgroups sdk

* Updated exception handler file to resolve errors in pipeline

* Re-ran some tests in live mode

* Modified the update method for managementgroups and re-ran tests in live mode

* Ran tests in latest and 2019_03_01 Profile

* Re-ran tests in live mode under test_resource

* Updated management-group so that it now passes the style and linter checks

* Added new commands from the managementgroups api

* Passed style check

* Re-ran unit tests after update to PATCH in the MG codebase

* Re-ran tests in the 2019_03_01 profile

* Ran a test in policyinsights

* Made changes based on the PR comments
  • Loading branch information
git-thomasdolan authored Feb 22, 2022
1 parent 3d75c8e commit 03932ec
Show file tree
Hide file tree
Showing 58 changed files with 20,006 additions and 6,835 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ interactions:
accept-language:
- en-US
method: PUT
uri: https://management.azure.com/providers/Microsoft.Management/managementGroups/cli-test-mg000003?api-version=2018-03-01-preview
uri: https://management.azure.com/providers/Microsoft.Management/managementGroups/cli-test-mg000003?api-version=2021-04-01
response:
body:
string: '{"id":"/providers/Microsoft.Management/managementGroups/cli-test-mg000003","type":"/providers/Microsoft.Management/managementGroups","name":"cli-test-mg000003","status":"NotStarted"}'
Expand All @@ -132,7 +132,7 @@ interactions:
expires:
- '-1'
location:
- https://management.azure.com/providers/Microsoft.Management/operationResults/create/managementGroups/cli-test-mg000003?api-version=2018-03-01-preview
- https://management.azure.com/providers/Microsoft.Management/operationResults/create/managementGroups/cli-test-mg000003?api-version=2021-04-01
pragma:
- no-cache
request-id:
Expand Down Expand Up @@ -169,7 +169,7 @@ interactions:
- python/3.8.8 (Windows-10-10.0.19041-SP0) msrest/0.6.21 msrest_azure/0.6.3
azure-mgmt-managementgroups/0.2.0 Azure-SDK-For-Python AZURECLI/2.30.0
method: GET
uri: https://management.azure.com/providers/Microsoft.Management/operationResults/create/managementGroups/cli-test-mg000003?api-version=2018-03-01-preview
uri: https://management.azure.com/providers/Microsoft.Management/operationResults/create/managementGroups/cli-test-mg000003?api-version=2021-04-01
response:
body:
string: '{"id":"/providers/Microsoft.Management/managementGroups/cli-test-mg000003","type":"/providers/Microsoft.Management/managementGroups","name":"cli-test-mg000003","status":"Running"}'
Expand All @@ -185,7 +185,7 @@ interactions:
expires:
- '-1'
location:
- https://management.azure.com/providers/Microsoft.Management/operationResults/create/managementGroups/cli-test-mg000003?api-version=2018-03-01-preview
- https://management.azure.com/providers/Microsoft.Management/operationResults/create/managementGroups/cli-test-mg000003?api-version=2021-04-01
pragma:
- no-cache
request-id:
Expand Down Expand Up @@ -218,7 +218,7 @@ interactions:
- python/3.8.8 (Windows-10-10.0.19041-SP0) msrest/0.6.21 msrest_azure/0.6.3
azure-mgmt-managementgroups/0.2.0 Azure-SDK-For-Python AZURECLI/2.30.0
method: GET
uri: https://management.azure.com/providers/Microsoft.Management/operationResults/create/managementGroups/cli-test-mg000003?api-version=2018-03-01-preview
uri: https://management.azure.com/providers/Microsoft.Management/operationResults/create/managementGroups/cli-test-mg000003?api-version=2021-04-01
response:
body:
string: '{"id":"/providers/Microsoft.Management/managementGroups/cli-test-mg000003","type":"/providers/Microsoft.Management/managementGroups","name":"cli-test-mg000003","status":"Succeeded","properties":{"tenantId":"72f988bf-86f1-41af-91ab-2d7cd011db47","displayName":"cli-test-mg000003","details":{"version":1,"updatedTime":"2021-11-23T00:37:21.1188471Z","updatedBy":"0dc80135-ae53-4da3-8695-220a2d93aad8","parent":{"id":"/providers/Microsoft.Management/managementGroups/72f988bf-86f1-41af-91ab-2d7cd011db47","name":"72f988bf-86f1-41af-91ab-2d7cd011db47","displayName":"72f988bf-86f1-41af-91ab-2d7cd011db47"}}}}'
Expand Down Expand Up @@ -852,7 +852,7 @@ interactions:
accept-language:
- en-US
method: DELETE
uri: https://management.azure.com/providers/Microsoft.Management/managementGroups/cli-test-mg000003?api-version=2018-03-01-preview
uri: https://management.azure.com/providers/Microsoft.Management/managementGroups/cli-test-mg000003?api-version=2021-04-01
response:
body:
string: '{"id":"/providers/Microsoft.Management/managementGroups/cli-test-mg000003","type":"/providers/Microsoft.Management/managementGroups","name":"cli-test-mg000003","status":"NotStarted"}'
Expand All @@ -868,7 +868,7 @@ interactions:
expires:
- '-1'
location:
- https://management.azure.com/providers/Microsoft.Management/operationResults/delete/managementGroups/cli-test-mg000003?api-version=2018-03-01-preview
- https://management.azure.com/providers/Microsoft.Management/operationResults/delete/managementGroups/cli-test-mg000003?api-version=2021-04-01
pragma:
- no-cache
request-id:
Expand Down Expand Up @@ -905,7 +905,7 @@ interactions:
- python/3.8.8 (Windows-10-10.0.19041-SP0) msrest/0.6.21 msrest_azure/0.6.3
azure-mgmt-managementgroups/0.2.0 Azure-SDK-For-Python AZURECLI/2.30.0
method: GET
uri: https://management.azure.com/providers/Microsoft.Management/operationResults/delete/managementGroups/cli-test-mg000003?api-version=2018-03-01-preview
uri: https://management.azure.com/providers/Microsoft.Management/operationResults/delete/managementGroups/cli-test-mg000003?api-version=2021-04-01
response:
body:
string: '{"id":"/providers/Microsoft.Management/managementGroups/cli-test-mg000003","type":"/providers/Microsoft.Management/managementGroups","name":"cli-test-mg000003","status":"Succeeded"}'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,10 @@ def cf_resource_managedappdefinitions(cli_ctx, _):
return _resource_managedapps_client_factory(cli_ctx).application_definitions


def cf_management_groups_mixin(cli_ctx, _):
return _resource_managementgroups_client_factory(cli_ctx)


def cf_management_groups(cli_ctx, _):
return _resource_managementgroups_client_factory(cli_ctx).management_groups

Expand All @@ -136,5 +140,13 @@ def cf_management_group_subscriptions(cli_ctx, _):
return _resource_managementgroups_client_factory(cli_ctx).management_group_subscriptions


def cf_management_group_entities(cli_ctx, _):
return _resource_managementgroups_client_factory(cli_ctx).entities


def cf_hierarchy_settings(cli_ctx, _):
return _resource_managementgroups_client_factory(cli_ctx).hierarchy_settings


def cf_resource_templatespecs(cli_ctx, _):
return _resource_templatespecs_client_factory(cli_ctx).template_specs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@


def managementgroups_exception_handler(ex):
from azure.mgmt.managementgroups.models import ErrorResponseException
if isinstance(ex, ErrorResponseException):
from azure.core.exceptions import HttpResponseError
if isinstance(ex, HttpResponseError):
if ex.error.error:
raise CLIError(ex.error.error)
raise CLIError(ex.error)
Expand Down
176 changes: 176 additions & 0 deletions src/azure-cli/azure/cli/command_modules/resource/_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,45 @@
short-summary: Manage Azure Management Groups.
"""

helps['account management-group tenant-backfill'] = """
type: group
short-summary: Backfill Tenant Subscription Operations for Management Groups
"""

helps['account management-group tenant-backfill get'] = """
type: command
short-summary: Get the backfill status for a tenant.
long-summary: Get the backfill status for a tenant.
examples:
- name: Get the backfill status for a tenant.
text: >
az account management-group tenant-backfill get
"""

helps['account management-group tenant-backfill start'] = """
type: command
short-summary: Start backfilling subscriptions for a tenant.
long-summary: Start backfilling subscriptions for a tenant.
examples:
- name: Start backfilling subscriptions for a tenant.
text: >
az account management-group tenant-backfill start
"""

helps['account management-group check-name-availability'] = """
type: command
short-summary: Check if a Management Group Name is Valid.
long-summary: Check if a Management Group Name is Valid.
parameters:
- name: --name -n
type: string
short-summary: Name of the management group.
examples:
- name: Check if a Management Group Name is Valid.
text: >
az account management-group check-name-availability --name GroupName
"""

helps['account management-group create'] = """
type: command
short-summary: Create a new management group.
Expand Down Expand Up @@ -163,6 +202,52 @@
az account management-group subscription add --name GroupName --subscription Subscription
"""

helps['account management-group subscription show'] = """
type: command
short-summary: Show the details of a subscription under a known management group.
long-summary: Show the details of a subscription under a known management group.
parameters:
- name: --name -n
type: string
short-summary: Name of the management group.
- name: --subscription -s
type: string
short-summary: Subscription Id or Name
examples:
- name: Show the details of a subscription under a known management group.
text: >
az account management-group subscription show --name GroupName --subscription Subscription
"""

helps['account management-group subscription show-sub-under-mg'] = """
type: command
short-summary: Get the subscription under a management group.
long-summary: Get the subscription under a management group.
parameters:
- name: --name -n
type: string
short-summary: Name of the management group.
examples:
- name: Get the subscription under a management group.
text: >
az account management-group subscription show-sub-under-mg --name GroupName
"""

helps['account management-group entities'] = """
type: group
short-summary: Entity operations (Management Group and Subscriptions) for Management Groups.
"""

helps['account management-group entities list'] = """
type: command
short-summary: List all entities for the authenticated user.
long-summary: List all entities for the authenticated user.
examples:
- name: List all entities for the authenticated user.
text: >
az account management-group entities list
"""

helps['account management-group subscription remove'] = """
type: command
short-summary: Remove an existing subscription from a management group.
Expand Down Expand Up @@ -206,6 +291,97 @@
az account management-group update --name GroupName --display-name DisplayName --parent ParentId/ParentName
"""

helps['account management-group hierarchy-settings'] = """
type: group
short-summary: Provide operations for hierarchy settings defined at the management group level. Settings can only be set on the root Management Group of the hierarchy.
"""

helps['account management-group hierarchy-settings create'] = """
type: command
short-summary: Create hierarchy settings defined at the Management Group level.
long-summary: Create hierarchy settings defined at the Management Group level.
parameters:
- name: --name -n
type: string
short-summary: Name of the management group.
- name: --default-management-group -m
type: string
short-summary: Set the default Management Group under which new subscriptions get added in this tenant. Default setting is the Root Management Group.
- name: --require-authorization-for-group-creation -r
type: boolean
short-summary: Indicate whether RBAC access is required upon group creation under the root Management Group. True means user will require Microsoft.Management/managementGroups/write action on the root Management Group. Default setting is false.
examples:
- name: Create hierarchy settings defined at the Management Group level.
text: >
az account management-group hierarchy-settings create --name GroupName
- name: Set the default Management Group new Subscriptions get placed under.
text: >
az account management-group hierarchy-settings create --name GroupName -m /providers/Microsoft.Management/managementGroups/DefaultGroup
- name: Require user to have Microsoft.Management/managementGroups/write access on the Root to create new Management Groups under the Root.
text: >
az account management-group hierarchy-settings create --name GroupName -r True
- name: Update both hierarchy settings.
text: >
az account management-group hierarchy-settings create --name GroupName -m /providers/Microsoft.Management/managementGroups/DefaultGroup -r True
"""

helps['account management-group hierarchy-settings list'] = """
type: command
short-summary: Get all the hierarchy settings defined at the Management Group level.
long-summary: Get all the hierarchy settings defined at the Management Group level.
parameters:
- name: --name -n
type: string
short-summary: Name of the management group.
examples:
- name: Get all hierarchy settings defined at the Management Group level.
text: >
az account management-group hierarchy-settings list --name GroupName
"""

helps['account management-group hierarchy-settings delete'] = """
type: command
short-summary: Delete the hierarchy settings defined at the Management Group level.
long-summary: Delete the hierarchy settings defined at the Management Group level.
parameters:
- name: --name -n
type: string
short-summary: Name of the management group.
examples:
- name: Delete all hierarchy settings defined at the Management Group level.
text: >
az account management-group hierarchy-settings delete --name GroupName
"""

helps['account management-group hierarchy-settings update'] = """
type: command
short-summary: Update the hierarchy settings defined at the Management Group level.
long-summary: Update the hierarchy settings defined at the Management Group level.
parameters:
- name: --name -n
type: string
short-summary: Name of the management group.
- name: --default-management-group -m
type: string
short-summary: Set the default Management Group under which new subscriptions get added in this tenant. Default setting is the Root Management Group.
- name: --require-authorization-for-group-creation -r
type: boolean
short-summary: Indicate whether RBAC access is required upon group creation under the root Management Group. True means user will require Microsoft.Management/managementGroups/write action on the root Management Group. Default setting is false.
examples:
- name: Create hierarchy settings defined at the Management Group level.
text: >
az account management-group hierarchy-settings update --name GroupName
- name: Set the default Management Group new Subscriptions get placed under.
text: >
az account management-group hierarchy-settings update --name GroupName -m /providers/Microsoft.Management/managementGroups/DefaultGroup
- name: Require user to have Microsoft.Management/managementGroups/write access on the Root to create new Management Groups under the Root.
text: >
az account management-group hierarchy-settings update --name GroupName -r True
- name: Update both hierarchy settings.
text: >
az account management-group hierarchy-settings update --name GroupName -m /providers/Microsoft.Management/managementGroups/DefaultGroup -r True
"""

helps['deployment'] = """
type: group
short-summary: Manage Azure Resource Manager template deployment at subscription scope.
Expand Down
8 changes: 8 additions & 0 deletions src/azure-cli/azure/cli/command_modules/resource/_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -591,6 +591,14 @@ def load_arguments(self, _):
c.argument('display_name', options_list=['--display-name', '-d'])
c.argument('parent_id', options_list=['--parent', '-p'])

with self.argument_context('account management-group hierarchy-settings create') as c:
c.argument('default_management_group', options_list=['--default-management-group', '-m'])
c.argument('require_authorization_for_group_creation', options_list=['--require-authorization-for-group-creation', '-r'])

with self.argument_context('account management-group hierarchy-settings update') as c:
c.argument('default_management_group', options_list=['--default-management-group', '-m'])
c.argument('require_authorization_for_group_creation', options_list=['--require-authorization-for-group-creation', '-r'])

with self.argument_context('ts') as c:
c.argument('name', options_list=['--name', '-n'], help='The name of the template spec.')
c.argument('version', options_list=['--version', '-v'], help='The template spec version.')
Expand Down
Loading

0 comments on commit 03932ec

Please sign in to comment.