Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
48845e9
Update to autorest 4.x
mentat9 Mar 6, 2024
e2edce0
Clean up some transforms in README
mentat9 Mar 13, 2024
3c8cc6b
Merge from upstream
mentat9 Mar 13, 2024
609deaf
Remove extra parameters from Get-AzPolicyAssignment
mentat9 Mar 13, 2024
73eb4b5
Fix $testFilesFolder calculation to work on macOS/linux.
mentat9 Mar 18, 2024
e945b1e
Refresh from Azure fork
mentat9 Mar 18, 2024
c0a07f8
Hide generated parameter sets for New-*
mentat9 Mar 26, 2024
a7d5fb6
Merge branch 'generation-Resources-preview' of https://github.com/Azu…
mentat9 Mar 26, 2024
00784de
Replace Get-AzContext with Utils\Get-SubscriptionIdTestSafe
mentat9 Mar 27, 2024
3d011e0
Remove location completer from exports/docs/examples/help
mentat9 Mar 27, 2024
62965b7
Improve location completer tests
mentat9 Mar 27, 2024
84715cb
Remove transforms for Scope and Id parameters no longer needed
mentat9 Mar 28, 2024
66dc615
Change location completer to lazy load (vs. module load)
mentat9 Mar 30, 2024
cd6cb87
Merge from upstream
mentat9 Mar 30, 2024
1abce39
Merge branch 'generation-Resources-preview' of https://github.com/Azu…
mentat9 Apr 1, 2024
533a569
Minor updates for consistency
mentat9 Apr 2, 2024
8c2813f
Merge Yabo's changes
mentat9 Apr 2, 2024
69c8dae
Updates for consistency and to fix tests
mentat9 Apr 3, 2024
72cdc1f
Fix bad merge
mentat9 Apr 3, 2024
7a5dc72
Re-record tests
mentat9 Apr 3, 2024
6a3082b
Merge branch 'generation-Resources-preview' of https://github.com/Azu…
mentat9 Apr 3, 2024
52d7917
Merge branch 'generation-Resources-preview' of https://github.com/Azu…
mentat9 Apr 26, 2024
6f644d6
Implement feedback:
mentat9 Apr 27, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ param(
${IncludeDescendent},

[Parameter()]
[Obsolete('This parameter is a temporary bridge to new types and formats and will be removed in a future release.')]
[System.Management.Automation.SwitchParameter]
# Causes cmdlet to return artifacts using legacy format placing policy-specific properties in a property bag object.
${BackwardCompatible} = $false,
Expand Down
38 changes: 20 additions & 18 deletions src/Resources/Policy.Autorest/custom/Get-AzPolicyDefinition.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ param(
${Id},

[Parameter(ParameterSetName='ManagementGroupName', Mandatory, ValueFromPipelineByPropertyName)]
[Parameter(ParameterSetName='BuiltIn', ValueFromPipelineByPropertyName)]
[Parameter(ParameterSetName='Builtin', ValueFromPipelineByPropertyName)]
[Parameter(ParameterSetName='Custom', ValueFromPipelineByPropertyName)]
[Parameter(ParameterSetName='Static', ValueFromPipelineByPropertyName)]
[ValidateNotNullOrEmpty()]
Expand All @@ -61,7 +61,7 @@ param(
${ManagementGroupName},

[Parameter(ParameterSetName='SubscriptionId', Mandatory, ValueFromPipelineByPropertyName)]
[Parameter(ParameterSetName='BuiltIn', ValueFromPipelineByPropertyName)]
[Parameter(ParameterSetName='Builtin', ValueFromPipelineByPropertyName)]
[Parameter(ParameterSetName='Custom', ValueFromPipelineByPropertyName)]
[Parameter(ParameterSetName='Static', ValueFromPipelineByPropertyName)]
[ValidateNotNullOrEmpty()]
Expand All @@ -70,11 +70,11 @@ param(
# The ID of the target subscription.
${SubscriptionId},

[Parameter(ParameterSetName='BuiltIn', Mandatory, ValueFromPipelineByPropertyName)]
[Parameter(ParameterSetName='Builtin', Mandatory, ValueFromPipelineByPropertyName)]
[Microsoft.Azure.PowerShell.Cmdlets.Policy.Category('Query')]
[System.Management.Automation.SwitchParameter]
# Causes cmdlet to return only built-in policy definitions.
${BuiltIn},
${Builtin},

[Parameter(ParameterSetName='Custom', Mandatory, ValueFromPipelineByPropertyName)]
[Microsoft.Azure.PowerShell.Cmdlets.Policy.Category('Query')]
Expand All @@ -89,6 +89,7 @@ param(
${Static},

[Parameter()]
[Obsolete('This parameter is a temporary bridge to new types and formats and will be removed in a future release.')]
[System.Management.Automation.SwitchParameter]
# Causes cmdlet to return artifacts using legacy format placing policy-specific properties in a property bag object.
${BackwardCompatible} = $false,
Expand All @@ -101,7 +102,7 @@ param(
# If $filter is not provided, no filtering is performed.
# If $filter=atExactScope() is provided, the returned list only includes all policy definitions that at the given scope.
# If $filter='policyType -eq {value}' is provided, the returned list only includes all policy definitions whose type match the {value}.
# Possible policyType values are NotSpecified, BuiltIn, Custom, and Static.
# Possible policyType values are NotSpecified, Builtin, Custom, and Static.
# If $filter='category -eq {value}' is provided, the returned list only includes all policy definitions whose category match the {value}.
${Filter},

Expand Down Expand Up @@ -176,19 +177,20 @@ begin {
GetViaIdentity1 = 'Az.Policy.private\Get-AzPolicyDefinition_GetViaIdentity1';
List='Az.Policy.private\Get-AzPolicyDefinition_List';
List1='Az.Policy.private\Get-AzPolicyDefinition_List1';
BuiltInId='Az.Policy.private\Get-AzPolicyDefinitionBuilt_GetViaIdentity';
BuiltInGet='Az.Policy.private\Get-AzPolicyDefinitionBuilt_Get';
BuiltInList='Az.Policy.private\Get-AzPolicyDefinitionBuilt_List';
BuiltinId='Az.Policy.private\Get-AzPolicyDefinitionBuilt_GetViaIdentity';
BuiltinGet='Az.Policy.private\Get-AzPolicyDefinitionBuilt_Get';
BuiltinList='Az.Policy.private\Get-AzPolicyDefinitionBuilt_List';
}
}

process {
$PSBoundParameters['ErrorAction'] = 'Stop'

if ($writeln) {
Write-Host -ForegroundColor Cyan "process:Get-AzPolicyDefinition(" $PSBoundParameters ") - (ParameterSet: $($PSCmdlet.ParameterSetName))"
}

# ensure fallback try/catch is invoked if necessary
$PSBoundParameters['ErrorAction'] = 'Stop'

# handle disallowed cases not handled by PS parameter attributes
if ($PSBoundParameters['SubscriptionId'] -and $PSBoundParameters['ManagementGroupName']) {
throw 'Only ManagementGroupName or SubscriptionId can be provided, not both.'
Expand All @@ -199,8 +201,8 @@ process {
$calledParameterSet = 'List'

switch ($parameterSet) {
'BuiltIn' {
$PSBoundParameters.Add('Filter', "policyType eq 'BuiltIn'")
'Builtin' {
$PSBoundParameters.Add('Filter', "policyType eq 'Builtin'")
}
'Custom' {
$PSBoundParameters.Add('Filter', "policyType eq 'Custom'")
Expand All @@ -225,15 +227,15 @@ process {
$calledParameterSet = 'Get1';
}
'builtin' {
$calledParameterSet = 'BuiltInId'
$calledParameterSet = 'BuiltinId'
$PSBoundParameters['InputObject'] = @{ 'Id' = $PSBoundParameters['Id'] }
}
}
}
}

# this check is needed because builtin Ids are special (no subId, no mgId)
if ($calledParameterSet -ne 'BuiltInId') {
if ($calledParameterSet -ne 'BuiltinId') {
# determine parameter set for call to generated cmdlet
if ($PSBoundParameters['SubscriptionId']) {
if ($PSBoundParameters['Name']) {
Expand Down Expand Up @@ -264,7 +266,7 @@ process {
$null = $PSBoundParameters.Remove('BackwardCompatible')
$null = $PSBoundParameters.Remove('ManagementGroupName')
$null = $PSBoundParameters.Remove('Id')
$null = $PSBoundParameters.Remove('BuiltIn')
$null = $PSBoundParameters.Remove('Builtin')
$null = $PSBoundParameters.Remove('Custom')
$null = $PSBoundParameters.Remove('Static')

Expand All @@ -288,13 +290,13 @@ process {
$PSBoundParameters.PolicyDefinitionName = $PSBoundParameters.Name
$null = $PSBoundParameters.Remove('Name')
$null = $PSBoundParameters.Remove('SubscriptionId')
$cmdInfo = Get-Command -Name $mapping['BuiltInGet']
$cmdInfo = Get-Command -Name $mapping['BuiltinGet']
[Microsoft.Azure.PowerShell.Cmdlets.Policy.Runtime.MessageAttributeHelper]::ProcessCustomAttributesAtRuntime($cmdInfo, $MyInvocation, $calledParameterSet, $PSCmdlet)
$wrappedCmd = $ExecutionContext.InvokeCommand.GetCommand(($mapping['BuiltInGet']), [System.Management.Automation.CommandTypes]::Cmdlet)
$wrappedCmd = $ExecutionContext.InvokeCommand.GetCommand(($mapping['BuiltinGet']), [System.Management.Automation.CommandTypes]::Cmdlet)
$scriptCmd = {& $wrappedCmd @PSBoundParameters}

if ($writeln) {
Write-Host -ForegroundColor Blue -> $mapping['BuiltInGet']'(' $PSBoundParameters ')'
Write-Host -ForegroundColor Blue -> $mapping['BuiltinGet']'(' $PSBoundParameters ')'
}

$output = Invoke-Command -ScriptBlock $scriptCmd
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ param(
${IncludeDescendent},

[Parameter()]
[Obsolete('This parameter is a temporary bridge to new types and formats and will be removed in a future release.')]
[System.Management.Automation.SwitchParameter]
# Causes cmdlet to return artifacts using legacy format placing policy-specific properties in a property bag object.
${BackwardCompatible} = $false,
Expand Down
36 changes: 20 additions & 16 deletions src/Resources/Policy.Autorest/custom/Get-AzPolicySetDefinition.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ param(
${Id},

[Parameter(ParameterSetName='ManagementGroupName', Mandatory, ValueFromPipelineByPropertyName)]
[Parameter(ParameterSetName='BuiltIn', ValueFromPipelineByPropertyName)]
[Parameter(ParameterSetName='Builtin', ValueFromPipelineByPropertyName)]
[Parameter(ParameterSetName='Custom', ValueFromPipelineByPropertyName)]
[ValidateNotNullOrEmpty()]
[Microsoft.Azure.PowerShell.Cmdlets.Policy.Category('Path')]
Expand All @@ -60,19 +60,19 @@ param(
${ManagementGroupName},

[Parameter(ParameterSetName='SubscriptionId', Mandatory, ValueFromPipelineByPropertyName)]
[Parameter(ParameterSetName='BuiltIn', ValueFromPipelineByPropertyName)]
[Parameter(ParameterSetName='Builtin', ValueFromPipelineByPropertyName)]
[Parameter(ParameterSetName='Custom', ValueFromPipelineByPropertyName)]
[ValidateNotNullOrEmpty()]
[Microsoft.Azure.PowerShell.Cmdlets.Policy.Category('Path')]
[System.String]
# The ID of the target subscription.
${SubscriptionId},

[Parameter(ParameterSetName='BuiltIn', Mandatory, ValueFromPipelineByPropertyName)]
[Parameter(ParameterSetName='Builtin', Mandatory, ValueFromPipelineByPropertyName)]
[Microsoft.Azure.PowerShell.Cmdlets.Policy.Category('Query')]
[System.Management.Automation.SwitchParameter]
# Causes cmdlet to return only built-in policy definitions.
${BuiltIn},
${Builtin},

[Parameter(ParameterSetName='Custom', Mandatory, ValueFromPipelineByPropertyName)]
[Microsoft.Azure.PowerShell.Cmdlets.Policy.Category('Query')]
Expand All @@ -81,6 +81,7 @@ param(
${Custom},

[Parameter()]
[Obsolete('This parameter is a temporary bridge to new types and formats and will be removed in a future release.')]
[System.Management.Automation.SwitchParameter]
# Causes cmdlet to return artifacts using legacy format placing policy-specific properties in a property bag object.
${BackwardCompatible} = $false,
Expand All @@ -100,7 +101,7 @@ param(
# If $filter is not provided, no filtering is performed.
# If $filter=atExactScope() is provided, the returned list only includes all policy set definitions that at the given scope.
# If $filter='policyType -eq {value}' is provided, the returned list only includes all policy set definitions whose type match the {value}.
# Possible policyType values are NotSpecified, BuiltIn, Custom, and Static.
# Possible policyType values are NotSpecified, Builtin, Custom, and Static.
# If $filter='category -eq {value}' is provided, the returned list only includes all policy set definitions whose category match the {value}.
${Filter},

Expand Down Expand Up @@ -169,9 +170,9 @@ begin {
GetViaIdentity1 = 'Az.Policy.private\Get-AzPolicySetDefinition_GetViaIdentity1';
List = 'Az.Policy.private\Get-AzPolicySetDefinition_List';
List1 = 'Az.Policy.private\Get-AzPolicySetDefinition_List1';
BuiltInId='Az.Policy.private\Get-AzPolicySetDefinitionBuilt_GetViaIdentity';
BuiltInGet='Az.Policy.private\Get-AzPolicySetDefinitionBuilt_Get';
BuiltInList='Az.Policy.private\Get-AzPolicySetDefinitionBuilt_List';
BuiltinId='Az.Policy.private\Get-AzPolicySetDefinitionBuilt_GetViaIdentity';
BuiltinGet='Az.Policy.private\Get-AzPolicySetDefinitionBuilt_Get';
BuiltinList='Az.Policy.private\Get-AzPolicySetDefinitionBuilt_List';
}
}

Expand All @@ -180,6 +181,9 @@ process {
Write-Host -ForegroundColor Cyan "process:Get-AzPolicySetDefinition(" $PSBoundParameters ") - (ParameterSet: $($PSCmdlet.ParameterSetName))"
}

# ensure fallback try/catch is invoked if necessary
$PSBoundParameters['ErrorAction'] = 'Stop'

# handle disallowed cases not handled by PS parameter attributes
if ($PSBoundParameters['SubscriptionId'] -and $PSBoundParameters['ManagementGroupName']) {
throw 'Only ManagementGroupName or SubscriptionId can be provided, not both.'
Expand All @@ -190,8 +194,8 @@ process {
$calledParameterSet = 'List'

switch ($parameterSet) {
'BuiltIn' {
$PSBoundParameters.Add('Filter', "policyType eq 'BuiltIn'")
'Builtin' {
$PSBoundParameters.Add('Filter', "policyType eq 'Builtin'")
}
'Custom' {
$PSBoundParameters.Add('Filter', "policyType eq 'Custom'")
Expand All @@ -213,15 +217,15 @@ process {
$calledParameterSet = 'Get1';
}
'builtin' {
$calledParameterSet = 'BuiltInId'
$calledParameterSet = 'BuiltinId'
$PSBoundParameters['InputObject'] = @{ 'Id' = $PSBoundParameters['Id'] }
}
}
}
}

# this check is needed because builtin Ids are special (no subId, no mgId)
if ($calledParameterSet -ne 'BuiltInId') {
if ($calledParameterSet -ne 'BuiltinId') {
# determine parameter set for call to generated cmdlet
if ($PSBoundParameters['SubscriptionId']) {
if ($PSBoundParameters['Name']) {
Expand Down Expand Up @@ -252,7 +256,7 @@ process {
$null = $PSBoundParameters.Remove('BackwardCompatible')
$null = $PSBoundParameters.Remove('ManagementGroupName')
$null = $PSBoundParameters.Remove('Id')
$null = $PSBoundParameters.Remove('BuiltIn')
$null = $PSBoundParameters.Remove('Builtin')
$null = $PSBoundParameters.Remove('Custom')

if ($writeln) {
Expand All @@ -276,13 +280,13 @@ process {
$null = $PSBoundParameters.Remove('Name')
$null = $PSBoundParameters.Remove('SubscriptionId')

$cmdInfo = Get-Command -Name $mapping['BuiltInGet']
$cmdInfo = Get-Command -Name $mapping['BuiltinGet']
[Microsoft.Azure.PowerShell.Cmdlets.Policy.Runtime.MessageAttributeHelper]::ProcessCustomAttributesAtRuntime($cmdInfo, $MyInvocation, $calledParameterSet, $PSCmdlet)
$wrappedCmd = $ExecutionContext.InvokeCommand.GetCommand(($mapping['BuiltInGet']), [System.Management.Automation.CommandTypes]::Cmdlet)
$wrappedCmd = $ExecutionContext.InvokeCommand.GetCommand(($mapping['BuiltinGet']), [System.Management.Automation.CommandTypes]::Cmdlet)
$scriptCmd = {& $wrappedCmd @PSBoundParameters}

if ($writeln) {
Write-Host -ForegroundColor Blue -> $mapping['BuiltInGet']'(' $PSBoundParameters ')'
Write-Host -ForegroundColor Blue -> $mapping['BuiltinGet']'(' $PSBoundParameters ')'
}

$output = Invoke-Command -ScriptBlock $scriptCmd
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ param(
${NonComplianceMessage},

[Parameter()]
[Obsolete('This parameter is a temporary bridge to new types and formats and will be removed in a future release.')]
[System.Management.Automation.SwitchParameter]
# Causes cmdlet to return artifacts using legacy format placing policy-specific properties in a property bag object.
${BackwardCompatible} = $false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ param(
${SubscriptionId},

[Parameter()]
[Obsolete('This parameter is a temporary bridge to new types and formats and will be removed in a future release.')]
[System.Management.Automation.SwitchParameter]
# Causes cmdlet to return artifacts using legacy format placing policy-specific properties in a property bag object.
${BackwardCompatible} = $false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ param(
${Metadata},

[Parameter()]
[Obsolete('This parameter is a temporary bridge to new types and formats and will be removed in a future release.')]
[System.Management.Automation.SwitchParameter]
# Causes cmdlet to return artifacts using legacy format placing policy-specific properties in a property bag object.
${BackwardCompatible} = $false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ param(
${PolicyDefinitionGroup},

[Parameter()]
[Obsolete('This parameter is a temporary bridge to new types and formats and will be removed in a future release.')]
[System.Management.Automation.SwitchParameter]
# Causes cmdlet to return artifacts using legacy format placing policy-specific properties in a property bag object.
${BackwardCompatible} = $false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ param(
[Parameter(ParameterSetName='Id', Mandatory, ValueFromPipelineByPropertyName)]
[ValidateNotNullOrEmpty()]
[Alias('PolicyAssignmentId')]
[Alias('ResourceId')]
[Microsoft.Azure.PowerShell.Cmdlets.Policy.Category('Path')]
[System.String]
# The ID of the policy assignment to delete.
Expand All @@ -74,6 +75,7 @@ param(
${Force},

[Parameter()]
[Obsolete('This parameter is a temporary bridge to new types and formats and will be removed in a future release.')]
[System.Management.Automation.SwitchParameter]
# Causes cmdlet to return artifacts using legacy format placing policy-specific properties in a property bag object.
${BackwardCompatible} = $false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ param(
${InputObject},

[Parameter()]
[Obsolete('This parameter is a temporary bridge to new types and formats and will be removed in a future release.')]
[System.Management.Automation.SwitchParameter]
# Causes cmdlet to return artifacts using legacy format placing policy-specific properties in a property bag object.
${BackwardCompatible} = $false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ param(
[Parameter(ParameterSetName='Id', Mandatory, ValueFromPipelineByPropertyName)]
[ValidateNotNullOrEmpty()]
[Alias('PolicyExemptionId')]
[Alias('ResourceId')]
[Microsoft.Azure.PowerShell.Cmdlets.Policy.Category('Path')]
[System.String]
# The ID of the policy exemption to delete.
Expand All @@ -74,6 +75,7 @@ param(
${InputObject},

[Parameter()]
[Obsolete('This parameter is a temporary bridge to new types and formats and will be removed in a future release.')]
[System.Management.Automation.SwitchParameter]
# Causes cmdlet to return artifacts using legacy format placing policy-specific properties in a property bag object.
${BackwardCompatible} = $false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ param(
${InputObject},

[Parameter()]
[Obsolete('This parameter is a temporary bridge to new types and formats and will be removed in a future release.')]
[System.Management.Automation.SwitchParameter]
# Causes cmdlet to return artifacts using legacy format placing policy-specific properties in a property bag object.
${BackwardCompatible} = $false,
Expand Down
Loading