Skip to content

Commit c3d3675

Browse files
committed
[Insights] Removing hard-coded subId from the TestController, adding parameters to several cmdlets as requested in review feedback.
1 parent 0a67a46 commit c3d3675

File tree

4 files changed

+22
-14
lines changed

4 files changed

+22
-14
lines changed

src/ResourceManager/Insights/Commands.Insights.Test/ScenarioTests/TestsController.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -149,12 +149,10 @@ private void SetupManagementClients(RestTestFramework.MockContext context)
149149
{
150150
if (HttpMockServer.Mode == HttpRecorderMode.Record)
151151
{
152+
// This allows the use of a particular subscription if the user is associated to several
152153
// "TEST_CSM_ORGID_AUTHENTICATION=SubscriptionId=<subscription-id>"
153154
string subId = Environment.GetEnvironmentVariable("TEST_CSM_ORGID_AUTHENTICATION");
154-
subId = string.IsNullOrWhiteSpace(subId) ? "07c0b09d-9f69-4e6e-8d05-f59f67299cb2" : subId.Split('=')[1];
155-
156-
// ;AADTenant=72f988bf-86f1-41af-91ab-2d7cd011db47;[email protected]");
157-
RestTestFramework.TestEnvironment environment = new RestTestFramework.TestEnvironment(connectionString: "SubscriptionId=" + subId);
155+
RestTestFramework.TestEnvironment environment = new RestTestFramework.TestEnvironment(connectionString: subId);
158156
this.MonitorClient = this.GetMonitorClient(context: context, env: environment);
159157
this.MonitorManagementClient = this.GetInsightsManagementClient(context: context, env: environment);
160158
}

src/ResourceManager/Insights/Commands.Insights/ActivityLogAlert/DisableAzureRmActivityLogAlertCommand.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ public class DisableAzureRmActivityLogAlertCommand : ManagementCmdletBase
5050
/// Gets or sets the Tags of the activity log alert resource
5151
/// </summary>
5252
[Parameter(ParameterSetName = DisableActivityLogAlertDeafultParamGroup, Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = "The tags of the activity log alert resource")]
53+
[Parameter(ParameterSetName = DisableActivityLogAlertFromPipeParamGroup, Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = "The tags of the activity log alert resource")]
54+
[Parameter(ParameterSetName = DisableActivityLogAlertFromResourceIdParamGroup, Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = "The tags of the activity log alert resource")]
5355
[ValidateNotNullOrEmpty]
5456
public Dictionary<string, string> Tag { get; set; }
5557

@@ -90,7 +92,7 @@ protected override void ProcessRecordInternal()
9092
resourceGroupName: out resourceGroupName,
9193
activityLogAlertName: out activityLogAlertName);
9294

93-
tags = this.InputObject.Tags;
95+
tags = this.MyInvocation.BoundParameters.ContainsKey("Tag") || this.Tag != null ? this.Tag : this.InputObject.Tags;
9496
}
9597
else if (this.MyInvocation.BoundParameters.ContainsKey("ResourceId") || !string.IsNullOrWhiteSpace(this.ResourceId))
9698
{

src/ResourceManager/Insights/Commands.Insights/ActivityLogAlert/EnableAzureRmActivityLogAlertCommand.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ public class EnableAzureRmActivityLogAlertCommand : ManagementCmdletBase
5050
/// Gets or sets the Tags of the activity log alert resource
5151
/// </summary>
5252
[Parameter(ParameterSetName = EnableActivityLogAlertDeafultParamGroup, Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = "The tags of the activity log alert resource")]
53+
[Parameter(ParameterSetName = EnableActivityLogAlertFromPipeParamGroup, Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = "The tags of the activity log alert resource")]
54+
[Parameter(ParameterSetName = EnableActivityLogAlertFromResourceIdParamGroup, Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = "The tags of the activity log alert resource")]
5355
[ValidateNotNullOrEmpty]
5456
public Dictionary<string, string> Tag { get; set; }
5557

@@ -90,7 +92,7 @@ protected override void ProcessRecordInternal()
9092
resourceGroupName: out resourceGroupName,
9193
activityLogAlertName: out activityLogAlertName);
9294

