All checks were successful
DCO / DCO (pull_request) Successful in 33s
Signed-off-by: Pavel Gross <p.gross@yando.com>
35 lines
No EOL
1.1 KiB
C#
35 lines
No EOL
1.1 KiB
C#
using System;
|
|
using System.Linq;
|
|
|
|
using FrostFS.Netmap;
|
|
using FrostFS.SDK.ClientV2.Mappers.GRPC;
|
|
|
|
namespace FrostFS.SDK.ClientV2;
|
|
|
|
public static class NodeInfoMapper
|
|
{
|
|
public static FrostFsNodeInfo ToModel(this LocalNodeInfoResponse.Types.Body node)
|
|
{
|
|
return node.NodeInfo.ToModel(node.Version);
|
|
}
|
|
|
|
public static FrostFsNodeInfo ToModel(this NodeInfo nodeInfo, Refs.Version version)
|
|
{
|
|
NodeState state = nodeInfo.State switch
|
|
{
|
|
NodeInfo.Types.State.Unspecified => NodeState.Unspecified,
|
|
NodeInfo.Types.State.Online => NodeState.Online,
|
|
NodeInfo.Types.State.Offline => NodeState.Offline,
|
|
NodeInfo.Types.State.Maintenance => NodeState.Maintenance,
|
|
_ => throw new ArgumentException($"Unknown NodeState. Value: '{nodeInfo.State}'.")
|
|
};
|
|
|
|
return new FrostFsNodeInfo(
|
|
version: version.ToModel(),
|
|
state: state,
|
|
addresses: [.. nodeInfo.Addresses],
|
|
attributes: nodeInfo.Attributes.ToDictionary(n => n.Key, n => n.Value),
|
|
publicKey: nodeInfo.PublicKey.ToByteArray()
|
|
);
|
|
}
|
|
} |