Skip to content

Commit ab525e6

Browse files
Migrate KeyVault from generation to main (#24499)
* Move KeyVault to main * Update ExampleIssues.csv * Update ChangeLog.md --------- Co-authored-by: Vincent Dai <[email protected]>
1 parent 24ae171 commit ab525e6

File tree

130 files changed

+2570
-568
lines changed

Some content is hidden

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

130 files changed

+2570
-568
lines changed

src/KeyVault/KeyVault.Autorest/Az.KeyVault.psm1

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -47,37 +47,41 @@
4747

4848
# Ask for the shared functionality table
4949
$VTable = Register-AzModule
50-
50+
5151
# Tweaks the pipeline on module load
5252
$instance.OnModuleLoad = $VTable.OnModuleLoad
5353

5454
# Following two delegates are added for telemetry
5555
$instance.GetTelemetryId = $VTable.GetTelemetryId
5656
$instance.Telemetry = $VTable.Telemetry
57-
57+
58+
# Delegate to sanitize the output object
59+
$instance.SanitizeOutput = $VTable.SanitizerHandler
60+
61+
# Delegate to get the telemetry info
62+
$instance.GetTelemetryInfo = $VTable.GetTelemetryInfo
5863

5964
# Tweaks the pipeline per call
6065
$instance.OnNewRequest = $VTable.OnNewRequest
61-
66+
6267
# Gets shared parameter values
6368
$instance.GetParameterValue = $VTable.GetParameterValue
64-
69+
6570
# Allows shared module to listen to events from this module
6671
$instance.EventListener = $VTable.EventListener
67-
72+
6873
# Gets shared argument completers
6974
$instance.ArgumentCompleter = $VTable.ArgumentCompleter
70-
75+
7176
# The name of the currently selected Azure profile
7277
$instance.ProfileName = $VTable.ProfileName
7378

74-
7579
# Load the custom module
7680
$customModulePath = Join-Path $PSScriptRoot './custom/Az.KeyVault.custom.psm1'
7781
if(Test-Path $customModulePath) {
7882
$null = Import-Module -Name $customModulePath
7983
}
80-
84+
8185
# Export nothing to clear implicit exports
8286
Export-ModuleMember
8387

@@ -97,12 +101,12 @@
97101
# Load the last folder if no profile is selected
98102
$profileDirectory = $directories | Select-Object -Last 1
99103
}
100-
104+
101105
if($profileDirectory) {
102106
Write-Information "Loaded Azure profile '$($profileDirectory.Name)' for module '$($instance.Name)'"
103107
$exportsPath = $profileDirectory.FullName
104108
}
105-
109+
106110
if($exportsPath) {
107111
Get-ChildItem -Path $exportsPath -Recurse -Include '*.ps1' -File | ForEach-Object { . $_.FullName }
108112
$cmdletNames = Get-ScriptCmdlet -ScriptFolder $exportsPath

src/KeyVault/KeyVault.Autorest/README.md

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
This directory contains the PowerShell module for the KeyVault service.
44

55
---
6-
76
## Info
87
- Modifiable: yes
98
- Generated: all
@@ -29,7 +28,7 @@ For information on how to develop for `Az.KeyVault`, see [how-to.md](how-to.md).
2928
3029
``` yaml
3130
# Please specify the commit id that includes your features to make sure generated codes stable.
32-
branch: 8fa9b5051129dd4808c9be1f5b753af226b044db
31+
commit: 8fa9b5051129dd4808c9be1f5b753af226b044db
3332
require:
3433
# readme.azure.noprofile.md is the common configuration file
3534
- $(this-folder)/../../readme.azure.noprofile.md
@@ -46,8 +45,6 @@ module-version: 0.1.0
4645
# Normally, title is the service name
4746
title: KeyVault
4847
subject-prefix: $(service-name)
49-
use-extension:
50-
"@autorest/powershell": "4.x"
5148

5249
# If there are post APIs for some kinds of actions in the RP, you may need to
5350
# uncomment following line to support viaIdentity for these post APIs

src/KeyVault/KeyVault.Autorest/exports/Add-AzKeyVaultManagedHsmRegion.ps1

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ param(
5555
[Microsoft.Azure.PowerShell.Cmdlets.KeyVault.Category('Body')]
5656
[System.String[]]
5757
# List of regions to be added associated with the managed hsm pool.
58+
# To construct, see NOTES section for REGION properties and create a hash table.
5859
${Region},
5960

6061
[Parameter()]
@@ -141,7 +142,13 @@ begin {
141142
__AllParameterSets = 'Az.KeyVault.custom\Add-AzKeyVaultManagedHsmRegion';
142143
}
143144
if (('__AllParameterSets') -contains $parameterSet -and -not $PSBoundParameters.ContainsKey('SubscriptionId') ) {
144-
$PSBoundParameters['SubscriptionId'] = (Get-AzContext).Subscription.Id
145+
$testPlayback = $false
146+
$PSBoundParameters['HttpPipelinePrepend'] | Foreach-Object { $testPlayback = $testPlayback -or ('Microsoft.Azure.PowerShell.Cmdlets.KeyVault.Runtime.PipelineMock' -eq $_.Target.GetType().FullName -and 'Playback' -eq $_.Target.Mode) }
147+
if ($testPlayback) {
148+
$PSBoundParameters['SubscriptionId'] = . (Join-Path $PSScriptRoot '..' 'utils' 'Get-SubscriptionIdTestSafe.ps1')
149+
} else {
150+
$PSBoundParameters['SubscriptionId'] = (Get-AzContext).Subscription.Id
151+
}
145152
}
146153
$cmdInfo = Get-Command -Name $mapping[$parameterSet]
147154
[Microsoft.Azure.PowerShell.Cmdlets.KeyVault.Runtime.MessageAttributeHelper]::ProcessCustomAttributesAtRuntime($cmdInfo, $MyInvocation, $parameterSet, $PSCmdlet)

src/KeyVault/KeyVault.Autorest/exports/Get-AzKeyVaultManagedHsmRegion.ps1

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,13 @@ begin {
129129
List = 'Az.KeyVault.private\Get-AzKeyVaultManagedHsmRegion_List';
130130
}
131131
if (('List') -contains $parameterSet -and -not $PSBoundParameters.ContainsKey('SubscriptionId') ) {
132-
$PSBoundParameters['SubscriptionId'] = (Get-AzContext).Subscription.Id
132+
$testPlayback = $false
133+
$PSBoundParameters['HttpPipelinePrepend'] | Foreach-Object { $testPlayback = $testPlayback -or ('Microsoft.Azure.PowerShell.Cmdlets.KeyVault.Runtime.PipelineMock' -eq $_.Target.GetType().FullName -and 'Playback' -eq $_.Target.Mode) }
134+
if ($testPlayback) {
135+
$PSBoundParameters['SubscriptionId'] = . (Join-Path $PSScriptRoot '..' 'utils' 'Get-SubscriptionIdTestSafe.ps1')
136+
} else {
137+
$PSBoundParameters['SubscriptionId'] = (Get-AzContext).Subscription.Id
138+
}
133139
}
134140
$cmdInfo = Get-Command -Name $mapping[$parameterSet]
135141
[Microsoft.Azure.PowerShell.Cmdlets.KeyVault.Runtime.MessageAttributeHelper]::ProcessCustomAttributesAtRuntime($cmdInfo, $MyInvocation, $parameterSet, $PSCmdlet)

src/KeyVault/KeyVault.Autorest/exports/ProxyCmdletDefinitions.ps1

Lines changed: 36 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,13 @@ begin {
129129
List = 'Az.KeyVault.private\Get-AzKeyVaultManagedHsmRegion_List';
130130
}
131131
if (('List') -contains $parameterSet -and -not $PSBoundParameters.ContainsKey('SubscriptionId') ) {
132-
$PSBoundParameters['SubscriptionId'] = (Get-AzContext).Subscription.Id
132+
$testPlayback = $false
133+
$PSBoundParameters['HttpPipelinePrepend'] | Foreach-Object { $testPlayback = $testPlayback -or ('Microsoft.Azure.PowerShell.Cmdlets.KeyVault.Runtime.PipelineMock' -eq $_.Target.GetType().FullName -and 'Playback' -eq $_.Target.Mode) }
134+
if ($testPlayback) {
135+
$PSBoundParameters['SubscriptionId'] = . (Join-Path $PSScriptRoot '..' 'utils' 'Get-SubscriptionIdTestSafe.ps1')
136+
} else {
137+
$PSBoundParameters['SubscriptionId'] = (Get-AzContext).Subscription.Id
138+
}
133139
}
134140
$cmdInfo = Get-Command -Name $mapping[$parameterSet]
135141
[Microsoft.Azure.PowerShell.Cmdlets.KeyVault.Runtime.MessageAttributeHelper]::ProcessCustomAttributesAtRuntime($cmdInfo, $MyInvocation, $parameterSet, $PSCmdlet)
@@ -306,7 +312,13 @@ begin {
306312
CheckViaJsonString = 'Az.KeyVault.private\Test-AzKeyVaultManagedHsmNameAvailability_CheckViaJsonString';
307313
}
308314
if (('CheckExpanded', 'CheckViaJsonFilePath', 'CheckViaJsonString') -contains $parameterSet -and -not $PSBoundParameters.ContainsKey('SubscriptionId') ) {
309-
$PSBoundParameters['SubscriptionId'] = (Get-AzContext).Subscription.Id
315+
$testPlayback = $false
316+
$PSBoundParameters['HttpPipelinePrepend'] | Foreach-Object { $testPlayback = $testPlayback -or ('Microsoft.Azure.PowerShell.Cmdlets.KeyVault.Runtime.PipelineMock' -eq $_.Target.GetType().FullName -and 'Playback' -eq $_.Target.Mode) }
317+
if ($testPlayback) {
318+
$PSBoundParameters['SubscriptionId'] = . (Join-Path $PSScriptRoot '..' 'utils' 'Get-SubscriptionIdTestSafe.ps1')
319+
} else {
320+
$PSBoundParameters['SubscriptionId'] = (Get-AzContext).Subscription.Id
321+
}
310322
}
311323
$cmdInfo = Get-Command -Name $mapping[$parameterSet]
312324
[Microsoft.Azure.PowerShell.Cmdlets.KeyVault.Runtime.MessageAttributeHelper]::ProcessCustomAttributesAtRuntime($cmdInfo, $MyInvocation, $parameterSet, $PSCmdlet)
@@ -483,7 +495,13 @@ begin {
483495
CheckViaJsonString = 'Az.KeyVault.private\Test-AzKeyVaultNameAvailability_CheckViaJsonString';
484496
}
485497
if (('CheckExpanded', 'CheckViaJsonFilePath', 'CheckViaJsonString') -contains $parameterSet -and -not $PSBoundParameters.ContainsKey('SubscriptionId') ) {
486-
$PSBoundParameters['SubscriptionId'] = (Get-AzContext).Subscription.Id
498+
$testPlayback = $false
499+
$PSBoundParameters['HttpPipelinePrepend'] | Foreach-Object { $testPlayback = $testPlayback -or ('Microsoft.Azure.PowerShell.Cmdlets.KeyVault.Runtime.PipelineMock' -eq $_.Target.GetType().FullName -and 'Playback' -eq $_.Target.Mode) }
500+
if ($testPlayback) {
501+
$PSBoundParameters['SubscriptionId'] = . (Join-Path $PSScriptRoot '..' 'utils' 'Get-SubscriptionIdTestSafe.ps1')
502+
} else {
503+
$PSBoundParameters['SubscriptionId'] = (Get-AzContext).Subscription.Id
504+
}
487505
}
488506
$cmdInfo = Get-Command -Name $mapping[$parameterSet]
489507
[Microsoft.Azure.PowerShell.Cmdlets.KeyVault.Runtime.MessageAttributeHelper]::ProcessCustomAttributesAtRuntime($cmdInfo, $MyInvocation, $parameterSet, $PSCmdlet)
@@ -576,6 +594,7 @@ param(
576594
[Microsoft.Azure.PowerShell.Cmdlets.KeyVault.Category('Body')]
577595
[System.String[]]
578596
# List of regions to be added associated with the managed hsm pool.
597+
# To construct, see NOTES section for REGION properties and create a hash table.
579598
${Region},
580599

581600
[Parameter()]
@@ -662,7 +681,13 @@ begin {
662681
__AllParameterSets = 'Az.KeyVault.custom\Add-AzKeyVaultManagedHsmRegion';
663682
}
664683
if (('__AllParameterSets') -contains $parameterSet -and -not $PSBoundParameters.ContainsKey('SubscriptionId') ) {
665-
$PSBoundParameters['SubscriptionId'] = (Get-AzContext).Subscription.Id
684+
$testPlayback = $false
685+
$PSBoundParameters['HttpPipelinePrepend'] | Foreach-Object { $testPlayback = $testPlayback -or ('Microsoft.Azure.PowerShell.Cmdlets.KeyVault.Runtime.PipelineMock' -eq $_.Target.GetType().FullName -and 'Playback' -eq $_.Target.Mode) }
686+
if ($testPlayback) {
687+
$PSBoundParameters['SubscriptionId'] = . (Join-Path $PSScriptRoot '..' 'utils' 'Get-SubscriptionIdTestSafe.ps1')
688+
} else {
689+
$PSBoundParameters['SubscriptionId'] = (Get-AzContext).Subscription.Id
690+
}
666691
}
667692
$cmdInfo = Get-Command -Name $mapping[$parameterSet]
668693
[Microsoft.Azure.PowerShell.Cmdlets.KeyVault.Runtime.MessageAttributeHelper]::ProcessCustomAttributesAtRuntime($cmdInfo, $MyInvocation, $parameterSet, $PSCmdlet)
@@ -847,7 +872,13 @@ begin {
847872
__AllParameterSets = 'Az.KeyVault.custom\Remove-AzKeyVaultManagedHsmRegion';
848873
}
849874
if (('__AllParameterSets') -contains $parameterSet -and -not $PSBoundParameters.ContainsKey('SubscriptionId') ) {
850-
$PSBoundParameters['SubscriptionId'] = (Get-AzContext).Subscription.Id
875+
$testPlayback = $false
876+
$PSBoundParameters['HttpPipelinePrepend'] | Foreach-Object { $testPlayback = $testPlayback -or ('Microsoft.Azure.PowerShell.Cmdlets.KeyVault.Runtime.PipelineMock' -eq $_.Target.GetType().FullName -and 'Playback' -eq $_.Target.Mode) }
877+
if ($testPlayback) {
878+
$PSBoundParameters['SubscriptionId'] = . (Join-Path $PSScriptRoot '..' 'utils' 'Get-SubscriptionIdTestSafe.ps1')
879+
} else {
880+
$PSBoundParameters['SubscriptionId'] = (Get-AzContext).Subscription.Id
881+
}
851882
}
852883
$cmdInfo = Get-Command -Name $mapping[$parameterSet]
853884
[Microsoft.Azure.PowerShell.Cmdlets.KeyVault.Runtime.MessageAttributeHelper]::ProcessCustomAttributesAtRuntime($cmdInfo, $MyInvocation, $parameterSet, $PSCmdlet)

src/KeyVault/KeyVault.Autorest/exports/Remove-AzKeyVaultManagedHsmRegion.ps1

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,13 @@ begin {
147147
__AllParameterSets = 'Az.KeyVault.custom\Remove-AzKeyVaultManagedHsmRegion';
148148
}
149149
if (('__AllParameterSets') -contains $parameterSet -and -not $PSBoundParameters.ContainsKey('SubscriptionId') ) {
150-
$PSBoundParameters['SubscriptionId'] = (Get-AzContext).Subscription.Id
150+
$testPlayback = $false
151+
$PSBoundParameters['HttpPipelinePrepend'] | Foreach-Object { $testPlayback = $testPlayback -or ('Microsoft.Azure.PowerShell.Cmdlets.KeyVault.Runtime.PipelineMock' -eq $_.Target.GetType().FullName -and 'Playback' -eq $_.Target.Mode) }
152+
if ($testPlayback) {
153+
$PSBoundParameters['SubscriptionId'] = . (Join-Path $PSScriptRoot '..' 'utils' 'Get-SubscriptionIdTestSafe.ps1')
154+
} else {
155+
$PSBoundParameters['SubscriptionId'] = (Get-AzContext).Subscription.Id
156+
}
151157
}
152158
$cmdInfo = Get-Command -Name $mapping[$parameterSet]
153159
[Microsoft.Azure.PowerShell.Cmdlets.KeyVault.Runtime.MessageAttributeHelper]::ProcessCustomAttributesAtRuntime($cmdInfo, $MyInvocation, $parameterSet, $PSCmdlet)

src/KeyVault/KeyVault.Autorest/exports/Test-AzKeyVaultManagedHsmNameAvailability.ps1

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,13 @@ begin {
139139
CheckViaJsonString = 'Az.KeyVault.private\Test-AzKeyVaultManagedHsmNameAvailability_CheckViaJsonString';
140140
}
141141
if (('CheckExpanded', 'CheckViaJsonFilePath', 'CheckViaJsonString') -contains $parameterSet -and -not $PSBoundParameters.ContainsKey('SubscriptionId') ) {
142-
$PSBoundParameters['SubscriptionId'] = (Get-AzContext).Subscription.Id
142+
$testPlayback = $false
143+
$PSBoundParameters['HttpPipelinePrepend'] | Foreach-Object { $testPlayback = $testPlayback -or ('Microsoft.Azure.PowerShell.Cmdlets.KeyVault.Runtime.PipelineMock' -eq $_.Target.GetType().FullName -and 'Playback' -eq $_.Target.Mode) }
144+
if ($testPlayback) {
145+
$PSBoundParameters['SubscriptionId'] = . (Join-Path $PSScriptRoot '..' 'utils' 'Get-SubscriptionIdTestSafe.ps1')
146+
} else {
147+
$PSBoundParameters['SubscriptionId'] = (Get-AzContext).Subscription.Id
148+
}
143149
}
144150
$cmdInfo = Get-Command -Name $mapping[$parameterSet]
145151
[Microsoft.Azure.PowerShell.Cmdlets.KeyVault.Runtime.MessageAttributeHelper]::ProcessCustomAttributesAtRuntime($cmdInfo, $MyInvocation, $parameterSet, $PSCmdlet)

src/KeyVault/KeyVault.Autorest/exports/Test-AzKeyVaultNameAvailability.ps1

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,13 @@ begin {
139139
CheckViaJsonString = 'Az.KeyVault.private\Test-AzKeyVaultNameAvailability_CheckViaJsonString';
140140
}
141141
if (('CheckExpanded', 'CheckViaJsonFilePath', 'CheckViaJsonString') -contains $parameterSet -and -not $PSBoundParameters.ContainsKey('SubscriptionId') ) {
142-
$PSBoundParameters['SubscriptionId'] = (Get-AzContext).Subscription.Id
142+
$testPlayback = $false
143+
$PSBoundParameters['HttpPipelinePrepend'] | Foreach-Object { $testPlayback = $testPlayback -or ('Microsoft.Azure.PowerShell.Cmdlets.KeyVault.Runtime.PipelineMock' -eq $_.Target.GetType().FullName -and 'Playback' -eq $_.Target.Mode) }
144+
if ($testPlayback) {
145+
$PSBoundParameters['SubscriptionId'] = . (Join-Path $PSScriptRoot '..' 'utils' 'Get-SubscriptionIdTestSafe.ps1')
146+
} else {
147+
$PSBoundParameters['SubscriptionId'] = (Get-AzContext).Subscription.Id
148+
}
143149
}
144150
$cmdInfo = Get-Command -Name $mapping[$parameterSet]
145151
[Microsoft.Azure.PowerShell.Cmdlets.KeyVault.Runtime.MessageAttributeHelper]::ProcessCustomAttributesAtRuntime($cmdInfo, $MyInvocation, $parameterSet, $PSCmdlet)

src/KeyVault/KeyVault.Autorest/generate-portal-ux.ps1

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,6 @@ $instance = [Microsoft.Azure.PowerShell.Cmdlets.KeyVault.Module]::Instance
4242
$moduleInfo = Get-Module -Name $moduleName
4343
$parameterSetsInfo = Get-Module -Name "$moduleName.private"
4444

45-
$buildinFunctions = @("Export-CmdletSurface", "Export-ExampleStub", "Export-FormatPs1xml", "Export-HelpMarkdown", "Export-ModelSurface", "Export-ProxyCmdlet", "Export-Psd1", "Export-TestStub", "Get-CommonParameter", "Get-ModuleGuid", "Get-ScriptCmdlet")
46-
4745
function Test-FunctionSupported()
4846
{
4947
[CmdletBinding()]
@@ -53,12 +51,12 @@ function Test-FunctionSupported()
5351
$FunctionName
5452
)
5553

56-
If ($buildinfunctions.Contains($FunctionName)) {
54+
If (-not $FunctionName.Contains("_")) {
5755
return $false
5856
}
5957

6058
$cmdletName, $parameterSetName = $FunctionName.Split("_")
61-
If ($parameterSetName.Contains("List") -or $parameterSetName.Contains("ViaIdentity")) {
59+
If ($parameterSetName.Contains("List") -or $parameterSetName.Contains("ViaIdentity") -or $parameterSetName.Contains("ViaJson")) {
6260
return $false
6361
}
6462
If ($cmdletName.StartsWith("New") -or $cmdletName.StartsWith("Set") -or $cmdletName.StartsWith("Update")) {
@@ -311,7 +309,7 @@ function New-MetadataForCmdlet()
311309
return $result
312310
}
313311

314-
$parameterSets = $parameterSetsInfo.ExportedCmdlets.Keys | Where-Object { Test-functionSupported($_) }
312+
$parameterSets = $parameterSetsInfo.ExportedCmdlets.Keys | Where-Object { Test-FunctionSupported($_) }
315313
$resourceTypes = @{}
316314
foreach ($parameterSetName in $parameterSets)
317315
{

0 commit comments

Comments
 (0)