Skip to content

Commit 48cd964

Browse files
committed
SDK Update
1 parent 838e1cd commit 48cd964

27 files changed

+1294939
-82
lines changed

src/RecoveryServices/RecoveryServices.Backup.Helpers/RecoveryServices.Backup.Helpers.csproj

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@
1212
</PropertyGroup>
1313

1414
<ItemGroup>
15-
<PackageReference Include="Microsoft.Azure.Management.RecoveryServices.Backup" Version="3.0.1-preview" />
15+
<PackageReference Include="Microsoft.Azure.Management.RecoveryServices.Backup" Version="3.1.1-preview" />
16+
<PackageReference Include="Microsoft.Rest.ClientRuntime" Version="2.3.19" />
17+
<PackageReference Include="Microsoft.Rest.ClientRuntime.Azure" Version="3.3.19" />
1618
</ItemGroup>
1719

1820
<ItemGroup>

src/RecoveryServices/RecoveryServices.Backup.Models/RecoveryServices.Backup.Models.csproj

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@
1212
</PropertyGroup>
1313

1414
<ItemGroup>
15-
<PackageReference Include="Microsoft.Azure.Management.RecoveryServices.Backup" Version="3.0.1-preview" />
15+
<PackageReference Include="Microsoft.Azure.Management.RecoveryServices.Backup" Version="3.1.1-preview" />
16+
<PackageReference Include="Microsoft.Rest.ClientRuntime" Version="2.3.19" />
17+
<PackageReference Include="Microsoft.Rest.ClientRuntime.Azure" Version="3.3.19" />
1618
</ItemGroup>
1719

1820
</Project>

