diff --git a/src/ResourceManager/Compute/Commands.Compute.Test/ScenarioTests/VirtualMachineScaleSetTests.ps1 b/src/ResourceManager/Compute/Commands.Compute.Test/ScenarioTests/VirtualMachineScaleSetTests.ps1 index e17aa4e9dc5e..0e55fd7cfcd6 100644 --- a/src/ResourceManager/Compute/Commands.Compute.Test/ScenarioTests/VirtualMachineScaleSetTests.ps1 +++ b/src/ResourceManager/Compute/Commands.Compute.Test/ScenarioTests/VirtualMachineScaleSetTests.ps1 @@ -28,11 +28,8 @@ Add-AzureRmVmssNetworkInterfaceConfiguration 1.2.3 AzureRM.Compute Add-AzureRmVmssPublicKey 1.2.3 AzureRM.Compute Add-AzureRmVmssSecret 1.2.3 AzureRM.Compute Get-AzureRmVmss 1.2.3 AzureRM.Compute -Get-AzureRmVmssAllList 1.2.3 AzureRM.Compute -Get-AzureRmVmssList 1.2.3 AzureRM.Compute Get-AzureRmVmssSkusList 1.2.3 AzureRM.Compute Get-AzureRmVmssVM 1.2.3 AzureRM.Compute -Get-AzureRmVmssVMList 1.2.3 AzureRM.Compute New-AzureRmVmss 1.2.3 AzureRM.Compute New-AzureRmVmssConfig 1.2.3 AzureRM.Compute New-AzureRmVmssIpConfigurationConfig 1.2.3 AzureRM.Compute @@ -124,15 +121,15 @@ function Test-VirtualMachineScaleSet $argList = New-AzureComputeArgumentList -MethodName VirtualMachineScaleSetsListAll; $args = ($argList | select -ExpandProperty Value); - $vmssList = Get-AzureRmVmssAllList; + $vmssList = Get-AzureRmVmss; Assert-True { ($vmssList | select -ExpandProperty Name) -contains $vmssName }; $output = $vmssList | Out-String; Write-Verbose ($output); Assert-True { $output.Contains("VirtualMachineProfile") }; # List from RG - Write-Verbose ('Running Command : ' + 'Get-AzureRmVmssList'); - $vmssList = Get-AzureRmVmssList -ResourceGroupName $rgname; + Write-Verbose ('Running Command : ' + 'Get-AzureRmVmss List'); + $vmssList = Get-AzureRmVmss -ResourceGroupName $rgname; Assert-True { ($vmssList | select -ExpandProperty Name) -contains $vmssName }; $output = $vmssList | Out-String; Write-Verbose ($output); @@ -146,13 +143,13 @@ function Test-VirtualMachineScaleSet Assert-True { $output.Contains("Sku") }; # List All VMs - Write-Verbose ('Running Command : ' + 'Get-AzureRmVmssVMList'); + Write-Verbose ('Running Command : ' + 'Get-AzureRmVmssVM List'); $argList = New-AzureComputeArgumentList -MethodName VirtualMachineScaleSetVMsList; $argList[0].Value = $rgname; $argList[1].Value = $vmssName; $args = ($argList | select -ExpandProperty Value); - $vmListResult = Get-AzureRmVmssVMList -ResourceGroupName $rgname -VirtualMachineScaleSetName $vmssName -Select $null; + $vmListResult = Get-AzureRmVmssVM -ResourceGroupName $rgname -VMScaleSetName $vmssName; # -Select $null; $output = $vmListResult | Out-String; Write-Verbose ($output); Assert-True { $output.Contains("StorageProfile") }; diff --git a/src/ResourceManager/Compute/Commands.Compute/Generated/InvokeAzureComputeMethodCmdlet.cs b/src/ResourceManager/Compute/Commands.Compute/Generated/InvokeAzureComputeMethodCmdlet.cs index bb7e0393a7f0..8c6b625e841e 100644 --- a/src/ResourceManager/Compute/Commands.Compute/Generated/InvokeAzureComputeMethodCmdlet.cs +++ b/src/ResourceManager/Compute/Commands.Compute/Generated/InvokeAzureComputeMethodCmdlet.cs @@ -97,7 +97,7 @@ protected override void ProcessRecord() base.ProcessRecord(); ExecuteClientAction(() => { - if (ParameterSetName == "InvokeByDynamicParameters" || ParameterSetName == "InvokeByDynamicParametersForFriendMethod") + if (ParameterSetName.StartsWith("InvokeByDynamicParameters")) { argumentList = ConvertDynamicParameters(dynamicParameters); } diff --git a/src/ResourceManager/Compute/Commands.Compute/Generated/VirtualMachineScaleSet/VirtualMachineScaleSetGetMethod.cs b/src/ResourceManager/Compute/Commands.Compute/Generated/VirtualMachineScaleSet/VirtualMachineScaleSetGetMethod.cs index cda400121c0d..bd2228331e87 100644 --- a/src/ResourceManager/Compute/Commands.Compute/Generated/VirtualMachineScaleSet/VirtualMachineScaleSetGetMethod.cs +++ b/src/ResourceManager/Compute/Commands.Compute/Generated/VirtualMachineScaleSet/VirtualMachineScaleSetGetMethod.cs @@ -79,9 +79,23 @@ protected void ExecuteVirtualMachineScaleSetGetMethod(object[] invokeMethodInput string resourceGroupName = (string)ParseParameter(invokeMethodInputParameters[0]); string vmScaleSetName = (string)ParseParameter(invokeMethodInputParameters[1]); - var result = VirtualMachineScaleSetsClient.Get(resourceGroupName, vmScaleSetName); - WriteObject(result); + if (!string.IsNullOrEmpty(resourceGroupName) && !string.IsNullOrEmpty(vmScaleSetName)) + { + var result = VirtualMachineScaleSetsClient.Get(resourceGroupName, vmScaleSetName); + WriteObject(result); + } + else if (!string.IsNullOrEmpty(resourceGroupName)) + { + var result = VirtualMachineScaleSetsClient.List(resourceGroupName); + WriteObject(result); + } + else + { + var result = VirtualMachineScaleSetsClient.ListAll(); + WriteObject(result); + } } + } public partial class NewAzureComputeArgumentListCmdlet : ComputeAutomationBaseCmdlet diff --git a/src/ResourceManager/Compute/Commands.Compute/Generated/VirtualMachineScaleSet/VirtualMachineScaleSetListAllMethod.cs b/src/ResourceManager/Compute/Commands.Compute/Generated/VirtualMachineScaleSet/VirtualMachineScaleSetListAllMethod.cs index 80a0c0218f27..b09955ecbd7d 100644 --- a/src/ResourceManager/Compute/Commands.Compute/Generated/VirtualMachineScaleSet/VirtualMachineScaleSetListAllMethod.cs +++ b/src/ResourceManager/Compute/Commands.Compute/Generated/VirtualMachineScaleSet/VirtualMachineScaleSetListAllMethod.cs @@ -76,38 +76,4 @@ protected PSArgument[] CreateVirtualMachineScaleSetListAllParameters() return ConvertFromObjectsToArguments(new string[0], new object[0]); } } - - [Cmdlet("Get", "AzureRmVmssAllList", DefaultParameterSetName = "InvokeByDynamicParameters")] - public partial class GetAzureRmVMSSAllList : InvokeAzureComputeMethodCmdlet - { - public GetAzureRmVMSSAllList() - { - } - - public override string MethodName { get; set; } - - protected override void ProcessRecord() - { - this.MethodName = "VirtualMachineScaleSetListAll"; - base.ProcessRecord(); - } - - public override object GetDynamicParameters() - { - dynamicParameters = new RuntimeDefinedParameterDictionary(); - var pArgumentList = new RuntimeDefinedParameter(); - pArgumentList.Name = "ArgumentList"; - pArgumentList.ParameterType = typeof(object[]); - pArgumentList.Attributes.Add(new ParameterAttribute - { - ParameterSetName = "InvokeByStaticParameters", - Position = 1, - Mandatory = true - }); - pArgumentList.Attributes.Add(new AllowNullAttribute()); - dynamicParameters.Add("ArgumentList", pArgumentList); - - return dynamicParameters; - } - } } diff --git a/src/ResourceManager/Compute/Commands.Compute/Generated/VirtualMachineScaleSet/VirtualMachineScaleSetListMethod.cs b/src/ResourceManager/Compute/Commands.Compute/Generated/VirtualMachineScaleSet/VirtualMachineScaleSetListMethod.cs index fe4268417443..2b1049921b6a 100644 --- a/src/ResourceManager/Compute/Commands.Compute/Generated/VirtualMachineScaleSet/VirtualMachineScaleSetListMethod.cs +++ b/src/ResourceManager/Compute/Commands.Compute/Generated/VirtualMachineScaleSet/VirtualMachineScaleSetListMethod.cs @@ -93,50 +93,4 @@ protected PSArgument[] CreateVirtualMachineScaleSetListParameters() new object[] { resourceGroupName }); } } - - [Cmdlet("Get", "AzureRmVmssList", DefaultParameterSetName = "InvokeByDynamicParameters")] - public partial class GetAzureRmVMSSList : InvokeAzureComputeMethodCmdlet - { - public GetAzureRmVMSSList() - { - } - - public override string MethodName { get; set; } - - protected override void ProcessRecord() - { - this.MethodName = "VirtualMachineScaleSetList"; - base.ProcessRecord(); - } - - public override object GetDynamicParameters() - { - dynamicParameters = new RuntimeDefinedParameterDictionary(); - var pResourceGroupName = new RuntimeDefinedParameter(); - pResourceGroupName.Name = "ResourceGroupName"; - pResourceGroupName.ParameterType = typeof(string); - pResourceGroupName.Attributes.Add(new ParameterAttribute - { - ParameterSetName = "InvokeByDynamicParameters", - Position = 1, - Mandatory = false - }); - pResourceGroupName.Attributes.Add(new AllowNullAttribute()); - dynamicParameters.Add("ResourceGroupName", pResourceGroupName); - - var pArgumentList = new RuntimeDefinedParameter(); - pArgumentList.Name = "ArgumentList"; - pArgumentList.ParameterType = typeof(object[]); - pArgumentList.Attributes.Add(new ParameterAttribute - { - ParameterSetName = "InvokeByStaticParameters", - Position = 2, - Mandatory = true - }); - pArgumentList.Attributes.Add(new AllowNullAttribute()); - dynamicParameters.Add("ArgumentList", pArgumentList); - - return dynamicParameters; - } - } } diff --git a/src/ResourceManager/Compute/Commands.Compute/Generated/VirtualMachineScaleSetVM/VirtualMachineScaleSetVMGetMethod.cs b/src/ResourceManager/Compute/Commands.Compute/Generated/VirtualMachineScaleSetVM/VirtualMachineScaleSetVMGetMethod.cs index 9ed0bf88a581..315f1a5a264b 100644 --- a/src/ResourceManager/Compute/Commands.Compute/Generated/VirtualMachineScaleSetVM/VirtualMachineScaleSetVMGetMethod.cs +++ b/src/ResourceManager/Compute/Commands.Compute/Generated/VirtualMachineScaleSetVM/VirtualMachineScaleSetVMGetMethod.cs @@ -92,9 +92,18 @@ protected void ExecuteVirtualMachineScaleSetVMGetMethod(object[] invokeMethodInp string vmScaleSetName = (string)ParseParameter(invokeMethodInputParameters[1]); string instanceId = (string)ParseParameter(invokeMethodInputParameters[2]); - var result = VirtualMachineScaleSetVMsClient.Get(resourceGroupName, vmScaleSetName, instanceId); - WriteObject(result); + if (!string.IsNullOrEmpty(resourceGroupName) && !string.IsNullOrEmpty(vmScaleSetName) && !string.IsNullOrEmpty(instanceId)) + { + var result = VirtualMachineScaleSetVMsClient.Get(resourceGroupName, vmScaleSetName, instanceId); + WriteObject(result); + } + else if (!string.IsNullOrEmpty(resourceGroupName) && !string.IsNullOrEmpty(vmScaleSetName)) + { + var result = VirtualMachineScaleSetVMsClient.List(resourceGroupName, vmScaleSetName); + WriteObject(result); + } } + } public partial class NewAzureComputeArgumentListCmdlet : ComputeAutomationBaseCmdlet diff --git a/src/ResourceManager/Compute/Commands.Compute/Generated/VirtualMachineScaleSetVM/VirtualMachineScaleSetVMListMethod.cs b/src/ResourceManager/Compute/Commands.Compute/Generated/VirtualMachineScaleSetVM/VirtualMachineScaleSetVMListMethod.cs index 2e86f991718c..f5fe0b35ece9 100644 --- a/src/ResourceManager/Compute/Commands.Compute/Generated/VirtualMachineScaleSetVM/VirtualMachineScaleSetVMListMethod.cs +++ b/src/ResourceManager/Compute/Commands.Compute/Generated/VirtualMachineScaleSetVM/VirtualMachineScaleSetVMListMethod.cs @@ -123,74 +123,4 @@ protected PSArgument[] CreateVirtualMachineScaleSetVMListParameters() new object[] { resourceGroupName, virtualMachineScaleSetName, odataQuery, select }); } } - - [Cmdlet("Get", "AzureRmVmssVMList", DefaultParameterSetName = "InvokeByDynamicParameters")] - public partial class GetAzureRmVMSSVMList : InvokeAzureComputeMethodCmdlet - { - public GetAzureRmVMSSVMList() - { - } - - public override string MethodName { get; set; } - - protected override void ProcessRecord() - { - this.MethodName = "VirtualMachineScaleSetVMList"; - base.ProcessRecord(); - } - - public override object GetDynamicParameters() - { - dynamicParameters = new RuntimeDefinedParameterDictionary(); - var pResourceGroupName = new RuntimeDefinedParameter(); - pResourceGroupName.Name = "ResourceGroupName"; - pResourceGroupName.ParameterType = typeof(string); - pResourceGroupName.Attributes.Add(new ParameterAttribute - { - ParameterSetName = "InvokeByDynamicParameters", - Position = 1, - Mandatory = false - }); - pResourceGroupName.Attributes.Add(new AllowNullAttribute()); - dynamicParameters.Add("ResourceGroupName", pResourceGroupName); - - var pVirtualMachineScaleSetName = new RuntimeDefinedParameter(); - pVirtualMachineScaleSetName.Name = "VirtualMachineScaleSetName"; - pVirtualMachineScaleSetName.ParameterType = typeof(string); - pVirtualMachineScaleSetName.Attributes.Add(new ParameterAttribute - { - ParameterSetName = "InvokeByDynamicParameters", - Position = 2, - Mandatory = false - }); - pVirtualMachineScaleSetName.Attributes.Add(new AllowNullAttribute()); - dynamicParameters.Add("VirtualMachineScaleSetName", pVirtualMachineScaleSetName); - - var pSelect = new RuntimeDefinedParameter(); - pSelect.Name = "Select"; - pSelect.ParameterType = typeof(string); - pSelect.Attributes.Add(new ParameterAttribute - { - ParameterSetName = "InvokeByDynamicParameters", - Position = 3, - Mandatory = false - }); - pSelect.Attributes.Add(new AllowNullAttribute()); - dynamicParameters.Add("Select", pSelect); - - var pArgumentList = new RuntimeDefinedParameter(); - pArgumentList.Name = "ArgumentList"; - pArgumentList.ParameterType = typeof(object[]); - pArgumentList.Attributes.Add(new ParameterAttribute - { - ParameterSetName = "InvokeByStaticParameters", - Position = 4, - Mandatory = true - }); - pArgumentList.Attributes.Add(new AllowNullAttribute()); - dynamicParameters.Add("ArgumentList", pArgumentList); - - return dynamicParameters; - } - } } diff --git a/src/ServiceManagement/Compute/Commands.ServiceManagement.Preview/Automation/Generate-FunctionCommand.ps1 b/src/ServiceManagement/Compute/Commands.ServiceManagement.Preview/Automation/Generate-FunctionCommand.ps1 index 77e5b46f4892..e7686f0e6f20 100644 --- a/src/ServiceManagement/Compute/Commands.ServiceManagement.Preview/Automation/Generate-FunctionCommand.ps1 +++ b/src/ServiceManagement/Compute/Commands.ServiceManagement.Preview/Automation/Generate-FunctionCommand.ps1 @@ -34,7 +34,13 @@ param [System.Reflection.MethodInfo]$FriendMethodInfo = $null, [Parameter(Mandatory = $false)] - [System.Reflection.MethodInfo]$PageMethodInfo = $null + [System.Reflection.MethodInfo]$PageMethodInfo = $null, + + [Parameter(Mandatory = $false)] + [bool]$CombineGetAndList = $false, + + [Parameter(Mandatory = $false)] + [bool]$CombineGetAndListAll = $false ) . "$PSScriptRoot\Import-StringFunction.ps1"; @@ -167,8 +173,8 @@ function Get-InvokeMethodCmdletCode # 2. Iterate through Param List $methodParamList = $MethodInfo.GetParameters(); - $paramNameList = @(); - $paramLocalNameList = @(); + [System.Collections.ArrayList]$paramNameList = @(); + [System.Collections.ArrayList]$paramLocalNameList = @(); [System.Collections.ArrayList]$pruned_params = @(); foreach ($methodParam in $methodParamList) { @@ -195,7 +201,7 @@ function Get-InvokeMethodCmdletCode } } - $invoke_params_join_str = [string]::Join(', ', $paramLocalNameList); + $invoke_params_join_str = [string]::Join(', ', $paramLocalNameList.ToArray()); # 2.1 Dynamic Parameter Assignment $dynamic_param_assignment_code_lines = @(); @@ -425,6 +431,63 @@ ${invoke_local_param_code_content} } "@; } + elseif ($methodName -eq 'Get' -and $ModelClassNameSpace -like "*.Azure.Management.*Model*") + { + # Only for ARM Cmdlets + [System.Collections.ArrayList]$paramLocalNameList2 = @(); + for ($i2 = 0; $i2 -lt $paramLocalNameList.Count - 1; $i2++) + { + $item2 = $paramLocalNameList[$i2]; + $paramLocalNameList2 += $item2; + } + $invoke_cmdlt_source_template = " protected void Execute${invoke_param_set_name}Method(object[] ${invoke_input_params_name})" + $NEW_LINE; + $invoke_cmdlt_source_template += " {" + $NEW_LINE; + $invoke_cmdlt_source_template += "${invoke_local_param_code_content}" + $NEW_LINE; + $invoke_cmdlt_source_template += " if (" + for ($i2 = 0; $i2 -lt $paramLocalNameList.Count; $i2++) + { + if ($i2 -gt 0) + { + $invoke_cmdlt_source_template += " && "; + } + $invoke_cmdlt_source_template += "!string.IsNullOrEmpty(" + $paramLocalNameList[$i2] + ")" + } + $invoke_cmdlt_source_template += ")" + $NEW_LINE; + $invoke_cmdlt_source_template += " {" + $NEW_LINE; + $invoke_cmdlt_source_template += " var result = ${OperationName}Client.${methodName}(${invoke_params_join_str});" + $NEW_LINE; + $invoke_cmdlt_source_template += " WriteObject(result);" + $NEW_LINE; + $invoke_cmdlt_source_template += " }" + $NEW_LINE; + + if ($CombineGetAndList) + { + $invoke_params_join_str_for_list = [string]::Join(', ', $paramLocalNameList2.ToArray()); + $invoke_cmdlt_source_template += " else if (" + for ($i2 = 0; $i2 -lt $paramLocalNameList2.Count; $i2++) + { + if ($i2 -gt 0) + { + $invoke_cmdlt_source_template += " && "; + } + $invoke_cmdlt_source_template += "!string.IsNullOrEmpty(" + $paramLocalNameList2[$i2] + ")" + } + $invoke_cmdlt_source_template += ")" + $NEW_LINE; + $invoke_cmdlt_source_template += " {" + $NEW_LINE; + $invoke_cmdlt_source_template += " var result = ${OperationName}Client.List(${invoke_params_join_str_for_list});" + $NEW_LINE; + $invoke_cmdlt_source_template += " WriteObject(result);" + $NEW_LINE; + $invoke_cmdlt_source_template += " }" + $NEW_LINE; + } + + if ($CombineGetAndListAll) + { + $invoke_cmdlt_source_template += " else" + $NEW_LINE; + $invoke_cmdlt_source_template += " {" + $NEW_LINE; + $invoke_cmdlt_source_template += " var result = ${OperationName}Client.ListAll();" + $NEW_LINE; + $invoke_cmdlt_source_template += " WriteObject(result);" + $NEW_LINE; + $invoke_cmdlt_source_template += " }" + $NEW_LINE; + } + + $invoke_cmdlt_source_template += " }" + $NEW_LINE; + } else { $invoke_cmdlt_source_template = diff --git a/src/ServiceManagement/Compute/Commands.ServiceManagement.Preview/Automation/Import-CommonVariables.ps1 b/src/ServiceManagement/Compute/Commands.ServiceManagement.Preview/Automation/Import-CommonVariables.ps1 index 56db246774b2..98d9fdd6b8f5 100644 --- a/src/ServiceManagement/Compute/Commands.ServiceManagement.Preview/Automation/Import-CommonVariables.ps1 +++ b/src/ServiceManagement/Compute/Commands.ServiceManagement.Preview/Automation/Import-CommonVariables.ps1 @@ -79,7 +79,7 @@ $component_name = $client_library_namespace.Substring($client_library_namespace. $all_return_type_names = @(); -$SKIP_VERB_NOUN_CMDLET_LIST = @('PowerOff', 'ListNext', 'ListAllNext', 'ListSkusNext', 'GetInstanceView'); +$SKIP_VERB_NOUN_CMDLET_LIST = @('PowerOff', 'ListNext', 'ListAllNext', 'ListSkusNext', 'GetInstanceView', 'List', 'ListAll'); Write-Verbose $BAR_LINE; Write-Verbose "Input Parameters:"; diff --git a/src/ServiceManagement/Compute/Commands.ServiceManagement.Preview/Automation/Import-TypeFunction.ps1 b/src/ServiceManagement/Compute/Commands.ServiceManagement.Preview/Automation/Import-TypeFunction.ps1 index dbfe756198d2..697358d3aa02 100644 --- a/src/ServiceManagement/Compute/Commands.ServiceManagement.Preview/Automation/Import-TypeFunction.ps1 +++ b/src/ServiceManagement/Compute/Commands.ServiceManagement.Preview/Automation/Import-TypeFunction.ps1 @@ -781,4 +781,37 @@ function CheckIf-ListAndPageMethods } return $false; +} + +# Function Friend Finder +function Find-MatchedMethod +{ + param + ( + [Parameter(Mandatory = $true)] + [string]$searchName, + + [Parameter(Mandatory = $true)] + [System.Reflection.MethodInfo[]]$methodList, + + [Parameter(Mandatory = $false)] + [System.Reflection.MethodInfo]$paramMatchedMethodInfo + ) + + foreach ($methodInfo in $methodList) + { + if ($methodInfo.Name -eq $searchName) + { + if ($paramMatchedMethodInfo -eq $null) + { + return $methodInfo; + } + elseif (CheckIf-SameParameterList $methodInfo $paramMatchedMethodInfo) + { + return $methodInfo; + } + } + } + + return $null; } \ No newline at end of file diff --git a/src/ServiceManagement/Compute/Commands.ServiceManagement.Preview/Automation/RunCodeGeneration.ps1 b/src/ServiceManagement/Compute/Commands.ServiceManagement.Preview/Automation/RunCodeGeneration.ps1 index e3081e54c9c3..e46205330345 100644 --- a/src/ServiceManagement/Compute/Commands.ServiceManagement.Preview/Automation/RunCodeGeneration.ps1 +++ b/src/ServiceManagement/Compute/Commands.ServiceManagement.Preview/Automation/RunCodeGeneration.ps1 @@ -338,7 +338,7 @@ $validate_all_method_names_code base.ProcessRecord(); ExecuteClientAction(() => { - if (ParameterSetName == `"$dynamic_param_set_name`" || ParameterSetName == `"${dynamic_param_set_name}ForFriendMethod`") + if (ParameterSetName.StartsWith(`"$dynamic_param_set_name`")) { argumentList = ConvertDynamicParameters(dynamicParameters); } @@ -1196,34 +1196,30 @@ else # Handle Friend Methods if (-not $friendMethodDict.ContainsKey($mtItem.Name)) { + $searchName = $null; + $matchedMethodInfo = $null; if ($mtItem.Name -eq 'Deallocate') { - $methods2 = Get-OperationMethods $operation_type; - foreach ($friendMethodInfo in $methods2) - { - if ($friendMethodInfo.Name -eq 'PowerOff') - { - if (CheckIf-SameParameterList $methodInfo $friendMethodInfo) - { - $friendMethodDict.Add($mtItem.Name, $friendMethodInfo); - break; - } - } - } + $searchName = 'PowerOff'; + $matchedMethodInfo = $methodInfo; } elseif ($mtItem.Name -eq 'Get') + { + $searchName = 'GetInstanceView'; + $matchedMethodInfo = $methodInfo; + } + elseif ($mtItem.Name -eq 'List') + { + $searchName = 'ListAll'; + } + + if ($searchName -ne $null) { $methods2 = Get-OperationMethods $operation_type; - foreach ($friendMethodInfo in $methods2) + $foundMethod = Find-MatchedMethod $searchName $methods2 $matchedMethodInfo; + if ($foundMethod -ne $null) { - if ($friendMethodInfo.Name -eq 'GetInstanceView') - { - if (CheckIf-SameParameterList $methodInfo $friendMethodInfo) - { - $friendMethodDict.Add($mtItem.Name, $friendMethodInfo); - break; - } - } + $friendMethodDict.Add($mtItem.Name, $foundMethod); } } } @@ -1232,17 +1228,8 @@ else if ($mtItem.Name -like 'List*' -and (-not $pageMethodDict.ContainsKey($mtItem.Name))) { $methods2 = Get-OperationMethods $operation_type; - foreach ($pageMethodInfo in $methods2) - { - if ($pageMethodInfo.Name -eq ($mtItem.Name + 'Next')) - { - if (CheckIf-ListAndPageMethods $methodInfo $pageMethodInfo) - { - $pageMethodDict.Add($mtItem.Name, $pageMethodInfo); - break; - } - } - } + $foundMethod = Find-MatchedMethod ($mtItem.Name + 'Next') $methods2; + $pageMethodDict.Add($mtItem.Name, $foundMethod); } } @@ -1277,6 +1264,26 @@ else { $pageMethodMessage = 'Page=' + ($pageMethodInfo.Name.Replace('Async', '')) + ''; } + + # Combine Get and List/ListAll Methods (if any) + $combineGetAndList = $false; + $combineGetAndListAll = $false; + if ($mtItem.Name -eq 'Get') + { + $methods3 = Get-OperationMethods $operation_type; + $foundMethod1 = Find-MatchedMethod 'List' $methods3; + $foundMethod2 = Find-MatchedMethod 'ListAll' $methods3; + + if ($foundMethod1 -ne $null) + { + $combineGetAndList = $true; + } + + if ($foundMethod2 -ne $null) + { + $combineGetAndListAll = $true; + } + } # Output Info for Method Signature Write-Verbose ""; @@ -1323,7 +1330,9 @@ else -FileOutputFolder $opOutFolder ` -FunctionCmdletFlavor $opCmdletFlavor ` -FriendMethodInfo $friendMethodInfo ` - -PageMethodInfo $pageMethodInfo); + -PageMethodInfo $pageMethodInfo ` + -CombineGetAndList $combineGetAndList ` + -CombineGetAndListAll $combineGetAndListAll ); if ($outputs.Count -ne $null) { diff --git a/src/ServiceManagement/Compute/Commands.ServiceManagement.Preview/Generated/InvokeAzureComputeMethodCmdlet.cs b/src/ServiceManagement/Compute/Commands.ServiceManagement.Preview/Generated/InvokeAzureComputeMethodCmdlet.cs index b8bec0291796..3a2b5936319d 100644 --- a/src/ServiceManagement/Compute/Commands.ServiceManagement.Preview/Generated/InvokeAzureComputeMethodCmdlet.cs +++ b/src/ServiceManagement/Compute/Commands.ServiceManagement.Preview/Generated/InvokeAzureComputeMethodCmdlet.cs @@ -172,7 +172,7 @@ protected override void ProcessRecord() base.ProcessRecord(); ExecuteClientAction(() => { - if (ParameterSetName == "InvokeByDynamicParameters" || ParameterSetName == "InvokeByDynamicParametersForFriendMethod") + if (ParameterSetName.StartsWith("InvokeByDynamicParameters")) { argumentList = ConvertDynamicParameters(dynamicParameters); }