using System.Xml.Serialization; namespace ControlPlane.Core.Models; [XmlRoot("Tenant")] public class TenantRecord { // ── Identity ────────────────────────────────────────────────────────── [XmlAttribute] public string Subdomain { get; set; } = string.Empty; [XmlElement] public string ClientName { get; set; } = string.Empty; [XmlElement] public string StateCode { get; set; } = string.Empty; [XmlElement] public string AdminEmail { get; set; } = string.Empty; [XmlElement] public string SiteCode { get; set; } = string.Empty; [XmlElement] public string Environment { get; set; } = "fdev"; [XmlElement] public string Tier { get; set; } = string.Empty; [XmlElement] public string Status { get; set; } = "Provisioning"; [XmlElement] public string ProvisionedAt { get; set; } = DateTimeOffset.UtcNow.ToString("o"); [XmlElement] public string JobId { get; set; } = string.Empty; // ── Container (written by InfrastructureStep / LaunchStep) ──────────── [XmlElement(IsNullable = true)] public string? ContainerName { get; set; } [XmlElement(IsNullable = true)] public string? ContainerPort { get; set; } [XmlElement(IsNullable = true)] public string? ContainerImage { get; set; } [XmlElement(IsNullable = true)] public string? ContainerNetwork { get; set; } [XmlElement(IsNullable = true)] public string? NginxConfPath { get; set; } [XmlElement(IsNullable = true)] public string? ApiBaseUrl { get; set; } [XmlElement(IsNullable = true)] public string? PublicUrl { get; set; } [XmlElement(IsNullable = true)] public string? LastProvisioningStep { get; set; } [XmlElement(IsNullable = true)] public string? ProvisioningNotes { get; set; } // ── web.config-style sections ───────────────────────────────────────── [XmlElement("ConnectionStrings")] public ConnectionStringsSection ConnectionStrings { get; set; } = new(); [XmlElement("AppSettings")] public AppSettingsSection AppSettings { get; set; } = new(); // ── Helpers ─────────────────────────────────────────────────────────── public void SetConnectionString(string name, string connectionString) { var existing = ConnectionStrings.Entries.FirstOrDefault(e => e.Name == name); if (existing is not null) existing.ConnectionString = connectionString; else ConnectionStrings.Entries.Add(new ConnectionStringEntry { Name = name, ConnectionString = connectionString }); } public string? GetConnectionString(string name) => ConnectionStrings.Entries.FirstOrDefault(e => e.Name == name)?.ConnectionString; public void SetAppSetting(string key, string value) { var existing = AppSettings.Entries.FirstOrDefault(e => e.Key == key); if (existing is not null) existing.Value = value; else AppSettings.Entries.Add(new AppSettingEntry { Key = key, Value = value }); } public string? GetAppSetting(string key) => AppSettings.Entries.FirstOrDefault(e => e.Key == key)?.Value; } // ── Section types ────────────────────────────────────────────────────────── public class ConnectionStringsSection { [XmlElement("add")] public List Entries { get; set; } = []; } public class AppSettingsSection { [XmlElement("add")] public List Entries { get; set; } = []; } public class ConnectionStringEntry { [XmlAttribute("name")] public string Name { get; set; } = string.Empty; [XmlAttribute("connectionString")] public string ConnectionString { get; set; } = string.Empty; [XmlAttribute("providerName")] public string ProviderName { get; set; } = "System.Data.SqlClient"; } public class AppSettingEntry { [XmlAttribute("key")] public string Key { get; set; } = string.Empty; [XmlAttribute("value")] public string Value { get; set; } = string.Empty; }