Skip to content

Commit 38dfc1e

Browse files
author
Samuel Anudeep
committed
Merge pull request #141 from MabOneSdk/dev1
FI from dev1 into release
2 parents 608b8b3 + 79b49af commit 38dfc1e

File tree

10 files changed

+85
-14
lines changed

10 files changed

+85
-14
lines changed

src/ResourceManager/AzureBackup/Commands.AzureBackup.Test/Commands.AzureBackup.Test.csproj

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,7 @@
4040
<HintPath>..\..\..\packages\Microsoft.Azure.Common.Authentication.1.1.3-preview\lib\net45\Microsoft.Azure.Common.Authentication.dll</HintPath>
4141
</Reference>
4242
<Reference Include="Microsoft.Azure.Management.BackupServicesManagement, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
43-
<SpecificVersion>False</SpecificVersion>
44-
<HintPath>..\Commands.AzureBackup\Resources\Microsoft.Azure.Management.BackupServicesManagement.dll</HintPath>
43+
<HintPath>..\..\..\packages\Microsoft.Azure.Management.BackupServices.1.0.4-preview\lib\net40\Microsoft.Azure.Management.BackupServicesManagement.dll</HintPath>
4544
</Reference>
4645
<Reference Include="Microsoft.Azure.ResourceManager, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
4746
<SpecificVersion>False</SpecificVersion>

src/ResourceManager/AzureBackup/Commands.AzureBackup.Test/packages.config

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<package id="Microsoft.Azure.Common" version="2.1.0" targetFramework="net45" />
55
<package id="Microsoft.Azure.Common.Authentication" version="1.1.3-preview" targetFramework="net45" />
66
<package id="Microsoft.Azure.Common.Dependencies" version="1.0.0" targetFramework="net45" />
7-
<package id="Microsoft.Azure.Management.BackupServices" version="1.0.3-preview" targetFramework="net45" />
7+
<package id="Microsoft.Azure.Management.BackupServices" version="1.0.4-preview" targetFramework="net45" />
88
<package id="Microsoft.Azure.Management.Resources" version="2.18.7-preview" targetFramework="net45" />
99
<package id="Microsoft.Azure.Test.Framework" version="1.0.5687.28567-prerelease" targetFramework="net45" />
1010
<package id="Microsoft.Azure.Test.HttpRecorder" version="1.0.5687.28567-prerelease" targetFramework="net45" />

src/ResourceManager/AzureBackup/Commands.AzureBackup/AzureBackupCmdletHelpMessage.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,5 +93,7 @@ internal static class AzureBackupCmdletHelpMessage
9393
public const string WeekNumber = "List of Week Numbers of the month";
9494
public const string MonthsOfYear = "List of Months of the year";
9595
public const string Retention = "Retention duration value";
96+
97+
public const string PolicyObject = "Policy object for enabling protection";
9698
}
9799
}

src/ResourceManager/AzureBackup/Commands.AzureBackup/Cmdlets/Item/Disable-AzureRMBackupProtection .cs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,6 @@ public SwitchParameter RemoveRecoveryPoints
4040
}
4141
private bool DeleteBackupData;
4242

