Skip to content

Commit 064e118

Browse files
committed
Merge branch 'dev' of https://github.com/Azure/azure-powershell into MoveRG
Conflicts: src/ResourceManager/Resources/Commands.Resources.Test/Commands.Resources.Test.csproj
2 parents 26c2949 + 72b79da commit 064e118

File tree

87 files changed

+3396
-311
lines changed

Some content is hidden

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

87 files changed

+3396
-311
lines changed

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

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -107,16 +107,12 @@
107107
<SpecificVersion>False</SpecificVersion>
108108
<HintPath>..\..\packages\Microsoft.Bcl.Async.1.0.168\lib\net40\Microsoft.Threading.Tasks.Extensions.Desktop.dll</HintPath>
109109
</Reference>
110-
<Reference Include="Microsoft.WindowsAzure.Configuration">
111-
<SpecificVersion>False</SpecificVersion>
112-
<HintPath>..\..\..\packages\Microsoft.WindowsAzure.ConfigurationManager.3.2.0\lib\net40\Microsoft.WindowsAzure.Configuration.dll</HintPath>
113-
</Reference>
114110
<Reference Include="Microsoft.WindowsAzure.Management, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
115111
<SpecificVersion>False</SpecificVersion>
116112
<HintPath>..\..\packages\Microsoft.WindowsAzure.Management.4.1.1\lib\net40\Microsoft.WindowsAzure.Management.dll</HintPath>
117113
</Reference>
118114
<Reference Include="Microsoft.WindowsAzure.Management.Storage">
119-
<HintPath>..\..\packages\Microsoft.WindowsAzure.Management.Storage.5.1.1\lib\net40\Microsoft.WindowsAzure.Management.Storage.dll</HintPath>
115+
<HintPath>..\..\packages\Microsoft.WindowsAzure.Management.Storage.6.0.0\lib\net40\Microsoft.WindowsAzure.Management.Storage.dll</HintPath>
120116
</Reference>
121117
<Reference Include="Microsoft.WindowsAzure.Storage, Version=6.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
122118
<SpecificVersion>False</SpecificVersion>

src/Common/Commands.Common.Storage/packages.config

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
<package id="Microsoft.Rest.ClientRuntime.Azure.Authentication" version="2.0.1-preview" targetFramework="net45" />
1919
<package id="Microsoft.WindowsAzure.ConfigurationManager" version="3.2.0" targetFramework="net45" />
2020
<package id="Microsoft.WindowsAzure.Management" version="4.1.1" targetFramework="net45" />
21-
<package id="Microsoft.WindowsAzure.Management.Storage" version="5.1.1" targetFramework="net45" />
21+
<package id="Microsoft.WindowsAzure.Management.Storage" version="6.0.0" targetFramework="net45" />
2222
<package id="Newtonsoft.Json" version="6.0.8" targetFramework="net45" />
2323
<package id="System.Spatial" version="5.6.4" targetFramework="net45" />
2424
<package id="WindowsAzure.Storage" version="6.1.0" targetFramework="net45" />

src/ResourceManager/Automation/Commands.Automation.Test/Commands.Automation.Test.csproj

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,9 @@
5959
<Reference Include="Microsoft.Azure.Common.NetFramework">
6060
<HintPath>..\..\..\packages\Microsoft.Azure.Common.2.1.0\lib\net45\Microsoft.Azure.Common.NetFramework.dll</HintPath>
6161
</Reference>
62-
<Reference Include="Microsoft.Azure.Management.Automation">
63-
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Automation.2.0.0\lib\net40\Microsoft.Azure.Management.Automation.dll</HintPath>
62+
<Reference Include="Microsoft.Azure.Management.Automation, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
63+
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Automation.2.0.1\lib\net40\Microsoft.Azure.Management.Automation.dll</HintPath>
64+
<Private>True</Private>
6465
</Reference>
6566
<Reference Include="Microsoft.Azure.ResourceManager, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
6667
<SpecificVersion>False</SpecificVersion>
@@ -130,8 +131,10 @@
130131
<HintPath>..\..\..\packages\Microsoft.Net.Http.2.2.28\lib\net45\System.Net.Http.Primitives.dll</HintPath>
131132
</Reference>
132133
<Reference Include="System.Net.Http.WebRequest" />
133-
<Reference Include="System.Xml" /> <Reference Include="xunit.abstractions, Version=2.0.0.0, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c, processorArchitecture=MSIL">
134-
<HintPath>..\..\..\packages\xunit.abstractions.2.0.0\lib\net35\xunit.abstractions.dll</HintPath> <Private>True</Private>
134+
<Reference Include="System.Xml" />
135+
<Reference Include="xunit.abstractions, Version=2.0.0.0, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c, processorArchitecture=MSIL">
136+
<HintPath>..\..\..\packages\xunit.abstractions.2.0.0\lib\net35\xunit.abstractions.dll</HintPath>
137+
<Private>True</Private>
135138
</Reference>
136139
<Reference Include="xunit.assert, Version=2.1.0.3179, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c, processorArchitecture=MSIL">
137140
<HintPath>..\..\..\packages\xunit.assert.2.1.0\lib\portable-net45+win8+wp8+wpa81\xunit.assert.dll</HintPath>

