frostfs-sdk-csharp/src/FrostFS.SDK.ClientV2/Mappers/Container.cs
Pavel Gross c988ff3c76 [#11] Add Network Snapshot
Signed-off-by: Pavel Gross <p.gross@yadro.com>
2024-06-26 12:29:33 +03:00

36 lines
1.1 KiB
C#

using System;
using Google.Protobuf;
using FrostFS.SDK.ClientV2.Mappers.GRPC.Netmap;
using FrostFS.SDK.Cryptography;
using FrostFS.SDK.ModelsV2.Enums;
namespace FrostFS.SDK.ClientV2.Mappers.GRPC;
public static class ContainerMapper
{
public static Container.Container ToGrpcMessage(this ModelsV2.Container container)
{
return new Container.Container
{
BasicAcl = (uint)container.BasicAcl,
PlacementPolicy = container.PlacementPolicy.ToGrpcMessage(),
Nonce = ByteString.CopyFrom(container.Nonce.ToBytes())
};
}
public static ModelsV2.Container ToModel(this Container.Container container)
{
if (!Enum.IsDefined(typeof(BasicAcl),(int)container.BasicAcl))
throw new ArgumentException($"Unknown BasicACL rule. Value: '{container.BasicAcl}'.");
BasicAcl acl = (BasicAcl)container.BasicAcl;
return new ModelsV2.Container(acl, container.PlacementPolicy.ToModel())
{
Nonce = container.Nonce.ToUuid(),
Version = container.Version.ToModel()
};
}
}