17
17
using Microsoft . Azure . Commands . RecoveryServices . Backup . Helpers ;
18
18
using Microsoft . Azure . Commands . RecoveryServices . Backup . Properties ;
19
19
using Microsoft . Azure . Management . Internal . Resources . Models ;
20
- using Microsoft . Azure . Management . Internal . Resources . Utilities . Models ;
21
20
using Microsoft . Azure . Management . RecoveryServices . Backup . Models ;
22
21
using Microsoft . Rest . Azure . OData ;
23
22
using System ;
27
26
using CmdletModel = Microsoft . Azure . Commands . RecoveryServices . Backup . Cmdlets . Models ;
28
27
using RestAzureNS = Microsoft . Rest . Azure ;
29
28
using ServiceClientModel = Microsoft . Azure . Management . RecoveryServices . Backup . Models ;
30
- using SystemNet = System . Net ;
31
29
32
30
namespace Microsoft . Azure . Commands . RecoveryServices . Backup . Cmdlets . ProviderModel
33
31
{
@@ -65,7 +63,7 @@ public void Initialize(
65
63
/// Triggers the enable protection operation for the given item
66
64
/// </summary>
67
65
/// <returns>The job response returned from the service</returns>
68
- public RestAzureNS . AzureOperationResponse EnableProtection ( )
66
+ public RestAzureNS . AzureOperationResponse < ProtectedItemResource > EnableProtection ( )
69
67
{
70
68
return EnableOrModifyProtection ( ) ;
71
69
}
@@ -74,7 +72,24 @@ public RestAzureNS.AzureOperationResponse EnableProtection()
74
72
/// Triggers the disable protection operation for the given item
75
73
/// </summary>
76
74
/// <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 ( )
78
93
{
79
94
string vaultName = ( string ) ProviderData [ VaultParams . VaultName ] ;
80
95
string vaultResourceGroupName = ( string ) ProviderData [ VaultParams . ResourceGroupName ] ;
@@ -89,25 +104,17 @@ public RestAzureNS.AzureOperationResponse DisableProtection()
89
104
string protectedItemUri = "" ;
90
105
AzureFileshareProtectedItem properties = new AzureFileshareProtectedItem ( ) ;
91
106
92
- if ( deleteBackupData )
93
- {
94
- //Disable protection and delete backup data
95
- ValidateAzureFileShareDisableProtectionRequest ( itemBase ) ;
107
+ ValidateAzureFileShareDisableProtectionRequest ( itemBase ) ;
96
108
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 ) ;
100
112
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 ) ;
111
118
}
112
119
113
120
public List < ContainerBase > ListProtectionContainers ( )
@@ -476,7 +483,8 @@ private WorkloadProtectableItemResource GetAzureFileShareProtectableObject(
476
483
}
477
484
478
485
//inquiry
479
- TriggerInquiry ( vaultName , vaultResourceGroupName , storageContainerName ) ;
486
+ AzureWorkloadProviderHelper . TriggerInquiry ( vaultName , vaultResourceGroupName ,
487
+ storageContainerName , ServiceClientModel . WorkloadType . AzureFileShare ) ;
480
488
481
489
//get protectable item
482
490
WorkloadProtectableItemResource protectableObjectResource = null ;
@@ -532,37 +540,6 @@ private WorkloadProtectableItemResource GetProtectableItem(string vaultName, str
532
540
return protectableObjectResource ;
533
541
}
534
542
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
-
566
543
private List < ContainerBase > GetRegisteredStorageAccounts ( string vaultName = null ,
567
544
string vaultResourceGroupName = null )
568
545
{
@@ -700,7 +677,12 @@ public List<ItemBase> ListProtectedItems()
700
677
return itemModels ;
701
678
}
702
679
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 )
704
686
{
705
687
string vaultName = ( string ) ProviderData [ VaultParams . VaultName ] ;
706
688
string vaultResourceGroupName = ( string ) ProviderData [ VaultParams . ResourceGroupName ] ;
@@ -914,5 +896,10 @@ private void ValidateLocationRestoreRequest(string targetFileShareName, string t
914
896
throw new ArgumentException ( string . Format ( Resources . AzureFileTargetSANameMissingException ) ) ;
915
897
}
916
898
}
899
+
900
+ public List < PointInTimeBase > GetLogChains ( )
901
+ {
902
+ throw new NotImplementedException ( ) ;
903
+ }
917
904
}
918
905
}
0 commit comments