Skip to content

Commit 8bba930

Browse files
author
Mahak Jain
committed
Moved customer facing strinsg to resources
1 parent be04c36 commit 8bba930

File tree

9 files changed

+378
-48
lines changed

9 files changed

+378
-48
lines changed

src/AlertsManagement/AlertsManagement/ActionRuleCommands/RemoveAzureActionRule.cs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
using System.Management.Automation;
1919
using Microsoft.Azure.Commands.AlertsManagement.OutputModels;
2020
using Microsoft.Azure.Management.AlertsManagement.Models;
21+
using Microsoft.Azure.PowerShell.Cmdlets.AlertsManagement.Properties;
2122

2223
namespace Microsoft.Azure.Commands.AlertsManagement
2324
{
@@ -86,8 +87,8 @@ protected override void ProcessRecordInternal()
8687
{
8788
case ByResourceIdParameterSet:
8889
if (ShouldProcess(
89-
target: string.Format("Remove the action rule: {0}", ResourceId),
90-
action: "Remove the action rule"))
90+
target: string.Format(Resources.Target, this.ResourceId),
91+
action: Resources.RemoveActionRule_Action))
9192
{
9293
var extractedInfo = CommonUtils.ExtractFromActionRuleResourceId(ResourceId);
9394
isDeleted = this.AlertsManagementClient.ActionRules.DeleteWithHttpMessagesAsync(
@@ -104,8 +105,8 @@ protected override void ProcessRecordInternal()
104105

105106
case ByInputObjectParameterSet:
106107
if (ShouldProcess(
107-
target: string.Format("Remove the action rule: {0}", InputObject.Id),
108-
action: "Remove an action rule"))
108+
target: string.Format(Resources.Target, this.InputObject.Id),
109+
action: Resources.RemoveActionRule_Action))
109110
{
110111
var extractedInfo = CommonUtils.ExtractFromActionRuleResourceId(InputObject.Id);
111112
isDeleted = this.AlertsManagementClient.ActionRules.DeleteWithHttpMessagesAsync(
@@ -123,8 +124,8 @@ protected override void ProcessRecordInternal()
123124

124125
case ByNameParameterSet:
125126
if (ShouldProcess(
126-
target: string.Format("Remove the action rule: {0} from resource group: {1}", this.Name, this.ResourceGroupName),
127-
action: "Remove an action rule"))
127+
target: string.Format(Resources.TargetWithRG, this.Name, this.ResourceGroupName),
128+
action: Resources.RemoveActionRule_Action))
128129
{
129130
isDeleted = this.AlertsManagementClient.ActionRules.DeleteWithHttpMessagesAsync(
130131
resourceGroupName: ResourceGroupName,

src/AlertsManagement/AlertsManagement/ActionRuleCommands/SetAzureActionRule.cs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
using Microsoft.Azure.Commands.AlertsManagement.OutputModels;
2121
using Microsoft.Azure.Management.AlertsManagement.Models;
2222
using Newtonsoft.Json;
23+
using Microsoft.Azure.PowerShell.Cmdlets.AlertsManagement.Properties;
2324

2425
namespace Microsoft.Azure.Commands.AlertsManagement
2526
{
@@ -305,16 +306,15 @@ protected override void ProcessRecordInternal()
305306
{
306307
PSActionRule actionRule = new PSActionRule();
307308
if (ShouldProcess(
308-
target: string.Format("Create new Action Rule"),
309-
action: "Create the action rule"))
309+
target: string.Format(Resources.TargetWithRG, this.Name, this.ResourceGroupName),
310+
action: Resources.CreateOrUpdateActionRule_Action))
310311
{
311312
switch (ParameterSetName)
312313
{
313314
case BySimplifiedFormatActionGroupActionRuleParameterSet:
314315
if (ActionRuleType != "ActionGroup")
315316
{
316-
throw new PSInvalidOperationException("Incorrect Action Rule Type for given set of parameters. +" +
317-
"Use ActionGroup type for this parameter set.");
317+
throw new PSInvalidOperationException(string.Format(Resources.IncorrectActionRuleType_Exception, "ActionGroup"));
318318
}
319319

320320
// Create Action Rule
@@ -338,8 +338,7 @@ protected override void ProcessRecordInternal()
338338

339339
if (ActionRuleType != "Suppression")
340340
{
341-
throw new PSInvalidOperationException("Incorrect Action Rule Type for given set of parameters. +" +
342-
"Use Suppression type for this parameter set.");
341+
throw new PSInvalidOperationException(string.Format(Resources.IncorrectActionRuleType_Exception, "Suppression"));
343342
}
344343

345344
SuppressionConfig config = new SuppressionConfig(recurrenceType: ReccurenceType);
@@ -378,8 +377,7 @@ protected override void ProcessRecordInternal()
378377
case BySimplifiedFormatDiagnosticsActionRuleParameterSet:
379378
if (ActionRuleType != "Diagnostics")
380379
{
381-
throw new PSInvalidOperationException("Incorrect Action Rule Type for given set of parameters. +" +
382-
"Use Diagnostics type for this parameter set.");
380+
throw new PSInvalidOperationException(string.Format(Resources.IncorrectActionRuleType_Exception, "Diagnostics"));
383381
}
384382

385383
// Create Action Rule

src/AlertsManagement/AlertsManagement/ActionRuleCommands/UpdateAzureActionRule.cs

Lines changed: 35 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
using Microsoft.Azure.Management.AlertsManagement.Models;
2121
using Newtonsoft.Json;
2222
using System.Collections;
23+
using Microsoft.Azure.PowerShell.Cmdlets.AlertsManagement.Properties;
2324

2425
namespace Microsoft.Azure.Commands.AlertsManagement
2526
{
@@ -85,26 +86,31 @@ public class UpdateAzureActionRule : AlertsManagementBaseCmdlet
8586
#endregion
8687

8788
protected override void ProcessRecordInternal()
88-
{
89-
if (ShouldProcess(
90-
target: string.Format("Update Action rule (status/tags)"),
91-
action: "Update Action rule"))
89+
{
90+
PSActionRule updatedActionRule = new PSActionRule();
91+
switch (ParameterSetName)
9292
{
93-
PSActionRule updatedActionRule = new PSActionRule();
94-
switch (ParameterSetName)
95-
{
96-
case ByNameSimplifiedPatchParameterSet:
93+
case ByNameSimplifiedPatchParameterSet:
94+
if (ShouldProcess(
95+
target: string.Format(Resources.TargetWithRG, this.Name, this.ResourceGroupName),
96+
action: Resources.CreateOrUpdateActionRule_Action))
97+
{
9798
updatedActionRule = new PSActionRule(this.AlertsManagementClient.ActionRules.UpdateWithHttpMessagesAsync(
98-
resourceGroupName: ResourceGroupName,
99-
actionRuleName: Name,
100-
actionRulePatch: new PatchObject(
101-
status: Status,
102-
tags: Tag
103-
)
104-
).Result.Body);
105-
break;
99+
resourceGroupName: ResourceGroupName,
100+
actionRuleName: Name,
101+
actionRulePatch: new PatchObject(
102+
status: Status,
103+
tags: Tag
104+
)
105+
).Result.Body);
106+
}
107+
break;
106108

107-
case ByInputObjectParameterSet:
109+
case ByInputObjectParameterSet:
110+
if (ShouldProcess(
111+
target: string.Format(Resources.Target, this.InputObject.Id),
112+
action: Resources.CreateOrUpdateActionRule_Action))
113+
{
108114
var extractedInfo = CommonUtils.ExtractFromActionRuleResourceId(InputObject.Id);
109115
updatedActionRule = new PSActionRule(this.AlertsManagementClient.ActionRules.UpdateWithHttpMessagesAsync(
110116
resourceGroupName: extractedInfo.ResourceGroupName,
@@ -114,10 +120,15 @@ protected override void ProcessRecordInternal()
114120
tags: Tag
115121
)
116122
).Result.Body);
117-
break;
123+
}
124+
break;
118125

119-
case ByResourceIdParameterSet:
120-
var info = CommonUtils.ExtractFromActionRuleResourceId(InputObject.Id);
126+
case ByResourceIdParameterSet:
127+
if (ShouldProcess(
128+
target: string.Format(Resources.Target, this.ResourceId),
129+
action: Resources.CreateOrUpdateActionRule_Action))
130+
{
131+
var info = CommonUtils.ExtractFromActionRuleResourceId(ResourceId);
121132
updatedActionRule = new PSActionRule(this.AlertsManagementClient.ActionRules.UpdateWithHttpMessagesAsync(
122133
resourceGroupName: info.ResourceGroupName,
123134
actionRuleName: info.Resource,
@@ -126,11 +137,11 @@ protected override void ProcessRecordInternal()
126137
tags: Tag
127138
)
128139
).Result.Body);
129-
break;
130-
}
131-
132-
WriteObject(sendToPipeline: updatedActionRule);
140+
}
141+
break;
133142
}
143+
144+
WriteObject(sendToPipeline: updatedActionRule);
134145
}
135146
}
136147
}

