36 lines
1.1 KiB
C#
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()
|
|
};
|
|
}
|
|
}
|