0765eb4de3
Seventh PR of the alarms-over-gateway epic (docs/plans/alarms-over-gateway.md). Depends on PR A.1 (proto, merged) and E.1 (regen, merged). Hand-written .NET SDK methods on top of the regenerated proto types: - MxGatewayClient.AcknowledgeAlarmAsync — routes through the existing safe-unary retry pipeline (Acks are idempotent at MxAccess), maps Unauthenticated/PermissionDenied RpcExceptions to typed MxGatewayAuthenticationException / MxGatewayAuthorizationException via GrpcMxGatewayClientTransport.MapRpcException. - MxGatewayClient.QueryActiveAlarmsAsync — server-streaming IAsyncEnumerable<ActiveAlarmSnapshot> mirroring the StreamEvents pattern. - IMxGatewayClientTransport extended; GrpcMxGatewayClientTransport implements both methods using the regenerated grpc client. - FakeGatewayTransport extended with capture lists, exception queue, and reply / snapshot enqueue helpers. CLI version-string assertions updated for the GatewayProtocolVersion 2 → 3 bump from A.1. The CLI alarms verb (subscribe / acknowledge / query-active) is deferred to a follow-up — keeping this PR focused on the SDK surface that lmxopcua's GalaxyDriver consumes in PR B.2. The other-language SDKs (E.3-E.6) layer the same shape on the regen. Tests: - 6 new MxGatewayClientAlarmsTests — request shape, cancellation honor (linked-token via retry pipeline), Unauthenticated mapping, streaming snapshot enumeration, filter prefix passthrough, cancellation during enumeration. - Full client test suite: 57 passed (was 51; 6 new). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
79 lines
2.8 KiB
C#
79 lines
2.8 KiB
C#
using Grpc.Core;
|
|
using MxGateway.Contracts.Proto;
|
|
|
|
namespace MxGateway.Client;
|
|
|
|
internal interface IMxGatewayClientTransport
|
|
{
|
|
/// <summary>
|
|
/// Gets the client configuration options.
|
|
/// </summary>
|
|
MxGatewayClientOptions Options { get; }
|
|
|
|
/// <summary>
|
|
/// Gets the underlying gRPC client, if available.
|
|
/// </summary>
|
|
MxAccessGateway.MxAccessGatewayClient? RawClient { get; }
|
|
|
|
/// <summary>
|
|
/// Opens a new gateway session.
|
|
/// </summary>
|
|
/// <param name="request">Session open request.</param>
|
|
/// <param name="callOptions">gRPC call options.</param>
|
|
/// <returns>The session open reply.</returns>
|
|
Task<OpenSessionReply> OpenSessionAsync(
|
|
OpenSessionRequest request,
|
|
CallOptions callOptions);
|
|
|
|
/// <summary>
|
|
/// Closes an open gateway session.
|
|
/// </summary>
|
|
/// <param name="request">Session close request.</param>
|
|
/// <param name="callOptions">gRPC call options.</param>
|
|
/// <returns>The session close reply.</returns>
|
|
Task<CloseSessionReply> CloseSessionAsync(
|
|
CloseSessionRequest request,
|
|
CallOptions callOptions);
|
|
|
|
/// <summary>
|
|
/// Invokes an MXAccess command on the session.
|
|
/// </summary>
|
|
/// <param name="request">The command request.</param>
|
|
/// <param name="callOptions">gRPC call options.</param>
|
|
/// <returns>The command reply.</returns>
|
|
Task<MxCommandReply> InvokeAsync(
|
|
MxCommandRequest request,
|
|
CallOptions callOptions);
|
|
|
|
/// <summary>
|
|
/// Streams events from the session.
|
|
/// </summary>
|
|
/// <param name="request">The stream events request.</param>
|
|
/// <param name="callOptions">gRPC call options.</param>
|
|
/// <returns>An async enumerable of events.</returns>
|
|
IAsyncEnumerable<MxEvent> StreamEventsAsync(
|
|
StreamEventsRequest request,
|
|
CallOptions callOptions);
|
|
|
|
/// <summary>
|
|
/// Acknowledges an active MXAccess alarm condition.
|
|
/// </summary>
|
|
/// <param name="request">The acknowledge request.</param>
|
|
/// <param name="callOptions">gRPC call options.</param>
|
|
/// <returns>The acknowledge reply with native MxStatus.</returns>
|
|
Task<AcknowledgeAlarmReply> AcknowledgeAlarmAsync(
|
|
AcknowledgeAlarmRequest request,
|
|
CallOptions callOptions);
|
|
|
|
/// <summary>
|
|
/// Streams a snapshot of all alarms currently in Active or ActiveAcked state — the
|
|
/// ConditionRefresh equivalent for the gateway.
|
|
/// </summary>
|
|
/// <param name="request">The query request, optionally scoped by alarm-reference prefix.</param>
|
|
/// <param name="callOptions">gRPC call options.</param>
|
|
/// <returns>An async enumerable of active-alarm snapshots.</returns>
|
|
IAsyncEnumerable<ActiveAlarmSnapshot> QueryActiveAlarmsAsync(
|
|
QueryActiveAlarmsRequest request,
|
|
CallOptions callOptions);
|
|
}
|