Skip to content

Commit 53133ba

Browse files
author
dragonfly91
committed
commit post resolving conflicts
2 parents dca13bb + bab1c8e commit 53133ba

File tree

7 files changed

+406
-0
lines changed

7 files changed

+406
-0
lines changed
Lines changed: 47 additions & 0 deletions
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.Management.Automation;
17+
using System.Collections.Generic;
18+
using System.Xml;
19+
using Microsoft.WindowsAzure.Commands.Utilities.Common;
20+
using Microsoft.Azure.Common.Authentication;
21+
using Microsoft.Azure.Common.Authentication.Models;
22+
using System.Threading;
23+
using Hyak.Common;
24+
using Microsoft.Azure.Commands.AzureBackup.Properties;
25+
using System.Net;
26+
27+
namespace Microsoft.Azure.Commands.AzureBackup.Cmdlets
28+
{
29+
public abstract class AzureBackupDSCmdletBase : AzureBackupCmdletBase
30+
{
31+
// ToDO:
32+
// Correct Help message and other attributes related to paameters
33+
[Parameter(Position = 0, Mandatory = true, HelpMessage = AzureBackupCmdletHelpMessage.ResourceGroupName, ValueFromPipelineByPropertyName = true)]
34+
[ValidateNotNullOrEmpty]
35+
public AzureBackupItem AzureBackupItem { get; set; }
36+
37+
public override void ExecuteCmdlet()
38+
{
39+
base.ExecuteCmdlet();
40+
41+
WriteDebug(String.Format("Cmdlet called for ResourceGroupName: {0}, ResourceName: {1}", AzureBackupItem.ResourceGroupName, AzureBackupItem.ResourceName));
42+
43+
InitializeAzureBackupCmdlet(AzureBackupItem.ResourceGroupName, AzureBackupItem.ResourceName);
44+
}
45+
}
46+
}
47+
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
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.Management.Automation;
17+
using System.Collections.Generic;
18+
using System.Xml;
19+
using System.Linq;
20+
using Microsoft.Azure.Management.BackupServices.Models;
21+
using MBS = Microsoft.Azure.Management.BackupServices;
22+
23+
namespace Microsoft.Azure.Commands.AzureBackup.Cmdlets
24+
{
25+
// ToDo:
26+
// Correct the Commandlet
27+
// Correct the OperationResponse
28+
// Get Tracking API from Piyush and Get JobResponse
29+
// Get JobResponse Object from Aditya
30+
31+
/// <summary>
32+
/// Get list of containers
33+
/// </summary>
34+
[Cmdlet(VerbsCommon.New, "AzureBackupItem"), OutputType(typeof(MBS.OperationResponse))]
35+
public class TriggerAzureBackup : AzureBackupDSCmdletBase
36+
{
37+
public override void ExecuteCmdlet()
38+
{
39+
base.ExecuteCmdlet();
40+
41+
ExecutionBlock(() =>
42+
{
43+
WriteVerbose("Making client call");
44+
45+
MBS.OperationResponse triggerBackUpInfo =
46+
AzureBackupClient.BackUp.TriggerBackUpAsync(GetCustomRequestHeaders(),
47+
AzureBackupItem.ContainerName,
48+
AzureBackupItem.DataSourceType,
49+
AzureBackupItem.DataSourceId,
50+
CmdletCancellationToken).Result;
51+
52+
WriteVerbose("Received policy response");
53+
WriteVerbose("Received policy response2");
54+
55+
WriteVerbose("Converting response");
56+
WriteAzureBackupProtectionPolicy(triggerBackUpInfo);
57+
});
58+
}
59+
60+
public void WriteAzureBackupProtectionPolicy(MBS.OperationResponse sourceOperationResponse)
61+
{
62+
// this needs to be uncommented once we have proper constructor
63+
//this.WriteObject(new AzureBackupRecoveryPoint(ResourceGroupName, ResourceName, sourceOperationResponse));
64+
}
65+
66+
public void WriteAzureBackupProtectionPolicy(IEnumerable<MBS.OperationResponse> sourceOperationResponseList)
67+
{
68+
List<MBS.OperationResponse> targetList = new List<MBS.OperationResponse>();
69+
70+
foreach (var sourceOperationResponse in sourceOperationResponseList)
71+
{
72+
// this needs to be uncommented once we have proper constructor
73+
//targetList.Add(new TriggerBackUpInfo(ResourceGroupName, ResourceName, sourceOperationResponse));
74+
}
75+
76+
this.WriteObject(targetList, true);
77+
}
78+
}
79+
}
80+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
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.Management.Automation;
17+
using System.Collections.Generic;
18+
using System.Xml;
19+
using System.Linq;
20+
using Microsoft.Azure.Management.BackupServices.Models;
21+
22+
namespace Microsoft.Azure.Commands.AzureBackup.Cmdlets
23+
{
24+
/// <summary>
25+
/// Get list of containers
26+
/// </summary>
27+
[Cmdlet(VerbsCommon.Get, "AzureBackupRecoveryPoint"), OutputType(typeof(AzureBackupRecoveryPoint), typeof(List<AzureBackupRecoveryPoint>))]
28+
public class GetAzureBackupRecoveryPoint : AzureBackupDSCmdletBase
29+
{
30+
[Parameter(Position = 2, Mandatory = false, HelpMessage = AzureBackupCmdletHelpMessage.PolicyName)]
31+
[ValidateNotNullOrEmpty]
32+
public string Id { get; set; }
33+
34+
public override void ExecuteCmdlet()
35+
{
36+
base.ExecuteCmdlet();
37+
38+
ExecutionBlock(() =>
39+
{
40+
WriteVerbose("Making client call");
41+
42+
RecoveryPointListResponse recoveryPointListResponse =
43+
AzureBackupClient.RecoveryPoint.ListAsync(GetCustomRequestHeaders(),
44+
AzureBackupItem.ContainerName,
45+
AzureBackupItem.DataSourceType,
46+
AzureBackupItem.DataSourceId,
47+
CmdletCancellationToken).Result;
48+
49+
WriteVerbose("Received policy response");
50+
WriteVerbose("Received policy response2");
51+
IEnumerable<RecoveryPointInfo> recoveryPointObjects = null;
52+
if (Id != null)
53+
{
54+
recoveryPointObjects = recoveryPointListResponse.RecoveryPoints.Objects.Where(x => x.InstanceId.Equals(Id, System.StringComparison.InvariantCultureIgnoreCase));
55+
}
56+
else
57+
{
58+
recoveryPointObjects = recoveryPointListResponse.RecoveryPoints.Objects;
59+
}
60+
61+
WriteVerbose("Converting response");
62+
WriteAzureBackupProtectionPolicy(recoveryPointObjects, AzureBackupItem);
63+
});
64+
}
65+
66+
public void WriteAzureBackupProtectionPolicy(RecoveryPointInfo sourceRecoverPoint, AzureBackupItem azureBackupItem)
67+
{
68+
this.WriteObject(new AzureBackupRecoveryPoint(sourceRecoverPoint, azureBackupItem));
69+
}
70+
71+
public void WriteAzureBackupProtectionPolicy(IEnumerable<RecoveryPointInfo> sourceRecoverPointList, AzureBackupItem azureBackupItem)
72+
{
73+
List<AzureBackupRecoveryPoint> targetList = new List<AzureBackupRecoveryPoint>();
74+
75+
foreach (var sourceRecoverPoint in sourceRecoverPointList)
76+
{
77+
targetList.Add(new AzureBackupRecoveryPoint(sourceRecoverPoint, azureBackupItem));
78+
}
79+
80+
this.WriteObject(targetList, true);
81+
}
82+
}
83+
}
84+