src/ResourceManager/Automation/Commands.Automation.Test/UnitTests/NewAzureAutomationRunbookTest.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
using Microsoft.WindowsAzure.Commands.Utilities.Common;
2121
using Moq;
2222
using System.Collections.Generic;
23+
2324
namespace Microsoft.Azure.Commands.ResourceManager.Automation.Test.UnitTests
2425
{
2526
[TestClass]
@@ -44,7 +45,7 @@ public void SetupTest()
4445
}
4546

4647
[TestMethod]
47-
public void NewAzureAutomationRunbookByNameSuccessfull()
48+
public void NewAzureAutomationRunbookByNameSuccessful()
4849
{
4950
// Setup
5051
string resourceGroupName = "resourceGroup";

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
<package id="Hyak.Common" version="1.0.3" targetFramework="net45" />
44
<package id="Microsoft.Azure.Common" version="2.1.0" targetFramework="net45" />
55
<package id="Microsoft.Azure.Common.Dependencies" version="1.0.0" targetFramework="net45" />
6+
<package id="Microsoft.Azure.Management.Automation" version="2.0.1" targetFramework="net45" />
67
<package id="Microsoft.Azure.Management.Resources" version="2.20.0-preview" targetFramework="net45" />
78
<package id="Microsoft.Azure.Test.Framework" version="1.0.5945.28173-prerelease" targetFramework="net45" />
89
<package id="Microsoft.Azure.Test.HttpRecorder" version="1.0.5945.28173-prerelease" targetFramework="net45" />

src/ResourceManager/Automation/Commands.Automation/Cmdlet/ImportAzureAutomationRunbook.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,12 @@ public class ImportAzureAutomationRunbook : AzureAutomationBaseCmdlet
6161
/// Gets or sets the runbook version type
6262
/// </summary>
6363
[Parameter(Mandatory = true, HelpMessage = "Runbook definition type.")]
64-
[ValidateSet(Constants.RunbookType.Graph, Constants.RunbookType.PowerShell, Constants.RunbookType.PowerShellWorkflow, IgnoreCase = true)]
64+
[ValidateSet(Constants.RunbookType.PowerShell,
65+
Constants.RunbookType.GraphicalPowerShell,
66+
Constants.RunbookType.PowerShellWorkflow,
67+
Constants.RunbookType.GraphicalPowerShellWorkflow,
68+
Constants.RunbookType.Graph,
69+
IgnoreCase = true)]
6570
[ValidateNotNullOrEmpty]
6671
public string Type { get; set; }
6772

@@ -101,7 +106,7 @@ protected override void AutomationProcessRecord()
101106
this.ResolvePath(this.Path),
102107
this.Description,
103108
this.Tags,
104-
this.Type,
109+
RunbookTypeSdkValue.Resolve(this.Type),
105110
this.LogProgress,
106111
this.LogVerbose,
107112
this.Published.IsPresent,

src/ResourceManager/Automation/Commands.Automation/Cmdlet/NewAzureAutomationRunbook.cs

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,12 @@ public class NewAzureAutomationRunbook : AzureAutomationBaseCmdlet
5252
/// Gets or sets the runbook version type
5353
/// </summary>
5454
[Parameter(Mandatory = true, HelpMessage = "Runbook definition type.")]
55-
[ValidateSet(Constants.RunbookType.Graph, Constants.RunbookType.PowerShell, Constants.RunbookType.PowerShellWorkflow, IgnoreCase = true)]
55+
[ValidateSet(Constants.RunbookType.PowerShell,
56+
Constants.RunbookType.GraphicalPowerShell,
57+
Constants.RunbookType.PowerShellWorkflow,
58+
Constants.RunbookType.GraphicalPowerShellWorkflow,
59+
Constants.RunbookType.Graph,
60+
IgnoreCase = true)]
5661
[ValidateNotNullOrEmpty]
5762
public string Type { get; set; }
5863

@@ -78,7 +83,15 @@ protected override void AutomationProcessRecord()
7883

7984
// ByRunbookName
8085
runbook = this.AutomationClient.CreateRunbookByName(
81-
this.ResourceGroupName, this.AutomationAccountName, this.Name, this.Description, this.Tags, this.Type, this.LogProgress, this.LogVerbose, false);
86+
this.ResourceGroupName,
87+
this.AutomationAccountName,
88+
this.Name,
89+
this.Description,
90+
this.Tags,
91+
RunbookTypeSdkValue.Resolve(this.Type),
92+
this.LogProgress,
93+
this.LogVerbose,
94+
false);
8295

