private AutomationManagement.Models.Runbook GetRunbookModel(string automationAccountName, Guid runbookId, bool withSchedules) { AutomationManagement.Models.Runbook runbookModel = withSchedules ? this.automationManagementClient.Runbooks.GetWithSchedules( automationAccountName, runbookId.ToString()).Runbook : this.automationManagementClient.Runbooks.Get( automationAccountName, runbookId.ToString()).Runbook; if (runbookModel == null) { throw new ResourceNotFoundException(typeof(Runbook), string.Format(CultureInfo.CurrentCulture, Resources.RunbookNotFoundById, runbookId)); } return(runbookModel); }
private Runbook UpdateRunbookHelper( string automationAccountName, AutomationManagement.Models.Runbook runbook, string description, string[] tags, bool?logDebug, bool?logProgress, bool?logVerbose) { if (description != null) { runbook.Description = description; } if (tags != null) { runbook.Tags = string.Join(Constants.RunbookTagsSeparatorString, tags); } if (logDebug.HasValue) { runbook.LogDebug = logDebug.Value; } if (logProgress.HasValue) { runbook.LogProgress = logProgress.Value; } if (logVerbose.HasValue) { runbook.LogVerbose = logVerbose.Value; } var runbookUpdateParameters = new AutomationManagement.Models.RunbookUpdateParameters { Runbook = runbook }; this.automationManagementClient.Runbooks.Update(automationAccountName, runbookUpdateParameters); var runbookId = new Guid(runbook.Id); return(this.GetRunbook(automationAccountName, runbookId)); }
/// <summary> /// Initializes a new instance of the <see cref="Runbook"/> class. /// </summary> /// <param name="runbook"> /// The runbook. /// </param> /// <exception cref="ArgumentException"> /// </exception> public Runbook(AutomationManagement.Models.Runbook runbook) { Requires.Argument("runbook", runbook).NotNull(); if (runbook.Schedules == null) { throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, Resources.InvalidRunbookModel)); } this.AccountId = new Guid(runbook.AccountId); this.Id = new Guid(runbook.Id); this.Name = runbook.Name; this.CreationTime = DateTime.SpecifyKind(runbook.CreationTime, DateTimeKind.Utc).ToLocalTime(); this.LastModifiedTime = DateTime.SpecifyKind(runbook.LastModifiedTime, DateTimeKind.Utc).ToLocalTime(); this.LastModifiedBy = runbook.LastModifiedBy; this.Description = runbook.Description; this.IsApiOnly = runbook.IsApiOnly; this.IsGlobal = runbook.IsGlobal; if (runbook.PublishedRunbookVersionId != null) { this.PublishedRunbookVersionId = new Guid(runbook.PublishedRunbookVersionId); } if (runbook.DraftRunbookVersionId != null) { this.DraftRunbookVersionId = new Guid(runbook.DraftRunbookVersionId); } this.Tags = runbook.Tags != null?runbook.Tags.Split(Constants.RunbookTagsSeparatorChar) : new string[] { }; this.LogDebug = runbook.LogDebug; this.LogVerbose = runbook.LogVerbose; this.LogProgress = runbook.LogProgress; this.ScheduleNames = from schedule in runbook.Schedules where (schedule.NextRun != null) select schedule.Name; }
public IEnumerable <Job> ListJobsByRunbookId(string automationAccountName, Guid runbookId, DateTime?startTime, DateTime?endTime) { AutomationManagement.Models.Runbook runbookModel = this.GetRunbookModel(automationAccountName, runbookId, false); return(this.ListJobsByValidRunbookId(automationAccountName, new Guid(runbookModel.Id), startTime, endTime)); }
public IEnumerable <RunbookDefinition> ListRunbookDefinitionsByRunbookId(string automationAccountName, Guid runbookId, bool?isDraft) { AutomationManagement.Models.Runbook runbookModel = this.GetRunbookModel(automationAccountName, runbookId, false); return(this.ListRunbookDefinitionsByValidRunbookId(automationAccountName, new Guid(runbookModel.Id), isDraft)); }
public Runbook UpdateRunbook(string automationAccountName, string runbookName, string description, string[] tags, bool?logDebug, bool?logProgress, bool?logVerbose) { AutomationManagement.Models.Runbook runbookModel = this.GetRunbookModel(automationAccountName, runbookName, false); return(this.UpdateRunbookHelper(automationAccountName, runbookModel, description, tags, logDebug, logProgress, logVerbose)); }