using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; namespace OTSSignsOrchestrator.Core.Models.Entities; public enum InstanceStatus { Deploying, Active, Error, Deleted } public enum XiboApiTestStatus { Unknown, Success, Failed } public class CmsInstance { [Key] public Guid Id { get; set; } = Guid.NewGuid(); [Required, MaxLength(100)] public string CustomerName { get; set; } = string.Empty; /// Exactly 3 lowercase letters used to derive all resource names. [MaxLength(3)] public string CustomerAbbrev { get; set; } = string.Empty; [Required, MaxLength(100)] public string StackName { get; set; } = string.Empty; [Required, MaxLength(200)] public string CmsServerName { get; set; } = string.Empty; [Required, Range(1024, 65535)] public int HostHttpPort { get; set; } [Required, MaxLength(500)] public string ThemeHostPath { get; set; } = string.Empty; [Required, MaxLength(500)] public string LibraryHostPath { get; set; } = string.Empty; [Required, MaxLength(200)] public string SmtpServer { get; set; } = string.Empty; [Required, MaxLength(200)] public string SmtpUsername { get; set; } = string.Empty; /// /// JSON array of placement constraints, e.g. ["node.labels.xibo==true"] /// [MaxLength(2000)] public string? Constraints { get; set; } [Required, MaxLength(500)] public string TemplateRepoUrl { get; set; } = string.Empty; [MaxLength(500)] public string? TemplateRepoPat { get; set; } public DateTime? TemplateLastFetch { get; set; } [MaxLength(100)] public string? TemplateCacheKey { get; set; } public InstanceStatus Status { get; set; } = InstanceStatus.Deploying; /// Encrypted Xibo admin username for API access. [MaxLength(500)] public string? XiboUsername { get; set; } /// Encrypted Xibo admin password. Never logged; encrypted at rest. [MaxLength(1000)] public string? XiboPassword { get; set; } public XiboApiTestStatus XiboApiTestStatus { get; set; } = XiboApiTestStatus.Unknown; public DateTime? XiboApiTestedAt { get; set; } public DateTime CreatedAt { get; set; } = DateTime.UtcNow; public DateTime UpdatedAt { get; set; } = DateTime.UtcNow; /// Soft delete marker. public DateTime? DeletedAt { get; set; } // ── CIFS / SMB credentials (per-instance) ───────────────────────────── [MaxLength(200)] public string? CifsServer { get; set; } [MaxLength(500)] public string? CifsShareBasePath { get; set; } [MaxLength(200)] public string? CifsUsername { get; set; } /// Encrypted CIFS password. Never logged; encrypted at rest. [MaxLength(1000)] public string? CifsPassword { get; set; } [MaxLength(500)] public string? CifsExtraOptions { get; set; } /// ID of the SshHost this instance is deployed to. public Guid? SshHostId { get; set; } [ForeignKey(nameof(SshHostId))] public SshHost? SshHost { get; set; } public ICollection OperationLogs { get; set; } = new List(); }