8396
this.WriteObject(runbook);
8497
}

src/ResourceManager/Automation/Commands.Automation/Cmdlet/NewAzureAutomationSchedule.cs

Lines changed: 208 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,15 @@
1212
// limitations under the License.
1313
// ----------------------------------------------------------------------------------
1414

15-
using Microsoft.Azure.Commands.Automation.Common;
16-
using Microsoft.Azure.Commands.Automation.Model;
1715
using System;
16+
using System.Collections.Generic;
17+
using System.Linq;
1818
using System.Management.Automation;
1919
using System.Security.Permissions;
20+
using Microsoft.Azure.Commands.Automation.Common;
21+
using Microsoft.Azure.Commands.Automation.Model;
22+
using Microsoft.Azure.Commands.Automation.Properties;
23+
using DayOfWeek = Microsoft.Azure.Commands.Automation.Model.DayOfWeek;
2024

2125
namespace Microsoft.Azure.Commands.Automation.Cmdlet
2226
{
@@ -57,6 +61,30 @@ public NewAzureAutomationSchedule()
5761
[Parameter(Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = "The schedule description.")]
5862
public string Description { get; set; }
5963

64+
/// <summary>
65+
/// Gets or sets the schedule days of the week.
66+
/// </summary>
67+
[Parameter(ParameterSetName = AutomationCmdletParameterSets.ByWeekly, Mandatory = false, HelpMessage = "The list of days of week for the weekly schedule.")]
68+
public System.DayOfWeek[] DaysOfWeek { get; set; }
69+
70+
/// <summary>
71+
/// Gets or sets the schedule days of the month.
72+
/// </summary>
73+
[Parameter(ParameterSetName = AutomationCmdletParameterSets.ByMonthlyDaysOfMonth, Mandatory = false, HelpMessage = "The list of days of month for the monthly schedule.")]
74+
public DaysOfMonth[] DaysOfMonth { get; set; }
75+
76+
/// <summary>
77+
/// Gets or sets the schedule day of the week.
78+
/// </summary>
79+
[Parameter(ParameterSetName = AutomationCmdletParameterSets.ByMonthlyDayOfWeek, Mandatory = false, HelpMessage = "The day of week for the monthly occurrence.")]
80+
public System.DayOfWeek? DayOfWeek { get; set; }
81+
82+
/// <summary>
83+
/// Gets or sets the schedule day of the week.
84+
/// </summary>
85+
[Parameter(ParameterSetName = AutomationCmdletParameterSets.ByMonthlyDayOfWeek, Mandatory = false, HelpMessage = "The Occurrence of the week within the month.")]
86+
public DayOfWeekOccurrence DayOfWeekOccurrence { get; set; }
87+
6088
/// <summary>
6189
/// Gets or sets the switch parameter to create a one time schedule.
6290
/// </summary>
@@ -68,6 +96,9 @@ public NewAzureAutomationSchedule()
6896
/// </summary>
6997
[Parameter(ParameterSetName = AutomationCmdletParameterSets.ByDaily, Mandatory = false, HelpMessage = "The schedule expiry time.")]
7098
[Parameter(ParameterSetName = AutomationCmdletParameterSets.ByHourly, Mandatory = false, HelpMessage = "The schedule expiry time.")]
99+
[Parameter(ParameterSetName = AutomationCmdletParameterSets.ByWeekly, Mandatory = false, HelpMessage = "The schedule expiry time.")]
100+
[Parameter(ParameterSetName = AutomationCmdletParameterSets.ByMonthlyDaysOfMonth, Mandatory = false, HelpMessage = "The schedule expiry time.")]
101+
[Parameter(ParameterSetName = AutomationCmdletParameterSets.ByMonthlyDayOfWeek, Mandatory = false, HelpMessage = "The schedule expiry time.")]
71102
public DateTimeOffset ExpiryTime { get; set; }
72103

73104
/// <summary>
@@ -84,6 +115,27 @@ public NewAzureAutomationSchedule()
84115
[ValidateRange(1, byte.MaxValue)]
85116
public byte HourInterval { get; set; }
86117

118+
/// <summary>
119+
/// Gets or sets the weekly schedule week interval.
120+
/// </summary>
121+
[Parameter(ParameterSetName = AutomationCmdletParameterSets.ByWeekly, Mandatory = true, HelpMessage = "The weekly schedule week interval.")]
122+
[ValidateRange(1, byte.MaxValue)]
123+
public byte WeekInterval { get; set; }
124+
125+
/// <summary>
126+
/// Gets or sets the weekly schedule week interval.
127+
/// </summary>
128+
[Parameter(ParameterSetName = AutomationCmdletParameterSets.ByMonthlyDaysOfMonth, Mandatory = true, HelpMessage = "The monthly schedule month interval.")]
129+
[Parameter(ParameterSetName = AutomationCmdletParameterSets.ByMonthlyDayOfWeek, Mandatory = true, HelpMessage = "The monthly schedule month interval.")]
130+
[ValidateRange(1, byte.MaxValue)]
131+
public byte MonthInterval { get; set; }
132+
133+
/// <summary>
134+
/// Gets or sets the schedule time zone.
135+
/// </summary>
136+
[Parameter(Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = "The schedule time zone.")]
137+
public string TimeZone { get; set; }
138+
87139
/// <summary>
88140
/// Execute this cmdlet.
89141
/// </summary>
@@ -95,26 +147,168 @@ protected override void AutomationProcessRecord()
95147
Name = this.Name,
96148
StartTime = this.StartTime,
97149
Description = this.Description,
98-
ExpiryTime = this.ExpiryTime
150+
ExpiryTime = this.ExpiryTime,
151+
TimeZone = this.TimeZone,
99152
};
100153

