OPC # 0001: Extract OPC into standalone repo

This commit is contained in:
amadzarak
2026-04-25 17:26:42 -04:00
commit 42383bdc03
170 changed files with 21365 additions and 0 deletions
+135
View File
@@ -0,0 +1,135 @@
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<ConnectionStringEntry> Entries { get; set; } = [];
}
public class AppSettingsSection
{
[XmlElement("add")]
public List<AppSettingEntry> 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;
}