Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
//******************************************************************************************************
// FileUploadOperationFilter.cs - Gbtc
//
// Copyright © 2026, Grid Protection Alliance. All Rights Reserved.
//
// Licensed to the Grid Protection Alliance (GPA) under one or more contributor license agreements. See
// the NOTICE file distributed with this work for additional information regarding copyright ownership.
// The GPA licenses this file to you under the Eclipse Public License -v 1.0 (the "License"); you may
// not use this file except in compliance with the License. You may obtain a copy of the License at:
//
// http://www.opensource.org/licenses/eclipse-1.0.php
//
// Unless agreed to in writing, the subject software distributed under the License is distributed on an
// "AS-IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. Refer to the
// License for the specific language governing permissions and limitations.
//
// Code Modification History:
// ----------------------------------------------------------------------------------------------------
// 06/05/2026 - Marcos Vinicius Snak
// Generated original version of source code.
//
//******************************************************************************************************

using System.Collections.Generic;
using System.Web.Http.Description;
using Swashbuckle.Swagger;

namespace StreamSplitter.Api.Filters
{
/// <summary>
/// Swashbuckle operation filter that replaces the body parameter on the
/// <c>ImportFromFile</c> action with a multipart/form-data file picker,
/// enabling file upload directly from the Swagger UI.
/// </summary>
public class FileUploadOperationFilter : IOperationFilter
{
#region [ Methods ]

/// <inheritdoc />
public void Apply(Operation operation, SchemaRegistry schemaRegistry, ApiDescription apiDescription)
{
bool isImport =
apiDescription.ActionDescriptor.ControllerDescriptor.ControllerName == "Connections"
&& apiDescription.ActionDescriptor.ActionName == "ImportFromFile";

if (!isImport)
return;

operation.consumes = new List<string> { "multipart/form-data" };
operation.parameters = new List<Parameter>
{
new Parameter
{
name = "file",
@in = "formData",
required = true,
type = "file",
description = "Configuration file (.s3config) exported from StreamSplitterManager."
}
};
}

#endregion
}
}
122 changes: 122 additions & 0 deletions Source/Applications/StreamSplitter/Api/Models/ConnectionDto.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
//******************************************************************************************************
// ConnectionDto.cs - Gbtc
//
// Copyright © 2026, Grid Protection Alliance. All Rights Reserved.
//
// Licensed to the Grid Protection Alliance (GPA) under one or more contributor license agreements. See
// the NOTICE file distributed with this work for additional information regarding copyright ownership.
// The GPA licenses this file to you under the Eclipse Public License -v 1.0 (the "License"); you may
// not use this file except in compliance with the License. You may obtain a copy of the License at:
//
// http://www.opensource.org/licenses/eclipse-1.0.php
//
// Unless agreed to in writing, the subject software distributed under the License is distributed on an
// "AS-IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. Refer to the
// License for the specific language governing permissions and limitations.
//
// Code Modification History:
// ----------------------------------------------------------------------------------------------------
// 06/01/2026 - Marcos Vinicius Snak
// Generated original version of source code.
//
//******************************************************************************************************

using System;
using GSF;
using StreamSplitter;

