/// <summary> /// The validate. /// </summary> /// <returns> /// The <see cref="Schedule"/>. /// </returns> /// <exception cref="Exception"> /// throws exception /// </exception> private Models.Schedule CreateMonthlyScheduleModel() { var dayOfWeek = this.DayOfWeek.HasValue ? this.DayOfWeek.ToString() : null; if ((!string.IsNullOrWhiteSpace(dayOfWeek) && this.DayOfWeekOccurrence == 0) || (string.IsNullOrWhiteSpace(dayOfWeek) && this.DayOfWeekOccurrence != 0)) { throw new ArgumentException(Resources.MonthlyScheduleNeedsDayOfWeekAndOccurrence); } var newSchedule = new Models.Schedule { Name = this.Name, StartTime = this.StartTime, Description = this.Description, ExpiryTime = this.ExpiryTime, TimeZone = this.TimeZone, Frequency = Models.ScheduleFrequency.Month, Interval = this.MonthInterval, MonthlyScheduleOptions = this.IsMonthlyScheduleNull() ? null : new Models.MonthlyScheduleOptions() { DaysOfMonth = this.DaysOfMonth, DayOfWeek = this.DayOfWeek == null && this.DayOfWeekOccurrence == 0 ? null : new DayOfWeek() { Day = dayOfWeek, Occurrence = this.DayOfWeekOccurrence == 0 ? null : this.DayOfWeekOccurrence.ToString() } } }; return(newSchedule); }
protected override void AutomationProcessRecord() { if (!this.IsScheduleNameValid()) { throw new AzPSArgumentException(Resources.ScheduleNameInvalid, nameof(Name)); } var schedule = new Models.Schedule { Name = this.Name, StartTime = this.StartTime, Description = this.Description, ExpiryTime = this.ExpiryTime, TimeZone = this.TimeZone, }; switch (this.ParameterSetName) { case AutomationCmdletParameterSets.ByOneTime: schedule.Frequency = Models.ScheduleFrequency.Onetime; break; case AutomationCmdletParameterSets.ByDaily: schedule.Frequency = Models.ScheduleFrequency.Day; schedule.Interval = this.DayInterval; break; case AutomationCmdletParameterSets.ByHourly: schedule.Frequency = Models.ScheduleFrequency.Hour; schedule.Interval = this.HourInterval; break; case AutomationCmdletParameterSets.ByWeekly: schedule = this.CreateWeeklyScheduleModel(); break; case AutomationCmdletParameterSets.ByMonthlyDayOfWeek: schedule = this.CreateMonthlyScheduleModel(); break; case AutomationCmdletParameterSets.ByMonthlyDaysOfMonth: schedule = this.CreateMonthlyScheduleModel(); break; } Models.Schedule createdSchedule = schedule; if (!this.ForUpdateConfiguration.IsPresent) { createdSchedule = this.AutomationClient.CreateSchedule(this.ResourceGroupName, this.AutomationAccountName, schedule); } this.WriteObject(createdSchedule); }
public Schedule CreateSchedule(string automationAccountName, Schedule schedule) { var scheduleCreateParameters = new AutomationManagement.Models.ScheduleCreateParameters { Name = schedule.Name, Properties = new AutomationManagement.Models.ScheduleCreateProperties { StartTime = schedule.StartTime, ExpiryTime = schedule.ExpiryTime, Description = schedule.Description, Interval = schedule.Interval, Frequency = schedule.Frequency.ToString() } }; var scheduleCreateResponse = this.automationManagementClient.Schedules.Create( automationAccountName, scheduleCreateParameters); return this.GetSchedule(automationAccountName, schedule.Name); }
/// <summary> /// The create weekly schedule model. /// </summary> /// <returns> /// The <see cref="Schedule"/>. /// </returns> private Models.Schedule CreateWeeklyScheduleModel() { var newSchedule = new Models.Schedule { Name = this.Name, StartTime = this.StartTime, Description = this.Description, ExpiryTime = this.ExpiryTime, TimeZone = this.TimeZone, Frequency = Models.ScheduleFrequency.Week, Interval = this.WeekInterval, WeeklyScheduleOptions = this.DaysOfWeek == null ? null : new Models.WeeklyScheduleOptions() { DaysOfWeek = this.DaysOfWeek.Select(day => day.ToString()).ToList() } }; return(newSchedule); }
public Schedule CreateSchedule(string automationAccountName, Schedule schedule) { var scheduleCreateParameters = new AutomationManagement.Models.ScheduleCreateParameters { Name = schedule.Name, Properties = new AutomationManagement.Models.ScheduleCreateProperties { StartTime = schedule.StartTime, ExpiryTime = schedule.ExpiryTime, Description = schedule.Description, Interval = schedule.Interval, Frequency = schedule.Frequency.ToString() } }; var scheduleCreateResponse = this.automationManagementClient.Schedules.Create( automationAccountName, scheduleCreateParameters); return(this.GetSchedule(automationAccountName, schedule.Name)); }
/// <summary> /// The create weekly schedule model. /// </summary> /// <returns> /// The <see cref="Schedule"/>. /// </returns> private Schedule CreateWeeklyScheduleModel() { var newSchedule = new Schedule { Name = this.Name, StartTime = this.StartTime, Description = this.Description, ExpiryTime = this.ExpiryTime, Frequency = ScheduleFrequency.Week, Interval = this.WeekInterval, WeeklyScheduleOptions = this.DaysOfWeek == null ? null : new WeeklyScheduleOptions() { DaysOfWeek = this.DaysOfWeek.Select(day => day.ToString()).ToList() } }; return newSchedule; }
/// <summary> /// The validate. /// </summary> /// <returns> /// The <see cref="Schedule"/>. /// </returns> /// <exception cref="Exception"> /// throws exception /// </exception> private Schedule CreateMonthlyScheduleModel() { var dayOfWeek = this.DayOfWeek.HasValue ? this.DayOfWeek.ToString() : null; if ((!string.IsNullOrWhiteSpace(dayOfWeek) && this.DayOfWeekOccurrence == 0) || (string.IsNullOrWhiteSpace(dayOfWeek) && this.DayOfWeekOccurrence != 0)) { throw new ArgumentException(Resources.MonthlyScheduleNeedsDayOfWeekAndOccurrence); } var newSchedule = new Schedule { Name = this.Name, StartTime = this.StartTime, Description = this.Description, ExpiryTime = this.ExpiryTime, Frequency = ScheduleFrequency.Month, Interval = this.MonthInterval, MonthlyScheduleOptions = this.IsMonthlyScheduleNull() ? null : new MonthlyScheduleOptions() { DaysOfMonth = this.DaysOfMonth, DayOfWeek = this.DayOfWeek == null && this.DayOfWeekOccurrence == 0 ? null : new DayOfWeek() { Day = dayOfWeek, Occurrence = this.DayOfWeekOccurrence == 0 ? null : this.DayOfWeekOccurrence.ToString() } } }; return newSchedule; }
protected override void AutomationProcessRecord() { var schedule = new Schedule { Name = this.Name, StartTime = this.StartTime, Description = this.Description, ExpiryTime = this.ExpiryTime, TimeZone = this.TimeZone, }; switch (this.ParameterSetName) { case AutomationCmdletParameterSets.ByOneTime: schedule.Frequency = ScheduleFrequency.Onetime; break; case AutomationCmdletParameterSets.ByDaily: schedule.Frequency = ScheduleFrequency.Day; schedule.Interval = this.DayInterval; break; case AutomationCmdletParameterSets.ByHourly: schedule.Frequency = ScheduleFrequency.Hour; schedule.Interval = this.HourInterval; break; case AutomationCmdletParameterSets.ByWeekly: schedule = this.CreateWeeklyScheduleModel(); break; case AutomationCmdletParameterSets.ByMonthlyDayOfWeek: schedule = this.CreateMonthlyScheduleModel(); break; case AutomationCmdletParameterSets.ByMonthlyDaysOfMonth: schedule = this.CreateMonthlyScheduleModel(); break; } Schedule createdSchedule = this.AutomationClient.CreateSchedule(this.ResourceGroupName, this.AutomationAccountName, schedule); this.WriteObject(createdSchedule); }
protected override void AutomationProcessRecord() { var schedule = new Schedule { Name = this.Name, StartTime = this.StartTime, Description = this.Description, ExpiryTime = this.ExpiryTime }; if (this.ParameterSetName == AutomationCmdletParameterSets.ByOneTime) { schedule.Frequency = ScheduleFrequency.Onetime; } else if (this.ParameterSetName == AutomationCmdletParameterSets.ByDaily) { schedule.Frequency = ScheduleFrequency.Day; schedule.Interval = this.DayInterval; } else if (this.ParameterSetName == AutomationCmdletParameterSets.ByHourly) { schedule.Frequency = ScheduleFrequency.Hour; schedule.Interval = this.HourInterval; } Schedule createdSchedule = this.AutomationClient.CreateSchedule(this.ResourceGroupName, this.AutomationAccountName, schedule); this.WriteObject(createdSchedule); }
public Schedule CreateSchedule(string resourceGroupName, string automationAccountName, Schedule schedule) { var scheduleCreateOrUpdateParameters = new AutomationManagement.Models.ScheduleCreateOrUpdateParameters { Name = schedule.Name, Properties = new AutomationManagement.Models.ScheduleCreateOrUpdateProperties { StartTime = schedule.StartTime, ExpiryTime = schedule.ExpiryTime, Description = schedule.Description, Interval = schedule.Interval, Frequency = schedule.Frequency.ToString(), AdvancedSchedule = schedule.GetAdvancedSchedule(), TimeZone = schedule.TimeZone, } }; var scheduleCreateResponse = this.automationManagementClient.Schedules.CreateOrUpdate( resourceGroupName, automationAccountName, scheduleCreateOrUpdateParameters); return this.GetSchedule(resourceGroupName, automationAccountName, schedule.Name); }