src/ResourceManager/AzureBackup/Commands.AzureBackup/Commands.AzureBackup.csproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,9 +116,11 @@
116116
<Reference Include="System.Xml" />
117117
</ItemGroup>
118118
<ItemGroup>
119+
<Compile Include="AzureBackupDSCmdletBase.cs" />
119120
<Compile Include="AzureBackupVaultCmdletBase.cs" />
120121
<Compile Include="AzureBackupCmdletBase.cs" />
121122
<Compile Include="AzureBackupCmdletHelpMessage.cs" />
123+
<Compile Include="Cmdlets\BackUp\TriggerBackUp.cs" />
122124
<Compile Include="Cmdlets\Jobs\GetAzureBackupJob.cs" />
123125
<Compile Include="Cmdlets\ProtectionPolicy\GetAzureBackupProtectionPolicy.cs" />
124126
<Compile Include="Cmdlets\VaultCredentials\AcsNamespace.cs" />
@@ -128,6 +130,8 @@
128130
<Compile Include="Cmdlets\VaultCredentials\VaultCredentials.cs" />
129131
<Compile Include="Models\AzureBackupBaseObjects.cs" />
130132
<Compile Include="Models\AzureBackupContainer.cs" />
133+
<Compile Include="Models\AzureBackupItem.cs" />
134+
<Compile Include="Models\AzureBackupRecoveryPoint.cs" />
131135
<Compile Include="Models\ProtectionPolicy.cs" />
132136
<Compile Include="Properties\Resources.Designer.cs">
133137
<AutoGen>True</AutoGen>

