Skip to content

Commit 320ae4f

Browse files
committed
Merge pull request #230 from MabOneSdk/pragrawa-dev1
Addinng positions to ps params
2 parents db51176 + 99cbcf4 commit 320ae4f

File tree

4 files changed

+37
-20
lines changed

4 files changed

+37
-20
lines changed

src/ResourceManager/RecoveryServices.Backup/Cmdlets/Item/DisableAzureRmRecoveryServicesProtection.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,11 @@ namespace Microsoft.Azure.Commands.RecoveryServices.Backup.Cmdlets
3333
[Cmdlet(VerbsLifecycle.Disable, "AzureRmRecoveryServicesProtection"), OutputType(typeof(AzureRmRecoveryServicesJobBase))]
3434
public class DisableAzureRmRecoveryServicesProtection : RecoveryServicesBackupCmdletBase
3535
{
36-
[Parameter(Mandatory = true, HelpMessage = ParamHelpMsg.Item.ProtectedItem, ValueFromPipeline = true)]
36+
[Parameter(Position = 1, Mandatory = true, HelpMessage = ParamHelpMsg.Item.ProtectedItem, ValueFromPipeline = true)]
3737
[ValidateNotNullOrEmpty]
3838
public AzureRmRecoveryServicesItemBase Item { get; set; }
3939

40-
[Parameter(Position = 1, Mandatory = false, HelpMessage = ParamHelpMsg.Item.RemoveProtectionOption)]
40+
[Parameter(Position = 2, Mandatory = false, HelpMessage = ParamHelpMsg.Item.RemoveProtectionOption)]
4141
public SwitchParameter RemoveRecoveryPoints
4242
{
4343
get { return DeleteBackupData; }

src/ResourceManager/RecoveryServices.Backup/Cmdlets/Item/EnableAzureRmRecoveryServicesProtection.cs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -37,28 +37,28 @@ public class EnableAzureRmRecoveryServicesProtection : RecoveryServicesBackupCmd
3737
internal const string AzureVMComputeParameterSet = "AzureVMComputeEnableProtection";
3838
internal const string ModifyProtectionParameterSet = "ModifyProtection";
3939

40-
[Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true, ParameterSetName = AzureVMClassicComputeParameterSet, HelpMessage = ParamHelpMsg.Item.AzureVMName)]
40+
[Parameter(Position = 1, Mandatory = true, HelpMessage = ParamHelpMsg.Policy.ProtectionPolicy)]
41+
[ValidateNotNullOrEmpty]
42+
public AzureRmRecoveryServicesPolicyBase Policy { get; set; }
43+
44+
[Parameter(Position = 2, Mandatory = true, ParameterSetName = ModifyProtectionParameterSet, HelpMessage = ParamHelpMsg.Item.ProtectedItem, ValueFromPipeline = true)]
45+
[ValidateNotNullOrEmpty]
46+
public AzureRmRecoveryServicesItemBase Item { get; set; }
47+
48+
[Parameter(Position = 2, Mandatory = true, ValueFromPipelineByPropertyName = true, ParameterSetName = AzureVMClassicComputeParameterSet, HelpMessage = ParamHelpMsg.Item.AzureVMName)]
4149
[Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true, ParameterSetName = AzureVMComputeParameterSet, HelpMessage = ParamHelpMsg.Item.AzureVMName)]
4250
public string Name { get; set; }
4351

44-
[Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true, ParameterSetName = AzureVMClassicComputeParameterSet, HelpMessage = ParamHelpMsg.Item.AzureVMServiceName)]
52+
[Parameter(Position = 3, Mandatory = true, ValueFromPipelineByPropertyName = true, ParameterSetName = AzureVMClassicComputeParameterSet, HelpMessage = ParamHelpMsg.Item.AzureVMServiceName)]
4553
public string ServiceName { get; set; }
4654

47-
[Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true, ParameterSetName = AzureVMComputeParameterSet, HelpMessage = ParamHelpMsg.Item.AzureVMResourceGroupName)]
55+
[Parameter(Position = 3, Mandatory = true, ValueFromPipelineByPropertyName = true, ParameterSetName = AzureVMComputeParameterSet, HelpMessage = ParamHelpMsg.Item.AzureVMResourceGroupName)]
4856
public string ResourceGroupName { get; set; }
4957

50-
[Parameter(Mandatory = true, ParameterSetName = AzureVMClassicComputeParameterSet, HelpMessage = ParamHelpMsg.Common.WorkloadType)]
51-
[Parameter(Mandatory = true, ParameterSetName = AzureVMComputeParameterSet, HelpMessage = ParamHelpMsg.Common.WorkloadType)]
58+
[Parameter(Position = 4, Mandatory = true, ParameterSetName = AzureVMClassicComputeParameterSet, HelpMessage = ParamHelpMsg.Common.WorkloadType)]
59+
[Parameter(Position = 4, Mandatory = true, ParameterSetName = AzureVMComputeParameterSet, HelpMessage = ParamHelpMsg.Common.WorkloadType)]
5260
public WorkloadType WorkLoadType { get; set; }
5361

