24
24
using CmdletModel = Microsoft . Azure . Commands . RecoveryServices . Backup . Cmdlets . Models ;
25
25
using RestAzureNS = Microsoft . Rest . Azure ;
26
26
using ServiceClientModel = Microsoft . Azure . Management . RecoveryServices . Backup . Models ;
27
- using System . Net . Http ;
28
27
29
28
namespace Microsoft . Azure . Commands . RecoveryServices . Backup . Cmdlets . ProviderModel
30
29
{
@@ -70,6 +69,8 @@ public RestAzureNS.AzureOperationResponse EnableProtection()
70
69
/// <returns>The job response returned from the service</returns>
71
70
public RestAzureNS . AzureOperationResponse DisableProtection ( )
72
71
{
72
+ string vaultName = ( string ) ProviderData [ VaultParams . VaultName ] ;
73
+ string resourceGroupName = ( string ) ProviderData [ VaultParams . ResourceGroupName ] ;
73
74
bool deleteBackupData = ( bool ) ProviderData [ ItemParams . DeleteBackupData ] ;
74
75
75
76
ItemBase itemBase = ( ItemBase ) ProviderData [ ItemParams . Item ] ;
@@ -84,8 +85,10 @@ public RestAzureNS.AzureOperationResponse DisableProtection()
84
85
if ( deleteBackupData )
85
86
{
86
87
return ServiceClientAdapter . DeleteProtectedItem (
87
- containerUri ,
88
- protectedItemUri ) ;
88
+ containerUri ,
89
+ protectedItemUri ,
90
+ vaultName : vaultName ,
91
+ resourceGroupName : resourceGroupName ) ;
89
92
}
90
93
else
91
94
{
@@ -126,6 +129,8 @@ public void RevokeItemLevelRecoveryAccess()
126
129
/// <returns>Recovery point detail as returned by the service</returns>
127
130
public RecoveryPointBase GetRecoveryPointDetails ( )
128
131
{
132
+ string vaultName = ( string ) ProviderData [ VaultParams . VaultName ] ;
133
+ string resourceGroupName = ( string ) ProviderData [ VaultParams . ResourceGroupName ] ;
129
134
AzureSqlItem item = ProviderData [ RecoveryPointParams . Item ]
130
135
as AzureSqlItem ;
131
136
@@ -136,7 +141,11 @@ public RecoveryPointBase GetRecoveryPointDetails()
136
141
string protectedItemName = HelperUtils . GetProtectedItemUri ( uriDict , item . Id ) ;
137
142
138
143
var rpResponse = ServiceClientAdapter . GetRecoveryPointDetails (
139
- containerUri , protectedItemName , recoveryPointId ) ;
144
+ containerUri ,
145
+ protectedItemName ,
146
+ recoveryPointId ,
147
+ vaultName : vaultName ,
148
+ resourceGroupName : resourceGroupName ) ;
140
149
return RecoveryPointConversions . GetPSAzureRecoveryPoints ( rpResponse , item ) ;
141
150
}
142
151
@@ -146,6 +155,8 @@ public RecoveryPointBase GetRecoveryPointDetails()
146
155
/// <returns>List of recovery point PowerShell model objects</returns>
147
156
public List < RecoveryPointBase > ListRecoveryPoints ( )
148
157
{
158
+ string vaultName = ( string ) ProviderData [ VaultParams . VaultName ] ;
159
+ string resourceGroupName = ( string ) ProviderData [ VaultParams . ResourceGroupName ] ;
149
160
DateTime startDate = ( DateTime ) ( ProviderData [ RecoveryPointParams . StartDate ] ) ;
150
161
DateTime endDate = ( DateTime ) ( ProviderData [ RecoveryPointParams . EndDate ] ) ;
151
162
AzureSqlItem item = ProviderData [ RecoveryPointParams . Item ]
@@ -172,7 +183,11 @@ public List<RecoveryPointBase> ListRecoveryPoints()
172
183
queryFilter . Filter = queryFilterString ;
173
184
174
185
List < RecoveryPointResource > rpListResponse = ServiceClientAdapter . GetRecoveryPoints (
175
- containerUri , protectedItemName , queryFilter ) ;
186
+ containerUri ,
187
+ protectedItemName ,
188
+ queryFilter ,
189
+ vaultName : vaultName ,
190
+ resourceGroupName : resourceGroupName ) ;
176
191
return RecoveryPointConversions . GetPSAzureRecoveryPoints ( rpListResponse , item ) ;
177
192
}
178
193
@@ -182,6 +197,8 @@ public List<RecoveryPointBase> ListRecoveryPoints()
182
197
/// <returns>Created policy object as returned by the service</returns>
183
198
public ProtectionPolicyResource CreatePolicy ( )
184
199
{
200
+ string vaultName = ( string ) ProviderData [ VaultParams . VaultName ] ;
201
+ string resourceGroupName = ( string ) ProviderData [ VaultParams . ResourceGroupName ] ;
185
202
string policyName = ( string ) ProviderData [ PolicyParams . PolicyName ] ;
186
203
CmdletModel . WorkloadType workloadType =
187
204
( CmdletModel . WorkloadType ) ProviderData [ PolicyParams . WorkloadType ] ;
@@ -197,7 +214,7 @@ public ProtectionPolicyResource CreatePolicy()
197
214
Logger . Instance . WriteDebug ( "Validation of Retention policy is successful" ) ;
198
215
199
216
// construct Hydra policy request
200
- ProtectionPolicyResource hydraRequest = new ProtectionPolicyResource ( )
217
+ ProtectionPolicyResource protectionPolicyResource = new ProtectionPolicyResource ( )
201
218
{
202
219
Properties = new AzureSqlProtectionPolicy ( )
203
220
{
@@ -207,8 +224,10 @@ public ProtectionPolicyResource CreatePolicy()
207
224
} ;
208
225
209
226
return ServiceClientAdapter . CreateOrUpdateProtectionPolicy (
210
- policyName ,
211
- hydraRequest ) . Body ;
227
+ policyName ,
228
+ protectionPolicyResource ,
229
+ vaultName : vaultName ,
230
+ resourceGroupName : resourceGroupName ) . Body ;
212
231
}
213
232
214
233
/// <summary>
@@ -217,6 +236,8 @@ public ProtectionPolicyResource CreatePolicy()
217
236
/// <returns>Modified policy object as returned by the service</returns>
218
237
public RestAzureNS . AzureOperationResponse < ProtectionPolicyResource > ModifyPolicy ( )
219
238
{
239
+ string vaultName = ( string ) ProviderData [ VaultParams . VaultName ] ;
240
+ string resourceGroupName = ( string ) ProviderData [ VaultParams . ResourceGroupName ] ;
220
241
RetentionPolicyBase retentionPolicy =
221
242
ProviderData . ContainsKey ( PolicyParams . RetentionPolicy ) ?
222
243
( RetentionPolicyBase ) ProviderData [ PolicyParams . RetentionPolicy ] :
@@ -241,7 +262,7 @@ public RestAzureNS.AzureOperationResponse<ProtectionPolicyResource> ModifyPolicy
241
262
242
263
CmdletModel . SimpleRetentionPolicy sqlRetentionPolicy =
243
264
( CmdletModel . SimpleRetentionPolicy ) ( ( AzureSqlPolicy ) policy ) . RetentionPolicy ;
244
- ProtectionPolicyResource hydraRequest = new ProtectionPolicyResource ( )
265
+ ProtectionPolicyResource protectionPolicyResource = new ProtectionPolicyResource ( )
245
266
{
246
267
Properties = new AzureSqlProtectionPolicy ( )
247
268
{
@@ -250,8 +271,11 @@ public RestAzureNS.AzureOperationResponse<ProtectionPolicyResource> ModifyPolicy
250
271
}
251
272
} ;
252
273
253
- return ServiceClientAdapter . CreateOrUpdateProtectionPolicy ( policy . Name ,
254
- hydraRequest ) ;
274
+ return ServiceClientAdapter . CreateOrUpdateProtectionPolicy (
275
+ policy . Name ,
276
+ protectionPolicyResource ,
277
+ vaultName : vaultName ,
278
+ resourceGroupName : resourceGroupName ) ;
255
279
}
256
280
257
281
/// <summary>
@@ -260,15 +284,19 @@ public RestAzureNS.AzureOperationResponse<ProtectionPolicyResource> ModifyPolicy
260
284
/// <returns>List of protection containers</returns>
261
285
public List < ContainerBase > ListProtectionContainers ( )
262
286
{
263
- string name = ( string ) this . ProviderData [ ContainerParams . Name ] ;
287
+ string vaultName = ( string ) ProviderData [ VaultParams . VaultName ] ;
288
+ string resourceGroupName = ( string ) ProviderData [ VaultParams . ResourceGroupName ] ;
289
+ string name = ( string ) ProviderData [ ContainerParams . Name ] ;
264
290
265
291
ODataQuery < BMSContainerQueryObject > queryParams =
266
292
new ODataQuery < BMSContainerQueryObject > (
267
293
q => q . BackupManagementType
268
294
== ServiceClientModel . BackupManagementType . AzureSql ) ;
269
295
270
-
271
- var listResponse = ServiceClientAdapter . ListContainers ( queryParams ) ;
296
+ var listResponse = ServiceClientAdapter . ListContainers (
297
+ queryParams ,
298
+ vaultName : vaultName ,
299
+ resourceGroupName : resourceGroupName ) ;
272
300
273
301
List < ContainerBase > containerModels =
274
302
ConversionHelpers . GetContainerModelList ( listResponse ) ;
@@ -317,6 +345,8 @@ public RetentionPolicyBase GetDefaultRetentionPolicyObject()
317
345
/// <returns>List of protected items</returns>
318
346
public List < ItemBase > ListProtectedItems ( )
319
347
{
348
+ string vaultName = ( string ) ProviderData [ VaultParams . VaultName ] ;
349
+ string resourceGroupName = ( string ) ProviderData [ VaultParams . ResourceGroupName ] ;
320
350
ContainerBase container = ( ContainerBase ) ProviderData [ ItemParams . Container ] ;
321
351
string name = ( string ) ProviderData [ ItemParams . AzureVMName ] ;
322
352
ItemProtectionStatus protectionStatus =
@@ -334,10 +364,13 @@ public List<ItemBase> ListProtectedItems()
334
364
335
365
List < ProtectedItemResource > protectedItems = new List < ProtectedItemResource > ( ) ;
336
366
string skipToken = null ;
337
- var listResponse = ServiceClientAdapter . ListProtectedItem ( queryParams , skipToken ) ;
367
+ var listResponse = ServiceClientAdapter . ListProtectedItem (
368
+ queryParams ,
369
+ skipToken ,
370
+ vaultName : vaultName ,
371
+ resourceGroupName : resourceGroupName ) ;
338
372
protectedItems . AddRange ( listResponse ) ;
339
373
340
-
341
374
// 1. Filter by container
342
375
if ( container != null )
343
376
{
@@ -379,7 +412,11 @@ public List<ItemBase> ListProtectedItems()
379
412
HelperUtils . GetProtectedItemUri ( dictionary , protectedItems [ i ] . Id ) ;
380
413
381
414
var getResponse = ServiceClientAdapter . GetProtectedItem (
382
- containerUri , protectedItemUri , getItemQueryParams ) ;
415
+ containerUri ,
416
+ protectedItemUri ,
417
+ getItemQueryParams ,
418
+ vaultName : vaultName ,
419
+ resourceGroupName : resourceGroupName ) ;
383
420
protectedItemGetResponses . Add ( getResponse . Body ) ;
384
421
}
385
422
}
0 commit comments