diff --git a/src/ResourceManager/AzureBackup/Commands.AzureBackup/AzureBackupContainerCmdletBase.cs b/src/ResourceManager/AzureBackup/Commands.AzureBackup/AzureBackupContainerCmdletBase.cs
new file mode 100644
index 000000000000..bffc98a2f8c6
--- /dev/null
+++ b/src/ResourceManager/AzureBackup/Commands.AzureBackup/AzureBackupContainerCmdletBase.cs
@@ -0,0 +1,46 @@
+// ----------------------------------------------------------------------------------
+//
+// 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 AzureBackupContainerCmdletBase : AzureBackupCmdletBase
+ {
+ // ToDO:
+ // Correct Help message and other attributes related to paameters
+ [Parameter(Position = 0, Mandatory = true, HelpMessage = AzureBackupCmdletHelpMessage.ResourceGroupName, ValueFromPipelineByPropertyName = true)]
+ [ValidateNotNullOrEmpty]
+ public AzureBackupContainer AzureBackupContainer { get; set; }
+
+ public override void ExecuteCmdlet()
+ {
+ base.ExecuteCmdlet();
+
+ WriteDebug(String.Format("Cmdlet called for ResourceGroupName: {0}, ResourceName: {1}", AzureBackupContainer.ResourceGroupName, AzureBackupContainer.ResourceName));
+
+ InitializeAzureBackupCmdlet(AzureBackupContainer.ResourceGroupName, AzureBackupContainer.ResourceName);
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/ResourceManager/AzureBackup/Commands.AzureBackup/Cmdlets/DataSource/Disable-AzureBackupProtection .cs b/src/ResourceManager/AzureBackup/Commands.AzureBackup/Cmdlets/DataSource/Disable-AzureBackupProtection .cs
new file mode 100644
index 000000000000..af20462b0fab
--- /dev/null
+++ b/src/ResourceManager/AzureBackup/Commands.AzureBackup/Cmdlets/DataSource/Disable-AzureBackupProtection .cs
@@ -0,0 +1,12 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Microsoft.Azure.Commands.AzureBackup.Cmdlets.DataSource
+{
+ class Disable_AzureBackupProtection
+ {
+ }
+}
diff --git a/src/ResourceManager/AzureBackup/Commands.AzureBackup/Cmdlets/DataSource/Enable-AzureBackupProtection .cs b/src/ResourceManager/AzureBackup/Commands.AzureBackup/Cmdlets/DataSource/Enable-AzureBackupProtection .cs
new file mode 100644
index 000000000000..6ada63c063e1
--- /dev/null
+++ b/src/ResourceManager/AzureBackup/Commands.AzureBackup/Cmdlets/DataSource/Enable-AzureBackupProtection .cs
@@ -0,0 +1,12 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Microsoft.Azure.Commands.AzureBackup.Cmdlets.DataSource
+{
+ class Enable_AzureBackupProtection
+ {
+ }
+}
diff --git a/src/ResourceManager/AzureBackup/Commands.AzureBackup/Cmdlets/DataSource/GetAzureBackupItem.cs b/src/ResourceManager/AzureBackup/Commands.AzureBackup/Cmdlets/DataSource/GetAzureBackupItem.cs
new file mode 100644
index 000000000000..3f088a0a0a23
--- /dev/null
+++ b/src/ResourceManager/AzureBackup/Commands.AzureBackup/Cmdlets/DataSource/GetAzureBackupItem.cs
@@ -0,0 +1,89 @@
+// ----------------------------------------------------------------------------------
+//
+// 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, "AzureBackupItem"), OutputType(typeof(AzureBackupItem), typeof(List))]
+ public class GetAzureBackupItem : AzureBackupContainerCmdletBase
+ {
+ [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");
+
+ var azureBackupDatasourceListResponse = AzureBackupClient.DataSource.ListAsync(GetCustomRequestHeaders(), CmdletCancellationToken).Result;
+ var azureBackupPOListResponse = AzureBackupClient.ProtectableObject. ListAsync(GetCustomRequestHeaders(), CmdletCancellationToken).Result;
+
+ WriteVerbose("Received policy response");
+ WriteVerbose("Received policy response2");
+ IEnumerable azureBackupDatasourceObjects = null;
+ IEnumerable azureBackupPOObjects = null;
+
+ if (Id != null)
+ {
+ azureBackupDatasourceObjects = azureBackupDatasourceListResponse.DataSources.Objects.Where(x => x.InstanceId.Equals(Id, System.StringComparison.InvariantCultureIgnoreCase));
+ azureBackupPOObjects = azureBackupPOListResponse.ProtectableObject.Objects.Where(x => x.InstanceId.Equals(Id, System.StringComparison.InvariantCultureIgnoreCase));
+ }
+ else
+ {
+ azureBackupDatasourceObjects = azureBackupDatasourceListResponse.DataSources.Objects;
+ azureBackupPOObjects = azureBackupPOListResponse.ProtectableObject.Objects;
+ }
+
+ WriteVerbose("Converting response");
+ WriteAzureBackupProtectionPolicy(azureBackupDatasourceObjects, azureBackupPOObjects, AzureBackupContainer);
+ });
+ }
+
+ public void WriteAzureBackupProtectionPolicy(DataSourceInfo sourceItem, AzureBackupContainer azureBackupItem)
+ {
+ this.WriteObject(new AzureBackupItem(sourceItem, azureBackupItem));
+ }
+
+ public void WriteAzureBackupProtectionPolicy(IEnumerable sourceDataSourceList,IEnumerable sourcePOList, AzureBackupContainer azureBackupContainer)
+ {
+ List targetList = new List();
+
+ foreach (var item in sourceDataSourceList)
+ {
+ targetList.Add(new AzureBackupItem(item, azureBackupContainer));
+ }
+
+ foreach (var item in sourcePOList)
+ {
+ targetList.Add(new AzureBackupItem(item, azureBackupContainer));
+ }
+
+ this.WriteObject(targetList, true);
+ }
+
+ }
+}
diff --git a/src/ResourceManager/AzureBackup/Commands.AzureBackup/Models/AzureBackupBaseObjects.cs b/src/ResourceManager/AzureBackup/Commands.AzureBackup/Models/AzureBackupBaseObjects.cs
index 1c1c77a0a5fb..711b119e6c04 100644
--- a/src/ResourceManager/AzureBackup/Commands.AzureBackup/Models/AzureBackupBaseObjects.cs
+++ b/src/ResourceManager/AzureBackup/Commands.AzureBackup/Models/AzureBackupBaseObjects.cs
@@ -12,6 +12,7 @@
// limitations under the License.
// ----------------------------------------------------------------------------------
+using Microsoft.Azure.Management.BackupServices.Models;
namespace Microsoft.Azure.Commands.AzureBackup.Cmdlets
{
public class AzureBackupVaultContextObject
@@ -66,6 +67,13 @@ public AzureBackupContainerContextObject(AzureBackupContainerContextObject azure
ContainerName = azureBackupContainerContextObject.ContainerName;
ContainerId = azureBackupContainerContextObject.ContainerId;
}
+ public AzureBackupContainerContextObject(AzureBackupContainer azureBackupContainer)
+ : base(azureBackupContainer.ResourceGroupName, azureBackupContainer.ResourceName)
+ {
+ ContainerType = azureBackupContainer.ContainerType;
+ ContainerName = azureBackupContainer.ContainerName;
+ ContainerId = azureBackupContainer.ContainerId;
+ }
}
public class AzureBackupItemContextObject : AzureBackupContainerContextObject
@@ -91,5 +99,18 @@ public AzureBackupItemContextObject(AzureBackupItemContextObject azureBackupItem
DataSourceId = azureBackupItemContextObject.DataSourceId;
DataSourceType = azureBackupItemContextObject.DataSourceType;
}
+
+ public AzureBackupItemContextObject(DataSourceInfo item, AzureBackupContainer azureBackupContainer)
+ : base(azureBackupContainer)
+ {
+ DataSourceId = item.InstanceId;
+ DataSourceType = item.Type;
+ }
+
+ public AzureBackupItemContextObject(ProtectableObjectInfo item, AzureBackupContainer azureBackupContainer)
+ : base(azureBackupContainer)
+ {
+ DataSourceType = item.Type;
+ }
}
}
diff --git a/src/ResourceManager/AzureBackup/Commands.AzureBackup/Models/AzureBackupContainer.cs b/src/ResourceManager/AzureBackup/Commands.AzureBackup/Models/AzureBackupContainer.cs
index 1a7f9b6c6c3a..428ac72cb0bc 100644
--- a/src/ResourceManager/AzureBackup/Commands.AzureBackup/Models/AzureBackupContainer.cs
+++ b/src/ResourceManager/AzureBackup/Commands.AzureBackup/Models/AzureBackupContainer.cs
@@ -23,7 +23,7 @@ namespace Microsoft.Azure.Commands.AzureBackup.Cmdlets
///
/// Represents Azure Backup Container
///
- public class AzureBackupContainer : AzureBackupVaultContextObject
+ public class AzureBackupContainer : AzureBackupContainerContextObject
{
///
/// Type of the Azure Backup container
diff --git a/src/ResourceManager/AzureBackup/Commands.AzureBackup/Models/AzureBackupItem.cs b/src/ResourceManager/AzureBackup/Commands.AzureBackup/Models/AzureBackupItem.cs
index 28f6e6607364..d8bec9419989 100644
--- a/src/ResourceManager/AzureBackup/Commands.AzureBackup/Models/AzureBackupItem.cs
+++ b/src/ResourceManager/AzureBackup/Commands.AzureBackup/Models/AzureBackupItem.cs
@@ -17,6 +17,7 @@
using System.Linq;
using System.Text;
using System.Threading.Tasks;
+using Microsoft.Azure.Management.BackupServices.Models;
namespace Microsoft.Azure.Commands.AzureBackup.Cmdlets
{
@@ -79,5 +80,33 @@ public class AzureBackupItem : AzureBackupItemContextObject
/// Last Backup Job Id for the Azure Backup Item
///
public string LastBackupJobId { get; set; }
+
+ public AzureBackupItem()
+ : base()
+ {
+ }
+
+ public AzureBackupItem(DataSourceInfo datasource, AzureBackupContainer azureBackupContainer)
+ : base(datasource, azureBackupContainer)
+ {
+ Status = datasource.Status;
+ ProtectionStatus = datasource.ProtectionStatus;
+ ProtectableObjectName = datasource.ProtectableObjectName;
+ ProtectionPolicyName = datasource.ProtectionPolicyName;
+ ProtectionPolicyId = datasource.ProtectionPolicyId;
+ PolicyInconsistent = datasource.PolicyInconsistent;
+ RecoveryPointsCount = datasource.RecoveryPointsCount;
+ LastRecoveryPoint = datasource.LastRecoveryPoint;
+ LastBackupTime = datasource.LastBackupTime;
+ LastBackupStatus = datasource.LastBackupStatus;
+ LastBackupJobId = datasource.LastBackupJobId;
+ }
+
+ public AzureBackupItem(ProtectableObjectInfo pPOItem, AzureBackupContainer azureBackupContainer)
+ : base(pPOItem, azureBackupContainer)
+ {
+ ProtectionStatus = pPOItem.ProtectionStatus;
+ ProtectableObjectName = pPOItem.Name;
+ }
}
}
\ No newline at end of file