101-
if (this.ParameterSetName == AutomationCmdletParameterSets.ByOneTime)
154+
switch (this.ParameterSetName)
102155
{
103-
schedule.Frequency = ScheduleFrequency.Onetime;
156+
case AutomationCmdletParameterSets.ByOneTime:
157+
schedule.Frequency = ScheduleFrequency.Onetime;
158+
break;
159+
case AutomationCmdletParameterSets.ByDaily:
160+
schedule.Frequency = ScheduleFrequency.Day;
161+
schedule.Interval = this.DayInterval;
162+
break;
163+
case AutomationCmdletParameterSets.ByHourly:
164+
schedule.Frequency = ScheduleFrequency.Hour;
165+
schedule.Interval = this.HourInterval;
166+
break;
167+
case AutomationCmdletParameterSets.ByWeekly:
168+
schedule = this.CreateWeeklyScheduleModel();
169+
break;
170+
case AutomationCmdletParameterSets.ByMonthlyDayOfWeek:
171+
schedule = this.CreateMonthlyScheduleModel();
172+
break;
173+
case AutomationCmdletParameterSets.ByMonthlyDaysOfMonth:
174+
schedule = this.CreateMonthlyScheduleModel();
175+
break;
104176
}
105-
else if (this.ParameterSetName == AutomationCmdletParameterSets.ByDaily)
177+
178+
Schedule createdSchedule = this.AutomationClient.CreateSchedule(this.ResourceGroupName, this.AutomationAccountName, schedule);
179+
this.WriteObject(createdSchedule);
180+
}
181+
182+
/// <summary>
183+
/// The validate.
184+
/// </summary>
185+
/// <returns>
186+
/// The <see cref="Schedule"/>.
187+
/// </returns>
188+
/// <exception cref="Exception">
189+
/// throws exception
190+
/// </exception>
191+
private Schedule CreateMonthlyScheduleModel()
192+
{
193+
var dayOfWeek = this.DayOfWeek.HasValue ? this.DayOfWeek.ToString() : null;
194+
if ((!string.IsNullOrWhiteSpace(dayOfWeek) && this.DayOfWeekOccurrence == 0) || (string.IsNullOrWhiteSpace(dayOfWeek) && this.DayOfWeekOccurrence != 0))
106195
{
107-
schedule.Frequency = ScheduleFrequency.Day;
108-
schedule.Interval = this.DayInterval;
196+
throw new ArgumentException(Resources.MonthlyScheduleNeedsDayOfWeekAndOccurrence);
109197
}
110-
else if (this.ParameterSetName == AutomationCmdletParameterSets.ByHourly)
198+
199+
var newSchedule = new Schedule
111200
{
112-
schedule.Frequency = ScheduleFrequency.Hour;
113-
schedule.Interval = this.HourInterval;
114-
}
201+
Name = this.Name,
202+
StartTime = this.StartTime,
203+
Description = this.Description,
204+
ExpiryTime = this.ExpiryTime,
205+
Frequency = ScheduleFrequency.Month,
206+
Interval = this.MonthInterval,
207+
MonthlyScheduleOptions = this.IsMonthlyScheduleNull()
208+
? null
209+
: new MonthlyScheduleOptions()
210+
{
211+
DaysOfMonth = this.DaysOfMonth,
212+
DayOfWeek = this.DayOfWeek == null && this.DayOfWeekOccurrence == 0
213+
? null
214+
: new DayOfWeek()
215+
{
216+
Day = dayOfWeek,
217+
Occurrence = this.DayOfWeekOccurrence == 0 ? null : this.DayOfWeekOccurrence.ToString()
218+
}
219+
}
220+
};
115221

