Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
// ----------------------------------------------------------------------------------
//
// 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.RecoveryServices.Backup.Models;
using System;
using System.Collections.Generic;

namespace Microsoft.Azure.Commands.RecoveryServices.Backup.Cmdlets.Models
{
/// <summary>
/// Soft Deleted Azure VM Item Class
/// </summary>
public class SoftDeletedVaultAzureVmItem : AzureVmItem
{
/// <summary>
/// Vault ID from which the item was soft deleted
/// </summary>
public string VaultId { get; set; }

/// <summary>
/// Constructor for soft deleted Azure VM item
/// </summary>
/// <param name="protectedItemResource">Mock protected item resource</param>
/// <param name="containerName">Container name</param>
/// <param name="containerType">Container type</param>
/// <param name="policyName">Policy name</param>
public SoftDeletedVaultAzureVmItem(ProtectedItemResource protectedItemResource,
string containerName, ContainerType containerType, string policyName)
: base(protectedItemResource, containerName, containerType, policyName)
{
// Extract vault ID from the protected item resource ID if available
if (!string.IsNullOrEmpty(protectedItemResource?.Id))
{
VaultId = ModeHelpers.ExtractVaultIdFromSoftDeletedId(protectedItemResource.Id);
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
// ----------------------------------------------------------------------------------
//
// 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.RecoveryServices.Backup.Models;
using System;
using System.Collections.Generic;

namespace Microsoft.Azure.Commands.RecoveryServices.Backup.Cmdlets.Models
{
/// <summary>
/// Soft Deleted Azure FileShare Item Class
/// </summary>
public class SoftDeletedVaultAzureFileShareItem : AzureFileShareItem
{
/// <summary>
/// Vault ID from which the item was soft deleted
/// </summary>
public string VaultId { get; set; }

/// <summary>
/// Constructor for soft deleted Azure FileShare item
/// </summary>
/// <param name="protectedItemResource">Mock protected item resource</param>
/// <param name="containerName">Container name</param>
/// <param name="containerType">Container type</param>
/// <param name="policyName">Policy name</param>
public SoftDeletedVaultAzureFileShareItem(ProtectedItemResource protectedItemResource,
string containerName, ContainerType containerType, string policyName)
: base(protectedItemResource, containerName, containerType, policyName)
{
if (!string.IsNullOrEmpty(protectedItemResource?.Id))
{
VaultId = ModeHelpers.ExtractVaultIdFromSoftDeletedId(protectedItemResource.Id);
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
// ----------------------------------------------------------------------------------
//
// 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.RecoveryServices.Backup.Models;
using System;
using System.Collections.Generic;

namespace Microsoft.Azure.Commands.RecoveryServices.Backup.Cmdlets.Models
{
/// <summary>
/// Soft Deleted Azure Workload SAP HANA Database Item Class
/// </summary>
public class SoftDeletedVaultAzureWorkloadSAPHanaDatabaseProtectedItem : AzureWorkloadSAPHanaDatabaseProtectedItem
{
/// <summary>
/// Vault ID from which the item was soft deleted
/// </summary>
public string VaultId { get; set; }

/// <summary>
/// Constructor for soft deleted Azure Workload SAP HANA Database item
/// </summary>
/// <param name="protectedItemResource">Mock protected item resource</param>
/// <param name="containerName">Container name</param>
/// <param name="containerType">Container type</param>
/// <param name="policyName">Policy name</param>
public SoftDeletedVaultAzureWorkloadSAPHanaDatabaseProtectedItem(ProtectedItemResource protectedItemResource,
string containerName, ContainerType containerType, string policyName)
: base(protectedItemResource, containerName, containerType, policyName)
{
if (!string.IsNullOrEmpty(protectedItemResource?.Id))
{
VaultId = ModeHelpers.ExtractVaultIdFromSoftDeletedId(protectedItemResource.Id);
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
// ----------------------------------------------------------------------------------
//
// 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.RecoveryServices.Backup.Models;
using System;
using System.Collections.Generic;

namespace Microsoft.Azure.Commands.RecoveryServices.Backup.Cmdlets.Models
{
/// <summary>
/// Soft Deleted Azure Workload SQL Database Item Class
/// </summary>
public class SoftDeletedVaultAzureWorkloadSQLDatabaseProtectedItem : AzureWorkloadSQLDatabaseProtectedItem
{
/// <summary>
/// Vault ID from which the item was soft deleted
/// </summary>
public string VaultId { get; set; }

/// <summary>
/// Constructor for soft deleted Azure Workload SQL Database item
/// </summary>
/// <param name="protectedItemResource">Mock protected item resource</param>
/// <param name="containerName">Container name</param>
/// <param name="containerType">Container type</param>
/// <param name="policyName">Policy name</param>
public SoftDeletedVaultAzureWorkloadSQLDatabaseProtectedItem(ProtectedItemResource protectedItemResource,
string containerName, ContainerType containerType, string policyName)
: base(protectedItemResource, containerName, containerType, policyName)
{
if (!string.IsNullOrEmpty(protectedItemResource?.Id))
{
VaultId = ModeHelpers.ExtractVaultIdFromSoftDeletedId(protectedItemResource.Id);
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
// ----------------------------------------------------------------------------------
//
// 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.RecoveryServices.Backup.Models;
using System;
using System.Collections.Generic;

namespace Microsoft.Azure.Commands.RecoveryServices.Backup.Cmdlets.Models
{
/// <summary>
/// Soft Deleted Azure Workload SQL Database Item Class
/// </summary>
public class ModeHelpers
{
public static string ExtractVaultIdFromSoftDeletedId(string itemId)
{
if (string.IsNullOrEmpty(itemId)) return "";

try
{
var parts = itemId.Split('/');
for (int i = 0; i < parts.Length - 1; i++)
{
if (parts[i].Equals("deletedVaults", StringComparison.OrdinalIgnoreCase))
{
// Build vault ID: /subscriptions/{sub}/providers/Microsoft.RecoveryServices/locations/{loc}/deletedVaults/{vault}
var vaultParts = new List<string>();
for (int j = 0; j <= i + 1; j++)
{
vaultParts.Add(parts[j]);
}
return string.Join("/", vaultParts);
}
}
return "";
}
catch
{
return "";
}
}
}
}
Loading
Loading