Skip to content

Commit d9f62c2

Browse files
committed
Update
1 parent 0062307 commit d9f62c2

File tree

7 files changed

+1273
-1092
lines changed

7 files changed

+1273
-1092
lines changed

src/ResourceManager/Compute/Commands.Compute/Generated/cli.js

Lines changed: 300 additions & 258 deletions
Large diffs are not rendered by default.

src/ServiceManagement/Compute/Commands.ServiceManagement.Preview/Automation/Create-ParameterTree.ps1

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ function New-ParameterTreeNode
3939
$node | Add-Member -Type NoteProperty -Name OnlySimple -Value $false;
4040
$node | Add-Member -Type NoteProperty -Name Properties -Value @();
4141
$node | Add-Member -Type NoteProperty -Name SubNodes -Value @();
42+
$node | Add-Member -Type NoteProperty -Name IsPrimitive -Value $false;
4243

4344
return $node;
4445
}
@@ -65,7 +66,8 @@ function Create-ParameterTreeImpl
6566
}
6667
elseif (-not $TypeInfo.FullName.StartsWith($NameSpace + "."))
6768
{
68-
return New-ParameterTreeNode $ParameterName $TypeInfo $Parent;
69+
$node = New-ParameterTreeNode $ParameterName $TypeInfo $Parent;
70+
return $node;
6971
}
7072
else
7173
{
@@ -131,6 +133,12 @@ function Create-ParameterTreeImpl
131133
}
132134
else
133135
{
136+
if ($nodeProp["Type"].IsEquivalentTo([System.Nullable[long]]) -or
137+
$nodeProp["Type"].IsEquivalentTo([System.Nullable[bool]]))
138+
{
139+
$nodeProp["IsPrimitive"] = $true;
140+
}
141+
134142
# Primitive Type, e.g. int, string, Dictionary<string, string>, etc.
135143
Write-Verbose ($padding + '-' + $nodeProp["Name"] + " : " + $nodeProp["Type"]);
136144
}