116-
Schedule createdSchedule = this.AutomationClient.CreateSchedule(this.ResourceGroupName, this.AutomationAccountName, schedule);
117-
this.WriteObject(createdSchedule);
222+
return newSchedule;
223+
}
224+
225+
/// <summary>
226+
/// The is monthly schedule null.
227+
/// </summary>
228+
/// <returns>
229+
/// The <see cref="bool"/>.
230+
/// </returns>
231+
private bool IsMonthlyScheduleNull()
232+
{
233+
return this.DaysOfMonth == null && this.DayOfWeek == null && this.DayOfWeekOccurrence == 0;
234+
}
235+
236+
/// <summary>
237+
/// The create weekly schedule model.
238+
/// </summary>
239+
/// <returns>
240+
/// The <see cref="Schedule"/>.
241+
/// </returns>
242+
private Schedule CreateWeeklyScheduleModel()
243+
{
244+
var newSchedule = new Schedule
245+
{
246+
Name = this.Name,
247+
StartTime = this.StartTime,
248+
Description = this.Description,
249+
ExpiryTime = this.ExpiryTime,
250+
Frequency = ScheduleFrequency.Week,
251+
Interval = this.WeekInterval,
252+
WeeklyScheduleOptions = this.DaysOfWeek == null
253+
? null
254+
: new WeeklyScheduleOptions()
255+
{
256+
DaysOfWeek = this.DaysOfWeek.Select(day => day.ToString()).ToList()
257+
}
258+
};
259+
260+
return newSchedule;
118261
}
119262
}
263+
264+
/// <summary>
265+
/// The day of week occurrence.
266+
/// </summary>
267+
public enum DayOfWeekOccurrence
268+
{
269+
First = 1,
270+
Second = 2,
271+
Third = 3,
272+
Fourth = 4,
273+
Last = -1
274+
}
275+
276+
/// <summary>
277+
/// The day of week occurrence.
278+
/// </summary>
279+
public enum DaysOfMonth
280+
{
281+
One = 1,
282+
Two = 2,
283+
Three = 3,
284+
Four = 4,
285+
Five = 5,
286+
Six = 6,
287+
Seventh = 7,
288+
Eighth = 8,
289+
Ninth = 9,
290+
Tenth = 10,
291+
Eleventh =11,
292+
Twelfth =12,
293+
Thirteenth = 13,
294+
Fourteenth = 14,
295+
Fifteenth = 15,
296+
Sixteenth = 16,
297+
Seventeenth = 17,
298+
Eighteenth = 18,
299+
Nineteenth = 19,
300+
Twentieth = 20,
301+
TwentyFirst = 21,
302+
TwentySecond = 22,
303+
TwentyThird = 23,
304+
TwentyFourth = 24,
305+
TwentyFifth = 25,
306+
TwentySixth = 26,
307+
TwentySeventh = 27,
308+
TwentyEighth = 28,
309+
TwentyNinth = 29,
310+
Thirtieth = 30,
311+
ThirtyFirst = 31,
312+
LastDay = -1
313+
}
120314
}

0 commit comments

Comments
 (0)