43-
[Parameter(Position = 2, Mandatory = false, HelpMessage = AzureBackupCmdletHelpMessage.Reason)]
44-
public string Reason { get; set; }
45-
46-
[Parameter(Position = 3, Mandatory = false, HelpMessage = AzureBackupCmdletHelpMessage.Comments)]
47-
public string Comments { get; set; }
48-
4943
public override void ExecuteCmdlet()
5044
{
5145
ExecutionBlock(() =>

src/ResourceManager/AzureBackup/Commands.AzureBackup/Cmdlets/Item/Enable-AzureRMBackupProtection .cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ namespace Microsoft.Azure.Commands.AzureBackup.Cmdlets
3232
[Cmdlet(VerbsLifecycle.Enable, "AzureRMBackupProtection"), OutputType(typeof(AzureRMBackupJob))]
3333
public class EnableAzureRMBackupProtection : AzureRMBackupItemCmdletBase
3434
{
35-
[Parameter(Mandatory = true, HelpMessage = AzureBackupCmdletHelpMessage.PolicyName)]
35+
[Parameter(Mandatory = true, HelpMessage = AzureBackupCmdletHelpMessage.PolicyObject)]
3636
[ValidateNotNullOrEmpty]
3737
public AzureRMBackupProtectionPolicy Policy { get; set; }
3838

src/ResourceManager/AzureBackup/Commands.AzureBackup/Commands.AzureBackup.csproj

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,7 @@
5757
<HintPath>..\..\..\packages\Microsoft.Azure.Common.2.1.0\lib\net45\Microsoft.Azure.Common.NetFramework.dll</HintPath>
5858
</Reference>
5959
<Reference Include="Microsoft.Azure.Management.BackupServicesManagement, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
60-
<SpecificVersion>False</SpecificVersion>
61-
<HintPath>Resources\Microsoft.Azure.Management.BackupServicesManagement.dll</HintPath>
60+
<HintPath>..\..\..\packages\Microsoft.Azure.Management.BackupServices.1.0.4-preview\lib\net40\Microsoft.Azure.Management.BackupServicesManagement.dll</HintPath>
6261
</Reference>
6362
<Reference Include="Microsoft.Azure.ResourceManager, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
6463
<SpecificVersion>False</SpecificVersion>

src/ResourceManager/AzureBackup/Commands.AzureBackup/Helpers/VaultHelpers.cs

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@
1313
// ----------------------------------------------------------------------------------
1414

1515
using System;
16+
using System.Collections;
17+
using System.Collections.Generic;
18+
using System.Linq;
1619
using ClientModel = Microsoft.Azure.Management.BackupServices.Models;
1720
using CmdletModel = Microsoft.Azure.Commands.AzureBackup.Models;
1821

@@ -50,5 +53,78 @@ public static string GetResourceGroup(string vaultId)
5053
string[] tokens = vaultId.Split(new[] { '/' }, StringSplitOptions.RemoveEmptyEntries);
5154
return tokens[3];
5255
}
56+
57+
// NOTE: Commenting code which will be used in a later sprint, but not right now.
58+
59+
/// <summary>
60+
/// Extension to convert enumerable Hashtable into a dictionary
61+
/// </summary>
62+
/// <param name="tags"></param>
63+
/// <returns></returns>
64+
// public static Dictionary<string, string> ConvertToDictionary(this Hashtable[] tags)
65+
// {
66+
// return tags == null
67+
// ? null
68+
// : tags
69+
// .CoalesceEnumerable()
70+
// .Select(hashTable => hashTable.OfType<DictionaryEntry>()
71+
// .ToDictionary(kvp => kvp.Key.ToString(), kvp => kvp.Value))
72+
// .Where(tagDictionary => tagDictionary.ContainsKey("Name"))
73+
// .Select(tagDictionary => Tuple
74+
// .Create(
75+
// tagDictionary["Name"].ToString(),
76+
// tagDictionary.ContainsKey("Value") ? tagDictionary["Value"].ToString() : string.Empty))
77+
// .Distinct(kvp => kvp.Item1)
78+
// .ToDictionary(kvp => kvp.Item1, kvp => kvp.Item2);
79+
// }
80+
81+
/// <summary>
82+
/// Extension to coalesce enumerable
83+
/// </summary>
84+
/// <typeparam name="TSource">Enumerable type</typeparam>
85+
/// <param name="source">Enumerable</param>
86+
/// <returns></returns>
87+
// public static IEnumerable<TSource> CoalesceEnumerable<TSource>(this IEnumerable<TSource> source)
88+
// {
89+
// return source ?? Enumerable.Empty<TSource>();
90+
// }
91+
92+
/// <summary>
93+
/// Extension to remove duplicates from enumerable based on a provided key selector
94+
/// </summary>
95+
/// <typeparam name="TSource">Enumerable type</typeparam>
96+
/// <typeparam name="TKeyType">Type of key</typeparam>
97+
/// <param name="source">Input enumerable to remove duplicates from</param>
98+
/// <param name="keySelector">Lambda to select key</param>
99+
/// <returns></returns>
100+
// public static IEnumerable<TSource> Distinct<TSource, TKeyType>(this IEnumerable<TSource> source, Func<TSource, TKeyType> keySelector)
101+
// {
102+
// var set = new Dictionary<TKeyType, TSource>(EqualityComparer<TKeyType>.Default);
103+
// foreach (TSource element in source)
104+
// {
105+
// TSource value;
106+
// var key = keySelector(element);
107+
// if (!set.TryGetValue(key, out value))
108+
// {
109+
// yield return element;
110+
// }
111+
// else
112+
// {
113+
// set[key] = value;
114+
// }
115+
// }
116+
// }
117+
118+
/// <summary>
119+
/// Extension to convert dictionary to hashtable enumerable
120+
/// </summary>
121+
/// <param name="tags"></param>
122+
/// <returns></returns>
123+
// public static Hashtable[] GetTagsHashtables(this IDictionary<string, string> tags)
124+
// {
125+
// return tags == null
126+
// ? null
127+
// : tags.Select(kvp => new Hashtable { { "Name", kvp.Key }, { "Value", kvp.Value } }).ToArray();
128+
// }
53129
}
54130
}

src/ResourceManager/AzureBackup/Commands.AzureBackup/Models/AzurePSBackupVault.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ public class AzureRMBackupVault
3030

3131
public string Region { get; set; }
3232

33-
// public Hashtable[] Tags { get; protected set; }
33+
// TODO: Add support for tags
34+
//public Hashtable[] Tags { get; set; }
3435

3536
public string Storage { get; set; }
3637

src/ResourceManager/AzureBackup/Commands.AzureBackup/packages.config

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<package id="Microsoft.Azure.Common" version="2.1.0" targetFramework="net45" />
55
<package id="Microsoft.Azure.Common.Authentication" version="1.1.3-preview" targetFramework="net45" />
66
<package id="Microsoft.Azure.Common.Dependencies" version="1.0.0" targetFramework="net45" />
7-
<package id="Microsoft.Azure.Management.BackupServices" version="1.0.3-preview" targetFramework="net45" />
7+
<package id="Microsoft.Azure.Management.BackupServices" version="1.0.4-preview" targetFramework="net45" />
88
<package id="Microsoft.Azure.Management.Resources" version="2.18.7-preview" targetFramework="net45" />
99
<package id="Microsoft.Bcl" version="1.1.9" targetFramework="net45" />
1010
<package id="Microsoft.Bcl.Async" version="1.0.168" targetFramework="net45" />

0 commit comments

Comments
 (0)