@@ -49,110 +49,17 @@ public static List<RecoveryPointBase> GetPSAzureRecoveryPoints(
49
49
{
50
50
if ( rp . Properties . GetType ( ) == typeof ( ServiceClientModel . IaasVMRecoveryPoint ) )
51
51
{
52
- ServiceClientModel . IaasVMRecoveryPoint recPoint =
53
- rp . Properties as ServiceClientModel . IaasVMRecoveryPoint ;
54
-
55
- DateTime recPointTime = DateTime . MinValue ;
56
- if ( recPoint . RecoveryPointTime . HasValue )
57
- {
58
- recPointTime = ( DateTime ) recPoint . RecoveryPointTime ;
59
- }
60
- else
61
- {
62
- throw new ArgumentNullException ( "RecoveryPointTime is null" ) ;
63
- }
64
-
65
- bool isInstantILRSessionActive =
66
- recPoint . IsInstantIlrSessionActive . HasValue ?
67
- ( bool ) recPoint . IsInstantIlrSessionActive : false ;
68
-
69
- AzureVmRecoveryPoint rpBase = new AzureVmRecoveryPoint ( )
70
- {
71
- RecoveryPointId = rp . Name ,
72
- BackupManagementType = item . BackupManagementType ,
73
- ItemName = protectedItemName ,
74
- ContainerName = containerName ,
75
- ContainerType = item . ContainerType ,
76
- RecoveryPointTime = recPointTime ,
77
- RecoveryPointType = recPoint . RecoveryPointType ,
78
- Id = rp . Id ,
79
- WorkloadType = item . WorkloadType ,
80
- RecoveryPointAdditionalInfo = recPoint . RecoveryPointAdditionalInfo ,
81
- SourceVMStorageType = recPoint . SourceVMStorageType ,
82
- SourceResourceId = item . SourceResourceId ,
83
- EncryptionEnabled = recPoint . IsSourceVMEncrypted . HasValue ?
84
- recPoint . IsSourceVMEncrypted . Value : false ,
85
- IlrSessionActive = isInstantILRSessionActive ,
86
- IsManagedVirtualMachine = recPoint . IsManagedVirtualMachine . HasValue ?
87
- recPoint . IsManagedVirtualMachine . Value : false ,
88
- OriginalSAEnabled = recPoint . OriginalStorageAccountOption . HasValue ?
89
- recPoint . OriginalStorageAccountOption . Value : false ,
90
- } ;
91
- result . Add ( rpBase ) ;
52
+ result . Add ( GetPSAzureVMRecoveryPoint ( rp , item ) ) ;
92
53
}
93
54
94
55
if ( rp . Properties . GetType ( ) == typeof ( ServiceClientModel . AzureFileShareRecoveryPoint ) )
95
56
{
96
- ServiceClientModel . AzureFileShareRecoveryPoint recPoint =
97
- rp . Properties as ServiceClientModel . AzureFileShareRecoveryPoint ;
98
-
99
- DateTime recPointTime = DateTime . MinValue ;
100
- if ( recPoint . RecoveryPointTime . HasValue )
101
- {
102
- recPointTime = ( DateTime ) recPoint . RecoveryPointTime ;
103
- }
104
- else
105
- {
106
- throw new ArgumentNullException ( "RecoveryPointTime is null" ) ;
107
- }
108
-
109
- AzureFileShareRecoveryPoint rpBase = new AzureFileShareRecoveryPoint ( )
110
- {
111
- RecoveryPointId = rp . Name ,
112
- BackupManagementType = item . BackupManagementType ,
113
- ItemName = protectedItemName ,
114
- ContainerName = containerName ,
115
- ContainerType = item . ContainerType ,
116
- RecoveryPointTime = recPointTime ,
117
- RecoveryPointType = recPoint . RecoveryPointType ,
118
- Id = rp . Id ,
119
- WorkloadType = item . WorkloadType ,
120
- FileShareSnapshotUri = recPoint . FileShareSnapshotUri ,
121
- } ;
122
- result . Add ( rpBase ) ;
57
+ result . Add ( GetPSAzureFileRecoveryPoint ( rp , item ) ) ;
123
58
}
124
59
125
60
if ( rp . Properties . GetType ( ) == typeof ( ServiceClientModel . GenericRecoveryPoint ) )
126
61
{
127
- ServiceClientModel . GenericRecoveryPoint recPoint =
128
- rp . Properties as ServiceClientModel . GenericRecoveryPoint ;
129
-
130
- DateTime recPointTime = DateTime . MinValue ;
131
- if ( recPoint . RecoveryPointTime . HasValue )
132
- {
133
- recPointTime = ( DateTime ) recPoint . RecoveryPointTime ;
134
- }
135
- else
136
- {
137
- throw new ArgumentNullException ( "RecoveryPointTime is null" ) ;
138
- }
139
-
140
- AzureSqlRecoveryPoint rpBase = new AzureSqlRecoveryPoint ( )
141
- {
142
- RecoveryPointId = rp . Name ,
143
- BackupManagementType = item . BackupManagementType ,
144
- ItemName = protectedItemName ,
145
- ContainerName = containerUri ,
146
- ContainerType = item . ContainerType ,
147
- RecoveryPointTime = recPointTime ,
148
- RecoveryPointType = recPoint . RecoveryPointType ,
149
- Id = rp . Id ,
150
- WorkloadType = item . WorkloadType ,
151
- RecoveryPointAdditionalInfo = recPoint . RecoveryPointAdditionalInfo ,
152
- FriendlyName = recPoint . FriendlyName ,
153
- } ;
154
-
155
- result . Add ( rpBase ) ;
62
+ result . Add ( GetPSAzureGenericRecoveryPoint ( rp , item ) ) ;
156
63
}
157
64
}
158
65
@@ -173,136 +80,167 @@ public static RecoveryPointBase GetPSAzureRecoveryPoints(
173
80
174
81
RecoveryPointBase result = null ;
175
82
176
- Dictionary < UriEnums , string > uriDict = HelperUtils . ParseUri ( item . Id ) ;
177
- string containerUri = HelperUtils . GetContainerUri ( uriDict , item . Id ) ;
178
- string containerName = IdUtils . GetNameFromUri ( containerUri ) ;
179
- string protectedItemUri = HelperUtils . GetProtectedItemUri ( uriDict , item . Id ) ;
180
- string protectedItemName = IdUtils . GetNameFromUri ( protectedItemUri ) ;
181
-
182
83
if ( rpResponse . Properties . GetType ( ) ==
183
84
typeof ( ServiceClientModel . IaasVMRecoveryPoint ) )
184
85
{
185
- ServiceClientModel . IaasVMRecoveryPoint recPoint =
186
- rpResponse . Properties as ServiceClientModel . IaasVMRecoveryPoint ;
86
+ result = GetPSAzureVMRecoveryPoint ( rpResponse , item ) ;
87
+ }
187
88
188
- DateTime recPointTime = DateTime . MinValue ;
189
- if ( recPoint . RecoveryPointTime . HasValue )
190
- {
191
- recPointTime = ( DateTime ) recPoint . RecoveryPointTime ;
192
- }
193
- else
194
- {
195
- throw new ArgumentNullException ( "RecoveryPointTime is null" ) ;
196
- }
89
+ if ( rpResponse . Properties . GetType ( ) ==
90
+ typeof ( ServiceClientModel . AzureFileShareRecoveryPoint ) )
91
+ {
92
+ result = GetPSAzureFileRecoveryPoint ( rpResponse , item ) ;
93
+ }
197
94
198
- bool isInstantILRSessionActive =
199
- recPoint . IsInstantIlrSessionActive . HasValue ?
200
- ( bool ) recPoint . IsInstantIlrSessionActive : false ;
201
- AzureVmRecoveryPoint vmResult = new AzureVmRecoveryPoint ( )
202
- {
203
- RecoveryPointId = rpResponse . Name ,
204
- BackupManagementType = item . BackupManagementType ,
205
- ItemName = protectedItemName ,
206
- ContainerName = containerName ,
207
- ContainerType = item . ContainerType ,
208
- RecoveryPointTime = recPointTime ,
209
- RecoveryPointType = recPoint . RecoveryPointType ,
210
- Id = rpResponse . Id ,
211
- WorkloadType = item . WorkloadType ,
212
- RecoveryPointAdditionalInfo = recPoint . RecoveryPointAdditionalInfo ,
213
- EncryptionEnabled = recPoint . IsSourceVMEncrypted . HasValue ?
214
- recPoint . IsSourceVMEncrypted . Value : false ,
215
- IlrSessionActive = isInstantILRSessionActive ,
216
- SourceResourceId = item . SourceResourceId ,
217
- SourceVMStorageType = recPoint . SourceVMStorageType ,
218
- OriginalSAEnabled = recPoint . OriginalStorageAccountOption . HasValue ?
219
- recPoint . OriginalStorageAccountOption . Value : false ,
220
- } ;
95
+ if ( rpResponse . Properties . GetType ( ) ==
96
+ typeof ( ServiceClientModel . GenericRecoveryPoint ) )
97
+ {
98
+ result = GetPSAzureGenericRecoveryPoint ( rpResponse , item ) ;
99
+ }
100
+ return result ;
101
+ }
221
102
222
- if ( vmResult . EncryptionEnabled && recPoint . KeyAndSecret != null )
223
- {
224
- vmResult . KeyAndSecretDetails = new KeyAndSecretDetails ( )
225
- {
226
- SecretUrl = recPoint . KeyAndSecret . BekDetails . SecretUrl ,
227
- KeyUrl = recPoint . KeyAndSecret . KekDetails . KeyUrl ,
228
- SecretData = recPoint . KeyAndSecret . BekDetails . SecretData ,
229
- KeyBackupData = recPoint . KeyAndSecret . KekDetails . KeyBackupData ,
230
- KeyVaultId = recPoint . KeyAndSecret . KekDetails . KeyVaultId ,
231
- SecretVaultId = recPoint . KeyAndSecret . BekDetails . SecretVaultId ,
232
- } ;
233
- }
103
+ public static RecoveryPointBase GetPSAzureVMRecoveryPoint (
104
+ ServiceClientModel . RecoveryPointResource rp , ItemBase item )
105
+ {
106
+ Dictionary < UriEnums , string > uriDict = HelperUtils . ParseUri ( item . Id ) ;
107
+ string containerUri = HelperUtils . GetContainerUri ( uriDict , item . Id ) ;
108
+ string protectedItemUri = HelperUtils . GetProtectedItemUri ( uriDict , item . Id ) ;
234
109
235
- result = vmResult ;
236
- }
110
+ string containerName = IdUtils . GetNameFromUri ( containerUri ) ;
111
+ string protectedItemName = IdUtils . GetNameFromUri ( protectedItemUri ) ;
237
112
238
- if ( rpResponse . Properties . GetType ( ) ==
239
- typeof ( ServiceClientModel . AzureFileShareRecoveryPoint ) )
113
+ ServiceClientModel . IaasVMRecoveryPoint recoveryPoint =
114
+ rp . Properties as ServiceClientModel . IaasVMRecoveryPoint ;
115
+
116
+ DateTime recoveryPointTime = DateTime . MinValue ;
117
+ if ( recoveryPoint . RecoveryPointTime . HasValue )
240
118
{
241
- ServiceClientModel . AzureFileShareRecoveryPoint recPoint =
242
- rpResponse . Properties as ServiceClientModel . AzureFileShareRecoveryPoint ;
119
+ recoveryPointTime = ( DateTime ) recoveryPoint . RecoveryPointTime ;
120
+ }
121
+ else
122
+ {
123
+ throw new ArgumentNullException ( "RecoveryPointTime is null" ) ;
124
+ }
243
125
244
- DateTime recPointTime = DateTime . MinValue ;
245
- if ( recPoint . RecoveryPointTime . HasValue )
246
- {
247
- recPointTime = ( DateTime ) recPoint . RecoveryPointTime ;
248
- }
249
- else
250
- {
251
- throw new ArgumentNullException ( "RecoveryPointTime is null" ) ;
252
- }
126
+ bool isInstantILRSessionActive =
127
+ recoveryPoint . IsInstantIlrSessionActive . HasValue ?
128
+ ( bool ) recoveryPoint . IsInstantIlrSessionActive : false ;
253
129
254
- AzureFileShareRecoveryPoint fileResult = new AzureFileShareRecoveryPoint ( )
130
+ AzureVmRecoveryPoint rpBase = new AzureVmRecoveryPoint ( )
131
+ {
132
+ RecoveryPointId = rp . Name ,
133
+ BackupManagementType = item . BackupManagementType ,
134
+ ItemName = protectedItemName ,
135
+ ContainerName = containerName ,
136
+ ContainerType = item . ContainerType ,
137
+ RecoveryPointTime = recoveryPointTime ,
138
+ RecoveryPointType = recoveryPoint . RecoveryPointType ,
139
+ Id = rp . Id ,
140
+ WorkloadType = item . WorkloadType ,
141
+ RecoveryPointAdditionalInfo = recoveryPoint . RecoveryPointAdditionalInfo ,
142
+ SourceVMStorageType = recoveryPoint . SourceVMStorageType ,
143
+ SourceResourceId = item . SourceResourceId ,
144
+ EncryptionEnabled = recoveryPoint . IsSourceVMEncrypted . HasValue ?
145
+ recoveryPoint . IsSourceVMEncrypted . Value : false ,
146
+ IlrSessionActive = isInstantILRSessionActive ,
147
+ IsManagedVirtualMachine = recoveryPoint . IsManagedVirtualMachine . HasValue ?
148
+ recoveryPoint . IsManagedVirtualMachine . Value : false ,
149
+ OriginalSAEnabled = recoveryPoint . OriginalStorageAccountOption . HasValue ?
150
+ recoveryPoint . OriginalStorageAccountOption . Value : false ,
151
+ } ;
152
+
153
+ if ( rpBase . EncryptionEnabled && recoveryPoint . KeyAndSecret != null )
154
+ {
155
+ rpBase . KeyAndSecretDetails = new KeyAndSecretDetails ( )
255
156
{
256
- RecoveryPointId = rpResponse . Name ,
257
- BackupManagementType = item . BackupManagementType ,
258
- ItemName = protectedItemName ,
259
- ContainerName = containerName ,
260
- ContainerType = item . ContainerType ,
261
- RecoveryPointTime = recPointTime ,
262
- RecoveryPointType = recPoint . RecoveryPointType ,
263
- Id = rpResponse . Id ,
264
- WorkloadType = item . WorkloadType ,
265
- FileShareSnapshotUri = recPoint . FileShareSnapshotUri
157
+ SecretUrl = recoveryPoint . KeyAndSecret . BekDetails . SecretUrl ,
158
+ KeyUrl = recoveryPoint . KeyAndSecret . KekDetails . KeyUrl ,
159
+ SecretData = recoveryPoint . KeyAndSecret . BekDetails . SecretData ,
160
+ KeyBackupData = recoveryPoint . KeyAndSecret . KekDetails . KeyBackupData ,
161
+ KeyVaultId = recoveryPoint . KeyAndSecret . KekDetails . KeyVaultId ,
162
+ SecretVaultId = recoveryPoint . KeyAndSecret . BekDetails . SecretVaultId ,
266
163
} ;
164
+ }
165
+ return rpBase ;
166
+ }
267
167
268
- result = fileResult ;
168
+ public static RecoveryPointBase GetPSAzureFileRecoveryPoint (
169
+ ServiceClientModel . RecoveryPointResource rp , ItemBase item )
170
+ {
171
+ Dictionary < UriEnums , string > uriDict = HelperUtils . ParseUri ( item . Id ) ;
172
+ string containerUri = HelperUtils . GetContainerUri ( uriDict , item . Id ) ;
173
+ string protectedItemUri = HelperUtils . GetProtectedItemUri ( uriDict , item . Id ) ;
174
+
175
+ string containerName = IdUtils . GetNameFromUri ( containerUri ) ;
176
+ string protectedItemName = IdUtils . GetNameFromUri ( protectedItemUri ) ;
177
+ ServiceClientModel . AzureFileShareRecoveryPoint recoveryPoint =
178
+ rp . Properties as ServiceClientModel . AzureFileShareRecoveryPoint ;
179
+
180
+ DateTime recoveryPointTime = DateTime . MinValue ;
181
+ if ( recoveryPoint . RecoveryPointTime . HasValue )
182
+ {
183
+ recoveryPointTime = ( DateTime ) recoveryPoint . RecoveryPointTime ;
184
+ }
185
+ else
186
+ {
187
+ throw new ArgumentNullException ( "RecoveryPointTime is null" ) ;
269
188
}
270
189
271
- if ( rpResponse . Properties . GetType ( ) ==
272
- typeof ( ServiceClientModel . GenericRecoveryPoint ) )
190
+ AzureFileShareRecoveryPoint rpBase = new AzureFileShareRecoveryPoint ( )
273
191
{
274
- ServiceClientModel . GenericRecoveryPoint recPoint =
275
- rpResponse . Properties as ServiceClientModel . GenericRecoveryPoint ;
192
+ RecoveryPointId = rp . Name ,
193
+ BackupManagementType = item . BackupManagementType ,
194
+ ItemName = protectedItemName ,
195
+ ContainerName = containerName ,
196
+ ContainerType = item . ContainerType ,
197
+ RecoveryPointTime = recoveryPointTime ,
198
+ RecoveryPointType = recoveryPoint . RecoveryPointType ,
199
+ Id = rp . Id ,
200
+ WorkloadType = item . WorkloadType ,
201
+ FileShareSnapshotUri = recoveryPoint . FileShareSnapshotUri ,
202
+ } ;
203
+ return rpBase ;
204
+ }
276
205
277
- DateTime recPointTime = DateTime . MinValue ;
278
- if ( recPoint . RecoveryPointTime . HasValue )
279
- {
280
- recPointTime = ( DateTime ) recPoint . RecoveryPointTime ;
281
- }
282
- else
283
- {
284
- throw new ArgumentNullException ( "RecoveryPointTime is null" ) ;
285
- }
206
+ public static RecoveryPointBase GetPSAzureGenericRecoveryPoint (
207
+ ServiceClientModel . RecoveryPointResource rp , ItemBase item )
208
+ {
209
+ Dictionary < UriEnums , string > uriDict = HelperUtils . ParseUri ( item . Id ) ;
210
+ string containerUri = HelperUtils . GetContainerUri ( uriDict , item . Id ) ;
211
+ string protectedItemUri = HelperUtils . GetProtectedItemUri ( uriDict , item . Id ) ;
286
212
287
- AzureSqlRecoveryPoint sqlResult = new AzureSqlRecoveryPoint ( )
288
- {
289
- RecoveryPointId = rpResponse . Name ,
290
- BackupManagementType = item . BackupManagementType ,
291
- ItemName = protectedItemName ,
292
- ContainerName = containerName ,
293
- ContainerType = item . ContainerType ,
294
- RecoveryPointTime = recPointTime ,
295
- RecoveryPointType = recPoint . RecoveryPointType ,
296
- Id = rpResponse . Id ,
297
- WorkloadType = item . WorkloadType ,
298
- RecoveryPointAdditionalInfo = recPoint . RecoveryPointAdditionalInfo ,
299
- SourceResourceId = item . SourceResourceId ,
300
- FriendlyName = recPoint . FriendlyName
301
- } ;
213
+ string containerName = IdUtils . GetNameFromUri ( containerUri ) ;
214
+ string protectedItemName = IdUtils . GetNameFromUri ( protectedItemUri ) ;
302
215
303
- result = sqlResult ;
216
+ ServiceClientModel . GenericRecoveryPoint recoveryPoint =
217
+ rp . Properties as ServiceClientModel . GenericRecoveryPoint ;
218
+
219
+ DateTime recoveryPointTime = DateTime . MinValue ;
220
+ if ( recoveryPoint . RecoveryPointTime . HasValue )
221
+ {
222
+ recoveryPointTime = ( DateTime ) recoveryPoint . RecoveryPointTime ;
304
223
}
305
- return result ;
224
+ else
225
+ {
226
+ throw new ArgumentNullException ( "RecoveryPointTime is null" ) ;
227
+ }
228
+
229
+ AzureSqlRecoveryPoint rpBase = new AzureSqlRecoveryPoint ( )
230
+ {
231
+ RecoveryPointId = rp . Name ,
232
+ BackupManagementType = item . BackupManagementType ,
233
+ ItemName = protectedItemName ,
234
+ ContainerName = containerUri ,
235
+ ContainerType = item . ContainerType ,
236
+ RecoveryPointTime = recoveryPointTime ,
237
+ RecoveryPointType = recoveryPoint . RecoveryPointType ,
238
+ Id = rp . Id ,
239
+ WorkloadType = item . WorkloadType ,
240
+ RecoveryPointAdditionalInfo = recoveryPoint . RecoveryPointAdditionalInfo ,
241
+ FriendlyName = recoveryPoint . FriendlyName ,
242
+ } ;
243
+ return rpBase ;
306
244
}
307
245
}
308
246
}
0 commit comments