frostfs-sdk-csharp/src/FrostFS.SDK.ClientV2/Mappers/GRPC/Netmap/NodeInfo.cs
Ivan Pchelintsev 6f24f567c1 [#1] Remove unnecessary layer
Signed-off-by: Ivan Pchelintsev <i.pchelintsev@yadro.com>
2024-05-22 14:29:20 +03:00

21 lines
No EOL
668 B
C#

using FrostFS.SDK.ModelsV2.Enums;
using FrostFS.SDK.ModelsV2.Netmap;
namespace FrostFS.SDK.ClientV2.Mappers.GRPC.Netmap;
public static class NodeInfoMapper
{
public static NodeInfo ToModel(this FrostFS.Netmap.LocalNodeInfoResponse.Types.Body nodeInfo)
{
var nodeStateName = Enum.GetName(typeof(NodeState), nodeInfo.NodeInfo.State);
if (nodeStateName is null)
{
throw new ArgumentException($"Unknown NodeState. Value: '{nodeInfo.NodeInfo.State}'.");
}
return new NodeInfo
{
State = Enum.Parse<NodeState>(nodeStateName),
Version = nodeInfo.Version.ToModel()
};
}
}