Skip to content

Commit 175c597

Browse files
authored
Update Policy CRUD cmdlets (#24361)
* Update to autorest 4.x Update to Azure Policy 2023-04-01 Move to non-versioned interface types Complete full test suite for existing cmdlets Few bug fixes Add completer for Location parameter Fix record/playback, remove -LiveOnly tags Make test names repeatable to work with record/playback Implement resource group functions that became inaccessible Fix test failures due to default parameter injection * Clean up some transforms in README Remove unsupported (for now) parameters Streamline common test code Move common test code to utils.ps1 Add serialization of test variables to env.json * Remove extra parameters from Get-AzPolicyAssignment Rerecord the tests
1 parent a9229ad commit 175c597

File tree

92 files changed

+15439
-13284
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

92 files changed

+15439
-13284
lines changed

src/Resources/Policy.Autorest/README.md

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -330,8 +330,8 @@ directive:
330330
# For some reason these can't be hidden by hiding them in
331331
# the custom folder so we have to do it here.
332332
- where:
333-
verb: New
334-
subject: PolicyAssignment
333+
verb: New|Update
334+
subject: PolicyAssignment|PolicyExemption
335335
parameter-name: PolicyDefinitionId|ResourceSelector|Override
336336
hide: true
337337
- where:
@@ -341,18 +341,22 @@ directive:
341341
hide: true
342342
- where:
343343
verb: New|Update
344-
subject: PolicyExemption
345-
parameter-name: ResourceSelector
344+
subject: PolicyDefinition|PolicySetDefinition
345+
parameter-name: Version|PropertiesVersions
346+
hide: true
347+
- where:
348+
verb: Get
349+
parameter-name: Top
346350
hide: true
347351

348-
# Hide cmdlets that are customized or not supported at all
352+
# Remove or hide cmdlets that are customized or not supported at all
349353
- where:
350354
verb: Get|Remove|Update
351355
hide: true
352356
- where:
353357
verb: New|Remove|Update
354358
subject: PolicyDefinitionVersion|PolicySetDefinitionVersion
355-
hide: true
359+
remove: true
356360

357361
metadata:
358362
scriptsToProcess:

src/Resources/Policy.Autorest/custom/Get-AzPolicyAssignment.ps1

Lines changed: 0 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -75,21 +75,6 @@ param(
7575
# Get all policy assignments that target the given policy definition [fully qualified] ID.
7676
${IncludeDescendent},
7777

78-
# This switch is implemented and working, but confusing, since -Top is a misleading name. Due to backend implementation
79-
# of $top, this parameter should actually be called -Pagesize. Addressing this issue is beyond the scope of the initial
80-
# port to autorest: we will address this in the future and hide the parameter for now to avoid future backcompat complexity.
81-
[Parameter(ParameterSetName='Default', ValueFromPipelineByPropertyName)]
82-
[Parameter(ParameterSetName='Scope', ValueFromPipelineByPropertyName)]
83-
[Parameter(ParameterSetName='PolicyDefinitionId', ValueFromPipelineByPropertyName)]
84-
[Parameter(ParameterSetName='IncludeDescendent', ValueFromPipelineByPropertyName)]
85-
[Parameter(ParameterSetName='Top', Mandatory, ValueFromPipelineByPropertyName)]
86-
[Microsoft.Azure.PowerShell.Cmdlets.Policy.Category('Query')]
87-
[System.Int32]
88-
# Maximum number of records to return.
89-
# When -Top is not provided, this cmdlet will return 500 or fewer records.
90-
[Parameter(DontShow)]
91-
${Top},
92-
9378
[Parameter()]
9479
[System.Management.Automation.SwitchParameter]
9580
# Causes cmdlet to return artifacts using legacy format placing policy-specific properties in a property bag object.
@@ -106,45 +91,6 @@ param(
10691
# If $filter=policyDefinitionId eq '{value}' is provided, the returned list includes all policy assignments of the policy definition whose id is {value}.
10792
${Filter},
10893

109-
[Parameter(DontShow)]
110-
[Microsoft.Azure.PowerShell.Cmdlets.Policy.Category('Path')]
111-
[System.String]
112-
# The name of the resource group that contains policy assignments.
113-
${ResourceGroupName},
114-
115-
[Parameter(DontShow)]
116-
[Microsoft.Azure.PowerShell.Cmdlets.Policy.Category('Path')]
117-
[System.String[]]
118-
# The ID of the target subscription.
119-
${SubscriptionId},
120-
121-
[Parameter(DontShow)]
122-
[Microsoft.Azure.PowerShell.Cmdlets.Policy.Category('Path')]
123-
[System.String]
124-
# The parent resource path.
125-
# Use empty string if there is none.
126-
${ParentResourcePath},
127-
128-
[Parameter(DontShow)]
129-
[Microsoft.Azure.PowerShell.Cmdlets.Policy.Category('Path')]
130-
[System.String]
131-
# The name of the resource.
132-
${ResourceName},
133-
134-
[Parameter(DontShow)]
135-
[Microsoft.Azure.PowerShell.Cmdlets.Policy.Category('Path')]
136-
[System.String]
137-
# The namespace of the resource provider.
138-
# For example, the namespace of a virtual machine is Microsoft.Compute (from Microsoft.Compute/virtualMachines)
139-
${ResourceProviderNamespace},
140-
141-
[Parameter(DontShow)]
142-
[Microsoft.Azure.PowerShell.Cmdlets.Policy.Category('Path')]
143-
[System.String]
144-
# The resource type name.
145-
# For example the type name of a web app is 'sites' (from Microsoft.Web/sites).
146-
${ResourceType},
147-
14894
[Parameter(DontShow)]
14995
[Microsoft.Azure.PowerShell.Cmdlets.Policy.Category('Path')]
15096
[Microsoft.Azure.PowerShell.Cmdlets.Policy.Models.IPolicyIdentity]
@@ -229,10 +175,6 @@ process {
229175

230176
$calledParameters = $PSBoundParameters
231177

232-
# SubscriptionId is autorest-generated and mandatory so gets populated with default value.
233-
# This customized cmdlet doesn't allow/use it, so we must remove it, otherwise the parameter set is broken.
234-
$null = $calledParameters.Remove('SubscriptionId')
235-
236178
if ($Name) {
237179
$calledParameterSet = 'Get'
238180
$calledParameters.NameInternal = $Name

src/Resources/Policy.Autorest/custom/Get-AzPolicyDefinition.ps1

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -88,23 +88,6 @@ param(
8888
# Causes cmdlet to return only static policy definitions.
8989
${Static},
9090

91-
# This switch is implemented and working, but confusing, since -Top is a misleading name. Due to backend implementation
92-
# of $top, this parameter should actually be called -Pagesize. Addressing this issue is beyond the scope of the initial
93-
# port to autorest: we will address this in the future and hide the parameter for now to avoid future backcompat complexity.
94-
[Parameter(ParameterSetName='Name', ValueFromPipelineByPropertyName)]
95-
[Parameter(ParameterSetName='SubscriptionId', ValueFromPipelineByPropertyName)]
96-
[Parameter(ParameterSetName='ManagementGroupName', ValueFromPipelineByPropertyName)]
97-
[Parameter(ParameterSetName='BuiltIn', ValueFromPipelineByPropertyName)]
98-
[Parameter(ParameterSetName='Custom', ValueFromPipelineByPropertyName)]
99-
[Parameter(ParameterSetName='Static', ValueFromPipelineByPropertyName)]
100-
[Parameter(ParameterSetName='Top', Mandatory, ValueFromPipelineByPropertyName)]
101-
[Microsoft.Azure.PowerShell.Cmdlets.Policy.Category('Query')]
102-
[System.Int32]
103-
# Maximum number of records to return.
104-
# When -Top is not provided, this cmdlet will return 500 or fewer records.
105-
[Parameter(DontShow)]
106-
${Top},
107-
10891
[Parameter()]
10992
[System.Management.Automation.SwitchParameter]
11093
# Causes cmdlet to return artifacts using legacy format placing policy-specific properties in a property bag object.

src/Resources/Policy.Autorest/custom/Get-AzPolicySetDefinition.ps1

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -80,21 +80,6 @@ param(
8080
# Causes cmdlet to return only custom policy definitions.
8181
${Custom},
8282

83-
# This switch is implemented and working, but confusing, since -Top is a misleading name. Due to backend implementation
84-
# of $top, this parameter should actually be called -Pagesize. Addressing this is beyond the scope of the initial port
85-
# to autorest: we will address this in the future and hide the parameter for now to avoid future backcompat complexity.
86-
[Parameter(ParameterSetName='Name', ValueFromPipelineByPropertyName)]
87-
[Parameter(ParameterSetName='SubscriptionId', ValueFromPipelineByPropertyName)]
88-
[Parameter(ParameterSetName='BuiltIn', ValueFromPipelineByPropertyName)]
89-
[Parameter(ParameterSetName='Custom', ValueFromPipelineByPropertyName)]
90-
[Parameter(ParameterSetName='Top', Mandatory, ValueFromPipelineByPropertyName)]
91-
[Microsoft.Azure.PowerShell.Cmdlets.Policy.Category('Query')]
92-
[System.Int32]
93-
# Maximum number of records to return.
94-
# When -Top is not provided, this cmdlet will return 500 or fewer records.
95-
[Parameter(DontShow)]
96-
${Top},
97-
9883
[Parameter()]
9984
[System.Management.Automation.SwitchParameter]
10085
# Causes cmdlet to return artifacts using legacy format placing policy-specific properties in a property bag object.

src/Resources/Policy.Autorest/docs/Get-AzPolicyAssignment.md

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,6 @@ Get-AzPolicyAssignment -PolicyDefinitionId <String> [-Scope <String>] [-Backward
4545
Get-AzPolicyAssignment -Scope <String> [-BackwardCompatible] [-DefaultProfile <PSObject>] [<CommonParameters>]
4646
```
4747

48-
### Top
49-
```
50-
Get-AzPolicyAssignment [-BackwardCompatible] [-DefaultProfile <PSObject>] [<CommonParameters>]
51-
```
52-
5348
## DESCRIPTION
5449
The **Get-AzPolicyAssignment** cmdlet gets all policy assignments or particular assignments.
5550
Identify a policy assignment to get by name and scope or by ID.

src/Resources/Policy.Autorest/docs/Get-AzPolicyDefinition.md

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,6 @@ Get-AzPolicyDefinition -SubscriptionId <String> [-Name <String>] [-BackwardCompa
5353
[-DefaultProfile <PSObject>] [<CommonParameters>]
5454
```
5555

56-
### Top
57-
```
58-
Get-AzPolicyDefinition [-BackwardCompatible] [-DefaultProfile <PSObject>] [<CommonParameters>]
59-
```
60-
6156
## DESCRIPTION
6257
The **Get-AzPolicySetDefinition** cmdlet gets a collection of policy set definitions or a specific policy set definition identified by name or ID.
6358

src/Resources/Policy.Autorest/docs/Get-AzPolicySetDefinition.md

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,6 @@ Get-AzPolicySetDefinition -SubscriptionId <String> [-Name <String>] [-BackwardCo
4747
[-DefaultProfile <PSObject>] [<CommonParameters>]
4848
```
4949

50-
### Top
51-
```
52-
Get-AzPolicySetDefinition [-BackwardCompatible] [-DefaultProfile <PSObject>] [<CommonParameters>]
53-
```
54-
5550
## DESCRIPTION
5651
The **Get-AzPolicySetDefinition** cmdlet gets a collection of policy set definitions or a specific policy set definition identified by name or ID.
5752

src/Resources/Policy.Autorest/test/Backcompat/Backcompat-GetBuiltinsByName.Recording.json

Lines changed: 2815 additions & 2815 deletions
Large diffs are not rendered by default.

src/Resources/Policy.Autorest/test/Backcompat/Backcompat-GetCmdletFilterParameter.Recording.json

Lines changed: 90 additions & 90 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)