Skip to content

Commit 39cc0ce

Browse files
author
Jeffrey Robinson
committed
Updated New and Set operations
1 parent f12f669 commit 39cc0ce

File tree

24 files changed

+581
-431
lines changed

24 files changed

+581
-431
lines changed

src/StackAdmin/Azs.Backup.Admin/Module/Azs.Backup.Admin/Generated.PowerShell.Commands/SwaggerPathCommands/Set-AzsBackupShare.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ function Set-AzsBackupShare {
166166
$InputObject.Password = ConvertTo-String -SecureString $Password
167167
$InputObject.EncryptionKeyBase64 = ConvertTo-String $EncryptionKey
168168

169-
Write-Verbose -Message 'Performing operation UpdateWithHttpMessagesAsync on $BackupAdminClient.'
169+
Write-Verbose -Message 'Performing operation update on $BackupAdminClient.'
170170
$TaskResult = $BackupAdminClient.BackupLocations.UpdateWithHttpMessagesAsync($ResourceGroupName, $Location, $InputObject)
171171
} else {
172172
Write-Verbose -Message 'Failed to map parameter set to operation method.'

src/StackAdmin/Azs.Compute.Admin/Module/Azs.Compute.Admin/Generated.PowerShell.Commands/SwaggerPathCommands/Add-AzsPlatformImage.ps1

Lines changed: 81 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -122,93 +122,102 @@ function Add-AzsPlatformImage {
122122
Process {
123123
$ErrorActionPreference = 'Stop'
124124

125-
if ($PSCmdlet.ShouldProcess("$Publisher / $Offer / $Sku / $Version" , "Add new virtual machine image")) {
126-
if ($Force.IsPresent -or $PSCmdlet.ShouldContinue("Add new virtual machine image?", "Performing operation add virtual machine image with publisher $Publisher, offer $Offer, SKU $Sku, and version $Version.")) {
125+
if ($PSCmdlet.ShouldProcess("$Publisher/$Offer/$Sku/$Version" , "Add new virtual machine image")) {
126+
127+
$dontCheck = $true
128+
try {
129+
$result = Get-AzsPlatformImage -Publisher $Publisher -Offer $Offer -Sku $Sku -Version $Version
130+
$dontCheck = $result -eq $null
131+
} catch {
132+
# No-op
133+
}
127134

128-
$NewServiceClient_params = @{
129-
FullClientTypeName = 'Microsoft.AzureStack.Management.Compute.Admin.ComputeAdminClient'
130-
}
135+
if ($dontCheck -or ($Force.IsPresent -or $PSCmdlet.ShouldContinue("Virtual machine image exists with values $Publisher/$Offer/$Sku/$Version, overwrite?", "Performing operation add virtual machine image with publisher $Publisher, offer $Offer, SKU $Sku, and version $Version.")) {
131136

132-
$GlobalParameterHashtable = @{}
133-
$NewServiceClient_params['GlobalParameterHashtable'] = $GlobalParameterHashtable
137+
$NewServiceClient_params = @{
138+
FullClientTypeName = 'Microsoft.AzureStack.Management.Compute.Admin.ComputeAdminClient'
139+
}
134140

135-
$GlobalParameterHashtable['SubscriptionId'] = $null
136-
if ($PSBoundParameters.ContainsKey('SubscriptionId')) {
137-
$GlobalParameterHashtable['SubscriptionId'] = $PSBoundParameters['SubscriptionId']
138-
}
141+
$GlobalParameterHashtable = @{}
142+
$NewServiceClient_params['GlobalParameterHashtable'] = $GlobalParameterHashtable
139143

140-
$ComputeAdminClient = New-ServiceClient @NewServiceClient_params
144+
$GlobalParameterHashtable['SubscriptionId'] = $null
145+
if ($PSBoundParameters.ContainsKey('SubscriptionId')) {
146+
$GlobalParameterHashtable['SubscriptionId'] = $PSBoundParameters['SubscriptionId']
147+
}
141148

142-
# Create object
143-
$flattenedParameters = @('DataDisks')
144-
$utilityCmdParams = @{}
145-
$utilityCmdParams['OsDisk'] = New-OSDiskObject -OsType $OsType -Uri $OsUri
146-
if ($PSBoundParameters.ContainsKey('BillingPartNumber')) {
147-
$utilityCmdParams['Details'] = New-ImageDetailsObject -BillingPartNumber $PSBoundParameters['BillingPartNumber']
148-
}
149-
$flattenedParameters | ForEach-Object {
150-
if ($PSBoundParameters.ContainsKey($_)) {
151-
$utilityCmdParams[$_] = $PSBoundParameters[$_]
149+
$ComputeAdminClient = New-ServiceClient @NewServiceClient_params
150+
151+
# Create object
152+
$flattenedParameters = @('DataDisks')
153+
$utilityCmdParams = @{}
154+
$utilityCmdParams['OsDisk'] = New-OSDiskObject -OsType $OsType -Uri $OsUri
155+
if ($PSBoundParameters.ContainsKey('BillingPartNumber')) {
156+
$utilityCmdParams['Details'] = New-ImageDetailsObject -BillingPartNumber $PSBoundParameters['BillingPartNumber']
152157
}
153-
}
154-
$NewImage = New-PlatformImageParametersObject @utilityCmdParams
158+
$flattenedParameters | ForEach-Object {
159+
if ($PSBoundParameters.ContainsKey($_)) {
160+
$utilityCmdParams[$_] = $PSBoundParameters[$_]
161+
}
162+
}
163+
$NewImage = New-PlatformImageParametersObject @utilityCmdParams
155164

156-
if ( -not $PSBoundParameters.ContainsKey('Location')) {
157-
$Location = (Get-AzureRMLocation).Location
158-
}
165+
if ( -not $PSBoundParameters.ContainsKey('Location')) {
166+
$Location = (Get-AzureRMLocation).Location
167+
}
159168

160-
Write-Verbose -Message 'Performing operation CreateWithHttpMessagesAsync on $ComputeAdminClient.'
161-
$TaskResult = $ComputeAdminClient.PlatformImages.CreateWithHttpMessagesAsync($Location, $Publisher, $Offer, $Sku, $Version, $NewImage)
162-
163-
Write-Verbose -Message "Waiting for the operation to complete."
164-
165-
$PSSwaggerJobScriptBlock = {
166-
[CmdletBinding()]
167-
param(
168-
[Parameter(Mandatory = $true)]
169-
[System.Threading.Tasks.Task]
170-
$TaskResult,
171-
172-
[Parameter(Mandatory = $true)]
173-
[System.String]
174-
$TaskHelperFilePath
175-
)
176-
if ($TaskResult) {
177-
. $TaskHelperFilePath
178-
$GetTaskResult_params = @{
179-
TaskResult = $TaskResult
169+
Write-Verbose -Message 'Performing operation add on $ComputeAdminClient.'
170+
$TaskResult = $ComputeAdminClient.PlatformImages.CreateWithHttpMessagesAsync($Location, $Publisher, $Offer, $Sku, $Version, $NewImage)
171+
172+
Write-Verbose -Message "Waiting for the operation to complete."
173+
174+
$PSSwaggerJobScriptBlock = {
175+
[CmdletBinding()]
176+
param(
177+
[Parameter(Mandatory = $true)]
178+
[System.Threading.Tasks.Task]
179+
$TaskResult,
180+
181+
[Parameter(Mandatory = $true)]
182+
[System.String]
183+
$TaskHelperFilePath
184+
)
185+
if ($TaskResult) {
186+
. $TaskHelperFilePath
187+
$GetTaskResult_params = @{
188+
TaskResult = $TaskResult
189+
}
190+
Get-TaskResult @GetTaskResult_params
180191
}
181-
Get-TaskResult @GetTaskResult_params
182192
}
183-
}
184193

185-
$PSCommonParameters = Get-PSCommonParameter -CallerPSBoundParameters $PSBoundParameters
186-
$TaskHelperFilePath = Join-Path -Path $ExecutionContext.SessionState.Module.ModuleBase -ChildPath 'Get-TaskResult.ps1'
187-
if ($AsJob) {
188-
$ScriptBlockParameters = New-Object -TypeName 'System.Collections.Generic.Dictionary[string,object]'
189-
$ScriptBlockParameters['TaskResult'] = $TaskResult
190-
$ScriptBlockParameters['AsJob'] = $true
191-
$ScriptBlockParameters['TaskHelperFilePath'] = $TaskHelperFilePath
192-
$PSCommonParameters.GetEnumerator() | ForEach-Object { $ScriptBlockParameters[$_.Name] = $_.Value }
193-
194-
Start-PSSwaggerJobHelper -ScriptBlock $PSSwaggerJobScriptBlock `
195-
-CallerPSBoundParameters $ScriptBlockParameters `
196-
-CallerPSCmdlet $PSCmdlet `
197-
@PSCommonParameters
198-
} else {
199-
Invoke-Command -ScriptBlock $PSSwaggerJobScriptBlock `
200-
-ArgumentList $TaskResult, $TaskHelperFilePath `
201-
@PSCommonParameters
194+
$PSCommonParameters = Get-PSCommonParameter -CallerPSBoundParameters $PSBoundParameters
195+
$TaskHelperFilePath = Join-Path -Path $ExecutionContext.SessionState.Module.ModuleBase -ChildPath 'Get-TaskResult.ps1'
196+
if ($AsJob) {
197+
$ScriptBlockParameters = New-Object -TypeName 'System.Collections.Generic.Dictionary[string,object]'
198+
$ScriptBlockParameters['TaskResult'] = $TaskResult
199+
$ScriptBlockParameters['AsJob'] = $true
200+
$ScriptBlockParameters['TaskHelperFilePath'] = $TaskHelperFilePath
201+
$PSCommonParameters.GetEnumerator() | ForEach-Object { $ScriptBlockParameters[$_.Name] = $_.Value }
202+
203+
Start-PSSwaggerJobHelper -ScriptBlock $PSSwaggerJobScriptBlock `
204+
-CallerPSBoundParameters $ScriptBlockParameters `
205+
-CallerPSCmdlet $PSCmdlet `
206+
@PSCommonParameters
207+
} else {
208+
Invoke-Command -ScriptBlock $PSSwaggerJobScriptBlock `
209+
-ArgumentList $TaskResult, $TaskHelperFilePath `
210+
@PSCommonParameters
211+
}
202212
}
203213
}
204214
}
205-
}
206215

207-
End {
208-
if ($tracerObject) {
209-
$global:DebugPreference = $oldDebugPreference
210-
Unregister-PSSwaggerClientTracing -TracerObject $tracerObject
216+
End {
217+
if ($tracerObject) {
218+
$global:DebugPreference = $oldDebugPreference
219+
Unregister-PSSwaggerClientTracing -TracerObject $tracerObject
220+
}
211221
}
212222
}
213-
}
214223

src/StackAdmin/Azs.Compute.Admin/Module/Azs.Compute.Admin/Generated.PowerShell.Commands/SwaggerPathCommands/Add-AzsVMExtension.ps1

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -126,8 +126,17 @@ function Add-AzsVMExtension {
126126
Process {
127127
$ErrorActionPreference = 'Stop'
128128

129-
if ($PSCmdlet.ShouldProcess("$Publisher / $Type / $Version" , "Add virtual machine image extension")) {
130-
if ($Force.IsPresent -or $PSCmdlet.ShouldContinue("Add virtual machine image extension?", "Performing operation add virtual machine image extension with publisher $Publisher, type $Type, and version $Version.")) {
129+
if ($PSCmdlet.ShouldProcess("$Publisher/$Type/$Version" , "Add virtual machine image extension")) {
130+
131+
$dontCheck = $true
132+
try {
133+
$result = Get-AzsVMExtension -Publisher $Publisher -Type $Type -Sku $Sku
134+
$dontCheck = $result -eq $null
135+
} catch {
136+
# No-op
137+
}
138+
139+
if ($dontCheck -or ($Force.IsPresent -or $PSCmdlet.ShouldContinue("Virtual machine image extension exists with values $Publisher/$Type/$Sku, overwrite?", "Performing operation add virtual machine image extension with publisher $Publisher, type $Type, and version $Version."))) {
131140

132141
$NewServiceClient_params = @{
133142
FullClientTypeName = 'Microsoft.AzureStack.Management.Compute.Admin.ComputeAdminClient'
@@ -160,7 +169,7 @@ function Add-AzsVMExtension {
160169
$Location = (Get-AzureRMLocation).Location
161170
}
162171

163-
Write-Verbose -Message 'Performing operation CreateWithHttpMessagesAsync on $ComputeAdminClient.'
172+
Write-Verbose -Message 'Performing operation add on $ComputeAdminClient.'
164173
$TaskResult = $ComputeAdminClient.VMExtensions.CreateWithHttpMessagesAsync($Location, $Publisher, $Type, $Version, $Extension)
165174

166175
Write-Verbose -Message "Waiting for the operation to complete."

src/StackAdmin/Azs.Compute.Admin/Module/Azs.Compute.Admin/Generated.PowerShell.Commands/SwaggerPathCommands/New-AzsComputeQuota.ps1

Lines changed: 43 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ Changes may cause incorrect behavior and will be lost if the code is regenerated
4040
#>
4141
function New-AzsComputeQuota {
4242
[OutputType([Microsoft.AzureStack.Management.Compute.Admin.Models.Quota])]
43-
[CmdletBinding()]
43+
[CmdletBinding(SupportsShouldProcess = $true)]
4444
param(
4545
[Parameter(Mandatory = $true)]
4646
[ValidateNotNullOrEmpty()]
@@ -83,41 +83,54 @@ function New-AzsComputeQuota {
8383

8484
$ErrorActionPreference = 'Stop'
8585

86-
$NewServiceClient_params = @{
87-
FullClientTypeName = 'Microsoft.AzureStack.Management.Compute.Admin.ComputeAdminClient'
88-
}
89-
90-
$GlobalParameterHashtable = @{}
91-
$NewServiceClient_params['GlobalParameterHashtable'] = $GlobalParameterHashtable
92-
93-
$GlobalParameterHashtable['SubscriptionId'] = $null
94-
if ($PSBoundParameters.ContainsKey('SubscriptionId')) {
95-
$GlobalParameterHashtable['SubscriptionId'] = $PSBoundParameters['SubscriptionId']
96-
}
86+
if ($PSCmdlet.ShouldProcess("$Name", "Create a new compute quota.")) {
9787

98-
$ComputeAdminClient = New-ServiceClient @NewServiceClient_params
88+
# Default location if missing
89+
if ([System.String]::IsNullOrEmpty($Location)) {
90+
$Location = (Get-AzureRmLocation).Location
91+
}
9992

100-
# Default location if missing
101-
if ([System.String]::IsNullOrEmpty($Location)) {
102-
$Location = (Get-AzureRmLocation).Location
103-
}
93+
# Validate this resource does not exist.
94+
$_objectCheck = $null
95+
try {
96+
Write-Verbose "Checking to see if compute quota already exists."
97+
$_objectCheck = Get-AzsComputeQuota -Name $Name -Location $Location
98+
} catch {
99+
# No op
100+
} finally {
101+
if ($_objectCheck -ne $null) {
102+
throw "A compute quota with name $Name at location $Location already exists."
103+
}
104+
}
104105

105-
# Create object
106-
$flattenedParameters = @('AvailabilitySetCount', 'CoresLimit', 'VmScaleSetCount', 'VirtualMachineCount', 'Location' )
107-
$utilityCmdParams = @{}
108-
$flattenedParameters | ForEach-Object {
109-
$utilityCmdParams[$_] = Get-Variable -Name $_ -ValueOnly
110-
}
111-
$NewQuota = New-QuotaObject @utilityCmdParams
106+
# Create object
107+
$flattenedParameters = @('AvailabilitySetCount', 'CoresLimit', 'VmScaleSetCount', 'VirtualMachineCount', 'Location' )
108+
$utilityCmdParams = @{}
109+
$flattenedParameters | ForEach-Object {
110+
$utilityCmdParams[$_] = Get-Variable -Name $_ -ValueOnly
111+
}
112+
$NewQuota = New-QuotaObject @utilityCmdParams
113+
114+
$NewServiceClient_params = @{
115+
FullClientTypeName = 'Microsoft.AzureStack.Management.Compute.Admin.ComputeAdminClient'
116+
}
117+
$GlobalParameterHashtable = @{}
118+
$GlobalParameterHashtable['SubscriptionId'] = $null
119+
if ($PSBoundParameters.ContainsKey('SubscriptionId')) {
120+
$GlobalParameterHashtable['SubscriptionId'] = $PSBoundParameters['SubscriptionId']
121+
}
122+
$NewServiceClient_params['GlobalParameterHashtable'] = $GlobalParameterHashtable
123+
$ComputeAdminClient = New-ServiceClient @NewServiceClient_params
112124

113-
Write-Verbose -Message 'Performing operation CreateOrUpdateWithHttpMessagesAsync on $ComputeAdminClient.'
114-
$TaskResult = $ComputeAdminClient.Quotas.CreateOrUpdateWithHttpMessagesAsync($Location, $Name, $NewQuota)
125+
Write-Verbose -Message 'Performing operation create on $ComputeAdminClient.'
126+
$TaskResult = $ComputeAdminClient.Quotas.CreateOrUpdateWithHttpMessagesAsync($Location, $Name, $NewQuota)
115127

116-
if ($TaskResult) {
117-
$GetTaskResult_params = @{
118-
TaskResult = $TaskResult
128+
if ($TaskResult) {
129+
$GetTaskResult_params = @{
130+
TaskResult = $TaskResult
131+
}
132+
Get-TaskResult @GetTaskResult_params
119133
}
120-
Get-TaskResult @GetTaskResult_params
121134
}
122135
}
123136

src/StackAdmin/Azs.Compute.Admin/Module/Azs.Compute.Admin/Generated.PowerShell.Commands/SwaggerPathCommands/Set-AzsComputeQuota.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ function Set-AzsComputeQuota {
151151
}
152152
}
153153

154-
Write-Verbose -Message 'Performing operation CreateOrUpdateWithHttpMessagesAsync on $ComputeAdminClient.'
154+
Write-Verbose -Message 'Performing operation update on $ComputeAdminClient.'
155155
$TaskResult = $ComputeAdminClient.Quotas.CreateOrUpdateWithHttpMessagesAsync($Location, $Name, $NewQuota)
156156
} else {
157157
Write-Verbose -Message 'Failed to map parameter set to operation method.'

0 commit comments

Comments
 (0)