Skip to content

Commit 9f67c13

Browse files
committed
Change update from GET+PUT to GET+PATCH
1 parent 9be5978 commit 9f67c13

12 files changed

+437
-101
lines changed

src/Workloads/SapVirtualInstance.Autorest/Properties/AssemblyInfo.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,7 @@
2525
[assembly: System.Runtime.InteropServices.ComVisibleAttribute(false)]
2626
[assembly: System.CLSCompliantAttribute(false)]
2727

28+
29+
30+
31+

src/Workloads/SapVirtualInstance.Autorest/README.md

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ subject-prefix: Workloads
4646
namespace: Microsoft.Azure.PowerShell.Cmdlets.Workloads.SapVirtualInstance
4747
inlining-threshold: 100
4848

49+
flatten-userassignedidentity: false
50+
disable-transform-identity-type: true
51+
4952
directive:
5053
- where:
5154
variant: ^(Stop|Update)(?!.*?(Expanded|JsonFilePath|JsonString))
@@ -92,7 +95,7 @@ directive:
9295
- where:
9396
verb: New
9497
subject: ^SapVirtualInstance$
95-
variant: ^Create$|^CreateViaIdentity$|^CreateViaIdentityExpanded$
98+
variant: ^(Create)(?!.*?(Expanded|JsonFilePath|JsonString))|^CreateViaIdentityExpanded$
9699
remove: true
97100

98101
- where:
@@ -103,15 +106,14 @@ directive:
103106

104107
- where:
105108
subject: ^SapVirtualInstance$
106-
parameter-name: IdentityUserAssignedIdentity
109+
parameter-name: ManagedResourceGroupConfigurationName
107110
set:
108-
parameter-name: UserAssignedIdentity
111+
parameter-name: ManagedResourceGroupName
109112

110113
- where:
114+
verb: Update
111115
subject: ^SapVirtualInstance$
112-
parameter-name: ManagedResourceGroupConfigurationName
113-
set:
114-
parameter-name: ManagedResourceGroupName
116+
hide: true
115117

116118
# SapAvailabilityZoneDetail
117119
- where:

