Skip to content

Commit aa9cd90

Browse files
committed
[Insights] Including feedback from PR
1 parent 626ed19 commit aa9cd90

32 files changed

+157
-88
lines changed

src/ResourceManager/Insights/Commands.Insights.Test/ActivityLogs/GetAzureRmLogTests.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ public void GetAzureCorrelationIdLogCommandParametersProcessing()
9898
// Setting required parameter
9999
cmdlet.CorrelationId = Utilities.Correlation;
100100
cmdlet.ResourceId = null;
101-
cmdlet.ResourceGroup = null;
101+
cmdlet.ResourceGroupName = null;
102102
cmdlet.ResourceProvider = null;
103103

104104
Utilities.ExecuteVerifications(
@@ -118,7 +118,7 @@ public void GetAzureResourceGroupLogCommandParametersProcessing()
118118
var startDate = DateTime.Now.AddSeconds(-1);
119119

120120
// Setting required parameter
121-
cmdlet.ResourceGroup = Utilities.ResourceGroup;
121+
cmdlet.ResourceGroupName = Utilities.ResourceGroup;
122122
cmdlet.CorrelationId = null;
123123
cmdlet.ResourceId = null;
124124
cmdlet.ResourceProvider = null;
@@ -141,7 +141,7 @@ public void GetAzureResourceLogCommandParametersProcessing()
141141

142142
// Setting required parameter
143143
cmdlet.ResourceId = Utilities.ResourceUri;
144-
cmdlet.ResourceGroup = null;
144+
cmdlet.ResourceGroupName = null;
145145
cmdlet.CorrelationId = null;
146146
cmdlet.ResourceProvider = null;
147147

@@ -164,7 +164,7 @@ public void GetAzureResourceProviderLogCommandParametersProcessing()
164164
// Setting required parameter
165165
cmdlet.ResourceProvider = Utilities.ResourceProvider;
166166
cmdlet.ResourceId = null;
167-
cmdlet.ResourceGroup = null;
167+
cmdlet.ResourceGroupName = null;
168168
cmdlet.CorrelationId = null;
169169

170170
Utilities.ExecuteVerifications(

src/ResourceManager/Insights/Commands.Insights.Test/Autoscale/AddAzureRmAutoscaleSettingTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ public void AddAutoscaleSettingCommandParametersProcessing()
9090
// Add-AutoscaleSetting -SettingSpec <AutoscaleSettingResource> -ResourceGroup <String> [-DisableSetting [<SwitchParameter>]] [-AutoscaleProfiles <List[AutoscaleProfile]>] [-Profile <AzureSMProfile>] [<CommonParameters>]
9191
// Add-AutoscaleSetting -SettingSpec $spec -ResourceGroup $Utilities.ResourceGroup
9292
// A NOP
93-
cmdlet.SettingSpec = spec;
93+
cmdlet.InputObject = spec;
9494
cmdlet.ResourceGroupName = Utilities.ResourceGroup;
9595
cmdlet.ExecuteCmdlet();
9696

@@ -114,7 +114,7 @@ public void AddAutoscaleSettingCommandParametersProcessing()
114114
cmdlet.ExecuteCmdlet();
115115

116116
// Add-AutoscaleSetting -Location <String> -Name <String> -ResourceGroup <String> [-DisableSetting [<SwitchParameter>]] [-AutoscaleProfiles <List[AutoscaleProfile]>] -TargetResourceId <String> [-Profile <AzureSMProfile>] [<CommonParameters>]
117-
cmdlet.SettingSpec = null;
117+
cmdlet.InputObject = null;
118118
cmdlet.Name = "SettingName";
119119
cmdlet.Location = "East US";
120120
cmdlet.ResourceGroupName = Utilities.ResourceGroup;

src/ResourceManager/Insights/Commands.Insights.Test/LogProfiles/AddAzureRmLogProfileTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ public void AddLogProfileCommandParametersProcessing()
8585
// With all arguments
8686
cmdlet.Name = Utilities.Name;
8787
cmdlet.Location = new List<string>() {"East US"};
88-
cmdlet.RetentionInDay = 10;
88+
cmdlet.RetentionInDays = 10;
8989
cmdlet.ServiceBusRuleId = "miBusId";
9090
cmdlet.StorageAccountId = "miCuentaId";
9191
cmdlet.Category = new List<string>() {"cat1"};

src/ResourceManager/Insights/Commands.Insights.Test/Utilities.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,6 @@ public static void VerifyDetailedOutput(LogsCmdletBase cmdlet)
177177
// Calling with detailed output
178178
cmdlet.DetailedOutput = true;
179179
cmdlet.ExecuteCmdlet();
180-
// Assert.Null(selected); // Incorrect nameOrTargetUri clause with detailed output on
181180
}
182181

183182
public static void VerifyContinuationToken(string nextLink)

src/ResourceManager/Insights/Commands.Insights/ActivityLogs/GetAzureRmLogCommand.cs

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,11 @@ public class GetAzureRmLogCommand : LogsCmdletBase
2828
/// <summary>
2929
/// Gets or sets the starttime parameter of the cmdlet
3030
/// </summary>
31-
[Parameter(ParameterSetName = CorrelationIdName, ValueFromPipelineByPropertyName = true, HelpMessage = "The correlationId of the query")]
32-
[Parameter(ParameterSetName = ResourceIdName, ValueFromPipelineByPropertyName = true, HelpMessage = "The resourceId of the query")]
33-
[Parameter(ParameterSetName = ResourceGroupName, ValueFromPipelineByPropertyName = true, HelpMessage = "The resource group name of the query")]
34-
[Parameter(ParameterSetName = ResourceProviderName, ValueFromPipelineByPropertyName = true, HelpMessage = "The resource provider name of the query")]
35-
[Parameter(ParameterSetName = SubscriptionLevelName, ValueFromPipelineByPropertyName = true, HelpMessage = "The subscriptionId of the query")]
31+
[Parameter(ParameterSetName = CorrelationIdParameterSetName, ValueFromPipelineByPropertyName = true, HelpMessage = "The correlationId of the query")]
32+
[Parameter(ParameterSetName = ResourceIdParameterSetName, ValueFromPipelineByPropertyName = true, HelpMessage = "The resourceId of the query")]
33+
[Parameter(ParameterSetName = LogsCmdletBase.ResourceGroupParameterSetName, ValueFromPipelineByPropertyName = true, HelpMessage = "The resource group name of the query")]
34+
[Parameter(ParameterSetName = ResourceProviderParameterSetName, ValueFromPipelineByPropertyName = true, HelpMessage = "The resource provider name of the query")]
35+
[Parameter(ParameterSetName = SubscriptionLevelParameterSetName, ValueFromPipelineByPropertyName = true, HelpMessage = "The subscriptionId of the query")]
3636
public override DateTime? StartTime { get; set; }
3737

3838
/// <summary>
@@ -64,28 +64,29 @@ public class GetAzureRmLogCommand : LogsCmdletBase
6464
/// <summary>
6565
/// Gets or sets the correlationId of the cmdlet
6666
/// </summary>
67-
[Parameter(Position = 0, ParameterSetName = CorrelationIdName, Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "The CorrelationId")]
67+
[Parameter(Position = 0, ParameterSetName = CorrelationIdParameterSetName, Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "The CorrelationId")]
6868
[ValidateNotNullOrEmpty]
6969
public string CorrelationId { get; set; }
7070

7171
/// <summary>
72-
/// Gets or sets the resourcegroup parameters of this cmdlet
72+
/// Gets or sets the resource group name parameter of this cmdlet
7373
/// </summary>
74-
[Parameter(Position = 0, ParameterSetName = ResourceGroupName, Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "The resource group name")]
74+
[Parameter(Position = 0, ParameterSetName = LogsCmdletBase.ResourceGroupParameterSetName, Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "The resource group name")]
7575
[ValidateNotNullOrEmpty]
76-
public string ResourceGroup { get; set; }
76+
[Alias("ResourceGroup")]
77+
public string ResourceGroupName { get; set; }
7778

7879
/// <summary>
7980
/// Gets or sets the resourceId parameter of the cmdlet
8081
/// </summary>
81-
[Parameter(Position = 0, ParameterSetName = ResourceIdName, Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "The ResourceId")]
82+
[Parameter(Position = 0, ParameterSetName = ResourceIdParameterSetName, Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "The ResourceId")]
8283
[ValidateNotNullOrEmpty]
8384
public string ResourceId { get; set; }
8485

8586
/// <summary>
8687
/// Gets or sets the resourceprovider parameter of the cmdlet
8788
/// </summary>
88-
[Parameter(Position = 0, ParameterSetName = ResourceProviderName, Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "The ResourceProvider name")]
89+
[Parameter(Position = 0, ParameterSetName = ResourceProviderParameterSetName, Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "The ResourceProvider name")]
8990
[ValidateNotNullOrEmpty]
9091
public string ResourceProvider { get; set; }
9192

@@ -104,11 +105,11 @@ public class GetAzureRmLogCommand : LogsCmdletBase
104105
/// <returns>The query filter with the conditions for particular parameters added</returns>
105106
protected override string ProcessParticularParameters(string currentQueryFilter)
106107
{
107-
WriteWarning("Parameter name change: The parameter plural names for the parameters will be deprecated in May 2018 in favor of the singular versions of the same names.");
108+
this.WriteIdentifiedWarning("Parameter name change", "The parameter plural names for the parameters will be deprecated in May 2018 in favor of the singular versions of the same names.");
108109
this.SetMaxEventsIfPresent(currentQueryFilter, this.MaxRecord);
109110

110111
string extendedQuery = this.AddConditionIfPResent(currentQueryFilter, "correlationId", this.CorrelationId);
111-
extendedQuery = this.AddConditionIfPResent(extendedQuery, "resourceGroupName", this.ResourceGroup);
112+
extendedQuery = this.AddConditionIfPResent(extendedQuery, "resourceGroupName", this.ResourceGroupName);
112113

113114
// Notice the different name in the condition (resourceUri) and the parameter (resourceId)
114115
// The difference is intentional as the new directive is to use ResourceId everywhere, but the SDK still uses resourceUri

src/ResourceManager/Insights/Commands.Insights/Alerts/AddAzureRmAlertRuleCommandBase.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ public abstract class AddAzureRmAlertRuleCommandBase : ManagementCmdletBase
5353
/// </summary>
5454
[Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "The resource group name")]
5555
[ValidateNotNullOrEmpty]
56+
[Alias("ResourceGroup")]
5657
public string ResourceGroupName { get; set; }
5758

5859
/// <summary>
@@ -77,7 +78,7 @@ public abstract class AddAzureRmAlertRuleCommandBase : ManagementCmdletBase
7778
/// </summary>
7879
protected override void ProcessRecordInternal()
7980
{
80-
WriteWarning("Parameter name change: The parameter plural names for the parameters will be deprecated in May 2018 in favor of the singular versions of the same names.");
81+
this.WriteIdentifiedWarning("Parameter name change", "The parameter plural names for the parameters will be deprecated in May 2018 in favor of the singular versions of the same names.");
8182
if (ShouldProcess(
8283
target: string.Format("Create/update an alert rule: {0} from resource group: {1}", this.Name, this.ResourceGroupName),
8384
action: "Create/update an alert rule"))

src/ResourceManager/Insights/Commands.Insights/Alerts/GetAzureRmAlertRuleCommand.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ public class GetAzureRmAlertRuleCommand : ManagementCmdletBase
4141
[Parameter(ParameterSetName = GetAzureRmAlertRuleWithNameParamGroup, Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "The resource group name")]
4242
[Parameter(ParameterSetName = GetAzureRmAlertRuleWithUriParamGroup, Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "The resource group name")]
4343
[ValidateNotNullOrEmpty]
44+
[Alias("ResourceGroup")]
4445
public string ResourceGroupName { get; set; }
4546

4647
/// <summary>
@@ -106,7 +107,7 @@ private static string ExtractTargetResourceId(AlertRuleResource alertRuleResourc
106107
/// </summary>
107108
protected override void ProcessRecordInternal()
108109
{
109-
WriteWarning("Parameter deprecation: The DetailedOutput parameter will be deprecated in May 2018.");
110+
this.WriteIdentifiedWarning("Parameter deprecation", "The DetailedOutput parameter will be deprecated in May 2018.");
110111
if (string.IsNullOrWhiteSpace(this.Name))
111112
{
112113
// Retrieve all the AlertRules for a ResourceGroup

src/ResourceManager/Insights/Commands.Insights/Alerts/NewAzureRmAlertRuleEmailCommand.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
using Microsoft.Azure.Commands.ResourceManager.Common;
1616
using Microsoft.Azure.Management.Monitor.Management.Models;
1717
using System;
18+
using System.Globalization;
1819
using System.Management.Automation;
1920

2021
namespace Microsoft.Azure.Commands.Insights.Alerts
@@ -45,7 +46,11 @@ public class NewAzureRmAlertRuleEmailCommand : AzureRMCmdlet
4546
/// </summary>
4647
public override void ExecuteCmdlet()
4748
{
48-
WriteWarning("Parameter name change: The parameter plural names for the parameters will be deprecated in May 2018 in favor of the singular versions of the same names.");
49+
WriteWarning(
50+
Utilities.FormatIdentifiedMessage(
51+
this.GetType(),
52+
"Parameter name change",
53+
"The parameter plural names for the parameters will be deprecated in May 2018 in favor of the singular versions of the same names."));
4954
if (!this.SendToServiceOwner && (this.CustomEmail == null || this.CustomEmail.Length < 1))
5055
{
5156
throw new ArgumentException("Either SendToServiceOwners must be set or at least one custom email must be present");

src/ResourceManager/Insights/Commands.Insights/Alerts/NewAzureRmAlertRuleWebhookCommand.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,11 @@ public class NewAzureRmAlertRuleWebhookCommand : AzureRMCmdlet
4545
/// </summary>
4646
public override void ExecuteCmdlet()
4747
{
48-
WriteWarning("Parameter name change: The parameter plural names for the parameters will be deprecated in May 2018 in favor of the singular versions of the same names.");
48+
WriteWarning(
49+
Utilities.FormatIdentifiedMessage(
50+
this.GetType(),
51+
"Parameter name change",
52+
"The parameter plural names for the parameters will be deprecated in May 2018 in favor of the singular versions of the same names."));
4953
Utilities.ValidateUri(this.ServiceUri, "ServiceUri");
5054

5155
var dictionary = this.Property == null

src/ResourceManager/Insights/Commands.Insights/Alerts/RemoveAzureRmAlertRuleCommand.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ public class RemoveAzureRmAlertRuleCommand : ManagementCmdletBase
3232
/// </summary>
3333
[Parameter(ParameterSetName = RemoveAzureRmAlertRuleParamGroup, Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "The resource group name")]
3434
[ValidateNotNullOrEmpty]
35+
[Alias("ResourceGroup")]
3536
public string ResourceGroupName { get; set; }
3637

3738
/// <summary>

src/ResourceManager/Insights/Commands.Insights/Autoscale/AddAzureRmAutoscaleSettingCommand.cs

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,12 @@ public class AddAzureRmAutoscaleSettingCommand : ManagementCmdletBase
3737
#region Cmdlet parameters
3838

3939
/// <summary>
40-
/// Gets or sets the SettingSpec parameter of the cmdlet
40+
/// Gets or sets the InputObject parameter of the cmdlet
4141
/// </summary>
4242
[Parameter(ParameterSetName = AddAzureRmAutoscaleSettingUpdateParamGroup, Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "The complete spec of an AutoscaleSetting")]
4343
[ValidateNotNullOrEmpty]
44-
[Alias("InputObject")]
45-
public PSAutoscaleSetting SettingSpec { get; set; }
44+
[Alias("SettingSpec")]
45+
public PSAutoscaleSetting InputObject { get; set; }
4646

4747
/// <summary>
4848
/// Gets or sets the Location parameter of the cmdlet
@@ -64,6 +64,7 @@ public class AddAzureRmAutoscaleSettingCommand : ManagementCmdletBase
6464
[Parameter(ParameterSetName = AddAzureRmAutoscaleSettingCreateParamGroup, Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "The resource group name")]
6565
[Parameter(ParameterSetName = AddAzureRmAutoscaleSettingUpdateParamGroup, Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "The resource group name")]
6666
[ValidateNotNullOrEmpty]
67+
[Alias("ResourceGroup")]
6768
public string ResourceGroupName { get; set; }
6869

6970
/// <summary>
@@ -105,7 +106,7 @@ public class AddAzureRmAutoscaleSettingCommand : ManagementCmdletBase
105106
/// </summary>
106107
protected override void ProcessRecordInternal()
107108
{
108-
WriteWarning("Parameter name change: The parameter plural names for the parameters will be deprecated in May 2018 in favor of he singular versions of the same names.");
109+
this.WriteIdentifiedWarning("Parameter name change", "The parameter plural names for the parameters will be deprecated in May 2018 in favor of he singular versions of the same names.");
109110
if (ShouldProcess(
110111
target: string.Format("Create/update an autoscale setting: {0} from resource group: {1}", this.Name, this.ResourceGroupName),
111112
action: "Create/update an autoscale setting"))
@@ -129,19 +130,19 @@ private AutoscaleSettingResource CreateAutoscaleSettingResource()
129130
{
130131
bool enableSetting = !this.DisableSetting.IsPresent || !this.DisableSetting;
131132

132-
if (this.SettingSpec != null)
133+
if (this.InputObject != null)
133134
{
134135

135136
// Receiving a single parameter with the whole spec for an autoscale setting
136-
var property = this.SettingSpec;
137+
var property = this.InputObject;
137138

138139
if (property == null)
139140
{
140141
throw new ArgumentException(ResourcesForAutoscaleCmdlets.PropertiresCannotBeNull);
141142
}
142143

143-
this.Location = this.SettingSpec.Location;
144-
this.Name = this.SettingSpec.Name;
144+
this.Location = this.InputObject.Location;
145+
this.Name = this.InputObject.Name;
145146

146147
// The semantics is if AutoscaleProfiles is given it will replace the existing Profiles
147148
this.AutoscaleProfile = this.AutoscaleProfile ?? property.Profiles.ToList();
@@ -150,7 +151,7 @@ private AutoscaleSettingResource CreateAutoscaleSettingResource()
150151
enableSetting = !this.DisableSetting.IsPresent && property.Enabled.HasValue && property.Enabled.Value;
151152

152153
// The semantics is if Notifications is given it will replace the existing ones
153-
this.Notification = this.Notification ?? (this.SettingSpec.Notifications != null ? this.SettingSpec.Notifications.ToList() : null);
154+
this.Notification = this.Notification ?? (this.InputObject.Notifications != null ? this.InputObject.Notifications.ToList() : null);
154155
}
155156

156157
return new AutoscaleSettingResource(
@@ -161,7 +162,7 @@ private AutoscaleSettingResource CreateAutoscaleSettingResource()
161162
Enabled = enableSetting,
162163
TargetResourceUri = this.TargetResourceId,
163164
Notifications = this.Notification,
164-
Tags = this.SettingSpec != null ? new Dictionary<string, string>(this.SettingSpec.Tags) : new Dictionary<string, string>()
165+
Tags = this.InputObject != null ? new Dictionary<string, string>(this.InputObject.Tags) : new Dictionary<string, string>()
165166
};
166167
}
167168
}

src/ResourceManager/Insights/Commands.Insights/Autoscale/GetAzureRmAutoscaleSettingCommand.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ public class GetAzureRmAutoscaleSettingCommand : ManagementCmdletBase
3737
/// </summary>
3838
[Parameter(ParameterSetName = GetAzureRmAutoscaleSettingParamGroup, Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "The resource group name")]
3939
[ValidateNotNullOrEmpty]
40+
[Alias("ResourceGroup")]
4041
public string ResourceGroupName { get; set; }
4142

4243
/// <summary>
@@ -59,7 +60,7 @@ public class GetAzureRmAutoscaleSettingCommand : ManagementCmdletBase
5960
/// </summary>
6061
protected override void ProcessRecordInternal()
6162
{
62-
WriteWarning("Parameter deprecation: The DetailedOutput parameter will be deprecated in May 2018.");
63+
this.WriteIdentifiedWarning("Parameter deprecation", "The DetailedOutput parameter will be deprecated in May 2018.");
6364
if (string.IsNullOrWhiteSpace(this.Name))
6465
{
6566
// Retrieve all the Autoscale settings for a resource group

0 commit comments

Comments
 (0)