Skip to content

Commit 24f5e86

Browse files
committed
Merge pull request #179 from MabOneSdk/dev1-sudreddy
Cmdlets, Convertors, Provider skeletons for Policy
2 parents c87bd0b + 0dcf616 commit 24f5e86

File tree

11 files changed

+184
-23
lines changed

11 files changed

+184
-23
lines changed

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,28 +26,28 @@ namespace Microsoft.Azure.Commands.RecoveryServices.Backup.Cmdlets
2626
/// <summary>
2727
/// Create new protection policy
2828
/// </summary>
29-
[Cmdlet(VerbsCommon.New, "AzureRmRecoveryServicesProtectionPolicy")]
29+
[Cmdlet(VerbsCommon.New, "AzureRmRecoveryServicesProtectionPolicy"), OutputType(typeof(AzureRmRecoveryServicesPolicyBase))]
3030
public class NewAzureRmRecoveryServicesProtectionPolicy : RecoveryServicesBackupCmdletBase
3131
{
3232
[Parameter(Mandatory = true, HelpMessage = "")]
3333
[ValidateNotNullOrEmpty]
3434
public string Name { get; set; }
3535

36-
[Parameter(Mandatory = true, HelpMessage = "", ValueFromPipeline = true)]
36+
[Parameter(Mandatory = true, HelpMessage = "", ValueFromPipelineByPropertyName = true)]
3737
[ValidateNotNullOrEmpty]
3838
public WorkloadType WorkloadType { get; set; }
3939

40-
[Parameter(Mandatory = false, HelpMessage = "", ValueFromPipeline = true)]
40+
[Parameter(Mandatory = false, HelpMessage = "", ValueFromPipelineByPropertyName = true)]
4141
[ValidateNotNullOrEmpty]
4242
public BackupManagementType BackupManagementType { get; set; }
43-
44-
[Parameter(Mandatory = false, HelpMessage = "", ValueFromPipeline = true)]
43+
44+
[Parameter(Mandatory = false, HelpMessage = "", ValueFromPipelineByPropertyName = true)]
4545
[ValidateNotNullOrEmpty]
4646
public AzureRmRecoveryServicesRetentionPolicyBase RetentionPolicy { get; set; }
4747

48-
[Parameter(Mandatory = false, HelpMessage = "", ValueFromPipeline = true)]
48+
[Parameter(Mandatory = false, HelpMessage = "", ValueFromPipelineByPropertyName = true)]
4949
[ValidateNotNullOrEmpty]
50-
public AzureRmRecoveryServicesSchedulePolicyBase SchedulePolicy { get; set; }
50+
public AzureRmRecoveryServicesSchedulePolicyBase SchedulePolicy { get; set; }
5151

5252
public override void ExecuteCmdlet()
5353
{

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,28 +26,28 @@ namespace Microsoft.Azure.Commands.RecoveryServices.Backup.Cmdlets
2626
/// <summary>
2727
/// Update existing protection policy
2828
/// </summary>
29-
[Cmdlet(VerbsCommon.Set, "AzureRmRecoveryServicesProtectionPolicy")]
29+
[Cmdlet(VerbsCommon.Set, "AzureRmRecoveryServicesProtectionPolicy")]
3030
public class SetAzureRmRecoveryServicesProtectionPolicy : RecoveryServicesBackupCmdletBase
3131
{
3232
[Parameter(Mandatory = true, HelpMessage = "")]
3333
[ValidateNotNullOrEmpty]
3434
public string Name { get; set; }
3535

36-
[Parameter(Mandatory = true, HelpMessage = "", ValueFromPipeline = true)]
36+
[Parameter(Mandatory = true, HelpMessage = "", ValueFromPipelineByPropertyName = true)]
3737
[ValidateNotNullOrEmpty]
3838
public WorkloadType WorkloadType { get; set; }
3939

40-
[Parameter(Mandatory = false, HelpMessage = "", ValueFromPipeline = true)]
40+
[Parameter(Mandatory = false, HelpMessage = "", ValueFromPipelineByPropertyName = true)]
4141
[ValidateNotNullOrEmpty]
4242
public BackupManagementType BackupManagementType { get; set; }
43-
44-
[Parameter(Mandatory = false, HelpMessage = "", ValueFromPipeline = true)]
43+
44+
[Parameter(Mandatory = false, HelpMessage = "", ValueFromPipelineByPropertyName = true)]
4545
[ValidateNotNullOrEmpty]
4646
public AzureRmRecoveryServicesRetentionPolicyBase RetentionPolicy { get; set; }
4747

48-
[Parameter(Mandatory = false, HelpMessage = "", ValueFromPipeline = true)]
48+
[Parameter(Mandatory = false, HelpMessage = "", ValueFromPipelineByPropertyName = true)]
4949
[ValidateNotNullOrEmpty]
50-
public AzureRmRecoveryServicesSchedulePolicyBase SchedulePolicy { get; set; }
50+
public AzureRmRecoveryServicesSchedulePolicyBase SchedulePolicy { get; set; }
5151

5252
public override void ExecuteCmdlet()
5353
{

src/ResourceManager/RecoveryServices.Backup/Commands.RecoveryServices.Backup.Helpers/Commands.RecoveryServices.Backup.Helpers.csproj

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,10 @@
4242
<Reference Include="System.Xml" />
4343
</ItemGroup>
4444
<ItemGroup>
45-
<Compile Include="ConversionHelpers.cs" />
45+
<Compile Include="Validations\PolicyValidations.cs" />
46+
<Compile Include="Conversions\SchedulePolicyConversions.cs" />
47+
<Compile Include="Conversions\RetentionPolicyConversions.cs" />
48+
<Compile Include="Conversions\ConversionHelpers.cs" />
4649
<Compile Include="HydraHelpers.cs" />
4750
<Compile Include="Properties\AssemblyInfo.cs" />
4851
</ItemGroup>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
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.Linq;
17+
using System.Text;
18+
using System.Threading.Tasks;
19+
using System.Collections.Generic;
20+
using Microsoft.Azure.Commands.RecoveryServices.Backup.Cmdlets.Models;
21+
using Microsoft.Azure.Management.RecoveryServices.Backup.Models;
22+
23+
namespace Microsoft.Azure.Commands.RecoveryServices.Backup.Helpers
24+
{
25+
public partial class PolicyHelpers
26+
{
27+
#region HydraToPSObject conversions
28+
public static AzureRmRecoveryServicesLongTermRetentionPolicy GetPSLongTermRetentionPolicy(
29+
LongTermRetentionPolicy hydraRetPolicy)
30+
{
31+
throw new NotImplementedException();
32+
}
33+
34+
#endregion
35+
36+
#region PStoHydraObject conversions
37+
public static LongTermRetentionPolicy GetHydraLongTermRetentionPolicy(
38+
AzureRmRecoveryServicesLongTermRetentionPolicy psRetPolicy)
39+
{
40+
throw new NotImplementedException();
41+
}
42+
43+
#endregion
44+
}
45+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
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.Linq;
17+
using System.Text;
18+
using System.Threading.Tasks;
19+
using System.Collections.Generic;
20+
using Microsoft.Azure.Commands.RecoveryServices.Backup.Cmdlets.Models;
21+
using Microsoft.Azure.Management.RecoveryServices.Backup.Models;
22+
23+
namespace Microsoft.Azure.Commands.RecoveryServices.Backup.Helpers
24+
{
25+
public partial class PolicyHelpers
26+
{
27+
#region HydraToPSObject conversions
28+
29+
public static AzureRmRecoveryServicesSimpleSchedulePolicy GetPSSimpleSchedulePolicyPolicy(
30+
SimpleSchedulePolicy hydraRetPolicy)
31+
{
32+
throw new NotImplementedException();
33+
}
34+
35+
#endregion
36+
37+
#region PStoHydraObject conversions
38+
39+
public static SimpleSchedulePolicy GetHydraSimpleSchedulePolicy(
40+
AzureRmRecoveryServicesSimpleSchedulePolicy psRetPolicy)
41+
{
42+
throw new NotImplementedException();
43+
}
44+
45+
#endregion
46+
}
47+
}

src/ResourceManager/RecoveryServices.Backup/Commands.RecoveryServices.Backup.Helpers/HydraHelpers.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,5 +39,21 @@ public static string GetHydraProviderType(ContainerType containerType)
3939

4040
return providerType;
4141
}
42+
43+
public static string GetHydraProviderType(WorkloadType workloadType)
44+
{
45+
string providerType = string.Empty;
46+
47+
switch (workloadType)
48+
{
49+
case WorkloadType.AzureVM:
50+
providerType = ProviderType.AzureIaasVM.ToString();
51+
break;
52+
default:
53+
break;
54+
}
55+
56+
return providerType;
57+
}
4258
}
4359
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
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.Linq;
17+
using System.Text;
18+
using System.Threading.Tasks;
19+
using System.Collections.Generic;
20+
using Microsoft.Azure.Commands.RecoveryServices.Backup.Cmdlets.Models;
21+
using Microsoft.Azure.Management.RecoveryServices.Backup.Models;
22+
23+
namespace Microsoft.Azure.Commands.RecoveryServices.Backup.Helpers
24+
{
25+
public partial class PolicyHelpers
26+
{
27+
public static void ValidateLongTermRetentionPolicyWithSimpleRetentionPolicy(
28+
AzureRmRecoveryServicesLongTermRetentionPolicy ltrPolicy,
29+
AzureRmRecoveryServicesSimpleSchedulePolicy schPolicy)
30+
{
31+
throw new NotImplementedException();
32+
}
33+
}
34+
}

src/ResourceManager/RecoveryServices.Backup/Commands.RecoveryServices.Backup.Models/CommonModels/Enums.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ public enum BackupManagementType
3131

3232
public enum WorkloadType
3333
{
34+
AzureVM,
3435
}
3536

3637
public enum PsBackupProviderTypes

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,5 +40,9 @@ public interface IPsBackupProvider
4040
ProtectionPolicyResponse CreatePolicy();
4141

4242
ProtectionPolicyResponse ModifyPolicy();
43+
44+
ProtectionPolicyResponse GetPolicy();
45+
46+
void DeletePolicy();
4347
}
4448
}

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

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
using System.Linq;
1818
using System.Text;
1919
using System.Threading.Tasks;
20+
using Microsoft.Azure.Management.RecoveryServices.Backup.Models;
2021

2122
namespace Microsoft.Azure.Commands.RecoveryServices.Backup.Cmdlets.ProviderModel
2223
{
@@ -27,42 +28,52 @@ public void Initialize(ProviderData providerData, HydraAdapter.HydraAdapter hydr
2728
throw new NotImplementedException();
2829
}
2930

30-
public Management.RecoveryServices.Backup.Models.BaseRecoveryServicesJobResponse EnableProtection()
31+
public BaseRecoveryServicesJobResponse EnableProtection()
3132
{
3233
throw new NotImplementedException();
3334
}
3435

35-
public Management.RecoveryServices.Backup.Models.BaseRecoveryServicesJobResponse DisableProtection()
36+
public BaseRecoveryServicesJobResponse DisableProtection()
3637
{
3738
throw new NotImplementedException();
3839
}
3940

40-
public Management.RecoveryServices.Backup.Models.BaseRecoveryServicesJobResponse TriggerBackup()
41+
public BaseRecoveryServicesJobResponse TriggerBackup()
4142
{
4243
throw new NotImplementedException();
4344
}
4445

45-
public Management.RecoveryServices.Backup.Models.BaseRecoveryServicesJobResponse TriggerRestore()
46+
public BaseRecoveryServicesJobResponse TriggerRestore()
4647
{
4748
throw new NotImplementedException();
4849
}
4950

50-
public Management.RecoveryServices.Backup.Models.ProtectedItemResponse GetProtectedItem()
51+
public ProtectedItemResponse GetProtectedItem()
5152
{
5253
throw new NotImplementedException();
5354
}
5455

55-
public Management.RecoveryServices.Backup.Models.RecoveryPointResponse GetRecoveryPoint()
56+
public RecoveryPointResponse GetRecoveryPoint()
5657
{
5758
throw new NotImplementedException();
5859
}
5960

60-
public Management.RecoveryServices.Backup.Models.ProtectionPolicyResponse CreatePolicy()
61+
public ProtectionPolicyResponse CreatePolicy()
6162
{
6263
throw new NotImplementedException();
6364
}
6465

65-
public Management.RecoveryServices.Backup.Models.ProtectionPolicyResponse ModifyPolicy()
66+
public ProtectionPolicyResponse ModifyPolicy()
67+
{
68+
throw new NotImplementedException();
69+
}
70+
71+
public ProtectionPolicyResponse GetPolicy()
72+
{
73+
throw new NotImplementedException();
74+
}
75+
76+
public void DeletePolicy()
6677
{
6778
throw new NotImplementedException();
6879
}

0 commit comments

Comments
 (0)