Skip to content

Commit 8512eb9

Browse files
author
dragonfly91
committed
Merge branch 'dev1' into anudeeb-dev1
2 parents 314e099 + 1bc5cb1 commit 8512eb9

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
@@ -69,6 +69,9 @@
6969
</ItemGroup>
7070
<ItemGroup>
7171
<Compile Include="Cmdlets\Container\GetAzureRmRecoveryServicesContainer.cs" />
72+
<Compile Include="Cmdlets\ProtectionPolicy\GetAzureRmRecoveryServicesPolicy.cs" />
73+
<Compile Include="Cmdlets\ProtectionPolicy\SetAzureRmRecoveryServicesPolicy.cs" />
74+
<Compile Include="Cmdlets\ProtectionPolicy\NewAzureRmRecoveryServicesPolicy.cs" />
7275
<Compile Include="Properties\AssemblyInfo.cs" />
7376
<Compile Include="Properties\Resources.Designer.cs">
7477
<AutoGen>True</AutoGen>
@@ -82,7 +85,6 @@
8285
<Folder Include="Cmdlets\Backup\" />
8386
<Folder Include="Cmdlets\Item\" />
8487
<Folder Include="Cmdlets\Jobs\" />
85-
<Folder Include="Cmdlets\ProtectionPolicy\" />
8688
<Folder Include="Cmdlets\RecoveryPoint\" />
8789
<Folder Include="Cmdlets\Restore\" />
8890
</ItemGroup>

src/ResourceManager/RecoveryServices.Backup/Commands.RecoveryServices.Backup.Models/AzureVmModels/AzureRmRecoveryServicesAzureVmPolicy.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,12 @@ public class AzureRmRecoveryServicesIaasVmPolicy : AzureRmRecoveryServicesPolicy
2525
public AzureRmRecoveryServicesSchedulePolicyBase SchedulePolicy { get; set; }
2626

2727
public AzureRmRecoveryServicesRetentionPolicyBase RetentionPolicy { get; set; }
28+
29+
public virtual void Validate()
30+
{
31+
SchedulePolicy.Validate();
32+
RetentionPolicy.Validate();
33+
}
2834
}
2935

3036
}

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

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

2222
namespace Microsoft.Azure.Commands.RecoveryServices.Backup.Cmdlets.Models
2323
{
24-
public class AzureRmRecoveryServicesContainerBase
24+
public class AzureRmRecoveryServicesObjectBase
25+
{
26+
public virtual void Validate()
27+
{
28+
29+
}
30+
}
31+
32+
public class AzureRmRecoveryServicesContainerBase : AzureRmRecoveryServicesObjectBase
2533
{
2634
/// <summary>
2735
/// Container Name
@@ -36,32 +44,35 @@ public AzureRmRecoveryServicesContainerBase(ProtectionContainerResource protecti
3644
}
3745
}
3846

39-
public class AzureRmRecoveryServicesItemBase
47+
public class AzureRmRecoveryServicesItemBase : AzureRmRecoveryServicesObjectBase
4048
{
4149
}
4250

43-
public class AzureRmRecoveryServicesRecoveryPointBase
51+
public class AzureRmRecoveryServicesRecoveryPointBase : AzureRmRecoveryServicesObjectBase
4452
{
4553
}
4654

47-
public class AzureRmRecoveryServicesPolicyBase
55+
public class AzureRmRecoveryServicesPolicyBase : AzureRmRecoveryServicesObjectBase
4856
{
4957
public BackupManagementType BackupManagementType { get; set; }
5058

5159
public WorkloadType WorkloadType { get; set; }
5260

61+
public override void Validate()
62+
{
63+
}
5364
}
5465

55-
public class AzureRmRecoveryServicesRetentionPolicyBase
66+
public class AzureRmRecoveryServicesRetentionPolicyBase : AzureRmRecoveryServicesObjectBase
5667
{
57-
public virtual void Validate()
68+
public override void Validate()
5869
{
5970
}
6071
}
6172

62-
public class AzureRmRecoveryServicesSchedulePolicyBase
73+
public class AzureRmRecoveryServicesSchedulePolicyBase : AzureRmRecoveryServicesObjectBase
6374
{
64-
public virtual void Validate()
75+
public override void Validate()
6576
{
6677
}
6778
}

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)