Skip to content

Commit e4d975f

Browse files
authored
Merge pull request Azure#30 from bganapa/AzureStack
Removing shouldprocess for New*
2 parents b2af9d5 + a27dccb commit e4d975f

File tree

9 files changed

+307
-334
lines changed

9 files changed

+307
-334
lines changed

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

Lines changed: 28 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ Changes may cause incorrect behavior and will be lost if the code is regenerated
4343
#>
4444
function New-AzsComputeQuota {
4545
[OutputType([Microsoft.AzureStack.Management.Compute.Admin.Models.Quota])]
46-
[CmdletBinding(SupportsShouldProcess = $true)]
4746
param(
4847
[Parameter(Mandatory = $true)]
4948
[ValidateNotNullOrEmpty()]
@@ -89,45 +88,43 @@ function New-AzsComputeQuota {
8988
Process {
9089

9190
$ErrorActionPreference = 'Stop'
92-
if ($PSCmdlet.ShouldProcess("$Name" , "Add new compute quota")) {
93-
if ($Force.IsPresent -or $PSCmdlet.ShouldContinue("Add new compute quota?", "Adding a new compute quota with name $Name")) {
91+
if ($Force.IsPresent -or $PSCmdlet.ShouldContinue("Add new compute quota?", "Adding a new compute quota with name $Name")) {
9492

95-
$NewServiceClient_params = @{
96-
FullClientTypeName = 'Microsoft.AzureStack.Management.Compute.Admin.ComputeAdminClient'
97-
}
93+
$NewServiceClient_params = @{
94+
FullClientTypeName = 'Microsoft.AzureStack.Management.Compute.Admin.ComputeAdminClient'
95+
}
9896

99-
$GlobalParameterHashtable = @{}
100-
$NewServiceClient_params['GlobalParameterHashtable'] = $GlobalParameterHashtable
97+
$GlobalParameterHashtable = @{}
98+
$NewServiceClient_params['GlobalParameterHashtable'] = $GlobalParameterHashtable
10199

102-
$GlobalParameterHashtable['SubscriptionId'] = $null
103-
if ($PSBoundParameters.ContainsKey('SubscriptionId')) {
104-
$GlobalParameterHashtable['SubscriptionId'] = $PSBoundParameters['SubscriptionId']
105-
}
100+
$GlobalParameterHashtable['SubscriptionId'] = $null
101+
if ($PSBoundParameters.ContainsKey('SubscriptionId')) {
102+
$GlobalParameterHashtable['SubscriptionId'] = $PSBoundParameters['SubscriptionId']
103+
}
106104

107-
$ComputeAdminClient = New-ServiceClient @NewServiceClient_params
105+
$ComputeAdminClient = New-ServiceClient @NewServiceClient_params
108106

109-
# Default location if missing
110-
if ([String]::IsNullOrEmpty($Location)) {
111-
$Location = (Get-AzureRmLocation).Location
112-
}
107+
# Default location if missing
108+
if ([String]::IsNullOrEmpty($Location)) {
109+
$Location = (Get-AzureRmLocation).Location
110+
}
113111

114-
# Create object
115-
$flattenedParameters = @('AvailabilitySetCount', 'CoresLimit', 'VmScaleSetCount', 'VirtualMachineCount', 'Location' )
116-
$utilityCmdParams = @{}
117-
$flattenedParameters | ForEach-Object {
118-
$utilityCmdParams[$_] = Get-Variable -Name $_ -ValueOnly
119-
}
120-
$NewQuota = New-QuotaObject @utilityCmdParams
112+
# Create object
113+
$flattenedParameters = @('AvailabilitySetCount', 'CoresLimit', 'VmScaleSetCount', 'VirtualMachineCount', 'Location' )
114+
$utilityCmdParams = @{}
115+
$flattenedParameters | ForEach-Object {
116+
$utilityCmdParams[$_] = Get-Variable -Name $_ -ValueOnly
117+
}
118+
$NewQuota = New-QuotaObject @utilityCmdParams
121119

122-
Write-Verbose -Message 'Performing operation CreateOrUpdateWithHttpMessagesAsync on $ComputeAdminClient.'
123-
$TaskResult = $ComputeAdminClient.Quotas.CreateOrUpdateWithHttpMessagesAsync($Location, $Name, $NewQuota)
120+
Write-Verbose -Message 'Performing operation CreateOrUpdateWithHttpMessagesAsync on $ComputeAdminClient.'
121+
$TaskResult = $ComputeAdminClient.Quotas.CreateOrUpdateWithHttpMessagesAsync($Location, $Name, $NewQuota)
124122

125-
if ($TaskResult) {
126-
$GetTaskResult_params = @{
127-
TaskResult = $TaskResult
128-
}
129-
Get-TaskResult @GetTaskResult_params
123+
if ($TaskResult) {
124+
$GetTaskResult_params = @{
125+
TaskResult = $TaskResult
130126
}
127+
Get-TaskResult @GetTaskResult_params
131128
}
132129
}
133130
}

src/StackAdmin/Azs.Fabric.Admin/Module/Azs.Fabric.Admin/Generated.PowerShell.Commands/SwaggerPathCommands/New-AzsIpPool.ps1

Lines changed: 65 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ Licensed under the MIT License. See License.txt in the project root for license
4343
#>
4444
function New-AzsIpPool {
4545
[OutputType([Microsoft.AzureStack.Management.Fabric.Admin.Models.ProvisioningState])]
46-
[CmdletBinding(SupportsShouldProcess = $true)]
4746
param(
4847
[Parameter(Mandatory = $false)]
4948
[string]
@@ -98,84 +97,82 @@ function New-AzsIpPool {
9897

9998
$ErrorActionPreference = 'Stop'
10099

101-
if ($PSCmdlet.ShouldProcess("$Name" , "Add IP pool")) {
102-
if ($Force.IsPresent -or $PSCmdlet.ShouldContinue("Add IP pool?", "Performing operation add IP pool for $Name")) {
100+
if ($Force.IsPresent -or $PSCmdlet.ShouldContinue("Add IP pool?", "Performing operation add IP pool for $Name")) {
103101

104-
$NewServiceClient_params = @{
105-
FullClientTypeName = 'Microsoft.AzureStack.Management.Fabric.Admin.FabricAdminClient'
106-
}
102+
$NewServiceClient_params = @{
103+
FullClientTypeName = 'Microsoft.AzureStack.Management.Fabric.Admin.FabricAdminClient'
104+
}
107105

108-
$GlobalParameterHashtable = @{}
109-
$NewServiceClient_params['GlobalParameterHashtable'] = $GlobalParameterHashtable
106+
$GlobalParameterHashtable = @{}
107+
$NewServiceClient_params['GlobalParameterHashtable'] = $GlobalParameterHashtable
110108

111-
$GlobalParameterHashtable['SubscriptionId'] = $null
112-
if ($PSBoundParameters.ContainsKey('SubscriptionId')) {
113-
$GlobalParameterHashtable['SubscriptionId'] = $PSBoundParameters['SubscriptionId']
114-
}
109+
$GlobalParameterHashtable['SubscriptionId'] = $null
110+
if ($PSBoundParameters.ContainsKey('SubscriptionId')) {
111+
$GlobalParameterHashtable['SubscriptionId'] = $PSBoundParameters['SubscriptionId']
112+
}
115113

116-
$FabricAdminClient = New-ServiceClient @NewServiceClient_params
114+
$FabricAdminClient = New-ServiceClient @NewServiceClient_params
117115

118-
if ([String]::IsNullOrEmpty($Location)) {
119-
$Location = (Get-AzureRMLocation).Location
120-
}
121-
if ([String]::IsNullOrEmpty($ResourceGroupName)) {
122-
$ResourceGroupName = "System.$Location"
123-
}
116+
if ([String]::IsNullOrEmpty($Location)) {
117+
$Location = (Get-AzureRMLocation).Location
118+
}
119+
if ([String]::IsNullOrEmpty($ResourceGroupName)) {
120+
$ResourceGroupName = "System.$Location"
121+
}
124122

125-
$flattenedParameters = @('NumberOfIpAddressesInTransition', 'StartIpAddress', 'Tags', 'AddressPrefix', 'NumberOfIpAddresses', 'Location', 'EndIpAddress', 'NumberOfAllocatedIpAddresses')
126-
$utilityCmdParams = @{}
127-
$flattenedParameters | ForEach-Object {
128-
if ($PSBoundParameters.ContainsKey($_)) {
129-
$utilityCmdParams[$_] = $PSBoundParameters[$_]
130-
}
123+
$flattenedParameters = @('NumberOfIpAddressesInTransition', 'StartIpAddress', 'Tags', 'AddressPrefix', 'NumberOfIpAddresses', 'Location', 'EndIpAddress', 'NumberOfAllocatedIpAddresses')
124+
$utilityCmdParams = @{}
125+
$flattenedParameters | ForEach-Object {
126+
if ($PSBoundParameters.ContainsKey($_)) {
127+
$utilityCmdParams[$_] = $PSBoundParameters[$_]
131128
}
132-
$Pool = New-IpPoolObject @utilityCmdParams
133-
134-
Write-Verbose -Message 'Performing operation CreateOrUpdateWithHttpMessagesAsync on $FabricAdminClient.'
135-
$TaskResult = $FabricAdminClient.IpPools.CreateOrUpdateWithHttpMessagesAsync($ResourceGroupName, $Location, $Name, $Pool)
136-
137-
Write-Verbose -Message "Waiting for the operation to complete."
138-
139-
$PSSwaggerJobScriptBlock = {
140-
[CmdletBinding()]
141-
param(
142-
[Parameter(Mandatory = $true)]
143-
[System.Threading.Tasks.Task]
144-
$TaskResult,
145-
146-
[Parameter(Mandatory = $true)]
147-
[string]
148-
$TaskHelperFilePath
149-
)
150-
if ($TaskResult) {
151-
. $TaskHelperFilePath
152-
$GetTaskResult_params = @{
153-
TaskResult = $TaskResult
154-
}
129+
}
130+
$Pool = New-IpPoolObject @utilityCmdParams
131+
132+
Write-Verbose -Message 'Performing operation CreateOrUpdateWithHttpMessagesAsync on $FabricAdminClient.'
133+
$TaskResult = $FabricAdminClient.IpPools.CreateOrUpdateWithHttpMessagesAsync($ResourceGroupName, $Location, $Name, $Pool)
134+
135+
Write-Verbose -Message "Waiting for the operation to complete."
136+
137+
$PSSwaggerJobScriptBlock = {
138+
[CmdletBinding()]
139+
param(
140+
[Parameter(Mandatory = $true)]
141+
[System.Threading.Tasks.Task]
142+
$TaskResult,
143+
144+
[Parameter(Mandatory = $true)]
145+
[string]
146+
$TaskHelperFilePath
147+
)
148+
if ($TaskResult) {
149+
. $TaskHelperFilePath
150+
$GetTaskResult_params = @{
151+
TaskResult = $TaskResult
152+
}
155153

156-
Get-TaskResult @GetTaskResult_params
154+
Get-TaskResult @GetTaskResult_params
157155

158-
}
159156
}
157+
}
160158

161-
$PSCommonParameters = Get-PSCommonParameter -CallerPSBoundParameters $PSBoundParameters
162-
$TaskHelperFilePath = Join-Path -Path $ExecutionContext.SessionState.Module.ModuleBase -ChildPath 'Get-TaskResult.ps1'
163-
if (-not $AsJob.IsPresent) {
164-
Invoke-Command -ScriptBlock $PSSwaggerJobScriptBlock `
165-
-ArgumentList $TaskResult, $TaskHelperFilePath `
166-
@PSCommonParameters
167-
} else {
168-
$ScriptBlockParameters = New-Object -TypeName 'System.Collections.Generic.Dictionary[string,object]'
169-
$ScriptBlockParameters['TaskResult'] = $TaskResult
170-
$ScriptBlockParameters['AsJob'] = $true
171-
$ScriptBlockParameters['TaskHelperFilePath'] = $TaskHelperFilePath
172-
$PSCommonParameters.GetEnumerator() | ForEach-Object { $ScriptBlockParameters[$_.Name] = $_.Value }
173-
174-
Start-PSSwaggerJobHelper -ScriptBlock $PSSwaggerJobScriptBlock `
175-
-CallerPSBoundParameters $ScriptBlockParameters `
176-
-CallerPSCmdlet $PSCmdlet `
177-
@PSCommonParameters
178-
}
159+
$PSCommonParameters = Get-PSCommonParameter -CallerPSBoundParameters $PSBoundParameters
160+
$TaskHelperFilePath = Join-Path -Path $ExecutionContext.SessionState.Module.ModuleBase -ChildPath 'Get-TaskResult.ps1'
161+
if (-not $AsJob.IsPresent) {
162+
Invoke-Command -ScriptBlock $PSSwaggerJobScriptBlock `
163+
-ArgumentList $TaskResult, $TaskHelperFilePath `
164+
@PSCommonParameters
165+
} else {
166+
$ScriptBlockParameters = New-Object -TypeName 'System.Collections.Generic.Dictionary[string,object]'
167+
$ScriptBlockParameters['TaskResult'] = $TaskResult
168+
$ScriptBlockParameters['AsJob'] = $true
169+
$ScriptBlockParameters['TaskHelperFilePath'] = $TaskHelperFilePath
170+
$PSCommonParameters.GetEnumerator() | ForEach-Object { $ScriptBlockParameters[$_.Name] = $_.Value }
171+
172+
Start-PSSwaggerJobHelper -ScriptBlock $PSSwaggerJobScriptBlock `
173+
-CallerPSBoundParameters $ScriptBlockParameters `
174+
-CallerPSCmdlet $PSCmdlet `
175+
@PSCommonParameters
179176
}
180177
}
181178
}

src/StackAdmin/Azs.Network.Admin/Module/Azs.Network.Admin/Generated.PowerShell.Commands/SwaggerPathCommands/New-AzsNetworkQuota.ps1

Lines changed: 32 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ Licensed under the MIT License. See License.txt in the project root for license
5050
#>
5151
function New-AzsNetworkQuota {
5252
[OutputType([Microsoft.AzureStack.Management.Network.Admin.Models.Quota])]
53-
[CmdletBinding(SupportsShouldProcess = $true)]
5453
param(
5554
[Parameter(Mandatory = $true)]
5655
[ValidateNotNullOrEmpty()]
@@ -114,49 +113,47 @@ function New-AzsNetworkQuota {
114113

115114
$ErrorActionPreference = 'Stop'
116115

117-
if ($PSCmdlet.ShouldProcess("$Name" , "Create new network quota")) {
118-
if (($Force.IsPresent -or $PSCmdlet.ShouldContinue("Create new network quota?", "Performing operation create network quota with $Name."))) {
116+
if (($Force.IsPresent -or $PSCmdlet.ShouldContinue("Create new network quota?", "Performing operation create network quota with $Name."))) {
119117

120-
$NewServiceClient_params = @{
121-
FullClientTypeName = 'Microsoft.AzureStack.Management.Network.Admin.NetworkAdminClient'
122-
}
118+
$NewServiceClient_params = @{
119+
FullClientTypeName = 'Microsoft.AzureStack.Management.Network.Admin.NetworkAdminClient'
120+
}
123121

124-
$GlobalParameterHashtable = @{}
125-
$NewServiceClient_params['GlobalParameterHashtable'] = $GlobalParameterHashtable
122+
$GlobalParameterHashtable = @{}
123+
$NewServiceClient_params['GlobalParameterHashtable'] = $GlobalParameterHashtable
126124

127-
$GlobalParameterHashtable['SubscriptionId'] = $null
128-
if ($PSBoundParameters.ContainsKey('SubscriptionId')) {
129-
$GlobalParameterHashtable['SubscriptionId'] = $PSBoundParameters['SubscriptionId']
130-
}
125+
$GlobalParameterHashtable['SubscriptionId'] = $null
126+
if ($PSBoundParameters.ContainsKey('SubscriptionId')) {
127+
$GlobalParameterHashtable['SubscriptionId'] = $PSBoundParameters['SubscriptionId']
128+
}
131129

132-
$NetworkAdminClient = New-ServiceClient @NewServiceClient_params
130+
$NetworkAdminClient = New-ServiceClient @NewServiceClient_params
133131

134-
if ([String]::IsNullOrEmpty($Location)) {
135-
$Location = (Get-AzureRMLocation).Location
136-
}
132+
if ([String]::IsNullOrEmpty($Location)) {
133+
$Location = (Get-AzureRMLocation).Location
134+
}
137135

138-
# Create object
139-
$flattenedParameters = @(
140-
'MaxNicsPerSubscription', 'MaxPublicIpsPerSubscription',
141-
'MaxVirtualNetworkGatewayConnectionsPerSubscription', 'MaxVnetsPerSubscription',
142-
'MaxVirtualNetworkGatewaysPerSubscription', 'MaxSecurityGroupsPerSubscription',
143-
'MaxLoadBalancersPerSubscription', 'MigrationPhase'
144-
)
145-
$utilityCmdParams = @{}
146-
$flattenedParameters | ForEach-Object {
147-
$utilityCmdParams[$_] = Get-Variable -Name $_ -ValueOnly
148-
}
149-
$Quota = New-QuotaObject @utilityCmdParams
136+
# Create object
137+
$flattenedParameters = @(
138+
'MaxNicsPerSubscription', 'MaxPublicIpsPerSubscription',
139+
'MaxVirtualNetworkGatewayConnectionsPerSubscription', 'MaxVnetsPerSubscription',
140+
'MaxVirtualNetworkGatewaysPerSubscription', 'MaxSecurityGroupsPerSubscription',
141+
'MaxLoadBalancersPerSubscription', 'MigrationPhase'
142+
)
143+
$utilityCmdParams = @{}
144+
$flattenedParameters | ForEach-Object {
145+
$utilityCmdParams[$_] = Get-Variable -Name $_ -ValueOnly
146+
}
147+
$Quota = New-QuotaObject @utilityCmdParams
150148

151-
Write-Verbose -Message 'Performing operation CreateOrUpdateWithHttpMessagesAsync on $NetworkAdminClient.'
152-
$TaskResult = $NetworkAdminClient.Quotas.CreateOrUpdateWithHttpMessagesAsync($Location, $Name, $Quota)
149+
Write-Verbose -Message 'Performing operation CreateOrUpdateWithHttpMessagesAsync on $NetworkAdminClient.'
150+
$TaskResult = $NetworkAdminClient.Quotas.CreateOrUpdateWithHttpMessagesAsync($Location, $Name, $Quota)
153151

154-
if ($TaskResult) {
155-
$GetTaskResult_params = @{
156-
TaskResult = $TaskResult
157-
}
158-
Get-TaskResult @GetTaskResult_params
152+
if ($TaskResult) {
153+
$GetTaskResult_params = @{
154+
TaskResult = $TaskResult
159155
}
156+
Get-TaskResult @GetTaskResult_params
160157
}
161158
}
162159
}

0 commit comments

Comments
 (0)