src/ResourceManager/AzureBackup/Commands.AzureBackup/Models/AzureBackupBaseObjects.cs

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,5 +53,43 @@ public class AzureBackupContainerContextObject : AzureBackupVaultContextObject
5353
/// Id of the Azure Backup Container
5454
/// </summary>
5555
public string ContainerId { get; set; }
56+
57+
public AzureBackupContainerContextObject()
58+
: base()
59+
{
60+
}
61+
62+
public AzureBackupContainerContextObject(AzureBackupContainerContextObject azureBackupContainerContextObject)
63+
: base(azureBackupContainerContextObject.ResourceGroupName, azureBackupContainerContextObject.ResourceName)
64+
{
65+
ContainerType = azureBackupContainerContextObject.ContainerType;
66+
ContainerName = azureBackupContainerContextObject.ContainerName;
67+
ContainerId = azureBackupContainerContextObject.ContainerId;
68+
}
69+
}
70+
71+
public class AzureBackupItemContextObject : AzureBackupContainerContextObject
72+
{
73+
/// <summary>
74+
/// DataSourceId of Azure Backup Item
75+
/// </summary>
76+
public string DataSourceId { get; set; }
77+
78+
/// <summary>
79+
/// DataSourceId of Azure Backup Item
80+
/// </summary>
81+
public string DataSourceType { get; set; }
82+
83+
public AzureBackupItemContextObject()
84+
: base()
85+
{
86+
}
87+
88+
public AzureBackupItemContextObject(AzureBackupItemContextObject azureBackupItemContextObject)
89+
: base(azureBackupItemContextObject)
90+
{
91+
DataSourceId = azureBackupItemContextObject.DataSourceId;
92+
DataSourceType = azureBackupItemContextObject.DataSourceType;
93+
}
5694
}
5795
}
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
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.Collections.Generic;
17+
using System.Linq;
18+
using System.Text;
19+
using System.Threading.Tasks;
20+
21+
namespace Microsoft.Azure.Commands.AzureBackup.Cmdlets
22+
{
23+
/// <summary>
24+
/// Represents Azure Backup Container
25+
/// </summary>
26+
public class AzureBackupItem : AzureBackupItemContextObject
27+
{
28+
/// <summary>
29+
/// Status for the Azure Backup Item
30+
/// </summary>
31+
public string Status { get; set; }
32+
33+
/// <summary>
34+
/// Protection Status for the Azure Backup Item
35+
/// </summary>
36+
public string ProtectionStatus { get; set; }
37+
38+
/// <summary>
39+
/// Protectable Object Name for the Azure Backup Item
40+
/// </summary>
41+
public string ProtectableObjectName { get; set; }
42+
43+
/// <summary>
44+
/// Protection Policy Name for the Azure Backup Item
45+
/// </summary>
46+
public string ProtectionPolicyName { get; set; }
47+
48+
/// <summary>
49+
/// Protection Policy Id for the Azure Backup Item
50+
/// </summary>
51+
public string ProtectionPolicyId { get; set; }
52+
53+
/// <summary>
54+
/// Policy Inconsistent for the Azure Backup Item
55+
/// </summary>
56+
public bool PolicyInconsistent { get; set; }
57+
58+
/// <summary>
59+
/// Recovery Points Count for the Azure Backup Item
60+
/// </summary>
61+
public int RecoveryPointsCount { get; set; }
62+
63+
/// <summary>
64+
/// Last Recovery Point for the Azure Backup Item
65+
/// </summary>
66+
public DateTime? LastRecoveryPoint { get; set; }
67+
68+
/// <summary>
69+
/// Last Backup Time for the Azure Backup Item
70+
/// </summary>
71+
public DateTime? LastBackupTime { get; set; }
72+
73+
/// <summary>
74+
/// Last Backup Status for the Azure Backup Item
75+
/// </summary>
76+
public string LastBackupStatus { get; set; }
77+
78+
/// <summary>
79+
/// Last Backup Job Id for the Azure Backup Item
80+
/// </summary>
81+
public string LastBackupJobId { get; set; }
82+
}
83+
}

0 commit comments

Comments
 (0)