Skip to content

Commit c0cc783

Browse files
committed
minor validation fix in policy cmdlet
1 parent b332ee4 commit c0cc783

File tree

5 files changed

+45
-2
lines changed

5 files changed

+45
-2
lines changed

src/ResourceManager/RecoveryServices.Backup/Cmdlets/ProtectionPolicy/PolicyCmdletHelpers.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,11 @@ public class PolicyCmdletHelpers
3333

3434
public static void ValidateProtectionPolicyName(string policyName)
3535
{
36+
if(string.IsNullOrEmpty(policyName))
37+
{
38+
throw new ArgumentException(Resources.PolicyNameIsEmptyOrNull);
39+
}
40+
3641
if (policyName.Length < PolicyConstants.MinPolicyNameLength ||
3742
policyName.Length > PolicyConstants.MaxPolicyNameLength)
3843
{

src/ResourceManager/RecoveryServices.Backup/Commands.RecoveryServices.Backup.Helpers/Conversions/ConversionHelpers.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ public static AzureRmRecoveryServicesPolicyBase GetPolicyModel(ProtectionPolicyR
111111
}
112112

113113
policyModel.Name = hydraResponse.Name;
114+
policyModel.Id = hydraResponse.Id;
114115

115116
return policyModel;
116117
}

src/ResourceManager/RecoveryServices.Backup/Commands.RecoveryServices.Backup.Models/BaseObjects.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
using System;
1616
using System.Collections.Generic;
1717
using Microsoft.Azure.Management.RecoveryServices.Backup.Models;
18+
using Microsoft.Azure.Commands.RecoveryServices.Backup.Properties;
1819

1920
namespace Microsoft.Azure.Commands.RecoveryServices.Backup.Cmdlets.Models
2021
{
@@ -172,9 +173,21 @@ public class AzureRmRecoveryServicesPolicyBase : AzureRmRecoveryServicesBackupMa
172173

173174
public WorkloadType WorkloadType { get; set; }
174175

176+
public string Id { get; set; }
177+
175178
public override void Validate()
176179
{
177180
base.Validate();
181+
182+
if(string.IsNullOrEmpty(Name))
183+
{
184+
throw new ArgumentException(Resources.PolicyNameIsEmptyOrNull);
185+
}
186+
187+
if(string.IsNullOrEmpty(Id))
188+
{
189+
throw new ArgumentException(Resources.PolicyIdIsEmptyOrNull);
190+
}
178191
}
179192
}
180193

src/ResourceManager/RecoveryServices.Backup/Commands.RecoveryServices.Backup.Models/Properties/Resources.Designer.cs

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

src/ResourceManager/RecoveryServices.Backup/Commands.RecoveryServices.Backup.Models/Properties/Resources.resx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -350,4 +350,10 @@ Please contact Microsoft for further assistant.</value>
350350
<data name="DisableProtectionOperationFailed" xml:space="preserve">
351351
<value>Disable Protection OperationFailed with error code {0} , and error Message {1}</value>
352352
</data>
353+
<data name="PolicyIdIsEmptyOrNull" xml:space="preserve">
354+
<value>PolicyId is NULL or Empty. Please enter valid PolicyId</value>
355+
</data>
356+
<data name="PolicyNameIsEmptyOrNull" xml:space="preserve">
357+
<value>PolicyName is NULL or Empty. Please enter valid PolicyName</value>
358+
</data>
353359
</root>

0 commit comments

Comments
 (0)