diff --git a/src/ResourceManager/AzureBackup/Commands.AzureBackup/AzureBackupDSCmdletBase.cs b/src/ResourceManager/AzureBackup/Commands.AzureBackup/AzureBackupDSCmdletBase.cs
new file mode 100644
index 000000000000..a998ce6ca367
--- /dev/null
+++ b/src/ResourceManager/AzureBackup/Commands.AzureBackup/AzureBackupDSCmdletBase.cs
@@ -0,0 +1,47 @@
+// ----------------------------------------------------------------------------------
+//
+// Copyright Microsoft Corporation
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+// http://www.apache.org/licenses/LICENSE-2.0
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+// ----------------------------------------------------------------------------------
+
+using System;
+using System.Management.Automation;
+using System.Collections.Generic;
+using System.Xml;
+using Microsoft.WindowsAzure.Commands.Utilities.Common;
+using Microsoft.Azure.Common.Authentication;
+using Microsoft.Azure.Common.Authentication.Models;
+using System.Threading;
+using Hyak.Common;
+using Microsoft.Azure.Commands.AzureBackup.Properties;
+using System.Net;
+
+namespace Microsoft.Azure.Commands.AzureBackup.Cmdlets
+{
+ public abstract class AzureBackupDSCmdletBase : AzureBackupCmdletBase
+ {
+ // ToDO:
+ // Correct Help message and other attributes related to paameters
+ [Parameter(Position = 0, Mandatory = true, HelpMessage = AzureBackupCmdletHelpMessage.ResourceGroupName, ValueFromPipelineByPropertyName = true)]
+ [ValidateNotNullOrEmpty]
+ public AzureBackupItem AzureBackupItem { get; set; }
+
+ public override void ExecuteCmdlet()
+ {
+ base.ExecuteCmdlet();
+
+ WriteDebug(String.Format("Cmdlet called for ResourceGroupName: {0}, ResourceName: {1}", AzureBackupItem.ResourceGroupName, AzureBackupItem.ResourceName));
+
+ InitializeAzureBackupCmdlet(AzureBackupItem.ResourceGroupName, AzureBackupItem.ResourceName);
+ }
+ }
+}
+
diff --git a/src/ResourceManager/AzureBackup/Commands.AzureBackup/Cmdlets/BackUp/TriggerBackUp.cs b/src/ResourceManager/AzureBackup/Commands.AzureBackup/Cmdlets/BackUp/TriggerBackUp.cs
new file mode 100644
index 000000000000..ebda269195ee
--- /dev/null
+++ b/src/ResourceManager/AzureBackup/Commands.AzureBackup/Cmdlets/BackUp/TriggerBackUp.cs
@@ -0,0 +1,80 @@
+// ----------------------------------------------------------------------------------
+//
+// Copyright Microsoft Corporation
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+// http://www.apache.org/licenses/LICENSE-2.0
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+// ----------------------------------------------------------------------------------
+
+using System;
+using System.Management.Automation;
+using System.Collections.Generic;
+using System.Xml;
+using System.Linq;
+using Microsoft.Azure.Management.BackupServices.Models;
+using MBS = Microsoft.Azure.Management.BackupServices;
+
+namespace Microsoft.Azure.Commands.AzureBackup.Cmdlets
+{
+ // ToDo:
+ // Correct the Commandlet
+ // Correct the OperationResponse
+ // Get Tracking API from Piyush and Get JobResponse
+ // Get JobResponse Object from Aditya
+
+ ///
+ /// Get list of containers
+ ///
+ [Cmdlet(VerbsCommon.New, "AzureBackupItem"), OutputType(typeof(MBS.OperationResponse))]
+ public class TriggerAzureBackup : AzureBackupDSCmdletBase
+ {
+ public override void ExecuteCmdlet()
+ {
+ base.ExecuteCmdlet();
+
+ ExecutionBlock(() =>
+ {
+ WriteVerbose("Making client call");
+
+ MBS.OperationResponse triggerBackUpInfo =
+ AzureBackupClient.BackUp.TriggerBackUpAsync(GetCustomRequestHeaders(),
+ AzureBackupItem.ContainerName,
+ AzureBackupItem.DataSourceType,
+ AzureBackupItem.DataSourceId,
+ CmdletCancellationToken).Result;
+
+ WriteVerbose("Received policy response");
+ WriteVerbose("Received policy response2");
+
+ WriteVerbose("Converting response");
+ WriteAzureBackupProtectionPolicy(triggerBackUpInfo);
+ });
+ }
+
+ public void WriteAzureBackupProtectionPolicy(MBS.OperationResponse sourceOperationResponse)
+ {
+ // this needs to be uncommented once we have proper constructor
+ //this.WriteObject(new AzureBackupRecoveryPoint(ResourceGroupName, ResourceName, sourceOperationResponse));
+ }
+
+ public void WriteAzureBackupProtectionPolicy(IEnumerable sourceOperationResponseList)
+ {
+ List targetList = new List();
+
+ foreach (var sourceOperationResponse in sourceOperationResponseList)
+ {
+ // this needs to be uncommented once we have proper constructor
+ //targetList.Add(new TriggerBackUpInfo(ResourceGroupName, ResourceName, sourceOperationResponse));
+ }
+
+ this.WriteObject(targetList, true);
+ }
+ }
+}
+
diff --git a/src/ResourceManager/AzureBackup/Commands.AzureBackup/Cmdlets/ProtectionPolicy/GetAzureBackupProtectionPolicy.cs b/src/ResourceManager/AzureBackup/Commands.AzureBackup/Cmdlets/ProtectionPolicy/GetAzureBackupProtectionPolicy.cs
index 5ab989901c70..322690782d8c 100644
--- a/src/ResourceManager/AzureBackup/Commands.AzureBackup/Cmdlets/ProtectionPolicy/GetAzureBackupProtectionPolicy.cs
+++ b/src/ResourceManager/AzureBackup/Commands.AzureBackup/Cmdlets/ProtectionPolicy/GetAzureBackupProtectionPolicy.cs
@@ -46,11 +46,11 @@ public override void ExecuteCmdlet()
IEnumerable policyObjects = null;
if (Name != null)
{
- policyObjects = policyListResponse.Objects.Where(x => x.Name.Equals(Name, System.StringComparison.InvariantCultureIgnoreCase));
+ policyObjects = policyListResponse.ProtectionPolicies.Objects.Where(x => x.Name.Equals(Name, System.StringComparison.InvariantCultureIgnoreCase));
}
else
{
- policyObjects = policyListResponse.Objects;
+ policyObjects = policyListResponse.ProtectionPolicies.Objects;
}
WriteVerbose("Converting response");
diff --git a/src/ResourceManager/AzureBackup/Commands.AzureBackup/Cmdlets/RecoveryPoint/GetAzureBackupRecoveryPoint.cs b/src/ResourceManager/AzureBackup/Commands.AzureBackup/Cmdlets/RecoveryPoint/GetAzureBackupRecoveryPoint.cs
new file mode 100644
index 000000000000..1ade5956fa4b
--- /dev/null
+++ b/src/ResourceManager/AzureBackup/Commands.AzureBackup/Cmdlets/RecoveryPoint/GetAzureBackupRecoveryPoint.cs
@@ -0,0 +1,84 @@
+// ----------------------------------------------------------------------------------
+//
+// Copyright Microsoft Corporation
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+// http://www.apache.org/licenses/LICENSE-2.0
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+// ----------------------------------------------------------------------------------
+
+using System;
+using System.Management.Automation;
+using System.Collections.Generic;
+using System.Xml;
+using System.Linq;
+using Microsoft.Azure.Management.BackupServices.Models;
+
+namespace Microsoft.Azure.Commands.AzureBackup.Cmdlets
+{
+ ///
+ /// Get list of containers
+ ///
+ [Cmdlet(VerbsCommon.Get, "AzureBackupRecoveryPoint"), OutputType(typeof(AzureBackupRecoveryPoint), typeof(List))]
+ public class GetAzureBackupRecoveryPoint : AzureBackupDSCmdletBase
+ {
+ [Parameter(Position = 2, Mandatory = false, HelpMessage = AzureBackupCmdletHelpMessage.PolicyName)]
+ [ValidateNotNullOrEmpty]
+ public string Id { get; set; }
+
+ public override void ExecuteCmdlet()
+ {
+ base.ExecuteCmdlet();
+
+ ExecutionBlock(() =>
+ {
+ WriteVerbose("Making client call");
+
+ RecoveryPointListResponse recoveryPointListResponse =
+ AzureBackupClient.RecoveryPoint.ListAsync(GetCustomRequestHeaders(),
+ AzureBackupItem.ContainerName,
+ AzureBackupItem.DataSourceType,
+ AzureBackupItem.DataSourceId,
+ CmdletCancellationToken).Result;
+
+ WriteVerbose("Received policy response");
+ WriteVerbose("Received policy response2");
+ IEnumerable recoveryPointObjects = null;
+ if (Id != null)
+ {
+ recoveryPointObjects = recoveryPointListResponse.RecoveryPoints.Objects.Where(x => x.InstanceId.Equals(Id, System.StringComparison.InvariantCultureIgnoreCase));
+ }
+ else
+ {
+ recoveryPointObjects = recoveryPointListResponse.RecoveryPoints.Objects;
+ }
+
+ WriteVerbose("Converting response");
+ WriteAzureBackupProtectionPolicy(recoveryPointObjects, AzureBackupItem);
+ });
+ }
+
+ public void WriteAzureBackupProtectionPolicy(RecoveryPointInfo sourceRecoverPoint, AzureBackupItem azureBackupItem)
+ {
+ this.WriteObject(new AzureBackupRecoveryPoint(sourceRecoverPoint, azureBackupItem));
+ }
+
+ public void WriteAzureBackupProtectionPolicy(IEnumerable sourceRecoverPointList, AzureBackupItem azureBackupItem)
+ {
+ List targetList = new List();
+
+ foreach (var sourceRecoverPoint in sourceRecoverPointList)
+ {
+ targetList.Add(new AzureBackupRecoveryPoint(sourceRecoverPoint, azureBackupItem));
+ }
+
+ this.WriteObject(targetList, true);
+ }
+ }
+}
+
diff --git a/src/ResourceManager/AzureBackup/Commands.AzureBackup/Commands.AzureBackup.csproj b/src/ResourceManager/AzureBackup/Commands.AzureBackup/Commands.AzureBackup.csproj
index 7e47d90c23c7..eac24317ee67 100644
--- a/src/ResourceManager/AzureBackup/Commands.AzureBackup/Commands.AzureBackup.csproj
+++ b/src/ResourceManager/AzureBackup/Commands.AzureBackup/Commands.AzureBackup.csproj
@@ -77,9 +77,8 @@
..\..\..\packages\Microsoft.WindowsAzure.Management.4.1.1\lib\net40\Microsoft.WindowsAzure.Management.dll
-
- False
- ..\..\..\Microsoft.WindowsAzure.Management.BackupServicesManagment.dll
+
+ ..\..\..\..\..\azure-sdk-for-net\src\ResourceManagement\AzureBackup\BackupServicesManagment\bin\Net40-Debug\Microsoft.WindowsAzure.Management.BackupServicesManagment.dll
..\..\..\packages\Microsoft.WindowsAzure.Management.Scheduler.6.0.0\lib\net40\Microsoft.WindowsAzure.Management.Scheduler.dll
@@ -111,12 +110,18 @@
+
+
+
+
+
+
True
diff --git a/src/ResourceManager/AzureBackup/Commands.AzureBackup/Models/AzureBackupBaseObjects.cs b/src/ResourceManager/AzureBackup/Commands.AzureBackup/Models/AzureBackupBaseObjects.cs
index b50deee0f03e..1c1c77a0a5fb 100644
--- a/src/ResourceManager/AzureBackup/Commands.AzureBackup/Models/AzureBackupBaseObjects.cs
+++ b/src/ResourceManager/AzureBackup/Commands.AzureBackup/Models/AzureBackupBaseObjects.cs
@@ -53,6 +53,19 @@ public class AzureBackupContainerContextObject : AzureBackupVaultContextObject
/// Id of the Azure Backup Container
///
public string ContainerId { get; set; }
+
+ public AzureBackupContainerContextObject()
+ : base()
+ {
+ }
+
+ public AzureBackupContainerContextObject(AzureBackupContainerContextObject azureBackupContainerContextObject)
+ : base(azureBackupContainerContextObject.ResourceGroupName, azureBackupContainerContextObject.ResourceName)
+ {
+ ContainerType = azureBackupContainerContextObject.ContainerType;
+ ContainerName = azureBackupContainerContextObject.ContainerName;
+ ContainerId = azureBackupContainerContextObject.ContainerId;
+ }
}
public class AzureBackupItemContextObject : AzureBackupContainerContextObject
@@ -66,5 +79,17 @@ public class AzureBackupItemContextObject : AzureBackupContainerContextObject
/// DataSourceId of Azure Backup Item
///
public string DataSourceType { get; set; }
+
+ public AzureBackupItemContextObject()
+ : base()
+ {
+ }
+
+ public AzureBackupItemContextObject(AzureBackupItemContextObject azureBackupItemContextObject)
+ : base(azureBackupItemContextObject)
+ {
+ DataSourceId = azureBackupItemContextObject.DataSourceId;
+ DataSourceType = azureBackupItemContextObject.DataSourceType;
+ }
}
}
diff --git a/src/ResourceManager/AzureBackup/Commands.AzureBackup/Models/AzureBackupRecoveryPoint.cs b/src/ResourceManager/AzureBackup/Commands.AzureBackup/Models/AzureBackupRecoveryPoint.cs
new file mode 100644
index 000000000000..6d7c95a0d57e
--- /dev/null
+++ b/src/ResourceManager/AzureBackup/Commands.AzureBackup/Models/AzureBackupRecoveryPoint.cs
@@ -0,0 +1,70 @@
+// ----------------------------------------------------------------------------------
+//
+// Copyright Microsoft Corporation
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+// http://www.apache.org/licenses/LICENSE-2.0
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+// ----------------------------------------------------------------------------------
+
+using Microsoft.Azure.Management.BackupServices.Models;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Microsoft.Azure.Commands.AzureBackup.Cmdlets
+{
+ public class AzureBackupRecoveryPointContextObject : AzureBackupItemContextObject
+ {
+ ///
+ /// RecoveryPointId of Azure Backup Item
+ ///
+ public string RecoveryPointId { get; set; }
+
+ public AzureBackupRecoveryPointContextObject()
+ : base()
+ {
+ }
+
+ public AzureBackupRecoveryPointContextObject(RecoveryPointInfo recoveryPointInfo, AzureBackupItem azureBackupItem)
+ : base(azureBackupItem)
+ {
+ RecoveryPointId = recoveryPointInfo.InstanceId;
+ }
+ }
+
+ ///
+ /// Represents Azure Backup Container
+ ///
+ public class AzureBackupRecoveryPoint : AzureBackupRecoveryPointContextObject
+ {
+ ///
+ /// Last Recovery Point for the Azure Backup Item
+ ///
+ public DateTime RecoveryPointTime { get; set; }
+
+ ///
+ /// DataSourceId of Azure Backup Item
+ ///
+ public string RecoveryPointType { get; set; }
+
+ public AzureBackupRecoveryPoint()
+ : base()
+ {
+ }
+
+ public AzureBackupRecoveryPoint(RecoveryPointInfo recoveryPointInfo, AzureBackupItem azureBackupItem)
+ : base(recoveryPointInfo, azureBackupItem)
+ {
+ RecoveryPointTime = recoveryPointInfo.RecoveryPointTime;
+ RecoveryPointType = recoveryPointInfo.RecoveryPointType;
+ }
+ }
+}
\ No newline at end of file