src/Workloads/SapVirtualInstance.Autorest/custom/New-AzWorkloadsSapVirtualInstance/New-AzWorkloadsSapVirtualInstance_CreateWithDiscovery.ps1

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,41 @@ function New-AzWorkloadsSapVirtualInstance {
188188
)
189189
process {
190190
try {
191+
if ($PSBoundParameters.ContainsKey('EnableSystemAssignedIdentity') -or $PSBoundParameters.ContainsKey('UserAssignedIdentity')) {
192+
$supportsSystemAssignedIdentity = $PSBoundParameters.ContainsKey('EnableSystemAssignedIdentity')
193+
$supportsUserAssignedIdentity = $PSBoundParameters.ContainsKey("UserAssignedIdentity") -and $UserAssignedIdentity.Length -gt 0
194+
195+
# calculate IdentityType
196+
if (($supportsSystemAssignedIdentity -and $supportsUserAssignedIdentity)) {
197+
$PSBoundParameters.Add("IdentityType", "SystemAssigned,UserAssigned")
198+
}
199+
elseif ($supportsUserAssignedIdentity -and (-not $supportsSystemAssignedIdentity)) {
200+
$PSBoundParameters.Add("IdentityType", "UserAssigned")
201+
}
202+
elseif ((-not $supportsUserAssignedIdentity) -and $supportsSystemAssignedIdentity) {
203+
$PSBoundParameters.Add("IdentityType", "SystemAssigned")
204+
}
205+
else {
206+
$PSBoundParameters.Add("IdentityType", "None")
207+
}
208+
209+
# If user input UserAssignedIdentity
210+
if ($PSBoundParameters.ContainsKey('UserAssignedIdentity')) {
211+
$userIdentityObject = [Microsoft.Azure.PowerShell.Cmdlets.Workloads.SapVirtualInstance.Models.UserAssignedIdentity]::New()
212+
$PSBoundParameters.IdentityUserAssignedIdentity = @{}
213+
foreach ($item in $PSBoundParameters.UserAssignedIdentity) {
214+
$PSBoundParameters.IdentityUserAssignedIdentity.Add($item, $userIdentityObject )
215+
}
216+
217+
$null = $PSBoundParameters.Remove('UserAssignedIdentity')
218+
}
219+
220+
# remove EnableSystemAssignedIdentity
221+
if ($PSBoundParameters.ContainsKey('EnableSystemAssignedIdentity')) {
222+
$null = $PSBoundParameters.Remove("EnableSystemAssignedIdentity")
223+
}
224+
}
225+
191226
$discoveryConfiguration = [Microsoft.Azure.PowerShell.Cmdlets.Workloads.SapVirtualInstance.Models.DiscoveryConfiguration]::new();
192227
$discoveryConfiguration.CentralServerVMId = $CentralServerVmId
193228
$null = $PSBoundParameters.Remove('CentralServerVmId')
@@ -196,6 +231,7 @@ function New-AzWorkloadsSapVirtualInstance {
196231
$null = $PSBoundParameters.Remove('ManagedRgStorageAccountName')
197232
}
198233
$null = $PSBoundParameters.Add('Configuration', $discoveryConfiguration)
234+
199235
Az.SapVirtualInstance.private\New-AzWorkloadsSapVirtualInstance_CreateExpanded @PSBoundParameters
200236
} catch {
201237

src/Workloads/SapVirtualInstance.Autorest/custom/New-AzWorkloadsSapVirtualInstance/New-AzWorkloadsSapVirtualInstance_CreateWithJsonString.cs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -171,14 +171,6 @@ public partial class NewAzWorkloadsSapVirtualInstance_CreateWithJsonString : glo
171171
[global::Microsoft.Azure.PowerShell.Cmdlets.Workloads.SapVirtualInstance.Category(global::Microsoft.Azure.PowerShell.Cmdlets.Workloads.SapVirtualInstance.ParameterCategory.Path)]
172172
public string SubscriptionId { get => this._subscriptionId; set => this._subscriptionId = value; }
173173

174-
/// <summary>
175-
/// The array of user assigned identities associated with the resource. The elements in array will be ARM resource ids in
176-
/// the form: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}.'
177-
/// </summary>
178-
[global::System.Management.Automation.Parameter(Mandatory = false, HelpMessage = "The array of user assigned identities associated with the resource. The elements in array will be ARM resource ids in the form: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}.'")]
179-
[global::System.Management.Automation.AllowEmptyCollection]
180-
public string[] UserAssignedIdentity { get; set; }
181-
182174
/// <summary>
183175
/// <c>overrideOnDefault</c> will be called before the regular onDefault has been processed, allowing customization of what
184176
/// happens on that response. Implement this method in a partial class to enable this behavior
Lines changed: 278 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,278 @@
1+
2+
# ----------------------------------------------------------------------------------
3+
# Copyright (c) Microsoft Corporation. All rights reserved.
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
# Unless required by applicable law or agreed to in writing, software
9+
# distributed under the License is distributed on an "AS IS" BASIS,
10+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
# See the License for the specific language governing permissions and
12+
# limitations under the License.
13+
# Code generated by Microsoft (R) AutoRest Code Generator.Changes may cause incorrect behavior and will be lost if the code
14+
# is regenerated.
15+
# ----------------------------------------------------------------------------------
16+
17+
<#
18+
.Synopsis
19+
Update a Virtual Instance for SAP solutions resource
20+
.Description
21+
Update a Virtual Instance for SAP solutions resource
22+
.Example
23+
{{ Add code here }}
24+
.Example
25+
{{ Add code here }}
26+
27+
.Inputs
28+
Microsoft.Azure.PowerShell.Cmdlets.Workloads.SapVirtualInstance.Models.ISapVirtualInstanceIdentity
29+
.Outputs
30+
Microsoft.Azure.PowerShell.Cmdlets.Workloads.SapVirtualInstance.Models.ISapVirtualInstance
31+
.Notes
32+
COMPLEX PARAMETER PROPERTIES
33+
34+
To create the parameters described below, construct a hash table containing the appropriate properties. For information on hash tables, run Get-Help about_Hash_Tables.
35+
36+
INPUTOBJECT <ISapVirtualInstanceIdentity>: Identity Parameter
37+
[ApplicationInstanceName <String>]: The name of SAP Application Server instance resource.
38+
[CentralInstanceName <String>]: Central Services Instance resource name string modeled as parameter for auto generation to work correctly.
39+
[DatabaseInstanceName <String>]: Database resource name string modeled as parameter for auto generation to work correctly.
40+
[Id <String>]: Resource identity path
41+
[Location <String>]: The name of the Azure region.
42+
[ResourceGroupName <String>]: The name of the resource group. The name is case insensitive.
43+
[SapVirtualInstanceName <String>]: The name of the Virtual Instances for SAP solutions resource
44+
[SubscriptionId <String>]: The ID of the target subscription. The value must be an UUID.
45+
.Link
46+
https://learn.microsoft.com/powershell/module/az.workloads/update-azworkloadssapvirtualinstance
47+
#>
48+
function Update-AzWorkloadsSapVirtualInstance {
49+
[Alias('Update-AzVIS')]
50+
[OutputType([Microsoft.Azure.PowerShell.Cmdlets.Workloads.SapVirtualInstance.Models.ISapVirtualInstance])]
51+
[CmdletBinding(DefaultParameterSetName='UpdateExpanded', PositionalBinding=$false, SupportsShouldProcess, ConfirmImpact='Medium')]
52+
param(
53+
[Parameter(ParameterSetName='UpdateExpanded', Mandatory)]
54+
[Parameter(ParameterSetName='UpdateViaJsonFilePath', Mandatory)]
55+
[Parameter(ParameterSetName='UpdateViaJsonString', Mandatory)]
56+
[Alias('SapVirtualInstanceName')]
57+
[Microsoft.Azure.PowerShell.Cmdlets.Workloads.SapVirtualInstance.Category('Path')]
58+
[System.String]
59+
# The name of the Virtual Instances for SAP solutions resource
60+
${Name},
61+
62+
[Parameter(ParameterSetName='UpdateExpanded', Mandatory)]
63+
[Parameter(ParameterSetName='UpdateViaJsonFilePath', Mandatory)]
64+
[Parameter(ParameterSetName='UpdateViaJsonString', Mandatory)]
65+
[Microsoft.Azure.PowerShell.Cmdlets.Workloads.SapVirtualInstance.Category('Path')]
66+
[System.String]
67+
# The name of the resource group.
68+
# The name is case insensitive.
69+
${ResourceGroupName},
70+
71+
[Parameter(ParameterSetName='UpdateExpanded')]
72+
[Parameter(ParameterSetName='UpdateViaJsonFilePath')]
73+
[Parameter(ParameterSetName='UpdateViaJsonString')]
74+
[Microsoft.Azure.PowerShell.Cmdlets.Workloads.SapVirtualInstance.Category('Path')]
75+
[Microsoft.Azure.PowerShell.Cmdlets.Workloads.SapVirtualInstance.Runtime.DefaultInfo(Script='(Get-AzContext).Subscription.Id')]
76+
[System.String]
77+
# The ID of the target subscription.
78+
# The value must be an UUID.
79+
${SubscriptionId},
80+
81+
[Parameter(ParameterSetName='UpdateViaIdentityExpanded', Mandatory, ValueFromPipeline)]
82+
[Microsoft.Azure.PowerShell.Cmdlets.Workloads.SapVirtualInstance.Category('Path')]
83+
[Microsoft.Azure.PowerShell.Cmdlets.Workloads.SapVirtualInstance.Models.ISapVirtualInstanceIdentity]
84+
# Identity Parameter
85+
${InputObject},
86+
87+
[Parameter(ParameterSetName = 'UpdateExpanded')]
88+
[Parameter(ParameterSetName = 'UpdateViaIdentityExpanded')]
89+
[Microsoft.Azure.PowerShell.Cmdlets.Workloads.SapVirtualInstance.Category('Body')]
90+
[System.Nullable[System.Boolean]]
91+
# Determines whether to enable a system-assigned identity for the resource.
92+
${EnableSystemAssignedIdentity},
93+
94+
[Parameter(ParameterSetName='UpdateExpanded')]
95+
[Parameter(ParameterSetName='UpdateViaIdentityExpanded')]
96+
[AllowEmptyCollection()]
97+
[Microsoft.Azure.PowerShell.Cmdlets.Workloads.SapVirtualInstance.Category('Body')]
98+
[System.String[]]
99+
# The array of user assigned identities associated with the resource.
100+
# The elements in array will be ARM resource ids in the form: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}.'
101+
${UserAssignedIdentity},
102+
103+
[Parameter(ParameterSetName='UpdateExpanded')]
104+
[Parameter(ParameterSetName='UpdateViaIdentityExpanded')]
105+
[Microsoft.Azure.PowerShell.Cmdlets.Workloads.SapVirtualInstance.PSArgumentCompleterAttribute("Public", "Private")]
106+
[Microsoft.Azure.PowerShell.Cmdlets.Workloads.SapVirtualInstance.Category('Body')]
107+
[System.String]
108+
# Specifies the network access configuration for the resources that will be deployed in the Managed Resource Group.
109+
# The options to choose from are Public and Private.
110+
# If 'Private' is chosen, the Storage Account service tag should be enabled on the subnets in which the SAP VMs exist.
111+
# This is required for establishing connectivity between VM extensions and the managed resource group storage account.
112+
# This setting is currently applicable only to Storage Account.
113+
# Learn more here https://go.microsoft.com/fwlink/?linkid=2247228
114+
${ManagedResourcesNetworkAccessType},
115+
116+
[Parameter(ParameterSetName='UpdateExpanded')]
117+
[Parameter(ParameterSetName='UpdateViaIdentityExpanded')]
118+
[Microsoft.Azure.PowerShell.Cmdlets.Workloads.SapVirtualInstance.Category('Body')]
119+
[Microsoft.Azure.PowerShell.Cmdlets.Workloads.SapVirtualInstance.Runtime.Info(PossibleTypes=([Microsoft.Azure.PowerShell.Cmdlets.Workloads.SapVirtualInstance.Models.IUpdateSapVirtualInstanceRequestTags]))]
120+
[System.Collections.Hashtable]
121+
# Gets or sets the Resource tags.
122+
${Tag},
123+
124+
[Parameter(ParameterSetName='UpdateViaJsonFilePath', Mandatory)]
125+
[Microsoft.Azure.PowerShell.Cmdlets.Workloads.SapVirtualInstance.Category('Body')]
126+
[System.String]
127+
# Path of Json file supplied to the Update operation
128+
${JsonFilePath},
129+
130+
[Parameter(ParameterSetName='UpdateViaJsonString', Mandatory)]
131+
[Microsoft.Azure.PowerShell.Cmdlets.Workloads.SapVirtualInstance.Category('Body')]
132+
[System.String]
133+
# Json string supplied to the Update operation
134+
${JsonString},
135+
136+
[Parameter()]
137+
[Alias('AzureRMContext', 'AzureCredential')]
138+
[ValidateNotNull()]
139+
[Microsoft.Azure.PowerShell.Cmdlets.Workloads.SapVirtualInstance.Category('Azure')]
140+
[System.Management.Automation.PSObject]
141+
# The DefaultProfile parameter is not functional.
142+
# Use the SubscriptionId parameter when available if executing the cmdlet against a different subscription.
143+
${DefaultProfile},
144+
145+
[Parameter()]
146+
[Microsoft.Azure.PowerShell.Cmdlets.Workloads.SapVirtualInstance.Category('Runtime')]
147+
[System.Management.Automation.SwitchParameter]
148+
# Run the command as a job
149+
${AsJob},
150+
151+
[Parameter(DontShow)]
152+
[Microsoft.Azure.PowerShell.Cmdlets.Workloads.SapVirtualInstance.Category('Runtime')]
153+
[System.Management.Automation.SwitchParameter]
154+
# Wait for .NET debugger to attach
155+
${Break},
156+
157+
[Parameter(DontShow)]
158+
[ValidateNotNull()]
159+
[Microsoft.Azure.PowerShell.Cmdlets.Workloads.SapVirtualInstance.Category('Runtime')]
160+
[Microsoft.Azure.PowerShell.Cmdlets.Workloads.SapVirtualInstance.Runtime.SendAsyncStep[]]
161+
# SendAsync Pipeline Steps to be appended to the front of the pipeline
162+
${HttpPipelineAppend},
163+
164+
[Parameter(DontShow)]
165+
[ValidateNotNull()]
166+
[Microsoft.Azure.PowerShell.Cmdlets.Workloads.SapVirtualInstance.Category('Runtime')]
167+
[Microsoft.Azure.PowerShell.Cmdlets.Workloads.SapVirtualInstance.Runtime.SendAsyncStep[]]
168+
# SendAsync Pipeline Steps to be prepended to the front of the pipeline
169+
${HttpPipelinePrepend},
170+
171+
[Parameter()]
172+
[Microsoft.Azure.PowerShell.Cmdlets.Workloads.SapVirtualInstance.Category('Runtime')]
173+
[System.Management.Automation.SwitchParameter]
174+
# Run the command asynchronously
175+
${NoWait},
176+
177+
[Parameter(DontShow)]
178+
[Microsoft.Azure.PowerShell.Cmdlets.Workloads.SapVirtualInstance.Category('Runtime')]
179+
[System.Uri]
180+
# The URI for the proxy server to use
181+
${Proxy},
182+
183+
[Parameter(DontShow)]
184+
[ValidateNotNull()]
185+
[Microsoft.Azure.PowerShell.Cmdlets.Workloads.SapVirtualInstance.Category('Runtime')]
186+
[System.Management.Automation.PSCredential]
187+
# Credentials for a proxy server to use for the remote call
188+
${ProxyCredential},
189+
190+
[Parameter(DontShow)]
191+
[Microsoft.Azure.PowerShell.Cmdlets.Workloads.SapVirtualInstance.Category('Runtime')]
192+
[System.Management.Automation.SwitchParameter]
193+
# Use the default credentials for the proxy
194+
${ProxyUseDefaultCredentials}
195+
)
196+
process {
197+
if ($PSBoundParameters.ContainsKey('EnableSystemAssignedIdentity') -or $PSBoundParameters.ContainsKey('UserAssignedIdentity') ) {
198+
199+
$EnvPSBoundParameters = @{}
200+
if ($PSBoundParameters.ContainsKey('Debug')) {
201+
$EnvPSBoundParameters['Debug'] = $Debug
202+
}
203+
if ($PSBoundParameters.ContainsKey('HttpPipelineAppend')) {
204+
$EnvPSBoundParameters['HttpPipelineAppend'] = $HttpPipelineAppend
205+
}
206+
if ($PSBoundParameters.ContainsKey('HttpPipelinePrepend')) {
207+
$EnvPSBoundParameters['HttpPipelinePrepend'] = $HttpPipelinePrepend
208+
}
209+
if ($PSBoundParameters.ContainsKey('Proxy')) {
210+
$EnvPSBoundParameters['Proxy'] = $Proxy
211+
}
212+
if ($PSBoundParameters.ContainsKey('ProxyCredential')) {
213+
$EnvPSBoundParameters['ProxyCredential'] = $ProxyCredential
214+
}
215+
if ($PSBoundParameters.ContainsKey('ProxyUseDefaultCredentials')) {
216+
$EnvPSBoundParameters['ProxyUseDefaultCredentials'] = $ProxyUseDefaultCredentials
217+
}
218+
if ($PSBoundParameters.ContainsKey('DefaultProfile')) {
219+
$EnvPSBoundParameters['DefaultProfile'] = $DefaultProfile
220+
}
221+
222+
# Get SAPVirtualInstance DataObj
223+
$parameterSet = $PSCmdlet.ParameterSetName
224+
if (('UpdateExpanded') -contains $parameterSet) {
225+
$SapVirtualInstanceObj = Az.SapVirtualInstance.private\Get-AzWorkloadsSapVirtualInstance_Get -Name $Name -ResourceGroupName $ResourceGroupName -SubscriptionId $SubscriptionId @EnvPSBoundParameters
226+
}
227+
elseif (('UpdateViaIdentityExpanded') -contains $parameterSet) {
228+
$SapVirtualInstanceObj = Az.SapVirtualInstance.private\Get-AzWorkloadsSapVirtualInstance_GetViaIdentity -InputObject $InputObject @EnvPSBoundParameters
229+
}
230+
if ($null -eq $SapVirtualInstanceObj) {
231+
throw "$Name doesn't exist"
232+
}
233+
234+
# If user input UserAssignedIdentity
235+
if ($PSBoundParameters.ContainsKey('UserAssignedIdentity')) {
236+
$userIdentityObject = [Microsoft.Azure.PowerShell.Cmdlets.Workloads.SapVirtualInstance.Models.UserAssignedIdentity]::New()
237+
$PSBoundParameters.IdentityUserAssignedIdentity = @{}
238+
foreach ($item in $PSBoundParameters.UserAssignedIdentity) {
239+
$PSBoundParameters.IdentityUserAssignedIdentity.Add($item, $userIdentityObject )
240+
}
241+
242+
if ($SapVirtualInstanceObj.IdentityUserAssignedIdentity.Count -gt 0) {
243+
$SapVirtualInstanceObj.IdentityUserAssignedIdentity.Keys | ForEach-Object {
244+
if (-NOT($_ -in $UserAssignedIdentity)) {
245+
$PSBoundParameters.IdentityUserAssignedIdentity.Add($_, $null)
246+
}
247+
}
248+
}
249+
}
250+
251+
# calculate IdentityType
252+
$supportsSystemAssignedIdentity = $EnableSystemAssignedIdentity -or (($null -eq $EnableSystemAssignedIdentity) -and ($SapVirtualInstanceObj.IdentityType.Contains('SystemAssigned')))
253+
$supportsUserAssignedIdentity = ($PSBoundParameters.ContainsKey('UserAssignedIdentity') -and $UserAssignedIdentity.Length -gt 0) -or ((-not $PSBoundParameters.ContainsKey('UserAssignedIdentity')) -and ($SapVirtualInstanceObj.IdentityType.Contains('UserAssigned')));
254+
if (($supportsSystemAssignedIdentity -and $supportsUserAssignedIdentity)) {
255+
$PSBoundParameters.Add("IdentityType", "SystemAssigned,UserAssigned")
256+
}
257+
elseif ($supportsUserAssignedIdentity -and (-not $supportsSystemAssignedIdentity)) {
258+
$PSBoundParameters.Add("IdentityType", "UserAssigned")
259+
}
260+
elseif ((-not $supportsUserAssignedIdentity) -and $supportsSystemAssignedIdentity) {
261+
$PSBoundParameters.Add("IdentityType", "SystemAssigned")
262+
}
263+
else {
264+
$PSBoundParameters.Add("IdentityType", "None")
265+
}
266+
267+
# remove EnableSystemAssignedIdentity
268+
if ($PSBoundParameters.ContainsKey('EnableSystemAssignedIdentity')) {
269+
$null = $PSBoundParameters.Remove("EnableSystemAssignedIdentity")
270+
}
271+
# remove UserAssignedIdentity
272+
if ($PSBoundParameters.ContainsKey('UserAssignedIdentity')) {
273+
$null = $PSBoundParameters.Remove('UserAssignedIdentity')
274+
}
275+
}
276+
Az.SapVirtualInstance.internal\Update-AzWorkloadsSapVirtualInstance @PSBoundParameters
277+
}
278+
}

0 commit comments

Comments
 (0)