src/ServiceManagement/Compute/Commands.ServiceManagement.Preview/Automation/Generate-FunctionCommand.ps1

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,6 @@ param(
3737
. "$PSScriptRoot\StringProcessingHelper.ps1";
3838
. "$PSScriptRoot\ParameterTypeHelper.ps1";
3939

40-
$CLI_HELP_MSG = " There are two sets of commands:\r\n" `
41-
+ " 1) function commands that are used to manage Azure resources in the cloud, and \r\n" `
42-
+ " 2) parameter commands that generate & edit input files for the other set of commands.\r\n" `
43-
+ " For example, \'vmss get/list/stop\' are the function commands that call get, list and stop operations of \r\n" `
44-
+ " virtual machine scale set, whereas \'vmss create-or-update-parameters generate/set/remove/add\' commands \r\n" `
45-
+ " are used to configure the input parameter file. The \'vmss create-or-update\' command takes a parameter \r\n" `
46-
+ " file as for the VM scale set configuration, and creates it online.";
47-
4840
function Generate-CliFunctionCommandImpl
4941
{
5042
param(
@@ -286,8 +278,12 @@ function Generate-CliFunctionCommandImpl
286278
{
287279
$code += " var ${cli_param_name}ValArr = ${cli_param_name}.split(',');" + $NEW_LINE;
288280
$code += " cli.output.verbose(`'${cli_param_name}ValArr : `' + ${cli_param_name}ValArr);" + $NEW_LINE;
289-
$code += " ${cli_param_name}Obj = {};" + $NEW_LINE;
290-
$code += " ${cli_param_name}Obj.instanceIDs = ${cli_param_name}ValArr;" + $NEW_LINE;
281+
#$code += " ${cli_param_name}Obj = {};" + $NEW_LINE;
282+
#$code += " ${cli_param_name}Obj.instanceIDs = ${cli_param_name}ValArr;" + $NEW_LINE;
283+
$code += " ${cli_param_name}Obj = [];" + $NEW_LINE;
284+
$code += " for (var item in ${cli_param_name}ValArr) {" + $NEW_LINE;
285+
$code += " ${cli_param_name}Obj.push(item);" + $NEW_LINE;
286+
$code += " }" + $NEW_LINE;
291287
}
292288
else
293289
{
@@ -307,7 +303,7 @@ function Generate-CliFunctionCommandImpl
307303
}
308304
else
309305
{
310-
$code += " var computeManagementClient = utils.createComputeResourceProviderClient(subscription);" + $NEW_LINE;
306+
$code += " var computeManagementClient = utils.createComputeManagementClient(subscription);" + $NEW_LINE;
311307
}
312308

313309
if ($cliMethodName -eq 'delete')
@@ -319,7 +315,7 @@ function Generate-CliFunctionCommandImpl
319315
$cliMethodFuncName = $cliMethodName;
320316
}
321317

322-
$code += " var result = computeManagementClient.${cliOperationName}s.${cliMethodFuncName}(";
318+
$code += " var result = computeManagementClient.${cliOperationName}.${cliMethodFuncName}(";
323319

324320
for ($index = 0; $index -lt $methodParamNameList.Count; $index++)
325321
{

src/ServiceManagement/Compute/Commands.ServiceManagement.Preview/Automation/Generate-ParameterCommand.ps1

Lines changed: 35 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,14 @@ param(
4040
$NEW_LINE = "`r`n";
4141
. "$PSScriptRoot\StringProcessingHelper.ps1";
4242

43+
$CLI_HELP_MSG = " There are two sets of commands:\r\n" `
44+
+ " 1) function commands that are used to manage Azure resources in the cloud, and \r\n" `
45+
+ " 2) parameter commands that generate & edit input files for the other set of commands.\r\n" `
46+
+ " For example, \'vmss get/list/stop\' are the function commands that call get, list and stop operations of \r\n" `
47+
+ " virtual machine scale set, whereas \'vmss create-or-update-parameters * generate/set/remove/add\' commands \r\n" `
48+
+ " are used to configure the input parameter file. The \'vmss create-or-update\' command takes a parameter \r\n" `
49+
+ " file as for the VM scale set configuration, and creates it online.";
50+
4351
function Get-ParameterCommandCategoryDescription
4452
{
4553
param
@@ -91,10 +99,11 @@ function Generate-CliParameterCommandImpl
9199
{
92100
[string]$nodeName = Get-CliNormalizedName $parentNode.Name.Trim();
93101
[string]$pathName = $nodeName;
94-
if ($pathName.ToLower().StartsWith('ip'))
95-
{
96-
$pathName = 'iP' + $pathName.Substring(2);
97-
}
102+
# Skip this for AutoRest, as the parameter names are always matched.
103+
# if ($pathName.ToLower().StartsWith('ip'))
104+
# {
105+
# $pathName = 'iP' + $pathName.Substring(2);
106+
# }
98107

99108
if ($parentNode.Parent -ne $null)
100109
{
@@ -147,10 +156,13 @@ function Generate-CliParameterCommandImpl
147156
}
148157
else
149158
{
150-
$sampleJsonText = "{\r\n ...\r\n";
151-
$sampleJsonText += " `"" + (Get-CliNormalizedName $TreeNode.Name) + "`" : ";
152-
$sampleJsonText += ($paramObjText.Replace("`r`n", "\r\n ")) + "\r\n";
153-
$sampleJsonText += " ...\r\n}\r\n";
159+
$padding = " ";
160+
$sampleJsonText = $padding + "{\r\n";
161+
$sampleJsonText += $padding + " ...\r\n";
162+
$sampleJsonText += $padding + " `"" + (Get-CliNormalizedName $TreeNode.Name) + "`" : ";
163+
$sampleJsonText += ($paramObjText.Replace("`r`n", "\r\n" + $padding + " ")) + "\r\n";
164+
$sampleJsonText += $padding + " ...\r\n";
165+
$sampleJsonText += $padding + "}\r\n";
154166
}
155167

156168
if ($TreeNode.Properties.Count -gt 0 -or ($TreeNode.IsListItem))
@@ -167,7 +179,7 @@ function Generate-CliParameterCommandImpl
167179
$code += " var ${params_generate_category_var_name} = ${params_category_var_name}.category('${cli_method_option_name}')" + $NEW_LINE;
168180
$code += " .description(`$('" + (Get-ParameterCommandCategoryDescription $cli_op_description $params_category_name $cli_method_option_name) +"'));" + $NEW_LINE;
169181
$code += " ${params_generate_category_var_name}.command('${params_generate_category_name}')" + $NEW_LINE;
170-
$code += " .description(`$('Set ${cli_method_option_name} in ${params_category_name} string or files, e.g. \r\n${sampleJsonText}'))" + $NEW_LINE;
182+
$code += " .description(`$('Set ${cli_method_option_name} in ${params_category_name} string or files, e.g. \r\n${sampleJsonText}\r\n" + $CLI_HELP_MSG + "'))" + $NEW_LINE;
171183
$code += " .usage('[options]')" + $NEW_LINE;
172184
$code += " .option('--parameter-file <parameter-file>', `$('The parameter file path.'))" + $NEW_LINE;
173185

@@ -244,6 +256,12 @@ function Generate-CliParameterCommandImpl
244256
$code += " if (options.parse && options.${paramName}) {" + $NEW_LINE;
245257
$code += " options.${paramName} = JSON.parse(options.${paramName});" + $NEW_LINE;
246258
$code += " }" + $NEW_LINE;
259+
260+
if ($propertyItem["IsPrimitive"])
261+
{
262+
$code += " options.${paramName} = JSON.parse(options.${paramName});" + $NEW_LINE;
263+
}
264+
247265
$code += " jsonpatch.apply(${cli_param_name}Obj, [{op: options.operation, path: paramPath, value: options.${paramName}}]);" + $NEW_LINE;
248266
$code += " }" + $NEW_LINE;
249267
}
@@ -274,7 +292,7 @@ function Generate-CliParameterCommandImpl
274292
$code += " var ${params_generate_category_var_name} = ${params_category_var_name}.category('${cli_method_option_name}')" + $NEW_LINE;
275293
$code += " .description(`$('" + (Get-ParameterCommandCategoryDescription $cli_op_description $params_category_name $cli_method_option_name) +"'));" + $NEW_LINE;
276294
$code += " ${params_generate_category_var_name}.command('${params_generate_category_name}')" + $NEW_LINE;
277-
$code += " .description(`$('Remove ${cli_method_option_name} in ${params_category_name} string or files, e.g. \r\n${sampleJsonText}'))" + $NEW_LINE;
295+
$code += " .description(`$('Remove ${cli_method_option_name} in ${params_category_name} string or files, e.g. \r\n${sampleJsonText}\r\n" + $CLI_HELP_MSG + "'))" + $NEW_LINE;
278296
$code += " .usage('[options]')" + $NEW_LINE;
279297
$code += " .option('--parameter-file <parameter-file>', `$('The parameter file path.'))" + $NEW_LINE;
280298

@@ -364,7 +382,7 @@ function Generate-CliParameterCommandImpl
364382
$code += " var ${params_generate_category_var_name} = ${params_category_var_name}.category('${cli_method_option_name}')" + $NEW_LINE;
365383
$code += " .description(`$('" + (Get-ParameterCommandCategoryDescription $cli_op_description $params_category_name $cli_method_option_name) +"'));" + $NEW_LINE;
366384
$code += " ${params_generate_category_var_name}.command('${params_generate_category_name}')" + $NEW_LINE;
367-
$code += " .description(`$('Add ${cli_method_option_name} in ${params_category_name} string or files, e.g. \r\n${sampleJsonText}'))" + $NEW_LINE;
385+
$code += " .description(`$('Add ${cli_method_option_name} in ${params_category_name} string or files, e.g. \r\n${sampleJsonText}\r\n" + $CLI_HELP_MSG + "'))" + $NEW_LINE;
368386
$code += " .usage('[options]')" + $NEW_LINE;
369387
$code += " .option('--parameter-file <parameter-file>', `$('The parameter file path.'))" + $NEW_LINE;
370388
$code += " .option('--key <key>', `$('The JSON key.'))" + $NEW_LINE;
@@ -422,6 +440,12 @@ function Generate-CliParameterCommandImpl
422440
$code += " if (options.parse && options.${paramName}) {" + $NEW_LINE;
423441
$code += " options.${paramName} = JSON.parse(options.${paramName});" + $NEW_LINE;
424442
$code += " }" + $NEW_LINE;
443+
444+
if ($propertyItem["IsPrimitive"])
445+
{
446+
$code += " options.${paramName} = JSON.parse(options.${paramName});" + $NEW_LINE;
447+
}
448+
425449
$code += " jsonpatch.apply(${cli_param_name}Obj, [{op: options.operation, path: paramPath, value: options.${paramName}}]);" + $NEW_LINE;
426450
$code += " }" + $NEW_LINE;
427451
}

src/ServiceManagement/Compute/Commands.ServiceManagement.Preview/Automation/ParameterTypeHelper.ps1

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ function Contains-OnlyStringFields
2424
return $false;
2525
}
2626

27-
if ($parameterType.BaseType.IsEquivalentTo([System.Enum]))
27+
if ((-not $parameterType.IsInterface) -and ($parameterType.BaseType -ne $null) -and $parameterType.BaseType.IsEquivalentTo([System.Enum]))
2828
{
2929
return $false;
3030
}
@@ -49,12 +49,17 @@ function Contains-OnlyStringList
4949
[System.Type]$parameterType
5050
)
5151

52-
if ($parameterType -eq $null -or $parameterType.BaseType -eq $null)
52+
if ($parameterType -eq $null)
5353
{
5454
return $false;
5555
}
56+
57+
if ($parameterType.IsEquivalentTo([System.Collections.Generic.IList[string]]))
58+
{
59+
return $true;
60+
}
5661

57-
if ($parameterType.BaseType.IsEquivalentTo([System.Enum]))
62+
if ((-not $parameterType.IsInterface) -and ($parameterType.BaseType -ne $null) -and $parameterType.BaseType.IsEquivalentTo([System.Enum]))
5863
{
5964
return $false;
6065
}

src/ServiceManagement/Compute/Commands.ServiceManagement.Preview/Automation/StringProcessingHelper.ps1

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,14 @@ function Get-CliCategoryName
9696
{
9797
$outName = 'vmssvm';
9898
}
99+
if ($inName -eq 'VirtualMachineScaleSets')
100+
{
101+
$outName = 'vmss';
102+
}
103+
elseif ($inName -eq 'VirtualMachineScaleSetVMs')
104+
{
105+
$outName = 'vmssvm';
106+
}
99107
else
100108
{
101109
$outName = Get-CliOptionName $inName;

0 commit comments

Comments
 (0)