/// <summary> /// Initializes a new instance of the <see cref="Runbook"/> class. /// </summary> /// <param name="accountName"> /// The account name. /// </param> /// <param name="runbook"> /// The runbook. /// </param> /// <exception cref="System.ArgumentException"> /// </exception> public Runbook(string accountName, AutomationManagement.Models.Runbook runbook) { Requires.Argument("runbook", runbook).NotNull(); Requires.Argument("accountName", accountName).NotNull(); this.AutomationAccountName = accountName; this.Name = runbook.Name; this.Location = runbook.Location; this.Type = runbook.Type; this.Tags = runbook.Tags ?? new Dictionary <string, string>(); if (runbook.Properties == null) { return; } this.CreationTime = runbook.Properties.CreationTime.ToLocalTime(); this.LastModifiedTime = runbook.Properties.LastModifiedTime.ToLocalTime(); this.Description = runbook.Properties.Description; this.LogVerbose = runbook.Properties.LogVerbose; this.LogProgress = runbook.Properties.LogProgress; this.State = runbook.Properties.State; this.JobCount = runbook.Properties.JobCount; this.RunbookType = runbook.Properties.RunbookType; this.Parameters = runbook.Properties.Parameters ?? new Dictionary <string, RunbookParameter>(); }
/// <summary> /// Initializes a new instance of the <see cref="Runbook"/> class. /// </summary> /// <param name="accountName"> /// The account name. /// </param> /// <param name="runbook"> /// The runbook. /// </param> /// <exception cref="System.ArgumentException"> /// </exception> public Runbook(string accountName, AutomationManagement.Models.Runbook runbook) { Requires.Argument("runbook", runbook).NotNull(); Requires.Argument("accountName", accountName).NotNull(); this.AutomationAccountName = accountName; this.Name = runbook.Name; this.Location = runbook.Location; this.Tags = null; if (runbook.Properties == null) { return; } this.CreationTime = runbook.Properties.CreationTime.ToLocalTime(); this.LastModifiedTime = runbook.Properties.LastModifiedTime.ToLocalTime(); this.Description = runbook.Properties.Description; this.LogVerbose = runbook.Properties.LogVerbose; this.LogProgress = runbook.Properties.LogProgress; this.State = runbook.Properties.State; this.JobCount = runbook.Properties.JobCount; this.RunbookType = runbook.Properties.RunbookType; this.Parameters = new Hashtable(StringComparer.InvariantCultureIgnoreCase); foreach (var kvp in runbook.Properties.Parameters) { this.Parameters.Add(kvp.Key, (object)kvp.Value); } }
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="RunbookDefinition"/> class. /// </summary> /// <param name="accountName"> /// The runbook version. /// </param> /// <param name="runbook"> /// The runbook version. /// </param> /// <param name="content"> /// The content. /// </param> /// <param name="slot"> /// Slot published or draft. /// </param> public RunbookDefinition(string accountName, AutomationManagement.Models.Runbook runbook, string content, string slot) { Requires.Argument("runbook", runbook).NotNull(); Requires.Argument("accountName", accountName).NotNull(); Requires.Argument("slot", slot).NotNull(); this.AutomationAccountName = accountName; this.Name = runbook.Name; this.Content = content; if (runbook.Properties == null) { return; } this.CreationTime = runbook.Properties.CreationTime.ToLocalTime(); this.LastModifiedTime = runbook.Properties.LastModifiedTime.ToLocalTime(); this.Slot = slot; this.RunbookType = runbook.Properties.RunbookType; }
/// <summary> /// Initializes a new instance of the <see cref="Runbook"/> class. /// </summary> /// <param name="runbook"> /// The runbook. /// </param> /// <exception cref="System.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)); }