/// <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; }
/// <summary> /// Initializes a new instance of the <see cref="CompilationJob"/> class. /// </summary> /// <param name="resourceGroupName"> /// The resource group name. /// </param> /// <param name="accountName"> /// The account name. /// </param> /// <param name="job"> /// The Job. /// </param> /// <exception cref="System.ArgumentException"> /// </exception> public CompilationJob(string resourceGroupName, string accountName, AutomationManagement.Models.DscCompilationJob job) { Requires.Argument("job", job).NotNull(); Requires.Argument("accountName", accountName).NotNull(); this.ResourceGroupName = resourceGroupName; this.AutomationAccountName = accountName; if (job.Properties == null) return; this.Id = job.Properties.JobId; this.CreationTime = job.Properties.CreationTime.ToLocalTime(); this.LastModifiedTime = job.Properties.LastModifiedTime.ToLocalTime(); this.StartTime = job.Properties.StartTime.HasValue ? job.Properties.StartTime.Value.ToLocalTime() : (DateTimeOffset?)null; this.Status = job.Properties.Status; this.StatusDetails = job.Properties.StatusDetails; this.ConfigurationName = job.Properties.Configuration.Name; this.Exception = job.Properties.Exception; this.EndTime = job.Properties.EndTime.HasValue ? job.Properties.EndTime.Value.ToLocalTime() : (DateTimeOffset?)null; this.LastStatusModifiedTime = job.Properties.LastStatusModifiedTime; this.JobParameters = new Hashtable(StringComparer.InvariantCultureIgnoreCase); foreach (var kvp in job.Properties.Parameters.Where(kvp => 0 != String.Compare(kvp.Key, Constants.JobStartedByParameterName, CultureInfo.InvariantCulture, CompareOptions.IgnoreCase))) { this.JobParameters.Add(kvp.Key, (object)(kvp.Value)); } }
/// <summary> /// Initializes a new instance of the <see cref="Job"/> class. /// </summary> /// <param name="job">The job</param> /// The resource. /// <summary> /// Initializes a new instance of the <see cref="Job"/> class. /// </summary> public Job(AutomationManagement.Models.Job job) { Requires.Argument("job", job).NotNull(); if (job.Context == null || job.Context.RunbookVersion == null || job.Context.RunbookVersion.Runbook == null || job.Context.JobParameters == null) { throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, Resources.InvalidJobModel)); } this.Id = new Guid(job.Id); this.AccountId = new Guid(job.AccountId); this.Exception = job.Exception; this.CreationTime = DateTime.SpecifyKind(job.CreationTime, DateTimeKind.Utc).ToLocalTime(); this.LastModifiedTime = DateTime.SpecifyKind(job.LastModifiedTime, DateTimeKind.Utc).ToLocalTime(); this.StartTime = job.StartTime.HasValue ? DateTime.SpecifyKind(job.StartTime.Value, DateTimeKind.Utc).ToLocalTime() : this.StartTime; this.EndTime = job.EndTime.HasValue ? DateTime.SpecifyKind(job.EndTime.Value, DateTimeKind.Utc).ToLocalTime() : this.EndTime; this.LastStatusModifiedTime = DateTime.SpecifyKind(job.LastStatusModifiedTime, DateTimeKind.Utc).ToLocalTime(); this.Status = job.Status; this.StatusDetails = job.StatusDetails; this.RunbookId = new Guid(job.Context.RunbookVersion.Runbook.Id); this.RunbookName = job.Context.RunbookVersion.Runbook.Name; this.ScheduleName = job.Context.Schedule != null ? job.Context.Schedule.Name : string.Empty; this.JobParameters = from jobParameter in job.Context.JobParameters where jobParameter.Name != Constants.JobStartedByParameterName select new JobParameter(jobParameter); }
/// <summary> /// Initializes a new instance of the <see cref="DscConfiguration"/> class. /// </summary> /// <param name="resourceGroupName"> /// The resource group name. /// </param> /// <param name="automationAccountName"> /// The automation account. /// </param> /// <param name="configuration"> /// The configuration script. /// </param> public DscConfiguration(string resourceGroupName, string automationAccountName, AutomationManagement.Models.DscConfiguration configuration) { Requires.Argument("ResourceGroupName", resourceGroupName).NotNull(); Requires.Argument("AutomationAccountName", automationAccountName).NotNull(); Requires.Argument("Configuration", configuration).NotNull(); this.ResourceGroupName = resourceGroupName; this.AutomationAccountName = automationAccountName; this.Name = configuration.Name; this.Location = configuration.Location; this.Tags = null; if (configuration.Properties == null) return; this.CreationTime = configuration.Properties.CreationTime.ToLocalTime(); this.LastModifiedTime = configuration.Properties.LastModifiedTime.ToLocalTime(); this.Description = configuration.Properties.Description; this.LogVerbose = configuration.Properties.LogVerbose; this.State = configuration.Properties.State; this.Location = configuration.Location; this.Tags = new Hashtable(StringComparer.InvariantCultureIgnoreCase); foreach (var kvp in configuration.Tags) { this.Tags.Add(kvp.Key, kvp.Value); } this.Parameters = new Hashtable(StringComparer.InvariantCultureIgnoreCase); foreach (var kvp in configuration.Properties.Parameters) { this.Parameters.Add(kvp.Key, (object)kvp.Value); } }
public RunbookParameter(AutomationManagement.Models.RunbookParameter runbookParameter) { this.RunbookVersionId = new Guid(runbookParameter.RunbookVersionId); this.Name = runbookParameter.Name; this.Type = runbookParameter.Type; this.IsMandatory = runbookParameter.IsMandatory; this.Position = runbookParameter.Position; }
public AutomationClient(AzureSubscription subscription, AutomationManagement.IAutomationManagementClient automationManagementClient) { Requires.Argument("automationManagementClient", automationManagementClient).NotNull(); this.Subscription = subscription; this.automationManagementClient = automationManagementClient; }
/// <summary> /// Initializes a new instance of the <see cref="JobStreamItem"/> class. /// </summary> /// <param name="jobStreamItem"> /// The job stream item. /// </param> public JobStreamItem(AutomationManagement.Models.JobStreamItem jobStreamItem) { Requires.Argument("jobStreamItem", jobStreamItem).NotNull(); this.AccountId = new Guid(jobStreamItem.AccountId); this.JobId = new Guid(jobStreamItem.JobId); this.RunbookVersionId = new Guid(jobStreamItem.RunbookVersionId); this.Text = jobStreamItem.Text; this.Time = DateTime.SpecifyKind(jobStreamItem.Time, DateTimeKind.Utc).ToLocalTime(); this.Type = jobStreamItem.Type; }
/// <summary> /// Initializes a new instance of the <see cref="RunbookVersion"/> class. /// </summary> /// <param name="runbookVersion"> /// The runbook version. /// </param> public RunbookVersion(AutomationManagement.Models.RunbookVersion runbookVersion) { Requires.Argument("runbookVersion", runbookVersion).NotNull(); this.AccountId = new Guid(runbookVersion.AccountId); this.Id = new Guid(runbookVersion.Id); this.RunbookId = new Guid(runbookVersion.RunbookId); this.VersionNumber = runbookVersion.VersionNumber; this.IsDraft = runbookVersion.IsDraft; this.CreationTime = DateTime.SpecifyKind(runbookVersion.CreationTime, DateTimeKind.Utc).ToLocalTime(); this.LastModifiedTime = DateTime.SpecifyKind(runbookVersion.LastModifiedTime, DateTimeKind.Utc).ToLocalTime(); }
/// <summary> /// Initializes a new instance of the <see cref="JobStream"/> class. /// </summary> /// <param name="jobStream"> /// The job stream. /// </param> /// <param name="resourceGroupName"> /// The resource group name. /// </param> /// <param name="automationAccountName"> /// The automation account name /// </param> /// <param name="jobId"> /// The job Id /// </param> /// <exception cref="System.ArgumentException"> /// </exception> public JobStream(AutomationManagement.Models.JobStream jobStream, string resourceGroupName, string automationAccountName, Guid jobId ) { Requires.Argument("jobStream", jobStream).NotNull(); this.JobStreamId = jobStream.Properties.JobStreamId; this.Type = jobStream.Properties.StreamType; this.Text = jobStream.Properties.Summary; this.Time = jobStream.Properties.Time; this.AutomationAccountName = automationAccountName; this.ResourceGroupName = resourceGroupName; this.Id = jobId; }
/// <summary> /// Initializes a new instance of the <see cref="AgentRegistration"/> class. /// </summary> /// <param name="resourceGroupName"> /// The resource group name. /// </param> /// <param name="automationAccountName"> /// The automation account. /// </param> /// <param name="agentRegistration"> /// The automation account agent registration /// </param>/// public AgentRegistration(string resourceGroupName, string automationAccountName, AutomationManagement.Models.AgentRegistration agentRegistration) { Requires.Argument("ResourceGroupName", resourceGroupName).NotNull(); Requires.Argument("AutomationAccountName", automationAccountName).NotNull(); this.ResourceGroupName = resourceGroupName; this.AutomationAccountName = automationAccountName; if (agentRegistration.Keys != null) { this.PrimaryKey = agentRegistration.Keys.Primary; this.SecondaryKey = agentRegistration.Keys.Secondary; } this.Endpoint = agentRegistration.Endpoint; }
/// <summary> /// Initializes a new instance of the <see cref="DscNodeReport"/> class. /// </summary> /// <param name="resourceGroupName">The resource group name.</param> /// <param name="automationAccountName">The automation account.</param> /// <param name="nodeId">The Node Id.</param> /// <param name="dscNodeReport">The dsc node report.</param> public DscNodeReport(string resourceGroupName, string automationAccountName, string nodeId, AutomationManagement.Models.DscNodeReport dscNodeReport) { Requires.Argument("ResourceGroupName", resourceGroupName).NotNull(); Requires.Argument("AutomationAccountName", automationAccountName).NotNull(); Requires.Argument("dscNodeReport", dscNodeReport).NotNull(); this.ResourceGroupName = resourceGroupName; this.AutomationAccountName = automationAccountName; this.StartTime = dscNodeReport.StartTime; this.EndTime = dscNodeReport.EndTime; this.LastModifiedTime = dscNodeReport.LastModifiedTime; this.ReportType = dscNodeReport.Type; this.Id = dscNodeReport.Id; this.NodeId = nodeId; }
/// <summary> /// Initializes a new instance of the <see cref="DscNode"/> class. /// </summary> /// <param name="resourceGroupName">The resource group name.</param> /// <param name="automationAccountName">The automation account.</param> /// <param name="node">The dsc node.</param> public DscNode(string resourceGroupName, string automationAccountName, AutomationManagement.Models.DscNode node) { Requires.Argument("ResourceGroupName", resourceGroupName).NotNull(); Requires.Argument("AutomationAccountName", automationAccountName).NotNull(); Requires.Argument("Node", node).NotNull(); this.ResourceGroupName = resourceGroupName; this.AutomationAccountName = automationAccountName; this.Name = node.Name; this.Id = node.NodeId.ToString("D"); this.IpAddress = node.Ip; this.LastSeen = node.LastSeen.ToLocalTime(); this.RegistrationTime = node.RegistrationTime.ToLocalTime(); this.Status = node.Status; this.NodeConfigurationName = node.NodeConfiguration.Name; }
/// <summary> /// Initializes a new instance of the <see cref="ConfigurationContent"/> class. /// </summary> /// <param name="resourceGroupName"> /// The resource group name. /// </param> /// <param name="accountName"> /// The account name. /// </param> /// <param name="configuration"> /// The configuration. /// </param> /// <param name="content"> /// The content. /// </param> /// <param name="slot"> /// Slot published or draft. /// </param> public ConfigurationContent(string resourceGroupName, string accountName, AutomationManagement.Models.DscConfiguration configuration, string content, string slot) { Requires.Argument("configuration", configuration).NotNull(); Requires.Argument("accountName", accountName).NotNull(); Requires.Argument("resourceGroupName", resourceGroupName).NotNull(); Requires.Argument("slot", slot).NotNull(); this.AutomationAccountName = accountName; this.Name = configuration.Name; this.Content = content; if (configuration.Properties == null) return; this.CreationTime = configuration.Properties.CreationTime.ToLocalTime(); this.LastModifiedTime = configuration.Properties.LastModifiedTime.ToLocalTime(); this.Slot = slot; }
/// <summary> /// Initializes a new instance of the <see cref="DscNodeConfiguration"/> class. /// </summary> /// <param name="accountName"> /// The account name. /// </param> /// <param name="nodeConfiguration"> /// The NodeConfiguration. /// </param> /// <exception cref="System.ArgumentException"> /// </exception> public NodeConfiguration(string resourceGroupName, string accountName, AutomationManagement.Models.DscNodeConfiguration nodeConfiguration, string rollUpStatus) { Requires.Argument("nodeConfiguration", nodeConfiguration).NotNull(); Requires.Argument("accountName", accountName).NotNull(); this.ResourceGroupName = resourceGroupName; this.AutomationAccountName = accountName; this.Name = nodeConfiguration.Name; this.CreationTime = nodeConfiguration.CreationTime.ToLocalTime(); this.LastModifiedTime = nodeConfiguration.LastModifiedTime.ToLocalTime(); this.RollupStatus = rollUpStatus; if (nodeConfiguration.Configuration != null) { this.ConfigurationName = nodeConfiguration.Configuration.Name; } }
/// <summary> /// Initializes a new instance of the <see cref="JobStream"/> class. /// </summary> /// <param name="jobStream"> /// The job stream. /// </param> /// <param name="resourceGroupName"> /// The resource group name. /// </param> /// <param name="automationAccountName"> /// The automation account name /// </param> /// <param name="jobId"> /// The job Id /// </param> /// <exception cref="System.ArgumentException"> /// </exception> public JobStream(AutomationManagement.Models.JobStream jobStream, string resourceGroupName, string automationAccountName, Guid jobId) { Requires.Argument("jobStream", jobStream).NotNull(); this.StreamRecordId = jobStream.Properties.JobStreamId; this.Type = jobStream.Properties.StreamType; this.Time = jobStream.Properties.Time; this.AutomationAccountName = automationAccountName; this.ResourceGroupName = resourceGroupName; this.JobId = jobId; if (!String.IsNullOrWhiteSpace(jobStream.Properties.Summary)) { this.Summary = jobStream.Properties.Summary.Length > Constants.JobSummaryLength ? jobStream.Properties.Summary.Substring(0, Constants.JobSummaryLength) + "..." : jobStream.Properties.Summary; } }
/// <summary> /// Initializes a new instance of the <see cref="DscNodeReport"/> class. /// </summary> /// <param name="resourceGroupName">The resource group name.</param> /// <param name="automationAccountName">The automation account.</param> /// <param name="nodeId">The Node Id.</param> /// <param name="dscNodeReport">The dsc node report.</param> public DscNodeReport(string resourceGroupName, string automationAccountName, string nodeId, AutomationManagement.Models.DscNodeReport dscNodeReport) { Requires.Argument("ResourceGroupName", resourceGroupName).NotNull(); Requires.Argument("AutomationAccountName", automationAccountName).NotNull(); Requires.Argument("dscNodeReport", dscNodeReport).NotNull(); Requires.Argument("dscNodeReport", dscNodeReport.ReportId).NotNull(); this.ResourceGroupName = resourceGroupName; this.AutomationAccountName = automationAccountName; this.StartTime = dscNodeReport.StartTime; this.EndTime = dscNodeReport.EndTime; this.LastModifiedTime = dscNodeReport.LastModifiedTime; this.ReportType = dscNodeReport.Type; this.Id = dscNodeReport.ReportId.ToString("D"); this.NodeId = nodeId; this.Status = dscNodeReport.Status; this.RefreshMode = dscNodeReport.RefreshMode; this.RebootRequested = dscNodeReport.RebootRequested; this.ReportFormatVersion = dscNodeReport.ReportFormatVersion; }
/// <summary> /// Initializes a new instance of the <see cref="JobStreamRecord"/> class. /// </summary> /// <param name="jobStream"> /// The job stream. /// </param> /// <param name="resourceGroupName"> /// The resource group name. /// </param> /// <param name="automationAccountName"> /// The automation account name /// </param> /// <param name="jobId"> /// The job Id /// </param> /// <exception cref="System.ArgumentException"> /// </exception> public JobStreamRecord(AutomationManagement.Models.JobStream jobStream, string resourceGroupName, string automationAccountName, Guid jobId) : base(jobStream, resourceGroupName, automationAccountName, jobId) { this.Value = new Hashtable(); foreach (var kvp in jobStream.Properties.Value) { object paramValue; try { paramValue = ((object)PowerShellJsonConverter.Deserialize(kvp.Value.ToString())); } catch (CmdletInvocationException exception) { if (!exception.Message.Contains("Invalid JSON primitive")) throw; paramValue = kvp.Value; } this.Value.Add(kvp.Key, paramValue); } }
/// <summary> /// Initializes a new instance of the <see cref="AutomationAccount"/> class. /// </summary> /// <param name="cloudService"> /// The cloud service. /// </param> /// <param name="resource"> /// The resource. /// </param> public AutomationAccount( AutomationManagement.Models.CloudService cloudService, AutomationManagement.Models.AutomationResource resource) { Requires.Argument("cloudService", cloudService).NotNull(); Requires.Argument("resource", resource).NotNull(); this.AutomationAccountName = resource.Name; this.Location = cloudService.GeoRegion; this.Plan = resource.Plan; switch (resource.State) { case AutomationManagement.Models.AutomationResourceState.Started: this.State = Constants.AutomationAccountState.Ready; break; case AutomationManagement.Models.AutomationResourceState.Stopped: this.State = Constants.AutomationAccountState.Suspended; break; default: this.State = resource.State; break; } }
private Model.JobStream CreateJobStreamFromJobStreamModel(AutomationManagement.Models.JobStream jobStream, string resourceGroupName, string automationAccountName, Guid jobId) { Requires.Argument("jobStream", jobStream).NotNull(); Requires.Argument("resourceGroupName", resourceGroupName).NotNull(); Requires.Argument("automationAccountName", automationAccountName).NotNull(); Requires.Argument("jobId", jobId).NotNull(); return new Model.JobStream(jobStream, resourceGroupName, automationAccountName, jobId); }
private Schedule UpdateScheduleHelper(string automationAccountName, AutomationManagement.Models.Schedule schedule, bool? isEnabled, string description) { // StartTime and ExpiryTime need to specified as Utc schedule.StartTime = DateTime.SpecifyKind(schedule.StartTime, DateTimeKind.Utc); schedule.ExpiryTime = DateTime.SpecifyKind(schedule.ExpiryTime, DateTimeKind.Utc); if (isEnabled.HasValue) { schedule.IsEnabled = isEnabled.Value; } if (description != null) { schedule.Description = description; } var scheduleUpdateParameters = new AutomationManagement.Models.ScheduleUpdateParameters { Schedule = schedule }; this.automationManagementClient.Schedules.Update( automationAccountName, scheduleUpdateParameters); var scheduleId = new Guid(schedule.Id); return this.GetSchedule(automationAccountName, scheduleId); }
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); }
private Schedule CreateScheduleFromScheduleModel(AutomationManagement.Models.Schedule schedule) { Requires.Argument("schedule", schedule).NotNull(); if (schedule.ScheduleType == AutomationManagement.Models.ScheduleType.DailySchedule) { return new DailySchedule(schedule); } else { return new OneTimeSchedule(schedule); } }
private JobSchedule CreateJobScheduleFromJobScheduleModel(string resourceGroupName, string automationAccountName, AutomationManagement.Models.JobSchedule jobSchedule) { Requires.Argument("jobSchedule", jobSchedule).NotNull(); return new JobSchedule(resourceGroupName, automationAccountName, jobSchedule); }
/// <summary> /// Initializes a new instance of the <see cref="RunbookDefinition"/> class. /// </summary> /// <param name="runbookVersion"> /// The runbook version. /// </param> /// <param name="content"> /// The content. /// </param> public RunbookDefinition(AutomationManagement.Models.RunbookVersion runbookVersion, byte[] content) { this.RunbookVersion = new RunbookVersion(runbookVersion); this.Content = System.Text.Encoding.UTF8.GetString(content); }
public JobParameter(AutomationManagement.Models.JobParameter jobParameter) { this.Name = jobParameter.Name; this.Value = jobParameter.Value; this.Type = jobParameter.Type; }