Skip to content

Fix issue #674, #1221, #270 #2184

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
May 5, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ internal static PSObject ToPsObject(this JToken jtoken, string objectType = null
foreach (var property in jobject.Properties())
{
psObject.Properties.Add(new PSNoteProperty(
name: JTokenExtensions.ConvertToPascalCase(propertyName: property.Name),
name: property.Name,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we please add a test for this? Feel free to edit one of our existing resources tests to add a check for this.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will fix this.

value: JTokenExtensions.ConvertPropertyValueForPsObject(propertyValue: property.Value)));
}

Expand Down Expand Up @@ -126,16 +126,5 @@ internal static object ConvertPropertyValueForPsObject(JToken propertyValue)

return propertyValue.ToString();
}

/// <summary>
/// Converts the property names from camel case to Pascal case.
/// </summary>
/// <param name="propertyName">The name of the property.</param>
private static string ConvertToPascalCase(string propertyName)
{
return char.IsLower(propertyName.First())
? new string(char.ToUpper(propertyName.First()).AsArray().Concat(propertyName.Skip(1)).ToArray())
: propertyName;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public sealed class NewAzureResourceCmdlet : ResourceManipulationCmdletBase
/// Gets or sets the property object.
/// </summary>
[Alias("PropertyObject")]
[Parameter(Mandatory = true, HelpMessage = "A hash table which represents resource properties.")]
[Parameter(Mandatory = false, HelpMessage = "A hash table which represents resource properties.")]
[ValidateNotNullOrEmpty]
public PSObject Properties { get; set; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,14 @@ function Test-SetAResource
# Test
New-AzureRmResourceGroup -Name $rgname -Location $rglocation
$resource = New-AzureRmResource -Name $rname -Location $rglocation -Tags @{Name = "testtag"; Value = "testval"} -ResourceGroupName $rgname -ResourceType $resourceType -PropertyObject @{"key" = "value"} -SkuObject @{ Name = "A0" } -ApiVersion $apiversion -Force

# Verify original value
$oldSku = $resource.Sku.psobject
$oldSkuNameProperty = $oldSku.Properties
Assert-AreEqual $oldSkuNameProperty.Name "name"
Assert-AreEqual $resource.SKu.Name "A0"

# Set resource
Set-AzureRmResource -ResourceGroupName $rgname -ResourceName $rname -ResourceType $resourceType -Properties @{"key2" = "value2"} -Force
Set-AzureRmResource -ResourceGroupName $rgname -ResourceName $rname -ResourceType $resourceType -SkuObject @{ Name = "A1" } -Force

Expand Down Expand Up @@ -346,6 +354,9 @@ function Test-GetResourceExpandProperties
$resourceGet = Get-AzureRmResource -ResourceName $rname -ResourceGroupName $rgname -ExpandProperties

# Assert
$properties = $resourceGet.Properties.psobject
$keyProperty = $properties.Properties
Assert-AreEqual $keyProperty.Name "key"
Assert-AreEqual $resourceGet.Properties.key "value"
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4431,6 +4431,13 @@ Resources</dev:code>
</maml:description>
<command:parameterValue required="true" variableLength="false">String</command:parameterValue>
</command:parameter>
<command:parameter required="true" variableLength="false" globbing="false" pipelineInput="true (ByPropertyName)" position="named">
<maml:name>TemplateFile</maml:name>
<maml:description>
<maml:para>Specifies the path and file name of a JSON template file on disk. This can be a custom template or a gallery template that is saved to disk as a JSON file.</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">String</command:parameterValue>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named">
<maml:name>Profile</maml:name>
<maml:description>
Expand All @@ -4455,13 +4462,6 @@ Resources</dev:code>
</maml:description>
<command:parameterValue required="true" variableLength="false">String</command:parameterValue>
</command:parameter>
<command:parameter required="true" variableLength="false" globbing="false" pipelineInput="true (ByPropertyName)" position="named">
<maml:name>TemplateParameterObject</maml:name>
<maml:description>
<maml:para>Specifies a hash table of template parameter names and values. This parameter is optional. For help with hash tables in Windows PowerShell, type: Get-Help about_Hash_Tables.If a template has parameters, you must specify parameter values, but you can use this parameter or the TemplateParameterObject parameter. Also, the template parameters are added to the command dynamically when you specify a template. To use the dynamic parameters, just type them in the command, or type a minus sign to indicate a parameter name (-) and then press the TAB key repeatedly to cycle through the available parameters. If you miss a required parameter, the cmdlet prompts you for the value.</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">Hashtable</command:parameterValue>
</command:parameter>
<command:parameter required="true" variableLength="false" globbing="false" pipelineInput="true (ByPropertyName)" position="named">
<maml:name>TemplateUri</maml:name>
<maml:description>
Expand Down Expand Up @@ -4501,9 +4501,9 @@ Resources</dev:code>
<command:parameterValue required="true" variableLength="false">Hashtable</command:parameterValue>
</command:parameter>
<command:parameter required="true" variableLength="false" globbing="false" pipelineInput="true (ByPropertyName)" position="named">
<maml:name>TemplateFile</maml:name>
<maml:name>TemplateUri</maml:name>
<maml:description>
<maml:para>Specifies the path and file name of a JSON template file on disk. This can be a custom template or a gallery template that is saved to disk as a JSON file.</maml:para>
<maml:para>Specifies the URI of a JSON template file. This file can be a custom template or a gallery template that is saved as a JSON file.</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">String</command:parameterValue>
</command:parameter>
Expand Down Expand Up @@ -4538,34 +4538,10 @@ Resources</dev:code>
</maml:description>
<command:parameterValue required="true" variableLength="false">Hashtable</command:parameterValue>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named">
<maml:name>Profile</maml:name>
<maml:description>
<maml:para />
</maml:description>
<command:parameterValue required="true" variableLength="false">AzureProfile</command:parameterValue>
</command:parameter>
</command:syntaxItem>
<command:syntaxItem>
<maml:name>New-AzureRmResourceGroupDeployment</maml:name>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="true (ByPropertyName)" position="named">
<maml:name>Name</maml:name>
<maml:description>
<maml:para>Specifies the name of the deployment project for the resource group. Use -Name or its alias -DeploymentName. This parameter is optional. The default value is the template name without the .json file name extension.</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">String</command:parameterValue>
</command:parameter>
<command:parameter required="true" variableLength="false" globbing="false" pipelineInput="true (ByPropertyName)" position="named">
<maml:name>ResourceGroupName</maml:name>
<maml:description>
<maml:para>Specifies the name of the resource group to which this deployment is added. This parameter is required. If the resource group does not exist, the command fails.</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">String</command:parameterValue>
</command:parameter>
<command:parameter required="true" variableLength="false" globbing="false" pipelineInput="true (ByPropertyName)" position="named">
<maml:name>TemplateParameterFile</maml:name>
<maml:name>TemplateFile</maml:name>
<maml:description>
<maml:para>Specifies the path and name of a JSON file with the names and values of the template parameters. This parameter is optional.If a template has parameters, you must specify parameter values, but you can use this parameter or the TemplateParameterObject parameter. Also, the template parameters are added to the command dynamically when you specify a template. To use the dynamic parameters, just type them in the command, or type a minus sign to indicate a parameter name (-) and then press the TAB key repeatedly to cycle through the available parameters. If you miss a required parameter, the cmdlet prompts you for the value.</maml:para>
<maml:para>Specifies the path and file name of a JSON template file on disk. This can be a custom template or a gallery template that is saved to disk as a JSON file.</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">String</command:parameterValue>
</command:parameter>
Expand Down Expand Up @@ -4669,34 +4645,17 @@ Resources</dev:code>
</maml:description>
<command:parameterValue required="true" variableLength="false">String</command:parameterValue>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named">
<maml:name>Profile</maml:name>
<maml:description>
<maml:para />
</maml:description>
<command:parameterValue required="true" variableLength="false">AzureProfile</command:parameterValue>
</command:parameter>
</command:syntaxItem>
<command:syntaxItem>
<maml:name>New-AzureRmResourceGroupDeployment</maml:name>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="true (ByPropertyName)" position="named">
<maml:name>Name</maml:name>
<maml:description>
<maml:para>Specifies the name of the deployment project for the resource group. Use -Name or its alias -DeploymentName. This parameter is optional. The default value is the template name without the .json file name extension.</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">String</command:parameterValue>
</command:parameter>
<command:parameter required="true" variableLength="false" globbing="false" pipelineInput="true (ByPropertyName)" position="named">
<maml:name>ResourceGroupName</maml:name>
<maml:name>TemplateParameterUri</maml:name>
<maml:description>
<maml:para>Specifies the name of the resource group to which this deployment is added. This parameter is required. If the resource group does not exist, the command fails.</maml:para>
<maml:para>Specifies the URI of a JSON template parameter file. This file includes all the parameters for the template.</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">String</command:parameterValue>
</command:parameter>
<command:parameter required="true" variableLength="false" globbing="false" pipelineInput="true (ByPropertyName)" position="named">
<maml:name>TemplateFile</maml:name>
<maml:name>TemplateUri</maml:name>
<maml:description>
<maml:para>Specifies the path and file name of a JSON template file on disk. This can be a custom template or a gallery template that is saved to disk as a JSON file.</maml:para>
<maml:para>Specifies the URI of a JSON template file. This file can be a custom template or a gallery template that is saved as a JSON file.</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">String</command:parameterValue>
</command:parameter>
Expand Down Expand Up @@ -4725,9 +4684,16 @@ Resources</dev:code>
<command:parameterValue required="true" variableLength="false">String</command:parameterValue>
</command:parameter>
<command:parameter required="true" variableLength="false" globbing="false" pipelineInput="true (ByPropertyName)" position="named">
<maml:name>TemplateUri</maml:name>
<maml:name>TemplateParameterUri</maml:name>
<maml:description>
<maml:para>Specifies the URI of a JSON template file. This file can be a custom template or a gallery template that is saved as a JSON file.</maml:para>
<maml:para>Specifies the URI of a JSON template parameter file. This file includes all the parameters for the template.</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">String</command:parameterValue>
</command:parameter>
<command:parameter required="true" variableLength="false" globbing="false" pipelineInput="true (ByPropertyName)" position="named">
<maml:name>TemplateFile</maml:name>
<maml:description>
<maml:para>Specifies the path and file name of a JSON template file on disk. This can be a custom template or a gallery template that is saved to disk as a JSON file.</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">String</command:parameterValue>
</command:parameter>
Expand Down Expand Up @@ -4781,22 +4747,22 @@ Resources</dev:code>
</dev:defaultValue>
</command:parameter>
<command:parameter required="true" variableLength="false" globbing="false" pipelineInput="true (ByPropertyName)" position="named">
<maml:name>TemplateParameterObject</maml:name>
<maml:name>TemplateUri</maml:name>
<maml:description>
<maml:para>Specifies a hash table of template parameter names and values. This parameter is optional. For help with hash tables in Windows PowerShell, type: Get-Help about_Hash_Tables.If a template has parameters, you must specify parameter values, but you can use this parameter or the TemplateParameterObject parameter. Also, the template parameters are added to the command dynamically when you specify a template. To use the dynamic parameters, just type them in the command, or type a minus sign to indicate a parameter name (-) and then press the TAB key repeatedly to cycle through the available parameters. If you miss a required parameter, the cmdlet prompts you for the value.</maml:para>
<maml:para>Specifies the URI of a JSON template file. This file can be a custom template or a gallery template that is saved as a JSON file.</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">Hashtable</command:parameterValue>
<command:parameterValue required="true" variableLength="false">String</command:parameterValue>
<dev:type>
<maml:name>Hashtable</maml:name>
<maml:name>String</maml:name>
<maml:uri />
</dev:type>
<dev:defaultValue>
</dev:defaultValue>
</command:parameter>
<command:parameter required="true" variableLength="false" globbing="false" pipelineInput="true (ByPropertyName)" position="named">
<maml:name>TemplateUri</maml:name>
<maml:name>TemplateFile</maml:name>
<maml:description>
<maml:para>Specifies the URI of a JSON template file. This file can be a custom template or a gallery template that is saved as a JSON file.</maml:para>
<maml:para>Specifies the path and file name of a JSON template file on disk. This can be a custom template or a gallery template that is saved to disk as a JSON file.</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">String</command:parameterValue>
<dev:type>
Expand All @@ -4807,13 +4773,13 @@ Resources</dev:code>
</dev:defaultValue>
</command:parameter>
<command:parameter required="true" variableLength="false" globbing="false" pipelineInput="true (ByPropertyName)" position="named">
<maml:name>TemplateFile</maml:name>
<maml:name>TemplateParameterObject</maml:name>
<maml:description>
<maml:para>Specifies the path and file name of a JSON template file on disk. This can be a custom template or a gallery template that is saved to disk as a JSON file.</maml:para>
<maml:para>Specifies a hash table of template parameter names and values. This parameter is optional. For help with hash tables in Windows PowerShell, type: Get-Help about_Hash_Tables.If a template has parameters, you must specify parameter values, but you can use this parameter or the TemplateParameterObject parameter. Also, the template parameters are added to the command dynamically when you specify a template. To use the dynamic parameters, just type them in the command, or type a minus sign to indicate a parameter name (-) and then press the TAB key repeatedly to cycle through the available parameters. If you miss a required parameter, the cmdlet prompts you for the value.</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">String</command:parameterValue>
<command:parameterValue required="true" variableLength="false">Hashtable</command:parameterValue>
<dev:type>
<maml:name>String</maml:name>
<maml:name>Hashtable</maml:name>
<maml:uri />
</dev:type>
<dev:defaultValue>
Expand All @@ -4832,6 +4798,19 @@ Resources</dev:code>
<dev:defaultValue>
</dev:defaultValue>
</command:parameter>
<command:parameter required="true" variableLength="false" globbing="false" pipelineInput="true (ByPropertyName)" position="named">
<maml:name>TemplateParameterUri</maml:name>
<maml:description>
<maml:para>Specifies the URI of a JSON template parameter file. This file includes all the parameters for the template.</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">String</command:parameterValue>
<dev:type>
<maml:name>String</maml:name>
<maml:uri />
</dev:type>
<dev:defaultValue>
</dev:defaultValue>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="true (ByPropertyName)" position="named">
<maml:name>Mode</maml:name>
<maml:description>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ namespace Microsoft.Azure.Commands.Resources
{
public abstract class ResourceWithParameterBaseCmdlet : ResourcesBaseCmdlet
{
protected const string BaseParameterSetName = "Default";
protected const string TemplateFileParameterObjectParameterSetName = "Deployment via template file and template parameters object";
protected const string TemplateFileParameterFileParameterSetName = "Deployment via template file and template parameters file";
protected const string TemplateFileParameterUriParameterSetName = "Deployment via template file template parameters uri";
Expand Down
Loading