Skip to content

Commit f43ba56

Browse files
author
Samuel Anudeep
committed
Merge pull request #329 from MabOneSdk/anudeeb-dev1
Fixing 7349803 in Helper, Logger and Models Layers
2 parents c8676c5 + c469de1 commit f43ba56

File tree

22 files changed

+521
-29
lines changed

22 files changed

+521
-29
lines changed

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ public static void AddServiceClientJobsToPSList(JobListResponse serviceClientJob
8282
#region AzureVm job private helpers
8383

8484
/// <summary>
85-
/// Helper function to convert ps auzre vm backup policy job from service response.
85+
/// Helper function to convert ps azure vm backup policy job from service response.
8686
/// </summary>
8787
private static CmdletModel.AzureVmJob GetPSAzureVmJob(JobResource serviceClientJob)
8888
{
@@ -154,7 +154,7 @@ private static CmdletModel.AzureVmJob GetPSAzureVmJob(JobResource serviceClientJ
154154
}
155155

156156
/// <summary>
157-
/// Helper function to convert ps auzre vm backup job error info from service response.
157+
/// Helper function to convert ps azure vm backup job error info from service response.
158158
/// </summary>
159159
private static CmdletModel.AzureVmJobErrorInfo GetPSAzureVmErrorInfo(AzureIaaSVMErrorInfo serviceClientError)
160160
{
@@ -187,7 +187,7 @@ public static string GetLastIdFromFullId(string fullId)
187187

188188

189189
/// <summary>
190-
/// Helper function to get job type from ps backupmanagement type.
190+
/// Helper function to get job type from ps backup management type.
191191
/// </summary>
192192
public static string GetJobTypeForService(CmdletModel.BackupManagementType mgmtType)
193193
{

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ public static List<DateTime> ParseDateTimesToUTC(IList<DateTime> localTimes)
8484
}
8585

8686
// <summary>
87-
/// Helper function to convert service simple schedule policy from ps scheduel policy.
87+
/// Helper function to convert service simple schedule policy from ps schedule policy.
8888
/// </summary>
8989
public static ServiceClientModel.SimpleSchedulePolicy GetServiceClientSimpleSchedulePolicy(
9090
SimpleSchedulePolicy psPolicy)

src/ResourceManager/RecoveryServices.Backup/Commands.RecoveryServices.Backup.Helpers/HelperUtils.cs

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,18 @@
2323

2424
namespace Microsoft.Azure.Commands.RecoveryServices.Backup.Helpers
2525
{
26+
/// <summary>
27+
/// Utilities used by the helpers.
28+
/// </summary>
2629
public class HelperUtils
2730
{
31+
/// <summary>
32+
/// Gets list of enums of type T given the corresponding list of string equivalents.
33+
/// This method parses each of the strings and converts them into enums.
34+
/// </summary>
35+
/// <typeparam name="T">Type of the enum into which each string in the input list is to be type casted</typeparam>
36+
/// <param name="strList">List of strings</param>
37+
/// <returns></returns>
2838
public static List<T> GetEnumListFromStringList<T>(IList<string> strList)
2939
{
3040
if (strList == null || strList.Count == 0)
@@ -41,6 +51,12 @@ public static List<T> GetEnumListFromStringList<T>(IList<string> strList)
4151
return ret;
4252
}
4353

54+
/// <summary>
55+
/// Gets list of string equivalents given the corresponding list of enums of type T.
56+
/// </summary>
57+
/// <typeparam name="T">Type of the enum whose list should be converted to list of strings</typeparam>
58+
/// <param name="enumList">List of enums</param>
59+
/// <returns></returns>
4460
public static List<string> GetStringListFromEnumList<T>(IList<T> enumList)
4561
{
4662
if (enumList == null || enumList.Count == 0)
@@ -97,6 +113,12 @@ public static List<string> GetStringListFromEnumList<T>(IList<T> enumList)
97113
return keyValuePairDict;
98114
}
99115

116+
/// <summary>
117+
/// Gets container URI from the provided dictionary of key value pairs.
118+
/// </summary>
119+
/// <param name="keyValuePairDict">Dictionary of UriEnum as key and value as value of corresponding URI enum</param>
120+
/// <param name="id">ID of the resource</param>
121+
/// <returns></returns>
100122
public static string GetContainerUri(
101123
Dictionary<CmdletModel.UriEnums, string> keyValuePairDict,
102124
string id
@@ -116,6 +138,12 @@ string id
116138
return containerUri;
117139
}
118140

141+
/// <summary>
142+
/// Gets protected item URI from the provided dictionary of key value pairs.
143+
/// </summary>
144+
/// <param name="keyValuePairDict">Dictionary of UriEnum as key and value as value of corresponding URI enum</param>
145+
/// <param name="id">ID of the resource</param>
146+
/// <returns></returns>
119147
public static string GetProtectedItemUri(
120148
Dictionary<CmdletModel.UriEnums, string> keyValuePairDict,
121149
string id
@@ -135,6 +163,12 @@ string id
135163
return itemUri;
136164
}
137165

166+
/// <summary>
167+
/// Gets protectable item URI from the provided dictionary of key value pairs.
168+
/// </summary>
169+
/// <param name="keyValuePairDict">Dictionary of UriEnum as key and value as value of corresponding URI enum</param>
170+
/// <param name="id">ID of the resource</param>
171+
/// <returns></returns>
138172
public static string GetProtectableItemUri(
139173
Dictionary<CmdletModel.UriEnums, string> keyValuePairDict,
140174
string id
@@ -154,6 +188,12 @@ string id
154188
return protectableItemUri;
155189
}
156190

191+
/// <summary>
192+
/// Gets polcy name from the provided dictionary of key value pairs.
193+
/// </summary>
194+
/// <param name="keyValuePairDict">Dictionary of UriEnum as key and value as value of corresponding URI enum</param>
195+
/// <param name="id">ID of the resource</param>
196+
/// <returns></returns>
157197
public static string GetPolicyNameFromPolicyId(
158198
Dictionary<CmdletModel.UriEnums, string> keyValuePairDict,
159199
string id

src/ResourceManager/RecoveryServices.Backup/Commands.RecoveryServices.Backup.Helpers/ServiceClientHelpers.cs

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,25 @@
2020

2121
namespace Microsoft.Azure.Commands.RecoveryServices.Backup.Helpers
2222
{
23+
/// <summary>
24+
/// Constants used by the service client helpers.
25+
/// </summary>
2326
public class ServiceClientConstants
2427
{
2528
public const string SkipToken = "skipToken";
2629
}
2730

31+
/// <summary>
32+
/// Helper methods used by the service client adapter.
33+
/// </summary>
2834
public class ServiceClientHelpers
2935
{
36+
/// <summary>
37+
/// Gets the provider type with which the service client calls are to made to contact the backend service.
38+
/// This can be determined by the container type in case of certain containers such as those of the type AzureVM.
39+
/// </summary>
40+
/// <param name="containerType">Type of the container</param>
41+
/// <returns></returns>
3042
public static string GetServiceClientProviderType(CmdletModel.ContainerType containerType)
3143
{
3244
string providerType = string.Empty;
@@ -43,6 +55,12 @@ public static string GetServiceClientProviderType(CmdletModel.ContainerType cont
4355
return providerType;
4456
}
4557

58+
/// <summary>
59+
/// Gets the provider type with which the service client calls are to made to contact the backend service.
60+
/// This is determined by the workload type in case of certain containers such as those of the type AzureVM.
61+
/// </summary>
62+
/// <param name="workloadType"></param>
63+
/// <returns></returns>
4664
public static string GetServiceClientProviderType(CmdletModel.WorkloadType workloadType)
4765
{
4866
string providerType = string.Empty;
@@ -59,6 +77,13 @@ public static string GetServiceClientProviderType(CmdletModel.WorkloadType workl
5977
return providerType;
6078
}
6179

80+
/// <summary>
81+
/// Gets the skip token from the next link. Usually, next link is the location uri returned as a header
82+
/// when an ARM call is made. When this skip token (if non-null) is used in the next call to the backend service,
83+
/// the next set of objects are returned.
84+
/// </summary>
85+
/// <param name="nextLink">The next link a.k.a location url</param>
86+
/// <param name="skipToken">The skip token extracted from the next link</param>
6287
public static void GetSkipTokenFromNextLink(string nextLink, out string skipToken)
6388
{
6489
if (nextLink != null)
@@ -98,6 +123,11 @@ public static string GetLastIdFromFullId(string fullId)
98123
return splitArr[splitArr.Length - 1];
99124
}
100125

126+
/// <summary>
127+
/// Gets the service client specific container type given the PS container type
128+
/// </summary>
129+
/// <param name="containerType">PS container type</param>
130+
/// <returns></returns>
101131
public static string GetServiceClientContainerType(CmdletModel.ContainerType containerType)
102132
{
103133
string serviceClientContainerType = string.Empty;
@@ -114,6 +144,11 @@ public static string GetServiceClientContainerType(CmdletModel.ContainerType con
114144
return serviceClientContainerType;
115145
}
116146

147+
/// <summary>
148+
/// Gets the service client specific workload type given the PS workload type
149+
/// </summary>
150+
/// <param name="workloadType"></param>
151+
/// <returns></returns>
117152
public static string GetServiceClientWorkloadType(CmdletModel.WorkloadType workloadType)
118153
{
119154
string serviceClientWorkloadType = string.Empty;

src/ResourceManager/RecoveryServices.Backup/Commands.RecoveryServices.Backup.Helpers/Validations/PolicyValidations.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@
2222

2323
namespace Microsoft.Azure.Commands.RecoveryServices.Backup.Helpers
2424
{
25+
/// <summary>
26+
/// Backup policy validation helpers.
27+
/// </summary>
2528
public partial class PolicyHelpers
2629
{
2730
// <summary>

src/ResourceManager/RecoveryServices.Backup/Commands.RecoveryServices.Backup.Logger/Logger.cs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@
2121

2222
namespace Microsoft.Azure.Commands.RecoveryServices.Backup
2323
{
24+
/// <summary>
25+
/// Utility for logging. Uses PS logging underneath.
26+
/// Plan to add more functionality in the upcoming releases.
27+
/// </summary>
2428
public class Logger
2529
{
2630
private Action<string> writeWarningAction;
@@ -33,6 +37,13 @@ public class Logger
3337

3438
public static Logger Instance { get; set; }
3539

40+
/// <summary>
41+
/// Constructor. Takes the delegates for the various logging operations as input.
42+
/// </summary>
43+
/// <param name="writeWarning">Delegate to write warnings</param>
44+
/// <param name="writeDebug">Delegate to write debug messages</param>
45+
/// <param name="writeVerbose">Delegate to write verbose messages</param>
46+
/// <param name="throwTerminatingError">Delegate to throw terminating errors</param>
3647
public Logger(Action<string> writeWarning,
3748
Action<string> writeDebug,
3849
Action<string> writeVerbose,
@@ -44,21 +55,37 @@ public Logger(Action<string> writeWarning,
4455
throwTerminatingErrorAction = throwTerminatingError;
4556
}
4657

58+
/// <summary>
59+
/// Writes verbose message.
60+
/// </summary>
61+
/// <param name="text"></param>
4762
public void WriteVerbose(string text)
4863
{
4964
writeVerboseAction(text);
5065
}
5166

67+
/// <summary>
68+
/// Writes debug message.
69+
/// </summary>
70+
/// <param name="text"></param>
5271
public void WriteDebug(string text)
5372
{
5473
writeDebugAction(text);
5574
}
5675

76+
/// <summary>
77+
/// Writes warning message.
78+
/// </summary>
79+
/// <param name="text"></param>
5780
public void WriteWarning(string text)
5881
{
5982
writeWarningAction(text);
6083
}
6184

85+
/// <summary>
86+
/// Throws a terminating error.
87+
/// </summary>
88+
/// <param name="errorRecord"></param>
6289
public void ThrowTerminatingError(ErrorRecord errorRecord)
6390
{
6491
throwTerminatingErrorAction(errorRecord);

src/ResourceManager/RecoveryServices.Backup/Commands.RecoveryServices.Backup.Models/AzureVmModels/AzureVmContainer.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,11 @@ public class AzureVmContainer : ContainerBase
4141
/// </summary>
4242
public ContainerRegistrationStatus Status { get; set; }
4343

44+
/// <summary>
45+
/// Constructor. Takes the service client object representing the container
46+
/// and converts it in to the PS container model
47+
/// </summary>
48+
/// <param name="protectionContainer">Service client object representing the container</param>
4449
public AzureVmContainer(ProtectionContainerResource protectionContainer)
4550
: base(protectionContainer)
4651
{

src/ResourceManager/RecoveryServices.Backup/Commands.RecoveryServices.Backup.Models/AzureVmModels/AzureVmItem.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,14 @@ public class AzureVmItem : ItemBase
5353
/// </summary
5454
public AzureVmItemExtendedInfo ExtendedInfo { get; set; }
5555

56+
/// <summary>
57+
/// Constructor. Takes the service client object representing the protected item
58+
/// and converts it in to the PS protected item model
59+
/// </summary>
60+
/// <param name="protectedItemResource">Service client object representing the protected item resource</param>
61+
/// <param name="containerName">Name of the container associated with this protected item</param>
62+
/// <param name="containerType">Type of the container associated with this protected item</param>
63+
/// <param name="policyName">Name of the protection policy associated with this protected item</param>
5664
public AzureVmItem(ProtectedItemResource protectedItemResource,
5765
string containerName, ContainerType containerType, string policyName)
5866
: base(protectedItemResource, containerName, containerType)

src/ResourceManager/RecoveryServices.Backup/Commands.RecoveryServices.Backup.Models/AzureVmModels/AzureVmJob.cs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,24 @@ namespace Microsoft.Azure.Commands.RecoveryServices.Backup.Cmdlets.Models
2121
/// </summary>
2222
public class AzureVmJob : JobBase
2323
{
24+
/// <summary>
25+
/// Represents whether this job is cancellable.
26+
/// </summary>
2427
public bool IsCancellable { get; set; }
2528

29+
/// <summary>
30+
/// Represents whether this job is retriable.
31+
/// </summary>
2632
public bool IsRetriable { get; set; }
2733

34+
/// <summary>
35+
/// The VM version of the Azure VM associated with this job.
36+
/// </summary>
2837
public string VmVersion { get; set; }
2938

39+
/// <summary>
40+
/// Error details associated with this job.
41+
/// </summary>
3042
public List<AzureVmJobErrorInfo> ErrorDetails { get; set; }
3143
}
3244

@@ -41,8 +53,14 @@ public class AzureVmJobDetails : AzureVmJob
4153
/// </summary>
4254
public string DynamicErrorMessage { get; set; }
4355

56+
/// <summary>
57+
/// Property bag consisting of the some Azure VM specific job details.
58+
/// </summary>
4459
public Dictionary<string, string> Properties { get; set; }
4560

61+
/// <summary>
62+
/// List of sub tasks triggered as part of this job's operation.
63+
/// </summary>
4664
public List<AzureVmJobSubTask> SubTasks { get; set; }
4765
}
4866

@@ -51,6 +69,9 @@ public class AzureVmJobDetails : AzureVmJob
5169
/// </summary>
5270
public class AzureVmJobErrorInfo : JobErrorInfoBase
5371
{
72+
/// <summary>
73+
/// Error code of this job's error.
74+
/// </summary>
5475
public int ErrorCode { get; set; }
5576
}
5677

src/ResourceManager/RecoveryServices.Backup/Commands.RecoveryServices.Backup.Models/AzureVmModels/AzureVmPolicy.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,14 @@ namespace Microsoft.Azure.Commands.RecoveryServices.Backup.Cmdlets.Models
2525
/// </summary>
2626
public class AzureVmPolicy : PolicyBase
2727
{
28+
/// <summary>
29+
/// Object defining the schedule associated with this policy.
30+
/// </summary>
2831
public SchedulePolicyBase SchedulePolicy { get; set; }
2932

33+
/// <summary>
34+
/// Object defining the retention behavior of this policy.
35+
/// </summary>
3036
public RetentionPolicyBase RetentionPolicy { get; set; }
3137

3238
public override void Validate()

src/ResourceManager/RecoveryServices.Backup/Commands.RecoveryServices.Backup.Models/AzureVmModels/AzureVmRecoveryPoint.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,14 @@ namespace Microsoft.Azure.Commands.RecoveryServices.Backup.Cmdlets.Models
2525
/// </summary>
2626
public class AzureVmRecoveryPoint : RecoveryPointBase
2727
{
28+
/// <summary>
29+
/// Additional info associated with this recovery point serialized into a string.
30+
/// </summary>
2831
public string RecoveryPointAdditionalInfo { get; set; }
2932

33+
/// <summary>
34+
/// Storage type of the VM whose backup operation has created this recovery point.
35+
/// </summary>
3036
public string SourceVMStorageType { get; set; }
3137

3238
public AzureVmRecoveryPoint()

0 commit comments

Comments
 (0)