namespace StreamSplitter.Api.Models
{
/// <summary>
/// Read-only data transfer object representing a <see cref="ProxyConnection"/>.
/// </summary>
public sealed class ConnectionDto
{
#region [ Constructors ]

private ConnectionDto()
{
}

#endregion

#region [ Properties ]

/// <summary>
/// Gets the unique identifier of the connection.
/// </summary>
public Guid Id { get; private set; }

/// <summary>
/// Gets the display name of the connection.
/// </summary>
public string Name { get; private set; }

/// <summary>
/// Gets a value indicating whether the connection is enabled.
/// </summary>
public bool Enabled { get; private set; }

/// <summary>
/// Gets the current <see cref="ConnectionState"/> of the connection.
/// </summary>
public ConnectionState ConnectionState { get; private set; }

/// <summary>
/// Gets a human-readable description of the current connection state.
/// </summary>
public string ConnectionStateDescription { get; private set; }

/// <summary>
/// Gets the raw GSF connection string.
/// </summary>
public string ConnectionString { get; private set; }

/// <summary>
/// Gets the source-side settings extracted from the connection string.
/// </summary>
public string SourceSettings { get; private set; }

/// <summary>
/// Gets the proxy-side settings extracted from the connection string.
/// </summary>
public string ProxySettings { get; private set; }

#endregion

#region [ Static ]

// Static Methods

/// <summary>
/// Creates a new <see cref="ConnectionDto"/> from a <see cref="ProxyConnection"/> and its
/// runtime <see cref="ConnectionState"/>.
/// </summary>
/// <param name="connection">Source <see cref="ProxyConnection"/> to map from.</param>
/// <param name="runtimeState">
/// Live <see cref="ConnectionState"/> read from the associated <see cref="StreamProxy"/>.
/// Pass <see cref="ConnectionState.Disabled"/> when no live proxy exists.
/// </param>
/// <returns>A populated <see cref="ConnectionDto"/>.</returns>
/// <exception cref="ArgumentNullException"><paramref name="connection"/> is <c>null</c>.</exception>
public static ConnectionDto FromProxyConnection(ProxyConnection connection, ConnectionState runtimeState)
{
if (connection is null)
throw new ArgumentNullException(nameof(connection));

return new ConnectionDto
{
Id = connection.ID,
Name = connection.Name,
Enabled = connection.Enabled,
ConnectionState = runtimeState,
ConnectionStateDescription = runtimeState.GetDescription(),
ConnectionString = connection.ConnectionString,
SourceSettings = connection.SourceSettings,
ProxySettings = connection.ProxySettings
};
}

#endregion
}
}
121 changes: 121 additions & 0 deletions Source/Applications/StreamSplitter/Api/Models/ConnectionStatusDto.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
//******************************************************************************************************
// ConnectionStatusDto.cs - Gbtc
//
// Copyright © 2026, Grid Protection Alliance. All Rights Reserved.
//
// Licensed to the Grid Protection Alliance (GPA) under one or more contributor license agreements. See
// the NOTICE file distributed with this work for additional information regarding copyright ownership.
// The GPA licenses this file to you under the Eclipse Public License -v 1.0 (the "License"); you may
// not use this file except in compliance with the License. You may obtain a copy of the License at:
//
// http://www.opensource.org/licenses/eclipse-1.0.php
//
// Unless agreed to in writing, the subject software distributed under the License is distributed on an
// "AS-IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. Refer to the
// License for the specific language governing permissions and limitations.
//
// Code Modification History:
// ----------------------------------------------------------------------------------------------------
// 06/08/2026 - Marcos Vinicius Snak
// Generated original version of source code.
//
//******************************************************************************************************

using System;
using GSF;

