Skip to content

Commit a46a0cd

Browse files
mkheraniSamuel Anudeep
authored andcommitted
Migrating cmdlet code base to swagger.
Migrating cmdlet code base to swagger. Swagger changes for job conversion, job adapter, policy adapter Swagger Changes Swagger changes. SwaggerChanges in Provider sln Swagger changes swagger changes swagger changes. Added latest swaggerDlls Migrated PO calls to swagger Swagger changes for Policy and Job model Infra part 1 Removed custom request headers, as client request ID will be passed via the Delegating Handler Swagger changes Part2 for Jobs and Policy Mkherani swagger (#354) * Container: ServiceCLient and conversionHelper * Container: conversionHelper.cs * container changes completed. Updating swagger dll Migrating common job tracking to Swagger. Swagger: fixed build Swagger changes Swagger changes for Policy/Jobs Tracking Helper Status code change RecoveryServicesBackupClient init hack in test Adding Microsoft.Rest.ClientRuntime.Azure to packages config Adding Microsoft.Rest.ClientRuntime.Azure to package config files of ServiceClientAdapter and Test Auth changes due to autorest in service client adapter, base cmdlet and base test. Correcting the reference for Microsoft.Rest.ClientRuntime.dll Changed auth dll reference Fixed internal constructors in the client Fixing build issue Updated latest DLL and made fixes Added Microsoft.Rest.ClientRuntime.Azure ref to Models proj. Fixing build break Fixing issue in job ListRP fix DateTime changes Updated to latest AutoRest DLL Updated latest AutoRest DLL fixed datetime format DateTime fix Exception handling changes Updated latest AutoRest DLL Added QueryBuilder util Added ToCamelCase string extension Fixing issues with query filters. Fixing filter for GetRPList Enum and query builder fixes Updated AutoRest DLL. fixed container bug with polymorphism Fix for pagination in HelperUtil.cs Fix for operation status tracking using location header Fixing issues with datetime, policy and query filters. Fixing query filter issue except datetime filter Fix for policy filter Updated latest Swagger DLL - used UTC converter for serialization, removed ContainerType enum and made corresponding changes. wix file changes and set-policy cmdlet fix Get policy filter fix Get Policy fix for default backup management type Fixed test infra and ready for recording.
1 parent df49015 commit a46a0cd

File tree

86 files changed

+2802
-959
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

86 files changed

+2802
-959
lines changed

setup/azurecmdfiles.wxi

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2331,6 +2331,9 @@
23312331
<Component Id="cmp902DC2364C6FF451A60B4D115B5DC7A9" Guid="*">
23322332
<File Id="filDFC93A6AA2A808957B249CC88C7D6EE5" KeyPath="yes" Source="$(var.sourceDir)\ResourceManager\AzureResourceManager\AzureRM.RecoveryServices.Backup\Microsoft.Rest.ClientRuntime.Azure.Authentication.dll" />
23332333
</Component>
2334+
<Component Id="cmpDB3F89FCB6F69647096085E3C07D2EA7" Guid="*">
2335+
<File Id="fil981731C42616352E119DFCB2CDFCF8BB" KeyPath="yes" Source="$(var.sourceDir)\ResourceManager\AzureResourceManager\AzureRM.RecoveryServices.Backup\Microsoft.Rest.ClientRuntime.Azure.dll" />
2336+
</Component>
23342337
<Component Id="cmpF8AEF0C5D785D40AEC8F1BF4ACE4E939" Guid="*">
23352338
<File Id="filA708CDDEB8C8A8363E22F4C83953E14E" KeyPath="yes" Source="$(var.sourceDir)\ResourceManager\AzureResourceManager\AzureRM.RecoveryServices.Backup\Microsoft.Rest.ClientRuntime.dll" />
23362339
</Component>
@@ -6277,6 +6280,7 @@
62776280
<ComponentRef Id="cmp13B3F08D31DD4410B1934B82517CAC9A" />
62786281
<ComponentRef Id="cmpA2EFAF047A9595A3CA7DFC6031140F27" />
62796282
<ComponentRef Id="cmp902DC2364C6FF451A60B4D115B5DC7A9" />
6283+
<ComponentRef Id="cmpDB3F89FCB6F69647096085E3C07D2EA7" />
62806284
<ComponentRef Id="cmpF8AEF0C5D785D40AEC8F1BF4ACE4E939" />
62816285
<ComponentRef Id="cmp0FB4C1F5BB0FB399774156C4B56696B8" />
62826286
<ComponentRef Id="cmp7B84FC694FB5281CF08E6F1B41D07E12" />

src/Common/Commands.Common.Authentication/Commands.Common.Authentication.csproj

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -71,13 +71,8 @@
7171
<HintPath>..\..\packages\Microsoft.IdentityModel.Clients.ActiveDirectory.2.28.3\lib\net45\Microsoft.IdentityModel.Clients.ActiveDirectory.WindowsForms.dll</HintPath>
7272
<Private>True</Private>
7373
</Reference>
74-
<Reference Include="Microsoft.Rest.ClientRuntime, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
74+
<Reference Include="Microsoft.Rest.ClientRuntime">
7575
<HintPath>..\..\packages\Microsoft.Rest.ClientRuntime.2.3.2\lib\net45\Microsoft.Rest.ClientRuntime.dll</HintPath>
76-
<Private>True</Private>
77-
</Reference>
78-
<Reference Include="Microsoft.Rest.ClientRuntime.Azure, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
79-
<HintPath>..\..\packages\Microsoft.Rest.ClientRuntime.Azure.3.3.2\lib\net45\Microsoft.Rest.ClientRuntime.Azure.dll</HintPath>
80-
<Private>True</Private>
8176
</Reference>
8277
<Reference Include="Microsoft.Rest.ClientRuntime.Azure.Authentication, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
8378
<HintPath>..\..\packages\Microsoft.Rest.ClientRuntime.Azure.Authentication.2.2.9-preview\lib\net45\Microsoft.Rest.ClientRuntime.Azure.Authentication.dll</HintPath>
@@ -188,4 +183,4 @@
188183
<None Include="packages.config" />
189184
</ItemGroup>
190185
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
191-
</Project>
186+
</Project>

src/Common/Commands.Common/Commands.Common.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,4 +183,4 @@
183183
</ProjectReference>
184184
</ItemGroup>
185185
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
186-
</Project>
186+
</Project>

src/ResourceManager/CognitiveServices/CognitiveServices.sln

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Microsoft Visual Studio Solution File, Format Version 12.00
2-
# Visual Studio 2013
3-
VisualStudioVersion = 12.0.40629.0
2+
# Visual Studio 14
3+
VisualStudioVersion = 14.0.25420.1
44
MinimumVisualStudioVersion = 10.0.40219.1
55
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Commands.ResourceManager.Common", "..\Common\Commands.ResourceManager.Common\Commands.ResourceManager.Common.csproj", "{3819D8A7-C62C-4C47-8DDD-0332D9CE1252}"
66
EndProject
@@ -46,6 +46,7 @@ Global
4646
{E1F5201D-6067-430E-B303-4E367652991B}.Release|Any CPU.Build.0 = Release|Any CPU
4747
{2493A8F7-1949-4F29-8D53-9D459046C3B8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
4848
{2493A8F7-1949-4F29-8D53-9D459046C3B8}.Debug|Any CPU.Build.0 = Debug|Any CPU
49+
{2493A8F7-1949-4F29-8D53-9D459046C3B8}.Debug|Any CPU.Deploy.0 = Debug|Any CPU
4950
{2493A8F7-1949-4F29-8D53-9D459046C3B8}.Release|Any CPU.ActiveCfg = Release|Any CPU
5051
{2493A8F7-1949-4F29-8D53-9D459046C3B8}.Release|Any CPU.Build.0 = Release|Any CPU
5152
{65C3A86A-716D-4E7D-AB67-1DB00B3BF72D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU

src/ResourceManager/Common/Commands.ResourceManager.Common/Commands.ResourceManager.Common.csproj

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,13 +77,11 @@
7777
<SpecificVersion>False</SpecificVersion>
7878
<HintPath>..\..\..\packages\Microsoft.IdentityModel.Clients.ActiveDirectory.2.28.3\lib\net45\Microsoft.IdentityModel.Clients.ActiveDirectory.WindowsForms.dll</HintPath>
7979
</Reference>
80-
<Reference Include="Microsoft.Rest.ClientRuntime, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
80+
<Reference Include="Microsoft.Rest.ClientRuntime">
8181
<HintPath>..\..\..\packages\Microsoft.Rest.ClientRuntime.2.3.2\lib\net45\Microsoft.Rest.ClientRuntime.dll</HintPath>
82-
<Private>True</Private>
8382
</Reference>
84-
<Reference Include="Microsoft.Rest.ClientRuntime.Azure, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
83+
<Reference Include="Microsoft.Rest.ClientRuntime.Azure">
8584
<HintPath>..\..\..\packages\Microsoft.Rest.ClientRuntime.Azure.3.3.2\lib\net45\Microsoft.Rest.ClientRuntime.Azure.dll</HintPath>
86-
<Private>True</Private>
8785
</Reference>
8886
<Reference Include="Microsoft.Rest.ClientRuntime.Azure.Authentication, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
8987
<HintPath>..\..\..\packages\Microsoft.Rest.ClientRuntime.Azure.Authentication.2.2.9-preview\lib\net45\Microsoft.Rest.ClientRuntime.Azure.Authentication.dll</HintPath>

src/ResourceManager/Common/Commands.ScenarioTests.ResourceManager.Common/Commands.ScenarioTests.ResourceManager.Common.csproj

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -71,13 +71,11 @@
7171
<SpecificVersion>False</SpecificVersion>
7272
<HintPath>..\..\..\packages\Microsoft.IdentityModel.Clients.ActiveDirectory.2.28.3\lib\net45\Microsoft.IdentityModel.Clients.ActiveDirectory.WindowsForms.dll</HintPath>
7373
</Reference>
74-
<Reference Include="Microsoft.Rest.ClientRuntime, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
74+
<Reference Include="Microsoft.Rest.ClientRuntime">
7575
<HintPath>..\..\..\packages\Microsoft.Rest.ClientRuntime.2.3.2\lib\net45\Microsoft.Rest.ClientRuntime.dll</HintPath>
76-
<Private>True</Private>
7776
</Reference>
78-
<Reference Include="Microsoft.Rest.ClientRuntime.Azure, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
77+
<Reference Include="Microsoft.Rest.ClientRuntime.Azure">
7978
<HintPath>..\..\..\packages\Microsoft.Rest.ClientRuntime.Azure.3.3.2\lib\net45\Microsoft.Rest.ClientRuntime.Azure.dll</HintPath>
80-
<Private>True</Private>
8179
</Reference>
8280
<Reference Include="Microsoft.Rest.ClientRuntime.Azure.Authentication, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
8381
<HintPath>..\..\..\packages\Microsoft.Rest.ClientRuntime.Azure.Authentication.2.2.9-preview\lib\net45\Microsoft.Rest.ClientRuntime.Azure.Authentication.dll</HintPath>
@@ -201,4 +199,4 @@
201199
</ItemGroup>
202200
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
203201
<Import Project="..\..\..\packages\Microsoft.Bcl.Build.1.0.14\tools\Microsoft.Bcl.Build.targets" Condition="Exists('..\..\..\packages\Microsoft.Bcl.Build.1.0.14\tools\Microsoft.Bcl.Build.targets')" />
204-
</Project>
202+
</Project>

src/ResourceManager/Profile/Commands.Profile/Commands.Profile.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,8 @@
7272
<Private>True</Private>
7373
</Reference>
7474
<Reference Include="Microsoft.Rest.ClientRuntime, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
75+
<SpecificVersion>False</SpecificVersion>
7576
<HintPath>..\..\..\packages\Microsoft.Rest.ClientRuntime.2.3.2\lib\net45\Microsoft.Rest.ClientRuntime.dll</HintPath>
76-
<Private>True</Private>
7777
</Reference>
7878
<Reference Include="Microsoft.Rest.ClientRuntime.Azure.Authentication, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
7979
<HintPath>..\..\..\packages\Microsoft.Rest.ClientRuntime.Azure.Authentication.2.2.9-preview\lib\net45\Microsoft.Rest.ClientRuntime.Azure.Authentication.dll</HintPath>

src/ResourceManager/RecoveryServices.Backup/Commands.RecoveryServices.Backup.Helpers/Commands.RecoveryServices.Backup.Helpers.csproj

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,20 @@
4040
<Reference Include="Microsoft.Azure.Common">
4141
<HintPath>..\..\..\packages\Microsoft.Azure.Common.2.1.0\lib\net45\Microsoft.Azure.Common.dll</HintPath>
4242
</Reference>
43-
<Reference Include="Microsoft.Azure.Management.RecoveryServices.Backup, Version=0.9.0.0, Culture=neutral, processorArchitecture=MSIL">
43+
<Reference Include="Microsoft.Azure.Management.RecoveryServices.Backup, Version=0.9.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
4444
<SpecificVersion>False</SpecificVersion>
45-
<HintPath>..\..\..\packages\Microsoft.Azure.Management.RecoveryServices.Backup.0.1.2\lib\net40\Microsoft.Azure.Management.RecoveryServices.Backup.dll</HintPath>
45+
<HintPath>..\..\..\tempDll\Debug-Net45\net45\Microsoft.Azure.Management.RecoveryServices.Backup.dll</HintPath>
46+
</Reference>
47+
<Reference Include="Microsoft.Rest.ClientRuntime">
48+
<HintPath>..\..\..\packages\Microsoft.Rest.ClientRuntime.2.3.2\lib\net45\Microsoft.Rest.ClientRuntime.dll</HintPath>
49+
</Reference>
50+
<Reference Include="Microsoft.Rest.ClientRuntime.Azure">
51+
<HintPath>..\..\..\packages\Microsoft.Rest.ClientRuntime.Azure.3.3.2\lib\net45\Microsoft.Rest.ClientRuntime.Azure.dll</HintPath>
4652
</Reference>
4753
<Reference Include="System" />
4854
<Reference Include="System.Core" />
55+
<Reference Include="System.Net" />
56+
<Reference Include="System.Net.Http" />
4957
<Reference Include="System.Web" />
5058
<Reference Include="System.Xml.Linq" />
5159
<Reference Include="System.Data.DataSetExtensions" />
@@ -56,6 +64,7 @@
5664
<ItemGroup>
5765
<Compile Include="Conversions\JobConversions.cs" />
5866
<Compile Include="Conversions\RecoveryPointConversions.cs" />
67+
<Compile Include="Extensions\HttpHeadersExtensions.cs" />
5968
<Compile Include="HelperUtils.cs" />
6069
<Compile Include="TrackingHelpers.cs" />
6170
<Compile Include="Validations\PolicyValidations.cs" />
@@ -92,4 +101,4 @@
92101
<Target Name="AfterBuild">
93102
</Target>
94103
-->
95-
</Project>
104+
</Project>

src/ResourceManager/RecoveryServices.Backup/Commands.RecoveryServices.Backup.Helpers/Conversions/ConversionHelpers.cs

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -41,16 +41,16 @@ public static ContainerBase GetContainerModel(ServiceClientModel.ProtectionConta
4141
if (protectionContainer != null &&
4242
protectionContainer.Properties != null)
4343
{
44-
if (protectionContainer.Properties.GetType().IsSubclassOf(typeof(ServiceClientModel.AzureIaaSVMProtectionContainer)))
44+
if (protectionContainer.Properties.GetType().IsSubclassOf(typeof(ServiceClientModel.IaaSVMContainer)))
4545
{
4646
containerModel = new AzureVmContainer(protectionContainer);
4747
}
48-
if (protectionContainer.Properties.GetType() == typeof(ServiceClientModel.MabProtectionContainer))
48+
if (protectionContainer.Properties.GetType() == typeof(ServiceClientModel.MabContainer))
4949
{
5050
containerModel = new MabContainer(protectionContainer);
5151
}
5252
else if (protectionContainer.Properties.GetType() ==
53-
typeof(ServiceClientModel.AzureSqlProtectionContainer))
53+
typeof(ServiceClientModel.AzureSqlContainer))
5454
{
5555
containerModel = new AzureSqlContainer(protectionContainer);
5656
}
@@ -62,13 +62,20 @@ public static ContainerBase GetContainerModel(ServiceClientModel.ProtectionConta
6262
/// <summary>
6363
/// Helper function to convert ps backup engine model from service response.
6464
/// </summary>
65-
public static BackupEngineBase GetBackupEngineModel(ServiceClientModel.BackupEngineResource backupEngine)
65+
public static BackupEngineBase GetBackupEngineModel(ServiceClientModel.BackupEngineBaseResource backupEngine)
6666
{
6767
BackupEngineBase backupEngineModel = null;
6868

6969
if (backupEngine != null &&
7070
backupEngine.Properties != null)
7171
{
72+
string friendlyName = backupEngine.Properties.FriendlyName;
73+
string backupManagementType = backupEngine.Properties.BackupManagementType.ToString();
74+
string registrationStatus = backupEngine.Properties.RegistrationStatus;
75+
string healthStatus = backupEngine.Properties.HealthStatus;
76+
bool? canReRegister = backupEngine.Properties.CanReRegister;
77+
string backupEngineId = backupEngine.Properties.BackupEngineId;
78+
7279
if (backupEngine.Properties.GetType() == (typeof(ServiceClientModel.DpmBackupEngine)))
7380
{
7481
backupEngineModel = new DpmBackupEngine(backupEngine);
@@ -100,7 +107,7 @@ public static List<ContainerBase> GetContainerModelList(IEnumerable<ServiceClien
100107
/// <summary>
101108
/// Helper function to convert ps backup engine model list from service response.
102109
/// </summary>
103-
public static List<BackupEngineBase> GetBackupEngineModelList(IEnumerable<ServiceClientModel.BackupEngineResource> backupEngines)
110+
public static List<BackupEngineBase> GetBackupEngineModelList(IEnumerable<ServiceClientModel.BackupEngineBaseResource> backupEngines)
104111
{
105112
List<BackupEngineBase> backupEngineModel = new List<BackupEngineBase>();
106113

@@ -203,10 +210,9 @@ public static PolicyBase GetPolicyModel(ServiceClientModel.ProtectionPolicyResou
203210
/// Helper function to convert ps backup policy list model from service response.
204211
/// </summary>
205212
public static List<PolicyBase> GetPolicyModelList(
206-
ServiceClientModel.ProtectionPolicyListResponse serviceClientListResponse)
213+
List<ServiceClientModel.ProtectionPolicyResource> serviceClientListResponse)
207214
{
208-
if (serviceClientListResponse == null || serviceClientListResponse.ItemList == null ||
209-
serviceClientListResponse.ItemList.Value == null || serviceClientListResponse.ItemList.Value.Count == 0)
215+
if (serviceClientListResponse == null && serviceClientListResponse.Count == 0)
210216
{
211217
Logger.Instance.WriteDebug("Received empty list of policies from service");
212218
return null;
@@ -215,7 +221,7 @@ public static List<PolicyBase> GetPolicyModelList(
215221
List<PolicyBase> policyModels = new List<PolicyBase>();
216222
PolicyBase policyModel = null;
217223

218-
foreach (ServiceClientModel.ProtectionPolicyResource resource in serviceClientListResponse.ItemList.Value)
224+
foreach (ServiceClientModel.ProtectionPolicyResource resource in serviceClientListResponse)
219225
{
220226
policyModel = GetPolicyModel(resource);
221227
if (policyModel != null)

src/ResourceManager/RecoveryServices.Backup/Commands.RecoveryServices.Backup.Helpers/Conversions/JobConversions.cs

Lines changed: 27 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@
1414

1515
using System;
1616
using System.Collections.Generic;
17-
using Microsoft.Azure.Commands.RecoveryServices.Backup.Properties;
18-
using Microsoft.Azure.Management.RecoveryServices.Backup.Models;
1917
using CmdletModel = Microsoft.Azure.Commands.RecoveryServices.Backup.Cmdlets.Models;
18+
using Microsoft.Azure.Management.RecoveryServices.Backup.Models;
19+
using Microsoft.Azure.Commands.RecoveryServices.Backup.Properties;
2020

2121
namespace Microsoft.Azure.Commands.RecoveryServices.Backup.Helpers
2222
{
@@ -35,10 +35,10 @@ public class JobConversions
3535
/// </summary>
3636
/// <param name="ServiceClientJob"></param>
3737
/// <returns></returns>
38-
public static CmdletModel.JobBase GetPSJob(JobResponse serviceClientJob)
39-
{
40-
return GetPSJob(serviceClientJob.Item);
41-
}
38+
//public static CmdletModel.JobBase GetPSJob(JobResponse serviceClientJob)
39+
//{
40+
// return GetPSJob(serviceClientJob.Item);
41+
//}
4242

4343
/// <summary>
4444
/// Helper function to convert ps backup job model from service response.
@@ -63,18 +63,22 @@ public static CmdletModel.JobBase GetPSJob(JobResource serviceClientJob)
6363
/// <summary>
6464
/// Helper function to convert ps backup job list model from service response.
6565
/// </summary>
66-
public static void AddServiceClientJobsToPSList(JobListResponse serviceClientJobs, List<CmdletModel.JobBase> psJobs, ref int jobsCount)
66+
public static void AddServiceClientJobsToPSList(List<JobResource> serviceClientJobs, List<CmdletModel.JobBase> psJobs, ref int jobsCount)
6767
{
68-
if (serviceClientJobs.ItemList != null && serviceClientJobs.ItemList.Value != null)
68+
if (serviceClientJobs != null )
6969
{
70-
foreach (var job in serviceClientJobs.ItemList.Value)
70+
foreach (var job in serviceClientJobs)
7171
{
7272
CmdletModel.JobBase convertedJob = GetPSJob(job);
7373
if (convertedJob != null)
7474
{
7575
jobsCount++;
7676
psJobs.Add(convertedJob);
7777
}
78+
else
79+
{
80+
Logger.Instance.WriteDebug("Ignoring some of the unexpected job while conversion");
81+
}
7882
}
7983
}
8084
}
@@ -100,15 +104,23 @@ private static CmdletModel.AzureVmJob GetPSAzureVmJob(JobResource serviceClientJ
100104
}
101105

102106
response.JobId = GetLastIdFromFullId(serviceClientJob.Id);
103-
response.StartTime = vmJob.StartTime;
107+
DateTime startTime = DateTime.MinValue;
108+
if (vmJob.StartTime.HasValue)
109+
{
110+
response.StartTime = (DateTime)vmJob.StartTime;
111+
}
112+
else
113+
{
114+
throw new ArgumentNullException("Job Start Time is null");
115+
}
104116
response.EndTime = vmJob.EndTime;
105-
response.Duration = vmJob.Duration;
117+
response.Duration = vmJob.Duration.HasValue ? (TimeSpan)vmJob.Duration : default(TimeSpan);
106118
response.Status = vmJob.Status;
107119
response.VmVersion = vmJob.VirtualMachineVersion;
108120
response.WorkloadName = vmJob.EntityFriendlyName;
109121
response.ActivityId = vmJob.ActivityId;
110122
response.BackupManagementType = CmdletModel.EnumUtils.GetEnum<CmdletModel.BackupManagementType>(
111-
GetPSBackupManagementType(vmJob.BackupManagementType));
123+
GetPSBackupManagementType(vmJob.BackupManagementType.ToString()));
112124
response.Operation = vmJob.Operation;
113125

114126
if (vmJob.ErrorDetails != null)
@@ -159,7 +171,7 @@ private static CmdletModel.AzureVmJob GetPSAzureVmJob(JobResource serviceClientJ
159171
private static CmdletModel.AzureVmJobErrorInfo GetPSAzureVmErrorInfo(AzureIaaSVMErrorInfo serviceClientError)
160172
{
161173
CmdletModel.AzureVmJobErrorInfo psErrorInfo = new CmdletModel.AzureVmJobErrorInfo();
162-
psErrorInfo.ErrorCode = serviceClientError.ErrorCode;
174+
psErrorInfo.ErrorCode = serviceClientError.ErrorCode ?? default(int);
163175
psErrorInfo.ErrorMessage = serviceClientError.ErrorString;
164176
if (serviceClientError.Recommendations != null)
165177
{
@@ -189,12 +201,12 @@ public static string GetLastIdFromFullId(string fullId)
189201
/// <summary>
190202
/// Helper function to get job type from ps backup management type.
191203
/// </summary>
192-
public static string GetJobTypeForService(CmdletModel.BackupManagementType mgmtType)
204+
public static BackupManagementType GetJobTypeForService(CmdletModel.BackupManagementType mgmtType)
193205
{
194206
switch (mgmtType)
195207
{
196208
case CmdletModel.BackupManagementType.AzureVM:
197-
return BackupManagementType.AzureIaasVM.ToString();
209+
return BackupManagementType.AzureIaasVM;
198210
default:
199211
throw new Exception("Invalid BackupManagementType provided: " + mgmtType);
200212
}

0 commit comments

Comments
 (0)