Skip to content

Commit c54d981

Browse files
committed
Updates RS SDK
Added ARG SDK Added support for vault soft delete - Get soft deleted vault - Undelete softdeleted vault - Get deleted backup items in a soft deleted vault using ARG
1 parent 94589ab commit c54d981

File tree

103 files changed

+8077
-785
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

103 files changed

+8077
-785
lines changed

src/RecoveryServices/RecoveryServices.Backup.Helpers/Conversions/ConversionHelpers.cs

Lines changed: 496 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
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.Management.RecoveryServices.Backup.Models;
16+
using System;
17+
using System.Collections.Generic;
18+
19+
namespace Microsoft.Azure.Commands.RecoveryServices.Backup.Cmdlets.Models
20+
{
21+
/// <summary>
22+
/// Soft Deleted Azure VM Item Class
23+
/// </summary>
24+
public class SoftDeletedVaultAzureVmItem : AzureVmItem
25+
{
26+
/// <summary>
27+
/// Vault ID from which the item was soft deleted
28+
/// </summary>
29+
public string VaultId { get; set; }
30+
31+
/// <summary>
32+
/// Constructor for soft deleted Azure VM item
33+
/// </summary>
34+
/// <param name="protectedItemResource">Mock protected item resource</param>
35+
/// <param name="containerName">Container name</param>
36+
/// <param name="containerType">Container type</param>
37+
/// <param name="policyName">Policy name</param>
38+
public SoftDeletedVaultAzureVmItem(ProtectedItemResource protectedItemResource,
39+
string containerName, ContainerType containerType, string policyName)
40+
: base(protectedItemResource, containerName, containerType, policyName)
41+
{
42+
// Extract vault ID from the protected item resource ID if available
43+
if (!string.IsNullOrEmpty(protectedItemResource?.Id))
44+
{
45+
VaultId = ModeHelpers.ExtractVaultIdFromSoftDeletedId(protectedItemResource.Id);
46+
}
47+
}
48+
}
49+
}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
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.Management.RecoveryServices.Backup.Models;
16+
using System;
17+
using System.Collections.Generic;
18+
19+
namespace Microsoft.Azure.Commands.RecoveryServices.Backup.Cmdlets.Models
20+
{
21+
/// <summary>
22+
/// Soft Deleted Azure FileShare Item Class
23+
/// </summary>
24+
public class SoftDeletedVaultAzureFileShareItem : AzureFileShareItem
25+
{
26+
/// <summary>
27+
/// Vault ID from which the item was soft deleted
28+
/// </summary>
29+
public string VaultId { get; set; }
30+
31+
/// <summary>
32+
/// Constructor for soft deleted Azure FileShare item
33+
/// </summary>
34+
/// <param name="protectedItemResource">Mock protected item resource</param>
35+
/// <param name="containerName">Container name</param>
36+
/// <param name="containerType">Container type</param>
37+
/// <param name="policyName">Policy name</param>
38+
public SoftDeletedVaultAzureFileShareItem(ProtectedItemResource protectedItemResource,
39+
string containerName, ContainerType containerType, string policyName)
40+
: base(protectedItemResource, containerName, containerType, policyName)
41+
{
42+
if (!string.IsNullOrEmpty(protectedItemResource?.Id))
43+
{
44+
VaultId = ModeHelpers.ExtractVaultIdFromSoftDeletedId(protectedItemResource.Id);
45+
}
46+
}
47+
}
48+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
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.Management.RecoveryServices.Backup.Models;
16+
using System;
17+
using System.Collections.Generic;
18+
19+
namespace Microsoft.Azure.Commands.RecoveryServices.Backup.Cmdlets.Models
20+
{
21+
/// <summary>
22+
/// Soft Deleted Azure Workload SAP HANA Database Item Class
23+
/// </summary>
24+
public class SoftDeletedVaultAzureWorkloadSAPHanaDatabaseProtectedItem : AzureWorkloadSAPHanaDatabaseProtectedItem
25+
{
26+
/// <summary>
27+
/// Vault ID from which the item was soft deleted
28+
/// </summary>
29+
public string VaultId { get; set; }
30+
31+
/// <summary>
32+
/// Constructor for soft deleted Azure Workload SAP HANA Database item
33+
/// </summary>
34+
/// <param name="protectedItemResource">Mock protected item resource</param>
35+
/// <param name="containerName">Container name</param>
36+
/// <param name="containerType">Container type</param>
37+
/// <param name="policyName">Policy name</param>
38+
public SoftDeletedVaultAzureWorkloadSAPHanaDatabaseProtectedItem(ProtectedItemResource protectedItemResource,
39+
string containerName, ContainerType containerType, string policyName)
40+
: base(protectedItemResource, containerName, containerType, policyName)
41+
{
42+
if (!string.IsNullOrEmpty(protectedItemResource?.Id))
43+
{
44+
VaultId = ModeHelpers.ExtractVaultIdFromSoftDeletedId(protectedItemResource.Id);
45+
}
46+
}
47+
}
48+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
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.Management.RecoveryServices.Backup.Models;
16+
using System;
17+
using System.Collections.Generic;
18+
19+
namespace Microsoft.Azure.Commands.RecoveryServices.Backup.Cmdlets.Models
20+
{
21+
/// <summary>
22+
/// Soft Deleted Azure Workload SQL Database Item Class
23+
/// </summary>
24+
public class SoftDeletedVaultAzureWorkloadSQLDatabaseProtectedItem : AzureWorkloadSQLDatabaseProtectedItem
25+
{
26+
/// <summary>
27+
/// Vault ID from which the item was soft deleted
28+
/// </summary>
29+
public string VaultId { get; set; }
30+
31+
/// <summary>
32+
/// Constructor for soft deleted Azure Workload SQL Database item
33+
/// </summary>
34+
/// <param name="protectedItemResource">Mock protected item resource</param>
35+
/// <param name="containerName">Container name</param>
36+
/// <param name="containerType">Container type</param>
37+
/// <param name="policyName">Policy name</param>
38+
public SoftDeletedVaultAzureWorkloadSQLDatabaseProtectedItem(ProtectedItemResource protectedItemResource,
39+
string containerName, ContainerType containerType, string policyName)
40+
: base(protectedItemResource, containerName, containerType, policyName)
41+
{
42+
if (!string.IsNullOrEmpty(protectedItemResource?.Id))
43+
{
44+
VaultId = ModeHelpers.ExtractVaultIdFromSoftDeletedId(protectedItemResource.Id);
45+
}
46+
}
47+
}
48+
}
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
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.Management.RecoveryServices.Backup.Models;
16+
using System;
17+
using System.Collections.Generic;
18+
19+
namespace Microsoft.Azure.Commands.RecoveryServices.Backup.Cmdlets.Models
20+
{
21+
/// <summary>
22+
/// Soft Deleted Azure Workload SQL Database Item Class
23+
/// </summary>
24+
public class ModeHelpers
25+
{
26+
public static string ExtractVaultIdFromSoftDeletedId(string itemId)
27+
{
28+
if (string.IsNullOrEmpty(itemId)) return "";
29+
30+
try
31+
{
32+
var parts = itemId.Split('/');
33+
for (int i = 0; i < parts.Length - 1; i++)
34+
{
35+
if (parts[i].Equals("deletedVaults", StringComparison.OrdinalIgnoreCase))
36+
{
37+
// Build vault ID: /subscriptions/{sub}/providers/Microsoft.RecoveryServices/locations/{loc}/deletedVaults/{vault}
38+
var vaultParts = new List<string>();
39+
for (int j = 0; j <= i + 1; j++)
40+
{
41+
vaultParts.Add(parts[j]);
42+
}
43+
return string.Join("/", vaultParts);
44+
}
45+
}
46+
return "";
47+
}
48+
catch
49+
{
50+
return "";
51+
}
52+
}
53+
}
54+
}

0 commit comments

Comments
 (0)