namespace StreamSplitter.Api.Models
{
/// <summary>
/// Lightweight data transfer object representing the current operational status of a
/// <see cref="ProxyConnection"/> and its associated <see cref="StreamProxy"/>.
/// Returned by <c>GET /api/connections/{id}/status</c>.
/// </summary>
public sealed class ConnectionStatusDto
{
#region [ Properties ]

/// <summary>Gets the unique identifier of the connection.</summary>
public Guid Id { get; private set; }

/// <summary>Gets the display name of the connection.</summary>
public string Name { get; private set; }

/// <summary>Gets a value indicating whether the connection is enabled in configuration.</summary>
public bool Enabled { get; private set; }

/// <summary>Gets the current runtime <see cref="ConnectionState"/> of the connection.</summary>
public ConnectionState ConnectionState { get; private set; }

/// <summary>Gets a human-readable description of the current connection state.</summary>
public string ConnectionStateDescription { get; private set; }

/// <summary>
/// Gets the source connection endpoint in the format <c>host:port/accessID</c>.
/// <c>null</c> when no live <see cref="StreamProxy"/> exists (e.g. connection is disabled).
/// </summary>
public string ConnectionInfo { get; private set; }

/// <summary>
/// Gets the total number of bytes sent to downstream clients since the proxy started.
/// Zero when no live <see cref="StreamProxy"/> exists.
/// </summary>
public long TotalBytesSent { get; private set; }

/// <summary>
/// Gets the total active run time of the proxy in seconds.
/// Zero when no live <see cref="StreamProxy"/> exists.
/// </summary>
public double RunTime { get; private set; }

/// <summary>
/// Gets the most recent status messages produced by the proxy (up to 2 048 characters).
/// <c>null</c> when no live <see cref="StreamProxy"/> exists.
/// </summary>
public string RecentStatusMessages { get; private set; }

#endregion

#region [ Static ]

// Static Methods

/// <summary>
/// Creates a <see cref="ConnectionStatusDto"/> from the provided service-layer objects.
/// </summary>
/// <param name="id">Connection identifier.</param>
/// <param name="connection">
/// <see cref="ProxyConnection"/> that holds the configuration. Must not be <c>null</c>.
/// </param>
/// <param name="splitter">
/// Live <see cref="StreamProxy"/> associated with <paramref name="connection"/>,
/// or <c>null</c> when the connection is disabled or not yet materialized.
/// </param>
/// <returns>A populated <see cref="ConnectionStatusDto"/>.</returns>
/// <exception cref="ArgumentNullException">
/// <paramref name="connection"/> is <c>null</c>.
/// </exception>
public static ConnectionStatusDto FromServiceHost(Guid id, ProxyConnection connection, StreamProxy splitter)
{
if (connection is null)
throw new ArgumentNullException(nameof(connection));

ConnectionState state = splitter?.StreamProxyStatus.ConnectionState ?? ConnectionState.Disabled;

return new ConnectionStatusDto
{
Id = id,
Name = connection.Name,
Enabled = connection.Enabled,
ConnectionState = state,
ConnectionStateDescription = state.GetDescription(),
ConnectionInfo = splitter?.ConnectionInfo,
TotalBytesSent = splitter?.TotalBytesSent ?? 0L,
RunTime = (double)(splitter?.RunTime ?? 0.0D),
RecentStatusMessages = splitter?.StreamProxyStatus.RecentStatusMessages
};
}

#endregion
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
//******************************************************************************************************
// CreateConnectionRequest.cs - Gbtc
//
// Copyright © 2026, Grid Protection Alliance. All Rights Reserved.
//
// Licensed to the Grid Protection Alliance (GPA) under one or more contributor license agreements. See
// the NOTICE file distributed with this work for additional information regarding copyright ownership.
// The GPA licenses this file to you under the Eclipse Public License -v 1.0 (the "License"); you may
// not use this file except in compliance with the License. You may obtain a copy of the License at:
//
// http://www.opensource.org/licenses/eclipse-1.0.php
//
// Unless agreed to in writing, the subject software distributed under the License is distributed on an
// "AS-IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. Refer to the
// License for the specific language governing permissions and limitations.
//
// Code Modification History:
// ----------------------------------------------------------------------------------------------------
// 06/05/2026 - Marcos Vinicius Snak
// Generated original version of source code.
//
//******************************************************************************************************

namespace StreamSplitter.Api.Models
{
/// <summary>
/// Request body for creating a new proxy connection via the REST API.
/// </summary>
public class CreateConnectionRequest
{
#region [ Properties ]

/// <summary>
/// Gets or sets the full GSF connection string (key=value pairs).
/// The string must include all required parameters such as name, enabled,
/// sourceSettings and proxySettings embedded in the standard GSF format.
/// This is the only required field; all other connection attributes are
/// parsed from it automatically.
/// </summary>
public string ConnectionString { get; set; }

#endregion
}
}
Loading