Skip to content

Commit b28d77c

Browse files
committed
Merge branch 'dev1' of https://github.com/MabOneSdk/azure-powershell into dev1
2 parents d32f28e + 7d06557 commit b28d77c

File tree

2 files changed

+61
-1
lines changed

2 files changed

+61
-1
lines changed
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
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 Microsoft.Azure.Commands.RecoveryServices.Backup.Cmdlets.Models;
16+
using Microsoft.Azure.Commands.RecoveryServices.Backup.Cmdlets.ProviderModel;
17+
using Microsoft.Azure.Commands.RecoveryServices.Backup.Helpers;
18+
using Microsoft.Azure.Commands.RecoveryServices.Backup.Properties;
19+
using System;
20+
using System.Collections.Generic;
21+
using System.Linq;
22+
using System.Management.Automation;
23+
using System.Text;
24+
using System.Threading.Tasks;
25+
26+
namespace Microsoft.Azure.Commands.RecoveryServices.Backup.Cmdlets
27+
{
28+
/// <summary>
29+
/// Backup Item
30+
/// </summary>
31+
[Cmdlet(VerbsData.Backup, "AzureRmRecoveryServicesItem"), OutputType(typeof(AzureRmRecoveryServicesJobBase))]
32+
public class BackupAzureRmRecoveryServicesItem : RecoveryServicesBackupCmdletBase
33+
{
34+
[Parameter(Mandatory = true, HelpMessage = ParamHelpMsg.Item.ProtectedItem, ValueFromPipeline = true)]
35+
[ValidateNotNullOrEmpty]
36+
public AzureRmRecoveryServicesItemBase Item { get; set; }
37+
38+
[Parameter(Mandatory = false, HelpMessage = ParamHelpMsg.Item.ExpiryDate, ValueFromPipeline = false)]
39+
[ValidateNotNullOrEmpty]
40+
public DateTime ExpiryDate { get; set; }
41+
42+
public override void ExecuteCmdlet()
43+
{
44+
base.ExecuteCmdlet();
45+
46+
PsBackupProviderManager providerManager = new PsBackupProviderManager(new Dictionary<System.Enum, object>()
47+
{
48+
{ItemParams.Item, Item},
49+
{ItemParams.ExpiryDate, ExpiryDate},
50+
}, HydraAdapter);
51+
52+
IPsBackupProvider psBackupProvider = providerManager.GetProviderInstance(Item.WorkloadType, Item.BackupManagementType);
53+
var jobResponse = psBackupProvider.TriggerBackup();
54+
55+
HandleCreatedJob(jobResponse, Resources.TriggerBackupOperation);
56+
}
57+
}
58+
}

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,9 @@
141141
<None Include="SessionRecords\Microsoft.Azure.Commands.RecoveryServices.Backup.Test.ScenarioTests.ContainerTests\TestGetContainerScenario.json">
142142
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
143143
</None>
144-
<None Include="SessionRecords\Microsoft.Azure.Commands.RecoveryServices.Backup.Test.ScenarioTests.ItemTests\TestBackupItemScenario.json" />
144+
<None Include="SessionRecords\Microsoft.Azure.Commands.RecoveryServices.Backup.Test.ScenarioTests.ItemTests\TestBackupItemScenario.json">
145+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
146+
</None>
145147
<None Include="SessionRecords\Microsoft.Azure.Commands.RecoveryServices.Backup.Test.ScenarioTests.JobTests\TestGetJobDetails.json">
146148
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
147149
</None>

0 commit comments

Comments
 (0)