93-
tags = this.InputObject.Tags;
95+
tags = this.MyInvocation.BoundParameters.ContainsKey("Tag") || this.Tag != null ? this.Tag : this.InputObject.Tags;
9496
}
9597
else if (this.MyInvocation.BoundParameters.ContainsKey("ResourceId") || !string.IsNullOrWhiteSpace(this.ResourceId))
9698
{

src/ResourceManager/Insights/Commands.Insights/ActivityLogAlert/SetAzureRmActivityLogAlertCommand.cs

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,45 +35,45 @@ public class SetAzureRmActivityLogAlertCommand : ManagementCmdletBase
3535
/// <summary>
3636
/// Gets or sets the Location parameter of the cmdlet
3737
/// </summary>
38-
[Parameter(ParameterSetName = SetActivityLogAlertDefaultParamGroup, Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "The location of the activity log rule resource")]
38+
[Parameter(ParameterSetName = SetActivityLogAlertDefaultParamGroup, Mandatory = true, ValueFromPipeline = true, HelpMessage = "The location of the activity log rule resource")]
3939
[Parameter(ParameterSetName = SetActivityLogAlertFromResourceIdParamGroup, Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = "The location of the activity log rule resource")]
4040
[ValidateNotNullOrEmpty]
4141
public string Location { get; set; }
4242

4343
/// <summary>
4444
/// Gets or sets the alert name parameter of the cmdlet
4545
/// </summary>
46-
[Parameter(ParameterSetName = SetActivityLogAlertDefaultParamGroup, Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "The activity log rule name")]
46+
[Parameter(ParameterSetName = SetActivityLogAlertDefaultParamGroup, Mandatory = true, ValueFromPipeline = true, HelpMessage = "The activity log rule name")]
4747
[ValidateNotNullOrEmpty]
4848
public string Name { get; set; }
4949

5050
/// <summary>
5151
/// Gets or set the resource group name
5252
/// </summary>
53-
[Parameter(ParameterSetName = SetActivityLogAlertDefaultParamGroup, Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "The resource group name of the activity log rule resource")]
53+
[Parameter(ParameterSetName = SetActivityLogAlertDefaultParamGroup, Mandatory = true, ValueFromPipeline = true, HelpMessage = "The resource group name of the activity log rule resource")]
5454
[ValidateNotNullOrEmpty]
5555
public string ResourceGroupName { get; set; }
5656

5757
/// <summary>
5858
/// Gets or sets the scopes of the activity log alert
5959
/// </summary>
60-
[Parameter(ParameterSetName = SetActivityLogAlertDefaultParamGroup, Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "The list scopes")]
60+
[Parameter(ParameterSetName = SetActivityLogAlertDefaultParamGroup, Mandatory = true, ValueFromPipeline = true, HelpMessage = "The list scopes")]
6161
[Parameter(ParameterSetName = SetActivityLogAlertFromResourceIdParamGroup, Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = "The list scopes")]
6262
[ValidateNotNullOrEmpty]
6363
public List<string> Scope { get; set; }
6464

6565
/// <summary>
6666
/// Gets or sets the conditions of the activity log alert
6767
/// </summary>
68-
[Parameter(ParameterSetName = SetActivityLogAlertDefaultParamGroup, Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "The list of leaf conditions of the activity log alert")]
68+
[Parameter(ParameterSetName = SetActivityLogAlertDefaultParamGroup, Mandatory = true, ValueFromPipeline = true, HelpMessage = "The list of leaf conditions of the activity log alert")]
6969
[Parameter(ParameterSetName = SetActivityLogAlertFromResourceIdParamGroup, Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = "The list of leaf conditions of the activity log alert")]
7070
[ValidateNotNullOrEmpty]
7171
public List<ActivityLogAlertLeafCondition> Condition { get; set; }
7272

7373
/// <summary>
7474
/// Gets or sets the actions of the activity log alert
7575
/// </summary>
76-
[Parameter(ParameterSetName = SetActivityLogAlertDefaultParamGroup, Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "The list actions of the activity log alert")]
76+
[Parameter(ParameterSetName = SetActivityLogAlertDefaultParamGroup, Mandatory = true, ValueFromPipeline = true, HelpMessage = "The list actions of the activity log alert")]
7777
[Parameter(ParameterSetName = SetActivityLogAlertFromResourceIdParamGroup, Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = "The list actions of the activity log alert")]
7878
[ValidateNotNullOrEmpty]
7979
public List<ActivityLogAlertActionGroup> Action { get; set; }
@@ -89,15 +89,17 @@ public class SetAzureRmActivityLogAlertCommand : ManagementCmdletBase
8989
/// <summary>
9090
/// Gets or set the alert description
9191
/// </summary>
92-
[Parameter(ParameterSetName = SetActivityLogAlertDefaultParamGroup, Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = "The description of the activity log rule resource")]
92+
[Parameter(ParameterSetName = SetActivityLogAlertDefaultParamGroup, Mandatory = false, ValueFromPipeline = true, HelpMessage = "The description of the activity log rule resource")]
93+
[Parameter(ParameterSetName = SetActivityLogAlertFromPipeParamGroup, Mandatory = false, ValueFromPipeline = true, HelpMessage = "The description of the activity log rule resource")]
9394
[Parameter(ParameterSetName = SetActivityLogAlertFromResourceIdParamGroup, Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = "The description of the activity log rule resource")]
9495
[ValidateNotNullOrEmpty]
9596
public string Description { get; set; }
9697

9798
/// <summary>
9899
/// Gets or sets the Tags of the activity log alert resource
99100
/// </summary>
100-
[Parameter(ParameterSetName = SetActivityLogAlertDefaultParamGroup, Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = "The tags of the activity log alert resource")]
101+
[Parameter(ParameterSetName = SetActivityLogAlertDefaultParamGroup, Mandatory = false, ValueFromPipeline = true, HelpMessage = "The tags of the activity log alert resource")]
102+
[Parameter(ParameterSetName = SetActivityLogAlertFromPipeParamGroup, Mandatory = false, ValueFromPipeline = true, HelpMessage = "The tags of the activity log alert resource")]
101103
[Parameter(ParameterSetName = SetActivityLogAlertFromResourceIdParamGroup, Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = "The tags of the activity log alert resource")]
102104
[ValidateNotNullOrEmpty]
103105
public Dictionary<string, string> Tag { get; set; }
@@ -142,6 +144,10 @@ protected override void ProcessRecordInternal()
142144
activityLogAlertName: out activityLogAlertName);
143145

144146
requestBody = this.InputObject;
147+
if (this.MyInvocation.BoundParameters.ContainsKey("Tag") || this.Tag != null)
148+
{
149+
requestBody.Tags = this.Tag;
150+
}
145151
}
146152
else if (this.MyInvocation.BoundParameters.ContainsKey("ResourceId") || !string.IsNullOrWhiteSpace(this.ResourceId))
147153
{

0 commit comments

Comments
 (0)