src/RecoveryServices/RecoveryServices.Backup.Providers/IPsBackupProvider.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@ public interface IPsBackupProvider
2929
{
3030
void Initialize(Dictionary<System.Enum, object> providerData, ServiceClientAdapter serviceClientAdapter);
3131

32-
RestAzureNS.AzureOperationResponse EnableProtection();
32+
RestAzureNS.AzureOperationResponse<ProtectedItemResource> EnableProtection();
3333

34-
RestAzureNS.AzureOperationResponse DisableProtection();
34+
RestAzureNS.AzureOperationResponse<ProtectedItemResource> DisableProtection();
3535

3636
RestAzureNS.AzureOperationResponse TriggerBackup();
3737

src/RecoveryServices/RecoveryServices.Backup.Providers/Providers/AzureFilesPsBackupProvider.cs

Lines changed: 41 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
using Microsoft.Azure.Commands.RecoveryServices.Backup.Helpers;
1818
using Microsoft.Azure.Commands.RecoveryServices.Backup.Properties;
1919
using Microsoft.Azure.Management.Internal.Resources.Models;
20-
using Microsoft.Azure.Management.Internal.Resources.Utilities.Models;
2120
using Microsoft.Azure.Management.RecoveryServices.Backup.Models;
2221
using Microsoft.Rest.Azure.OData;
2322
using System;
@@ -27,7 +26,6 @@
2726
using CmdletModel = Microsoft.Azure.Commands.RecoveryServices.Backup.Cmdlets.Models;
2827
using RestAzureNS = Microsoft.Rest.Azure;
2928
using ServiceClientModel = Microsoft.Azure.Management.RecoveryServices.Backup.Models;
30-
using SystemNet = System.Net;
3129

3230
namespace Microsoft.Azure.Commands.RecoveryServices.Backup.Cmdlets.ProviderModel
3331
{
@@ -65,7 +63,7 @@ public void Initialize(
6563
/// Triggers the enable protection operation for the given item
6664
/// </summary>
6765
/// <returns>The job response returned from the service</returns>
68-
public RestAzureNS.AzureOperationResponse EnableProtection()
66+
public RestAzureNS.AzureOperationResponse<ProtectedItemResource> EnableProtection()
6967
{
7068
return EnableOrModifyProtection();
7169
}
@@ -74,7 +72,24 @@ public RestAzureNS.AzureOperationResponse EnableProtection()
7472
/// Triggers the disable protection operation for the given item
7573
/// </summary>
7674
/// <returns>The job response returned from the service</returns>
77-
public RestAzureNS.AzureOperationResponse DisableProtection()
75+
public RestAzureNS.AzureOperationResponse<ProtectedItemResource> DisableProtection()
76+
{
77+
string vaultName = (string)ProviderData[VaultParams.VaultName];
78+
string vaultResourceGroupName = (string)ProviderData[VaultParams.ResourceGroupName];
79+
bool deleteBackupData = ProviderData.ContainsKey(ItemParams.DeleteBackupData) ?
80+
(bool)ProviderData[ItemParams.DeleteBackupData] : false;
81+
82+
ItemBase itemBase = (ItemBase)ProviderData[ItemParams.Item];
83+
84+
AzureFileShareItem item = (AzureFileShareItem)ProviderData[ItemParams.Item];
85+
86+
AzureFileshareProtectedItem properties = new AzureFileshareProtectedItem();
87+
88+
return EnableOrModifyProtection(disableWithRetentionData: true);
89+
90+
}
91+
92+
public RestAzureNS.AzureOperationResponse DisableProtectionWithDeleteData()
7893
{
7994
string vaultName = (string)ProviderData[VaultParams.VaultName];
8095
string vaultResourceGroupName = (string)ProviderData[VaultParams.ResourceGroupName];
@@ -89,25 +104,17 @@ public RestAzureNS.AzureOperationResponse DisableProtection()
89104
string protectedItemUri = "";
90105
AzureFileshareProtectedItem properties = new AzureFileshareProtectedItem();
91106

92-
if (deleteBackupData)
93-
{
94-
//Disable protection and delete backup data
95-
ValidateAzureFileShareDisableProtectionRequest(itemBase);
107+
ValidateAzureFileShareDisableProtectionRequest(itemBase);
96108

97-
Dictionary<UriEnums, string> keyValueDict = HelperUtils.ParseUri(item.Id);
98-
containerUri = HelperUtils.GetContainerUri(keyValueDict, item.Id);
99-
protectedItemUri = HelperUtils.GetProtectedItemUri(keyValueDict, item.Id);
109+
Dictionary<UriEnums, string> keyValueDict = HelperUtils.ParseUri(item.Id);
110+
containerUri = HelperUtils.GetContainerUri(keyValueDict, item.Id);
111+
protectedItemUri = HelperUtils.GetProtectedItemUri(keyValueDict, item.Id);
100112

101-
return ServiceClientAdapter.DeleteProtectedItem(
102-
containerUri,
103-
protectedItemUri,
104-
vaultName: vaultName,
105-
resourceGroupName: vaultResourceGroupName);
106-
}
107-
else
108-
{
109-
return EnableOrModifyProtection(disableWithRetentionData: true);
110-
}
113+
return ServiceClientAdapter.DeleteProtectedItem(
114+
containerUri,
115+
protectedItemUri,
116+
vaultName: vaultName,
117+
resourceGroupName: vaultResourceGroupName);
111118
}
112119

113120
public List<ContainerBase> ListProtectionContainers()
@@ -476,7 +483,8 @@ private WorkloadProtectableItemResource GetAzureFileShareProtectableObject(
476483
}
477484

478485
//inquiry
479-
TriggerInquiry(vaultName, vaultResourceGroupName, storageContainerName);
486+
AzureWorkloadProviderHelper.TriggerInquiry(vaultName, vaultResourceGroupName,
487+
storageContainerName, ServiceClientModel.WorkloadType.AzureFileShare);
480488

481489
//get protectable item
482490
WorkloadProtectableItemResource protectableObjectResource = null;
@@ -532,37 +540,6 @@ private WorkloadProtectableItemResource GetProtectableItem(string vaultName, str
532540
return protectableObjectResource;
533541
}
534542

535-
private void TriggerInquiry(string vaultName, string vaultResourceGroupName,
536-
string storageContainerName)
537-
{
538-
ODataQuery<BMSContainersInquiryQueryObject> queryParams = new ODataQuery<BMSContainersInquiryQueryObject>(
539-
q => q.WorkloadType
540-
== ServiceClientModel.WorkloadType.AzureFileShare);
541-
string errorMessage = string.Empty;
542-
var inquiryResponse = ServiceClientAdapter.InquireContainer(
543-
storageContainerName,
544-
queryParams,
545-
vaultName,
546-
vaultResourceGroupName);
547-
548-
var operationStatus = TrackingHelpers.GetOperationResult(
549-
inquiryResponse,
550-
operationId =>
551-
ServiceClientAdapter.GetContainerRefreshOrInquiryOperationResult(
552-
operationId,
553-
vaultName: vaultName,
554-
resourceGroupName: vaultResourceGroupName));
555-
556-
//Now wait for the operation to Complete
557-
if (inquiryResponse.Response.StatusCode
558-
!= SystemNet.HttpStatusCode.NoContent)
559-
{
560-
errorMessage = string.Format(Resources.TriggerEnquiryFailureErrorCode,
561-
inquiryResponse.Response.StatusCode);
562-
Logger.Instance.WriteDebug(errorMessage);
563-
}
564-
}
565-
566543
private List<ContainerBase> GetRegisteredStorageAccounts(string vaultName = null,
567544
string vaultResourceGroupName = null)
568545
{
@@ -700,7 +677,12 @@ public List<ItemBase> ListProtectedItems()
700677
return itemModels;
701678
}
702679

703-
private RestAzureNS.AzureOperationResponse EnableOrModifyProtection(bool disableWithRetentionData = false)
680+
public void RegisterContainer()
681+
{
682+
throw new NotImplementedException();
683+
}
684+
685+
private RestAzureNS.AzureOperationResponse<ProtectedItemResource> EnableOrModifyProtection(bool disableWithRetentionData = false)
704686
{
705687
string vaultName = (string)ProviderData[VaultParams.VaultName];
706688
string vaultResourceGroupName = (string)ProviderData[VaultParams.ResourceGroupName];
@@ -914,5 +896,10 @@ private void ValidateLocationRestoreRequest(string targetFileShareName, string t
914896
throw new ArgumentException(string.Format(Resources.AzureFileTargetSANameMissingException));
915897
}
916898
}
899+
900+
public List<PointInTimeBase> GetLogChains()
901+
{
902+
throw new NotImplementedException();
903+
}
917904
}
918905
}

src/RecoveryServices/RecoveryServices.Backup.Providers/Providers/AzureSqlPsBackupProvider.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public void Initialize(
5858
ServiceClientAdapter = serviceClientAdapter;
5959
}
6060

61-
public RestAzureNS.AzureOperationResponse EnableProtection()
61+
public RestAzureNS.AzureOperationResponse<ProtectedItemResource> EnableProtection()
6262
{
6363
throw new NotImplementedException();
6464
}
@@ -67,7 +67,7 @@ public RestAzureNS.AzureOperationResponse EnableProtection()
6767
/// Triggers the disable protection operation for the given item
6868
/// </summary>
6969
/// <returns>The job response returned from the service</returns>
70-
public RestAzureNS.AzureOperationResponse DisableProtection()
70+
public RestAzureNS.AzureOperationResponse<ProtectedItemResource> DisableProtection()
7171
{
7272
string vaultName = (string)ProviderData[VaultParams.VaultName];
7373
string resourceGroupName = (string)ProviderData[VaultParams.ResourceGroupName];

0 commit comments

Comments
 (0)