Skip to content

Commit 1bc5cb1

Browse files
committed
Merge pull request AzureRT#175 from MabOneSdk/dev1-sudreddy
added placeholders for policy cmdlets and minor updates to policy objects
2 parents b68e403 + ec7fd57 commit 1bc5cb1

File tree

10 files changed

+344
-238
lines changed

10 files changed

+344
-238
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
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 System.Management.Automation;
21+
using Microsoft.Azure.Commands.RecoveryServices.Backup.Cmdlets.Models;
22+
using Microsoft.Azure.Commands.RecoveryServices.Backup.Cmdlets.ProviderModel;
23+
24+
namespace Microsoft.Azure.Commands.RecoveryServices.Backup.Cmdlets
25+
{
26+
/// <summary>
27+
/// Get list of protection policies
28+
/// </summary>
29+
[Cmdlet(VerbsCommon.Get, "AzureRmRecoveryServicesProtectionPolicy"), OutputType(typeof(AzureRmRecoveryServicesPolicyBase), typeof(List<AzureRmRecoveryServicesPolicyBase>))]
30+
public class GetAzureRmRecoveryServicesProtectionPolicy : RecoveryServicesBackupCmdletBase
31+
{
32+
[Parameter(Mandatory = true, HelpMessage = "")]
33+
[ValidateNotNullOrEmpty]
34+
public string Name { get; set; }
35+
36+
public override void ExecuteCmdlet()
37+
{
38+
base.ExecuteCmdlet();
39+
40+
PsBackupProviderManager providerManager = new PsBackupProviderManager(new Dictionary<System.Enum, object>()
41+
{
42+
{GetContainerParams.Name, Name},
43+
}, HydraAdapter);
44+
45+
IPsBackupProvider psBackupProvider = providerManager.GetProviderInstance(ContainerType.AzureVM);
46+
}
47+
}
48+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
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 System.Management.Automation;
21+
using Microsoft.Azure.Commands.RecoveryServices.Backup.Cmdlets.Models;
22+
using Microsoft.Azure.Commands.RecoveryServices.Backup.Cmdlets.ProviderModel;
23+
24+
namespace Microsoft.Azure.Commands.RecoveryServices.Backup.Cmdlets
25+
{
26+
/// <summary>
27+
/// Create new protection policy
28+
/// </summary>
29+
[Cmdlet(VerbsCommon.New, "AzureRmRecoveryServicesProtectionPolicy")]
30+
public class NewAzureRmRecoveryServicesProtectionPolicy : RecoveryServicesBackupCmdletBase
31+
{
32+
[Parameter(Mandatory = true, HelpMessage = "")]
33+
[ValidateNotNullOrEmpty]
34+
public string Name { get; set; }
35+
36+
[Parameter(Mandatory = true, HelpMessage = "", ValueFromPipeline = true)]
37+
[ValidateNotNullOrEmpty]
38+
public WorkloadType WorkloadType { get; set; }
39+
40+
[Parameter(Mandatory = false, HelpMessage = "", ValueFromPipeline = true)]
41+
[ValidateNotNullOrEmpty]
42+
public BackupManagementType BackupManagementType { get; set; }
43+
44+
[Parameter(Mandatory = false, HelpMessage = "", ValueFromPipeline = true)]
45+
[ValidateNotNullOrEmpty]
46+
public AzureRmRecoveryServicesRetentionPolicyBase RetentionPolicy { get; set; }
47+
48+
[Parameter(Mandatory = false, HelpMessage = "", ValueFromPipeline = true)]
49+
[ValidateNotNullOrEmpty]
50+
public AzureRmRecoveryServicesSchedulePolicyBase SchedulePolicy { get; set; }
51+
52+
public override void ExecuteCmdlet()
53+
{
54+
base.ExecuteCmdlet();
55+
56+
PsBackupProviderManager providerManager = new PsBackupProviderManager(new Dictionary<System.Enum, object>()
57+
{
58+
{GetContainerParams.Name, Name},
59+
}, HydraAdapter);
60+
61+
IPsBackupProvider psBackupProvider = providerManager.GetProviderInstance(ContainerType.AzureVM);
62+
}
63+
}
64+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
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 System.Management.Automation;
21+
using Microsoft.Azure.Commands.RecoveryServices.Backup.Cmdlets.Models;
22+
using Microsoft.Azure.Commands.RecoveryServices.Backup.Cmdlets.ProviderModel;
23+
24+
namespace Microsoft.Azure.Commands.RecoveryServices.Backup.Cmdlets
25+
{
26+
/// <summary>
27+
/// Update existing protection policy
28+
/// </summary>
29+
[Cmdlet(VerbsCommon.Set, "AzureRmRecoveryServicesProtectionPolicy")]
30+
public class SetAzureRmRecoveryServicesProtectionPolicy : RecoveryServicesBackupCmdletBase
31+
{
32+
[Parameter(Mandatory = true, HelpMessage = "")]
33+
[ValidateNotNullOrEmpty]
34+
public string Name { get; set; }
35+
36+
[Parameter(Mandatory = true, HelpMessage = "", ValueFromPipeline = true)]
37+
[ValidateNotNullOrEmpty]
38+
public WorkloadType WorkloadType { get; set; }
39+
40+
[Parameter(Mandatory = false, HelpMessage = "", ValueFromPipeline = true)]
41+
[ValidateNotNullOrEmpty]
42+
public BackupManagementType BackupManagementType { get; set; }
43+
44+
[Parameter(Mandatory = false, HelpMessage = "", ValueFromPipeline = true)]
45+
[ValidateNotNullOrEmpty]
46+
public AzureRmRecoveryServicesRetentionPolicyBase RetentionPolicy { get; set; }
47+
48+
[Parameter(Mandatory = false, HelpMessage = "", ValueFromPipeline = true)]
49+
[ValidateNotNullOrEmpty]
50+
public AzureRmRecoveryServicesSchedulePolicyBase SchedulePolicy { get; set; }
51+
52+
public override void ExecuteCmdlet()
53+
{
54+
base.ExecuteCmdlet();
55+
56+
PsBackupProviderManager providerManager = new PsBackupProviderManager(new Dictionary<System.Enum, object>()
57+
{
58+
{GetContainerParams.Name, Name},
59+
}, HydraAdapter);
60+
61+
IPsBackupProvider psBackupProvider = providerManager.GetProviderInstance(ContainerType.AzureVM);
62+
}
63+
}
64+
}

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,9 @@
6565
</ItemGroup>
6666
<ItemGroup>
6767
<Compile Include="Cmdlets\Container\GetAzureRmRecoveryServicesContainer.cs" />
68+
<Compile Include="Cmdlets\ProtectionPolicy\GetAzureRmRecoveryServicesPolicy.cs" />
69+
<Compile Include="Cmdlets\ProtectionPolicy\SetAzureRmRecoveryServicesPolicy.cs" />
70+
<Compile Include="Cmdlets\ProtectionPolicy\NewAzureRmRecoveryServicesPolicy.cs" />
6871
<Compile Include="Properties\AssemblyInfo.cs" />
6972
<Compile Include="Properties\Resources.Designer.cs">
7073
<AutoGen>True</AutoGen>
@@ -77,7 +80,6 @@
7780
<Folder Include="Cmdlets\Backup\" />
7881
<Folder Include="Cmdlets\Item\" />
7982
<Folder Include="Cmdlets\Jobs\" />
80-
<Folder Include="Cmdlets\ProtectionPolicy\" />
8183
<Folder Include="Cmdlets\RecoveryPoint\" />
8284
<Folder Include="Cmdlets\Restore\" />
8385
</ItemGroup>

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

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,15 @@
2020

2121
namespace Microsoft.Azure.Commands.RecoveryServices.Backup.Cmdlets.Models
2222
{
23-
public class AzureRmRecoveryServicesContainerBase
23+
public class AzureRmRecoveryServicesObjectBase
24+
{
25+
public virtual void Validate()
26+
{
27+
28+
}
29+
}
30+
31+
public class AzureRmRecoveryServicesContainerBase : AzureRmRecoveryServicesObjectBase
2432
{
2533
public string Name { get; set; }
2634

@@ -33,32 +41,35 @@ public class AzureRmRecoveryServicesContainerBase
3341
public int BackupItemsCount { get; set; }
3442
}
3543

36-
public class AzureRmRecoveryServicesItemBase
44+
public class AzureRmRecoveryServicesItemBase : AzureRmRecoveryServicesObjectBase
3745
{
3846
}
3947

40-
public class AzureRmRecoveryServicesRecoveryPointBase
48+
public class AzureRmRecoveryServicesRecoveryPointBase : AzureRmRecoveryServicesObjectBase
4149
{
4250
}
4351

44-
public class AzureRmRecoveryServicesPolicyBase
52+
public class AzureRmRecoveryServicesPolicyBase : AzureRmRecoveryServicesObjectBase
4553
{
4654
public BackupManagementType BackupManagementType { get; set; }
4755

4856
public WorkloadType WorkloadType { get; set; }
4957

58+
public override void Validate()
59+
{
60+
}
5061
}
5162

52-
public class AzureRmRecoveryServicesRetentionPolicyBase
63+
public class AzureRmRecoveryServicesRetentionPolicyBase : AzureRmRecoveryServicesObjectBase
5364
{
54-
public virtual void Validate()
65+
public override void Validate()
5566
{
5667
}
5768
}
5869

59-
public class AzureRmRecoveryServicesSchedulePolicyBase
70+
public class AzureRmRecoveryServicesSchedulePolicyBase : AzureRmRecoveryServicesObjectBase
6071
{
61-
public virtual void Validate()
72+
public override void Validate()
6273
{
6374
}
6475
}

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

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,14 @@ public enum ContainerRegistrationStatus
4545
}
4646

4747
#region policy
48-
public enum WeekNumber
48+
public enum WeekOfMonth
4949
{
50-
First,
51-
Second,
52-
Third,
53-
Fourth,
54-
Last
50+
Invalid = 0,
51+
First = 1,
52+
Second = 2,
53+
Third = 3,
54+
Fourth = 4,
55+
Last = 5
5556
}
5657
public enum Month
5758
{

0 commit comments

Comments
 (0)