[#24] Client: Add Ape manager
Signed-off-by: Pavel Gross <p.gross@yadro.com>
This commit is contained in:
parent
704ce41173
commit
d7dbbf8da8
21 changed files with 411 additions and 381 deletions
37
src/FrostFS.SDK.ClientV2/Models/Chain/ChainTarget.cs
Normal file
37
src/FrostFS.SDK.ClientV2/Models/Chain/ChainTarget.cs
Normal file
|
@ -0,0 +1,37 @@
|
|||
using System;
|
||||
|
||||
using Frostfs.V2.Ape;
|
||||
|
||||
namespace FrostFS.SDK.ClientV2
|
||||
{
|
||||
public struct FrostFsChainTarget(FrostFsTargetType type, string name)
|
||||
{
|
||||
private ChainTarget? chainTarget;
|
||||
|
||||
public FrostFsTargetType Type { get; } = type;
|
||||
|
||||
public string Name { get; } = name;
|
||||
|
||||
internal ChainTarget GetChainTarget()
|
||||
{
|
||||
return chainTarget ??= new ChainTarget
|
||||
{
|
||||
Type = GetTargetType(Type),
|
||||
Name = Name
|
||||
};
|
||||
}
|
||||
|
||||
private static TargetType GetTargetType(FrostFsTargetType type)
|
||||
{
|
||||
return type switch
|
||||
{
|
||||
FrostFsTargetType.Undefined => TargetType.Undefined,
|
||||
FrostFsTargetType.Namespace => TargetType.Namespace,
|
||||
FrostFsTargetType.Container => TargetType.Container,
|
||||
FrostFsTargetType.User => TargetType.User,
|
||||
FrostFsTargetType.Group => TargetType.Group,
|
||||
_ => throw new ArgumentException("Unexpected value for TargetType", nameof(type)),
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
16
src/FrostFS.SDK.ClientV2/Models/Chain/FrostFsChain.cs
Normal file
16
src/FrostFS.SDK.ClientV2/Models/Chain/FrostFsChain.cs
Normal file
|
@ -0,0 +1,16 @@
|
|||
using Google.Protobuf;
|
||||
|
||||
namespace FrostFS.SDK.ClientV2
|
||||
{
|
||||
public struct FrostFsChain (byte[] raw)
|
||||
{
|
||||
private ByteString? grpcRaw;
|
||||
|
||||
public byte[] Raw { get; } = raw;
|
||||
|
||||
internal ByteString GetRaw()
|
||||
{
|
||||
return grpcRaw ??= ByteString.CopyFrom(Raw);
|
||||
}
|
||||
}
|
||||
}
|
11
src/FrostFS.SDK.ClientV2/Models/Chain/FrostFsTargetType.cs
Normal file
11
src/FrostFS.SDK.ClientV2/Models/Chain/FrostFsTargetType.cs
Normal file
|
@ -0,0 +1,11 @@
|
|||
namespace FrostFS.SDK.ClientV2
|
||||
{
|
||||
public enum FrostFsTargetType
|
||||
{
|
||||
Undefined = 0,
|
||||
Namespace,
|
||||
Container,
|
||||
User,
|
||||
Group
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue