using ZB.MOM.WW.ScadaBridge.Commons.Types.Transport;
namespace ZB.MOM.WW.ScadaBridge.Commons.Messages.Management;
///
/// Exports a bundle. Names rather than IDs in the selection so test scripts can
/// be written without an ID lookup step. All=true overrides the per-type
/// name lists and exports every entity of every supported type.
///
/// Inbound API keys are intentionally not selectable: per the inbound-API-key
/// re-architecture (C4) keys are not transported between environments; only API
/// methods travel. Re-create keys and re-grant their method scopes on the
/// destination via the admin UI/CLI.
///
///
public sealed record ExportBundleCommand(
bool All,
IReadOnlyList? TemplateNames,
IReadOnlyList? SharedScriptNames,
IReadOnlyList? ExternalSystemNames,
IReadOnlyList? DatabaseConnectionNames,
IReadOnlyList? NotificationListNames,
IReadOnlyList? SmtpConfigurationNames,
IReadOnlyList? ApiMethodNames,
bool IncludeDependencies,
string? Passphrase,
string SourceEnvironment,
// Additive (M8 B4): site/instance-scoped selection. Sites resolve by
// SiteIdentifier (preferred) or Name; instances resolve by UniqueName.
// Defaulted null so every existing positional caller keeps compiling; the
// handler normalizes null to "select nothing" (or everything under All=true).
IReadOnlyList? SiteNames = null,
IReadOnlyList? InstanceNames = null);
///
/// Bundle body returned as base64-encoded ZIP. is the
/// pre-encoded size for sanity checks against the configured bundle cap.
///
public sealed record ExportBundleResult(
string Base64Bundle,
int ByteCount);
///
/// Loads a bundle and returns its preview without applying anything. Useful
/// for tests that want to assert on the diff shape before committing.
///
public sealed record PreviewBundleCommand(
string Base64Bundle,
string? Passphrase);
public sealed record PreviewBundleResult(
IReadOnlyList Items,
int AddCount,
int ModifiedCount,
int IdenticalCount,
int BlockerCount,
// Additive (M8 D3): site/connection references the operator must resolve
// before import, carried verbatim from ImportPreview. Defaulted to empty so
// every existing positional caller keeps compiling.
IReadOnlyList? RequiredSiteMappings = null,
IReadOnlyList? RequiredConnectionMappings = null)
{
/// Site references the operator must resolve before import (M8). Never null.
public IReadOnlyList RequiredSiteMappings { get; init; } =
RequiredSiteMappings ?? Array.Empty();
/// Connection references the operator must resolve before import (M8). Never null.
public IReadOnlyList RequiredConnectionMappings { get; init; } =
RequiredConnectionMappings ?? Array.Empty();
}
///
/// One source-environment site → destination resolution carried on
/// across the CLI ⇆ ManagementActor boundary.
/// A null/blank means CreateNew; a
/// present value means MapToExisting that target. Serializable via
/// System.Text.Json.
///
public sealed record SiteMappingSpec(
string SourceSiteIdentifier,
string? TargetSiteIdentifier);
///
/// One source-environment data-connection (scoped to a source site) →
/// destination resolution carried on . A
/// null/blank means CreateNew; a present
/// value means MapToExisting that target. Serializable via System.Text.Json.
///
public sealed record ConnectionMappingSpec(
string SourceSiteIdentifier,
string SourceConnectionName,
string? TargetConnectionName);
///
/// Loads, previews, and applies a bundle in a single call. The diff is built
/// internally; every row is resolved with
/// , every
/// row gets , every
/// row gets ,
/// and any row fails the call.
///
/// Valid values: "skip",
/// "overwrite", "rename". Rename mints a unique suffix per row.
///
///
/// M8 (D3): /
/// supply explicit operator resolutions for the source-environment site/connection
/// references the bundle carries; the handler merges them with the preview's
/// auto-matches and the /
/// flags into a
/// passed to Apply. All four are defaulted so every
/// existing positional caller keeps compiling and central-config-only bundles
/// (no site/instance payload) carry an empty map.
///
///
public sealed record ImportBundleCommand(
string Base64Bundle,
string? Passphrase,
string DefaultConflictPolicy,
IReadOnlyList? SiteMappings = null,
IReadOnlyList? ConnectionMappings = null,
bool CreateMissingSites = false,
bool CreateMissingConnections = false);