@@ -54,7 +54,11 @@ public static CmdletModel.JobBase GetPSJob(JobResource serviceClientJob)
54
54
else if ( serviceClientJob . Properties . GetType ( ) == typeof ( MabJob ) )
55
55
{
56
56
response = GetPSMabJob ( serviceClientJob ) ;
57
- }
57
+ }
58
+ else if ( serviceClientJob . Properties . GetType ( ) == typeof ( VaultJob ) )
59
+ {
60
+ response = GetPSAzureVaultJob ( serviceClientJob ) ;
61
+ }
58
62
59
63
return response ;
60
64
}
@@ -86,80 +90,86 @@ public static void AddServiceClientJobsToPSList(
86
90
}
87
91
}
88
92
89
- #region AzureVm job private helpers
93
+ #endregion
94
+
95
+ #region Vault job private helpers
96
+
90
97
91
98
/// <summary>
92
99
/// Helper function to convert ps azure vm backup policy job from service response.
93
100
/// </summary>
94
- private static CmdletModel . AzureVmJob GetPSAzureVmJob ( JobResource serviceClientJob )
101
+ private static CmdletModel . VaultJob GetPSAzureVaultJob ( JobResource serviceClientJob )
95
102
{
96
- CmdletModel . AzureVmJob response ;
103
+ CmdletModel . VaultJob response ;
97
104
98
- AzureIaaSVMJob vmJob = serviceClientJob . Properties as AzureIaaSVMJob ;
105
+ VaultJob vaultJob = serviceClientJob . Properties as VaultJob ;
99
106
100
- if ( vmJob . ExtendedInfo != null )
107
+ if ( vaultJob . ExtendedInfo != null )
101
108
{
102
- response = new CmdletModel . AzureVmJobDetails ( ) ;
109
+ response = new CmdletModel . VaultJobDetails ( ) ;
103
110
}
104
111
else
105
112
{
106
- response = new CmdletModel . AzureVmJob ( ) ;
113
+ response = new CmdletModel . VaultJob ( ) ;
107
114
}
108
115
109
116
response . JobId = GetLastIdFromFullId ( serviceClientJob . Id ) ;
110
- response . StartTime = GetJobStartTime ( vmJob . StartTime ) ;
111
- response . EndTime = vmJob . EndTime ;
112
- response . Duration = GetJobDuration ( vmJob . Duration ) ;
113
- response . Status = vmJob . Status ;
114
- response . VmVersion = vmJob . VirtualMachineVersion ;
115
- response . WorkloadName = vmJob . EntityFriendlyName ;
116
- response . ActivityId = vmJob . ActivityId ;
117
- response . BackupManagementType =
118
- CmdletModel . ConversionUtils . GetPsBackupManagementType ( vmJob . BackupManagementType ) ;
119
- response . Operation = vmJob . Operation ;
120
-
121
- if ( vmJob . ErrorDetails != null )
117
+ response . StartTime = GetJobStartTime ( vaultJob . StartTime ) ;
118
+ response . EndTime = vaultJob . EndTime ;
119
+ response . Duration = GetJobDuration ( vaultJob . Duration ) ;
120
+ response . Status = vaultJob . Status ;
121
+ response . WorkloadName = vaultJob . EntityFriendlyName ;
122
+ response . ActivityId = vaultJob . ActivityId ;
123
+ response . BackupManagementType = CmdletModel . ConversionUtils . GetPsBackupManagementType ( vaultJob . BackupManagementType ) ;
124
+ response . Operation = vaultJob . Operation ;
125
+
126
+ if ( vaultJob . ErrorDetails != null )
122
127
{
123
128
response . ErrorDetails = new List < CmdletModel . AzureJobErrorInfo > ( ) ;
124
- foreach ( var vmError in vmJob . ErrorDetails )
129
+ foreach ( var vaultError in vaultJob . ErrorDetails )
125
130
{
126
- response . ErrorDetails . Add ( GetPSAzureVmErrorInfo ( vmError ) ) ;
131
+ response . ErrorDetails . Add ( GetPSVaultErrorInfo ( vaultError ) ) ;
127
132
}
128
133
}
129
134
130
- // fill extended info if present
131
- if ( vmJob . ExtendedInfo != null )
135
+ if ( vaultJob . ExtendedInfo != null )
132
136
{
133
- CmdletModel . AzureVmJobDetails detailedResponse =
134
- response as CmdletModel . AzureVmJobDetails ;
137
+ CmdletModel . VaultJobDetails detailedResponse =
138
+ response as CmdletModel . VaultJobDetails ;
135
139
136
- detailedResponse . DynamicErrorMessage = vmJob . ExtendedInfo . DynamicErrorMessage ;
137
- if ( vmJob . ExtendedInfo . PropertyBag != null )
140
+ if ( vaultJob . ExtendedInfo . PropertyBag != null )
138
141
{
139
142
detailedResponse . Properties = new Dictionary < string , string > ( ) ;
140
- foreach ( var key in vmJob . ExtendedInfo . PropertyBag . Keys )
143
+ foreach ( var key in vaultJob . ExtendedInfo . PropertyBag . Keys )
141
144
{
142
- detailedResponse . Properties . Add ( key , vmJob . ExtendedInfo . PropertyBag [ key ] ) ;
143
- }
144
- }
145
-
146
- if ( vmJob . ExtendedInfo . TasksList != null )
147
- {
148
- detailedResponse . SubTasks = new List < CmdletModel . AzureVmJobSubTask > ( ) ;
149
- foreach ( var vmJobTask in vmJob . ExtendedInfo . TasksList )
150
- {
151
- detailedResponse . SubTasks . Add ( new CmdletModel . AzureVmJobSubTask ( )
152
- {
153
- Name = vmJobTask . TaskId ,
154
- Status = vmJobTask . Status
155
- } ) ;
145
+ detailedResponse . Properties . Add ( key , vaultJob . ExtendedInfo . PropertyBag [ key ] ) ;
156
146
}
157
- }
147
+ }
158
148
}
159
149
160
150
return response ;
161
151
}
162
152
153
+
154
+ private static CmdletModel . AzureJobErrorInfo GetPSVaultErrorInfo ( VaultJobErrorInfo vaultError )
155
+ {
156
+ CmdletModel . VaultJobErrorInfo psErrorInfo = new CmdletModel . VaultJobErrorInfo ( ) ;
157
+ psErrorInfo . ErrorCode = GetJobErrorCode ( vaultError . ErrorCode ) ;
158
+ psErrorInfo . ErrorMessage = vaultError . ErrorString ;
159
+ if ( vaultError . Recommendations != null )
160
+ {
161
+ psErrorInfo . Recommendations = new List < string > ( ) ;
162
+ psErrorInfo . Recommendations . AddRange ( vaultError . Recommendations ) ;
163
+ }
164
+
165
+ return psErrorInfo ;
166
+ }
167
+
168
+
169
+ #endregion
170
+
171
+ #region MAB job private helpers
172
+
163
173
/// <summary>
164
174
/// Creates the powershell MabJob object from service response.
165
175
/// </summary>
@@ -177,7 +187,7 @@ private static CmdletModel.JobBase GetPSMabJob(JobResource serviceClientJob)
177
187
{
178
188
response = new CmdletModel . MabJob ( ) ;
179
189
}
180
-
190
+
181
191
// Transfer values from service job object to powershell job object.
182
192
response . JobId = GetLastIdFromFullId ( serviceClientJob . Id ) ;
183
193
response . StartTime = GetJobStartTime ( mabJob . StartTime ) ;
@@ -231,6 +241,7 @@ private static CmdletModel.JobBase GetPSMabJob(JobResource serviceClientJob)
231
241
return response ;
232
242
}
233
243
244
+
234
245
private static CmdletModel . AzureJobErrorInfo GetPSMabErrorInfo ( MabErrorInfo mabError )
235
246
{
236
247
CmdletModel . MabJobErrorInfo psErrorInfo = new CmdletModel . MabJobErrorInfo ( ) ;
@@ -244,6 +255,10 @@ private static CmdletModel.AzureJobErrorInfo GetPSMabErrorInfo(MabErrorInfo mabE
244
255
return psErrorInfo ;
245
256
}
246
257
258
+ #endregion
259
+
260
+ #region AFS job private helpers
261
+
247
262
private static CmdletModel . JobBase GetPSAzureFileShareJob ( JobResource serviceClientJob )
248
263
{
249
264
CmdletModel . AzureFileShareJob response ;
@@ -326,6 +341,10 @@ private static CmdletModel.AzureJobErrorInfo GetPSAzureFileShareErrorInfo(AzureS
326
341
return psErrorInfo ;
327
342
}
328
343
344
+ #endregion
345
+
346
+ #region Workload job private helpers
347
+
329
348
private static CmdletModel . JobBase GetPSAzureWorkloadJob ( JobResource serviceClientJob )
330
349
{
331
350
CmdletModel . AzureVmWorkloadJob response ;
@@ -408,26 +427,80 @@ private static CmdletModel.AzureJobErrorInfo GetPSAzureWorkloadErrorInfo(AzureWo
408
427
return psErrorInfo ;
409
428
}
410
429
411
- private static int GetJobErrorCode ( int ? errorCode )
412
- {
413
- return errorCode ?? default ( int ) ;
414
- }
430
+ #endregion
415
431
416
- private static TimeSpan GetJobDuration ( TimeSpan ? duration )
417
- {
418
- return duration . HasValue ? ( TimeSpan ) duration : default ( TimeSpan ) ;
419
- }
432
+ #region AzureVm job private helpers
420
433
421
- private static DateTime GetJobStartTime ( DateTime ? startTime )
434
+ /// <summary>
435
+ /// Helper function to convert ps azure vm backup policy job from service response.
436
+ /// </summary>
437
+ private static CmdletModel . AzureVmJob GetPSAzureVmJob ( JobResource serviceClientJob )
422
438
{
423
- if ( startTime . HasValue )
439
+ CmdletModel . AzureVmJob response ;
440
+
441
+ AzureIaaSVMJob vmJob = serviceClientJob . Properties as AzureIaaSVMJob ;
442
+
443
+ if ( vmJob . ExtendedInfo != null )
424
444
{
425
- return ( DateTime ) startTime ;
445
+ response = new CmdletModel . AzureVmJobDetails ( ) ;
426
446
}
427
447
else
428
448
{
429
- throw new ArgumentNullException ( "Job Start Time is null" ) ;
449
+ response = new CmdletModel . AzureVmJob ( ) ;
450
+ }
451
+
452
+ response . JobId = GetLastIdFromFullId ( serviceClientJob . Id ) ;
453
+ response . StartTime = GetJobStartTime ( vmJob . StartTime ) ;
454
+ response . EndTime = vmJob . EndTime ;
455
+ response . Duration = GetJobDuration ( vmJob . Duration ) ;
456
+ response . Status = vmJob . Status ;
457
+ response . VmVersion = vmJob . VirtualMachineVersion ;
458
+ response . WorkloadName = vmJob . EntityFriendlyName ;
459
+ response . ActivityId = vmJob . ActivityId ;
460
+ response . BackupManagementType =
461
+ CmdletModel . ConversionUtils . GetPsBackupManagementType ( vmJob . BackupManagementType ) ;
462
+ response . Operation = vmJob . Operation ;
463
+
464
+ if ( vmJob . ErrorDetails != null )
465
+ {
466
+ response . ErrorDetails = new List < CmdletModel . AzureJobErrorInfo > ( ) ;
467
+ foreach ( var vmError in vmJob . ErrorDetails )
468
+ {
469
+ response . ErrorDetails . Add ( GetPSAzureVmErrorInfo ( vmError ) ) ;
470
+ }
430
471
}
472
+
473
+ // fill extended info if present
474
+ if ( vmJob . ExtendedInfo != null )
475
+ {
476
+ CmdletModel . AzureVmJobDetails detailedResponse =
477
+ response as CmdletModel . AzureVmJobDetails ;
478
+
479
+ detailedResponse . DynamicErrorMessage = vmJob . ExtendedInfo . DynamicErrorMessage ;
480
+ if ( vmJob . ExtendedInfo . PropertyBag != null )
481
+ {
482
+ detailedResponse . Properties = new Dictionary < string , string > ( ) ;
483
+ foreach ( var key in vmJob . ExtendedInfo . PropertyBag . Keys )
484
+ {
485
+ detailedResponse . Properties . Add ( key , vmJob . ExtendedInfo . PropertyBag [ key ] ) ;
486
+ }
487
+ }
488
+
489
+ if ( vmJob . ExtendedInfo . TasksList != null )
490
+ {
491
+ detailedResponse . SubTasks = new List < CmdletModel . AzureVmJobSubTask > ( ) ;
492
+ foreach ( var vmJobTask in vmJob . ExtendedInfo . TasksList )
493
+ {
494
+ detailedResponse . SubTasks . Add ( new CmdletModel . AzureVmJobSubTask ( )
495
+ {
496
+ Name = vmJobTask . TaskId ,
497
+ Status = vmJobTask . Status
498
+ } ) ;
499
+ }
500
+ }
501
+ }
502
+
503
+ return response ;
431
504
}
432
505
433
506
/// <summary>
@@ -443,6 +516,32 @@ private static CmdletModel.AzureVmJobErrorInfo GetPSAzureVmErrorInfo(AzureIaaSVM
443
516
return psErrorInfo ;
444
517
}
445
518
519
+ #endregion
520
+
521
+ #region generic helpers
522
+
523
+ private static int GetJobErrorCode ( int ? errorCode )
524
+ {
525
+ return errorCode ?? default ( int ) ;
526
+ }
527
+
528
+ private static TimeSpan GetJobDuration ( TimeSpan ? duration )
529
+ {
530
+ return duration . HasValue ? ( TimeSpan ) duration : default ( TimeSpan ) ;
531
+ }
532
+
533
+ private static DateTime GetJobStartTime ( DateTime ? startTime )
534
+ {
535
+ if ( startTime . HasValue )
536
+ {
537
+ return ( DateTime ) startTime ;
538
+ }
539
+ else
540
+ {
541
+ throw new ArgumentNullException ( "Job Start Time is null" ) ;
542
+ }
543
+ }
544
+
446
545
private static List < string > GetJobErrorRecommendations ( IList < string > recommendations )
447
546
{
448
547
if ( recommendations != null )
@@ -465,7 +564,6 @@ public static string GetLastIdFromFullId(string fullId)
465
564
}
466
565
467
566
#endregion
468
-
469
- #endregion
567
+
470
568
}
471
569
}
0 commit comments