54-
[Parameter(Mandatory = true, HelpMessage = ParamHelpMsg.Policy.ProtectionPolicy)]
55-
[ValidateNotNullOrEmpty]
56-
public AzureRmRecoveryServicesPolicyBase Policy { get; set; }
57-
58-
[Parameter(Mandatory = true, ParameterSetName = ModifyProtectionParameterSet, HelpMessage = ParamHelpMsg.Item.ProtectedItem, ValueFromPipeline = true)]
59-
[ValidateNotNullOrEmpty]
60-
public AzureRmRecoveryServicesItemBase Item { get; set; }
61-
6262
public override void ExecuteCmdlet()
6363
{
6464
ExecutionBlock(() =>

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

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,21 +29,37 @@ namespace Microsoft.Azure.Commands.RecoveryServices.Backup.Cmdlets
2929
/// <summary>
3030
/// Update existing protection policy
3131
/// </summary>
32-
[Cmdlet(VerbsCommon.Remove, "AzureRmRecoveryServicesProtectionPolicy")]
32+
[Cmdlet(VerbsCommon.Remove, "AzureRmRecoveryServicesProtectionPolicy", DefaultParameterSetName = PolicyNameParameterSet)]
3333
public class RemoveAzureRmRecoveryServicesProtectionPolicy : RecoveryServicesBackupCmdletBase
3434
{
35-
[Parameter(Position = 1, Mandatory = true, HelpMessage = ParamHelpMsg.Policy.ProtectionPolicy, ValueFromPipeline = true)]
35+
internal const string PolicyNameParameterSet = "PolicyName";
36+
internal const string PolicyObjectParameterSet = "PolicyObject";
37+
38+
[Parameter(Position = 1, Mandatory = true, HelpMessage = ParamHelpMsg.Policy.Name, ValueFromPipeline = true,
39+
ParameterSetName = PolicyNameParameterSet)]
40+
[ValidateNotNullOrEmpty]
41+
public string Name { get; set; }
42+
43+
[Parameter(Position = 1, Mandatory = true, HelpMessage = ParamHelpMsg.Policy.ProtectionPolicy, ValueFromPipeline = true,
44+
ParameterSetName = PolicyObjectParameterSet)]
3645
[ValidateNotNullOrEmpty]
3746
public AzureRmRecoveryServicesPolicyBase Policy { get; set; }
3847

3948
[Parameter(Mandatory = false, HelpMessage = ParamHelpMsg.Common.ConfirmationMessage)]
4049
public SwitchParameter Force { get; set; }
4150

51+
private string PolicyName = string.Empty;
52+
4253
public override void ExecuteCmdlet()
4354
{
55+
PolicyName = (this.ParameterSetName == PolicyNameParameterSet) ? Name : Policy.Name;
56+
if(string.IsNullOrEmpty(PolicyName))
57+
{
58+
throw new ArgumentException(Resources.PolicyNameIsEmptyOrNull);
59+
}
4460
ConfirmAction(
4561
Force.IsPresent,
46-
string.Format(Resources.RemoveProtectionPolicyWarning, Policy.Name),
62+
string.Format(Resources.RemoveProtectionPolicyWarning, PolicyName),
4763
Resources.RemoveProtectionPolicyMessage,
4864
Policy.Name, () =>
4965
{
@@ -53,7 +69,7 @@ public override void ExecuteCmdlet()
5369

5470
WriteDebug(Resources.MakingClientCall);
5571

56-
HydraAdapter.RemoveProtectionPolicy(Policy.Name);
72+
HydraAdapter.RemoveProtectionPolicy(PolicyName);
5773
WriteDebug(Resources.ProtectionPolicyDeleted);
5874
});
5975

src/ResourceManager/RecoveryServices.Backup/Commands.RecoveryServices.Backup.Providers/Providers/IaasVmPsBackupProvider.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -824,6 +824,7 @@ private HttpStatusCode TrackRefreshContainerOperation(string operationResultLink
824824
catch (Exception ex)
825825
{
826826
Logger.Instance.WriteDebug(ex.Message);
827+
status = HttpStatusCode.InternalServerError;
827828
break;
828829
}
829830
}
@@ -834,7 +835,7 @@ private HttpStatusCode TrackRefreshContainerOperation(string operationResultLink
834835
}
835836
else
836837
{
837-
string msg = String.Format("Unexpected http status in response header{ {0}", status);
838+
string msg = String.Format("Unexpected http status in response header {0}", status);
838839
Logger.Instance.WriteDebug(msg);
839840
throw new Exception(msg);
840841
}

0 commit comments

Comments
 (0)