Skip to content

Commit 4ac734c

Browse files
Move ConnectedMachine to main (#24487)
1 parent 9c7d36a commit 4ac734c

File tree

123 files changed

+2709
-172
lines changed

Some content is hidden

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

123 files changed

+2709
-172
lines changed

src/ConnectedMachine/ConnectedMachine.Autorest/Az.ConnectedMachine.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.ConnectedMachine.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/ConnectedMachine/ConnectedMachine.Autorest/exports/Connect-AzConnectedMachine.ps1

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,13 @@ begin {
150150
__AllParameterSets = 'Az.ConnectedMachine.custom\Connect-AzConnectedMachine';
151151
}
152152
if (('__AllParameterSets') -contains $parameterSet -and -not $PSBoundParameters.ContainsKey('SubscriptionId') ) {
153-
$PSBoundParameters['SubscriptionId'] = (Get-AzContext).Subscription.Id
153+
$testPlayback = $false
154+
$PSBoundParameters['HttpPipelinePrepend'] | Foreach-Object { $testPlayback = $testPlayback -or ('Microsoft.Azure.PowerShell.Cmdlets.ConnectedMachine.Runtime.PipelineMock' -eq $_.Target.GetType().FullName -and 'Playback' -eq $_.Target.Mode) }
155+
if ($testPlayback) {
156+
$PSBoundParameters['SubscriptionId'] = . (Join-Path $PSScriptRoot '..' 'utils' 'Get-SubscriptionIdTestSafe.ps1')
157+
} else {
158+
$PSBoundParameters['SubscriptionId'] = (Get-AzContext).Subscription.Id
159+
}
154160
}
155161
$cmdInfo = Get-Command -Name $mapping[$parameterSet]
156162
[Microsoft.Azure.PowerShell.Cmdlets.ConnectedMachine.Runtime.MessageAttributeHelper]::ProcessCustomAttributesAtRuntime($cmdInfo, $MyInvocation, $parameterSet, $PSCmdlet)

src/ConnectedMachine/ConnectedMachine.Autorest/exports/Get-AzConnectedExtensionMetadata.ps1

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,13 @@ begin {
144144
List = 'Az.ConnectedMachine.private\Get-AzConnectedExtensionMetadata_List';
145145
}
146146
if (('Get', 'List') -contains $parameterSet -and -not $PSBoundParameters.ContainsKey('SubscriptionId') ) {
147-
$PSBoundParameters['SubscriptionId'] = (Get-AzContext).Subscription.Id
147+
$testPlayback = $false
148+
$PSBoundParameters['HttpPipelinePrepend'] | Foreach-Object { $testPlayback = $testPlayback -or ('Microsoft.Azure.PowerShell.Cmdlets.ConnectedMachine.Runtime.PipelineMock' -eq $_.Target.GetType().FullName -and 'Playback' -eq $_.Target.Mode) }
149+
if ($testPlayback) {
150+
$PSBoundParameters['SubscriptionId'] = . (Join-Path $PSScriptRoot '..' 'utils' 'Get-SubscriptionIdTestSafe.ps1')
151+
} else {
152+
$PSBoundParameters['SubscriptionId'] = (Get-AzContext).Subscription.Id
153+
}
148154
}
149155
$cmdInfo = Get-Command -Name $mapping[$parameterSet]
150156
[Microsoft.Azure.PowerShell.Cmdlets.ConnectedMachine.Runtime.MessageAttributeHelper]::ProcessCustomAttributesAtRuntime($cmdInfo, $MyInvocation, $parameterSet, $PSCmdlet)

src/ConnectedMachine/ConnectedMachine.Autorest/exports/Get-AzConnectedMachine.ps1

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,13 @@ begin {
145145
List1 = 'Az.ConnectedMachine.private\Get-AzConnectedMachine_List1';
146146
}
147147
if (('Get', 'List', 'List1') -contains $parameterSet -and -not $PSBoundParameters.ContainsKey('SubscriptionId') ) {
148-
$PSBoundParameters['SubscriptionId'] = (Get-AzContext).Subscription.Id
148+
$testPlayback = $false
149+
$PSBoundParameters['HttpPipelinePrepend'] | Foreach-Object { $testPlayback = $testPlayback -or ('Microsoft.Azure.PowerShell.Cmdlets.ConnectedMachine.Runtime.PipelineMock' -eq $_.Target.GetType().FullName -and 'Playback' -eq $_.Target.Mode) }
150+
if ($testPlayback) {
151+
$PSBoundParameters['SubscriptionId'] = . (Join-Path $PSScriptRoot '..' 'utils' 'Get-SubscriptionIdTestSafe.ps1')
152+
} else {
153+
$PSBoundParameters['SubscriptionId'] = (Get-AzContext).Subscription.Id
154+
}
149155
}
150156
$cmdInfo = Get-Command -Name $mapping[$parameterSet]
151157
[Microsoft.Azure.PowerShell.Cmdlets.ConnectedMachine.Runtime.MessageAttributeHelper]::ProcessCustomAttributesAtRuntime($cmdInfo, $MyInvocation, $parameterSet, $PSCmdlet)

src/ConnectedMachine/ConnectedMachine.Autorest/exports/Get-AzConnectedMachineExtension.ps1

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,13 @@ begin {
145145
List = 'Az.ConnectedMachine.private\Get-AzConnectedMachineExtension_List';
146146
}
147147
if (('Get', 'List') -contains $parameterSet -and -not $PSBoundParameters.ContainsKey('SubscriptionId') ) {
148-
$PSBoundParameters['SubscriptionId'] = (Get-AzContext).Subscription.Id
148+
$testPlayback = $false
149+
$PSBoundParameters['HttpPipelinePrepend'] | Foreach-Object { $testPlayback = $testPlayback -or ('Microsoft.Azure.PowerShell.Cmdlets.ConnectedMachine.Runtime.PipelineMock' -eq $_.Target.GetType().FullName -and 'Playback' -eq $_.Target.Mode) }
150+
if ($testPlayback) {
151+
$PSBoundParameters['SubscriptionId'] = . (Join-Path $PSScriptRoot '..' 'utils' 'Get-SubscriptionIdTestSafe.ps1')
152+
} else {
153+
$PSBoundParameters['SubscriptionId'] = (Get-AzContext).Subscription.Id
154+
}
149155
}
150156
$cmdInfo = Get-Command -Name $mapping[$parameterSet]
151157
[Microsoft.Azure.PowerShell.Cmdlets.ConnectedMachine.Runtime.MessageAttributeHelper]::ProcessCustomAttributesAtRuntime($cmdInfo, $MyInvocation, $parameterSet, $PSCmdlet)

src/ConnectedMachine/ConnectedMachine.Autorest/exports/Get-AzConnectedMachineRunCommand.ps1

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,13 @@ begin {
145145
List = 'Az.ConnectedMachine.private\Get-AzConnectedMachineRunCommand_List';
146146
}
147147
if (('Get', 'List') -contains $parameterSet -and -not $PSBoundParameters.ContainsKey('SubscriptionId') ) {
148-
$PSBoundParameters['SubscriptionId'] = (Get-AzContext).Subscription.Id
148+
$testPlayback = $false
149+
$PSBoundParameters['HttpPipelinePrepend'] | Foreach-Object { $testPlayback = $testPlayback -or ('Microsoft.Azure.PowerShell.Cmdlets.ConnectedMachine.Runtime.PipelineMock' -eq $_.Target.GetType().FullName -and 'Playback' -eq $_.Target.Mode) }
150+
if ($testPlayback) {
151+
$PSBoundParameters['SubscriptionId'] = . (Join-Path $PSScriptRoot '..' 'utils' 'Get-SubscriptionIdTestSafe.ps1')
152+
} else {
153+
$PSBoundParameters['SubscriptionId'] = (Get-AzContext).Subscription.Id
154+
}
149155
}
150156
$cmdInfo = Get-Command -Name $mapping[$parameterSet]
151157
[Microsoft.Azure.PowerShell.Cmdlets.ConnectedMachine.Runtime.MessageAttributeHelper]::ProcessCustomAttributesAtRuntime($cmdInfo, $MyInvocation, $parameterSet, $PSCmdlet)

src/ConnectedMachine/ConnectedMachine.Autorest/exports/Get-AzConnectedPrivateLinkScope.ps1

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,13 @@ begin {
135135
List1 = 'Az.ConnectedMachine.private\Get-AzConnectedPrivateLinkScope_List1';
136136
}
137137
if (('Get', 'List', 'List1') -contains $parameterSet -and -not $PSBoundParameters.ContainsKey('SubscriptionId') ) {
138-
$PSBoundParameters['SubscriptionId'] = (Get-AzContext).Subscription.Id
138+
$testPlayback = $false
139+
$PSBoundParameters['HttpPipelinePrepend'] | Foreach-Object { $testPlayback = $testPlayback -or ('Microsoft.Azure.PowerShell.Cmdlets.ConnectedMachine.Runtime.PipelineMock' -eq $_.Target.GetType().FullName -and 'Playback' -eq $_.Target.Mode) }
140+
if ($testPlayback) {
141+
$PSBoundParameters['SubscriptionId'] = . (Join-Path $PSScriptRoot '..' 'utils' 'Get-SubscriptionIdTestSafe.ps1')
142+
} else {
143+
$PSBoundParameters['SubscriptionId'] = (Get-AzContext).Subscription.Id
144+
}
139145
}
140146
$cmdInfo = Get-Command -Name $mapping[$parameterSet]
141147
[Microsoft.Azure.PowerShell.Cmdlets.ConnectedMachine.Runtime.MessageAttributeHelper]::ProcessCustomAttributesAtRuntime($cmdInfo, $MyInvocation, $parameterSet, $PSCmdlet)

src/ConnectedMachine/ConnectedMachine.Autorest/exports/Install-AzConnectedMachinePatch.ps1

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,13 @@ begin {
249249
InstallViaIdentityExpanded = 'Az.ConnectedMachine.private\Install-AzConnectedMachinePatch_InstallViaIdentityExpanded';
250250
}
251251
if (('InstallExpanded') -contains $parameterSet -and -not $PSBoundParameters.ContainsKey('SubscriptionId') ) {
252-
$PSBoundParameters['SubscriptionId'] = (Get-AzContext).Subscription.Id
252+
$testPlayback = $false
253+
$PSBoundParameters['HttpPipelinePrepend'] | Foreach-Object { $testPlayback = $testPlayback -or ('Microsoft.Azure.PowerShell.Cmdlets.ConnectedMachine.Runtime.PipelineMock' -eq $_.Target.GetType().FullName -and 'Playback' -eq $_.Target.Mode) }
254+
if ($testPlayback) {
255+
$PSBoundParameters['SubscriptionId'] = . (Join-Path $PSScriptRoot '..' 'utils' 'Get-SubscriptionIdTestSafe.ps1')
256+
} else {
257+
$PSBoundParameters['SubscriptionId'] = (Get-AzContext).Subscription.Id
258+
}
253259
}
254260
$cmdInfo = Get-Command -Name $mapping[$parameterSet]
255261
[Microsoft.Azure.PowerShell.Cmdlets.ConnectedMachine.Runtime.MessageAttributeHelper]::ProcessCustomAttributesAtRuntime($cmdInfo, $MyInvocation, $parameterSet, $PSCmdlet)

src/ConnectedMachine/ConnectedMachine.Autorest/exports/Invoke-AzConnectedAssessMachinePatch.ps1

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,13 @@ begin {
177177
AssessViaIdentity = 'Az.ConnectedMachine.private\Invoke-AzConnectedAssessMachinePatch_AssessViaIdentity';
178178
}
179179
if (('Assess') -contains $parameterSet -and -not $PSBoundParameters.ContainsKey('SubscriptionId') ) {
180-
$PSBoundParameters['SubscriptionId'] = (Get-AzContext).Subscription.Id
180+
$testPlayback = $false
181+
$PSBoundParameters['HttpPipelinePrepend'] | Foreach-Object { $testPlayback = $testPlayback -or ('Microsoft.Azure.PowerShell.Cmdlets.ConnectedMachine.Runtime.PipelineMock' -eq $_.Target.GetType().FullName -and 'Playback' -eq $_.Target.Mode) }
182+
if ($testPlayback) {
183+
$PSBoundParameters['SubscriptionId'] = . (Join-Path $PSScriptRoot '..' 'utils' 'Get-SubscriptionIdTestSafe.ps1')
184+
} else {
185+
$PSBoundParameters['SubscriptionId'] = (Get-AzContext).Subscription.Id
186+
}
181187
}
182188
$cmdInfo = Get-Command -Name $mapping[$parameterSet]
183189
[Microsoft.Azure.PowerShell.Cmdlets.ConnectedMachine.Runtime.MessageAttributeHelper]::ProcessCustomAttributesAtRuntime($cmdInfo, $MyInvocation, $parameterSet, $PSCmdlet)

src/ConnectedMachine/ConnectedMachine.Autorest/exports/New-AzConnectedMachineExtension.ps1

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -445,7 +445,13 @@ begin {
445445
CreateViaJsonString = 'Az.ConnectedMachine.private\New-AzConnectedMachineExtension_CreateViaJsonString';
446446
}
447447
if (('Create', 'CreateExpanded', 'CreateViaJsonFilePath', 'CreateViaJsonString') -contains $parameterSet -and -not $PSBoundParameters.ContainsKey('SubscriptionId') ) {
448-
$PSBoundParameters['SubscriptionId'] = (Get-AzContext).Subscription.Id
448+
$testPlayback = $false
449+
$PSBoundParameters['HttpPipelinePrepend'] | Foreach-Object { $testPlayback = $testPlayback -or ('Microsoft.Azure.PowerShell.Cmdlets.ConnectedMachine.Runtime.PipelineMock' -eq $_.Target.GetType().FullName -and 'Playback' -eq $_.Target.Mode) }
450+
if ($testPlayback) {
451+
$PSBoundParameters['SubscriptionId'] = . (Join-Path $PSScriptRoot '..' 'utils' 'Get-SubscriptionIdTestSafe.ps1')
452+
} else {
453+
$PSBoundParameters['SubscriptionId'] = (Get-AzContext).Subscription.Id
454+
}
449455
}
450456
$cmdInfo = Get-Command -Name $mapping[$parameterSet]
451457
[Microsoft.Azure.PowerShell.Cmdlets.ConnectedMachine.Runtime.MessageAttributeHelper]::ProcessCustomAttributesAtRuntime($cmdInfo, $MyInvocation, $parameterSet, $PSCmdlet)

src/ConnectedMachine/ConnectedMachine.Autorest/exports/New-AzConnectedMachineRunCommand.ps1

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -486,7 +486,13 @@ begin {
486486
ScriptLocalPath = 'Az.ConnectedMachine.custom\New-AzConnectedMachineRunCommand_ScriptLocalPath';
487487
}
488488
if (('Create', 'CreateExpanded', 'CreateViaJsonFilePath', 'CreateViaJsonString', 'ScriptLocalPath') -contains $parameterSet -and -not $PSBoundParameters.ContainsKey('SubscriptionId') ) {
489-
$PSBoundParameters['SubscriptionId'] = (Get-AzContext).Subscription.Id
489+
$testPlayback = $false
490+
$PSBoundParameters['HttpPipelinePrepend'] | Foreach-Object { $testPlayback = $testPlayback -or ('Microsoft.Azure.PowerShell.Cmdlets.ConnectedMachine.Runtime.PipelineMock' -eq $_.Target.GetType().FullName -and 'Playback' -eq $_.Target.Mode) }
491+
if ($testPlayback) {
492+
$PSBoundParameters['SubscriptionId'] = . (Join-Path $PSScriptRoot '..' 'utils' 'Get-SubscriptionIdTestSafe.ps1')
493+
} else {
494+
$PSBoundParameters['SubscriptionId'] = (Get-AzContext).Subscription.Id
495+
}
490496
}
491497
$cmdInfo = Get-Command -Name $mapping[$parameterSet]
492498
[Microsoft.Azure.PowerShell.Cmdlets.ConnectedMachine.Runtime.MessageAttributeHelper]::ProcessCustomAttributesAtRuntime($cmdInfo, $MyInvocation, $parameterSet, $PSCmdlet)

src/ConnectedMachine/ConnectedMachine.Autorest/exports/New-AzConnectedPrivateLinkScope.ps1

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,13 @@ begin {
233233
CreateViaJsonString = 'Az.ConnectedMachine.private\New-AzConnectedPrivateLinkScope_CreateViaJsonString';
234234
}
235235
if (('Create', 'CreateExpanded', 'CreateViaJsonFilePath', 'CreateViaJsonString') -contains $parameterSet -and -not $PSBoundParameters.ContainsKey('SubscriptionId') ) {
236-
$PSBoundParameters['SubscriptionId'] = (Get-AzContext).Subscription.Id
236+
$testPlayback = $false
237+
$PSBoundParameters['HttpPipelinePrepend'] | Foreach-Object { $testPlayback = $testPlayback -or ('Microsoft.Azure.PowerShell.Cmdlets.ConnectedMachine.Runtime.PipelineMock' -eq $_.Target.GetType().FullName -and 'Playback' -eq $_.Target.Mode) }
238+
if ($testPlayback) {
239+
$PSBoundParameters['SubscriptionId'] = . (Join-Path $PSScriptRoot '..' 'utils' 'Get-SubscriptionIdTestSafe.ps1')
240+
} else {
241+
$PSBoundParameters['SubscriptionId'] = (Get-AzContext).Subscription.Id
242+
}
237243
}
238244
$cmdInfo = Get-Command -Name $mapping[$parameterSet]
239245
[Microsoft.Azure.PowerShell.Cmdlets.ConnectedMachine.Runtime.MessageAttributeHelper]::ProcessCustomAttributesAtRuntime($cmdInfo, $MyInvocation, $parameterSet, $PSCmdlet)

0 commit comments

Comments
 (0)