src/AlertsManagement/AlertsManagement/AlertCommands/UpdateAzureAlertState.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
using System.Management.Automation;
1919
using Microsoft.Azure.Commands.AlertsManagement.OutputModels;
2020
using Microsoft.Azure.Management.AlertsManagement.Models;
21+
using Microsoft.Azure.PowerShell.Cmdlets.AlertsManagement.Properties;
2122

2223
namespace Microsoft.Azure.Commands.AlertsManagement
2324
{
@@ -70,8 +71,8 @@ public class UpdateAzureAlertState : AlertsManagementBaseCmdlet
7071
protected override void ProcessRecordInternal()
7172
{
7273
if (ShouldProcess(
73-
target: string.Format("Update alert state to {0}", State),
74-
action: "Update Alert state"))
74+
target: string.Format(Resources.Target, string.IsNullOrWhiteSpace(AlertId) ? InputObject.Id : AlertId),
75+
action: Resources.UpdateAlertState_Action))
7576
{
7677
string id = AlertId;
7778
switch (ParameterSetName)
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// ----------------------------------------------------------------------------------
2+
//
3+
// Copyright Microsoft Corporation
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
// Unless required by applicable law or agreed to in writing, software
9+
// distributed under the License is distributed on an "AS IS" BASIS,
10+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
// See the License for the specific language governing permissions and
12+
// limitations under the License.
13+
// ----------------------------------------------------------------------------------
14+
15+
using System;
16+
using System.Reflection;
17+
using System.Runtime.InteropServices;
18+
19+
[assembly: AssemblyTitle("Microsoft Azure Powershell - AlertsManagement Commands")]
20+
[assembly: AssemblyCompany(Microsoft.WindowsAzure.Commands.Common.AzurePowerShell.AssemblyCompany)]
21+
[assembly: AssemblyProduct(Microsoft.WindowsAzure.Commands.Common.AzurePowerShell.AssemblyProduct)]
22+
[assembly: AssemblyCopyright(Microsoft.WindowsAzure.Commands.Common.AzurePowerShell.AssemblyCopyright)]
23+
24+
[assembly: ComVisible(false)]
25+
[assembly: CLSCompliant(false)]
26+
[assembly: Guid("4381ecdd-5486-46fb-bef0-c0b2fb16bd54")]
27+
[assembly: AssemblyVersion("0.1.0")]
28+
[assembly: AssemblyFileVersion("0.1.0")]

src/AlertsManagement/AlertsManagement/Properties/Resources.Designer.cs

Lines changed: 135 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)