feat: deploy scoped grpc data connection configuration
This commit is contained in:
@@ -52,6 +52,14 @@ public static class ConfigComposer
|
||||
public static ConfigArtifact Compose(DraftSnapshot snapshot)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(snapshot);
|
||||
foreach (var connection in snapshot.DataConnections)
|
||||
{
|
||||
if (connection.Endpoints is null || connection.Endpoints.Any(endpoint =>
|
||||
!string.IsNullOrWhiteSpace(endpoint) &&
|
||||
(!Uri.TryCreate(endpoint, UriKind.Absolute, out var uri) || uri.Scheme != Uri.UriSchemeHttps ||
|
||||
!string.IsNullOrEmpty(uri.UserInfo) || !string.IsNullOrEmpty(uri.Query) || !string.IsNullOrEmpty(uri.Fragment))))
|
||||
throw new InvalidDataException($"Invalid endpoint in data connection '{connection.DataConnectionId}'.");
|
||||
}
|
||||
|
||||
// v3 greenfield snapshot: the Raw tree (RawFolders → DriverInstances(+RawFolderId) → Devices(+DeviceConfig)
|
||||
// → TagGroups → Tags(DeviceId/TagGroupId, no EquipmentId/FolderPath/DriverInstanceId)) plus the UNS
|
||||
@@ -87,6 +95,20 @@ public static class ConfigComposer
|
||||
Scripts = snapshot.Scripts,
|
||||
VirtualTags = snapshot.VirtualTags,
|
||||
ScriptedAlarms = snapshot.ScriptedAlarms,
|
||||
DataConnections = snapshot.DataConnections.OrderBy(x => x.DataConnectionId, StringComparer.Ordinal).Select(connection =>
|
||||
{
|
||||
var copy = JsonSerializer.Deserialize<ZB.MOM.WW.OtOpcUa.Configuration.Entities.DataConnection>(JsonSerializer.SerializeToUtf8Bytes(connection, JsonOptions), JsonOptions)!;
|
||||
copy.ConsumerNodeIds = copy.ConsumerNodeIds.OrderBy(x => x, StringComparer.Ordinal).ToList();
|
||||
copy.EligibleTargetNodeIds = copy.EligibleTargetNodeIds.OrderBy(x => x, StringComparer.Ordinal).ToList();
|
||||
return copy;
|
||||
}).ToArray(),
|
||||
DataExports = snapshot.DataExports.OrderBy(x => x.DataExportId, StringComparer.Ordinal).ToArray(),
|
||||
RemoteNamespaceMappings = snapshot.RemoteNamespaceMappings.OrderBy(x => x.RemoteNamespaceMappingId, StringComparer.Ordinal).Select(mapping =>
|
||||
{
|
||||
var copy = JsonSerializer.Deserialize<ZB.MOM.WW.OtOpcUa.Configuration.Entities.RemoteNamespaceMapping>(JsonSerializer.SerializeToUtf8Bytes(mapping, JsonOptions), JsonOptions)!;
|
||||
copy.ConsumerNodeIds = copy.ConsumerNodeIds.OrderBy(x => x, StringComparer.Ordinal).ToList();
|
||||
return copy;
|
||||
}).ToArray(),
|
||||
};
|
||||
|
||||
return Pack(JsonSerializer.SerializeToUtf8Bytes(ordered, JsonOptions));
|
||||
|
||||
Reference in New Issue
Block a user